#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*/ menu();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  int menu_choice = -1;
  while (menu_choice) {
    if (menu_choice == -1) {
      menu();
      scanf("%d", &menu_choice);
    } else if (menu_choice == 1) {
      int mystery_num = rand() % (100 - 0) + 0;
      int try;
      int lives = 9;
      do {
        printf("Try a value [%d - %d], %d lives remaining :\n", 0, 100, lives);
        scanf("%d", &try);
        if (try < 0 || try > 100) {
          continue;
        } else {
          if (try < mystery_num) {
            printf("Try more (+) !\n\n");
          } else if (try > mystery_num) {
            printf("Try less (-) !\n\n");
          }
          lives--;
        }
      } while (lives != 0 && try != mystery_num);
      if (!lives) {
        printf("You loose, mystery number was %d\n", mystery_num);
      } else {
        printf("Congratulations, you win !\n");
      }
      menu_choice = -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12ce <main+0x16e>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11b6 <main+0x56>
mov    $0x0,%al
call   1030 <menu@plt>
lea    0xe58(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
jmp    12c9 <main+0x169>
cmpl   $0x1,-0x8(%rbp)
jne    12c4 <main+0x164>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x0,%edx
mov    %edx,-0xc(%rbp)
movl   $0x9,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xe1d(%rip),%rdi
xor    %esi,%esi
mov    $0x64,%edx
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe05(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jl     1218 <main+0xb8>
cmpl   $0x64,-0x10(%rbp)
jle    121d <main+0xbd>
jmp    1269 <main+0x109>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123c <main+0xdc>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125b <main+0xfb>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1256 <main+0xf6>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125b <main+0xfb>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1269 <main+0x109>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x15(%rbp)
je     1284 <main+0x124>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11dc <main+0x7c>
cmpl   $0x0,-0x14(%rbp)
jne    12af <main+0x14f>
mov    -0xc(%rbp),%esi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bd <main+0x15d>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x8(%rbp)
jmp    12c9 <main+0x169>
jmp    1186 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0xffffffff,(%rsp)
mov    $0xffffffff,%eax
lea    0xe67(%rip),%r14
lea    0xe5d(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xece(%rip),%rbp
nop
cmp    $0x1,%eax
je     11d9 <main+0x69>
test   %eax,%eax
je     1295 <main+0x125>
cmp    $0xffffffff,%eax
jne    11b0 <main+0x40>
xor    %eax,%eax
call   1040 <menu@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%eax
jmp    11b0 <main+0x40>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%r13
imul   $0x51eb851f,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r13d
mov    $0x9,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x64,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x64,%eax
ja     1256 <main+0xe6>
mov    %rbp,%rdi
cmp    %r13d,%eax
jl     1249 <main+0xd9>
lea    0xe26(%rip),%rdi
jle    124e <main+0xde>
call   1030 <puts@plt>
add    $0xffffffff,%r12d
mov    0x4(%rsp),%eax
test   %r12d,%r12d
je     1260 <main+0xf0>
cmp    %r13d,%eax
jne    1210 <main+0xa0>
test   %r12d,%r12d
je     1273 <main+0x103>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
jmp    1284 <main+0x114>
lea    0xdb6(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0xffffffff,(%rsp)
mov    $0xffffffff,%eax
jmp    11b0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"Try a value [%d - %d], %d lives remaining :\0A\00"
@.str.2 = [17 x i8] c"Try more (+) !\0A\0A\00"
@.str.3 = [17 x i8] c"Try less (-) !\0A\0A\00"
@.str.4 = [34 x i8] c"You loose, mystery number was %d\0A\00"
@.str.5 = [28 x i8] c"Congratulations, you win !\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
store i32 -1, i32* %2
br label %8
8: ; preds = %70, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %71
11: ; preds = %8
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 (...) @menu()
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %70
17: ; preds = %11
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %69
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 100
%23 = add nsw i32 %22, 0
store i32 %23, i32* %3
store i32 9, i32* %5
br label %24
24: ; preds = %58, %20
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 100, i32 %25)
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 100
br i1 %32, label %33, label %34
33: ; preds = %30, %24
br label %51
34: ; preds = %30
%35 = load i32, i32* %4
%36 = load i32, i32* %3
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %47
40: ; preds = %34
%41 = load i32, i32* %4
%42 = load i32, i32* %3
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
br label %47
47: ; preds = %46, %38
%48 = load i32, i32* %5
%49 = add nsw i32 %48, -1
store i32 %49, i32* %5
br label %50
50: ; preds = %47
br label %51
51: ; preds = %50, %33
%52 = load i32, i32* %5
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i32, i32* %4
%56 = load i32, i32* %3
%57 = icmp ne i32 %55, %56
br label %58
58: ; preds = %54, %51
%59 = phi i1 [ false, %51 ], [ %57, %54 ]
br i1 %59, label %24, label %60
60: ; preds = %58
%61 = load i32, i32* %5
%62 = icmp ne i32 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = load i32, i32* %3
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %64)
br label %68
66: ; preds = %60
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
store i32 -1, i32* %2
br label %69
69: ; preds = %68, %17
br label %70
70: ; preds = %69, %14
br label %8
71: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"Try a value [%d - %d], %d lives remaining :\0A\00"
@.str.4 = [34 x i8] c"You loose, mystery number was %d\0A\00"
@str = [27 x i8] c"Congratulations, you win !\00"
@str.6 = [16 x i8] c"Try less (-) !\0A\00"
@str.7 = [16 x i8] c"Try more (+) !\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%6 = bitcast i32* %2 to i8*
br label %7
7: ; preds = %45, %0
%8 = phi i32 [ -1, %0 ], [ %46, %45 ]
br label %9
9: ; preds = %7, %9
switch i32 %8, label %9 [
i32 0, label %47
i32 -1, label %10
i32 1, label %14
]
10: ; preds = %9
%11 = call i32 (...) @menu()
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
br label %45
14: ; preds = %9
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 100
br label %17
17: ; preds = %33, %14
%18 = phi i32 [ 9, %14 ], [ %35, %33 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 100, i32 %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = icmp ugt i32 %21, 100
br i1 %22, label %33, label %23
23: ; preds = %17
%24 = icmp slt i32 %21, %16
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = icmp sgt i32 %21, %16
br i1 %26, label %27, label %30
27: ; preds = %25, %23
%28 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.7, i64 0, i64 0), %23 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0), %25 ]
%29 = call i32 @puts(i8* dereferenceable(1) %28)
br label %30
30: ; preds = %27, %25
%31 = add nsw i32 %18, -1
%32 = load i32, i32* %2
br label %33
33: ; preds = %17, %30
%34 = phi i32 [ %21, %17 ], [ %32, %30 ]
%35 = phi i32 [ %18, %17 ], [ %31, %30 ]
%36 = icmp ne i32 %35, 0
%37 = icmp ne i32 %34, %16
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %17, label %39
39: ; preds = %33
br i1 %36, label %42, label %40
40: ; preds = %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %44
42: ; preds = %39
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
store i32 -1, i32* %1
br label %45
45: ; preds = %44, %10
%46 = phi i32 [ %13, %10 ], [ -1, %44 ]
br label %7
47: ; preds = %9
ret i32 0
}