#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*/ ex2();
int /*<<< orphan*/ ex3();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main(void) {
  int pick;
  do {
    puts("escolha exercicio 1 a 3");
    scanf("%d", &pick);
  } while (pick < 1 || pick > 3);
  switch (pick) {
  case 1:
    ex1();
    break;
  case 2:
    ex2();
    break;
  case 3:
    ex3();
    break;
  }
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <puts@plt>
lea    0xe96(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     11a4 <main+0x44>
cmpl   $0x3,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    116f <main+0xf>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11e5 <main+0x85>
jmp    11c3 <main+0x63>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11f1 <main+0x91>
jmp    11d4 <main+0x74>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11fd <main+0x9d>
jmp    1204 <main+0xa4>
mov    $0x0,%al
call   1030 <ex1@plt>
jmp    1204 <main+0xa4>
mov    $0x0,%al
call   1070 <ex2@plt>
jmp    1204 <main+0xa4>
mov    $0x0,%al
call   1040 <ex3@plt>
lea    0xe10(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%r14
lea    0xea1(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jb     1180 <main+0x20>
cmp    $0x3,%eax
je     11b7 <main+0x57>
cmp    $0x2,%eax
je     11c0 <main+0x60>
cmp    $0x1,%eax
jne    11c7 <main+0x67>
xor    %eax,%eax
call   1030 <ex1@plt>
jmp    11c7 <main+0x67>
xor    %eax,%eax
call   1040 <ex3@plt>
jmp    11c7 <main+0x67>
xor    %eax,%eax
call   1070 <ex2@plt>
lea    0xe4d(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"escolha exercicio 1 a 3\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %12, %0
%4 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 3
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ true, %6 ], [ %11, %9 ]
br i1 %13, label %3, label %14
14: ; preds = %12
%15 = load i32, i32* %2
switch i32 %15, label %22 [
i32 1, label %16
i32 2, label %18
i32 3, label %20
]
16: ; preds = %14
%17 = call i32 (...) @ex1()
br label %22
18: ; preds = %14
%19 = call i32 (...) @ex2()
br label %22
20: ; preds = %14
%21 = call i32 (...) @ex3()
br label %22
22: ; preds = %14, %20, %18, %16
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"escolha exercicio 1 a 3\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -4
%8 = icmp ult i32 %7, -3
br i1 %8, label %3, label %9
9: ; preds = %3
switch i32 %6, label %16 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
]
10: ; preds = %9
%11 = call i32 (...) @ex1()
br label %16
12: ; preds = %9
%13 = call i32 (...) @ex2()
br label %16
14: ; preds = %9
%15 = call i32 (...) @ex3()
br label %16
16: ; preds = %9, %14, %12, %10
%17 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}