#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 */
char EOF;
char getchar();
int guessTheNumber();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand((time(NULL)));
  char c = 'y';
  int numberOfGuesses;
  while (c != 'n') {
    numberOfGuesses = guessTheNumber();
    if (numberOfGuesses < 10)
      printf("\nEither you know the secret or you got lucky!\n");
    else if (numberOfGuesses == 10)
      printf("\nAhah! You know the secret!\n");
    else
      printf("\nYou should be able to do better!\n");
    while ((c = getchar()) != '\n' && c != EOF) {
      ;
    }
    printf("Would you like to play again (y or n)? ");
    scanf("%c", &c);
  }
  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   1050 <srand@plt>
movb   $0x79,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
je     124d <main+0xed>
mov    $0x0,%al
call   1040 <guessTheNumber@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11b5 <main+0x55>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    11e1 <main+0x81>
cmpl   $0xa,-0xc(%rbp)
jne    11d0 <main+0x70>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    11dc <main+0x7c>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    11e1 <main+0x81>
jmp    11e6 <main+0x86>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     1217 <main+0xb7>
movsbl -0x5(%rbp),%eax
mov    0x2ddc(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1227 <main+0xc7>
jmp    122c <main+0xcc>
jmp    11e6 <main+0x86>
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe58(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1080 <scanf@plt>
jmp    1183 <main+0x23>
xor    %eax,%eax
add    $0x10,%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   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movb   $0x79,0x7(%rsp)
lea    0xe96(%rip),%r13
lea    0xecd(%rip),%rbp
mov    0x2e45(%rip),%r12
lea    0xe56(%rip),%r14
lea    0xe77(%rip),%r15
lea    0x7(%rsp),%rbx
jmp    11da <main+0x6a>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
cmpb   $0x6e,0x7(%rsp)
je     1217 <main+0xa7>
xor    %eax,%eax
call   1050 <guessTheNumber@plt>
cmp    $0xa,%eax
mov    %r13,%rdi
lea    0xe5f(%rip),%rax
cmove  %rax,%rdi
cmovl  %rbp,%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %al,0x7(%rsp)
cmp    $0xa,%al
je     11c0 <main+0x50>
cmp    (%r12),%al
jne    1200 <main+0x90>
jmp    11c0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0AEither you know the secret or you got lucky!\0A\00"
@.str.1 = [29 x i8] c"\0AAhah! You know the secret!\0A\00"
@.str.2 = [35 x i8] c"\0AYou should be able to do better!\0A\00"
@EOF = global i8 0
@.str.3 = [40 x i8] c"Would you like to play again (y or n)? \00"
@.str.4 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i8 121, i8* %2
br label %6
6: ; preds = %38, %0
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 110
br i1 %9, label %10, label %41
10: ; preds = %6
%11 = call i32 (...) @guessTheNumber()
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %24
16: ; preds = %10
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %23
21: ; preds = %16
%22 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23, %14
br label %25
25: ; preds = %37, %24
%26 = call signext i8 (...) @getchar()
store i8 %26, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 10
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = load i8, i8* @EOF
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %31, %33
br label %35
35: ; preds = %29, %25
%36 = phi i1 [ false, %25 ], [ %34, %29 ]
br i1 %36, label %37, label %38
37: ; preds = %35
br label %25
38: ; preds = %35
%39 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %6
41: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str.3 = [40 x i8] c"Would you like to play again (y or n)? \00"
@.str.4 = [3 x i8] c"%c\00"
@str = [34 x i8] c"\0AYou should be able to do better!\00"
@str.5 = [28 x i8] c"\0AAhah! You know the secret!\00"
@str.6 = [46 x i8] c"\0AEither you know the secret or you got lucky!\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
store i8 121, i8* %1
br label %4
4: ; preds = %0, %17
%5 = call i32 (...) @guessTheNumber()
%6 = icmp slt i32 %5, 10
%7 = icmp eq i32 %5, 10
%8 = select i1 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0)
%9 = select i1 %6, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @str.6, i64 0, i64 0), i8* %8
%10 = call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %11, %4
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %1
%13 = icmp ne i8 %12, 10
%14 = load i8, i8* @EOF
%15 = icmp ne i8 %12, %14
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %11, label %17
17: ; preds = %11
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%20 = load i8, i8* %1
%21 = icmp eq i8 %20, 110
br i1 %21, label %22, label %4
22: ; preds = %17
ret i32 0
}