#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 main() {
  int n;
  int cont;
  int nc;
  int indovinato;
  nc = rand() % 15;
  indovinato = 0;
  cont = 10;
  printf("il pc ha pensato un numero da 1 a 14");
  do {
    printf("\nIndovinalo con 10 tentativi:");
    scanf("%d", &n);
    if (n == nc) {
      indovinato = 1;
    }
    cont--;
  } while (cont > 0 && indovinato == 0);
  if (indovinato == 1) {
    printf("Hai vinto");
  } else {
    printf("Hai perso");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xa,-0xc(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    119a <main+0x6a>
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jle    11bc <main+0x8c>
cmpl   $0x0,-0x14(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    116b <main+0x3b>
cmpl   $0x1,-0x14(%rbp)
jne    11e2 <main+0xb2>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
jmp    11ee <main+0xbe>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rbx
imul   $0xffffffff88888889,%rbx,%rax
shr    $0x20,%rax
add    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x3,%eax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    $0xa,%ebp
lea    0xea8(%rip),%r14
lea    0xebf(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%ebp
jb     11b3 <main+0x83>
add    $0xffffffff,%ebp
cmp    %ebx,%eax
jne    1190 <main+0x60>
cmp    %ebx,%eax
lea    0xe8a(%rip),%rax
lea    0xe8d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"il pc ha pensato un numero da 1 a 14\00"
@.str.1 = [30 x i8] c"\0AIndovinalo con 10 tentativi:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"Hai vinto\00"
@.str.4 = [10 x i8] c"Hai perso\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 i32 (...) @rand()
%7 = srem i32 %6, 15
store i32 %7, i32* %4
store i32 0, i32* %5
store i32 10, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %25, %0
%10 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 1, i32* %5
br label %16
16: ; preds = %15, %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, -1
store i32 %18, i32* %3
br label %19
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 0
br label %25
25: ; preds = %22, %19
%26 = phi i1 [ false, %19 ], [ %24, %22 ]
br i1 %26, label %9, label %27
27: ; preds = %25
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [37 x i8] c"il pc ha pensato un numero da 1 a 14\00"
@.str.1 = [30 x i8] c"\0AIndovinalo con 10 tentativi:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"Hai vinto\00"
@.str.4 = [10 x i8] c"Hai perso\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 15
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ 10, %0 ], [ %13, %6 ]
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, %4
%12 = xor i1 %11, true
%13 = add nsw i32 %7, -1
%14 = icmp ugt i32 %7, 1
%15 = select i1 %14, i1 %12, i1 false
br i1 %15, label %6, label %16
16: ; preds = %6
%17 = select i1 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0)
%18 = call i32 @printf(i8* dereferenceable(1) %17)
ret i32 0
}