#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int AddSub, num1, num2, ans, guess;
  time_t t;
  srand((unsigned)time(&t));
  AddSub = rand() % 2;
  if (AddSub == 1) {
    int num1 = rand() % 1000001;
    int num2 = rand() % 1000001;
    int ans = num1 + num2;
    printf("%d + %d = \n", num1, num2);
    scanf("%d", &guess);
    if (ans != guess) {
      printf("Incorrect answer! The correct answer was %d\n.You entered %d.",
             ans, guess);
    } else {
      printf("You've done it! Congratulations!\n");
    }
  } else {
    int num1 = rand() % 1000001;
    int num2 = rand() % 1000001;
    if (num1 > num2) {
      ans = num1 - num2;
      printf("%d - %d = \n", num1, num2);
    } else {
      ans = num2 - num1;
      printf("%d - %d = \n", num2, num1);
    }
    scanf("%d", &guess);
    if (ans != guess) {
      printf("Incorrect answer! The correct answer was %d.\nYou entered %d.\n",
             ans, guess);
    } else {
      printf("You've done it! Congratulations!\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    121b <main+0xcb>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xf4241,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xf4241,%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     1208 <main+0xb8>
mov    -0x34(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <main+0xc6>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d2 <main+0x182>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xf4241,%ecx
cltd
idiv   %ecx
mov    %edx,-0x38(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xf4241,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jle    126d <main+0x11d>
mov    -0x38(%rbp),%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128a <main+0x13a>
mov    -0x3c(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd7b(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     12bf <main+0x16f>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cd <main+0x17d>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d2 <main+0x182>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebp
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebp
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbx
imul   $0x431bda1d,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
imul   $0xf4241,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rdx
imul   $0x431bda1d,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
imul   $0xf4241,%eax,%eax
sub    %eax,%edx
cmp    $0x1,%ebp
jne    120a <main+0xaa>
lea    (%rdx,%rbx,1),%ebp
lea    0xe1e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%edx
cmp    %edx,%ebp
je     1247 <main+0xe7>
lea    0xe07(%rip),%rdi
jmp    125c <main+0xfc>
mov    %ebx,%ebp
sub    %edx,%ebp
jle    121b <main+0xbb>
lea    0xe35(%rip),%rdi
mov    %ebx,%esi
jmp    122a <main+0xca>
mov    %edx,%ebp
sub    %ebx,%ebp
lea    0xe26(%rip),%rdi
mov    %edx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%edx
cmp    %edx,%ebp
jne    1255 <main+0xf5>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
jmp    1265 <main+0x105>
lea    0xdfc(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d + %d = \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [61 x i8] c"Incorrect answer! The correct answer was %d\0A.You entered %d.\00"
@.str.3 = [34 x i8] c"You've done it! Congratulations!\0A\00"
@.str.4 = [12 x i8] c"%d - %d = \0A\00"
@.str.5 = [62 x i8] c"Incorrect answer! The correct answer was %d.\0AYou entered %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = call i64 @time(i32* %11)
%18 = trunc i64 %17 to i32
%19 = call i32 @srand(i32 %18)
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 2
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %46
24: ; preds = %2
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 1000001
store i32 %26, i32* %12
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 1000001
store i32 %28, i32* %13
%29 = load i32, i32* %12
%30 = load i32, i32* %13
%31 = add nsw i32 %29, %30
store i32 %31, i32* %14
%32 = load i32, i32* %12
%33 = load i32, i32* %13
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %33)
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%36 = load i32, i32* %14
%37 = load i32, i32* %10
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %43
39: ; preds = %24
%40 = load i32, i32* %14
%41 = load i32, i32* %10
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41)
br label %45
43: ; preds = %24
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
br label %80
46: ; preds = %2
%47 = call i32 (...) @rand()
%48 = srem i32 %47, 1000001
store i32 %48, i32* %15
%49 = call i32 (...) @rand()
%50 = srem i32 %49, 1000001
store i32 %50, i32* %16
%51 = load i32, i32* %15
%52 = load i32, i32* %16
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %61
54: ; preds = %46
%55 = load i32, i32* %15
%56 = load i32, i32* %16
%57 = sub nsw i32 %55, %56
store i32 %57, i32* %9
%58 = load i32, i32* %15
%59 = load i32, i32* %16
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %58, i32 %59)
br label %68
61: ; preds = %46
%62 = load i32, i32* %16
%63 = load i32, i32* %15
%64 = sub nsw i32 %62, %63
store i32 %64, i32* %9
%65 = load i32, i32* %16
%66 = load i32, i32* %15
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %65, i32 %66)
br label %68
68: ; preds = %61, %54
%69 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%70 = load i32, i32* %9
%71 = load i32, i32* %10
%72 = icmp ne i32 %70, %71
br i1 %72, label %73, label %77
73: ; preds = %68
%74 = load i32, i32* %9
%75 = load i32, i32* %10
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %74, i32 %75)
br label %79
77: ; preds = %68
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
br label %80
80: ; preds = %79, %45
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d + %d = \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [61 x i8] c"Incorrect answer! The correct answer was %d\0A.You entered %d.\00"
@.str.4 = [12 x i8] c"%d - %d = \0A\00"
@.str.5 = [62 x i8] c"Incorrect answer! The correct answer was %d.\0AYou entered %d.\0A\00"
@str.6 = [33 x i8] c"You've done it! Congratulations!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i64 @time(i32* %4)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 2
%12 = icmp eq i32 %11, 1
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 1000001
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 1000001
br i1 %12, label %17, label %27
17: ; preds = %2
%18 = add nsw i32 %16, %14
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %16)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = icmp eq i32 %18, %21
br i1 %22, label %25, label %23
23: ; preds = %17
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %21)
br label %44
25: ; preds = %17
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.6, i64 0, i64 0))
br label %44
27: ; preds = %2
%28 = icmp sgt i32 %14, %16
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = sub nsw i32 %14, %16
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %14, i32 %16)
br label %35
32: ; preds = %27
%33 = sub nsw i32 %16, %14
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %14)
br label %35
35: ; preds = %32, %29
%36 = phi i32 [ %30, %29 ], [ %33, %32 ]
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%38 = load i32, i32* %3
%39 = icmp eq i32 %36, %38
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %36, i32 %38)
br label %44
42: ; preds = %35
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.6, i64 0, i64 0))
br label %44
44: ; preds = %40, %42, %23, %25
ret i32 0
}