#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*/ printf(char *, ...);
int const rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  const int kMin = 1;
  const int kMax = 10;
  srand(time(NULL));
  int number = (rand() % ((kMax - kMin) + 1)) + kMin;
  int tries = 0;
  int guess = -1;
  printf("I'm thinking of a number between %d and %d.\n", kMin, kMax);
  printf("Can you think of the number?\n");
  printf("Take a Guess: ");
  scanf("%d", &guess);
  tries++;
  while (guess != number) {
    printf("Nope, try again: ");
    scanf("%d", &guess);
    tries++;
  }
  if (guess == number) {
    if (tries == 1) {
      printf("Wow, you got it on the first try. Wasn't that fun!\n");
    } else if (tries == 3) {
      printf("You got it. I guess third times the charm.\n");
    } else if (tries == 7) {
      printf("Seven wonders. Seven sins. Seven attempts. Awesome tenacity!");
    } else if (tries == (kMax - kMin) + 1) {
      printf("You're really good at the art of elimination.\n");
    } else if (tries > (kMax - kMin) + 2) {
      printf("You finally got it, but I think you need your memory checked.\n");
    } else {
      printf("Yep, it was %d. How did you know?\n", number);
    }
    printf("Thanks for playing. bye bye now.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
lea    0xe59(%rip),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1225 <main+0xd5>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ed <main+0x9d>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    12f5 <main+0x1a5>
cmpl   $0x1,-0x14(%rbp)
jne    124e <main+0xfe>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e7 <main+0x197>
cmpl   $0x3,-0x14(%rbp)
jne    126b <main+0x11b>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e2 <main+0x192>
cmpl   $0x7,-0x14(%rbp)
jne    1288 <main+0x138>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12dd <main+0x18d>
cmpl   $0xa,-0x14(%rbp)
jne    12a5 <main+0x155>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x188>
cmpl   $0xb,-0x14(%rbp)
jle    12c2 <main+0x172>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d3 <main+0x183>
mov    -0x10(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x188>
jmp    12dd <main+0x18d>
jmp    12e2 <main+0x192>
jmp    12e7 <main+0x197>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0x1,%r15d
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xe73(%rip),%rdi
mov    $0x1,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmp    %r15d,0xc(%rsp)
jne    121f <main+0xbf>
lea    0xfaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe41(%rip),%r14
lea    0xe37(%rip),%r12
lea    0xc(%rsp),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
add    $0x1,%ebx
cmp    %r15d,0xc(%rsp)
jne    1240 <main+0xe0>
cmp    $0x9,%ebx
ja     127f <main+0x11f>
mov    %ebx,%eax
lea    0xd93(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf06(%rip),%rdi
jmp    11ff <main+0x9f>
cmp    $0xb,%ebx
jb     12af <main+0x14f>
lea    0xe8c(%rip),%rdi
jmp    11ff <main+0x9f>
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1204 <main+0xa4>
lea    0xeab(%rip),%rdi
jmp    11ff <main+0x9f>
lea    0xe00(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1204 <main+0xa4>

LLVM IR (-O0):
@.str = [45 x i8] c"I'm thinking of a number between %d and %d.\0A\00"
@.str.1 = [30 x i8] c"Can you think of the number?\0A\00"
@.str.2 = [15 x i8] c"Take a Guess: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [18 x i8] c"Nope, try again: \00"
@.str.5 = [52 x i8] c"Wow, you got it on the first try. Wasn't that fun!\0A\00"
@.str.6 = [44 x i8] c"You got it. I guess third times the charm.\0A\00"
@.str.7 = [61 x i8] c"Seven wonders. Seven sins. Seven attempts. Awesome tenacity!\00"
@.str.8 = [47 x i8] c"You're really good at the art of elimination.\0A\00"
@.str.9 = [63 x i8] c"You finally got it, but I think you need your memory checked.\0A\00"
@.str.10 = [35 x i8] c"Yep, it was %d. How did you know?\0A\00"
@.str.11 = [34 x i8] c"Thanks for playing. bye bye now.\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 1, i32* %2
store i32 10, i32* %3
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 10
%11 = add nsw i32 %10, 1
store i32 %11, i32* %4
store i32 0, i32* %5
store i32 -1, i32* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 1, i32 10)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %18
18: ; preds = %22, %0
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %18
27: ; preds = %18
%28 = load i32, i32* %6
%29 = load i32, i32* %4
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %65
31: ; preds = %27
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
br label %63
36: ; preds = %31
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 3
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
br label %62
41: ; preds = %36
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 7
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
br label %61
46: ; preds = %41
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 10
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
br label %60
51: ; preds = %46
%52 = load i32, i32* %5
%53 = icmp sgt i32 %52, 11
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.9, i64 0, i64 0))
br label %59
56: ; preds = %51
%57 = load i32, i32* %4
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %56, %54
br label %60
60: ; preds = %59, %49
br label %61
61: ; preds = %60, %44
br label %62
62: ; preds = %61, %39
br label %63
63: ; preds = %62, %34
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
br label %65
65: ; preds = %63, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"I'm thinking of a number between %d and %d.\0A\00"
@.str.2 = [15 x i8] c"Take a Guess: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [18 x i8] c"Nope, try again: \00"
@.str.7 = [61 x i8] c"Seven wonders. Seven sins. Seven attempts. Awesome tenacity!\00"
@.str.10 = [35 x i8] c"Yep, it was %d. How did you know?\0A\00"
@str = [29 x i8] c"Can you think of the number?\00"
@str.12 = [33 x i8] c"Thanks for playing. bye bye now.\00"
@str.13 = [62 x i8] c"You finally got it, but I think you need your memory checked.\00"
@str.14 = [46 x i8] c"You're really good at the art of elimination.\00"
@str.15 = [43 x i8] c"You got it. I guess third times the charm.\00"
@str.16 = [51 x i8] c"Wow, you got it on the first try. Wasn't that fun!\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 10
%6 = add nsw i32 %5, 1
%7 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 1, i32 10)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, %6
br i1 %13, label %22, label %14
14: ; preds = %0, %14
%15 = phi i32 [ %18, %14 ], [ 1, %0 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%18 = add nuw nsw i32 %15, 1
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, %6
br i1 %20, label %21, label %14
21: ; preds = %14
switch i32 %15, label %30 [
i32 0, label %22
i32 2, label %24
i32 6, label %26
i32 9, label %28
]
22: ; preds = %0, %21
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.16, i64 0, i64 0))
br label %36
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.15, i64 0, i64 0))
br label %36
26: ; preds = %21
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
br label %36
28: ; preds = %21
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.14, i64 0, i64 0))
br label %36
30: ; preds = %21
%31 = icmp ugt i32 %15, 10
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.13, i64 0, i64 0))
br label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 %6)
br label %36
36: ; preds = %24, %28, %34, %32, %26, %22
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.12, i64 0, i64 0))
ret i32 0
}