#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 *, ...);
void main() {
  float num1, num2, resultado;
  char op;
  printf("Selecione uma opção:\n\n(+) Adição\n(-) Subtração\n(*) "
         "Multiplicação\n(/) Divisão\n(x) Sair\n\n");
  scanf("%c", &op);
  while (op != 'x') {
    printf("Digite o primeiro numero: ");
    scanf("%f", &num1);
    printf("Digite o segundo numero: ");
    scanf("%f", &num2);
    switch (op) {
    case '+':
      resultado = num1 + num2;
      break;
    case '-':
      resultado = num1 - num2;
      break;
    case '*':
      resultado = num1 * num2;
      break;
    case '/':
      if (num1 == 0 || num2 == 0)
        printf("\n\nZero nao eh divisivel\n\n");
      else
        resultado = num1 / num2;
      break;
    default:
      printf("\n\nOpcao invalida\n\n");
    }
    printf("O resultado da operação %c eh igual a %.2f\n\n", op, resultado);
    printf("Selecione uma opção:\n\n(+) Adição\n(-) Subtração\n(*) "
           "Multiplicação\n(/) Divisão\n(x) Sair\n\n");
    scanf(" %c", &op);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfd1(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x78,%eax
je     12aa <main+0x18a>
lea    0xf1d(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf24(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
lea    0xf10(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x19(%rbp),%al
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     125c <main+0x13c>
mov    -0x18(%rbp),%rax
lea    0xe43(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x4(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    126a <main+0x14a>
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    126a <main+0x14a>
movss  -0x4(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    126a <main+0x14a>
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    121e <main+0xfe>
jp     121e <main+0xfe>
jmp    1235 <main+0x115>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1248 <main+0x128>
jp     1248 <main+0x128>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1257 <main+0x137>
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    126a <main+0x14a>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xd(%rbp),%esi
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe60(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    1148 <main+0x28>
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    0xf3e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2f(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x78,0xb(%rsp)
jne    1173 <main+0x43>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeb9(%rip),%rbx
lea    0xecf(%rip),%rbp
lea    0xefb(%rip),%r14
lea    0xef0(%rip),%r15
lea    0xb(%rsp),%r12
lea    0xe65(%rip),%r13
jmp    11e9 <main+0xb9>
nopl   (%rax)
movss  0x10(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
nopl   0x0(%rax)
movsbl 0xb(%rsp),%esi
movss  %xmm0,0x14(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x78,0xb(%rsp)
je     1164 <main+0x34>
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe29(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xb(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     1250 <main+0x120>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
movss  0x10(%rsp),%xmm0
addss  0xc(%rsp),%xmm0
jmp    11b0 <main+0x80>
nopl   0x0(%rax,%rax,1)
lea    0xea5(%rip),%rdi
jmp    12ad <main+0x17d>
nopl   0x0(%rax)
movss  0x10(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
jmp    11b0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x10(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jne    1290 <main+0x160>
jnp    12a6 <main+0x176>
movss  0xc(%rsp),%xmm1
ucomiss %xmm2,%xmm1
jne    129d <main+0x16d>
jnp    12a6 <main+0x176>
divss  %xmm1,%xmm0
jmp    11b0 <main+0x80>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
movss  0x14(%rsp),%xmm0
jmp    11b0 <main+0x80>

LLVM IR (-O0):
@.str = [97 x i8] c"Selecione uma op\C3\A7\C3\A3o:\0A\0A(+) Adi\C3\A7\C3\A3o\0A(-) Subtra\C3\A7\C3\A3o\0A(*) Multiplica\C3\A7\C3\A3o\0A(/) Divis\C3\A3o\0A(x) Sair\0A\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [27 x i8] c"Digite o primeiro numero: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [26 x i8] c"Digite o segundo numero: \00"
@.str.5 = [26 x i8] c"\0A\0AZero nao eh divisivel\0A\0A\00"
@.str.6 = [19 x i8] c"\0A\0AOpcao invalida\0A\0A\00"
@.str.7 = [47 x i8] c"O resultado da opera\C3\A7\C3\A3o %c eh igual a %.2f\0A\0A\00"
@.str.8 = [4 x i8] c" %c\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca i8
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %7
7: ; preds = %45, %0
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 120
br i1 %10, label %11, label %53
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %1)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
switch i32 %17, label %43 [
i32 43, label %18
i32 45, label %22
i32 42, label %26
i32 47, label %30
]
18: ; preds = %11
%19 = load float, float* %1
%20 = load float, float* %2
%21 = fadd float %19, %20
store float %21, float* %3
br label %45
22: ; preds = %11
%23 = load float, float* %1
%24 = load float, float* %2
%25 = fsub float %23, %24
store float %25, float* %3
br label %45
26: ; preds = %11
%27 = load float, float* %1
%28 = load float, float* %2
%29 = fmul float %27, %28
store float %29, float* %3
br label %45
30: ; preds = %11
%31 = load float, float* %1
%32 = fcmp oeq float %31, 0.000000e+00
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load float, float* %2
%35 = fcmp oeq float %34, 0.000000e+00
br i1 %35, label %36, label %38
36: ; preds = %33, %30
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %42
38: ; preds = %33
%39 = load float, float* %1
%40 = load float, float* %2
%41 = fdiv float %39, %40
store float %41, float* %3
br label %42
42: ; preds = %38, %36
br label %45
43: ; preds = %11
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %45
45: ; preds = %43, %42, %26, %22, %18
%46 = load i8, i8* %4
%47 = sext i8 %46 to i32
%48 = load float, float* %3
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i32 %47, double %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%52 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %7
53: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [27 x i8] c"Digite o primeiro numero: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [26 x i8] c"Digite o segundo numero: \00"
@.str.7 = [47 x i8] c"O resultado da opera\C3\A7\C3\A3o %c eh igual a %.2f\0A\0A\00"
@.str.8 = [4 x i8] c" %c\00"
@str.9 = [96 x i8] c"Selecione uma op\C3\A7\C3\A3o:\0A\0A(+) Adi\C3\A7\C3\A3o\0A(-) Subtra\C3\A7\C3\A3o\0A(*) Multiplica\C3\A7\C3\A3o\0A(/) Divis\C3\A3o\0A(x) Sair\0A\00"
@str.10 = [25 x i8] c"\0A\0AZero nao eh divisivel\0A\00"
@str.11 = [18 x i8] c"\0A\0AOpcao invalida\0A\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @str.9, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 120
br i1 %9, label %52, label %10
10: ; preds = %0, %42
%11 = phi float [ %43, %42 ], [ undef, %0 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
switch i32 %17, label %40 [
i32 43, label %18
i32 45, label %22
i32 42, label %26
i32 47, label %30
]
18: ; preds = %10
%19 = load float, float* %1
%20 = load float, float* %2
%21 = fadd float %19, %20
br label %42
22: ; preds = %10
%23 = load float, float* %1
%24 = load float, float* %2
%25 = fsub float %23, %24
br label %42
26: ; preds = %10
%27 = load float, float* %1
%28 = load float, float* %2
%29 = fmul float %27, %28
br label %42
30: ; preds = %10
%31 = load float, float* %1
%32 = fcmp oeq float %31, 0.000000e+00
%33 = load float, float* %2
%34 = fcmp oeq float %33, 0.000000e+00
%35 = select i1 %32, i1 true, i1 %34
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
br label %42
38: ; preds = %30
%39 = fdiv float %31, %33
br label %42
40: ; preds = %10
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.11, i64 0, i64 0))
br label %42
42: ; preds = %36, %38, %40, %26, %22, %18
%43 = phi float [ %11, %40 ], [ %11, %36 ], [ %39, %38 ], [ %29, %26 ], [ %25, %22 ], [ %21, %18 ]
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = fpext float %43 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i32 %45, double %46)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @str.9, i64 0, i64 0))
%49 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %3)
%50 = load i8, i8* %3
%51 = icmp eq i8 %50, 120
br i1 %51, label %52, label %10
52: ; preds = %42, %0
ret void
}