#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 play(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  int high_score = 0;
  int score;
  char command;
  srand((unsigned int)time(NULL));
  printf("Guess the secret number between 1 and %d.\n\n", 100);
  while (1) {
    if ((score = play((rand() % 100 + 1))) < high_score) {
      high_score = score;
      printf("New high score: %d\n", high_score);
    }
    printf("Play again? (Y/N) ");
    scanf(" %c", &command);
    if (command != 'y' && command != 'Y')
      break;
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe73(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x1,%edi
call   1050 <play@plt>
mov    %eax,-0xc(%rbp)
cmp    -0x8(%rbp),%eax
jge    11d5 <main+0x75>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
lea    -0xd(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x79,%eax
je     1212 <main+0xb2>
movsbl -0xd(%rbp),%eax
cmp    $0x59,%eax
je     1212 <main+0xb2>
jmp    1225 <main+0xc5>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <main+0x39>
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   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe70(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe89(%rip),%r14
lea    0xe96(%rip),%r15
lea    0xea2(%rip),%r12
lea    0x7(%rsp),%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x1,%edi
call   1060 <play@plt>
cmp    %ebx,%eax
jge    1201 <main+0x91>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%ebx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
movzbl 0x7(%rsp),%eax
and    $0xdf,%al
cmp    $0x59,%al
jne    122d <main+0xbd>
mov    $0xa,%edi
call   1030 <putchar@plt>
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 = [44 x i8] c"Guess the secret number between 1 and %d.\0A\0A\00"
@.str.1 = [20 x i8] c"New high score: %d\0A\00"
@.str.2 = [19 x i8] c"Play again? (Y/N) \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = call i32 @srand(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 100)
br label %9
9: ; preds = %0, %31
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 100
%12 = add nsw i32 %11, 1
%13 = call i32 @play(i32 %12)
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %9
%17 = load i32, i32* %3
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16, %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 121
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 89
br i1 %29, label %30, label %31
30: ; preds = %26
br label %33
31: ; preds = %26, %20
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %9
33: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Guess the secret number between 1 and %d.\0A\0A\00"
@.str.1 = [20 x i8] c"New high score: %d\0A\00"
@.str.2 = [19 x i8] c"Play again? (Y/N) \00"
@.str.3 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 100)
br label %6
6: ; preds = %22, %0
%7 = phi i32 [ 0, %0 ], [ %16, %22 ]
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 100
%10 = add nsw i32 %9, 1
%11 = call i32 @play(i32 %10)
%12 = icmp slt i32 %11, %7
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %15
15: ; preds = %13, %6
%16 = phi i32 [ %11, %13 ], [ %7, %6 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%19 = load i8, i8* %1
%20 = and i8 %19, -33
%21 = icmp eq i8 %20, 89
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 @putchar(i32 10)
br label %6
24: ; preds = %15
ret i32 0
}