#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 */

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  system("CLS");
  srand(time(NULL));
  int n = rand() % 100 + 1;
  char answer[10];
  printf("\nConsole: Welcome to Guess-that-number game. I have picked a number "
         "in [1, 100]. Please make a guess.\nUser: ");
  fgets(answer, 10, stdin);
  answer[strlen(answer) - 1] = '\0';
  while (strtol(answer, NULL, 10) != n) {
    if (strcmp(answer, "exit") == 0) {
      printf("Console: <Program terminates>");
      return 0;
    } else if (strtol(answer, NULL, 10) == 0L) {
      printf("Console: Wrong. That is not a number.\n");
    } else if (strtol(answer, NULL, 10) > n) {
      printf("Console: Wrong. That number is above my number.\n");
    } else {
      printf("Console: Wrong. That number is below my number.\n");
    }
    printf("User: ");
    fgets(answer, 10, stdin);
    answer[strlen(answer) - 1] = '\0';
  }
  printf("Console: Correct! That is my number! <Program terminates>");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
lea    -0x12(%rbp),%rdi
mov    0x2e01(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <fgets@plt>
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x12(%rbp,%rax,1)
lea    -0x12(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
cmp    -0x8(%rbp),%eax
je     12ff <main+0x16f>
lea    -0x12(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1253 <main+0xc3>
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    130b <main+0x17b>
lea    -0x12(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
cltq
cmp    $0x0,%rax
jne    1282 <main+0xf2>
lea    0xe1c(%rip),%rdi
call   1050 <printf@plt>
jmp    12bf <main+0x12f>
lea    -0x12(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
cmp    -0x8(%rbp),%eax
jle    12ae <main+0x11e>
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
jmp    12ba <main+0x12a>
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
jmp    12bf <main+0x12f>
jmp    12c4 <main+0x134>
lea    0xd9f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x12(%rbp),%rdi
mov    0x2d0d(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <fgets@plt>
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x12(%rbp,%rax,1)
jmp    1206 <main+0x76>
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe4b(%rip),%rdi
call   1050 <system@plt>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
lea    0xe0d(%rip),%rdi
call   1060 <printf@plt>
mov    0x2de5(%rip),%r13
mov    0x0(%r13),%edx
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
lea    0xe56(%rip),%rdi
cmp    %ebp,%eax
je     12fc <main+0x15c>
lea    0xe24(%rip),%r15
lea    0xeda(%rip),%r14
lea    0xe0f(%rip),%r12
jmp    12a0 <main+0x100>
nopl   (%rax)
call   1030 <puts@plt>
mov    %r12,%rdi
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
cmp    %ebp,%eax
je     12ec <main+0x14c>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     12f5 <main+0x155>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
mov    %r14,%rdi
test   %eax,%eax
je     1260 <main+0xc0>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
lea    0xe22(%rip),%rdi
cmp    %ebp,%eax
jg     1260 <main+0xc0>
lea    0xde7(%rip),%rdi
jmp    1260 <main+0xc0>
lea    0xda1(%rip),%rdi
jmp    12fc <main+0x15c>
lea    0xd7a(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"CLS\00"
@.str.1 = [109 x i8] c"\0AConsole: Welcome to Guess-that-number game. I have picked a number in [1, 100]. Please make a guess.\0AUser: \00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [30 x i8] c"Console: <Program terminates>\00"
@.str.4 = [39 x i8] c"Console: Wrong. That is not a number.\0A\00"
@.str.5 = [49 x i8] c"Console: Wrong. That number is above my number.\0A\00"
@.str.6 = [49 x i8] c"Console: Wrong. That number is below my number.\0A\00"
@.str.7 = [7 x i8] c"User: \00"
@.str.8 = [58 x i8] c"Console: Correct! That is my number! <Program terminates>\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 0, i32* %1
%4 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 100
%9 = add nsw i32 %8, 1
store i32 %9, i32* %2
%10 = call i32 @printf(i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 10, i32 %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %17
store i8 0, i8* %18
br label %19
19: ; preds = %48, %0
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%21 = call i32 @strtol(i8* %20, i32* null, i32 10)
%22 = load i32, i32* %2
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %58
24: ; preds = %19
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %60
30: ; preds = %24
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%32 = call i32 @strtol(i8* %31, i32* null, i32 10)
%33 = sext i32 %32 to i64
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %47
37: ; preds = %30
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%39 = call i32 @strtol(i8* %38, i32* null, i32 10)
%40 = load i32, i32* %2
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %46
44: ; preds = %37
%45 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46, %35
br label %48
48: ; preds = %47
%49 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%50 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%51 = load i32, i32* @stdin
%52 = call i32 @fgets(i8* %50, i32 10, i32 %51)
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%54 = call i32 @strlen(i8* %53)
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %56
store i8 0, i8* %57
br label %19
58: ; preds = %19
%59 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
br label %60
60: ; preds = %58, %28
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@.str = [4 x i8] c"CLS\00"
@.str.1 = [109 x i8] c"\0AConsole: Welcome to Guess-that-number game. I have picked a number in [1, 100]. Please make a guess.\0AUser: \00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [30 x i8] c"Console: <Program terminates>\00"
@.str.7 = [7 x i8] c"User: \00"
@.str.8 = [58 x i8] c"Console: Correct! That is my number! <Program terminates>\00"
@str = [48 x i8] c"Console: Wrong. That number is below my number.\00"
@str.9 = [48 x i8] c"Console: Wrong. That number is above my number.\00"
@str.10 = [38 x i8] c"Console: Wrong. That is not a number.\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = add nsw i32 %6, 1
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %8, i32 10, i32 %10)
%12 = call i32 @strlen(i8* %8)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 @strtol(i8* nocapture %8, i32* null, i32 10)
%17 = icmp eq i32 %16, %7
br i1 %17, label %40, label %18
18: ; preds = %0, %28
%19 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %40, label %21
21: ; preds = %18
%22 = call i32 @strtol(i8* nocapture %8, i32* null, i32 10)
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = call i32 @strtol(i8* nocapture %8, i32* null, i32 10)
%26 = icmp sgt i32 %25, %7
%27 = select i1 %26, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0)
br label %28
28: ; preds = %24, %21
%29 = phi i8* [ getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0), %21 ], [ %27, %24 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%32 = load i32, i32* @stdin
%33 = call i32 @fgets(i8* %8, i32 10, i32 %32)
%34 = call i32 @strlen(i8* %8)
%35 = add nsw i32 %34, -1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %36
store i8 0, i8* %37
%38 = call i32 @strtol(i8* nocapture %8, i32* null, i32 10)
%39 = icmp eq i32 %38, %7
br i1 %39, label %40, label %18
40: ; preds = %28, %18, %0
%41 = phi i8* [ getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), %0 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), %28 ]
%42 = call i32 @printf(i8* dereferenceable(1) %41)
ret i32 0
}