#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 opc, continuar;
  int num1, num2;
  float res;
  do {
    printf("\nQual operação deseja?");
    printf("\n1 - adição");
    printf("\n2 - subtração");
    printf("\n3 - multiplicação");
    printf("\n4 - divisão");
    printf("\nOpção:");
    scanf("%d", &opc);
    printf("\nEntre com num1:");
    scanf("%d", &num1);
    printf("\nEntre com num2:");
    scanf("%d", &num2);
    switch (opc) {
    case 1:
      res = num1 + num2;
      printf("\n %d + %d = %.2f", num1, num2, res);
      break;
    case 2:
      res = num1 - num2;
      printf("\n %d - %d = %.2f", num1, num2, res);
      break;
    case 3:
      res = num1 * num2;
      printf("\n %d * %d = %.2f", num1, num2, res);
      break;
    case 4:
      res = (float)num1 / num2;
      printf("\n %d / %d = %.2f", num1, num2, res);
      break;
    }
    printf("\nDeseja continuar(1-s/2-n)?");
    scanf("%d", &continuar);
  } while (continuar == 1);
  printf("\nBye bye\n");
  return 0;
}


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,-0x29(%rbp)
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xee0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     12c4 <main+0x1a4>
mov    -0x20(%rbp),%rax
lea    0xe09(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x1a4>
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x1a4>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x1a4>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe10(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd9c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
je     112f <main+0xf>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    0xf30(%rip),%r14
lea    0xf3d(%rip),%rbx
lea    0x8(%rsp),%rbp
lea    0xf86(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xe9c(%rip),%r13
jmp    11bc <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
xorps  %xmm0,%xmm0
cvtsi2ss %esi,%xmm0
mov    0x8(%rsp),%edx
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xf38(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x10(%rsp)
jne    12e4 <main+0x1b4>
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     119c <main+0x6c>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    (%rdx,%rsi,1),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe16(%rip),%rdi
jmp    1195 <main+0x65>
nopl   0x0(%rax)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %esi,%eax
sub    %edx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfd(%rip),%rdi
jmp    1195 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %edx,%eax
imul   %esi,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddd(%rip),%rdi
jmp    1195 <main+0x65>
lea    0xe0f(%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 = [25 x i8] c"\0AQual opera\C3\A7\C3\A3o deseja?\00"
@.str.1 = [14 x i8] c"\0A1 - adi\C3\A7\C3\A3o\00"
@.str.2 = [17 x i8] c"\0A2 - subtra\C3\A7\C3\A3o\00"
@.str.3 = [21 x i8] c"\0A3 - multiplica\C3\A7\C3\A3o\00"
@.str.4 = [14 x i8] c"\0A4 - divis\C3\A3o\00"
@.str.5 = [10 x i8] c"\0AOp\C3\A7\C3\A3o:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [17 x i8] c"\0AEntre com num1:\00"
@.str.8 = [17 x i8] c"\0AEntre com num2:\00"
@.str.9 = [17 x i8] c"\0A %d + %d = %.2f\00"
@.str.10 = [17 x i8] c"\0A %d - %d = %.2f\00"
@.str.11 = [17 x i8] c"\0A %d * %d = %.2f\00"
@.str.12 = [17 x i8] c"\0A %d / %d = %.2f\00"
@.str.13 = [28 x i8] c"\0ADeseja continuar(1-s/2-n)?\00"
@.str.14 = [10 x i8] c"\0ABye bye\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
br label %7
7: ; preds = %64, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %2
switch i32 %19, label %61 [
i32 1, label %20
i32 2, label %30
i32 3, label %40
i32 4, label %50
]
20: ; preds = %7
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = add nsw i32 %21, %22
%24 = sitofp i32 %23 to float
store float %24, float* %6
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %25, i32 %26, double %28)
br label %61
30: ; preds = %7
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = sub nsw i32 %31, %32
%34 = sitofp i32 %33 to float
store float %34, float* %6
%35 = load i32, i32* %4
%36 = load i32, i32* %5
%37 = load float, float* %6
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 %35, i32 %36, double %38)
br label %61
40: ; preds = %7
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = mul nsw i32 %41, %42
%44 = sitofp i32 %43 to float
store float %44, float* %6
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = load float, float* %6
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %45, i32 %46, double %48)
br label %61
50: ; preds = %7
%51 = load i32, i32* %4
%52 = sitofp i32 %51 to float
%53 = load i32, i32* %5
%54 = sitofp i32 %53 to float
%55 = fdiv float %52, %54
store float %55, float* %6
%56 = load i32, i32* %4
%57 = load i32, i32* %5
%58 = load float, float* %6
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i32 %56, i32 %57, double %59)
br label %61
61: ; preds = %7, %50, %40, %30, %20
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%63 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
br label %64
64: ; preds = %61
%65 = load i32, i32* %3
%66 = icmp eq i32 %65, 1
br i1 %66, label %7, label %67
67: ; preds = %64
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0AQual opera\C3\A7\C3\A3o deseja?\00"
@.str.1 = [14 x i8] c"\0A1 - adi\C3\A7\C3\A3o\00"
@.str.2 = [17 x i8] c"\0A2 - subtra\C3\A7\C3\A3o\00"
@.str.3 = [21 x i8] c"\0A3 - multiplica\C3\A7\C3\A3o\00"
@.str.4 = [14 x i8] c"\0A4 - divis\C3\A3o\00"
@.str.5 = [10 x i8] c"\0AOp\C3\A7\C3\A3o:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [17 x i8] c"\0AEntre com num1:\00"
@.str.8 = [17 x i8] c"\0AEntre com num2:\00"
@.str.9 = [17 x i8] c"\0A %d + %d = %.2f\00"
@.str.10 = [17 x i8] c"\0A %d - %d = %.2f\00"
@.str.11 = [17 x i8] c"\0A %d * %d = %.2f\00"
@.str.12 = [17 x i8] c"\0A %d / %d = %.2f\00"
@.str.13 = [28 x i8] c"\0ADeseja continuar(1-s/2-n)?\00"
@str = [9 x i8] c"\0ABye bye\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 = %51, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %1
switch i32 %21, label %51 [
i32 1, label %22
i32 2, label %29
i32 3, label %36
i32 4, label %43
]
22: ; preds = %9
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = add nsw i32 %24, %23
%26 = sitofp i32 %25 to float
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %23, i32 %24, double %27)
br label %51
29: ; preds = %9
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = sub nsw i32 %30, %31
%33 = sitofp i32 %32 to float
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 %30, i32 %31, double %34)
br label %51
36: ; preds = %9
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = mul nsw i32 %38, %37
%40 = sitofp i32 %39 to float
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i32 %37, i32 %38, double %41)
br label %51
43: ; preds = %9
%44 = load i32, i32* %3
%45 = sitofp i32 %44 to float
%46 = load i32, i32* %4
%47 = sitofp i32 %46 to float
%48 = fdiv float %45, %47
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i32 %44, i32 %46, double %49)
br label %51
51: ; preds = %9, %43, %36, %29, %22
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%54 = load i32, i32* %2
%55 = icmp eq i32 %54, 1
br i1 %55, label %9, label %56
56: ; preds = %51
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}