#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 *, float *);
int main() {
  float a, b, calc, op;
  printf("Escolha um operador: \n");
  printf(" 1 - Soma \n 2 - Subtração \n 3 - Divisão \n 4 - Multiplicação \n");
  scanf("%f", &op);
  printf("Agora digite o primeiro numero: ");
  scanf("%f", &a);
  printf("Digite o segundo numero: ");
  scanf("%f", &b);
  if (op == 1) {
    calc = a + b;
  } else if (op == 2) {
    calc = a - b;
  } else if (op == 3) {
    calc = a / b;
  } else if (op == 4) {
    calc = a * b;
  } else {
    printf("Você digitou um operador inválido");
  }
  printf("Resultado: %0.1f", calc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf18(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe5c(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11c7 <main+0xa7>
jp     11c7 <main+0xa7>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1274 <main+0x154>
movss  -0x14(%rbp),%xmm0
movss  0xe30(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11f7 <main+0xd7>
jp     11f7 <main+0xd7>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    126f <main+0x14f>
movss  -0x14(%rbp),%xmm0
movss  0xe04(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1227 <main+0x107>
jp     1227 <main+0x107>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    126a <main+0x14a>
movss  -0x14(%rbp),%xmm0
movss  0xdd8(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1257 <main+0x137>
jp     1257 <main+0x137>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1265 <main+0x145>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126a <main+0x14a>
jmp    126f <main+0x14f>
jmp    1274 <main+0x154>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0xf51(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xe5c(%rip),%xmm0
jne    11b6 <main+0x86>
jp     11b6 <main+0x86>
movss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
jmp    120f <main+0xdf>
ucomiss 0xe47(%rip),%xmm0
jne    11cf <main+0x9f>
jp     11cf <main+0x9f>
movss  0x8(%rsp),%xmm0
subss  0x4(%rsp),%xmm0
jmp    120f <main+0xdf>
ucomiss 0xe32(%rip),%xmm0
jne    11e8 <main+0xb8>
jp     11e8 <main+0xb8>
movss  0x8(%rsp),%xmm0
divss  0x4(%rsp),%xmm0
jmp    120f <main+0xdf>
ucomiss 0xe1d(%rip),%xmm0
jne    1201 <main+0xd1>
jp     1201 <main+0xd1>
movss  0x8(%rsp),%xmm0
mulss  0x4(%rsp),%xmm0
jmp    120f <main+0xdf>
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe58(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Escolha um operador: \0A\00"
@.str.1 = [67 x i8] c" 1 - Soma \0A 2 - Subtra\C3\A7\C3\A3o \0A 3 - Divis\C3\A3o \0A 4 - Multiplica\C3\A7\C3\A3o \0A\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [33 x i8] c"Agora digite o primeiro numero: \00"
@.str.4 = [26 x i8] c"Digite o segundo numero: \00"
@.str.5 = [36 x i8] c"Voc\C3\AA digitou um operador inv\C3\A1lido\00"
@.str.6 = [17 x i8] c"Resultado: %0.1f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%13 = load float, float* %5
%14 = fcmp oeq float %13, 1.000000e+00
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load float, float* %2
%17 = load float, float* %3
%18 = fadd float %16, %17
store float %18, float* %4
br label %45
19: ; preds = %0
%20 = load float, float* %5
%21 = fcmp oeq float %20, 2.000000e+00
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load float, float* %2
%24 = load float, float* %3
%25 = fsub float %23, %24
store float %25, float* %4
br label %44
26: ; preds = %19
%27 = load float, float* %5
%28 = fcmp oeq float %27, 3.000000e+00
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load float, float* %2
%31 = load float, float* %3
%32 = fdiv float %30, %31
store float %32, float* %4
br label %43
33: ; preds = %26
%34 = load float, float* %5
%35 = fcmp oeq float %34, 4.000000e+00
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load float, float* %2
%38 = load float, float* %3
%39 = fmul float %37, %38
store float %39, float* %4
br label %42
40: ; preds = %33
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
br label %43
43: ; preds = %42, %29
br label %44
44: ; preds = %43, %22
br label %45
45: ; preds = %44, %15
%46 = load float, float* %4
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %47)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [33 x i8] c"Agora digite o primeiro numero: \00"
@.str.4 = [26 x i8] c"Digite o segundo numero: \00"
@.str.5 = [36 x i8] c"Voc\C3\AA digitou um operador inv\C3\A1lido\00"
@.str.6 = [17 x i8] c"Resultado: %0.1f\00"
@str = [22 x i8] c"Escolha um operador: \00"
@str.7 = [66 x i8] c" 1 - Soma \0A 2 - Subtra\C3\A7\C3\A3o \0A 3 - Divis\C3\A3o \0A 4 - Multiplica\C3\A7\C3\A3o \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.7, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%14 = load float, float* %3
%15 = fcmp oeq float %14, 1.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = load float, float* %1
%18 = load float, float* %2
%19 = fadd float %17, %18
br label %40
20: ; preds = %0
%21 = fcmp oeq float %14, 2.000000e+00
br i1 %21, label %22, label %26
22: ; preds = %20
%23 = load float, float* %1
%24 = load float, float* %2
%25 = fsub float %23, %24
br label %40
26: ; preds = %20
%27 = fcmp oeq float %14, 3.000000e+00
br i1 %27, label %28, label %32
28: ; preds = %26
%29 = load float, float* %1
%30 = load float, float* %2
%31 = fdiv float %29, %30
br label %40
32: ; preds = %26
%33 = fcmp oeq float %14, 4.000000e+00
br i1 %33, label %34, label %38
34: ; preds = %32
%35 = load float, float* %1
%36 = load float, float* %2
%37 = fmul float %35, %36
br label %40
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %22, %34, %38, %28, %16
%41 = phi float [ %19, %16 ], [ %25, %22 ], [ %31, %28 ], [ %37, %34 ], [ undef, %38 ]
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %42)
ret i32 0
}