#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 EXIT_SUCCESS;
int atoi(char *);
scalar_t__ check_digits(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fscanf(int /*<<< orphan*/, char *, char **);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int r_number;
  char guess[20] = "";
  int i, res, guess_num;
  srand(time(NULL));
  for (i = 0; i < 10; i++) {
    r_number = rand() % 100 + 1;
    do {
      puts("Make a guess:");
      res = fscanf(stdin, "%s", &guess);
      if (check_digits(guess)) {
        guess_num = atoi(guess);
        break;
      }
    } while (1);
    fprintf(stdout, "FSCANF: %d\n", res);
    if (r_number > guess_num)
      fprintf(stdout, "%s", (i == 10 - 1) ? "" : "Go up!\n");
    else if (r_number < guess_num)
      fprintf(stdout, "%s", (i == 10 - 1) ? "" : "Go down!\n");
    else {
      fprintf(stdout, "Congratulations! You win. [%d]. Points: %d", r_number,
              100 - (i * 10));
      break;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
      ;
    }
  }
  if (r_number != guess_num)
    fprintf(stdout, "You lost! The number was %d.\n", r_number);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    1321 <main+0x191>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rdx
lea    0xe09(%rip),%rsi
call   1060 <fscanf@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <check_digits@plt>
cmp    $0x0,%rax
je     1231 <main+0xa1>
lea    -0x20(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    1245 <main+0xb5>
jmp    1236 <main+0xa6>
mov    $0x1,%al
test   $0x1,%al
jne    11e5 <main+0x55>
jmp    1245 <main+0xb5>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    129f <main+0x10f>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xd9f(%rip),%rdx
lea    0xda9(%rip),%rax
cmp    $0x9,%ecx
cmove  %rax,%rdx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    130e <main+0x17e>
mov    -0x8(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12df <main+0x14f>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%ecx
lea    0xd67(%rip),%rdx
lea    0xd69(%rip),%rax
cmp    $0x9,%ecx
cmove  %rax,%rdx
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1309 <main+0x179>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
imul   $0xa,-0x24(%rbp),%eax
mov    $0x64,%ecx
sub    %eax,%ecx
lea    0xd32(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1321 <main+0x191>
jmp    130e <main+0x17e>
jmp    1313 <main+0x183>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c6 <main+0x36>
mov    -0x8(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     1347 <main+0x1b7>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xd1a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe4d(%rip),%r14
mov    0x2e2e(%rip),%r13
lea    0xe4d(%rip),%r15
lea    0x20(%rsp),%rbx
xor    %ebp,%ebp
jmp    1202 <main+0x82>
nopw   0x0(%rax,%rax,1)
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rbp
cmp    $0x9,%ebp
lea    0xe46(%rip),%rax
cmove  %rax,%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
je     12d9 <main+0x159>
mov    %rbp,0x10(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbp
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0x0(%r13),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1040 <check_digits@plt>
test   %rax,%rax
je     1230 <main+0xb0>
lea    0x1(%rbp),%eax
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %rbp,0x18(%rsp)
mov    %eax,%ebp
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xd8f(%rip),%rdx
mov    %ebp,%r12d
cmp    %ebp,0x18(%rsp)
jge    11d0 <main+0x50>
lea    0xd83(%rip),%rdx
cmp    %r12d,0xc(%rsp)
jl     11d0 <main+0x50>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rsp),%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    $0x64,%ecx
sub    %eax,%ecx
lea    0xd61(%rip),%rsi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    %r12d,0xc(%rsp)
je     12fb <main+0x17b>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Make a guess:\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.2 = [12 x i8] c"FSCANF: %d\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [8 x i8] c"Go up!\0A\00"
@.str.5 = [10 x i8] c"Go down!\0A\00"
@.str.6 = [43 x i8] c"Congratulations! You win. [%d]. Points: %d\00"
@.str.7 = [30 x i8] c"You lost! The number was %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [20 x i8]* %3 to i8*
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %4
br label %10
10: ; preds = %64, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %67
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 100
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %17
17: ; preds = %29, %13
%18 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = bitcast [20 x i8]* %3 to i8**
%21 = call i32 @fscanf(i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %20)
store i32 %21, i32* %5
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%23 = call i64 @check_digits(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %6
br label %30
28: ; preds = %17
br label %29
29: ; preds = %28
br i1 true, label %17, label %30
30: ; preds = %29, %25
%31 = load i32, i32* @stdout
%32 = load i32, i32* %5
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = load i32, i32* %6
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %30
%38 = load i32, i32* @stdout
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 9
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %63
44: ; preds = %30
%45 = load i32, i32* %2
%46 = load i32, i32* %6
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %55
48: ; preds = %44
%49 = load i32, i32* @stdout
%50 = load i32, i32* %4
%51 = icmp eq i32 %50, 9
%52 = zext i1 %51 to i64
%53 = select i1 %51, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0)
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %53)
br label %62
55: ; preds = %44
%56 = load i32, i32* @stdout
%57 = load i32, i32* %2
%58 = load i32, i32* %4
%59 = mul nsw i32 %58, 10
%60 = sub nsw i32 100, %59
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %57, i32 %60)
br label %67
62: ; preds = %48
br label %63
63: ; preds = %62, %37
br label %64
64: ; preds = %63
%65 = load i32, i32* %4
%66 = add nsw i32 %65, 1
store i32 %66, i32* %4
br label %10
67: ; preds = %55, %10
%68 = load i32, i32* %2
%69 = load i32, i32* %6
%70 = icmp ne i32 %68, %69
br i1 %70, label %71, label %75
71: ; preds = %67
%72 = load i32, i32* @stdout
%73 = load i32, i32* %2
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %71, %67
%76 = load i32, i32* @EXIT_SUCCESS
ret i32 %76
}

LLVM IR (-O2):
@.str = [14 x i8] c"Make a guess:\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.2 = [12 x i8] c"FSCANF: %d\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [8 x i8] c"Go up!\0A\00"
@.str.5 = [10 x i8] c"Go down!\0A\00"
@.str.6 = [43 x i8] c"Congratulations! You win. [%d]. Points: %d\00"
@.str.7 = [30 x i8] c"You lost! The number was %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast [20 x i8]* %1 to i8**
br label %6
6: ; preds = %0, %29
%7 = phi i32 [ 0, %0 ], [ %35, %29 ]
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 100
br label %10
10: ; preds = %10, %6
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i32 @fscanf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %5)
%14 = call i64 @check_digits(i8* %2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %10
%17 = add nsw i32 %9, 1
%18 = call i32 @atoi(i8* %2)
%19 = load i32, i32* @stdout
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%21 = icmp slt i32 %9, %18
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = icmp slt i32 %17, %18
br i1 %23, label %29, label %24
24: ; preds = %22
%25 = load i32, i32* @stdout
%26 = mul i32 %7, -10
%27 = add i32 %26, 100
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %17, i32 %27)
br label %37
29: ; preds = %22, %16
%30 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %16 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %22 ]
%31 = load i32, i32* @stdout
%32 = icmp eq i32 %7, 9
%33 = select i1 %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %30
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = add nuw nsw i32 %7, 1
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %6
37: ; preds = %29, %24
%38 = icmp eq i32 %17, %18
br i1 %38, label %42, label %39
39: ; preds = %37
%40 = load i32, i32* @stdout
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %17)
br label %42
42: ; preds = %39, %37
%43 = load i32, i32* @EXIT_SUCCESS
ret i32 %43
}