#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);
int main(void) {
  int inpRndSeed = 0;
  int inpRange = 0;
  int guessTheNumber = 0;
  int userInput = 0;
  int triesUserGuessed = 0;
  printf("Give a random number: ");
  scanf("%d", &inpRndSeed);
  printf("Guess from 0 to: ");
  scanf("%d", &inpRange);
  srand(inpRndSeed);
  guessTheNumber = (rand() % inpRange + 1);
  do {
    printf("\n\nYour guess: ");
    scanf("%d", &userInput);
    if (guessTheNumber < userInput)
      printf("Your guess was to high!");
    else if (guessTheNumber > userInput)
      printf("Your guess was to small!");
    else {
      printf("\nYour guess was right!\nYou needed %d tries",
             ++triesUserGuessed);
      return 0;
    }
    triesUserGuessed += 1;
  } while (userInput != guessTheNumber);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe72(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0xc(%rbp)
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1204 <main+0xc4>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124b <main+0x10b>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1223 <main+0xe3>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1246 <main+0x106>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1267 <main+0x127>
jmp    124b <main+0x10b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11c7 <main+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9c(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x14(%rsp),%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltd
idivl  0x10(%rsp)
mov    %edx,%r13d
lea    0x1(%r13),%ebx
mov    $0x1,%ebp
lea    0xe61(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xe64(%rip),%r14
jmp    11f0 <main+0xb0>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    %ebx,0xc(%rsp)
je     1230 <main+0xf0>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %r14,%rdi
cmp    %eax,%ebx
jl     11e0 <main+0xa0>
lea    0xe38(%rip),%rdi
cmp    %eax,%r13d
jge    11e0 <main+0xa0>
lea    0xe45(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Give a random number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Guess from 0 to: \00"
@.str.3 = [15 x i8] c"\0A\0AYour guess: \00"
@.str.4 = [24 x i8] c"Your guess was to high!\00"
@.str.5 = [25 x i8] c"Your guess was to small!\00"
@.str.6 = [43 x i8] c"\0AYour guess was right!\0AYou needed %d tries\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %2
%12 = call i32 @srand(i32 %11)
%13 = call i32 (...) @rand()
%14 = load i32, i32* %3
%15 = srem i32 %13, %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %39, %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %36
25: ; preds = %17
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %35
31: ; preds = %25
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %33)
store i32 0, i32* %1
br label %44
35: ; preds = %29
br label %36
36: ; preds = %35, %23
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %36
%40 = load i32, i32* %5
%41 = load i32, i32* %4
%42 = icmp ne i32 %40, %41
br i1 %42, label %17, label %43
43: ; preds = %39
store i32 0, i32* %1
br label %44
44: ; preds = %43, %31
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str = [23 x i8] c"Give a random number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Guess from 0 to: \00"
@.str.3 = [15 x i8] c"\0A\0AYour guess: \00"
@.str.4 = [24 x i8] c"Your guess was to high!\00"
@.str.5 = [25 x i8] c"Your guess was to small!\00"
@.str.6 = [43 x i8] c"\0AYour guess was right!\0AYou needed %d tries\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %1
%12 = call i32 @srand(i32 %11)
%13 = call i32 (...) @rand()
%14 = load i32, i32* %2
%15 = srem i32 %13, %14
%16 = add nsw i32 %15, 1
br label %17
17: ; preds = %28, %0
%18 = phi i32 [ 0, %0 ], [ %31, %28 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = icmp slt i32 %16, %21
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = icmp slt i32 %15, %21
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = add nuw nsw i32 %18, 1
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %26)
br label %34
28: ; preds = %23, %17
%29 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), %17 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), %23 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %29)
%31 = add nuw nsw i32 %18, 1
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, %16
br i1 %33, label %34, label %17
34: ; preds = %28, %25
ret i32 0
}