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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     1194 <main+0x44>
cmpl   $0x2,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    115f <main+0xf>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11c4 <main+0x74>
jmp    11b3 <main+0x63>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11dc <main+0x8c>
jmp    11ef <main+0x9f>
lea    0xe50(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1030 <ex1@plt>
jmp    11ef <main+0x9f>
lea    0xe38(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1060 <ex2@plt>
lea    0xe28(%rip),%rdi
call   1050 <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    0xea0(%rip),%r14
lea    0xeb1(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffe,%ecx
jb     1170 <main+0x20>
cmp    $0x2,%eax
je     11ae <main+0x5e>
cmp    $0x1,%eax
jne    11c1 <main+0x71>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <ex1@plt>
jmp    11c1 <main+0x71>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <ex2@plt>
lea    0xe56(%rip),%rdi
call   1050 <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 2\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [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, 2
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 %19
]
16: ; preds = %14
%17 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (...) @ex1()
br label %22
19: ; preds = %14
%20 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (...) @ex2()
br label %22
22: ; preds = %14, %19, %16
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"escolha exercicio 1 a 2\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [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, -3
%8 = icmp ult i32 %7, -2
br i1 %8, label %3, label %9
9: ; preds = %3
switch i32 %6, label %16 [
i32 1, label %10
i32 2, label %13
]
10: ; preds = %9
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (...) @ex1()
br label %16
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (...) @ex2()
br label %16
16: ; preds = %9, %13, %10
%17 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}