#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 atoi(char *);
int /*<<< orphan*/ consultar();
int /*<<< orphan*/ examinar();
int /*<<< orphan*/ generar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  system("clear");
  char opc[5];
  int numero;
  printf("\t\t\tSistema generador de examenes.\n");
  printf("\tAutores: Lucas Comamala, Angeles Contreras, Brenda Themsel\n");
  do {
    printf("\n\n");
    printf("1. Generar un examen\n");
    printf("2. Aplicar examen\n");
    printf("3. Consultar calificaciones\n");
    printf("0. Salir\n");
    scanf(" %[^\n]", opc);
    printf("\n");
    numero = atoi(opc);
    if (numero <= 5 && numero >= 0) {
      switch (opc[0]) {
      case '0':
        break;
      case '1':
        generar();
        break;
      case '2':
        examinar();
        break;
      case '3':
        consultar();
        break;
      default:
        printf("Opcion no valida\n");
        break;
      }
    } else
      printf("Opcion no valida\n");
  } while (opc[0] != '0');
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <system@plt>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
call   1040 <printf@plt>
lea    -0x15(%rbp),%rsi
lea    0xed8(%rip),%rdi
call   1080 <scanf@plt>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jg     1286 <main+0x116>
cmpl   $0x0,-0x1c(%rbp)
jl     1286 <main+0x116>
movsbl -0x15(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     1275 <main+0x105>
mov    -0x28(%rbp),%rax
lea    0xdbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1281 <main+0x111>
mov    $0x0,%al
call   1070 <generar@plt>
jmp    1281 <main+0x111>
mov    $0x0,%al
call   1060 <examinar@plt>
jmp    1281 <main+0x111>
mov    $0x0,%al
call   1050 <consultar@plt>
jmp    1281 <main+0x111>
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
jmp    1292 <main+0x122>
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
jmp    1297 <main+0x127>
movsbl -0x15(%rbp),%eax
cmp    $0x30,%eax
jne    11aa <main+0x3a>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7e(%rip),%rdi
call   1050 <system@plt>
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0xec7(%rip),%r15
lea    0xed5(%rip),%r12
lea    0xee0(%rip),%r13
lea    0xef5(%rip),%rbx
lea    0xe44(%rip),%rbp
lea    0x3(%rsp),%r14
jmp    11f9 <main+0x79>
nopl   0x0(%rax)
lea    0xee2(%rip),%rdi
call   1040 <puts@plt>
movzbl 0x3(%rsp),%eax
cmp    $0x30,%al
je     1288 <main+0x108>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   10a0 <atoi@plt>
cmp    $0x5,%eax
ja     11e0 <main+0x60>
movsbl 0x3(%rsp),%eax
lea    -0x30(%rax),%ecx
cmp    $0x3,%ecx
ja     11e0 <main+0x60>
lea    0xda5(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1080 <generar@plt>
jmp    11ec <main+0x6c>
xor    %eax,%eax
call   1070 <examinar@plt>
jmp    11ec <main+0x6c>
xor    %eax,%eax
call   1060 <consultar@plt>
jmp    11ec <main+0x6c>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [35 x i8] c"\09\09\09Sistema generador de examenes.\0A\00"
@.str.2 = [61 x i8] c"\09Autores: Lucas Comamala, Angeles Contreras, Brenda Themsel\0A\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [22 x i8] c"1. Generar un examen\0A\00"
@.str.5 = [19 x i8] c"2. Aplicar examen\0A\00"
@.str.6 = [29 x i8] c"3. Consultar calificaciones\0A\00"
@.str.7 = [10 x i8] c"0. Salir\0A\00"
@.str.8 = [7 x i8] c" %[^\0A]\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [18 x i8] c"Opcion no valida\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %44, %2
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp sle i32 %22, 5
br i1 %23, label %24, label %41
24: ; preds = %11
%25 = load i32, i32* %7
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %24
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %38 [
i32 48, label %31
i32 49, label %32
i32 50, label %34
i32 51, label %36
]
31: ; preds = %27
br label %40
32: ; preds = %27
%33 = call i32 (...) @generar()
br label %40
34: ; preds = %27
%35 = call i32 (...) @examinar()
br label %40
36: ; preds = %27
%37 = call i32 (...) @consultar()
br label %40
38: ; preds = %27
%39 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %40
40: ; preds = %38, %36, %34, %32, %31
br label %43
41: ; preds = %24, %11
%42 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %43
43: ; preds = %41, %40
br label %44
44: ; preds = %43
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 48
br i1 %48, label %11, label %49
49: ; preds = %44
ret i32 1
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.8 = [7 x i8] c" %[^\0A]\00"
@str = [34 x i8] c"\09\09\09Sistema generador de examenes.\00"
@str.11 = [60 x i8] c"\09Autores: Lucas Comamala, Angeles Contreras, Brenda Themsel\00"
@str.12 = [2 x i8] c"\0A\00"
@str.13 = [21 x i8] c"1. Generar un examen\00"
@str.14 = [18 x i8] c"2. Aplicar examen\00"
@str.15 = [28 x i8] c"3. Consultar calificaciones\00"
@str.16 = [9 x i8] c"0. Salir\00"
@str.18 = [17 x i8] c"Opcion no valida\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i8]
%4 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.11, i64 0, i64 0))
br label %8
8: ; preds = %33, %2
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.14, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.15, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.16, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%15 = call i32 @putchar(i32 10)
%16 = call i32 @atoi(i8* %5)
%17 = icmp ult i32 %16, 6
br i1 %17, label %18, label %29
18: ; preds = %8
%19 = load i8, i8* %5
%20 = sext i8 %19 to i32
switch i32 %20, label %27 [
i32 48, label %33
i32 49, label %21
i32 50, label %23
i32 51, label %25
]
21: ; preds = %18
%22 = call i32 (...) @generar()
br label %31
23: ; preds = %18
%24 = call i32 (...) @examinar()
br label %31
25: ; preds = %18
%26 = call i32 (...) @consultar()
br label %31
27: ; preds = %18
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.18, i64 0, i64 0))
br label %31
29: ; preds = %8
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.18, i64 0, i64 0))
br label %31
31: ; preds = %21, %23, %25, %27, %29
%32 = load i8, i8* %5
br label %33
33: ; preds = %31, %18
%34 = phi i8 [ %32, %31 ], [ %19, %18 ]
%35 = icmp eq i8 %34, 48
br i1 %35, label %36, label %8
36: ; preds = %33
ret i32 1
}