#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*/ system(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand(time(NULL));
  int x = rand();
  int i = 0;
  int guesses = 0;
  while (x > 50) {
    x = rand();
  }
  system("clear");
  printf("What is your guess for the random number under 50?\n", x);
  while (guesses < 5) {
    scanf("%d", &i);
    if (i < x) {
      system("clear");
      printf("Your guess is too low.\n");
    } else if (i == x) {
      system("clear");
      printf("You guessed right!\n");
      break;
    } else if (i > x) {
      system("clear");
      printf("Your guess is too high.\n");
    }
    guesses = ++guesses;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x32,-0x14(%rbp)
jle    11b7 <main+0x57>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x3e>
lea    0xe42(%rip),%rdi
call   1030 <system@plt>
mov    -0x14(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x5,-0x1c(%rbp)
jge    1285 <main+0x125>
lea    0xe55(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1219 <main+0xb9>
lea    0xdff(%rip),%rdi
call   1030 <system@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1274 <main+0x114>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1244 <main+0xe4>
lea    0xdd4(%rip),%rdi
call   1030 <system@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1285 <main+0x125>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    126a <main+0x10a>
lea    0xda9(%rip),%rdi
call   1030 <system@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126f <main+0x10f>
jmp    1274 <main+0x114>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x1c(%rbp)
jmp    11d4 <main+0x74>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
movl   $0x0,0x4(%rsp)
cmp    $0x33,%eax
jl     119e <main+0x3e>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
cmp    $0x32,%eax
jg     1190 <main+0x30>
mov    %eax,%ebx
lea    0xe5b(%rip),%rdi
call   1040 <system@plt>
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
lea    0xe49(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jge    1240 <main+0xe0>
lea    0xe91(%rip),%r14
lea    0xe23(%rip),%rdi
call   1040 <system@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe15(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jge    1251 <main+0xf1>
lea    0xe5d(%rip),%r14
lea    0xdef(%rip),%rdi
call   1040 <system@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xde1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jge    1262 <main+0x102>
lea    0xe29(%rip),%r14
jmp    1271 <main+0x111>
je     12ea <main+0x18a>
jle    11ea <main+0x8a>
lea    0xded(%rip),%r14
jmp    11d6 <main+0x76>
je     12ea <main+0x18a>
jle    121e <main+0xbe>
lea    0xddc(%rip),%r14
jmp    120a <main+0xaa>
je     12ea <main+0x18a>
jle    1285 <main+0x125>
lea    0xdcb(%rip),%r14
lea    0xd88(%rip),%rdi
call   1040 <system@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xd7a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jge    12db <main+0x17b>
lea    0xdc2(%rip),%r14
lea    0xd54(%rip),%rdi
call   1040 <system@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xd46(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jge    12e8 <main+0x188>
lea    0xd8e(%rip),%rbx
jmp    12f1 <main+0x191>
je     12ea <main+0x18a>
jle    12b9 <main+0x159>
lea    0xd56(%rip),%r14
jmp    12a5 <main+0x145>
jne    130f <main+0x1af>
lea    0xd63(%rip),%rbx
lea    0xd08(%rip),%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
jle    1305 <main+0x1a5>
lea    0xd24(%rip),%rbx
jmp    12f1 <main+0x191>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [52 x i8] c"What is your guess for the random number under 50?\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [24 x i8] c"Your guess is too low.\0A\00"
@.str.4 = [20 x i8] c"You guessed right!\0A\00"
@.str.5 = [25 x i8] c"Your guess is too high.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32 (...) @rand()
store i32 %11, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %12
12: ; preds = %15, %2
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, 50
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (...) @rand()
store i32 %16, i32* %6
br label %12
17: ; preds = %12
%18 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %48, %17
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 5
br i1 %23, label %24, label %51
24: ; preds = %21
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %48
32: ; preds = %24
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %51
39: ; preds = %32
%40 = load i32, i32* %7
%41 = load i32, i32* %6
%42 = icmp sgt i32 %40, %41
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %43, %39
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47, %29
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
store i32 %50, i32* %8
br label %21
51: ; preds = %36, %21
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [51 x i8] c"What is your guess for the random number under 50?\00"
@str.6 = [24 x i8] c"Your guess is too high.\00"
@str.7 = [19 x i8] c"You guessed right!\00"
@str.8 = [23 x i8] c"Your guess is too low.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (...) @rand()
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = icmp sgt i32 %6, 50
br i1 %8, label %9, label %12
9: ; preds = %2, %9
%10 = tail call i32 (...) @rand()
%11 = icmp sgt i32 %10, 50
br i1 %11, label %9, label %12
12: ; preds = %9, %2
%13 = phi i32 [ %6, %2 ], [ %10, %9 ]
%14 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, %13
br i1 %18, label %23, label %19
19: ; preds = %12
%20 = icmp eq i32 %17, %13
br i1 %20, label %71, label %21
21: ; preds = %19
%22 = icmp sgt i32 %17, %13
br i1 %22, label %23, label %27
23: ; preds = %21, %12
%24 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %12 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %21 ]
%25 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) %24)
br label %27
27: ; preds = %23, %21
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, %13
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = icmp eq i32 %29, %13
br i1 %32, label %71, label %33
33: ; preds = %31
%34 = icmp sgt i32 %29, %13
br i1 %34, label %35, label %39
35: ; preds = %27, %33
%36 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %33 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %27 ]
%37 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @puts(i8* dereferenceable(1) %36)
br label %39
39: ; preds = %35, %33
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, %13
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = icmp eq i32 %41, %13
br i1 %44, label %71, label %45
45: ; preds = %43
%46 = icmp sgt i32 %41, %13
br i1 %46, label %47, label %51
47: ; preds = %39, %45
%48 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %45 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %39 ]
%49 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%50 = call i32 @puts(i8* dereferenceable(1) %48)
br label %51
51: ; preds = %47, %45
%52 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%53 = load i32, i32* %3
%54 = icmp slt i32 %53, %13
br i1 %54, label %59, label %55
55: ; preds = %51
%56 = icmp eq i32 %53, %13
br i1 %56, label %71, label %57
57: ; preds = %55
%58 = icmp sgt i32 %53, %13
br i1 %58, label %59, label %63
59: ; preds = %51, %57
%60 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %57 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %51 ]
%61 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%62 = call i32 @puts(i8* dereferenceable(1) %60)
br label %63
63: ; preds = %59, %57
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%65 = load i32, i32* %3
%66 = icmp slt i32 %65, %13
br i1 %66, label %71, label %67
67: ; preds = %63
%68 = icmp eq i32 %65, %13
br i1 %68, label %71, label %69
69: ; preds = %67
%70 = icmp sgt i32 %65, %13
br i1 %70, label %71, label %75
71: ; preds = %63, %69, %19, %31, %43, %55, %67
%72 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0), %67 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0), %55 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0), %43 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0), %31 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0), %19 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0), %69 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0), %63 ]
%73 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%74 = call i32 @puts(i8* dereferenceable(1) %72)
br label %75
75: ; preds = %71, %69
ret i32 0
}