#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*/ creaPercorso();
int /*<<< orphan*/ illegalChoice();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ terminaGioco();
void main() {
  int scelta;
  char conferma;
  while (1) {
    printf("PROGEXAM - MENU PRINCIPALE\n\n1 - Crea percorso\n2 - Muovi "
           "Oberon\n3 - Termina gioco\n\n");
    scanf("%d", &scelta);
    switch (scelta) {
    case 1:
      system("cls");
      creaPercorso();
      system("cls");
      break;
    case 2:
      system("cls");
      printf("Muovi Oberon\n");
      break;
    case 3:
      system("cls");
      printf("Sei sicuro di uscire? (y/n)\n");
      scanf(" %c", &conferma);
      do {
        switch (conferma) {
        case 'y':
          terminaGioco();
          break;
        case 'n':
          break;
        default:
          illegalChoice();
          break;
        }
      } while (conferma == 'y' || conferma == 'n');
      break;
    default:
      illegalChoice();
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    0xed8(%rip),%rdi
xor    %eax,%eax
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11bc <main+0x5c>
jmp    119a <main+0x3a>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11e0 <main+0x80>
jmp    11ab <main+0x4b>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     11fd <main+0x9d>
jmp    1299 <main+0x139>
lea    0xe93(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1070 <creaPercorso@plt>
lea    0xe80(%rip),%rdi
call   1040 <system@plt>
jmp    12a0 <main+0x140>
lea    0xe6f(%rip),%rdi
call   1040 <system@plt>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
jmp    12a0 <main+0x140>
lea    0xe52(%rip),%rdi
call   1040 <system@plt>
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
lea    0xe69(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x6e,%eax
je     1259 <main+0xf9>
jmp    123c <main+0xdc>
mov    -0x10(%rbp),%eax
sub    $0x79,%eax
jne    125e <main+0xfe>
jmp    124d <main+0xed>
mov    $0x0,%al
call   1080 <terminaGioco@plt>
jmp    1265 <main+0x105>
jmp    1265 <main+0x105>
mov    $0x0,%al
call   1030 <illegalChoice@plt>
jmp    126a <main+0x10a>
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x11(%rbp)
je     1289 <main+0x129>
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1227 <main+0xc7>
jmp    12a0 <main+0x140>
mov    $0x0,%al
call   1030 <illegalChoice@plt>
jmp    1168 <main+0x8>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe99(%rip),%r14
lea    0xe87(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe7e(%rip),%rbx
lea    0x3(%rsp),%r13
lea    0xee8(%rip),%rbp
jmp    11b0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <system@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     1200 <main+0xa0>
cmp    $0x2,%eax
je     11a0 <main+0x40>
cmp    $0x1,%eax
jne    1270 <main+0x110>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1070 <creaPercorso@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
jmp    11b0 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
lea    0xdec(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x3(%rsp),%al
nopl   0x0(%rax)
movsbl %al,%ecx
cmp    $0x6e,%ecx
je     125a <main+0xfa>
xor    %eax,%eax
cmp    $0x79,%ecx
jne    1250 <main+0xf0>
call   1080 <terminaGioco@plt>
jmp    1255 <main+0xf5>
cs nopw 0x0(%rax,%rax,1)
call   1030 <illegalChoice@plt>
movzbl 0x3(%rsp),%eax
cmp    $0x6e,%al
je     1230 <main+0xd0>
cmp    $0x79,%al
je     1230 <main+0xd0>
jmp    11b0 <main+0x50>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <illegalChoice@plt>
jmp    11b0 <main+0x50>

LLVM IR (-O0):
@.str = [83 x i8] c"PROGEXAM - MENU PRINCIPALE\0A\0A1 - Crea percorso\0A2 - Muovi Oberon\0A3 - Termina gioco\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [14 x i8] c"Muovi Oberon\0A\00"
@.str.4 = [29 x i8] c"Sei sicuro di uscire? (y/n)\0A\00"
@.str.5 = [4 x i8] c" %c\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8
br label %3
3: ; preds = %0, %40
%4 = call i32 @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %38 [
i32 1, label %7
i32 2, label %11
i32 3, label %14
]
7: ; preds = %3
%8 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @creaPercorso()
%10 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %40
11: ; preds = %3
%12 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %40
14: ; preds = %3
%15 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %2)
br label %18
18: ; preds = %35, %14
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
switch i32 %20, label %24 [
i32 121, label %21
i32 110, label %23
]
21: ; preds = %18
%22 = call i32 (...) @terminaGioco()
br label %26
23: ; preds = %18
br label %26
24: ; preds = %18
%25 = call i32 (...) @illegalChoice()
br label %26
26: ; preds = %24, %23, %21
br label %27
27: ; preds = %26
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 121
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i8, i8* %2
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 110
br label %35
35: ; preds = %31, %27
%36 = phi i1 [ true, %27 ], [ %34, %31 ]
br i1 %36, label %18, label %37
37: ; preds = %35
br label %40
38: ; preds = %3
%39 = call i32 (...) @illegalChoice()
br label %40
40: ; preds = %38, %37, %11, %7
br label %3
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.5 = [4 x i8] c" %c\00"
@str = [82 x i8] c"PROGEXAM - MENU PRINCIPALE\0A\0A1 - Crea percorso\0A2 - Muovi Oberon\0A3 - Termina gioco\0A\00"
@str.6 = [28 x i8] c"Sei sicuro di uscire? (y/n)\00"
@str.7 = [13 x i8] c"Muovi Oberon\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
br label %4
4: ; preds = %34, %0
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
switch i32 %7, label %32 [
i32 1, label %8
i32 2, label %12
i32 3, label %15
]
8: ; preds = %4
%9 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (...) @creaPercorso()
%11 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %34
12: ; preds = %4
%13 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
br label %34
15: ; preds = %4
%16 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%19 = load i8, i8* %2
br label %20
20: ; preds = %31, %15
%21 = phi i8 [ %19, %15 ], [ %30, %31 ]
%22 = sext i8 %21 to i32
switch i32 %22, label %25 [
i32 121, label %23
i32 110, label %29
]
23: ; preds = %20
%24 = call i32 (...) @terminaGioco()
br label %27
25: ; preds = %20
%26 = call i32 (...) @illegalChoice()
br label %27
27: ; preds = %25, %23
%28 = load i8, i8* %2
br label %29
29: ; preds = %27, %20
%30 = phi i8 [ %28, %27 ], [ %21, %20 ]
switch i8 %30, label %34 [
i8 121, label %31
i8 110, label %31
]
31: ; preds = %29, %29
br label %20
32: ; preds = %4
%33 = call i32 (...) @illegalChoice()
br label %34
34: ; preds = %29, %32, %12, %8
br label %4
}