#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 *, float *, char *, float *, char *, float *);
int main(void) {
  float operand1;
  float operand2;
  float operand3;
  float value;
  char operator1;
  char operator2;
  printf("THIS PROGRAM DOES NOT FOLLOW ORDER OF OPERATIONS!\n");
  printf("Enter a 3 operand equation: ");
  scanf("%f %c %f %c %f", &operand1, &operator1, &operand2, &operator2,
        &operand3);
  value = operand1;
  switch (operator1) {
  case '*':
    value *= operand2;
    break;
  case '/':
    value /= operand2;
    break;
  case '+':
    value += operand2;
    break;
  case '-':
    value -= operand2;
    break;
  }
  switch (operator2) {
  case '*':
    value *= operand3;
    break;
  case '/':
    value /= operand3;
    break;
  case '+':
    value += operand3;
    break;
  case '-':
    value -= operand3;
    break;
  }
  printf("Value of your expression is: %f\n", value);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1030 <printf@plt>
mov    -0x21(%rbp),%al
lea    0xf19(%rip),%rdi
call   1030 <printf@plt>
lea    0xf2a(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x15(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x16(%rbp),%r8
lea    -0x10(%rbp),%r9
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movsbl -0x15(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     11f6 <main+0xd6>
mov    -0x20(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11f6 <main+0xd6>
movss  -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11f6 <main+0xd6>
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11f6 <main+0xd6>
movss  -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movsbl -0x16(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x5,%eax
ja     1273 <main+0x153>
mov    -0x30(%rbp),%rax
lea    0xe01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1273 <main+0x153>
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1273 <main+0x153>
movss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1273 <main+0x153>
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef8(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xb(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xa(%rsp),%r8
lea    0xc(%rsp),%r9
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
movsbl 0xb(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11b4 <main+0x84>
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mulss  0x10(%rsp),%xmm0
jmp    11b4 <main+0x84>
addss  0x10(%rsp),%xmm0
jmp    11b4 <main+0x84>
subss  0x10(%rsp),%xmm0
jmp    11b4 <main+0x84>
divss  0x10(%rsp),%xmm0
movsbl 0xa(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     11ef <main+0xbf>
lea    0xe50(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mulss  0xc(%rsp),%xmm0
jmp    11ef <main+0xbf>
addss  0xc(%rsp),%xmm0
jmp    11ef <main+0xbf>
subss  0xc(%rsp),%xmm0
jmp    11ef <main+0xbf>
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"THIS PROGRAM DOES NOT FOLLOW ORDER OF OPERATIONS!\0A\00"
@.str.1 = [29 x i8] c"Enter a 3 operand equation: \00"
@.str.2 = [15 x i8] c"%f %c %f %c %f\00"
@.str.3 = [33 x i8] c"Value of your expression is: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), float* %2, i8* %6, float* %3, i8* %7, float* %4)
%11 = load float, float* %2
store float %11, float* %5
%12 = load i8, i8* %6
%13 = sext i8 %12 to i32
switch i32 %13, label %30 [
i32 42, label %14
i32 47, label %18
i32 43, label %22
i32 45, label %26
]
14: ; preds = %0
%15 = load float, float* %3
%16 = load float, float* %5
%17 = fmul float %16, %15
store float %17, float* %5
br label %30
18: ; preds = %0
%19 = load float, float* %3
%20 = load float, float* %5
%21 = fdiv float %20, %19
store float %21, float* %5
br label %30
22: ; preds = %0
%23 = load float, float* %3
%24 = load float, float* %5
%25 = fadd float %24, %23
store float %25, float* %5
br label %30
26: ; preds = %0
%27 = load float, float* %3
%28 = load float, float* %5
%29 = fsub float %28, %27
store float %29, float* %5
br label %30
30: ; preds = %0, %26, %22, %18, %14
%31 = load i8, i8* %7
%32 = sext i8 %31 to i32
switch i32 %32, label %49 [
i32 42, label %33
i32 47, label %37
i32 43, label %41
i32 45, label %45
]
33: ; preds = %30
%34 = load float, float* %4
%35 = load float, float* %5
%36 = fmul float %35, %34
store float %36, float* %5
br label %49
37: ; preds = %30
%38 = load float, float* %4
%39 = load float, float* %5
%40 = fdiv float %39, %38
store float %40, float* %5
br label %49
41: ; preds = %30
%42 = load float, float* %4
%43 = load float, float* %5
%44 = fadd float %43, %42
store float %44, float* %5
br label %49
45: ; preds = %30
%46 = load float, float* %4
%47 = load float, float* %5
%48 = fsub float %47, %46
store float %48, float* %5
br label %49
49: ; preds = %30, %45, %41, %37, %33
%50 = load float, float* %5
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %51)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"Enter a 3 operand equation: \00"
@.str.2 = [15 x i8] c"%f %c %f %c %f\00"
@.str.3 = [33 x i8] c"Value of your expression is: %f\0A\00"
@str = [50 x i8] c"THIS PROGRAM DOES NOT FOLLOW ORDER OF OPERATIONS!\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca i8
%5 = alloca i8
%6 = bitcast float* %1 to i8*
%7 = bitcast float* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), float* %1, i8* %4, float* %2, i8* %5, float* %3)
%12 = load float, float* %1
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
switch i32 %14, label %27 [
i32 42, label %15
i32 47, label %18
i32 43, label %21
i32 45, label %24
]
15: ; preds = %0
%16 = load float, float* %2
%17 = fmul float %12, %16
br label %27
18: ; preds = %0
%19 = load float, float* %2
%20 = fdiv float %12, %19
br label %27
21: ; preds = %0
%22 = load float, float* %2
%23 = fadd float %12, %22
br label %27
24: ; preds = %0
%25 = load float, float* %2
%26 = fsub float %12, %25
br label %27
27: ; preds = %0, %24, %21, %18, %15
%28 = phi float [ %12, %0 ], [ %26, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ]
%29 = load i8, i8* %5
%30 = sext i8 %29 to i32
switch i32 %30, label %43 [
i32 42, label %31
i32 47, label %34
i32 43, label %37
i32 45, label %40
]
31: ; preds = %27
%32 = load float, float* %3
%33 = fmul float %28, %32
br label %43
34: ; preds = %27
%35 = load float, float* %3
%36 = fdiv float %28, %35
br label %43
37: ; preds = %27
%38 = load float, float* %3
%39 = fadd float %28, %38
br label %43
40: ; preds = %27
%41 = load float, float* %3
%42 = fsub float %28, %41
br label %43
43: ; preds = %27, %40, %37, %34, %31
%44 = phi float [ %28, %27 ], [ %42, %40 ], [ %39, %37 ], [ %36, %34 ], [ %33, %31 ]
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %45)
ret i32 0
}