#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main(void) {
  char c;
  float a, b, sum;
  printf("Enter '+','-','*','/','q':\n");
  while ((c = getchar()) != 'q') {
    printf("Enter First Number:");
    scanf("%10f", &a);
    printf("Enter Second Number:");
    scanf("%10f", &b);
    if (c == '+') {
      sum = a + b;
      printf("The total is: %10f\n", sum);
    } else if (c == '-') {
      sum = a - b;
      printf("The total is: %10f\n", sum);
    } else if (c == '*') {
      sum = a * b;
      printf("The total is: %10f\n", sum);
    } else if (c == '/') {
      while (b == 0) {
        printf(
            "\nUnable to divide by 0. Please enter new number to divide by:\n");
        scanf("%10f", &b);
      }
      sum = a / b;
      printf("The total is: %10f\n", sum);
    }
    printf("Enter '+','-','*','/','q':\n");
    c = getchar();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x71,%eax
je     12e5 <main+0x1b5>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x2b,%eax
jne    11d7 <main+0xa7>
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c8 <main+0x198>
movsbl -0x5(%rbp),%eax
cmp    $0x2d,%eax
jne    120f <main+0xdf>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c3 <main+0x193>
movsbl -0x5(%rbp),%eax
cmp    $0x2a,%eax
jne    1247 <main+0x117>
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12be <main+0x18e>
movsbl -0x5(%rbp),%eax
cmp    $0x2f,%eax
jne    12b9 <main+0x189>
jmp    1259 <main+0x129>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1293 <main+0x163>
jp     1293 <main+0x163>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdab(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1259 <main+0x129>
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd98(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12be <main+0x18e>
jmp    12c3 <main+0x193>
jmp    12c8 <main+0x198>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf08(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x71,%al
jne    1173 <main+0x33>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r15d
lea    0xeaf(%rip),%rbx
mov    %rsp,%r13
lea    0xed3(%rip),%rbp
lea    0xe72(%rip),%r12
lea    0xee0(%rip),%r14
jmp    11d9 <main+0x99>
nopw   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe91(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%r15d
cmp    $0x71,%al
je     1162 <main+0x22>
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
add    $0xd6,%r15b
cmp    $0x5,%r15b
ja     11bc <main+0x7c>
movzbl %r15b,%eax
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
movss  0x4(%rsp),%xmm0
mulss  (%rsp),%xmm0
jmp    11aa <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x4(%rsp),%xmm0
addss  (%rsp),%xmm0
jmp    11aa <main+0x6a>
movss  0x4(%rsp),%xmm0
subss  (%rsp),%xmm0
jmp    11aa <main+0x6a>
movss  (%rsp),%xmm1
xorps  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
ucomiss %xmm0,%xmm1
jne    11a0 <main+0x60>
jp     11a0 <main+0x60>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
movss  (%rsp),%xmm1
jmp    1270 <main+0x130>

LLVM IR (-O0):
@.str = [28 x i8] c"Enter '+','-','*','/','q':\0A\00"
@.str.1 = [20 x i8] c"Enter First Number:\00"
@.str.2 = [5 x i8] c"%10f\00"
@.str.3 = [21 x i8] c"Enter Second Number:\00"
@.str.4 = [20 x i8] c"The total is: %10f\0A\00"
@.str.5 = [63 x i8] c"\0AUnable to divide by 0. Please enter new number to divide by:\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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %69, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 113
br i1 %10, label %11, label %72
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %4)
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 43
br i1 %18, label %19, label %26
19: ; preds = %11
%20 = load float, float* %3
%21 = load float, float* %4
%22 = fadd float %20, %21
store float %22, float* %5
%23 = load float, float* %5
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %24)
br label %69
26: ; preds = %11
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 45
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load float, float* %3
%32 = load float, float* %4
%33 = fsub float %31, %32
store float %33, float* %5
%34 = load float, float* %5
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %35)
br label %68
37: ; preds = %26
%38 = load i8, i8* %2
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 42
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load float, float* %3
%43 = load float, float* %4
%44 = fmul float %42, %43
store float %44, float* %5
%45 = load float, float* %5
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %46)
br label %67
48: ; preds = %37
%49 = load i8, i8* %2
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 47
br i1 %51, label %52, label %66
52: ; preds = %48
br label %53
53: ; preds = %56, %52
%54 = load float, float* %4
%55 = fcmp oeq float %54, 0.000000e+00
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%58 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %4)
br label %53
59: ; preds = %53
%60 = load float, float* %3
%61 = load float, float* %4
%62 = fdiv float %60, %61
store float %62, float* %5
%63 = load float, float* %5
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %64)
br label %66
66: ; preds = %59, %48
br label %67
67: ; preds = %66, %41
br label %68
68: ; preds = %67, %30
br label %69
69: ; preds = %68, %19
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%71 = call signext i8 (...) @getchar()
store i8 %71, i8* %2
br label %7
72: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"Enter First Number:\00"
@.str.2 = [5 x i8] c"%10f\00"
@.str.3 = [21 x i8] c"Enter Second Number:\00"
@.str.4 = [20 x i8] c"The total is: %10f\0A\00"
@str.6 = [27 x i8] c"Enter '+','-','*','/','q':\00"
@str.7 = [62 x i8] c"\0AUnable to divide by 0. Please enter new number to divide by:\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
%6 = call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 113
br i1 %7, label %47, label %8
8: ; preds = %0, %42
%9 = phi i8 [ %45, %42 ], [ %6, %0 ]
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %2)
switch i8 %9, label %42 [
i8 43, label %17
i8 45, label %21
i8 42, label %25
i8 47, label %14
]
14: ; preds = %8
%15 = load float, float* %2
%16 = fcmp oeq float %15, 0.000000e+00
br i1 %16, label %29, label %34
17: ; preds = %8
%18 = load float, float* %1
%19 = load float, float* %2
%20 = fadd float %18, %19
br label %38
21: ; preds = %8
%22 = load float, float* %1
%23 = load float, float* %2
%24 = fsub float %22, %23
br label %38
25: ; preds = %8
%26 = load float, float* %1
%27 = load float, float* %2
%28 = fmul float %26, %27
br label %38
29: ; preds = %14, %29
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.7, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), float* %2)
%32 = load float, float* %2
%33 = fcmp oeq float %32, 0.000000e+00
br i1 %33, label %29, label %34
34: ; preds = %29, %14
%35 = phi float [ %15, %14 ], [ %32, %29 ]
%36 = load float, float* %1
%37 = fdiv float %36, %35
br label %38
38: ; preds = %17, %25, %34, %21
%39 = phi float [ %24, %21 ], [ %37, %34 ], [ %28, %25 ], [ %20, %17 ]
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %40)
br label %42
42: ; preds = %38, %8
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
%44 = call signext i8 (...) @getchar()
%45 = call signext i8 (...) @getchar()
%46 = icmp eq i8 %45, 113
br i1 %46, label %47, label %8
47: ; preds = %42, %0
ret i32 0
}