#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 *, float, ...);
int main(int argc, char *argv[]) {
  float a = atof(argv[1]);
  char op = argv[2][0];
  float b = atof(argv[3]);
  float 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    $0x30,%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>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x1c(%rbp)
movsbl -0x15(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     11e1 <main+0xc1>
mov    -0x28(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x14(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1203 <main+0xe3>
movss  -0x14(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1203 <main+0xe3>
movss  -0x14(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1203 <main+0xe3>
movss  -0x14(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    1203 <main+0xe3>
movsbl -0x15(%rbp),%eax
cvtsi2ss %eax,%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1233 <main+0x113>
movss  -0x14(%rbp),%xmm0
movsbl -0x15(%rbp),%esi
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x20(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe09(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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>
movss  %xmm0,0xc(%rsp)
mov    0x10(%rbx),%rax
mov    0x18(%rbx),%rdi
movsbl (%rax),%ebx
call   1030 <atof@plt>
lea    -0x2a(%rbx),%eax
cmp    $0x5,%eax
ja     117d <main+0x5d>
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm2
mulss  %xmm0,%xmm2
jmp    11b5 <main+0x95>
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm2
addss  %xmm0,%xmm2
jmp    11b5 <main+0x95>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    11d2 <main+0xb2>
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm2
subss  %xmm0,%xmm2
jmp    11b5 <main+0x95>
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm2
divss  %xmm0,%xmm2
cvtss2sd %xmm0,%xmm1
cvtss2sd %xmm2,%xmm2
lea    0xe6a(%rip),%rdi
movaps %xmm3,%xmm0
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 float
%7 = alloca i8
%8 = alloca float
%9 = alloca float
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 float @atof(i8* %12)
store float %13, float* %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 float @atof(i8* %21)
store float %22, float* %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 float, float* %6
%27 = load float, float* %8
%28 = fadd float %26, %27
store float %28, float* %9
br label %45
29: ; preds = %2
%30 = load float, float* %6
%31 = load float, float* %8
%32 = fsub float %30, %31
store float %32, float* %9
br label %45
33: ; preds = %2
%34 = load float, float* %6
%35 = load float, float* %8
%36 = fmul float %34, %35
store float %36, float* %9
br label %45
37: ; preds = %2
%38 = load float, float* %6
%39 = load float, float* %8
%40 = fdiv float %38, %39
store float %40, float* %9
br label %45
41: ; preds = %2
%42 = load i8, i8* %7
%43 = sitofp i8 %42 to float
%44 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), float %43)
store i32 1, i32* %3
br label %54
45: ; preds = %37, %33, %29, %25
%46 = load float, float* %6
%47 = load i8, i8* %7
%48 = sext i8 %47 to i32
%49 = load float, float* %8
%50 = fpext float %49 to double
%51 = load float, float* %9
%52 = fpext float %51 to double
%53 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), float %46, i32 %48, double %50, double %52)
store i32 0, i32* %3
br label %54
54: ; preds = %45, %41
%55 = load i32, i32* %3
ret i32 %55
}

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 float @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 float @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 float %5, %11
br label %24
15: ; preds = %2
%16 = fsub float %5, %11
br label %24
17: ; preds = %2
%18 = fmul float %5, %11
br label %24
19: ; preds = %2
%20 = fdiv float %5, %11
br label %24
21: ; preds = %2
%22 = sitofp i8 %8 to float
%23 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), float %22)
br label %29
24: ; preds = %19, %17, %15, %13
%25 = phi float [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ]
%26 = fpext float %11 to double
%27 = fpext float %25 to double
%28 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), float %5, i32 %12, double %26, double %27)
br label %29
29: ; preds = %24, %21
%30 = phi i32 [ 1, %21 ], [ 0, %24 ]
ret i32 %30
}