#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*/ ex1();
int /*<<< orphan*/ ex10();
int /*<<< orphan*/ ex2();
int /*<<< orphan*/ ex3();
int /*<<< orphan*/ ex4();
int /*<<< orphan*/ ex5();
int /*<<< orphan*/ ex6();
int /*<<< orphan*/ ex7();
int /*<<< orphan*/ ex8();
int /*<<< orphan*/ ex9();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int menu;
  while (menu != 0) {
    printf("%s", "Escolha um exercício de 1 - 10, digite 0 para sair: ");
    scanf("%d", &menu);
    switch (menu) {
    case 1:
      ex1();
      break;
    case 2:
      ex2();
      break;
    case 3:
      ex3();
      break;
    case 4:
      ex4();
      break;
    case 5:
      ex5();
      break;
    case 6:
      ex6();
      break;
    case 7:
      ex7();
      break;
    case 8:
      ex8();
      break;
    case 9:
      ex9();
      break;
    case 10:
      ex10();
      break;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12a7 <main+0xe7>
lea    0xe48(%rip),%rdi
lea    0xe44(%rip),%rsi
call   1080 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10e0 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     129d <main+0xdd>
mov    -0x10(%rbp),%rax
lea    0xde4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1040 <ex1@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   10b0 <ex2@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   1050 <ex3@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   10a0 <ex4@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   1030 <ex5@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   1090 <ex6@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   1060 <ex7@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   10c0 <ex8@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   1070 <ex9@plt>
jmp    12a2 <main+0xe2>
mov    $0x0,%al
call   10d0 <ex10@plt>
jmp    12a2 <main+0xe2>
jmp    12a2 <main+0xe2>
jmp    11cf <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe54(%rip),%r14
lea    0xe50(%rip),%r15
lea    0xe7f(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xe12(%rip),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10e0 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x9,%ecx
ja     1284 <main+0xc4>
movslq (%rbx,%rcx,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <ex1@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   10b0 <ex2@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   1050 <ex3@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   10a0 <ex4@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   1030 <ex5@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   1090 <ex6@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   1060 <ex7@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   10c0 <ex8@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   1070 <ex9@plt>
jmp    1280 <main+0xc0>
xor    %eax,%eax
call   10d0 <ex10@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11f0 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [54 x i8] c"Escolha um exerc\C3\ADcio de 1 - 10, digite 0 para sair: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %31, %0
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %32
6: ; preds = %3
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
switch i32 %9, label %30 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
i32 5, label %18
i32 6, label %20
i32 7, label %22
i32 8, label %24
i32 9, label %26
i32 10, label %28
]
10: ; preds = %6
%11 = call i32 (...) @ex1()
br label %31
12: ; preds = %6
%13 = call i32 (...) @ex2()
br label %31
14: ; preds = %6
%15 = call i32 (...) @ex3()
br label %31
16: ; preds = %6
%17 = call i32 (...) @ex4()
br label %31
18: ; preds = %6
%19 = call i32 (...) @ex5()
br label %31
20: ; preds = %6
%21 = call i32 (...) @ex6()
br label %31
22: ; preds = %6
%23 = call i32 (...) @ex7()
br label %31
24: ; preds = %6
%25 = call i32 (...) @ex8()
br label %31
26: ; preds = %6
%27 = call i32 (...) @ex9()
br label %31
28: ; preds = %6
%29 = call i32 (...) @ex10()
br label %31
30: ; preds = %6
br label %31
31: ; preds = %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10
br label %3
32: ; preds = %3
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [54 x i8] c"Escolha um exerc\C3\ADcio de 1 - 10, digite 0 para sair: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %29
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %29 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
i32 6, label %17
i32 7, label %19
i32 8, label %21
i32 9, label %23
i32 10, label %25
]
7: ; preds = %3
%8 = call i32 (...) @ex1()
br label %27
9: ; preds = %3
%10 = call i32 (...) @ex2()
br label %27
11: ; preds = %3
%12 = call i32 (...) @ex3()
br label %27
13: ; preds = %3
%14 = call i32 (...) @ex4()
br label %27
15: ; preds = %3
%16 = call i32 (...) @ex5()
br label %27
17: ; preds = %3
%18 = call i32 (...) @ex6()
br label %27
19: ; preds = %3
%20 = call i32 (...) @ex7()
br label %27
21: ; preds = %3
%22 = call i32 (...) @ex8()
br label %27
23: ; preds = %3
%24 = call i32 (...) @ex9()
br label %27
25: ; preds = %3
%26 = call i32 (...) @ex10()
br label %27
27: ; preds = %7, %9, %11, %13, %15, %17, %19, %21, %23, %25
%28 = load i32, i32* %1
br label %29
29: ; preds = %27, %3
%30 = phi i32 [ %28, %27 ], [ %6, %3 ]
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %3
32: ; preds = %29
ret i32 0
}