#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int scanf(char *, int *);
int main(void) {
  int numero_studenti, numero_esami, esito, i, j, k;
  char codice_esame[6], nome_esame[51];
  FILE *output;
  printf("\nInserire il numero di studenti da generare: ");
  do {
    esito = scanf("%d", &numero_studenti);
    if (esito != 1 || numero_studenti < 1) {
      printf("\nScelta non valida!\n ... ");
      while (getchar() != '\n')
        ;
    }
  } while (esito != 1 || numero_studenti < 1);
  printf("Inserire il numero di esami da generare per ogni studente: ");
  do {
    esito = scanf("%d", &numero_esami);
    if (esito != 1 || numero_esami < 0) {
      printf("\nScelta non valida!\n ... ");
      while (getchar() != '\n')
        ;
    }
  } while (esito != 1 || numero_esami < 0);
  output = fopen("./random", "w");
  fprintf(output, "%d\n", numero_studenti);
  for (i = 0; i < numero_studenti; i++) {
    fprintf(output, "%d\n", rand());
    fprintf(output, "%d\n", numero_esami);
    for (j = 0; j < numero_esami; j++) {
      for (k = 0; k < 6 - 1; k++) {
        if (k < (6 / 2))
          codice_esame[k] = ((rand() % 26) + 'A');
        else
          codice_esame[k] = ((rand() % 10) + '0');
      }
      codice_esame[k] = '\0';
      fprintf(output, "%s ", codice_esame);
      nome_esame[0] = ((rand() % 26) + 'A');
      for (k = 1; k < (51 - (51 / 2)); k++)
        nome_esame[k] = ((rand() % 26) + 'a');
      nome_esame[k] = '\0';
      fprintf(output, "%s ", nome_esame);
      fprintf(output, "%d\n", ((rand() % 12) + 18));
    }
    fprintf(output, "\n");
  }
  fclose(output);
  printf("Il database casuale di studenti è stato salvato in \"%s\"!\n\n",
         "./random");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11b7 <main+0x47>
cmpl   $0x1,-0x8(%rbp)
jge    11e2 <main+0x72>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11dd <main+0x6d>
jmp    11c5 <main+0x55>
jmp    11e2 <main+0x72>
jmp    11e7 <main+0x77>
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x69(%rbp)
jne    1200 <main+0x90>
cmpl   $0x1,-0x8(%rbp)
setl   %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    1190 <main+0x20>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1240 <main+0xd0>
cmpl   $0x0,-0xc(%rbp)
jge    126b <main+0xfb>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1266 <main+0xf6>
jmp    124e <main+0xde>
jmp    126b <main+0xfb>
jmp    1270 <main+0x100>
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x6a(%rbp)
jne    1289 <main+0x119>
cmpl   $0x0,-0xc(%rbp)
setl   %al
mov    %al,-0x6a(%rbp)
mov    -0x6a(%rbp),%al
test   $0x1,%al
jne    1219 <main+0xa9>
lea    0xdec(%rip),%rdi
lea    0xdee(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1473 <main+0x303>
mov    -0x68(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%edx
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x68(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1453 <main+0x2e3>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    1389 <main+0x219>
cmpl   $0x3,-0x1c(%rbp)
jge    135a <main+0x1ea>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x22(%rbp,%rax,1)
jmp    1376 <main+0x206>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x22(%rbp,%rax,1)
jmp    137b <main+0x20b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1325 <main+0x1b5>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x22(%rbp,%rax,1)
mov    -0x68(%rbp),%rdi
lea    -0x22(%rbp),%rdx
lea    0xcf5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%al
mov    %al,-0x60(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1a,-0x1c(%rbp)
jge    13fa <main+0x28a>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %dl,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13c6 <main+0x256>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x68(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xc84(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x80(%rbp),%rdi
mov    $0xc,%ecx
cltd
idiv   %ecx
add    $0x12,%edx
lea    0xc54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1312 <main+0x1a2>
mov    -0x68(%rbp),%rdi
lea    0xc76(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c7 <main+0x157>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xc17(%rip),%rdi
lea    0xbfd(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8b(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe82(%rip),%r15
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    11e0 <main+0x60>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    11e0 <main+0x60>
cmp    $0x1,%ebp
jne    11b0 <main+0x30>
test   %eax,%eax
jle    11b0 <main+0x30>
jmp    1206 <main+0x86>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    11f0 <main+0x70>
mov    0x10(%rsp),%eax
cmp    $0x1,%ebp
je     11cf <main+0x4f>
jmp    11b0 <main+0x30>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe13(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xe0a(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    1260 <main+0xe0>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     1260 <main+0xe0>
cmp    $0x1,%ebp
jne    1230 <main+0xb0>
test   %eax,%eax
js     1230 <main+0xb0>
jmp    1286 <main+0x106>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    1270 <main+0xf0>
mov    0xc(%rsp),%eax
cmp    $0x1,%ebp
je     124f <main+0xcf>
jmp    1230 <main+0xb0>
lea    0xdfa(%rip),%rdi
lea    0xdfc(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edx
lea    0xdeb(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1507 <main+0x387>
lea    0xdcf(%rip),%r14
lea    0xdcc(%rip),%r15
lea    0x20(%rsp),%r13
xor    %eax,%eax
jmp    12fe <main+0x17e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    0x1c(%rsp),%eax
add    $0x1,%eax
cmp    0x10(%rsp),%eax
jge    1507 <main+0x387>
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12e0 <main+0x160>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x16(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x17(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x18(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x19(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    $0x30,%al
mov    %al,0x1a(%rsp)
movb   $0x0,0x1b(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
lea    0x16(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x20(%rsp)
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x61,%al
mov    %al,0x20(%rsp,%r12,1)
add    $0x1,%r12
cmp    $0x1a,%r12
jne    1470 <main+0x2f0>
movb   $0x0,0x3a(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x12,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1340 <main+0x1c0>
jmp    12e0 <main+0x160>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xb84(%rip),%rdi
lea    0xb6a(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"\0AInserire il numero di studenti da generare: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AScelta non valida!\0A ... \00"
@.str.3 = [60 x i8] c"Inserire il numero di esami da generare per ogni studente: \00"
@.str.4 = [9 x i8] c"./random\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [4 x i8] c"%s \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [60 x i8] c"Il database casuale di studenti \C3\A8 stato salvato in \22%s\22!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [6 x i8]
%9 = alloca [51 x i8]
%10 = alloca i32*
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %34, %0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %27
19: ; preds = %16, %12
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %25, %19
%22 = call signext i8 (...) @getchar()
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %26
25: ; preds = %21
br label %21
26: ; preds = %21
br label %27
27: ; preds = %26, %16
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 1
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 1
br label %34
34: ; preds = %31, %28
%35 = phi i1 [ true, %28 ], [ %33, %31 ]
br i1 %35, label %12, label %36
36: ; preds = %34
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %60, %36
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 %39, i32* %4
%40 = load i32, i32* %4
%41 = icmp ne i32 %40, 1
br i1 %41, label %45, label %42
42: ; preds = %38
%43 = load i32, i32* %3
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %53
45: ; preds = %42, %38
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %51, %45
%48 = call signext i8 (...) @getchar()
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 10
br i1 %50, label %51, label %52
51: ; preds = %47
br label %47
52: ; preds = %47
br label %53
53: ; preds = %52, %42
br label %54
54: ; preds = %53
%55 = load i32, i32* %4
%56 = icmp ne i32 %55, 1
br i1 %56, label %60, label %57
57: ; preds = %54
%58 = load i32, i32* %3
%59 = icmp slt i32 %58, 0
br label %60
60: ; preds = %57, %54
%61 = phi i1 [ true, %54 ], [ %59, %57 ]
br i1 %61, label %38, label %62
62: ; preds = %60
%63 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %63, i32** %10
%64 = load i32*, i32** %10
%65 = load i32, i32* %2
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %65)
store i32 0, i32* %5
br label %67
67: ; preds = %153, %62
%68 = load i32, i32* %5
%69 = load i32, i32* %2
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %156
71: ; preds = %67
%72 = load i32*, i32** %10
%73 = call i32 (...) @rand()
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %73)
%75 = load i32*, i32** %10
%76 = load i32, i32* %3
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %76)
store i32 0, i32* %6
br label %78
78: ; preds = %147, %71
%79 = load i32, i32* %6
%80 = load i32, i32* %3
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %150
82: ; preds = %78
store i32 0, i32* %7
br label %83
83: ; preds = %106, %82
%84 = load i32, i32* %7
%85 = icmp slt i32 %84, 5
br i1 %85, label %86, label %109
86: ; preds = %83
%87 = load i32, i32* %7
%88 = icmp slt i32 %87, 3
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = call i32 (...) @rand()
%91 = srem i32 %90, 26
%92 = add nsw i32 %91, 65
%93 = trunc i32 %92 to i8
%94 = load i32, i32* %7
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %95
store i8 %93, i8* %96
br label %105
97: ; preds = %86
%98 = call i32 (...) @rand()
%99 = srem i32 %98, 10
%100 = add nsw i32 %99, 48
%101 = trunc i32 %100 to i8
%102 = load i32, i32* %7
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %103
store i8 %101, i8* %104
br label %105
105: ; preds = %97, %89
br label %106
106: ; preds = %105
%107 = load i32, i32* %7
%108 = add nsw i32 %107, 1
store i32 %108, i32* %7
br label %83
109: ; preds = %83
%110 = load i32, i32* %7
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %111
store i8 0, i8* %112
%113 = load i32*, i32** %10
%114 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %113, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %114)
%116 = call i32 (...) @rand()
%117 = srem i32 %116, 26
%118 = add nsw i32 %117, 65
%119 = trunc i32 %118 to i8
%120 = getelementptr inbounds [51 x i8], [51 x i8]* %9, i64 0, i64 0
store i8 %119, i8* %120
store i32 1, i32* %7
br label %121
121: ; preds = %132, %109
%122 = load i32, i32* %7
%123 = icmp slt i32 %122, 26
br i1 %123, label %124, label %135
124: ; preds = %121
%125 = call i32 (...) @rand()
%126 = srem i32 %125, 26
%127 = add nsw i32 %126, 97
%128 = trunc i32 %127 to i8
%129 = load i32, i32* %7
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [51 x i8], [51 x i8]* %9, i64 0, i64 %130
store i8 %128, i8* %131
br label %132
132: ; preds = %124
%133 = load i32, i32* %7
%134 = add nsw i32 %133, 1
store i32 %134, i32* %7
br label %121
135: ; preds = %121
%136 = load i32, i32* %7
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds [51 x i8], [51 x i8]* %9, i64 0, i64 %137
store i8 0, i8* %138
%139 = load i32*, i32** %10
%140 = getelementptr inbounds [51 x i8], [51 x i8]* %9, i64 0, i64 0
%141 = call i32 (i32*, i8*, ...) @fprintf(i32* %139, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %140)
%142 = load i32*, i32** %10
%143 = call i32 (...) @rand()
%144 = srem i32 %143, 12
%145 = add nsw i32 %144, 18
%146 = call i32 (i32*, i8*, ...) @fprintf(i32* %142, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %135
%148 = load i32, i32* %6
%149 = add nsw i32 %148, 1
store i32 %149, i32* %6
br label %78
150: ; preds = %78
%151 = load i32*, i32** %10
%152 = call i32 (i32*, i8*, ...) @fprintf(i32* %151, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %153
153: ; preds = %150
%154 = load i32, i32* %5
%155 = add nsw i32 %154, 1
store i32 %155, i32* %5
br label %67
156: ; preds = %67
%157 = load i32*, i32** %10
%158 = call i32 @fclose(i32* %157)
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"\0AInserire il numero di studenti da generare: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AScelta non valida!\0A ... \00"
@.str.3 = [60 x i8] c"Inserire il numero di esami da generare per ogni studente: \00"
@.str.4 = [9 x i8] c"./random\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [4 x i8] c"%s \00"
@.str.9 = [60 x i8] c"Il database casuale di studenti \C3\A8 stato salvato in \22%s\22!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i8]
%4 = alloca [51 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %23, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = icmp ne i32 %11, 1
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %18, %16
%19 = call signext i8 (...) @getchar()
%20 = icmp eq i8 %19, 10
br i1 %20, label %21, label %18
21: ; preds = %18
%22 = load i32, i32* %1
br label %23
23: ; preds = %21, %10
%24 = phi i32 [ %22, %21 ], [ %13, %10 ]
%25 = icmp slt i32 %24, 1
%26 = select i1 %12, i1 true, i1 %25
br i1 %26, label %10, label %27
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %42, %27
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%31 = icmp ne i32 %30, 1
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 0
%34 = select i1 %31, i1 true, i1 %33
br i1 %34, label %35, label %42
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %37, %35
%38 = call signext i8 (...) @getchar()
%39 = icmp eq i8 %38, 10
br i1 %39, label %40, label %37
40: ; preds = %37
%41 = load i32, i32* %2
br label %42
42: ; preds = %40, %29
%43 = phi i32 [ %41, %40 ], [ %32, %29 ]
%44 = icmp slt i32 %43, 0
%45 = select i1 %31, i1 true, i1 %44
br i1 %45, label %29, label %46
46: ; preds = %42
%47 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* %1
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %1
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %117
52: ; preds = %46
%53 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 26
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
%55 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
%56 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
%57 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
%58 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 5
br label %59
59: ; preds = %52, %112
%60 = phi i32 [ %114, %112 ], [ 0, %52 ]
%61 = call i32 (...) @rand()
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %2
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %2
%66 = icmp sgt i32 %65, 0
br i1 %66, label %67, label %112
67: ; preds = %59, %103
%68 = phi i32 [ %109, %103 ], [ 0, %59 ]
%69 = call i32 (...) @rand()
%70 = srem i32 %69, 26
%71 = trunc i32 %70 to i8
%72 = add nsw i8 %71, 65
store i8 %72, i8* %7
%73 = call i32 (...) @rand()
%74 = srem i32 %73, 26
%75 = trunc i32 %74 to i8
%76 = add nsw i8 %75, 65
store i8 %76, i8* %54
%77 = call i32 (...) @rand()
%78 = srem i32 %77, 26
%79 = trunc i32 %78 to i8
%80 = add nsw i8 %79, 65
store i8 %80, i8* %55
%81 = call i32 (...) @rand()
%82 = srem i32 %81, 10
%83 = trunc i32 %82 to i8
%84 = add nsw i8 %83, 48
store i8 %84, i8* %56
%85 = call i32 (...) @rand()
%86 = srem i32 %85, 10
%87 = trunc i32 %86 to i8
%88 = add nsw i8 %87, 48
store i8 %88, i8* %57
store i8 0, i8* %58
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%90 = call i32 (...) @rand()
%91 = srem i32 %90, 26
%92 = trunc i32 %91 to i8
%93 = add nsw i8 %92, 65
store i8 %93, i8* %8
br label %94
94: ; preds = %67, %94
%95 = phi i64 [ 1, %67 ], [ %101, %94 ]
%96 = call i32 (...) @rand()
%97 = srem i32 %96, 26
%98 = trunc i32 %97 to i8
%99 = add nsw i8 %98, 97
%100 = getelementptr inbounds [51 x i8], [51 x i8]* %4, i64 0, i64 %95
store i8 %99, i8* %100
%101 = add nuw nsw i64 %95, 1
%102 = icmp eq i64 %101, 26
br i1 %102, label %103, label %94
103: ; preds = %94
store i8 0, i8* %53
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%105 = call i32 (...) @rand()
%106 = srem i32 %105, 12
%107 = add nsw i32 %106, 18
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %107)
%109 = add nuw nsw i32 %68, 1
%110 = load i32, i32* %2
%111 = icmp slt i32 %109, %110
br i1 %111, label %67, label %112
112: ; preds = %103, %59
%113 = call i32 @fputc(i32 10, i32* %47)
%114 = add nuw nsw i32 %60, 1
%115 = load i32, i32* %1
%116 = icmp slt i32 %114, %115
br i1 %116, label %59, label %117
117: ; preds = %112, %46
%118 = call i32 @fclose(i32* %47)
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}