#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*/ Cerca(char *);
int /*<<< orphan*/ CercaE(int);
scalar_t__ EOF;
int Elimina(char *);
int /*<<< orphan*/ Inserisci(char *, int);
int /*<<< orphan*/ InserisciCoda(char *, int);
int /*<<< orphan*/ Inseriscio(char *, int);
int /*<<< orphan*/ Salva(int /*<<< orphan*/ *);
int /*<<< orphan*/ Stampa();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int menu, Esami, cEsami;
  char buffer[200];
  char nomef[256];
  FILE *db;
  printf("Quale file vuoi caricare: ");
  scanf("%s", nomef);
  if (!(db = fopen(nomef, "r"))) {
    printf("\nIl file da te cercato non esiste. Ora lo creo...\n");
    db = fopen(nomef, "w");
  } else {
    while (fscanf(db, "%s", buffer) != EOF) {
      fscanf(db, "%d", &Esami);
      fscanf(db, "%s", nomef);
      Inseriscio(buffer, Esami);
    }
  }
  fclose(db);
  do {
    printf("\n--------");
    printf("\nMenu':\n");
    printf("\n1: Inserisci studente");
    printf("\n2: Inserisci studente in coda");
    printf("\n3: Inserisci studente ordinatamente");
    printf("\n4: Stampa studenti");
    printf("\n5: Cerca studente");
    printf("\n6: Cerca studenti per numero di Esami");
    printf("\n7: Elimina");
    printf("\n8: Salva ed esci");
    printf("\n");
    printf("\nInserisci la scelta: ");
    while (scanf("%d", &menu) <= 0)
      fflush(stdin);
    switch (menu) {
    case 1:
      printf("\nInserisci il cognome: ");
      scanf("%s", buffer);
      printf("\nInserisci il numero di Esami: ");
      scanf("%d", &Esami);
      Inserisci(buffer, Esami);
      break;
    case 2:
      printf("\nInserisci il cognome: ");
      scanf("%s", buffer);
      printf("\nInserisci il numero di Esami: ");
      scanf("%d", &Esami);
      InserisciCoda(buffer, Esami);
      break;
    case 3:
      printf("\nInserisci il cognome: ");
      scanf("%s", buffer);
      printf("\nInserisci il numero di Esami: ");
      scanf("%d", &Esami);
      Inseriscio(buffer, Esami);
      break;
    case 4:
      Stampa();
      break;
    case 5:
      printf("\nInserisci il cognome da ricercare: ");
      scanf("%s", buffer);
      Cerca(buffer);
      break;
    case 6:
      printf("\nInserisci il numero di Esami: ");
      scanf("%d", &cEsami);
      CercaE(cEsami);
      break;
    case 7:
      printf("\nInserisci il cognome: ");
      scanf("%s", buffer);
      printf("\nsono stati eliminati %d elemnti", Elimina(buffer));
      break;
    case 8:
      break;
    default:
      printf("\nIl valore inserito non e' valido!\n");
    }
  } while (menu != 8);
  printf("Su quale file vuoi salvare?: ");
  scanf("%s", nomef);
  db = fopen(nomef, "w");
  Salva(db);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f0(%rbp),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0x1f0(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1f8(%rbp)
cmp    $0x0,%rax
jne    126d <main+0x8d>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f0(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1f8(%rbp)
jmp    12ec <main+0x10c>
jmp    1272 <main+0x92>
mov    -0x1f8(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xdb4(%rip),%rsi
mov    $0x0,%al
call   1080 <fscanf@plt>
mov    0x2d4b(%rip),%rcx
cmp    (%rcx),%rax
je     12e7 <main+0x107>
mov    -0x1f8(%rbp),%rdi
lea    0xdc9(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1080 <fscanf@plt>
mov    -0x1f8(%rbp),%rdi
lea    -0x1f0(%rbp),%rdx
lea    0xd6f(%rip),%rsi
mov    $0x0,%al
call   1080 <fscanf@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10b0 <Inseriscio@plt>
jmp    1272 <main+0x92>
jmp    12ec <main+0x10c>
mov    -0x1f8(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcce(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   10e0 <scanf@plt>
cmp    $0x0,%rax
jg     13cf <main+0x1ef>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
jmp    13a0 <main+0x1c0>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x200(%rbp)
sub    $0x7,%eax
ja     15b9 <main+0x3d9>
mov    -0x200(%rbp),%rax
lea    0xc0b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xc21(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc3f(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10a0 <Inserisci@plt>
jmp    15c7 <main+0x3e7>
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xbca(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbe8(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1070 <InserisciCoda@plt>
jmp    15c7 <main+0x3e7>
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xb73(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb91(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   10b0 <Inseriscio@plt>
jmp    15c7 <main+0x3e7>
mov    $0x0,%al
call   1090 <Stampa@plt>
jmp    15c7 <main+0x3e7>
lea    0xc8b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xb10(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0xf0(%rbp),%rdi
call   10d0 <Cerca@plt>
jmp    15c7 <main+0x3e7>
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb1d(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   10e0 <scanf@plt>
mov    -0x1c(%rbp),%edi
call   1030 <CercaE@plt>
jmp    15c7 <main+0x3e7>
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xaaf(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0xf0(%rbp),%rdi
call   10f0 <Elimina@plt>
mov    %eax,%esi
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15c7 <main+0x3e7>
jmp    15c7 <main+0x3e7>
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15cc <main+0x3ec>
cmpl   $0x8,-0x14(%rbp)
jne    12f8 <main+0x118>
lea    0xc2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f0(%rbp),%rsi
lea    0xa49(%rip),%rdi
mov    $0x0,%al
call   10e0 <scanf@plt>
lea    -0x1f0(%rbp),%rdi
lea    0xa6c(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1f8(%rbp)
mov    -0x1f8(%rbp),%rdi
call   1050 <Salva@plt>
mov    -0x4(%rbp),%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d8,%rsp
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe15(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
lea    0xe02(%rip),%rsi
mov    %rbx,%rdi
call   1120 <fopen@plt>
test   %rax,%rax
je     12e7 <main+0xe7>
mov    %rax,%rbx
lea    0xde4(%rip),%rsi
lea    0x110(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   10a0 <fscanf@plt>
mov    0x2d70(%rip),%r14
cmp    (%r14),%rax
je     1307 <main+0x107>
lea    0x4(%rsp),%r15
lea    0xdb6(%rip),%r13
lea    0x10(%rsp),%r12
lea    0x110(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xd98(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <fscanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <fscanf@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   10d0 <Inseriscio@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fscanf@plt>
cmp    (%r14),%rax
jne    12a0 <main+0xa0>
jmp    1307 <main+0x107>
lea    0xedb(%rip),%rdi
call   1040 <puts@plt>
lea    0xd46(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1120 <fopen@plt>
mov    %rax,%rbx
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xe00(%rip),%rbx
lea    0xd25(%rip),%rbp
lea    0x8(%rsp),%r14
mov    0x2cbf(%rip),%r12
lea    0xcd0(%rip),%r13
lea    0x110(%rsp),%r15
jmp    135b <main+0x15b>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x8,0x8(%rsp)
je     15c0 <main+0x3c0>
lea    0xce3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
lea    0xcd3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xcdc(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xced(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd04(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd0a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd0f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd28(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd26(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
test   %rax,%rax
jg     1420 <main+0x220>
mov    (%r12),%edi
call   10e0 <fflush@plt>
jmp    1400 <main+0x200>
nopl   (%rax)
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x7,%eax
ja     133a <main+0x13a>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
lea    0xcec(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xbec(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
lea    0xce5(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   10c0 <Inserisci@plt>
jmp    1350 <main+0x150>
lea    0xc9f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb9f(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
lea    0xc98(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   1090 <InserisciCoda@plt>
jmp    1350 <main+0x150>
lea    0xc52(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb52(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
lea    0xc4b(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   10d0 <Inseriscio@plt>
jmp    1350 <main+0x150>
xor    %eax,%eax
call   10b0 <Stampa@plt>
jmp    1350 <main+0x150>
lea    0xc31(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xaf9(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
mov    %r15,%rdi
call   10f0 <Cerca@plt>
jmp    1350 <main+0x150>
lea    0xbe5(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
mov    0xc(%rsp),%edi
call   1050 <CercaE@plt>
jmp    1350 <main+0x150>
lea    0xba2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xaa2(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
mov    %r15,%rdi
call   1110 <Elimina@plt>
lea    0xbd8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1350 <main+0x150>
lea    0xbe4(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xa66(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1100 <scanf@plt>
lea    0xa55(%rip),%rsi
mov    %rbx,%rdi
call   1120 <fopen@plt>
mov    %rax,%rdi
call   1070 <Salva@plt>
xor    %eax,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Quale file vuoi caricare: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [51 x i8] c"\0AIl file da te cercato non esiste. Ora lo creo...\0A\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i64 0
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [10 x i8] c"\0A--------\00"
@.str.7 = [9 x i8] c"\0AMenu':\0A\00"
@.str.8 = [23 x i8] c"\0A1: Inserisci studente\00"
@.str.9 = [31 x i8] c"\0A2: Inserisci studente in coda\00"
@.str.10 = [37 x i8] c"\0A3: Inserisci studente ordinatamente\00"
@.str.11 = [20 x i8] c"\0A4: Stampa studenti\00"
@.str.12 = [19 x i8] c"\0A5: Cerca studente\00"
@.str.13 = [39 x i8] c"\0A6: Cerca studenti per numero di Esami\00"
@.str.14 = [12 x i8] c"\0A7: Elimina\00"
@.str.15 = [18 x i8] c"\0A8: Salva ed esci\00"
@.str.16 = [2 x i8] c"\0A\00"
@.str.17 = [23 x i8] c"\0AInserisci la scelta: \00"
@stdin = global i32 0
@.str.18 = [24 x i8] c"\0AInserisci il cognome: \00"
@.str.19 = [32 x i8] c"\0AInserisci il numero di Esami: \00"
@.str.20 = [37 x i8] c"\0AInserisci il cognome da ricercare: \00"
@.str.21 = [33 x i8] c"\0Asono stati eliminati %d elemnti\00"
@.str.22 = [36 x i8] c"\0AIl valore inserito non e' valido!\0A\00"
@.str.23 = [30 x i8] c"Su quale file vuoi salvare?: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [200 x i8]
%10 = alloca [256 x i8]
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%14 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %16, i32** %11
%17 = icmp ne i32* %16, null
br i1 %17, label %22, label %18
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %21, i32** %11
br label %39
22: ; preds = %2
br label %23
23: ; preds = %29, %22
%24 = load i32*, i32** %11
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%26 = call i64 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i64, i64* @EOF
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %23
%30 = load i32*, i32** %11
%31 = call i64 (i32*, i8*, ...) @fscanf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%32 = load i32*, i32** %11
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%34 = call i64 (i32*, i8*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%36 = load i32, i32* %7
%37 = call i32 @Inseriscio(i8* %35, i32 %36)
br label %23
38: ; preds = %23
br label %39
39: ; preds = %38, %18
%40 = load i32*, i32** %11
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %114, %39
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
br label %55
55: ; preds = %58, %42
%56 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%57 = icmp sle i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* @stdin
%60 = call i32 @fflush(i32 %59)
br label %55
61: ; preds = %55
%62 = load i32, i32* %6
switch i32 %62, label %111 [
i32 1, label %63
i32 2, label %72
i32 3, label %81
i32 4, label %90
i32 5, label %92
i32 6, label %98
i32 7, label %103
i32 8, label %110
]
63: ; preds = %61
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%65 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%66 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%68 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%69 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%70 = load i32, i32* %7
%71 = call i32 @Inserisci(i8* %69, i32 %70)
br label %113
72: ; preds = %61
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%74 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%75 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%77 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%78 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%79 = load i32, i32* %7
%80 = call i32 @InserisciCoda(i8* %78, i32 %79)
br label %113
81: ; preds = %61
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%83 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%84 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%86 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%87 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%88 = load i32, i32* %7
%89 = call i32 @Inseriscio(i8* %87, i32 %88)
br label %113
90: ; preds = %61
%91 = call i32 (...) @Stampa()
br label %113
92: ; preds = %61
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.20, i64 0, i64 0))
%94 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%95 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %94)
%96 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%97 = call i32 @Cerca(i8* %96)
br label %113
98: ; preds = %61
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%100 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %8)
%101 = load i32, i32* %8
%102 = call i32 @CercaE(i32 %101)
br label %113
103: ; preds = %61
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%105 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%106 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %105)
%107 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%108 = call i32 @Elimina(i8* %107)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.21, i64 0, i64 0), i32 %108)
br label %113
110: ; preds = %61
br label %113
111: ; preds = %61
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.22, i64 0, i64 0))
br label %113
113: ; preds = %111, %110, %103, %98, %92, %90, %81, %72, %63
br label %114
114: ; preds = %113
%115 = load i32, i32* %6
%116 = icmp ne i32 %115, 8
br i1 %116, label %42, label %117
117: ; preds = %114
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.23, i64 0, i64 0))
%119 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%120 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %119)
%121 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%122 = call i32* @fopen(i8* %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %122, i32** %11
%123 = load i32*, i32** %11
%124 = call i32 @Salva(i32* %123)
%125 = load i32, i32* %3
ret i32 %125
}

LLVM IR (-O2):
@.str = [27 x i8] c"Quale file vuoi caricare: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i64 0
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [10 x i8] c"\0A--------\00"
@.str.8 = [23 x i8] c"\0A1: Inserisci studente\00"
@.str.9 = [31 x i8] c"\0A2: Inserisci studente in coda\00"
@.str.10 = [37 x i8] c"\0A3: Inserisci studente ordinatamente\00"
@.str.11 = [20 x i8] c"\0A4: Stampa studenti\00"
@.str.12 = [19 x i8] c"\0A5: Cerca studente\00"
@.str.13 = [39 x i8] c"\0A6: Cerca studenti per numero di Esami\00"
@.str.14 = [12 x i8] c"\0A7: Elimina\00"
@.str.15 = [18 x i8] c"\0A8: Salva ed esci\00"
@.str.17 = [23 x i8] c"\0AInserisci la scelta: \00"
@stdin = global i32 0
@.str.18 = [24 x i8] c"\0AInserisci il cognome: \00"
@.str.19 = [32 x i8] c"\0AInserisci il numero di Esami: \00"
@.str.20 = [37 x i8] c"\0AInserisci il cognome da ricercare: \00"
@.str.21 = [33 x i8] c"\0Asono stati eliminati %d elemnti\00"
@.str.23 = [30 x i8] c"Su quale file vuoi salvare?: \00"
@str = [50 x i8] c"\0AIl file da te cercato non esiste. Ora lo creo...\00"
@str.24 = [8 x i8] c"\0AMenu':\00"
@str.25 = [35 x i8] c"\0AIl valore inserito non e' valido!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [200 x i8]
%7 = alloca [256 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%14 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%15 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %21, label %17
17: ; preds = %2
%18 = call i64 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %32, label %24
21: ; preds = %2
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%23 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %32
24: ; preds = %17, %24
%25 = call i64 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%26 = call i64 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%27 = load i32, i32* %4
%28 = call i32 @Inseriscio(i8* %11, i32 %27)
%29 = call i64 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%30 = load i64, i64* @EOF
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %24
32: ; preds = %24, %17, %21
%33 = phi i32* [ %23, %21 ], [ %15, %17 ], [ %15, %24 ]
%34 = call i32 @fclose(i32* %33)
br label %35
35: ; preds = %96, %32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.24, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%46 = call i32 @putchar(i32 10)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%48 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%49 = icmp slt i64 %48, 1
br i1 %49, label %50, label %55
50: ; preds = %35, %50
%51 = load i32, i32* @stdin
%52 = call i32 @fflush(i32 %51)
%53 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%54 = icmp slt i64 %53, 1
br i1 %54, label %50, label %55
55: ; preds = %50, %35
%56 = load i32, i32* %3
switch i32 %56, label %94 [
i32 1, label %57
i32 2, label %64
i32 3, label %71
i32 4, label %78
i32 5, label %80
i32 6, label %84
i32 7, label %89
i32 8, label %99
]
57: ; preds = %55
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%59 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%61 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%62 = load i32, i32* %4
%63 = call i32 @Inserisci(i8* %11, i32 %62)
br label %96
64: ; preds = %55
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%66 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%68 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%69 = load i32, i32* %4
%70 = call i32 @InserisciCoda(i8* %11, i32 %69)
br label %96
71: ; preds = %55
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%73 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%75 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%76 = load i32, i32* %4
%77 = call i32 @Inseriscio(i8* %11, i32 %76)
br label %96
78: ; preds = %55
%79 = call i32 (...) @Stampa()
br label %96
80: ; preds = %55
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.20, i64 0, i64 0))
%82 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%83 = call i32 @Cerca(i8* %11)
br label %96
84: ; preds = %55
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.19, i64 0, i64 0))
%86 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%87 = load i32, i32* %5
%88 = call i32 @CercaE(i32 %87)
br label %96
89: ; preds = %55
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0))
%91 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%92 = call i32 @Elimina(i8* %11)
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.21, i64 0, i64 0), i32 %92)
br label %96
94: ; preds = %55
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.25, i64 0, i64 0))
br label %96
96: ; preds = %57, %64, %71, %78, %80, %84, %89, %94
%97 = load i32, i32* %3
%98 = icmp eq i32 %97, 8
br i1 %98, label %99, label %35
99: ; preds = %55, %96
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.23, i64 0, i64 0))
%101 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%102 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%103 = call i32 @Salva(i32* %102)
ret i32 0
}