#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char opcao = ' ';
  printf("\nMenu:\n");
  printf("-----\n");
  printf("1: Somar\n");
  printf("2: Subtrair\n");
  printf("3: Dividir\n");
  printf("4: Multiplicar\n");
  printf("Resposta: ");
  scanf("%c", &opcao);
  switch (opcao) {
  case '1':
    printf("Foi escolhido a opcao 1 (Somar)");
    break;
  case '2':
    printf("Foi escolhido a opcao 2 (Subtrair)");
    break;
  case '3':
    printf("Foi escolhido a opcao 3 (Dividir)");
    break;
  case '4':
    printf("Foi escolhido a opcao 4 (Multiplicar)");
    break;
  default:
    printf("Opcao desconhecida...");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x20,-0x5(%rbp)
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     1205 <main+0xe5>
mov    -0x10(%rbp),%rax
lea    0xe48(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    1211 <main+0xf1>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    1211 <main+0xf1>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    1211 <main+0xf1>
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
jmp    1211 <main+0xf1>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movb   $0x20,0x7(%rsp)
lea    0xf72(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf67(%rip),%rdi
call   1030 <puts@plt>
lea    0xf64(%rip),%rdi
call   1030 <puts@plt>
lea    0xf64(%rip),%rdi
call   1030 <puts@plt>
lea    0xf63(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
movsbq 0x7(%rsp),%rax
add    $0xffffffffffffffcf,%rax
cmp    $0x3,%eax
ja     11ba <main+0x8a>
lea    0xf3b(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    11c1 <main+0x91>
lea    0xed8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\0AMenu:\0A\00"
@.str.1 = [7 x i8] c"-----\0A\00"
@.str.2 = [10 x i8] c"1: Somar\0A\00"
@.str.3 = [13 x i8] c"2: Subtrair\0A\00"
@.str.4 = [12 x i8] c"3: Dividir\0A\00"
@.str.5 = [16 x i8] c"4: Multiplicar\0A\00"
@.str.6 = [11 x i8] c"Resposta: \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [32 x i8] c"Foi escolhido a opcao 1 (Somar)\00"
@.str.9 = [35 x i8] c"Foi escolhido a opcao 2 (Subtrair)\00"
@.str.10 = [34 x i8] c"Foi escolhido a opcao 3 (Dividir)\00"
@.str.11 = [38 x i8] c"Foi escolhido a opcao 4 (Multiplicar)\00"
@.str.12 = [22 x i8] c"Opcao desconhecida...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
store i8 32, i8* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
switch i32 %12, label %21 [
i32 49, label %13
i32 50, label %15
i32 51, label %17
i32 52, label %19
]
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %23
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %23
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %23
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
br label %23
21: ; preds = %0
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
br label %23
23: ; preds = %21, %19, %17, %15, %13
ret i32 0
}

LLVM IR (-O2):
@.str.6 = [11 x i8] c"Resposta: \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [32 x i8] c"Foi escolhido a opcao 1 (Somar)\00"
@.str.9 = [35 x i8] c"Foi escolhido a opcao 2 (Subtrair)\00"
@.str.10 = [34 x i8] c"Foi escolhido a opcao 3 (Dividir)\00"
@.str.11 = [38 x i8] c"Foi escolhido a opcao 4 (Multiplicar)\00"
@.str.12 = [22 x i8] c"Opcao desconhecida...\00"
@str = [7 x i8] c"\0AMenu:\00"
@str.13 = [6 x i8] c"-----\00"
@str.14 = [9 x i8] c"1: Somar\00"
@str.15 = [12 x i8] c"2: Subtrair\00"
@str.16 = [11 x i8] c"3: Dividir\00"
@str.17 = [15 x i8] c"4: Multiplicar\00"
@reltable.main = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.8 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.9 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.10 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.11 to i64), i64 ptrtoint ([4 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i8
store i8 32, i8* %1
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.13, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.14, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.15, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.16, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.17, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
%12 = add nsw i32 %11, -49
%13 = icmp ult i32 %12, 4
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = sext i32 %12 to i64
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.main to i8*), i64 %16)
br label %18
18: ; preds = %0, %14
%19 = phi i8* [ %17, %14 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), %0 ]
%20 = call i32 @printf(i8* dereferenceable(1) %19)
ret i32 0
}