#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 pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, char *, double *);
int main() {
  double a, b;
  char op;
  printf("Enter two numbers separated by an operator:\n");
  scanf(" %lf %c %lf%*c", &a, &op, &b);
  printf("%.2lf %c %.2lf = %.2lf\n", a, op, b,
         (double)(op == '+'   ? a + b
                  : op == '-' ? a - b
                  : op == '*' ? a * b
                  : op == '/' ? a / b
                  : op == '^' ? pow(a, b)
                  : op == 'r' ? pow(b, 1.0 / a)
                  : op == '%' ? (unsigned)a % (unsigned)b
                              : 0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsbl -0x19(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
jne    11a1 <main+0x71>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12c8 <main+0x198>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    11c2 <main+0x92>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12be <main+0x18e>
movsbl -0x19(%rbp),%eax
cmp    $0x2a,%eax
jne    11e3 <main+0xb3>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12b4 <main+0x184>
movsbl -0x19(%rbp),%eax
cmp    $0x2f,%eax
jne    1204 <main+0xd4>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12aa <main+0x17a>
movsbl -0x19(%rbp),%eax
cmp    $0x5e,%eax
jne    122a <main+0xfa>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x60(%rbp)
jmp    12a0 <main+0x170>
movsbl -0x19(%rbp),%eax
cmp    $0x72,%eax
jne    1258 <main+0x128>
movsd  -0x18(%rbp),%xmm0
movsd  0xdbc(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x68(%rbp)
jmp    1296 <main+0x166>
movsbl -0x19(%rbp),%eax
cmp    $0x25,%eax
jne    127d <main+0x14d>
cvttsd2si -0x10(%rbp),%rax
cvttsd2si -0x18(%rbp),%rcx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x6c(%rbp)
jmp    1287 <main+0x157>
xor    %eax,%eax
mov    %eax,-0x6c(%rbp)
jmp    1287 <main+0x157>
mov    -0x6c(%rbp),%eax
mov    %eax,%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
lea    0xd63(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xfcb(%rip),%rdi
call   1030 <puts@plt>
lea    0xf98(%rip),%rdi
lea    0x28(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0x20(%rsp),%rcx
call   1050 <scanf@plt>
movsd  0x28(%rsp),%xmm0
mov    0xf(%rsp),%al
movsbl %al,%ebx
xorpd  %xmm2,%xmm2
movsd  0x20(%rsp),%xmm3
lea    -0x25(%rbx),%ecx
cmp    $0x39,%cl
ja     11b6 <main+0x76>
movzbl %cl,%eax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cvttsd2si %xmm0,%rax
cvttsd2si %xmm3,%rcx
xor    %edx,%edx
div    %ecx
xorps  %xmm2,%xmm2
cvtsi2sd %rdx,%xmm2
jmp    1225 <main+0xe5>
cmp    $0x72,%al
jne    1225 <main+0xe5>
movsd  0xe3e(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
movapd %xmm3,%xmm0
jmp    120a <main+0xca>
movapd %xmm0,%xmm2
mulsd  %xmm3,%xmm2
jmp    1225 <main+0xe5>
movapd %xmm0,%xmm2
addsd  %xmm3,%xmm2
jmp    1225 <main+0xe5>
movapd %xmm0,%xmm2
subsd  %xmm3,%xmm2
jmp    1225 <main+0xe5>
movapd %xmm0,%xmm2
divsd  %xmm3,%xmm2
jmp    1225 <main+0xe5>
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
movapd %xmm3,%xmm1
movsd  %xmm3,0x18(%rsp)
call   1060 <pow@plt>
movsd  0x18(%rsp),%xmm3
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
lea    0xed3(%rip),%rdi
mov    %ebx,%esi
movapd %xmm3,%xmm1
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter two numbers separated by an operator:\0A\00"
@.str.1 = [15 x i8] c" %lf %c %lf%*c\00"
@.str.2 = [24 x i8] c"%.2lf %c %.2lf = %.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double* %2, i8* %4, double* %3)
%7 = load double, double* %2
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
%10 = load double, double* %3
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 43
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load double, double* %2
%16 = load double, double* %3
%17 = fadd double %15, %16
br label %83
18: ; preds = %0
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 45
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load double, double* %2
%24 = load double, double* %3
%25 = fsub double %23, %24
br label %81
26: ; preds = %18
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 42
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load double, double* %2
%32 = load double, double* %3
%33 = fmul double %31, %32
br label %79
34: ; preds = %26
%35 = load i8, i8* %4
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 47
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load double, double* %2
%40 = load double, double* %3
%41 = fdiv double %39, %40
br label %77
42: ; preds = %34
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 94
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load double, double* %2
%48 = load double, double* %3
%49 = call double @pow(double %47, double %48)
br label %75
50: ; preds = %42
%51 = load i8, i8* %4
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 114
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = load double, double* %3
%56 = load double, double* %2
%57 = fdiv double 1.000000e+00, %56
%58 = call double @pow(double %55, double %57)
br label %73
59: ; preds = %50
%60 = load i8, i8* %4
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 37
br i1 %62, label %63, label %69
63: ; preds = %59
%64 = load double, double* %2
%65 = fptoui double %64 to i32
%66 = load double, double* %3
%67 = fptoui double %66 to i32
%68 = urem i32 %65, %67
br label %70
69: ; preds = %59
br label %70
70: ; preds = %69, %63
%71 = phi i32 [ %68, %63 ], [ 0, %69 ]
%72 = uitofp i32 %71 to double
br label %73
73: ; preds = %70, %54
%74 = phi double [ %58, %54 ], [ %72, %70 ]
br label %75
75: ; preds = %73, %46
%76 = phi double [ %49, %46 ], [ %74, %73 ]
br label %77
77: ; preds = %75, %38
%78 = phi double [ %41, %38 ], [ %76, %75 ]
br label %79
79: ; preds = %77, %30
%80 = phi double [ %33, %30 ], [ %78, %77 ]
br label %81
81: ; preds = %79, %22
%82 = phi double [ %25, %22 ], [ %80, %79 ]
br label %83
83: ; preds = %81, %14
%84 = phi double [ %17, %14 ], [ %82, %81 ]
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %7, i32 %9, double %10, double %84)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c" %lf %c %lf%*c\00"
@.str.2 = [24 x i8] c"%.2lf %c %.2lf = %.2lf\0A\00"
@str = [44 x i8] c"Enter two numbers separated by an operator:\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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double* %1, i8* %3, double* %2)
%8 = load double, double* %1
%9 = load i8, i8* %3
%10 = load double, double* %2
switch i8 %9, label %29 [
i8 43, label %11
i8 45, label %13
i8 42, label %15
i8 47, label %17
i8 94, label %19
i8 114, label %21
i8 37, label %24
]
11: ; preds = %0
%12 = fadd double %8, %10
br label %29
13: ; preds = %0
%14 = fsub double %8, %10
br label %29
15: ; preds = %0
%16 = fmul double %8, %10
br label %29
17: ; preds = %0
%18 = fdiv double %8, %10
br label %29
19: ; preds = %0
%20 = call double @pow(double %8, double %10)
br label %29
21: ; preds = %0
%22 = fdiv double 1.000000e+00, %8
%23 = call double @pow(double %10, double %22)
br label %29
24: ; preds = %0
%25 = fptoui double %8 to i32
%26 = fptoui double %10 to i32
%27 = urem i32 %25, %26
%28 = uitofp i32 %27 to double
br label %29
29: ; preds = %24, %0, %13, %17, %21, %19, %15, %11
%30 = phi double [ %12, %11 ], [ %14, %13 ], [ %16, %15 ], [ %18, %17 ], [ %20, %19 ], [ %23, %21 ], [ %28, %24 ], [ 0.000000e+00, %0 ]
%31 = sext i8 %9 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %8, i32 %31, double %10, double %30)
ret i32 0
}