#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 hai_vinto(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, vinto;
  do {
    printf("Inserisci un numero: ");
    scanf("%d", &n);
    if (n) {
      vinto = hai_vinto(n);
      if (vinto)
        printf("Hai vinto\n");
      else
        printf("Hai perso\n");
    }
  } while (n != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     119c <main+0x6c>
mov    -0x8(%rbp),%edi
call   1050 <hai_vinto@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     118b <main+0x5b>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    1197 <main+0x67>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <main+0x6c>
jmp    11a1 <main+0x71>
cmpl   $0x0,-0x8(%rbp)
jne    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%r14
lea    0xebb(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xeb2(%rip),%r12
lea    0xeb5(%rip),%r13
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
je     11a5 <main+0x65>
call   1060 <hai_vinto@plt>
test   %eax,%eax
mov    %r13,%rdi
cmove  %r12,%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Inserisci un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Hai vinto\0A\00"
@.str.3 = [11 x i8] c"Hai perso\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %20, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = load i32, i32* %2
%11 = call i32 @hai_vinto(i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
br label %19
19: ; preds = %18, %4
br label %20
20: ; preds = %19
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 0
br i1 %22, label %4, label %23
23: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Inserisci un numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [10 x i8] c"Hai perso\00"
@str.4 = [10 x i8] c"Hai vinto\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %8, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = call i32 @hai_vinto(i32 %6)
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0)
%12 = call i32 @puts(i8* dereferenceable(1) %11)
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %3
15: ; preds = %3, %8
ret i32 0
}