#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_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int random();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int num, num_aletori, cont;
  int major, menor;
  srandom(time(0));
  num_aletori = random() % 9;
  num = 0;
  cont = 0;
  while (num_aletori != num) {
    printf("Introdueix un numero: ");
    scanf("%d", &num);
    if (num > num_aletori) {
      major = num;
    } else
      menor = num;
    cont = cont + 1;
    printf("Has fallat. Torna-ho a provar.");
    printf("\n");
  }
  printf("\nEnhorabona. T'ha costat %d intents.", cont);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1205 <main+0xb5>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11d5 <main+0x85>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11db <main+0x8b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1194 <main+0x44>
mov    -0x1c(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1070 <random@plt>
movslq %eax,%rbp
imul   $0x38e38e39,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
movl   $0x0,0x4(%rsp)
sub    %eax,%ebp
je     1202 <main+0xa2>
lea    0xe51(%rip),%r14
lea    0xe61(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe58(%rip),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
add    $0x1,%ebx
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    0x4(%rsp),%ebp
jne    11d0 <main+0x70>
lea    0xe30(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Introdueix un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Has fallat. Torna-ho a provar.\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [37 x i8] c"\0AEnhorabona. T'ha costat %d intents.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @time(i32 0)
%12 = call i32 @srandom(i32 %11)
%13 = call i32 (...) @random()
%14 = srem i32 %13, 9
store i32 %14, i32* %7
store i32 0, i32* %6
store i32 0, i32* %8
br label %15
15: ; preds = %29, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = load i32, i32* %6
store i32 %26, i32* %9
br label %29
27: ; preds = %19
%28 = load i32, i32* %6
store i32 %28, i32* %10
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %15
34: ; preds = %15
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}

LLVM IR (-O2):
@.str = [23 x i8] c"Introdueix un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Has fallat. Torna-ho a provar.\00"
@.str.4 = [37 x i8] c"\0AEnhorabona. T'ha costat %d intents.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @time(i32 0)
%6 = tail call i32 @srandom(i32 %5)
%7 = tail call i32 (...) @random()
%8 = srem i32 %7, 9
store i32 0, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %2, %10
%11 = phi i32 [ %14, %10 ], [ 0, %2 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = add nuw nsw i32 %11, 1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @putchar(i32 10)
%17 = load i32, i32* %3
%18 = icmp eq i32 %8, %17
br i1 %18, label %19, label %10
19: ; preds = %10, %2
%20 = phi i32 [ 0, %2 ], [ %14, %10 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @EXIT_SUCCESS
ret i32 %22
}