#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 /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int randomNumber, userInput;
  srand(time(NULL));
  randomNumber = rand() % 10 + 1;
  do {
    printf("Guess the number (1 to 10): ");
    scanf("%d", &userInput);
    if (randomNumber < userInput)
      puts("The secret number is lower");
    else if (randomNumber > userInput)
      puts("The secret number is higher");
  } while (randomNumber != userInput);
  printf("Congratulations!");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <main+0x6d>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
jmp    11ea <main+0x8a>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11e5 <main+0x85>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
jmp    11ea <main+0x8a>
jmp    11ef <main+0x8f>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1194 <main+0x34>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%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>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%r12d
sub    %ecx,%r12d
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
lea    0xe50(%rip),%r14
lea    0xe66(%rip),%r15
lea    0x4(%rsp),%r13
lea    0xe5d(%rip),%rbx
jmp    11db <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <puts@plt>
cmp    0x4(%rsp),%ebp
je     1207 <main+0xa7>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %rbx,%rdi
cmp    %eax,%ebp
jl     11d0 <main+0x70>
lea    0xe3b(%rip),%rdi
cmp    %eax,%r12d
jge    11d0 <main+0x70>
jmp    11d5 <main+0x75>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Guess the number (1 to 10): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"The secret number is lower\00"
@.str.3 = [28 x i8] c"The secret number is higher\00"
@.str.4 = [17 x i8] c"Congratulations!\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, 10
%8 = add nsw i32 %7, 1
store i32 %8, i32* %2
br label %9
9: ; preds = %25, %0
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %24
17: ; preds = %9
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, 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 ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [29 x i8] c"Guess the number (1 to 10): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"The secret number is lower\00"
@.str.3 = [28 x i8] c"The secret number is higher\00"
@.str.4 = [17 x i8] c"Congratulations!\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, 10
%7 = add nsw i32 %6, 1
br label %8
8: ; preds = %18, %0
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp slt i32 %7, %11
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = icmp slt i32 %6, %11
br i1 %14, label %18, label %15
15: ; preds = %13, %8
%16 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, 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 %7, %19
br i1 %20, label %21, label %8
21: ; preds = %18
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}