#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ mostraPartenze(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ mostraPrezzo(int /*<<< orphan*/ *, float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
unsigned int scanf(char *, ...);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ visualizza(int /*<<< orphan*/ *);
int main(void) {
  FILE *alfa;
  unsigned int scelta;
  unsigned int esitoScanf;
  char partenza[21];
  float minimo;
  float massimo;
  if ((alfa = fopen("ElencoTreni.txt", "r")) == NULL) {
    puts("Attenzione non è stato possibile aprire il file ElencoTreni.txt");
  } else {
    puts("Selezionare la modalità di utilizzo");
    puts("0 - Visualizza tutti i treni nel file");
    puts("1 - Inserisci una partenza e mostra se ci sono treni che partono da "
         "li");
    puts("2 - Inserisci un range minimo e massimo e mostra i treni nel range");
    puts("3 - Esci");
    do {
      if ((esitoScanf = scanf("%d", &scelta)) == 0 || scelta > 3) {
        scanf("%*[^\n]");
        puts("Input non valido");
      }
    } while (esitoScanf == 0);
    if (scelta == 0) {
      visualizza(alfa);
    } else if (scelta == 1) {
      printf("%s", "Inserire la partenza: ");
      scanf("%20s", partenza);
      mostraPartenze(alfa, partenza);
    } else if (scelta == 2) {
      printf("Inserire il prezzo minimo :");
      scanf("%f", &minimo);
      printf("\nInserire il prezzo massimo :");
      scanf("%f", &massimo);
      mostraPrezzo(alfa, minimo, massimo);
    } else {
    }
  }
  fclose(alfa);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe53(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11d1 <main+0x41>
lea    0xe3b(%rip),%rdi
call   1050 <puts@plt>
jmp    132f <main+0x19f>
lea    0xe6b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe84(%rip),%rdi
call   1050 <puts@plt>
lea    0xe9e(%rip),%rdi
call   1050 <puts@plt>
lea    0xed9(%rip),%rdi
call   1050 <puts@plt>
lea    0xf10(%rip),%rdi
call   1050 <puts@plt>
lea    0xf0d(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     1235 <main+0xa5>
cmpl   $0x3,-0x14(%rbp)
jbe    124f <main+0xbf>
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    0xee1(%rip),%rdi
call   1050 <puts@plt>
jmp    1254 <main+0xc4>
cmpl   $0x0,-0x18(%rbp)
je     120d <main+0x7d>
cmpl   $0x0,-0x14(%rbp)
jne    1276 <main+0xe6>
mov    -0x10(%rbp),%rdi
call   10a0 <visualizza@plt>
jmp    132a <main+0x19a>
cmpl   $0x1,-0x14(%rbp)
jne    12b9 <main+0x129>
lea    0xeb5(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <mostraPartenze@plt>
jmp    1325 <main+0x195>
cmpl   $0x2,-0x14(%rbp)
jne    131b <main+0x18b>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    -0x10(%rbp),%rdi
movss  -0x34(%rbp),%xmm0
movss  -0x38(%rbp),%xmm1
call   1040 <mostraPrezzo@plt>
jmp    1320 <main+0x190>
jmp    1320 <main+0x190>
jmp    1325 <main+0x195>
jmp    132a <main+0x19a>
jmp    132f <main+0x19f>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
lea    0xe59(%rip),%rdi
call   1070 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1275 <main+0xe5>
lea    0xe7f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe98(%rip),%rdi
call   1050 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1050 <puts@plt>
lea    0xeed(%rip),%rdi
call   1050 <puts@plt>
lea    0xf24(%rip),%rdi
call   1050 <puts@plt>
lea    0xf21(%rip),%r15
lea    0x8(%rsp),%rbx
lea    0xf18(%rip),%r12
lea    0xf18(%rip),%r13
jmp    1236 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
test   %ebp,%ebp
jne    1252 <main+0xc2>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1220 <main+0x90>
cmpl   $0x4,0x8(%rsp)
jb     1232 <main+0xa2>
jmp    1220 <main+0x90>
mov    0x8(%rsp),%eax
cmp    $0x2,%eax
je     1286 <main+0xf6>
cmp    $0x1,%eax
je     12dd <main+0x14d>
test   %eax,%eax
jne    1313 <main+0x183>
mov    %r14,%rdi
call   10a0 <visualizza@plt>
jmp    1313 <main+0x183>
lea    0xd86(%rip),%rdi
call   1050 <puts@plt>
jmp    1313 <main+0x183>
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xedc(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mov    %r14,%rdi
call   1040 <mostraPrezzo@plt>
jmp    1313 <main+0x183>
lea    0xe58(%rip),%rdi
lea    0xe54(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <mostraPartenze@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0xe76(%rip),%rdi
call   1070 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"ElencoTreni.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [65 x i8] c"Attenzione non \C3\A8 stato possibile aprire il file ElencoTreni.txt\00"
@.str.3 = [37 x i8] c"Selezionare la modalit\C3\A0 di utilizzo\00"
@.str.4 = [38 x i8] c"0 - Visualizza tutti i treni nel file\00"
@.str.5 = [71 x i8] c"1 - Inserisci una partenza e mostra se ci sono treni che partono da li\00"
@.str.6 = [67 x i8] c"2 - Inserisci un range minimo e massimo e mostra i treni nel range\00"
@.str.7 = [9 x i8] c"3 - Esci\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [7 x i8] c"%*[^\0A]\00"
@.str.10 = [17 x i8] c"Input non valido\00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [23 x i8] c"Inserire la partenza: \00"
@.str.13 = [5 x i8] c"%20s\00"
@.str.14 = [28 x i8] c"Inserire il prezzo minimo :\00"
@.str.15 = [3 x i8] c"%f\00"
@.str.16 = [30 x i8] c"\0AInserire il prezzo massimo :\00"
@.str.17 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [21 x i8]
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @puts(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0))
br label %63
12: ; preds = %0
%13 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @puts(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @puts(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %18
18: ; preds = %28, %12
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
store i32 %19, i32* %4
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %3
%23 = icmp ugt i32 %22, 3
br i1 %23, label %24, label %27
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%26 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %18, label %31
31: ; preds = %28
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32*, i32** %2
%36 = call i32 @visualizza(i32* %35)
br label %62
37: ; preds = %31
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%42 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* %42)
%44 = load i32*, i32** %2
%45 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%46 = call i32 @mostraPartenze(i32* %44, i8* %45)
br label %61
47: ; preds = %37
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, 2
br i1 %49, label %50, label %59
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%52 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), float* %6)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), float* %7)
%55 = load i32*, i32** %2
%56 = load float, float* %6
%57 = load float, float* %7
%58 = call i32 @mostraPrezzo(i32* %55, float %56, float %57)
br label %60
59: ; preds = %47
br label %60
60: ; preds = %59, %50
br label %61
61: ; preds = %60, %40
br label %62
62: ; preds = %61, %34
br label %63
63: ; preds = %62, %10
%64 = load i32*, i32** %2
%65 = call i32 @fclose(i32* %64)
%66 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"ElencoTreni.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [65 x i8] c"Attenzione non \C3\A8 stato possibile aprire il file ElencoTreni.txt\00"
@.str.3 = [37 x i8] c"Selezionare la modalit\C3\A0 di utilizzo\00"
@.str.4 = [38 x i8] c"0 - Visualizza tutti i treni nel file\00"
@.str.5 = [71 x i8] c"1 - Inserisci una partenza e mostra se ci sono treni che partono da li\00"
@.str.6 = [67 x i8] c"2 - Inserisci un range minimo e massimo e mostra i treni nel range\00"
@.str.7 = [9 x i8] c"3 - Esci\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [7 x i8] c"%*[^\0A]\00"
@.str.10 = [17 x i8] c"Input non valido\00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [23 x i8] c"Inserire la partenza: \00"
@.str.13 = [5 x i8] c"%20s\00"
@.str.14 = [28 x i8] c"Inserire il prezzo minimo :\00"
@.str.15 = [3 x i8] c"%f\00"
@.str.16 = [30 x i8] c"\0AInserire il prezzo massimo :\00"
@.str.17 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = alloca float
%4 = alloca float
%5 = bitcast i32* %1 to i8*
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0))
br label %45
13: ; preds = %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %19
19: ; preds = %28, %13
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%21 = icmp eq i32 %20, 0
%22 = load i32, i32* %1
%23 = icmp ugt i32 %22, 3
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %28
28: ; preds = %25, %19
br i1 %21, label %19, label %29
29: ; preds = %28
%30 = load i32, i32* %1
switch i32 %30, label %45 [
i32 0, label %31
i32 1, label %33
i32 2, label %37
]
31: ; preds = %29
%32 = call i32 @visualizza(i32* %9)
br label %45
33: ; preds = %29
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* %6)
%36 = call i32 @mostraPartenze(i32* %9, i8* %6)
br label %45
37: ; preds = %29
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), float* %3)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), float* %4)
%42 = load float, float* %3
%43 = load float, float* %4
%44 = call i32 @mostraPrezzo(i32* %9, float %42, float %43)
br label %45
45: ; preds = %29, %31, %37, %33, %11
%46 = call i32 @fclose(i32* %9)
%47 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
ret i32 0
}