#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;
  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 o numero na seguinte forma \t N1 * N2\n");
    printf("Digite aqui o numero\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");
      }
      printf("%f\n", result);
    }
  } while (continuar == '1');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
lea    -0xa(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xa(%rbp),%eax
cmp    $0x32,%eax
jne    117d <main+0x5d>
lea    0xf3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bd <main+0x19d>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%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    11f1 <main+0xd1>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11f1 <main+0xd1>
jp     11f1 <main+0xd1>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c4 <main+0x1a4>
movsbl -0x9(%rbp),%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xa,%eax
ja     1286 <main+0x166>
mov    -0x20(%rbp),%rax
lea    0xdee(%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    1294 <main+0x174>
movss  -0x10(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1294 <main+0x174>
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1294 <main+0x174>
movss  -0x10(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1294 <main+0x174>
cvttss2si -0x10(%rbp),%eax
cvttss2si -0x14(%rbp),%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1294 <main+0x174>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12b0 <main+0x190>
movsbl -0xa(%rbp),%eax
cmp    $0x31,%eax
je     112f <main+0xf>
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),%r12
lea    0xb(%rsp),%rbp
lea    0x14(%rsp),%r13
lea    0xee4(%rip),%r14
lea    0xea4(%rip),%r15
jmp    11a2 <main+0x72>
lea    0xf30(%rip),%rdi
call   1030 <puts@plt>
movss  0x10(%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpb   $0x31,0xa(%rsp)
jne    129d <main+0x16d>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%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     1288 <main+0x158>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3f(%rip),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xb(%rsp),%eax
movss  0x14(%rsp),%xmm0
cmp    $0x2f,%eax
jne    1220 <main+0xf0>
ucomiss 0xde4(%rip),%xmm0
jne    1220 <main+0xf0>
jnp    1291 <main+0x161>
add    $0xffffffdb,%eax
cmp    $0xa,%eax
ja     1162 <main+0x32>
movslq (%r15,%rax,4),%rax
add    %r15,%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    0xe2f(%rip),%rdi
jmp    1298 <main+0x168>
lea    0xe0e(%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 = [46 x i8] c"Escreva o numero na seguinte forma \09 N1 * N2\0A\00"
@.str.5 = [22 x i8] c"Digite aqui o numero\0A\00"
@.str.6 = [9 x i8] c"%f %c %f\00"
@.str.7 = [32 x i8] c"Operacao nao permitida, SAINDO\0A\00"
@.str.8 = [14 x i8] c"SINAL ERRADO\0A\00"
@.str.9 = [4 x i8] c"%f\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
br label %7
7: ; preds = %61, %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 %65
16: ; preds = %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), float* %5, i8* %3, float* %6)
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load float, float* %6
%25 = fcmp oeq float %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %66
28: ; preds = %23, %16
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
switch i32 %30, label %54 [
i32 43, label %31
i32 45, label %35
i32 42, label %39
i32 47, label %43
i32 37, label %47
]
31: ; preds = %28
%32 = load float, float* %5
%33 = load float, float* %6
%34 = fadd float %32, %33
store float %34, float* %2
br label %56
35: ; preds = %28
%36 = load float, float* %5
%37 = load float, float* %6
%38 = fsub float %36, %37
store float %38, float* %2
br label %56
39: ; preds = %28
%40 = load float, float* %5
%41 = load float, float* %6
%42 = fmul float %40, %41
store float %42, float* %2
br label %56
43: ; preds = %28
%44 = load float, float* %5
%45 = load float, float* %6
%46 = fdiv float %44, %45
store float %46, float* %2
br label %56
47: ; preds = %28
%48 = load float, float* %5
%49 = fptosi float %48 to i32
%50 = load float, float* %6
%51 = fptosi float %50 to i32
%52 = srem i32 %49, %51
%53 = sitofp i32 %52 to float
store float %53, float* %2
br label %56
54: ; preds = %28
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %56
56: ; preds = %54, %47, %43, %39, %35, %31
%57 = load float, float* %2
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double %58)
br label %60
60: ; preds = %56
br label %61
61: ; preds = %60
%62 = load i8, i8* %4
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 49
br i1 %64, label %7, label %65
65: ; preds = %61, %14
store i32 0, i32* %1
br label %66
66: ; preds = %65, %26
%67 = load i32, i32* %1
ret i32 %67
}

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