#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t generateNumber(size_t, size_t);
size_t max(int /*<<< orphan*/, int /*<<< orphan*/);
size_t min(int /*<<< orphan*/, int /*<<< orphan*/);
size_t moreOrLess(size_t, size_t, size_t);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  size_t minVal, maxVal, valueToFind;
  size_t nbTurn;
  srand(time(NULL));
  if (argc != 3) {
    fprintf(stderr, "more_or_less min_value max_value\n");
    return EXIT_FAILURE;
  }
  minVal = min(atoi(argv[1]), atoi(argv[2]));
  maxVal = max(atoi(argv[1]), atoi(argv[2]));
  valueToFind = generateNumber(minVal, maxVal);
  if (maxVal - minVal < 2) {
    fprintf(stderr, "Your min and max value should be different\n");
    return EXIT_FAILURE;
  }
  nbTurn = moreOrLess(minVal, maxVal, valueToFind);
  fprintf(stdout, "You find the value %zu after %zu turns.\n", valueToFind,
          nbTurn);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmpl   $0x3,-0x8(%rbp)
je     11d8 <main+0x58>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12b9 <main+0x139>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%esi
call   1030 <min@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1040 <max@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <generateNumber@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cmp    $0x2,%rax
jae    1279 <main+0xf9>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12b9 <main+0x139>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1090 <moreOrLess@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmp    $0x3,%ebp
jne    120b <main+0x8b>
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <min@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <max@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1080 <generateNumber@plt>
mov    %rax,%r15
mov    %rbx,%rax
sub    %r14,%rax
cmp    $0x1,%rax
ja     122b <main+0xab>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
jmp    121b <main+0x9b>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2daf(%rip),%rax
jmp    125d <main+0xdd>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1090 <moreOrLess@plt>
mov    0x2d90(%rip),%rcx
mov    (%rcx),%edi
lea    0xe05(%rip),%rsi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"more_or_less min_value max_value\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [44 x i8] c"Your min and max value should be different\0A\00"
@stdout = global i32 0
@.str.2 = [41 x i8] c"You find the value %zu after %zu turns.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %58
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = call i64 @min(i32 %22, i32 %26)
store i64 %27, i64* %6
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = call i64 @max(i32 %31, i32 %35)
store i64 %36, i64* %7
%37 = load i64, i64* %6
%38 = load i64, i64* %7
%39 = call i64 @generateNumber(i64 %37, i64 %38)
store i64 %39, i64* %8
%40 = load i64, i64* %7
%41 = load i64, i64* %6
%42 = sub i64 %40, %41
%43 = icmp ult i64 %42, 2
br i1 %43, label %44, label %48
44: ; preds = %18
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
store i32 %47, i32* %3
br label %58
48: ; preds = %18
%49 = load i64, i64* %6
%50 = load i64, i64* %7
%51 = load i64, i64* %8
%52 = call i64 @moreOrLess(i64 %49, i64 %50, i64 %51)
store i64 %52, i64* %9
%53 = load i32, i32* @stdout
%54 = load i64, i64* %8
%55 = load i64, i64* %9
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i64 %54, i64 %55)
%57 = load i32, i32* @EXIT_SUCCESS
store i32 %57, i32* %3
br label %58
58: ; preds = %48, %44, %14
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"more_or_less min_value max_value\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [44 x i8] c"Your min and max value should be different\0A\00"
@stdout = global i32 0
@.str.2 = [41 x i8] c"You find the value %zu after %zu turns.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %32
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = tail call i64 @min(i32 %12, i32 %15)
%17 = load i8*, i8** %10
%18 = tail call i32 @atoi(i8* %17)
%19 = load i8*, i8** %13
%20 = tail call i32 @atoi(i8* %19)
%21 = tail call i64 @max(i32 %18, i32 %20)
%22 = tail call i64 @generateNumber(i64 %16, i64 %21)
%23 = sub i64 %21, %16
%24 = icmp ult i64 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %9
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
br label %32
28: ; preds = %9
%29 = tail call i64 @moreOrLess(i64 %16, i64 %21, i64 %22)
%30 = load i32, i32* @stdout
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i64 %22, i64 %29)
br label %32
32: ; preds = %28, %25, %6
%33 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %25 ], [ @EXIT_SUCCESS, %28 ]
%34 = load i32, i32* %33
ret i32 %34
}