#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 atof(char *);
int /*<<< orphan*/ printf(char *, double, ...);
int main(int argc, char *argv[]) {
  double a = atof(argv[1]);
  char op = argv[2][0];
  double b = atof(argv[3]);
  double r;
  switch (op) {
  case '+':
    r = a + b;
    break;
  case '-':
    r = a - b;
    break;
  case '*':
    r = a * b;
    break;
  case '/':
    r = a / b;
    break;
  default:
    printf("Unknown operation %c\n", op);
    return 1;
  }
  printf("%f %c %f = %f\n", a, op, b, r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
movsbl -0x19(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x5,%eax
ja     11e1 <main+0xc1>
mov    -0x38(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1203 <main+0xe3>
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1203 <main+0xe3>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1203 <main+0xe3>
movsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1203 <main+0xe3>
movsbl -0x19(%rbp),%eax
cvtsi2sd %eax,%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122b <main+0x10b>
movsd  -0x18(%rbp),%xmm0
movsbl -0x19(%rbp),%esi
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
lea    0xe11(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rbx),%rax
mov    0x18(%rbx),%rdi
movsbl (%rax),%ebx
call   1030 <atof@plt>
lea    -0x2a(%rbx),%eax
cmp    $0x5,%eax
ja     1183 <main+0x63>
movapd %xmm0,%xmm1
lea    0xea6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
jmp    11bd <main+0x9d>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
jmp    11bd <main+0x9d>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
lea    0xe87(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    11cf <main+0xaf>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
jmp    11bd <main+0x9d>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xe6a(%rip),%rdi
mov    %ebx,%esi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Unknown operation %c\0A\00"
@.str.1 = [15 x i8] c"%f %c %f = %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i8
%8 = alloca double
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call double @atof(i8* %12)
store double %13, double* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
store i8 %18, i8* %7
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call double @atof(i8* %21)
store double %22, double* %8
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
switch i32 %24, label %41 [
i32 43, label %25
i32 45, label %29
i32 42, label %33
i32 47, label %37
]
25: ; preds = %2
%26 = load double, double* %6
%27 = load double, double* %8
%28 = fadd double %26, %27
store double %28, double* %9
br label %45
29: ; preds = %2
%30 = load double, double* %6
%31 = load double, double* %8
%32 = fsub double %30, %31
store double %32, double* %9
br label %45
33: ; preds = %2
%34 = load double, double* %6
%35 = load double, double* %8
%36 = fmul double %34, %35
store double %36, double* %9
br label %45
37: ; preds = %2
%38 = load double, double* %6
%39 = load double, double* %8
%40 = fdiv double %38, %39
store double %40, double* %9
br label %45
41: ; preds = %2
%42 = load i8, i8* %7
%43 = sitofp i8 %42 to double
%44 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %43)
store i32 1, i32* %3
br label %52
45: ; preds = %37, %33, %29, %25
%46 = load double, double* %6
%47 = load i8, i8* %7
%48 = sext i8 %47 to i32
%49 = load double, double* %8
%50 = load double, double* %9
%51 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %46, i32 %48, double %49, double %50)
store i32 0, i32* %3
br label %52
52: ; preds = %45, %41
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [22 x i8] c"Unknown operation %c\0A\00"
@.str.1 = [15 x i8] c"%f %c %f = %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call double @atof(i8* %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call double @atof(i8* %10)
%12 = sext i8 %8 to i32
switch i32 %12, label %21 [
i32 43, label %13
i32 45, label %15
i32 42, label %17
i32 47, label %19
]
13: ; preds = %2
%14 = fadd double %5, %11
br label %24
15: ; preds = %2
%16 = fsub double %5, %11
br label %24
17: ; preds = %2
%18 = fmul double %5, %11
br label %24
19: ; preds = %2
%20 = fdiv double %5, %11
br label %24
21: ; preds = %2
%22 = sitofp i8 %8 to double
%23 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %22)
br label %27
24: ; preds = %19, %17, %15, %13
%25 = phi double [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ]
%26 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %5, i32 %12, double %11, double %25)
br label %27
27: ; preds = %24, %21
%28 = phi i32 [ 1, %21 ], [ 0, %24 ]
ret i32 %28
}