#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 */
struct Alumno {
  int dummy;
};

/* Variables and functions */
int agregarAlumno(struct Alumno **, int /*<<< orphan*/);
int agregarNotaAlumno(struct Alumno **, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ crearAlumno();
int /*<<< orphan*/ ingregarRut();
int /*<<< orphan*/ ingresarNota();
int mostrarAlumno(struct Alumno **, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void menu(struct Alumno **alumnos) {
  int opcion = 0, respuesta = 0;
  do {
    printf("%s", "\n");
    printf("%s", "1.- Agregar Alumno\n");
    printf("%s", "2.- Agregar Nota a Alumno\n");
    printf("%s", "3.- Buscar un Alumno por rut\n");
    printf("%s", "4.- Salir\n");
    scanf("%d", &opcion);
    switch (opcion) {
    case 1:
      respuesta = agregarAlumno(alumnos, crearAlumno());
      if (respuesta == 0) {
        printf("Hubo un error. Caso1");
      } else {
        printf("El alumno se agrego");
      }
      break;
    case 2:
      respuesta = agregarNotaAlumno(alumnos, ingresarNota(), ingregarRut());
      if (respuesta == 0) {
        printf("Hubo un error. Caso2");
      } else {
        printf("La nota se agrego");
      }
      break;
    case 3:
      respuesta = mostrarAlumno(alumnos, ingregarRut());
      if (respuesta == 0) {
        printf("No existe el rut");
      }
      break;
    }
  } while (opcion != 4);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe5f(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    0xe84(%rip),%rsi
xor    %eax,%eax
mov    %al,-0x15(%rbp)
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x15(%rbp),%al
lea    0xe3f(%rip),%rsi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x15(%rbp),%al
lea    0xe40(%rip),%rsi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x15(%rbp),%al
lea    0xe48(%rip),%rsi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x15(%rbp),%al
lea    0xe53(%rip),%rsi
call   1060 <printf@plt>
lea    0xe52(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     1248 <menu+0xc8>
jmp    1226 <menu+0xa6>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1295 <menu+0x115>
jmp    1237 <menu+0xb7>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     12ef <menu+0x16f>
jmp    1329 <menu+0x1a9>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1080 <crearAlumno@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1090 <agregarAlumno@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1282 <menu+0x102>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1290 <menu+0x110>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1329 <menu+0x1a9>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <ingresarNota@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <ingregarRut@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
call   1030 <agregarNotaAlumno@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    12dc <menu+0x15c>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12ea <menu+0x16a>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1329 <menu+0x1a9>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1040 <ingregarRut@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1070 <mostrarAlumno@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1324 <menu+0x1a4>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1329 <menu+0x1a9>
jmp    132e <menu+0x1ae>
cmpl   $0x4,-0xc(%rbp)
jne    119a <menu+0x1a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xea2(%rip),%rbp
lea    0xeae(%rip),%rbx
lea    0xec1(%rip),%r15
lea    0xed7(%rip),%r12
lea    0xe22(%rip),%r14
lea    0xc(%rsp),%r13
jmp    124f <menu+0xaf>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <ingresarNota@plt>
mov    %r14,%r13
mov    %r12,%r14
mov    %r15,%r12
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <ingregarRut@plt>
mov    0x10(%rsp),%rdi
mov    %r15d,%esi
mov    %r12,%r15
mov    %r14,%r12
mov    %r13,%r14
lea    0xc(%rsp),%r13
mov    %eax,%edx
call   1050 <agregarNotaAlumno@plt>
test   %eax,%eax
lea    0xe11(%rip),%rdi
lea    0xdf5(%rip),%rax
cmove  %rax,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0xc(%rsp),%eax
cmp    $0x4,%eax
je     12f7 <menu+0x157>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10c0 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     12d0 <menu+0x130>
cmp    $0x2,%eax
je     11f0 <menu+0x50>
cmp    $0x1,%eax
jne    1246 <menu+0xa6>
xor    %eax,%eax
call   10a0 <crearAlumno@plt>
mov    0x10(%rsp),%rdi
mov    %eax,%esi
call   10b0 <agregarAlumno@plt>
test   %eax,%eax
lea    0xd61(%rip),%rdi
lea    0xd45(%rip),%rax
jmp    1237 <menu+0x97>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <ingregarRut@plt>
mov    0x10(%rsp),%rdi
mov    %eax,%esi
call   1090 <mostrarAlumno@plt>
lea    0xd69(%rip),%rdi
test   %eax,%eax
jne    1242 <menu+0xa2>
jmp    123b <menu+0x9b>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Alumno = type { i32 }
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [20 x i8] c"1.- Agregar Alumno\0A\00"
@.str.3 = [27 x i8] c"2.- Agregar Nota a Alumno\0A\00"
@.str.4 = [30 x i8] c"3.- Buscar un Alumno por rut\0A\00"
@.str.5 = [11 x i8] c"4.- Salir\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [21 x i8] c"Hubo un error. Caso1\00"
@.str.8 = [20 x i8] c"El alumno se agrego\00"
@.str.9 = [21 x i8] c"Hubo un error. Caso2\00"
@.str.10 = [18 x i8] c"La nota se agrego\00"
@.str.11 = [17 x i8] c"No existe el rut\00"
define void @menu(%struct.Alumno** %0) {
%2 = alloca %struct.Alumno**
%3 = alloca i32
%4 = alloca i32
store %struct.Alumno** %0, %struct.Alumno*** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %46, %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
switch i32 %12, label %45 [
i32 1, label %13
i32 2, label %24
i32 3, label %36
]
13: ; preds = %5
%14 = load %struct.Alumno**, %struct.Alumno*** %2
%15 = call i32 (...) @crearAlumno()
%16 = call i32 @agregarAlumno(%struct.Alumno** %14, i32 %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %23
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %45
24: ; preds = %5
%25 = load %struct.Alumno**, %struct.Alumno*** %2
%26 = call i32 (...) @ingresarNota()
%27 = call i32 (...) @ingregarRut()
%28 = call i32 @agregarNotaAlumno(%struct.Alumno** %25, i32 %26, i32 %27)
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %35
33: ; preds = %24
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
br label %45
36: ; preds = %5
%37 = load %struct.Alumno**, %struct.Alumno*** %2
%38 = call i32 (...) @ingregarRut()
%39 = call i32 @mostrarAlumno(%struct.Alumno** %37, i32 %38)
store i32 %39, i32* %4
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
br label %44
44: ; preds = %42, %36
br label %45
45: ; preds = %5, %44, %35, %23
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = icmp ne i32 %47, 4
br i1 %48, label %5, label %49
49: ; preds = %46
ret void
}

LLVM IR (-O2):
%struct.Alumno = type { i32 }
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [21 x i8] c"Hubo un error. Caso1\00"
@.str.8 = [20 x i8] c"El alumno se agrego\00"
@.str.9 = [21 x i8] c"Hubo un error. Caso2\00"
@.str.10 = [18 x i8] c"La nota se agrego\00"
@.str.11 = [17 x i8] c"No existe el rut\00"
@str = [19 x i8] c"1.- Agregar Alumno\00"
@str.12 = [26 x i8] c"2.- Agregar Nota a Alumno\00"
@str.13 = [29 x i8] c"3.- Buscar un Alumno por rut\00"
@str.14 = [10 x i8] c"4.- Salir\00"
define void @menu(%struct.Alumno** %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %4
4: ; preds = %32, %1
%5 = call i32 @putchar(i32 10)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.14, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
switch i32 %11, label %32 [
i32 1, label %12
i32 2, label %17
i32 3, label %23
]
12: ; preds = %4
%13 = call i32 (...) @crearAlumno()
%14 = call i32 @agregarAlumno(%struct.Alumno** %0, i32 %13)
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0)
br label %27
17: ; preds = %4
%18 = call i32 (...) @ingresarNota()
%19 = call i32 (...) @ingregarRut()
%20 = call i32 @agregarNotaAlumno(%struct.Alumno** %0, i32 %18, i32 %19)
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0)
br label %27
23: ; preds = %4
%24 = call i32 (...) @ingregarRut()
%25 = call i32 @mostrarAlumno(%struct.Alumno** %0, i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23, %17, %12
%28 = phi i8* [ %16, %12 ], [ %22, %17 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), %23 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28)
br label %30
30: ; preds = %27, %23
%31 = load i32, i32* %2
br label %32
32: ; preds = %30, %4
%33 = phi i32 [ %31, %30 ], [ %11, %4 ]
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %4
35: ; preds = %32
ret void
}