#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 adicao, sub, mult, divi;
  int num1, num2;
  int resp, resp2;
  do {
    printf("\nEntre com um numero:");
    scanf("%d", &num1);
    printf("\n Entre com outro numero:");
    scanf("%d", &num2);
    printf("\n Escolha uma operaçao");
    printf("\n 1- adiçao");
    printf("\n 2- subtraçao");
    printf("\n 3- multiplicaçao");
    printf("\n 4- divisao");
    scanf("%d", &resp);
    if (resp == 1) {
      adicao = num1 + num2;
      printf("\n %d + %d = %d", num1, num2, adicao);
    } else if (resp == 2) {
      sub = num1 - num2;
      printf("\n %d - %d = %d", num1, num2, sub);
    } else if (resp == 3) {
      mult = num1 * num2;
      printf("\n %d * %d = %d", num1, num2, mult);
    } else if (resp == 4) {
      divi = num1 % num2;
      printf("\n %d / %d = %d", num1, num2, divi);
    }
    printf("\nDesesa continuar? (1-sim/2-nao)");
    scanf("%d", &resp2);
  } while (resp2 == 1);
  return 0;
}


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    0xf6c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4e(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x20(%rbp)
jne    11f0 <main+0xd0>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1289 <main+0x169>
cmpl   $0x2,-0x20(%rbp)
jne    121f <main+0xff>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1284 <main+0x164>
cmpl   $0x3,-0x20(%rbp)
jne    124f <main+0x12f>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <main+0x15f>
cmpl   $0x4,-0x20(%rbp)
jne    127a <main+0x15a>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <main+0x15f>
jmp    1284 <main+0x164>
jmp    1289 <main+0x169>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe12(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x24(%rbp)
je     112f <main+0xf>
xor    %eax,%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    0xedb(%rip),%rbp
lea    0xf84(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0xf8a(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xeac(%rip),%r13
jmp    11ab <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
mov    %rbx,%r8
mov    %rbp,%rbx
mov    0x8(%rsp),%ebp
mov    %esi,%eax
cltd
idiv   %ebp
mov    %edx,%ecx
lea    0xf47(%rip),%rdi
mov    %ebp,%edx
mov    %rbx,%rbp
mov    %r8,%rbx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0x10(%rsp)
jne    1299 <main+0x179>
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     118b <main+0x6b>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    (%rdx,%rsi,1),%ecx
lea    0xe3c(%rip),%rdi
jmp    1184 <main+0x64>
nop
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %esi,%ecx
sub    %edx,%ecx
lea    0xe32(%rip),%rdi
jmp    1184 <main+0x64>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %edx,%ecx
imul   %esi,%ecx
lea    0xe20(%rip),%rdi
jmp    1184 <main+0x64>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0AEntre com um numero:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0A Entre com outro numero:\00"
@.str.3 = [24 x i8] c"\0A Escolha uma opera\C3\A7ao\00"
@.str.4 = [13 x i8] c"\0A 1- adi\C3\A7ao\00"
@.str.5 = [16 x i8] c"\0A 2- subtra\C3\A7ao\00"
@.str.6 = [20 x i8] c"\0A 3- multiplica\C3\A7ao\00"
@.str.7 = [13 x i8] c"\0A 4- divisao\00"
@.str.8 = [15 x i8] c"\0A %d + %d = %d\00"
@.str.9 = [15 x i8] c"\0A %d - %d = %d\00"
@.str.10 = [15 x i8] c"\0A %d * %d = %d\00"
@.str.11 = [15 x i8] c"\0A %d / %d = %d\00"
@.str.12 = [33 x i8] c"\0ADesesa continuar? (1-sim/2-nao)\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
br label %10
10: ; preds = %70, %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %31
23: ; preds = %10
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = add nsw i32 %24, %25
store i32 %26, i32* %2
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %67
31: ; preds = %10
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = sub nsw i32 %35, %36
store i32 %37, i32* %3
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
br label %66
42: ; preds = %31
%43 = load i32, i32* %8
%44 = icmp eq i32 %43, 3
br i1 %44, label %45, label %53
45: ; preds = %42
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = mul nsw i32 %46, %47
store i32 %48, i32* %4
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = load i32, i32* %4
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
br label %65
53: ; preds = %42
%54 = load i32, i32* %8
%55 = icmp eq i32 %54, 4
br i1 %55, label %56, label %64
56: ; preds = %53
%57 = load i32, i32* %6
%58 = load i32, i32* %7
%59 = srem i32 %57, %58
store i32 %59, i32* %5
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = load i32, i32* %5
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %60, i32 %61, i32 %62)
br label %64
64: ; preds = %56, %53
br label %65
65: ; preds = %64, %45
br label %66
66: ; preds = %65, %34
br label %67
67: ; preds = %66, %23
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
%69 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
br label %70
70: ; preds = %67
%71 = load i32, i32* %9
%72 = icmp eq i32 %71, 1
br i1 %72, label %10, label %73
73: ; preds = %70
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"\0AEntre com um numero:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0A Entre com outro numero:\00"
@.str.3 = [24 x i8] c"\0A Escolha uma opera\C3\A7ao\00"
@.str.4 = [13 x i8] c"\0A 1- adi\C3\A7ao\00"
@.str.5 = [16 x i8] c"\0A 2- subtra\C3\A7ao\00"
@.str.6 = [20 x i8] c"\0A 3- multiplica\C3\A7ao\00"
@.str.7 = [13 x i8] c"\0A 4- divisao\00"
@.str.8 = [15 x i8] c"\0A %d + %d = %d\00"
@.str.9 = [15 x i8] c"\0A %d - %d = %d\00"
@.str.10 = [15 x i8] c"\0A %d * %d = %d\00"
@.str.11 = [15 x i8] c"\0A %d / %d = %d\00"
@.str.12 = [33 x i8] c"\0ADesesa continuar? (1-sim/2-nao)\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*
br label %9
9: ; preds = %41, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %3
switch i32 %20, label %41 [
i32 1, label %21
i32 2, label %26
i32 3, label %31
i32 4, label %36
]
21: ; preds = %9
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = add nsw i32 %23, %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
br label %41
26: ; preds = %9
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = sub nsw i32 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %41
31: ; preds = %9
%32 = load i32, i32* %1
%33 = load i32, i32* %2
%34 = mul nsw i32 %33, %32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
br label %41
36: ; preds = %9
%37 = load i32, i32* %1
%38 = load i32, i32* %2
%39 = srem i32 %37, %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %37, i32 %38, i32 %39)
br label %41
41: ; preds = %9, %26, %36, %31, %21
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, 1
br i1 %45, label %9, label %46
46: ; preds = %41
ret i32 0
}