#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 */
float atof(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  float num1, num2, resultado;
  char op;
  if (argc == 4) {
    op = argv[1][0];
    num1 = atof(argv[2]);
    num2 = atof(argv[3]);
    while (op != 'x') {
      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);
      op = 'x';
    }
  } else
    printf("\n\nFormato de entrada incorreto!\n\nTente novamente, por exemplo: "
           "%s / 10 5\n\n",
           argv[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    1275 <main+0x155>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x1d(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x18(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x78,%eax
je     1270 <main+0x150>
movsbl -0x1d(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     123e <main+0x11e>
mov    -0x28(%rbp),%rax
lea    0xe61(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    124c <main+0x12c>
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    124c <main+0x12c>
movss  -0x14(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    124c <main+0x12c>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1200 <main+0xe0>
jp     1200 <main+0xe0>
jmp    1217 <main+0xf7>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    122a <main+0x10a>
jp     122a <main+0x10a>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1239 <main+0x119>
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    124c <main+0x12c>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x1d(%rbp),%esi
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movb   $0x78,-0x1d(%rbp)
jmp    1171 <main+0x51>
jmp    128a <main+0x16a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
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
mov    %rsi,%r14
cmp    $0x4,%edi
jne    125f <main+0x12f>
mov    0x8(%r14),%rax
mov    0x10(%r14),%rdi
movsbl (%rax),%ebx
call   1040 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    0x18(%r14),%rdi
call   1040 <atof@plt>
xorps  %xmm1,%xmm1
movss  0x8(%rsp),%xmm2
ucomiss %xmm1,%xmm2
setnp  %al
sete   %cl
and    %al,%cl
ucomiss %xmm1,%xmm0
setnp  %al
sete   %r13b
and    %al,%r13b
or     %cl,%r13b
movaps %xmm2,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
movaps %xmm2,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
movaps %xmm2,%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
addss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
lea    0xee6(%rip),%r14
lea    0xe4c(%rip),%r15
lea    0xe2d(%rip),%rbp
lea    0xeb8(%rip),%r12
jmp    1214 <main+0xe4>
movss  0x10(%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm1,0x4(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x78,%ebx
movss  0x4(%rsp),%xmm0
lea    -0x2a(%rbx),%eax
cmp    $0x5,%eax
ja     1244 <main+0x114>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
movss  0x8(%rsp),%xmm1
jmp    *%rax
movss  0xc(%rsp),%xmm1
jmp    11f0 <main+0xc0>
movss  0x14(%rsp),%xmm1
test   %r13b,%r13b
je     11f0 <main+0xc0>
mov    %r12,%rdi
jmp    124c <main+0x11c>
cmp    $0x78,%ebx
je     1270 <main+0x140>
mov    %r14,%rdi
movss  %xmm0,0x4(%rsp)
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm1
jmp    11f0 <main+0xc0>
mov    (%r14),%rsi
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0A\0AZero nao eh divisivel\0A\0A\00"
@.str.1 = [19 x i8] c"\0A\0AOpcao invalida\0A\0A\00"
@.str.2 = [47 x i8] c"O resultado da opera\C3\A7\C3\A3o %c eh igual a %.2f\0A\0A\00"
@.str.3 = [75 x i8] c"\0A\0AFormato de entrada incorreto!\0A\0ATente novamente, por exemplo: %s / 10 5\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %67
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
store i8 %17, i8* %9
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call float @atof(i8* %20)
store float %21, float* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call float @atof(i8* %24)
store float %25, float* %7
br label %26
26: ; preds = %60, %12
%27 = load i8, i8* %9
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 120
br i1 %29, label %30, label %66
30: ; preds = %26
%31 = load i8, i8* %9
%32 = sext i8 %31 to i32
switch i32 %32, label %58 [
i32 43, label %33
i32 45, label %37
i32 42, label %41
i32 47, label %45
]
33: ; preds = %30
%34 = load float, float* %6
%35 = load float, float* %7
%36 = fadd float %34, %35
store float %36, float* %8
br label %60
37: ; preds = %30
%38 = load float, float* %6
%39 = load float, float* %7
%40 = fsub float %38, %39
store float %40, float* %8
br label %60
41: ; preds = %30
%42 = load float, float* %6
%43 = load float, float* %7
%44 = fmul float %42, %43
store float %44, float* %8
br label %60
45: ; preds = %30
%46 = load float, float* %6
%47 = fcmp oeq float %46, 0.000000e+00
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load float, float* %7
%50 = fcmp oeq float %49, 0.000000e+00
br i1 %50, label %51, label %53
51: ; preds = %48, %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %57
53: ; preds = %48
%54 = load float, float* %6
%55 = load float, float* %7
%56 = fdiv float %54, %55
store float %56, float* %8
br label %57
57: ; preds = %53, %51
br label %60
58: ; preds = %30
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %58, %57, %41, %37, %33
%61 = load i8, i8* %9
%62 = sext i8 %61 to i32
%63 = load float, float* %8
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %62, double %64)
store i8 120, i8* %9
br label %26
66: ; preds = %26
br label %72
67: ; preds = %2
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 0
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %67, %66
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@.str.2 = [47 x i8] c"O resultado da opera\C3\A7\C3\A3o %c eh igual a %.2f\0A\0A\00"
@.str.3 = [75 x i8] c"\0A\0AFormato de entrada incorreto!\0A\0ATente novamente, por exemplo: %s / 10 5\0A\0A\00"
@str = [25 x i8] c"\0A\0AZero nao eh divisivel\0A\00"
@str.4 = [18 x i8] c"\0A\0AOpcao invalida\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %36
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call float @atof(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call float @atof(i8* %12)
%14 = sext i8 %7 to i32
%15 = fcmp oeq float %10, 0.000000e+00
%16 = fcmp oeq float %13, 0.000000e+00
%17 = select i1 %15, i1 true, i1 %16
%18 = fdiv float %10, %13
%19 = fmul float %10, %13
%20 = fsub float %10, %13
%21 = fadd float %10, %13
br label %22
22: ; preds = %32, %4
%23 = phi float [ undef, %4 ], [ %33, %32 ]
%24 = phi i32 [ %14, %4 ], [ 120, %32 ]
switch i32 %24, label %30 [
i32 120, label %39
i32 43, label %32
i32 45, label %25
i32 42, label %26
i32 47, label %27
]
25: ; preds = %22
br label %32
26: ; preds = %22
br label %32
27: ; preds = %22
br i1 %17, label %28, label %32
28: ; preds = %27
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %32
30: ; preds = %22
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %32
32: ; preds = %27, %22, %28, %30, %26, %25
%33 = phi float [ %23, %30 ], [ %23, %28 ], [ %19, %26 ], [ %20, %25 ], [ %21, %22 ], [ %18, %27 ]
%34 = fpext float %33 to double
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %24, double %34)
br label %22
36: ; preds = %2
%37 = load i8*, i8** %1
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %22, %36
ret i32 0
}