#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 result = 0;
  char sinal, continuar;
  float n1, n2;
  do {
    printf("(1) Calcular\n");
    printf("(2) Sair\n");
    scanf(" %c", &continuar);
    if (continuar == '2') {
      printf("SAINDO\n");
      break;
    }
    printf("Escreva expressao na seguinte forma: N1 [sinal] N2\n");
    scanf("%f %c %f", &n1, &sinal, &n2);
    if ((sinal == '/') && (n2 == 0)) {
      printf("Operacao nao permitida, SAINDO\n");
      return 0;
    } else {
      switch (sinal) {
      case '+':
        result = n1 + n2;
        break;
      case '-':
        result = n1 - n2;
        break;
      case '*':
        result = n1 * n2;
        break;
      case '/':
        result = n1 / n2;
        break;
      case '%':
        result = (int)n1 % (int)n2;
        break;
      default:
        printf("SINAL ERRADO\n");
        break;
      }
      printf("%.2f\n", result);
    }
  } while (continuar == '1');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xa(%rbp),%eax
cmp    $0x32,%eax
jne    1185 <main+0x65>
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b7 <main+0x197>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x9(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x2f,%eax
jne    11eb <main+0xcb>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11eb <main+0xcb>
jp     11eb <main+0xcb>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12be <main+0x19e>
movsbl -0x9(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xa,%eax
ja     1280 <main+0x160>
mov    -0x20(%rbp),%rax
lea    0xdf4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    128e <main+0x16e>
movss  -0x10(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    128e <main+0x16e>
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    128e <main+0x16e>
movss  -0x10(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    128e <main+0x16e>
cvttss2si -0x10(%rbp),%eax
cvttss2si -0x14(%rbp),%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    128e <main+0x16e>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12aa <main+0x18a>
movsbl -0xa(%rbp),%eax
cmp    $0x31,%eax
je     1137 <main+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%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    0xa(%rsp),%rbx
lea    0xc(%rsp),%r15
lea    0xb(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0xee4(%rip),%rbp
lea    0xea4(%rip),%r14
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
jmp    11a2 <main+0x72>
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
movss  0x10(%rsp),%xmm1
nopl   (%rax)
movss  %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpb   $0x31,0xa(%rsp)
jne    1291 <main+0x161>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x32,0xa(%rsp)
je     127c <main+0x14c>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4b(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xb(%rsp),%eax
movss  0x14(%rsp),%xmm0
cmp    $0x2f,%eax
jne    1214 <main+0xe4>
ucomiss 0xdf0(%rip),%xmm0
jne    1214 <main+0xe4>
jnp    1285 <main+0x155>
add    $0xffffffdb,%eax
cmp    $0xa,%eax
ja     116b <main+0x3b>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
cvttss2si 0xc(%rsp),%eax
cvttss2si %xmm0,%ecx
cltd
idiv   %ecx
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
jmp    1180 <main+0x50>
mulss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
jmp    1180 <main+0x50>
addss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
jmp    1180 <main+0x50>
movss  0xc(%rsp),%xmm1
subss  %xmm0,%xmm1
jmp    1180 <main+0x50>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
jmp    1180 <main+0x50>
lea    0xe2e(%rip),%rdi
jmp    128c <main+0x15c>
lea    0xe0d(%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 = [14 x i8] c"(1) Calcular\0A\00"
@.str.1 = [10 x i8] c"(2) Sair\0A\00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [8 x i8] c"SAINDO\0A\00"
@.str.4 = [52 x i8] c"Escreva expressao na seguinte forma: N1 [sinal] N2\0A\00"
@.str.5 = [9 x i8] c"%f %c %f\00"
@.str.6 = [32 x i8] c"Operacao nao permitida, SAINDO\0A\00"
@.str.7 = [14 x i8] c"SINAL ERRADO\0A\00"
@.str.8 = [6 x i8] c"%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca i8
%4 = alloca i8
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
br label %7
7: ; preds = %60, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 50
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %64
16: ; preds = %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), float* %5, i8* %3, float* %6)
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load float, float* %6
%24 = fcmp oeq float %23, 0.000000e+00
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %65
27: ; preds = %22, %16
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
switch i32 %29, label %53 [
i32 43, label %30
i32 45, label %34
i32 42, label %38
i32 47, label %42
i32 37, label %46
]
30: ; preds = %27
%31 = load float, float* %5
%32 = load float, float* %6
%33 = fadd float %31, %32
store float %33, float* %2
br label %55
34: ; preds = %27
%35 = load float, float* %5
%36 = load float, float* %6
%37 = fsub float %35, %36
store float %37, float* %2
br label %55
38: ; preds = %27
%39 = load float, float* %5
%40 = load float, float* %6
%41 = fmul float %39, %40
store float %41, float* %2
br label %55
42: ; preds = %27
%43 = load float, float* %5
%44 = load float, float* %6
%45 = fdiv float %43, %44
store float %45, float* %2
br label %55
46: ; preds = %27
%47 = load float, float* %5
%48 = fptosi float %47 to i32
%49 = load float, float* %6
%50 = fptosi float %49 to i32
%51 = srem i32 %48, %50
%52 = sitofp i32 %51 to float
store float %52, float* %2
br label %55
53: ; preds = %27
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %55
55: ; preds = %53, %46, %42, %38, %34, %30
%56 = load float, float* %2
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), double %57)
br label %59
59: ; preds = %55
br label %60
60: ; preds = %59
%61 = load i8, i8* %4
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 49
br i1 %63, label %7, label %64
64: ; preds = %60, %14
store i32 0, i32* %1
br label %65
65: ; preds = %64, %25
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c" %c\00"
@.str.5 = [9 x i8] c"%f %c %f\00"
@.str.8 = [6 x i8] c"%.2f\0A\00"
@str = [13 x i8] c"(1) Calcular\00"
@str.9 = [9 x i8] c"(2) Sair\00"
@str.10 = [51 x i8] c"Escreva expressao na seguinte forma: N1 [sinal] N2\00"
@str.11 = [13 x i8] c"SINAL ERRADO\00"
@str.12 = [31 x i8] c"Operacao nao permitida, SAINDO\00"
@str.13 = [7 x i8] c"SAINDO\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %3 to i8*
%6 = bitcast float* %4 to i8*
br label %7
7: ; preds = %44, %0
%8 = phi float [ 0.000000e+00, %0 ], [ %45, %44 ]
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
%13 = icmp eq i8 %12, 50
br i1 %13, label %50, label %14
14: ; preds = %7
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.10, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), float* %3, i8* %1, float* %4)
%17 = load i8, i8* %1
%18 = icmp eq i8 %17, 47
%19 = load float, float* %4
%20 = fcmp oeq float %19, 0.000000e+00
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %50, label %22
22: ; preds = %14
%23 = sext i8 %17 to i32
switch i32 %23, label %42 [
i32 43, label %24
i32 45, label %27
i32 42, label %30
i32 47, label %33
i32 37, label %36
]
24: ; preds = %22
%25 = load float, float* %3
%26 = fadd float %19, %25
br label %44
27: ; preds = %22
%28 = load float, float* %3
%29 = fsub float %28, %19
br label %44
30: ; preds = %22
%31 = load float, float* %3
%32 = fmul float %19, %31
br label %44
33: ; preds = %22
%34 = load float, float* %3
%35 = fdiv float %34, %19
br label %44
36: ; preds = %22
%37 = load float, float* %3
%38 = fptosi float %37 to i32
%39 = fptosi float %19 to i32
%40 = srem i32 %38, %39
%41 = sitofp i32 %40 to float
br label %44
42: ; preds = %22
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
br label %44
44: ; preds = %42, %36, %33, %30, %27, %24
%45 = phi float [ %8, %42 ], [ %41, %36 ], [ %35, %33 ], [ %32, %30 ], [ %29, %27 ], [ %26, %24 ]
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), double %46)
%48 = load i8, i8* %2
%49 = icmp eq i8 %48, 49
br i1 %49, label %7, label %53
50: ; preds = %14, %7
%51 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.13, i64 0, i64 0), %7 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0), %14 ]
%52 = call i32 @puts(i8* dereferenceable(1) %51)
br label %53
53: ; preds = %44, %50
ret i32 0
}