#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(void) {
  float commission, value;
  printf("Enter value of trade: ");
  scanf("%f", &value);
  while (value != 0.0f) {
    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);
    printf("Enter value of trade: ");
    scanf("%f", &value);
  }
  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    1315 <main+0x1f5>
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>
lea    0xd4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd58(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114d <main+0x2d>
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    115b <main+0x3b>
jnp    128b <main+0x16b>
lea    0xf04(%rip),%r14
lea    0xee3(%rip),%r15
lea    0xef3(%rip),%r12
lea    0x4(%rsp),%rbx
jmp    11d7 <main+0xb7>
nopw   0x0(%rax,%rax,1)
mulss  0xeb4(%rip),%xmm0
addss  0xeb0(%rip),%xmm0
movss  0xeac(%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 0xe79(%rip),%xmm0
jne    11d7 <main+0xb7>
jnp    128b <main+0x16b>
movss  0xe21(%rip),%xmm1
ucomiss %xmm0,%xmm1
ja     1180 <main+0x60>
movss  0xe18(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1210 <main+0xf0>
mulss  0xe3b(%rip),%xmm0
addss  0xe37(%rip),%xmm0
jmp    1190 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0xdf0(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1232 <main+0x112>
mulss  0xe07(%rip),%xmm0
addss  0xe03(%rip),%xmm0
jmp    1190 <main+0x70>
movss  0xdd2(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1254 <main+0x134>
mulss  0xddd(%rip),%xmm0
addss  0xdd9(%rip),%xmm0
jmp    1190 <main+0x70>
movss  0xdb4(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1276 <main+0x156>
mulss  0xdb3(%rip),%xmm0
addss  0xdaf(%rip),%xmm0
jmp    1190 <main+0x70>
mulss  0xd96(%rip),%xmm0
addss  0xd92(%rip),%xmm0
jmp    1190 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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