#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 *, int *);
int main() {
  int a, b, operacao;
  printf("digite o primeiro numero:\n");
  scanf("%d", &a);
  printf("digite o segundo numero:\n");
  scanf("%d", &b);
  printf("Qual operacao voce deseja ?\n");
  printf(" 1 Soma\n 2 Subtracao\n 3 Multiplicacao\n 4 Divisao\n");
  scanf("%d", &operacao);
  switch (operacao) {
  case 1:
    printf("voce escolheu soma %d", a + b);
    break;
  case 2:
    printf("voce escolheu Subtracao %d", a - b);
    break;
  case 3:
    printf("voce escolheu Multiplicacao %d", a * b);
    break;
  case 4:
    printf("voce escolheu Divisao %d", a / b);
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
lea    0xf60(%rip),%rdi
mov    %rdi,-0x20(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1227 <main+0x107>
mov    -0x18(%rbp),%rax
lea    0xe45(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%esi
add    -0xc(%rbp),%esi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
mov    -0x8(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xedb(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11fc <main+0xcc>
lea    0xe5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x4(%rsp),%esi
add    0x8(%rsp),%esi
lea    0xe52(%rip),%rdi
jmp    11f5 <main+0xc5>
mov    0x8(%rsp),%esi
sub    0x4(%rsp),%esi
lea    0xe57(%rip),%rdi
jmp    11f5 <main+0xc5>
mov    0x4(%rsp),%esi
imul   0x8(%rsp),%esi
lea    0xe60(%rip),%rdi
jmp    11f5 <main+0xc5>
mov    0x8(%rsp),%eax
cltd
idivl  0x4(%rsp)
lea    0xe6d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"digite o primeiro numero:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"digite o segundo numero:\0A\00"
@.str.3 = [29 x i8] c"Qual operacao voce deseja ?\0A\00"
@.str.4 = [50 x i8] c" 1 Soma\0A 2 Subtracao\0A 3 Multiplicacao\0A 4 Divisao\0A\00"
@.str.5 = [22 x i8] c"voce escolheu soma %d\00"
@.str.6 = [27 x i8] c"voce escolheu Subtracao %d\00"
@.str.7 = [31 x i8] c"voce escolheu Multiplicacao %d\00"
@.str.8 = [25 x i8] c"voce escolheu Divisao %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
switch i32 %12, label %33 [
i32 1, label %13
i32 2, label %18
i32 3, label %23
i32 4, label %28
]
13: ; preds = %0
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = add nsw i32 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %16)
br label %33
18: ; preds = %0
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = sub nsw i32 %19, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %21)
br label %33
23: ; preds = %0
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = mul nsw i32 %24, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %26)
br label %33
28: ; preds = %0
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = sdiv i32 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %0, %28, %23, %18, %13
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [22 x i8] c"voce escolheu soma %d\00"
@.str.6 = [27 x i8] c"voce escolheu Subtracao %d\00"
@.str.7 = [31 x i8] c"voce escolheu Multiplicacao %d\00"
@.str.8 = [25 x i8] c"voce escolheu Divisao %d\00"
@str = [26 x i8] c"digite o primeiro numero:\00"
@str.9 = [25 x i8] c"digite o segundo numero:\00"
@str.10 = [28 x i8] c"Qual operacao voce deseja ?\00"
@str.11 = [49 x i8] c" 1 Soma\0A 2 Subtracao\0A 3 Multiplicacao\0A 4 Divisao\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.11, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
switch i32 %14, label %35 [
i32 1, label %15
i32 2, label %20
i32 3, label %25
i32 4, label %30
]
15: ; preds = %0
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %18)
br label %35
20: ; preds = %0
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = sub nsw i32 %21, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %35
25: ; preds = %0
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = mul nsw i32 %27, %26
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %28)
br label %35
30: ; preds = %0
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = sdiv i32 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %0, %30, %25, %20, %15
ret i32 0
}