Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Software The following software was procured by the US government. They believ

ID: 3546616 • Letter: C

Question

C Software

The following software was procured by the US government. They believe that there are several registers used to communicate a secret message for the CIA. The key is that they need to provide the CIA with the exact contents of the registers.

However, terrorists have hacked into every C compiler on the planet, so there is no way to run the code. They need you to show them the register contents step by step after each line of code is executed.


#include <stdio.h>


main()

{

unsigned long var1 = 0x1BA5; /* Register 1 */

unsigned long var2 = 0x1B2C; /* Register 2 */

unsigned long var3 = 0x0025; /* Register 3 */

unsigned long var4; /* Register 4 */

unsigned long var5; /* Register 5 */


var4 = var1 + var3;

var5 = var2 - var3;

var1 = var1 << 5;

var2 = var2 >> 10;

var1 = var1 & 0xFF00;

var3 = var3 | 0x830F;

var5 = var5 ^ 0x246A;

var4++;

var1--;


if (var5 < var4)

{

var5 = var4;

}

else

{

var4 = var5;

}

}




Explanation / Answer

#include <stdio.h>

int main(){
unsigned long var1 = 0x1BA5; /* Register 1 */
unsigned long var2 = 0x1B2C; /* Register 2 */
unsigned long var3 = 0x0025; /* Register 3 */
unsigned long var4; /* Register 4 */
unsigned long var5; /* Register 5 */
var4 = var1 + var3;
printf("After :- var4 = var1 + var3; ");
printf("Var1=%x ",var1);
printf("Var2=%x ",var2);
printf("Var3=%x ",var3);
printf("Var4=%x ",var4);
printf("Var5=%x ",var5);

printf("After :- var5 = var2