#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 */
char getchar();
int /*<<< orphan*/ input();
int /*<<< orphan*/ menu();
int /*<<< orphan*/ mult(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ output(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pot(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ raiz(int /*<<< orphan*/);
int /*<<< orphan*/ razao(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ soma(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sub(int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  char op;
  menu();
  op = getchar();
  switch (op) {
  case '+':
    printf("Soma!\n");
    output("A soma eh:", soma(input(), input()));
    break;
  case '-':
    printf("Subtracao!\n");
    output("A subtracao eh:", sub(input(), input()));
    break;
  case '*':
    printf("Multiplicacao!\n");
    output("A multiplicacao eh:", mult(input(), input()));
    break;
  case '/':
    printf("Divisao!\n");
    output("A divisao eh:", razao(input(), input()));
    break;
  case 'P':
    printf("Potencia!\n");
    output("A potencia eh: ", pot(input(), input()));
    break;
  case 'R':
    printf("Raiz Quadrada!\n");
    output("A raiz eh: ", raiz(input()));
    break;
  default:
    printf("Opcao Invalida!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0x11(%rbp)
call   1050 <menu@plt>
mov    -0x11(%rbp),%al
call   1080 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x28,%eax
ja     134d <main+0x19d>
mov    -0x10(%rbp),%rax
lea    0xe0b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <input@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   10a0 <soma@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
call   1040 <output@plt>
jmp    1359 <main+0x1a9>
lea    0xe77(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <input@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   10d0 <sub@plt>
mov    %eax,%esi
lea    0xe5a(%rip),%rdi
call   1040 <output@plt>
jmp    1359 <main+0x1a9>
lea    0xe59(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <input@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   10c0 <mult@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
call   1040 <output@plt>
jmp    1359 <main+0x1a9>
lea    0xe43(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1030 <input@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1070 <razao@plt>
mov    %eax,%esi
lea    0xe24(%rip),%rdi
call   1040 <output@plt>
jmp    1359 <main+0x1a9>
lea    0xe21(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <input@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   1090 <pot@plt>
mov    %eax,%esi
lea    0xe03(%rip),%rdi
call   1040 <output@plt>
jmp    1359 <main+0x1a9>
lea    0xe02(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,%edi
call   10b0 <raiz@plt>
mov    %eax,%esi
lea    0xdf6(%rip),%rdi
call   1040 <output@plt>
jmp    1359 <main+0x1a9>
lea    0xdf1(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <menu@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
movsbl %al,%eax
add    $0xffffffd6,%eax
cmp    $0x28,%eax
ja     123c <main+0x8c>
lea    0xe2f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf3e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <input@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10c0 <mult@plt>
lea    0xeb9(%rip),%rdi
jmp    12f8 <main+0x148>
lea    0xf27(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <input@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10a0 <soma@plt>
lea    0xe6d(%rip),%rdi
jmp    12f8 <main+0x148>
lea    0xefc(%rip),%rdi
call   1040 <puts@plt>
jmp    12ff <main+0x14f>
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <input@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   10d0 <sub@plt>
lea    0xe36(%rip),%rdi
jmp    12f8 <main+0x148>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <input@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <razao@plt>
lea    0xe2c(%rip),%rdi
jmp    12f8 <main+0x148>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <input@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1090 <pot@plt>
lea    0xe0c(%rip),%rdi
jmp    12f8 <main+0x148>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%edi
call   10b0 <raiz@plt>
lea    0xdf9(%rip),%rdi
mov    %eax,%esi
call   1050 <output@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Soma!\0A\00"
@.str.1 = [11 x i8] c"A soma eh:\00"
@.str.2 = [12 x i8] c"Subtracao!\0A\00"
@.str.3 = [16 x i8] c"A subtracao eh:\00"
@.str.4 = [16 x i8] c"Multiplicacao!\0A\00"
@.str.5 = [20 x i8] c"A multiplicacao eh:\00"
@.str.6 = [10 x i8] c"Divisao!\0A\00"
@.str.7 = [14 x i8] c"A divisao eh:\00"
@.str.8 = [11 x i8] c"Potencia!\0A\00"
@.str.9 = [16 x i8] c"A potencia eh: \00"
@.str.10 = [16 x i8] c"Raiz Quadrada!\0A\00"
@.str.11 = [12 x i8] c"A raiz eh: \00"
@.str.12 = [17 x i8] c"Opcao Invalida!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (...) @menu()
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
switch i32 %6, label %42 [
i32 43, label %7
i32 45, label %13
i32 42, label %19
i32 47, label %25
i32 80, label %31
i32 82, label %37
]
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @input()
%10 = call i32 (...) @input()
%11 = call i32 @soma(i32 %9, i32 %10)
%12 = call i32 @output(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %44
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (...) @input()
%16 = call i32 (...) @input()
%17 = call i32 @sub(i32 %15, i32 %16)
%18 = call i32 @output(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %44
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (...) @input()
%22 = call i32 (...) @input()
%23 = call i32 @mult(i32 %21, i32 %22)
%24 = call i32 @output(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %23)
br label %44
25: ; preds = %0
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (...) @input()
%28 = call i32 (...) @input()
%29 = call i32 @razao(i32 %27, i32 %28)
%30 = call i32 @output(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %29)
br label %44
31: ; preds = %0
%32 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%33 = call i32 (...) @input()
%34 = call i32 (...) @input()
%35 = call i32 @pot(i32 %33, i32 %34)
%36 = call i32 @output(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %35)
br label %44
37: ; preds = %0
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
%39 = call i32 (...) @input()
%40 = call i32 @raiz(i32 %39)
%41 = call i32 @output(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %40)
br label %44
42: ; preds = %0
%43 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %44
44: ; preds = %42, %37, %31, %25, %19, %13, %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"A soma eh:\00"
@.str.3 = [16 x i8] c"A subtracao eh:\00"
@.str.5 = [20 x i8] c"A multiplicacao eh:\00"
@.str.7 = [14 x i8] c"A divisao eh:\00"
@.str.9 = [16 x i8] c"A potencia eh: \00"
@.str.11 = [12 x i8] c"A raiz eh: \00"
@str = [15 x i8] c"Raiz Quadrada!\00"
@str.13 = [10 x i8] c"Potencia!\00"
@str.14 = [9 x i8] c"Divisao!\00"
@str.15 = [15 x i8] c"Multiplicacao!\00"
@str.16 = [11 x i8] c"Subtracao!\00"
@str.17 = [6 x i8] c"Soma!\00"
@str.18 = [16 x i8] c"Opcao Invalida!\00"
define i32 @main() {
%1 = tail call i32 (...) @menu()
%2 = tail call signext i8 (...) @getchar()
%3 = sext i8 %2 to i32
switch i32 %3, label %39 [
i32 43, label %4
i32 45, label %10
i32 42, label %16
i32 47, label %22
i32 80, label %28
i32 82, label %34
]
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.17, i64 0, i64 0))
%6 = tail call i32 (...) @input()
%7 = tail call i32 (...) @input()
%8 = tail call i32 @soma(i32 %6, i32 %7)
%9 = tail call i32 @output(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %41
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.16, i64 0, i64 0))
%12 = tail call i32 (...) @input()
%13 = tail call i32 (...) @input()
%14 = tail call i32 @sub(i32 %12, i32 %13)
%15 = tail call i32 @output(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %41
16: ; preds = %0
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.15, i64 0, i64 0))
%18 = tail call i32 (...) @input()
%19 = tail call i32 (...) @input()
%20 = tail call i32 @mult(i32 %18, i32 %19)
%21 = tail call i32 @output(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %20)
br label %41
22: ; preds = %0
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.14, i64 0, i64 0))
%24 = tail call i32 (...) @input()
%25 = tail call i32 (...) @input()
%26 = tail call i32 @razao(i32 %24, i32 %25)
%27 = tail call i32 @output(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %26)
br label %41
28: ; preds = %0
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.13, i64 0, i64 0))
%30 = tail call i32 (...) @input()
%31 = tail call i32 (...) @input()
%32 = tail call i32 @pot(i32 %30, i32 %31)
%33 = tail call i32 @output(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %32)
br label %41
34: ; preds = %0
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 (...) @input()
%37 = tail call i32 @raiz(i32 %36)
%38 = tail call i32 @output(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %37)
br label %41
39: ; preds = %0
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.18, i64 0, i64 0))
br label %41
41: ; preds = %39, %34, %28, %22, %16, %10, %4
ret i32 0
}