#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 *);
int main() {
  float commission, value;
  while (1) {
    printf("Enter value of trade: ");
    scanf("%f", &value);
    if (value == 0)
      break;
    if (value < 2500.00f)
      commission = 30.00f + .017f * value;
    else if (value < 6250.00f)
      commission = 56.00f + .0066f * value;
    else if (value < 20000.00f)
      commission = 76.00f + .0034f * value;
    else if (value < 50000.00f)
      commission = 100.00f + .0022f * value;
    else if (value < 500000.00f)
      commission = 155.00f + .0011f * value;
    else
      commission = 255.00f + .0009f * value;
    if (commission < 39.00f)
      commission = 39.00f;
    printf("Commission: $%.2f\n\n", commission);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1169 <main+0x49>
jp     1169 <main+0x49>
jmp    12f7 <main+0x1d7>
movss  0xe8f(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11a2 <main+0x82>
movss  -0xc(%rbp),%xmm0
movss  0xeb4(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xeac(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12bc <main+0x19c>
movss  0xe5a(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11db <main+0xbb>
movss  -0xc(%rbp),%xmm0
movss  0xe73(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe6b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12b7 <main+0x197>
movss  0xe25(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1214 <main+0xf4>
movss  -0xc(%rbp),%xmm0
movss  0xe32(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe2a(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12b2 <main+0x192>
movss  0xdf0(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    124d <main+0x12d>
movss  -0xc(%rbp),%xmm0
movss  0xdf1(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xde9(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12ad <main+0x18d>
movss  0xdbb(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1286 <main+0x166>
movss  -0xc(%rbp),%xmm0
movss  0xdb0(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xda8(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12a8 <main+0x188>
movss  -0xc(%rbp),%xmm0
movss  0xd81(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd79(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12ad <main+0x18d>
jmp    12b2 <main+0x192>
jmp    12b7 <main+0x197>
jmp    12bc <main+0x19c>
movss  0xd80(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    12db <main+0x1bb>
movss  0xd6e(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd77(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xf1d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf26(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1165 <main+0x45>
jp     1165 <main+0x45>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xefa(%rip),%r14
lea    0xed9(%rip),%r15
lea    0xee9(%rip),%r12
lea    0x4(%rsp),%rbx
jmp    11e7 <main+0xc7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mulss  0xea4(%rip),%xmm0
addss  0xea0(%rip),%xmm0
movss  0xe9c(%rip),%xmm1
maxss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0xe69(%rip),%xmm0
jne    11e7 <main+0xc7>
jnp    1157 <main+0x37>
movss  0xe11(%rip),%xmm1
ucomiss %xmm0,%xmm1
ja     1190 <main+0x70>
movss  0xe08(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1220 <main+0x100>
mulss  0xe2b(%rip),%xmm0
addss  0xe27(%rip),%xmm0
jmp    11a0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0xde0(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1242 <main+0x122>
mulss  0xdf7(%rip),%xmm0
addss  0xdf3(%rip),%xmm0
jmp    11a0 <main+0x80>
movss  0xdc2(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1264 <main+0x144>
mulss  0xdcd(%rip),%xmm0
addss  0xdc9(%rip),%xmm0
jmp    11a0 <main+0x80>
movss  0xda4(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1286 <main+0x166>
mulss  0xda3(%rip),%xmm0
addss  0xd9f(%rip),%xmm0
jmp    11a0 <main+0x80>
mulss  0xd86(%rip),%xmm0
addss  0xd82(%rip),%xmm0
jmp    11a0 <main+0x80>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter value of trade: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [20 x i8] c"Commission: $%.2f\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
br label %4
4: ; preds = %0, %51
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%7 = load float, float* %3
%8 = fcmp oeq float %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %4
br label %55
10: ; preds = %4
%11 = load float, float* %3
%12 = fcmp olt float %11, 2.500000e+03
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load float, float* %3
%15 = call float @llvm.fmuladd.f32(float 0x3F916872C0000000, float %14, float 3.000000e+01)
store float %15, float* %2
br label %47
16: ; preds = %10
%17 = load float, float* %3
%18 = fcmp olt float %17, 6.250000e+03
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load float, float* %3
%21 = call float @llvm.fmuladd.f32(float 0x3F7B089A00000000, float %20, float 5.600000e+01)
store float %21, float* %2
br label %46
22: ; preds = %16
%23 = load float, float* %3
%24 = fcmp olt float %23, 2.000000e+04
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load float, float* %3
%27 = call float @llvm.fmuladd.f32(float 0x3F6BDA5120000000, float %26, float 7.600000e+01)
store float %27, float* %2
br label %45
28: ; preds = %22
%29 = load float, float* %3
%30 = fcmp olt float %29, 5.000000e+04
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load float, float* %3
%33 = call float @llvm.fmuladd.f32(float 0x3F6205BC00000000, float %32, float 1.000000e+02)
store float %33, float* %2
br label %44
34: ; preds = %28
%35 = load float, float* %3
%36 = fcmp olt float %35, 5.000000e+05
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load float, float* %3
%39 = call float @llvm.fmuladd.f32(float 0x3F5205BC00000000, float %38, float 1.550000e+02)
store float %39, float* %2
br label %43
40: ; preds = %34
%41 = load float, float* %3
%42 = call float @llvm.fmuladd.f32(float 0x3F4D7DBF40000000, float %41, float 2.550000e+02)
store float %42, float* %2
br label %43
43: ; preds = %40, %37
br label %44
44: ; preds = %43, %31
br label %45
45: ; preds = %44, %25
br label %46
46: ; preds = %45, %19
br label %47
47: ; preds = %46, %13
%48 = load float, float* %2
%49 = fcmp olt float %48, 3.900000e+01
br i1 %49, label %50, label %51
50: ; preds = %47
store float 3.900000e+01, float* %2
br label %51
51: ; preds = %50, %47
%52 = load float, float* %2
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %53)
br label %4
55: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter value of trade: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [20 x i8] c"Commission: $%.2f\0A\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp oeq float %5, 0.000000e+00
br i1 %6, label %40, label %7
7: ; preds = %0, %30
%8 = phi float [ %38, %30 ], [ %5, %0 ]
%9 = fcmp olt float %8, 2.500000e+03
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call float @llvm.fmuladd.f32(float %8, float 0x3F916872C0000000, float 3.000000e+01)
br label %30
12: ; preds = %7
%13 = fcmp olt float %8, 6.250000e+03
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = call float @llvm.fmuladd.f32(float %8, float 0x3F7B089A00000000, float 5.600000e+01)
br label %30
16: ; preds = %12
%17 = fcmp olt float %8, 2.000000e+04
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = call float @llvm.fmuladd.f32(float %8, float 0x3F6BDA5120000000, float 7.600000e+01)
br label %30
20: ; preds = %16
%21 = fcmp olt float %8, 5.000000e+04
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = call float @llvm.fmuladd.f32(float %8, float 0x3F6205BC00000000, float 1.000000e+02)
br label %30
24: ; preds = %20
%25 = fcmp olt float %8, 5.000000e+05
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = call float @llvm.fmuladd.f32(float %8, float 0x3F5205BC00000000, float 1.550000e+02)
br label %30
28: ; preds = %24
%29 = call float @llvm.fmuladd.f32(float %8, float 0x3F4D7DBF40000000, float 2.550000e+02)
br label %30
30: ; preds = %14, %22, %28, %26, %18, %10
%31 = phi float [ %11, %10 ], [ %15, %14 ], [ %19, %18 ], [ %23, %22 ], [ %27, %26 ], [ %29, %28 ]
%32 = fcmp olt float %31, 3.900000e+01
%33 = select i1 %32, float 3.900000e+01, float %31
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%38 = load float, float* %1
%39 = fcmp oeq float %38, 0.000000e+00
br i1 %39, label %40, label %7
40: ; preds = %30, %0
ret i32 0
}