#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char choice;
  float a, b;
  float answer;
  printf("===============\n");
  printf("  Enter Choice\n");
  printf("===============\n");
  printf("1. +\n");
  printf("1. -\n");
  printf("1. *\n");
  printf("1. /\n");
  printf("===============\n");
  printf("Choice: ");
  scanf("%c", &choice);
  printf("Enter the 2 numbers: ");
  scanf("%f %f", &a, &b);
  switch (choice) {
  case '+':
    answer = a + b;
    printf("%0.2f\n", answer);
    break;
  case '-':
    answer = a - b;
    printf("%0.2f\n", answer);
    break;
  case '*':
    answer = a * b;
    printf("%0.2f\n", answer);
    break;
  case '/':
    if (b == 0)
      printf("Infinity.\n");
    else {
      answer = a / b;
      printf("%0.2f\n", answer);
    }
    break;
  default:
    printf("Invalid choice.\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    %rdi,-0x30(%rbp)
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x21(%rbp),%al
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe9a(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x21(%rbp),%al
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xe91(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     12ef <main+0x1cf>
mov    -0x20(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12fd <main+0x1dd>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe16(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12fd <main+0x1dd>
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdeb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12fd <main+0x1dd>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12c4 <main+0x1a4>
jp     12c4 <main+0x1a4>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ea <main+0x1ca>
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd96(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12fd <main+0x1dd>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf2e(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     1210 <main+0xe0>
lea    0xe15(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
jmp    1225 <main+0xf5>
movss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
jmp    1225 <main+0xf5>
lea    0xe6d(%rip),%rdi
jmp    1250 <main+0x120>
movss  0xc(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe10(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1255 <main+0x125>
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    125d <main+0x12d>
jp     125d <main+0x12d>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
jmp    1229 <main+0xf9>

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

LLVM IR (-O2):
@.str.6 = [9 x i8] c"Choice: \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [22 x i8] c"Enter the 2 numbers: \00"
@.str.9 = [6 x i8] c"%f %f\00"
@.str.10 = [7 x i8] c"%0.2f\0A\00"
@str.13 = [15 x i8] c" Enter Choice\00"
@str.15 = [5 x i8] c"1. +\00"
@str.16 = [5 x i8] c"1. -\00"
@str.17 = [5 x i8] c"1. *\00"
@str.18 = [5 x i8] c"1. /\00"
@str.19 = [16 x i8] c"===============\00"
@str.20 = [10 x i8] c"Infinity.\00"
@str.21 = [16 x i8] c"Invalid choice.\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.19, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.19, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.15, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.16, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.17, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.18, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.19, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), float* %2, float* %3)
%18 = load i8, i8* %1
%19 = sext i8 %18 to i32
switch i32 %19, label %48 [
i32 43, label %20
i32 45, label %26
i32 42, label %32
i32 47, label %38
]
20: ; preds = %0
%21 = load float, float* %2
%22 = load float, float* %3
%23 = fadd float %21, %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), double %24)
br label %50
26: ; preds = %0
%27 = load float, float* %2
%28 = load float, float* %3
%29 = fsub float %27, %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), double %30)
br label %50
32: ; preds = %0
%33 = load float, float* %2
%34 = load float, float* %3
%35 = fmul float %33, %34
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), double %36)
br label %50
38: ; preds = %0
%39 = load float, float* %3
%40 = fcmp oeq float %39, 0.000000e+00
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.20, i64 0, i64 0))
br label %50
43: ; preds = %38
%44 = load float, float* %2
%45 = fdiv float %44, %39
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), double %46)
br label %50
48: ; preds = %0
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.21, i64 0, i64 0))
br label %50
50: ; preds = %41, %43, %48, %32, %26, %20
ret i32 0
}