#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 main() {
  float a, b, resultado;
  char c;
  printf("entre com o valor do primeiro termo: ");
  scanf("%f", &a);
  printf("entre com o valor do segundo termo: ");
  scanf("%f", &b);
  printf("entre com a operação(+,-,*,/): ");
  scanf(" %c", &c);
  if (c == '/' && b == 0) {
    printf("o segundo termo não pode ser 0\n");
  } else {
    switch (c) {
    case '+': {
      resultado = a + b;
      break;
    }
    case '-': {
      resultado = a - b;
      break;
    }
    case '*': {
      resultado = a * b;
      break;
    }
    case '/': {
      resultado = a / b;
      break;
    }
    default:
      printf("opéração invalida\n");
    }
    if (c == '+' || c == '-' || c == '*' || c == '/')
      printf("resultado = %.2f", resultado);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
jne    11c6 <main+0xa6>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c6 <main+0xa6>
jp     11c6 <main+0xa6>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129e <main+0x17e>
movsbl -0x11(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1240 <main+0x120>
mov    -0x20(%rbp),%rax
lea    0xe19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    124e <main+0x12e>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    124e <main+0x12e>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    124e <main+0x12e>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    124e <main+0x12e>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x2b,%eax
je     1282 <main+0x162>
movsbl -0x11(%rbp),%eax
cmp    $0x2d,%eax
je     1282 <main+0x162>
movsbl -0x11(%rbp),%eax
cmp    $0x2a,%eax
je     1282 <main+0x162>
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
jne    1299 <main+0x179>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe31(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    129e <main+0x17e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef4(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xee1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xee9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefd(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
movss  0xc(%rsp),%xmm0
cmp    $0x2f,%eax
jne    11bf <main+0x8f>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11bf <main+0x8f>
jp     11bf <main+0x8f>
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
jmp    123b <main+0x10b>
lea    -0x2a(%rax),%ecx
cmp    $0x5,%ecx
ja     11e7 <main+0xb7>
lea    0xe32(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mulss  0x8(%rsp),%xmm0
jmp    1212 <main+0xe2>
addss  0x8(%rsp),%xmm0
jmp    1212 <main+0xe2>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    0x7(%rsp),%al
jmp    1212 <main+0xe2>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
jmp    120f <main+0xdf>
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
cmp    $0x2f,%al
ja     123b <main+0x10b>
movzbl %al,%eax
movabs $0xac0000000000,%rcx
bt     %rax,%rcx
jae    123b <main+0x10b>
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 = [38 x i8] c"entre com o valor do primeiro termo: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [37 x i8] c"entre com o valor do segundo termo: \00"
@.str.3 = [34 x i8] c"entre com a opera\C3\A7\C3\A3o(+,-,*,/): \00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [33 x i8] c"o segundo termo n\C3\A3o pode ser 0\0A\00"
@.str.6 = [22 x i8] c"op\C3\A9ra\C3\A7\C3\A3o invalida\0A\00"
@.str.7 = [17 x i8] c"resultado = %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i8
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 47
br i1 %14, label %15, label %20
15: ; preds = %0
%16 = load float, float* %3
%17 = fcmp oeq float %16, 0.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %62
20: ; preds = %15, %0
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
switch i32 %22, label %39 [
i32 43, label %23
i32 45, label %27
i32 42, label %31
i32 47, label %35
]
23: ; preds = %20
%24 = load float, float* %2
%25 = load float, float* %3
%26 = fadd float %24, %25
store float %26, float* %4
br label %41
27: ; preds = %20
%28 = load float, float* %2
%29 = load float, float* %3
%30 = fsub float %28, %29
store float %30, float* %4
br label %41
31: ; preds = %20
%32 = load float, float* %2
%33 = load float, float* %3
%34 = fmul float %32, %33
store float %34, float* %4
br label %41
35: ; preds = %20
%36 = load float, float* %2
%37 = load float, float* %3
%38 = fdiv float %36, %37
store float %38, float* %4
br label %41
39: ; preds = %20
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %41
41: ; preds = %39, %35, %31, %27, %23
%42 = load i8, i8* %5
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 43
br i1 %44, label %57, label %45
45: ; preds = %41
%46 = load i8, i8* %5
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 45
br i1 %48, label %57, label %49
49: ; preds = %45
%50 = load i8, i8* %5
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 42
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8, i8* %5
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 47
br i1 %56, label %57, label %61
57: ; preds = %53, %49, %45, %41
%58 = load float, float* %4
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), double %59)
br label %61
61: ; preds = %57, %53
br label %62
62: ; preds = %61, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"entre com o valor do primeiro termo: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [37 x i8] c"entre com o valor do segundo termo: \00"
@.str.3 = [34 x i8] c"entre com a opera\C3\A7\C3\A3o(+,-,*,/): \00"
@.str.4 = [4 x i8] c" %c\00"
@.str.7 = [17 x i8] c"resultado = %.2f\00"
@str = [21 x i8] c"op\C3\A9ra\C3\A7\C3\A3o invalida\00"
@str.8 = [32 x i8] c"o segundo termo n\C3\A3o pode ser 0\00"
define i32 @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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%12 = load i8, i8* %3
%13 = icmp eq i8 %12, 47
%14 = load float, float* %2
%15 = fcmp oeq float %14, 0.000000e+00
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
br label %42
19: ; preds = %0
%20 = sext i8 %12 to i32
switch i32 %20, label %33 [
i32 43, label %21
i32 45, label %24
i32 42, label %27
i32 47, label %30
]
21: ; preds = %19
%22 = load float, float* %1
%23 = fadd float %14, %22
br label %36
24: ; preds = %19
%25 = load float, float* %1
%26 = fsub float %25, %14
br label %36
27: ; preds = %19
%28 = load float, float* %1
%29 = fmul float %14, %28
br label %36
30: ; preds = %19
%31 = load float, float* %1
%32 = fdiv float %31, %14
br label %36
33: ; preds = %19
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%35 = load i8, i8* %3
br label %36
36: ; preds = %33, %30, %27, %24, %21
%37 = phi i8 [ %35, %33 ], [ %12, %30 ], [ %12, %27 ], [ %12, %24 ], [ %12, %21 ]
%38 = phi float [ undef, %33 ], [ %32, %30 ], [ %29, %27 ], [ %26, %24 ], [ %23, %21 ]
switch i8 %37, label %42 [
i8 47, label %39
i8 45, label %39
i8 43, label %39
i8 42, label %39
]
39: ; preds = %36, %36, %36, %36
%40 = fpext float %38 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), double %40)
br label %42
42: ; preds = %36, %39, %17
ret i32 0
}