#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 */
double divisao(double, double);
double multiplicacao(double, double);
int /*<<< orphan*/ printf(char *, double, char, double, double);
int /*<<< orphan*/ scanf(char *, double *, char *, double *);
double soma(double, double);
double subtracao(double, double);
int main() {
  double a, b, r;
  char operacao;
  scanf("%lf %c %lf", &a, &operacao, &b);
  switch (operacao) {
  case '+':
    r = soma(a, b);
    break;
  case '-':
    r = subtracao(a, b);
    break;
  case '*':
    r = multiplicacao(a, b);
    break;
  case '/':
    r = divisao(a, b);
    break;
  }
  printf("%g %c %g = %g\n", a, operacao, b, r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x21(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1080 <scanf@plt>
movsbl -0x21(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x5,%eax
ja     1210 <main+0xb0>
mov    -0x30(%rbp),%rax
lea    0xe58(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1060 <soma@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1210 <main+0xb0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <subtracao@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1210 <main+0xb0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1070 <multiplicacao@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1210 <main+0xb0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <divisao@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x21(%rbp),%al
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xdfa(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xead(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x7(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1080 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffd6,%eax
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1070 <multiplicacao@plt>
jmp    11e1 <main+0x81>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <divisao@plt>
jmp    11e1 <main+0x81>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1060 <soma@plt>
jmp    11e1 <main+0x81>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1050 <subtracao@plt>
movaps %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
movsbl 0x7(%rsp),%esi
movsd  0x8(%rsp),%xmm1
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%lf %c %lf\00"
@.str.1 = [15 x i8] c"%g %c %g = %g\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i8
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double* %2, i8* %5, double* %3)
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
switch i32 %8, label %25 [
i32 43, label %9
i32 45, label %13
i32 42, label %17
i32 47, label %21
]
9: ; preds = %0
%10 = load double, double* %2
%11 = load double, double* %3
%12 = call double @soma(double %10, double %11)
store double %12, double* %4
br label %25
13: ; preds = %0
%14 = load double, double* %2
%15 = load double, double* %3
%16 = call double @subtracao(double %14, double %15)
store double %16, double* %4
br label %25
17: ; preds = %0
%18 = load double, double* %2
%19 = load double, double* %3
%20 = call double @multiplicacao(double %18, double %19)
store double %20, double* %4
br label %25
21: ; preds = %0
%22 = load double, double* %2
%23 = load double, double* %3
%24 = call double @divisao(double %22, double %23)
store double %24, double* %4
br label %25
25: ; preds = %0, %21, %17, %13, %9
%26 = load double, double* %2
%27 = load i8, i8* %5
%28 = load double, double* %3
%29 = load double, double* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %26, i8 signext %27, double %28, double %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%lf %c %lf\00"
@.str.1 = [15 x i8] c"%g %c %g = %g\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i8
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double* %1, i8* %3, double* %2)
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
switch i32 %8, label %25 [
i32 43, label %9
i32 45, label %13
i32 42, label %17
i32 47, label %21
]
9: ; preds = %0
%10 = load double, double* %1
%11 = load double, double* %2
%12 = call double @soma(double %10, double %11)
br label %26
13: ; preds = %0
%14 = load double, double* %1
%15 = load double, double* %2
%16 = call double @subtracao(double %14, double %15)
br label %26
17: ; preds = %0
%18 = load double, double* %1
%19 = load double, double* %2
%20 = call double @multiplicacao(double %18, double %19)
br label %26
21: ; preds = %0
%22 = load double, double* %1
%23 = load double, double* %2
%24 = call double @divisao(double %22, double %23)
br label %26
25: ; preds = %0
unreachable
26: ; preds = %21, %17, %13, %9
%27 = phi double [ %24, %21 ], [ %20, %17 ], [ %16, %13 ], [ %12, %9 ]
%28 = load double, double* %1
%29 = load i8, i8* %3
%30 = load double, double* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %28, i8 signext %29, double %30, double %27)
ret i32 0
}