#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t max(size_t, size_t);
size_t min(size_t, size_t);
int scanf(char *, size_t *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
size_t moreOrLess(size_t minVal, size_t maxVal, size_t valueToFind) {
  size_t nbTurn = 0, userValue;
  int ret;
  do {
    fprintf(stdout, "Choose a number between %zu and %zu: ", minVal, maxVal);
    fflush(stdout);
    ret = scanf("%zu", &userValue);
    if (ret != 1) {
      fprintf(stderr, "You must enter a integer number!\n");
      continue;
    }
    nbTurn++;
    if (userValue < valueToFind) {
      fprintf(stdout, "It\'s more!\n");
      minVal = max(userValue, minVal);
    } else if (userValue > valueToFind) {
      fprintf(stdout, "It\'s less!\n");
      maxVal = min(userValue, maxVal);
    }
  } while (valueToFind != userValue);
  return nbTurn;
}


x86 assembly (clang, -O0):
<moreOrLess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xe86(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x1,-0x2c(%rbp)
je     11d2 <moreOrLess+0x82>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1259 <moreOrLess+0x109>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1219 <moreOrLess+0xc9>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <max@plt>
mov    %rax,-0x8(%rbp)
jmp    1254 <moreOrLess+0x104>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    124f <moreOrLess+0xff>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <min@plt>
mov    %rax,-0x10(%rbp)
jmp    1254 <moreOrLess+0x104>
jmp    1259 <moreOrLess+0x109>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    116c <moreOrLess+0x1c>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<moreOrLess>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e6d(%rip),%r13
mov    %rsp,%rbp
xor    %r12d,%r12d
jmp    11a1 <moreOrLess+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    %r15,(%rsp)
je     1238 <moreOrLess+0xe8>
mov    0x0(%r13),%edi
lea    0xe54(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%r13),%edi
call   1060 <fflush@plt>
lea    0xe5d(%rip),%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1180 <moreOrLess+0x30>
add    $0x1,%r12
cmp    %r15,(%rsp)
jae    1210 <moreOrLess+0xc0>
mov    0x0(%r13),%edi
lea    0xe61(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1040 <max@plt>
mov    %rax,%rbx
jmp    1197 <moreOrLess+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
jbe    1197 <moreOrLess+0x47>
mov    0x0(%r13),%edi
lea    0xe3b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1030 <min@plt>
mov    %rax,%r14
jmp    1197 <moreOrLess+0x47>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [38 x i8] c"Choose a number between %zu and %zu: \00"
@.str.1 = [4 x i8] c"%zu\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"You must enter a integer number!\0A\00"
@.str.3 = [12 x i8] c"It's more!\0A\00"
@.str.4 = [12 x i8] c"It's less!\0A\00"
define i64 @moreOrLess(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %10
10: ; preds = %47, %3
%11 = load i32, i32* @stdout
%12 = load i64, i64* %4
%13 = load i64, i64* %5
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %12, i64 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %8)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %47
23: ; preds = %10
%24 = load i64, i64* %7
%25 = add i64 %24, 1
store i64 %25, i64* %7
%26 = load i64, i64* %8
%27 = load i64, i64* %6
%28 = icmp ult i64 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%32 = load i64, i64* %8
%33 = load i64, i64* %4
%34 = call i64 @max(i64 %32, i64 %33)
store i64 %34, i64* %4
br label %46
35: ; preds = %23
%36 = load i64, i64* %8
%37 = load i64, i64* %6
%38 = icmp ugt i64 %36, %37
br i1 %38, label %39, label %45
39: ; preds = %35
%40 = load i32, i32* @stdout
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%42 = load i64, i64* %8
%43 = load i64, i64* %5
%44 = call i64 @min(i64 %42, i64 %43)
store i64 %44, i64* %5
br label %45
45: ; preds = %39, %35
br label %46
46: ; preds = %45, %29
br label %47
47: ; preds = %46, %20
%48 = load i64, i64* %6
%49 = load i64, i64* %8
%50 = icmp ne i64 %48, %49
br i1 %50, label %10, label %51
51: ; preds = %47
%52 = load i64, i64* %7
ret i64 %52
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [38 x i8] c"Choose a number between %zu and %zu: \00"
@.str.1 = [4 x i8] c"%zu\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"You must enter a integer number!\0A\00"
@.str.3 = [12 x i8] c"It's more!\0A\00"
@.str.4 = [12 x i8] c"It's less!\0A\00"
define i64 @moreOrLess(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
br label %6
6: ; preds = %35, %3
%7 = phi i64 [ %1, %3 ], [ %36, %35 ]
%8 = phi i64 [ 0, %3 ], [ %37, %35 ]
%9 = phi i64 [ %0, %3 ], [ %38, %35 ]
%10 = load i32, i32* @stdout
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %9, i64 %7)
%12 = load i32, i32* @stdout
%13 = call i32 @fflush(i32 %12)
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%15 = icmp eq i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %6
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %35
19: ; preds = %6
%20 = add i64 %8, 1
%21 = load i64, i64* %4
%22 = icmp ult i64 %21, %2
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i32, i32* @stdout
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%26 = load i64, i64* %4
%27 = call i64 @max(i64 %26, i64 %9)
br label %35
28: ; preds = %19
%29 = icmp ugt i64 %21, %2
br i1 %29, label %30, label %35
30: ; preds = %28
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%33 = load i64, i64* %4
%34 = call i64 @min(i64 %33, i64 %7)
br label %35
35: ; preds = %23, %30, %28, %16
%36 = phi i64 [ %7, %16 ], [ %7, %23 ], [ %34, %30 ], [ %7, %28 ]
%37 = phi i64 [ %8, %16 ], [ %20, %23 ], [ %20, %30 ], [ %20, %28 ]
%38 = phi i64 [ %9, %16 ], [ %27, %23 ], [ %9, %30 ], [ %9, %28 ]
%39 = load i64, i64* %4
%40 = icmp eq i64 %39, %2
br i1 %40, label %41, label %6
41: ; preds = %35
ret i64 %37
}