#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_u;
  int n_c;
  int j;
  int indovinato;
  n_c = rand() % 15;
  j = 10;
  indovinato = 0;
  printf("Inserisci il numero casuale ");
  scanf("%d", &n_u);
  do {
    printf("\nHai 10 tentativi per indovinarlo: ");
    scanf("%d", &n_c);
    if (n_u == n_c) {
      indovinato = 1;
    }
    j--;
  } while (j > 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,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11aa <main+0x7a>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
jle    11cc <main+0x9c>
cmpl   $0x0,-0x14(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    117b <main+0x4b>
cmpl   $0x1,-0x14(%rbp)
jne    11f2 <main+0xc2>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    11fe <main+0xce>
lea    0xe56(%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   %rbx
push   %rax
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xea8(%rip),%r14
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
mov    $0xa,%ebp
lea    0xe92(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%ecx
cmp    $0x2,%ebp
jb     11c6 <main+0x96>
add    $0xffffffff,%ebp
cmp    %ecx,%eax
jne    11a0 <main+0x70>
cmp    %ecx,%eax
lea    0xe75(%rip),%rax
lea    0xe79(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [29 x i8] c"Inserisci il numero casuale \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0AHai 10 tentativi per indovinarlo: \00"
@.str.3 = [11 x i8] c"Hai vinto!\00"
@.str.4 = [13 x i8] c"Hai perso :(\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 15
store i32 %6, i32* %2
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %9
9: ; preds = %9, %0
%10 = phi i32 [ 10, %0 ], [ %17, %9 ]
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = icmp eq i32 %13, %14
%16 = xor i1 %15, true
%17 = add nsw i32 %10, -1
%18 = icmp ugt i32 %10, 1
%19 = select i1 %18, i1 %16, i1 false
br i1 %19, label %9, label %20
20: ; preds = %9
%21 = select i1 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0)
%22 = call i32 @printf(i8* dereferenceable(1) %21)
ret i32 0
}