#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 *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int no;
  int ans;
  srand(time(NULL));
  ans = rand() % 1000;
  printf("Please guess a 0~999 integer. \n\n");
  do {
    printf("What is it: ");
    scanf("%d", &no);
    if (no > ans)
      printf("\aSmaller.\n");
    else if (no < ans)
      printf("\aBigger.\n");
  } while (no != ans);
  printf("Correct.\n");
  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   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11c6 <main+0x76>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    11e3 <main+0x93>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <main+0x8e>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    11e3 <main+0x93>
jmp    11e8 <main+0x98>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    118d <main+0x3d>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
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   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbx
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ebx
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4e(%rip),%r14
lea    0xe54(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe7d(%rip),%r13
lea    0xe6d(%rip),%rbp
jmp    11db <main+0x7b>
xchg   %ax,%ax
call   1030 <puts@plt>
cmp    %ebx,0x4(%rsp)
je     11fe <main+0x9e>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    %r13,%rdi
cmp    %ebx,0x4(%rsp)
jg     11d0 <main+0x70>
mov    %rbp,%rdi
jl     11d0 <main+0x70>
jmp    11d5 <main+0x75>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Please guess a 0~999 integer. \0A\0A\00"
@.str.1 = [13 x i8] c"What is it: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"\07Smaller.\0A\00"
@.str.4 = [10 x i8] c"\07Bigger.\0A\00"
@.str.5 = [10 x i8] c"Correct.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 1000
store i32 %7, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %25, %0
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %24
17: ; preds = %9
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
br label %24
24: ; preds = %23, %15
br label %25
25: ; preds = %24
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = icmp ne i32 %26, %27
br i1 %28, label %9, label %29
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"What is it: \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [32 x i8] c"Please guess a 0~999 integer. \0A\00"
@str.6 = [9 x i8] c"Correct.\00"
@str.7 = [9 x i8] c"\07Bigger.\00"
@str.8 = [10 x i8] c"\07Smaller.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 1000
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %18, %0
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, %6
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = icmp slt i32 %11, %6
br i1 %14, label %15, label %18
15: ; preds = %13, %8
%16 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), %13 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
br label %18
18: ; preds = %15, %13
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, %6
br i1 %20, label %21, label %8
21: ; preds = %18
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}