#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  int x, n, run;
  time_t t;
  srand((unsigned)time(&t));
  n = rand() % 10;
  printf("Estoy pensando un numero entre 1 y 10, adivinalo!!\n");
  run = 1;
  while (run == 1) {
    printf("Tu piensas que es el numero:  ");
    scanf("%d", &x);
    if (n == x) {
      printf("Muy bien, %d es correcto! \n", x);
      run = 0;
    } else {
      if (x < n)
        printf("Intenta con un numero mayor\n");
      else
        printf("Intenta con un numero menor\n");
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    121e <main+0xce>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11e7 <main+0x97>
mov    -0x8(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1219 <main+0xc9>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1206 <main+0xb6>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <main+0xc4>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1219 <main+0xc9>
jmp    1196 <main+0x46>
mov    $0x1,%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
lea    0x4(%rsp),%rdi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%eax
cmp    %eax,%ebx
jne    11f5 <main+0x95>
lea    0xe4a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe91(%rip),%r13
lea    0xe6e(%rip),%rbp
lea    0xdf6(%rip),%r14
lea    0xe0e(%rip),%r15
mov    %rsp,%r12
jmp    1241 <main+0xe1>
cs nopw 0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%eax
cmp    %eax,%ebx
je     11d1 <main+0x71>
mov    %r13,%rdi
cmp    %ebx,%eax
jl     1220 <main+0xc0>
mov    %rbp,%rdi
jmp    1220 <main+0xc0>

LLVM IR (-O0):
@.str = [52 x i8] c"Estoy pensando un numero entre 1 y 10, adivinalo!!\0A\00"
@.str.1 = [31 x i8] c"Tu piensas que es el numero: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"Muy bien, %d es correcto! \0A\00"
@.str.4 = [29 x i8] c"Intenta con un numero mayor\0A\00"
@.str.5 = [29 x i8] c"Intenta con un numero menor\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 @time(i32* %5)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 10
store i32 %10, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %12
12: ; preds = %33, %0
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %34
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %22)
store i32 0, i32* %4
br label %33
24: ; preds = %15
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
br label %33
33: ; preds = %32, %21
br label %12
34: ; preds = %12
ret i32 1
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"Tu piensas que es el numero: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"Muy bien, %d es correcto! \0A\00"
@str = [51 x i8] c"Estoy pensando un numero entre 1 y 10, adivinalo!!\00"
@str.6 = [28 x i8] c"Intenta con un numero menor\00"
@str.7 = [28 x i8] c"Intenta con un numero mayor\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @time(i32* %2)
%6 = trunc i64 %5 to i32
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp eq i32 %9, %13
br i1 %14, label %24, label %15
15: ; preds = %0, %15
%16 = phi i32 [ %22, %15 ], [ %13, %0 ]
%17 = icmp slt i32 %16, %9
%18 = select i1 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0)
%19 = call i32 @puts(i8* dereferenceable(1) %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%22 = load i32, i32* %1
%23 = icmp eq i32 %9, %22
br i1 %23, label %24, label %15
24: ; preds = %15, %0
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %9)
ret i32 1
}