#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) {
  srandom(time(0));
  printf("%d\n", random() % 1000);
  int num_secret, intents = 0, num_usu = -1;
  srandom(time(0));
  num_secret = random() % 10;
  printf("\nAdivina el número secret (entre 0 i 9)!!\n\n");
  do {
    if (num_usu == -1)
      printf("Introduix un número:\n");
    else
      printf("Has fallat. Torna-ho a provar.\nIntroduix un número:\n");
    scanf("%d", &num_usu);
    intents++;
  } while (num_secret != num_usu);
  if (intents < 5)
    printf("\nEnhorabona.");
  else
    printf("\nPots millorar.");
  printf(" T'ha costat %d intents!!\n", intents);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11ec <main+0x9c>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fa <main+0xaa>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11cf <main+0x7f>
cmpl   $0x5,-0x18(%rbp)
jge    123c <main+0xec>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124a <main+0xfa>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d7e(%rip),%rax
mov    (%rax),%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   1030 <srandom@plt>
xor    %eax,%eax
call   1070 <random@plt>
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0xffffffff,0x4(%rsp)
ff
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1070 <random@plt>
movslq %eax,%r12
imul   $0x66666667,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r12d
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
lea    0xe89(%rip),%r13
lea    0xe63(%rip),%rbp
lea    0xdf5(%rip),%r14
lea    0x4(%rsp),%r15
mov    $0xffffffff,%eax
jmp    123c <main+0xdc>
nopl   0x0(%rax,%rax,1)
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0x1,%ebx
cmp    %eax,%r12d
je     1249 <main+0xe9>
mov    %r13,%rdi
cmp    $0xffffffff,%eax
je     1220 <main+0xc0>
mov    %rbp,%rdi
jmp    1220 <main+0xc0>
cmp    $0x4,%ebx
lea    0xdb4(%rip),%rax
lea    0xdba(%rip),%rdi
cmovb  %rax,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
lea    0xdb5(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d61(%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 = [4 x i8] c"%d\0A\00"
@.str.1 = [45 x i8] c"\0AAdivina el n\C3\BAmero secret (entre 0 i 9)!!\0A\0A\00"
@.str.2 = [23 x i8] c"Introduix un n\C3\BAmero:\0A\00"
@.str.3 = [54 x i8] c"Has fallat. Torna-ho a provar.\0AIntroduix un n\C3\BAmero:\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"\0AEnhorabona.\00"
@.str.6 = [16 x i8] c"\0APots millorar.\00"
@.str.7 = [27 x i8] c" T'ha costat %d intents!!\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 i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32 0)
%10 = call i32 @srandom(i32 %9)
%11 = call i32 (...) @random()
%12 = srem i32 %11, 1000
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 0, i32* %7
store i32 -1, i32* %8
%14 = call i32 @time(i32 0)
%15 = call i32 @srandom(i32 %14)
%16 = call i32 (...) @random()
%17 = srem i32 %16, 10
store i32 %17, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %30, %2
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %30
30: ; preds = %26
%31 = load i32, i32* %6
%32 = load i32, i32* %8
%33 = icmp ne i32 %31, %32
br i1 %33, label %19, label %34
34: ; preds = %30
%35 = load i32, i32* %7
%36 = icmp slt i32 %35, 5
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %41
39: ; preds = %34
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
%42 = load i32, i32* %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"\0AEnhorabona.\00"
@.str.6 = [16 x i8] c"\0APots millorar.\00"
@.str.7 = [27 x i8] c" T'ha costat %d intents!!\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [44 x i8] c"\0AAdivina el n\C3\BAmero secret (entre 0 i 9)!!\0A\00"
@str.8 = [53 x i8] c"Has fallat. Torna-ho a provar.\0AIntroduix un n\C3\BAmero:\00"
@str.9 = [22 x i8] c"Introduix un n\C3\BAmero:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @time(i32 0)
%5 = tail call i32 @srandom(i32 %4)
%6 = tail call i32 (...) @random()
%7 = srem i32 %6, 1000
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%10 = tail call i32 @time(i32 0)
%11 = tail call i32 @srandom(i32 %10)
%12 = tail call i32 (...) @random()
%13 = srem i32 %12, 10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %15, %2
%16 = phi i32 [ %23, %15 ], [ -1, %2 ]
%17 = phi i32 [ %22, %15 ], [ 0, %2 ]
%18 = icmp eq i32 %16, -1
%19 = select i1 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @str.8, i64 0, i64 0)
%20 = call i32 @puts(i8* dereferenceable(1) %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%22 = add nuw nsw i32 %17, 1
%23 = load i32, i32* %3
%24 = icmp eq i32 %13, %23
br i1 %24, label %25, label %15
25: ; preds = %15
%26 = icmp ult i32 %17, 4
%27 = select i1 %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}