#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 n, x, limite_inferior, limite_superior, acertou, tentativas;
  srand(time(NULL));
  acertou = 0;
  tentativas = 0;
  limite_inferior = 0;
  limite_superior = 100;
  n = (rand() % 100) + 1;
  do {
    printf("Bem-vindo ao The Game, va' tentando enquanto pode\n");
    printf("Total de tentativas: %d\n", tentativas);
    printf("Digite um numero(Esta entre %d e %d): ", limite_inferior,
           limite_superior);
    scanf("%d", &x);
    tentativas++;
    if (x > n)
      limite_superior = x;
    else if (x < n)
      limite_inferior = x;
    else
      acertou = 1;
  } while (!acertou);
  printf("\nParabens, o numero eh: %d", n);
  printf("\nTotal de tentativas: %d\n", tentativas);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1203 <main+0xb3>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1226 <main+0xd6>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <main+0xca>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1221 <main+0xd1>
movl   $0x1,-0x18(%rbp)
jmp    1226 <main+0xd6>
jmp    122b <main+0xdb>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a0 <main+0x50>
mov    -0x8(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %eax,%r15d
sub    %ecx,%r15d
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0x1,%r14d
mov    $0x64,%ebx
lea    0x4(%rsp),%r12
xor    %eax,%eax
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %eax,%r13d
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%ecx
cmp    %r15d,%ecx
mov    %ecx,%eax
cmovg  %r13d,%eax
cmp    %r14d,%ecx
cmovg  %r13d,%eax
cmovg  %ecx,%ebx
jg     11c0 <main+0x60>
cmp    %r15d,%ecx
jle    11c0 <main+0x60>
lea    0xdfe(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe08(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
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 = [51 x i8] c"Bem-vindo ao The Game, va' tentando enquanto pode\0A\00"
@.str.1 = [25 x i8] c"Total de tentativas: %d\0A\00"
@.str.2 = [39 x i8] c"Digite um numero(Esta entre %d e %d): \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"\0AParabens, o numero eh: %d\00"
@.str.5 = [26 x i8] c"\0ATotal de tentativas: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %4
store i32 100, i32* %5
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 100
%12 = add nsw i32 %11, 1
store i32 %12, i32* %2
br label %13
13: ; preds = %37, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %13
%27 = load i32, i32* %3
store i32 %27, i32* %5
br label %36
28: ; preds = %13
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32, i32* %3
store i32 %33, i32* %4
br label %35
34: ; preds = %28
store i32 1, i32* %6
br label %35
35: ; preds = %34, %32
br label %36
36: ; preds = %35, %26
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
%40 = xor i1 %39, true
br i1 %40, label %13, label %41
41: ; preds = %37
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %44)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"Total de tentativas: %d\0A\00"
@.str.2 = [39 x i8] c"Digite um numero(Esta entre %d e %d): \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"\0AParabens, o numero eh: %d\00"
@.str.5 = [26 x i8] c"\0ATotal de tentativas: %d\0A\00"
@str = [50 x i8] c"Bem-vindo ao The Game, va' tentando enquanto pode\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, 100
%7 = add nsw i32 %6, 1
br label %8
8: ; preds = %8, %0
%9 = phi i32 [ 0, %0 ], [ %21, %8 ]
%10 = phi i32 [ 100, %0 ], [ %22, %8 ]
%11 = phi i32 [ 0, %0 ], [ %16, %8 ]
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10)
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%16 = add nuw nsw i32 %11, 1
%17 = load i32, i32* %1
%18 = icmp sgt i32 %17, %7
%19 = icmp sgt i32 %17, %6
%20 = or i1 %18, %19
%21 = select i1 %20, i32 %9, i32 %17
%22 = select i1 %18, i32 %17, i32 %10
%23 = xor i1 %19, true
%24 = or i1 %18, %23
br i1 %24, label %8, label %25
25: ; preds = %8
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %16)
ret i32 0
}