#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double a, b;
  if (argc < 3) {
    printf("Usage: %s <num one> + <num two>\n", argv[0]);
    exit(42);
  }
  a = atof(argv[1]);
  b = atof(argv[3]);
  switch (argv[2][0]) {
  case '+':
    printf("%f\n", a + b);
    break;
  case '/':
    printf("%f\n", a / b);
    break;
  default:
    printf("Undefined operation\n");
    exit(42);
    break;
  }
  exit(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   $0x3,-0x8(%rbp)
jge    116f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2a,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2b,%eax
je     11c0 <main+0x90>
jmp    11af <main+0x7f>
mov    -0x24(%rbp),%eax
sub    $0x2f,%eax
je     11dd <main+0xad>
jmp    11fa <main+0xca>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1212 <main+0xe2>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
lea    0xe33(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1212 <main+0xe2>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2a,%edi
call   1050 <exit@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1168 <main+0x28>
mov    (%rbx),%rsi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2a,%edi
call   1060 <exit@plt>
mov    0x8(%rbx),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1040 <atof@plt>
mov    0x10(%rbx),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     119d <main+0x5d>
cmp    $0x2b,%eax
jne    11c0 <main+0x80>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
jmp    11a7 <main+0x67>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xe6f(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2a,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Usage: %s <num one> + <num two>\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
@.str.2 = [21 x i8] c"Undefined operation\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 42)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call double @atof(i8* %19)
store double %20, double* %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call double @atof(i8* %23)
store double %24, double* %7
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %41 [
i32 43, label %31
i32 47, label %36
]
31: ; preds = %16
%32 = load double, double* %6
%33 = load double, double* %7
%34 = fadd double %32, %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %34)
br label %44
36: ; preds = %16
%37 = load double, double* %6
%38 = load double, double* %7
%39 = fdiv double %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %39)
br label %44
41: ; preds = %16
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @exit(i32 42)
unreachable
44: ; preds = %36, %31
%45 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [33 x i8] c"Usage: %s <num one> + <num two>\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
@str = [20 x i8] c"Undefined operation\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 42)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call double @atof(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call double @atof(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %23 [
i32 43, label %19
i32 47, label %21
]
19: ; preds = %8
%20 = fadd double %11, %14
br label %26
21: ; preds = %8
%22 = fdiv double %11, %14
br label %26
23: ; preds = %8
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%25 = tail call i32 @exit(i32 42)
unreachable
26: ; preds = %21, %19
%27 = phi double [ %22, %21 ], [ %20, %19 ]
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = tail call i32 @exit(i32 0)
unreachable
}