#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 rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int guess;
  int guesses_left;
  int random = rand() % 100 + 1;
  printf("Guess a number from 1-10.\n");
  for (guesses_left = 6; guesses_left > 0; guesses_left--) {
    scanf("%d", &guess);
    if (guess < random) {
      printf("Too low...\n");
    } else if (guess > random) {
      printf("Too high...\n");
    } else {
      printf("You win!\n");
      return 0;
    }
  }
  printf("You're out of guesses!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%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    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
movl   $0x6,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    121b <main+0xcb>
lea    0xe73(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ce <main+0x7e>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    1208 <main+0xb8>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11eb <main+0x9b>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
jmp    1203 <main+0xb3>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1227 <main+0xd7>
jmp    1208 <main+0xb8>
jmp    120d <main+0xbd>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x47>
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0x1,%r14d
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0xe59(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
lea    0xe8d(%rip),%rbx
mov    %rbx,%rdi
cmp    %ebp,%eax
jle    11d3 <main+0x83>
cmp    %r14d,%eax
jle    12ca <main+0x17a>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe21(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %rbx,%rdi
cmp    %ebp,%eax
jle    1204 <main+0xb4>
cmp    %r14d,%eax
jle    12ca <main+0x17a>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %rbx,%rdi
cmp    %ebp,%eax
jle    1235 <main+0xe5>
cmp    %r14d,%eax
jle    12ca <main+0x17a>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
lea    0xdbf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %rbx,%rdi
cmp    %ebp,%eax
jle    1262 <main+0x112>
cmp    %r14d,%eax
jle    12ca <main+0x17a>
lea    0xddb(%rip),%rdi
call   1030 <puts@plt>
lea    0xd92(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %rbx,%rdi
cmp    %ebp,%eax
jle    128f <main+0x13f>
cmp    %r14d,%eax
jle    12ca <main+0x17a>
lea    0xdae(%rip),%rdi
call   1030 <puts@plt>
lea    0xd65(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jle    12b9 <main+0x169>
cmp    %r14d,%eax
jle    12ca <main+0x17a>
lea    0xd84(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xd55(%rip),%rdi
jmp    12d1 <main+0x181>
lea    0xd63(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Guess a number from 1-10.\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Too low...\0A\00"
@.str.3 = [13 x i8] c"Too high...\0A\00"
@.str.4 = [10 x i8] c"You win!\0A\00"
@.str.5 = [24 x i8] c"You're out of guesses!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%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* %4
%10 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 6, i32* %3
br label %11
11: ; preds = %31, %0
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %30
21: ; preds = %14
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %29
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %36
29: ; preds = %25
br label %30
30: ; preds = %29, %19
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, -1
store i32 %33, i32* %3
br label %11
34: ; preds = %11
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %27
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [26 x i8] c"Guess a number from 1-10.\00"
@str.6 = [23 x i8] c"You're out of guesses!\00"
@str.7 = [9 x i8] c"You win!\00"
@str.8 = [12 x i8] c"Too high...\00"
@str.9 = [11 x i8] c"Too low...\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = add nsw i32 %6, 1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, %6
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = icmp sgt i32 %10, %7
br i1 %13, label %14, label %57
14: ; preds = %12, %0
%15 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %0 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), %12 ]
%16 = call i32 @puts(i8* dereferenceable(1) %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, %6
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = icmp sgt i32 %18, %7
br i1 %21, label %22, label %57
22: ; preds = %20, %14
%23 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), %20 ]
%24 = call i32 @puts(i8* dereferenceable(1) %23)
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, %6
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = icmp sgt i32 %26, %7
br i1 %29, label %30, label %57
30: ; preds = %28, %22
%31 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %22 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), %28 ]
%32 = call i32 @puts(i8* dereferenceable(1) %31)
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%34 = load i32, i32* %1
%35 = icmp sgt i32 %34, %6
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = icmp sgt i32 %34, %7
br i1 %37, label %38, label %57
38: ; preds = %36, %30
%39 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %30 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), %36 ]
%40 = call i32 @puts(i8* dereferenceable(1) %39)
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%42 = load i32, i32* %1
%43 = icmp sgt i32 %42, %6
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = icmp sgt i32 %42, %7
br i1 %45, label %46, label %57
46: ; preds = %44, %38
%47 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %38 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), %44 ]
%48 = call i32 @puts(i8* dereferenceable(1) %47)
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%50 = load i32, i32* %1
%51 = icmp sgt i32 %50, %6
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = icmp sgt i32 %50, %7
br i1 %53, label %54, label %57
54: ; preds = %52, %46
%55 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %46 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), %52 ]
%56 = call i32 @puts(i8* dereferenceable(1) %55)
br label %57
57: ; preds = %12, %20, %28, %36, %44, %52, %54
%58 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0), %54 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %52 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %44 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %36 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %28 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %20 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %12 ]
%59 = call i32 @puts(i8* dereferenceable(1) %58)
ret i32 0
}