int main() {
  char letter;
  float num1, num2;
  printf("What operation do you want to do?\n\tA) Addition\n\tB) "
         "Subtraction\n\tC) Multiplication\n\tD) Division");
  scanf("%c", &letter);
  printf("Please enter a number: ");
  scanf("%f", &num1);
  printf("Please enter another number: ");
  scanf("%f", &num2);
  if (letter == 'A' || letter == 'a') {
    printf("The sum of %.2f and %.2f is %.2f.\n", num1, num2, num1 + num2);
  } else if (letter == "B" || letter == "b") {
    printf("The difference of %.2f and %.2f is %.2f.\n", num1, num2,
           num1 - num2);
  } else if (letter == "C" || letter == "c") {
    printf("The difference of %.2f and %.2f is %.2f.\n", num1, num2,
           num1 * num2);
  } else if (letter == "D" || letter == "d") {
    printf("The quotient of %.2f and %.2f is %.2f.\n", num1, num2, num1 / num2);
  } else {
    printf("Sorry, that's an invalid character.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1b(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
je     11a9 <main+0x89>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jne    11dc <main+0xbc>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
addss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xecb(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1310 <main+0x1f0>
movsbq -0x5(%rbp),%rax
lea    0xed6(%rip),%rcx
cmp    %rcx,%rax
je     1206 <main+0xe6>
movsbq -0x5(%rbp),%rax
lea    0xec3(%rip),%rcx
cmp    %rcx,%rax
jne    1239 <main+0x119>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
subss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe95(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    130b <main+0x1eb>
movsbq -0x5(%rbp),%rax
lea    0xea7(%rip),%rcx
cmp    %rcx,%rax
je     1263 <main+0x143>
movsbq -0x5(%rbp),%rax
lea    0xe06(%rip),%rcx
cmp    %rcx,%rax
jne    1296 <main+0x176>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe38(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1306 <main+0x1e6>
movsbq -0x5(%rbp),%rax
lea    0xe4c(%rip),%rcx
cmp    %rcx,%rax
je     12c0 <main+0x1a0>
movsbq -0x5(%rbp),%rax
lea    0xe39(%rip),%rcx
cmp    %rcx,%rax
jne    12f3 <main+0x1d3>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
divss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe0b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1301 <main+0x1e1>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1306 <main+0x1e6>
jmp    130b <main+0x1eb>
jmp    1310 <main+0x1f0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf25(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf15(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf1f(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movsbq 0x7(%rsp),%rax
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x41,%cl
jne    11bf <main+0x9f>
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
addss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xee1(%rip),%rdi
jmp    1254 <main+0x134>
lea    0xef8(%rip),%rcx
cmp    %rcx,%rax
je     1217 <main+0xf7>
lea    0xeee(%rip),%rcx
cmp    %rcx,%rax
je     1217 <main+0xf7>
lea    0xf0e(%rip),%rcx
cmp    %rcx,%rax
je     1231 <main+0x111>
lea    0xe76(%rip),%rcx
cmp    %rcx,%rax
je     1231 <main+0x111>
lea    0xef8(%rip),%rcx
cmp    %rcx,%rax
je     1263 <main+0x143>
lea    0xeee(%rip),%rcx
cmp    %rcx,%rax
je     1263 <main+0x143>
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    125b <main+0x13b>
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
subss  %xmm3,%xmm2
jmp    1249 <main+0x129>
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
mulss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe6e(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
divss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe6c(%rip),%rdi
jmp    1254 <main+0x134>

LLVM IR (-O0):
@.str = [95 x i8] c"What operation do you want to do?\0A\09A) Addition\0A\09B) Subtraction\0A\09C) Multiplication\0A\09D) Division\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [24 x i8] c"Please enter a number: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [30 x i8] c"Please enter another number: \00"
@.str.5 = [35 x i8] c"The sum of %.2f and %.2f is %.2f.\0A\00"
@.str.6 = [2 x i8] c"B\00"
@.str.7 = [2 x i8] c"b\00"
@.str.8 = [42 x i8] c"The difference of %.2f and %.2f is %.2f.\0A\00"
@.str.9 = [2 x i8] c"C\00"
@.str.10 = [2 x i8] c"c\00"
@.str.11 = [2 x i8] c"D\00"
@.str.12 = [2 x i8] c"d\00"
@.str.13 = [40 x i8] c"The quotient of %.2f and %.2f is %.2f.\0A\00"
@.str.14 = [36 x i8] c"Sorry, that's an invalid character.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 65
br i1 %13, label %18, label %14
14: ; preds = %0
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 97
br i1 %17, label %18, label %28
18: ; preds = %14, %0
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = load float, float* %3
%24 = load float, float* %4
%25 = fadd float %23, %24
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), double %20, double %22, double %26)
br label %93
28: ; preds = %14
%29 = load i8, i8* %2
%30 = sext i8 %29 to i64
%31 = inttoptr i64 %30 to i8*
%32 = icmp eq i8* %31, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = load i8, i8* %2
%35 = sext i8 %34 to i64
%36 = inttoptr i64 %35 to i8*
%37 = icmp eq i8* %36, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
br i1 %37, label %38, label %48
38: ; preds = %33, %28
%39 = load float, float* %3
%40 = fpext float %39 to double
%41 = load float, float* %4
%42 = fpext float %41 to double
%43 = load float, float* %3
%44 = load float, float* %4
%45 = fsub float %43, %44
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), double %40, double %42, double %46)
br label %92
48: ; preds = %33
%49 = load i8, i8* %2
%50 = sext i8 %49 to i64
%51 = inttoptr i64 %50 to i8*
%52 = icmp eq i8* %51, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = load i8, i8* %2
%55 = sext i8 %54 to i64
%56 = inttoptr i64 %55 to i8*
%57 = icmp eq i8* %56, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0)
br i1 %57, label %58, label %68
58: ; preds = %53, %48
%59 = load float, float* %3
%60 = fpext float %59 to double
%61 = load float, float* %4
%62 = fpext float %61 to double
%63 = load float, float* %3
%64 = load float, float* %4
%65 = fmul float %63, %64
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), double %60, double %62, double %66)
br label %91
68: ; preds = %53
%69 = load i8, i8* %2
%70 = sext i8 %69 to i64
%71 = inttoptr i64 %70 to i8*
%72 = icmp eq i8* %71, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
br i1 %72, label %78, label %73
73: ; preds = %68
%74 = load i8, i8* %2
%75 = sext i8 %74 to i64
%76 = inttoptr i64 %75 to i8*
%77 = icmp eq i8* %76, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0)
br i1 %77, label %78, label %88
78: ; preds = %73, %68
%79 = load float, float* %3
%80 = fpext float %79 to double
%81 = load float, float* %4
%82 = fpext float %81 to double
%83 = load float, float* %3
%84 = load float, float* %4
%85 = fdiv float %83, %84
%86 = fpext float %85 to double
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), double %80, double %82, double %86)
br label %90
88: ; preds = %73
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.14, i64 0, i64 0))
br label %90
90: ; preds = %88, %78
br label %91
91: ; preds = %90, %58
br label %92
92: ; preds = %91, %38
br label %93
93: ; preds = %92, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [95 x i8] c"What operation do you want to do?\0A\09A) Addition\0A\09B) Subtraction\0A\09C) Multiplication\0A\09D) Division\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [24 x i8] c"Please enter a number: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [30 x i8] c"Please enter another number: \00"
@.str.5 = [35 x i8] c"The sum of %.2f and %.2f is %.2f.\0A\00"
@.str.6 = [2 x i8] c"B\00"
@.str.7 = [2 x i8] c"b\00"
@.str.8 = [42 x i8] c"The difference of %.2f and %.2f is %.2f.\0A\00"
@.str.9 = [2 x i8] c"C\00"
@.str.10 = [2 x i8] c"c\00"
@.str.11 = [2 x i8] c"D\00"
@.str.12 = [2 x i8] c"d\00"
@.str.13 = [40 x i8] c"The quotient of %.2f and %.2f is %.2f.\0A\00"
@.str.14 = [36 x i8] c"Sorry, that's an invalid character.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %2 to i8*
%5 = bitcast float* %3 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%12 = load i8, i8* %1
%13 = and i8 %12, -33
%14 = icmp eq i8 %13, 65
br i1 %14, label %15, label %23
15: ; preds = %0
%16 = load float, float* %2
%17 = fpext float %16 to double
%18 = load float, float* %3
%19 = fpext float %18 to double
%20 = fadd float %16, %18
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), double %17, double %19, double %21)
br label %63
23: ; preds = %0
%24 = sext i8 %12 to i64
%25 = inttoptr i64 %24 to i8*
%26 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%27 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%28 = or i1 %26, %27
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = load float, float* %2
%31 = fpext float %30 to double
%32 = load float, float* %3
%33 = fpext float %32 to double
%34 = fsub float %30, %32
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), double %31, double %33, double %35)
br label %63
37: ; preds = %23
%38 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%39 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0)
%40 = or i1 %38, %39
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = load float, float* %2
%43 = fpext float %42 to double
%44 = load float, float* %3
%45 = fpext float %44 to double
%46 = fmul float %42, %44
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), double %43, double %45, double %47)
br label %63
49: ; preds = %37
%50 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
%51 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0)
%52 = or i1 %50, %51
br i1 %52, label %53, label %61
53: ; preds = %49
%54 = load float, float* %2
%55 = fpext float %54 to double
%56 = load float, float* %3
%57 = fpext float %56 to double
%58 = fdiv float %54, %56
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0), double %55, double %57, double %59)
br label %63
61: ; preds = %49
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.14, i64 0, i64 0))
br label %63
63: ; preds = %29, %53, %61, %41, %15
ret i32 0
}