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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ welcome();
int main() {
  int mnum = 45, gnum, tries = 0, score = 100;
  FILE *hscore;
  welcome();
  do {
    printf("Enter your guess: ");
    scanf("%d", &gnum);
    tries++;
    if (gnum == mnum) {
      printf("You've guessed the right number\n");
      printf("Number of tries: %d\n", tries);
      if (score < 100) {
        score++;
      } else {
        score = 100;
      }
      printf("Score: %d\n", score);
      printf("Game Over!");
      hscore = fopen("score.txt", "w");
      fprintf(hscore, "HIGH SCORES\n");
      fprintf(hscore, "Score: %d\n", score);
      fclose(hscore);
    } else {
      printf("You've guessed the wrong number.\n");
      if (gnum > mnum)
        printf("Your guess is too high\n");
      else
        printf("Your guess is too low\n");
      printf("Number of tries: %d\n", tries);
      score--;
      printf("Score: %d\n", score);
    }
  } while (gnum != mnum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2d,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
mov    $0x0,%al
call   1060 <welcome@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1267 <main+0x107>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x64,-0x14(%rbp)
jge    11f5 <main+0x95>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fc <main+0x9c>
movl   $0x64,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
lea    0xe43(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12cd <main+0x16d>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1294 <main+0x134>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a2 <main+0x142>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d2 <main+0x172>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    118b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <welcome@plt>
mov    $0x1,%ebx
lea    0xe62(%rip),%r15
lea    0xe6e(%rip),%r13
lea    0x4(%rsp),%r12
lea    0xe65(%rip),%rbp
mov    $0x64,%r14d
jmp    1217 <main+0x97>
nopl   0x0(%rax)
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x2e,0x4(%rsp)
lea    0xea1(%rip),%rdi
lea    0xeb0(%rip),%rax
cmovge %rax,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%r14d
lea    0xe2c(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmpl   $0x2d,0x4(%rsp)
je     12db <main+0x15b>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
cmpl   $0x2d,0x4(%rsp)
jne    11c0 <main+0x40>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%r14),%r15d
cmp    $0x64,%r14d
mov    $0x64,%eax
cmovge %eax,%r15d
lea    0xdc8(%rip),%r14
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdbf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdbc(%rip),%rdi
lea    0xe01(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbp
mov    $0xc,%esi
mov    $0x1,%edx
lea    0xda6(%rip),%rdi
mov    %rax,%rcx
call   10a0 <fwrite@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %r15d,%r14d
lea    0xd47(%rip),%rbp
lea    0xd2a(%rip),%r15
jmp    1209 <main+0x89>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter your guess: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"You've guessed the right number\0A\00"
@.str.3 = [21 x i8] c"Number of tries: %d\0A\00"
@.str.4 = [11 x i8] c"Score: %d\0A\00"
@.str.5 = [11 x i8] c"Game Over!\00"
@.str.6 = [10 x i8] c"score.txt\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [13 x i8] c"HIGH SCORES\0A\00"
@.str.9 = [34 x i8] c"You've guessed the wrong number.\0A\00"
@.str.10 = [24 x i8] c"Your guess is too high\0A\00"
@.str.11 = [23 x i8] c"Your guess is too low\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
store i32 45, i32* %2
store i32 0, i32* %4
store i32 100, i32* %5
%7 = call i32 (...) @welcome()
br label %8
8: ; preds = %55, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %38
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 100
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %26
25: ; preds = %16
store i32 100, i32* %5
br label %26
26: ; preds = %25, %22
%27 = load i32, i32* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%33 = load i32*, i32** %6
%34 = load i32, i32* %5
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = load i32*, i32** %6
%37 = call i32 @fclose(i32* %36)
br label %54
38: ; preds = %8
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%40 = load i32, i32* %3
%41 = load i32, i32* %2
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %47
45: ; preds = %38
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
%48 = load i32, i32* %4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %5
%51 = add nsw i32 %50, -1
store i32 %51, i32* %5
%52 = load i32, i32* %5
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %47, %26
br label %55
55: ; preds = %54
%56 = load i32, i32* %3
%57 = load i32, i32* %2
%58 = icmp ne i32 %56, %57
br i1 %58, label %8, label %59
59: ; preds = %55
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter your guess: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"Number of tries: %d\0A\00"
@.str.4 = [11 x i8] c"Score: %d\0A\00"
@.str.5 = [11 x i8] c"Game Over!\00"
@.str.6 = [10 x i8] c"score.txt\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [13 x i8] c"HIGH SCORES\0A\00"
@str = [33 x i8] c"You've guessed the wrong number.\00"
@str.12 = [22 x i8] c"Your guess is too low\00"
@str.13 = [23 x i8] c"Your guess is too high\00"
@str.14 = [32 x i8] c"You've guessed the right number\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @welcome()
br label %4
4: ; preds = %33, %0
%5 = phi i32 [ 100, %0 ], [ %34, %33 ]
%6 = phi i32 [ 0, %0 ], [ %9, %33 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = add nuw nsw i32 %6, 1
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %24
12: ; preds = %4
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.14, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%15 = icmp slt i32 %5, 100
%16 = add nsw i32 %5, 1
%17 = select i1 %15, i32 %16, i32 100
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%21 = call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i64 12, i64 1, i32* %20)
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%23 = call i32 @fclose(i32* %20)
br label %33
24: ; preds = %4
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, 45
%28 = select i1 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0)
%29 = call i32 @puts(i8* dereferenceable(1) %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%31 = add nsw i32 %5, -1
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %12, %24
%34 = phi i32 [ %17, %12 ], [ %31, %24 ]
%35 = load i32, i32* %1
%36 = icmp eq i32 %35, 45
br i1 %36, label %37, label %4
37: ; preds = %33
ret i32 0
}