#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 /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void main(void) {
  int num, guess = 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);
      if (guess > num) {
        printf("%s\n", "Too high.Try again.");
      } else if (guess < num) {
        printf("%s\n", "Too low.Try again.");
      }
    }
    printf("%s\n%s\n", "Excellent! You guessed the number!",
           "Would you like to play again (y or n)?");
    scanf(" %c", &status);
    printf("\n\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movb   $0x79,-0x9(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x79,%eax
cmp    %ecx,%eax
jne    1257 <main+0x107>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     1216 <main+0xc6>
lea    0xea2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    11eb <main+0x9b>
lea    0xeb1(%rip),%rdi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <main+0xc1>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    120c <main+0xbc>
lea    0xe8b(%rip),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <main+0xc1>
jmp    11a7 <main+0x57>
lea    0xe69(%rip),%rdi
lea    0xe69(%rip),%rsi
lea    0xe85(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1188 <main+0x38>
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   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
mov    %eax,%r13d
sub    %ecx,%r13d
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
lea    0xe42(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe39(%rip),%rbp
lea    0xe46(%rip),%r14
jmp    1222 <main+0xc2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe43(%rip),%rdi
lea    0xe43(%rip),%rsi
lea    0xe5f(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x79,0x3(%rsp)
jne    125d <main+0xfd>
lea    0xe56(%rip),%rdi
nopl   0x0(%rax)
call   1030 <puts@plt>
cmp    %ebx,0x4(%rsp)
je     11e0 <main+0x80>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %rbp,%rdi
cmp    %ebx,%eax
jg     1230 <main+0xd0>
mov    %r14,%rdi
cmp    %r13d,%eax
jle    1230 <main+0xd0>
jmp    1235 <main+0xd5>
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 = [7 x i8] c"%s\0A%s\0A\00"
@.str.6 = [35 x i8] c"Excellent! You guessed the number!\00"
@.str.7 = [39 x i8] c"Would you like to play again (y or n)?\00"
@.str.8 = [4 x i8] c" %c\00"
@.str.9 = [3 x i8] c"\0A\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %2
store i8 121, i8* %3
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 1000
%8 = add nsw i32 %7, 1
store i32 %8, i32* %1
br label %9
9: ; preds = %34, %0
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp eq i32 121, %11
br i1 %12, label %13, label %38
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %33, %13
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = load i32, i32* %1
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = 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 %33
26: ; preds = %19
%27 = load i32, i32* %2
%28 = load i32, i32* %1
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = 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 %32
32: ; preds = %30, %26
br label %33
33: ; preds = %32, %24
br label %15
34: ; preds = %15
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %3)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %9
38: ; preds = %9
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 = [7 x i8] c"%s\0A%s\0A\00"
@.str.6 = [35 x i8] c"Excellent! You guessed the number!\00"
@.str.7 = [39 x i8] c"Would you like to play again (y or n)?\00"
@.str.8 = [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.10 = [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()
%7 = srem i32 %6, 1000
%8 = add nsw i32 %7, 1
br label %9
9: ; preds = %0, %25
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, %8
br i1 %12, label %25, label %13
13: ; preds = %9, %22
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, %8
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = icmp sgt i32 %15, %7
br i1 %18, label %22, label %19
19: ; preds = %17, %13
%20 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), %17 ]
%21 = call i32 @puts(i8* dereferenceable(1) %20)
br label %22
22: ; preds = %19, %17
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, %8
br i1 %24, label %25, label %13
25: ; preds = %22, %9
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
%29 = load i8, i8* %2
%30 = icmp eq i8 %29, 121
br i1 %30, label %9, label %31
31: ; preds = %25
ret void
}