#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 operacoes, soma, sub, mult, divi;
  int num1, num2, resp;
  printf("\nTabela da calculadora");
  printf("\n 1) soma");
  printf("\n 2) subtração");
  printf("\n 3)multiplicação");
  printf("\n 4)divisão");
  do {
    printf("\nentre com um número: ");
    scanf("%d", &num1);
    printf("\nentre com um número: ");
    scanf("%d", &num2);
    printf("qual operação você deseja? ");
    scanf("%d", &operacoes);
    if (operacoes == 1) {
      soma = num1 + num2;
      printf("\nsoma=%d", soma);
    }
    if (operacoes == 2) {
      sub = num1 - num2;
      printf("\nsub=%d", sub);
    }
    if (operacoes == 3) {
      mult = num1 * num2;
      printf("\nmult=%d", mult);
    }
    if (divi == 4) {
      divi = num1 / num2;
      printf("\ndivi=%d", divi);
    }
    printf("\ndeseja continuar? ");
    scanf("%d", &resp);
  } while (resp == 1);
  { printf("\nbons estudos\n"); }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11f3 <main+0xd3>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1217 <main+0xf7>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jne    123c <main+0x11c>
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x18(%rbp)
jne    1261 <main+0x141>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1a(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x24(%rbp)
je     1175 <main+0x55>
lea    0xe31(%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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec8(%rip),%r14
lea    0xefe(%rip),%rbx
lea    0x10(%rsp),%rbp
lea    0xf0f(%rip),%r15
lea    0x14(%rsp),%r12
jmp    11d0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x14(%rsp)
jne    12c0 <main+0x190>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    $0x1,%eax
je     1240 <main+0x110>
cmp    $0x2,%eax
je     125f <main+0x12f>
cmp    $0x3,%eax
je     127e <main+0x14e>
cmp    $0x4,%r13d
jne    11b0 <main+0x80>
jmp    129f <main+0x16f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
cmp    $0x2,%eax
jne    1225 <main+0xf5>
mov    0xc(%rsp),%esi
sub    0x8(%rsp),%esi
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
cmp    $0x3,%eax
jne    122a <main+0xfa>
mov    0x8(%rsp),%esi
imul   0xc(%rsp),%esi
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%r13d
jne    11b0 <main+0x80>
mov    0xc(%rsp),%eax
cltd
idivl  0x8(%rsp)
mov    %eax,%r13d
lea    0xdf2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b0 <main+0x80>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0ATabela da calculadora\00"
@.str.1 = [10 x i8] c"\0A 1) soma\00"
@.str.2 = [17 x i8] c"\0A 2) subtra\C3\A7\C3\A3o\00"
@.str.3 = [20 x i8] c"\0A 3)multiplica\C3\A7\C3\A3o\00"
@.str.4 = [13 x i8] c"\0A 4)divis\C3\A3o\00"
@.str.5 = [24 x i8] c"\0Aentre com um n\C3\BAmero: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [31 x i8] c"qual opera\C3\A7\C3\A3o voc\C3\AA deseja? \00"
@.str.8 = [9 x i8] c"\0Asoma=%d\00"
@.str.9 = [8 x i8] c"\0Asub=%d\00"
@.str.10 = [9 x i8] c"\0Amult=%d\00"
@.str.11 = [9 x i8] c"\0Adivi=%d\00"
@.str.12 = [20 x i8] c"\0Adeseja continuar? \00"
@.str.13 = [15 x i8] c"\0Abons estudos\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %60, %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %7)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %8)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %15
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = add nsw i32 %25, %26
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24, %15
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = sub nsw i32 %34, %35
store i32 %36, i32* %4
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %33, %30
%40 = load i32, i32* %2
%41 = icmp eq i32 %40, 3
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = mul nsw i32 %43, %44
store i32 %45, i32* %5
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %42, %39
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 4
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = sdiv i32 %52, %53
store i32 %54, i32* %6
%55 = load i32, i32* %6
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %51, %48
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%59 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %9)
br label %60
60: ; preds = %57
%61 = load i32, i32* %9
%62 = icmp eq i32 %61, 1
br i1 %62, label %15, label %63
63: ; preds = %60
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0ATabela da calculadora\00"
@.str.1 = [10 x i8] c"\0A 1) soma\00"
@.str.2 = [17 x i8] c"\0A 2) subtra\C3\A7\C3\A3o\00"
@.str.3 = [20 x i8] c"\0A 3)multiplica\C3\A7\C3\A3o\00"
@.str.4 = [13 x i8] c"\0A 4)divis\C3\A3o\00"
@.str.5 = [24 x i8] c"\0Aentre com um n\C3\BAmero: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [31 x i8] c"qual opera\C3\A7\C3\A3o voc\C3\AA deseja? \00"
@.str.8 = [9 x i8] c"\0Asoma=%d\00"
@.str.9 = [8 x i8] c"\0Asub=%d\00"
@.str.10 = [9 x i8] c"\0Amult=%d\00"
@.str.11 = [9 x i8] c"\0Adivi=%d\00"
@.str.12 = [20 x i8] c"\0Adeseja continuar? \00"
@str = [14 x i8] c"\0Abons estudos\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %54, %0
%15 = phi i32 [ undef, %0 ], [ %55, %54 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %14
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = add nsw i32 %26, %25
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
br label %30
30: ; preds = %24, %14
%31 = phi i32 [ %29, %24 ], [ %22, %14 ]
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = sub nsw i32 %34, %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %1
br label %39
39: ; preds = %33, %30
%40 = phi i32 [ %38, %33 ], [ %31, %30 ]
%41 = icmp eq i32 %40, 3
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = mul nsw i32 %44, %43
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %42, %39
%48 = icmp eq i32 %15, 4
br i1 %48, label %49, label %54
49: ; preds = %47
%50 = load i32, i32* %2
%51 = load i32, i32* %3
%52 = sdiv i32 %50, %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %49, %47
%55 = phi i32 [ %52, %49 ], [ %15, %47 ]
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
%57 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%58 = load i32, i32* %4
%59 = icmp eq i32 %58, 1
br i1 %59, label %14, label %60
60: ; preds = %54
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret i32 0
}