#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 checkGuess(int, int);
int /*<<< orphan*/ congrats();
int getGuess();
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ sorry(int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int rand1;
  int guess;
  srand(time(NULL));
  rand1 = rand() % 20 + 1;
  printf("\n\nI am thinking of a number between 1 and 20.");
  printf("\n\tCan you guess what it is?\t");
  guess = getGuess();
  if (guess == rand1)
    congrats();
  else {
    guess = checkGuess(guess, rand1);
    if (guess == rand1)
      congrats();
    else {
      guess = checkGuess(guess, rand1);
      if (guess == rand1)
        congrats();
      else {
        guess = checkGuess(guess, rand1);
        if (guess == rand1)
          congrats();
        else {
          guess = checkGuess(guess, rand1);
          if (guess == rand1)
            congrats();
          else {
            sorry(rand1);
          }
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getGuess@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11ee <main+0x6e>
mov    $0x0,%al
call   1050 <congrats@plt>
jmp    12a2 <main+0x122>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <checkGuess@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1214 <main+0x94>
mov    $0x0,%al
call   1050 <congrats@plt>
jmp    129d <main+0x11d>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <checkGuess@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    123a <main+0xba>
mov    $0x0,%al
call   1050 <congrats@plt>
jmp    1298 <main+0x118>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <checkGuess@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1260 <main+0xe0>
mov    $0x0,%al
call   1050 <congrats@plt>
jmp    1293 <main+0x113>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <checkGuess@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1286 <main+0x106>
mov    $0x0,%al
call   1050 <congrats@plt>
jmp    128e <main+0x10e>
mov    -0x8(%rbp),%edi
call   1080 <sorry@plt>
jmp    1293 <main+0x113>
jmp    1298 <main+0x118>
jmp    129d <main+0x11d>
jmp    12a2 <main+0x122>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getGuess@plt>
cmp    %ebx,%eax
je     1211 <main+0x91>
mov    %eax,%edi
mov    %ebx,%esi
call   1090 <checkGuess@plt>
cmp    %ebx,%eax
je     1211 <main+0x91>
mov    %eax,%edi
mov    %ebx,%esi
call   1090 <checkGuess@plt>
cmp    %ebx,%eax
je     1211 <main+0x91>
mov    %eax,%edi
mov    %ebx,%esi
call   1090 <checkGuess@plt>
cmp    %ebx,%eax
je     1211 <main+0x91>
mov    %eax,%edi
mov    %ebx,%esi
call   1090 <checkGuess@plt>
cmp    %ebx,%eax
jne    121c <main+0x9c>
xor    %eax,%eax
call   1050 <congrats@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %ebx,%edi
call   1080 <sorry@plt>
jmp    1218 <main+0x98>

LLVM IR (-O0):
@.str = [46 x i8] c"\0A\0AI am thinking of a number between 1 and 20.\00"
@.str.1 = [29 x i8] c"\0A\09Can you guess what it is?\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 20
%8 = add nsw i32 %7, 1
store i32 %8, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (...) @getGuess()
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (...) @congrats()
br label %60
17: ; preds = %0
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call i32 @checkGuess(i32 %18, i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 (...) @congrats()
br label %59
26: ; preds = %17
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = call i32 @checkGuess(i32 %27, i32 %28)
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = call i32 (...) @congrats()
br label %58
35: ; preds = %26
%36 = load i32, i32* %3
%37 = load i32, i32* %2
%38 = call i32 @checkGuess(i32 %36, i32 %37)
store i32 %38, i32* %3
%39 = load i32, i32* %3
%40 = load i32, i32* %2
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = call i32 (...) @congrats()
br label %57
44: ; preds = %35
%45 = load i32, i32* %3
%46 = load i32, i32* %2
%47 = call i32 @checkGuess(i32 %45, i32 %46)
store i32 %47, i32* %3
%48 = load i32, i32* %3
%49 = load i32, i32* %2
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %44
%52 = call i32 (...) @congrats()
br label %56
53: ; preds = %44
%54 = load i32, i32* %2
%55 = call i32 @sorry(i32 %54)
br label %56
56: ; preds = %53, %51
br label %57
57: ; preds = %56, %42
br label %58
58: ; preds = %57, %33
br label %59
59: ; preds = %58, %24
br label %60
60: ; preds = %59, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"\0A\0AI am thinking of a number between 1 and 20.\00"
@.str.1 = [29 x i8] c"\0A\09Can you guess what it is?\09\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 20
%5 = add nsw i32 %4, 1
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @getGuess()
%9 = icmp eq i32 %8, %5
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 (...) @congrats()
br label %34
12: ; preds = %0
%13 = tail call i32 @checkGuess(i32 %8, i32 %5)
%14 = icmp eq i32 %13, %5
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 (...) @congrats()
br label %34
17: ; preds = %12
%18 = tail call i32 @checkGuess(i32 %13, i32 %5)
%19 = icmp eq i32 %18, %5
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 (...) @congrats()
br label %34
22: ; preds = %17
%23 = tail call i32 @checkGuess(i32 %18, i32 %5)
%24 = icmp eq i32 %23, %5
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (...) @congrats()
br label %34
27: ; preds = %22
%28 = tail call i32 @checkGuess(i32 %23, i32 %5)
%29 = icmp eq i32 %28, %5
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 (...) @congrats()
br label %34
32: ; preds = %27
%33 = tail call i32 @sorry(i32 %5)
br label %34
34: ; preds = %15, %25, %32, %30, %20, %10
ret i32 0
}