#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 /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int menu() {
  int choice;
  char b[4];
  printf("\n");
  printf("[1] Agregar una cancion nueva\n");
  printf("[2] Enlistar todas las canciones\n");
  printf("[3] Eliminar una cancion\n");
  printf("[4] Duracion total de la biblioteca\n");
  printf("[5] Promedio de duracion por cancion\n");
  printf("[6] Cancion mas larga de la biblioteca\n");
  printf("[7] Salir\n");
  do {
    printf("Opcion: ");
    scanf("%d", &choice);
    getchar();
  } while (choice < 1 || choice > 8);
  printf("\n");
  return choice;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf8d(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
call   1030 <printf@plt>
lea    0xf3b(%rip),%rdi
call   1030 <printf@plt>
lea    0xf3a(%rip),%rdi
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jl     11d4 <menu+0xa4>
cmpl   $0x8,-0x4(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1198 <menu+0x68>
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
lea    0xeee(%rip),%rdi
call   1040 <puts@plt>
lea    0xf07(%rip),%rdi
call   1040 <puts@plt>
lea    0xf22(%rip),%rdi
call   1040 <puts@plt>
lea    0xe42(%rip),%r14
lea    0xe44(%rip),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0xc(%rsp),%eax
add    $0xfffffff7,%eax
cmp    $0xfffffff8,%eax
jb     11d0 <menu+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [31 x i8] c"[1] Agregar una cancion nueva\0A\00"
@.str.2 = [34 x i8] c"[2] Enlistar todas las canciones\0A\00"
@.str.3 = [26 x i8] c"[3] Eliminar una cancion\0A\00"
@.str.4 = [37 x i8] c"[4] Duracion total de la biblioteca\0A\00"
@.str.5 = [38 x i8] c"[5] Promedio de duracion por cancion\0A\00"
@.str.6 = [40 x i8] c"[6] Cancion mas larga de la biblioteca\0A\00"
@.str.7 = [11 x i8] c"[7] Salir\0A\00"
@.str.8 = [9 x i8] c"Opcion: \00"
@.str.9 = [3 x i8] c"%d\00"
define i32 @menu() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %11
11: ; preds = %21, %0
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%14 = call i32 (...) @getchar()
br label %15
15: ; preds = %11
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 8
br label %21
21: ; preds = %18, %15
%22 = phi i1 [ true, %15 ], [ %20, %18 ]
br i1 %22, label %11, label %23
23: ; preds = %21
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str.8 = [9 x i8] c"Opcion: \00"
@.str.9 = [3 x i8] c"%d\00"
@str = [30 x i8] c"[1] Agregar una cancion nueva\00"
@str.10 = [33 x i8] c"[2] Enlistar todas las canciones\00"
@str.11 = [25 x i8] c"[3] Eliminar una cancion\00"
@str.12 = [36 x i8] c"[4] Duracion total de la biblioteca\00"
@str.13 = [37 x i8] c"[5] Promedio de duracion por cancion\00"
@str.14 = [39 x i8] c"[6] Cancion mas larga de la biblioteca\00"
@str.15 = [10 x i8] c"[7] Salir\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.13, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.15, i64 0, i64 0))
br label %11
11: ; preds = %11, %0
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%14 = call i32 (...) @getchar()
%15 = load i32, i32* %1
%16 = add i32 %15, -9
%17 = icmp ult i32 %16, -8
br i1 %17, label %11, label %18
18: ; preds = %11
%19 = call i32 @putchar(i32 10)
%20 = load i32, i32* %1
ret i32 %20
}