#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  unsigned int GenerazioneCasualeNumero(unsigned int intervallo);
  unsigned int numeroCasuale;
  unsigned int numeroInput = 0;
  unsigned int intervallo = 1000;
  unsigned int valoreSentinella = 6666;
  srand(time(NULL));
  do {
    printf("Ho un numero tra 1 e %u.\n", intervallo);
    puts("Sei in grado di indovinare il mio numero?.");
    printf("%s", "Inserisci il tuo primo numero: ");
    numeroCasuale = GenerazioneCasualeNumero(intervallo);
    do {
      scanf("%u", &numeroInput);
      if (numeroInput == numeroCasuale) {
        puts("Eccellente! Hai indovinato il numero!");
      } else if (numeroInput > numeroCasuale) {
        puts("Troppo alto. Ritenta.");
      } else if (numeroInput < numeroCasuale) {
        puts("Troppo basso. Ritenta.");
      }
    } while (numeroInput != numeroCasuale);
    puts("Ti piacerebbe giocare ancora?");
    scanf("%u", &numeroInput);
    if (getchar() == 'n') {
      numeroInput = 6666;
    }
  } while (numeroInput != valoreSentinella);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x3e8,-0x10(%rbp)
movl   $0x1a0a,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x10(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7d(%rip),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%edi
call   1030 <GenerazioneCasualeNumero@plt>
mov    %eax,-0x8(%rbp)
lea    0xe80(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    120e <main+0x9e>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
jmp    124d <main+0xdd>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jbe    122b <main+0xbb>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
jmp    1248 <main+0xd8>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1243 <main+0xd3>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
jmp    1248 <main+0xd8>
jmp    124d <main+0xdd>
jmp    1252 <main+0xe2>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11e1 <main+0x71>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
jne    1294 <main+0x124>
movl   $0x1a0a,-0xc(%rbp)
jmp    1299 <main+0x129>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11a4 <main+0x34>
xor    %eax,%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
movl   $0x0,0x4(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xed0(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xec7(%rip),%r12
lea    0xee6(%rip),%r13
lea    0xef5(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe39(%rip),%rdi
mov    $0x3e8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5f(%rip),%rdi
lea    0xe5b(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3e8,%edi
call   1030 <GenerazioneCasualeNumero@plt>
mov    %eax,%r15d
jmp    121c <main+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <puts@plt>
cmp    %r15d,0x4(%rsp)
je     1240 <main+0xd0>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %r12,%rdi
cmp    %r15d,%eax
je     1210 <main+0xa0>
mov    %r13,%rdi
ja     1210 <main+0xa0>
mov    %r14,%rdi
jb     1210 <main+0xa0>
jmp    1215 <main+0xa5>
nop
lea    0xe77(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x6e,%al
je     1270 <main+0x100>
cmpl   $0x1a0a,0x4(%rsp)
jne    11c0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Ho un numero tra 1 e %u.\0A\00"
@.str.1 = [43 x i8] c"Sei in grado di indovinare il mio numero?.\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Inserisci il tuo primo numero: \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [38 x i8] c"Eccellente! Hai indovinato il numero!\00"
@.str.6 = [22 x i8] c"Troppo alto. Ritenta.\00"
@.str.7 = [23 x i8] c"Troppo basso. Ritenta.\00"
@.str.8 = [30 x i8] c"Ti piacerebbe giocare ancora?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1000, i32* %4
store i32 6666, i32* %5
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
br label %8
8: ; preds = %49, %0
%9 = load i32, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* %4
%14 = call i32 @GenerazioneCasualeNumero(i32 %13)
store i32 %14, i32* %2
br label %15
15: ; preds = %37, %8
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %36
22: ; preds = %15
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp ugt i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %35
28: ; preds = %22
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = icmp ult i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
br label %35
35: ; preds = %34, %26
br label %36
36: ; preds = %35, %20
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = load i32, i32* %2
%40 = icmp ne i32 %38, %39
br i1 %40, label %15, label %41
41: ; preds = %37
%42 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%44 = call signext i8 (...) @getchar()
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 110
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 6666, i32* %3
br label %48
48: ; preds = %47, %41
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = load i32, i32* %5
%52 = icmp ne i32 %50, %51
br i1 %52, label %8, label %53
53: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Ho un numero tra 1 e %u.\0A\00"
@.str.1 = [43 x i8] c"Sei in grado di indovinare il mio numero?.\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Inserisci il tuo primo numero: \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [38 x i8] c"Eccellente! Hai indovinato il numero!\00"
@.str.6 = [22 x i8] c"Troppo alto. Ritenta.\00"
@.str.7 = [23 x i8] c"Troppo basso. Ritenta.\00"
@.str.8 = [30 x i8] c"Ti piacerebbe giocare ancora?\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %24, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1000)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @GenerazioneCasualeNumero(i32 1000)
br label %10
10: ; preds = %21, %5
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, %9
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = icmp ugt i32 %12, %9
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = icmp ult i32 %12, %9
br i1 %17, label %18, label %21
18: ; preds = %16, %14, %10
%19 = phi i8* [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), %16 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %18, %16
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%27 = call signext i8 (...) @getchar()
%28 = icmp eq i8 %27, 110
%29 = load i32, i32* %1
%30 = icmp eq i32 %29, 6666
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %32, label %5
32: ; preds = %24
ret i32 0
}