#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*/ inf(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void main(void) {
  int num, guess = 0, n = 0;
  char status = 'y';
  srand(time(NULL));
  num = rand() % 1000 + 1;
  while ('y' == status) {
    printf("I have a number between 1 and 1000.\nCan you guess my "
           "number?\nPlease type your first guess.\n");
    while (guess != num) {
      scanf("%d", &guess);
      ++n;
      if (guess > num) {
        printf("%s\n", "Too high.Try again.");
      } else if (guess < num) {
        printf("%s\n", "Too low.Try again.");
      }
    }
    inf(n);
    printf("%s\n", "Would you like to play again (y or n)?");
    num = rand() % 1000 + 1;
    scanf(" %c", &status);
    printf("\n\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x79,-0xd(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
movsbl -0xd(%rbp),%ecx
mov    $0x79,%eax
cmp    %ecx,%eax
jne    128d <main+0x12d>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     1236 <main+0xd6>
lea    0xe8b(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    120b <main+0xab>
lea    0xe67(%rip),%rdi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <main+0xd1>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122c <main+0xcc>
lea    0xe41(%rip),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <main+0xd1>
jmp    11be <main+0x5e>
mov    -0xc(%rbp),%edi
call   1050 <inf@plt>
lea    0xe1a(%rip),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
lea    0xe42(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <main+0x3f>
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
movl   $0x0,0x4(%rsp)
movb   $0x79,0x3(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%r12d
lea    0x4(%rsp),%r14
lea    0xe67(%rip),%r13
xor    %r15d,%r15d
jmp    11f8 <main+0x98>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1050 <inf@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%r12d
lea    0xe7c(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x79,0x3(%rsp)
jne    1289 <main+0x129>
movslq %r12d,%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%ebp
mov    %ebp,%eax
neg    %eax
lea    (%r12,%rax,1),%ebx
add    $0x1,%ebx
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
cmp    %ebx,0x4(%rsp)
je     11b0 <main+0x50>
sub    %ebp,%r12d
lea    0xdc0(%rip),%rbp
jmp    1263 <main+0x103>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <puts@plt>
add    $0x1,%r15d
cmp    %ebx,0x4(%rsp)
je     11b0 <main+0x50>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %r13,%rdi
cmp    %ebx,%eax
jg     1250 <main+0xf0>
lea    0xd95(%rip),%rdi
cmp    %r12d,%eax
jle    1250 <main+0xf0>
jmp    1255 <main+0xf5>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [92 x i8] c"I have a number between 1 and 1000.\0ACan you guess my number?\0APlease type your first guess.\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [20 x i8] c"Too high.Try again.\00"
@.str.4 = [19 x i8] c"Too low.Try again.\00"
@.str.5 = [39 x i8] c"Would you like to play again (y or n)?\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.7 = [3 x i8] c"\0A\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %2
store i32 0, i32* %3
store i8 121, i8* %4
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
br label %10
10: ; preds = %37, %0
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp eq i32 121, %12
br i1 %13, label %14, label %46
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %36, %14
%17 = load i32, i32* %2
%18 = load i32, i32* %1
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %37
20: ; preds = %16
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
%24 = load i32, i32* %2
%25 = load i32, i32* %1
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %36
29: ; preds = %20
%30 = load i32, i32* %2
%31 = load i32, i32* %1
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
br label %36
36: ; preds = %35, %27
br label %16
37: ; preds = %16
%38 = load i32, i32* %3
%39 = call i32 @inf(i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 (...) @rand()
%42 = srem i32 %41, 1000
%43 = add nsw i32 %42, 1
store i32 %43, i32* %1
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %10
46: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"Too high.Try again.\00"
@.str.4 = [19 x i8] c"Too low.Try again.\00"
@.str.5 = [39 x i8] c"Would you like to play again (y or n)?\00"
@.str.6 = [4 x i8] c" %c\00"
@str = [91 x i8] c"I have a number between 1 and 1000.\0ACan you guess my number?\0APlease type your first guess.\00"
@str.8 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
store i8 121, i8* %2
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (...) @rand()
br label %7
7: ; preds = %0, %29
%8 = phi i32 [ %33, %29 ], [ %6, %0 ]
%9 = phi i32 [ %30, %29 ], [ 0, %0 ]
%10 = srem i32 %8, 1000
%11 = add nsw i32 %10, 1
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, %11
br i1 %14, label %29, label %15
15: ; preds = %7, %26
%16 = phi i32 [ %18, %26 ], [ %9, %7 ]
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = add nsw i32 %16, 1
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, %11
br i1 %20, label %23, label %21
21: ; preds = %15
%22 = icmp sgt i32 %19, %10
br i1 %22, label %26, label %23
23: ; preds = %21, %15
%24 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %15 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), %21 ]
%25 = call i32 @puts(i8* dereferenceable(1) %24)
br label %26
26: ; preds = %23, %21
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, %11
br i1 %28, label %29, label %15
29: ; preds = %26, %7
%30 = phi i32 [ %9, %7 ], [ %18, %26 ]
%31 = call i32 @inf(i32 %30)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 (...) @rand()
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
%36 = load i8, i8* %2
%37 = icmp eq i8 %36, 121
br i1 %37, label %7, label %38
38: ; preds = %29
ret void
}