#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;
  for (;;) {
    printf("Enter value of a 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 = 255.00f + .0009f * value;
    }
    if (commission < 39.00f) {
      commission = 39.00f;
    } else
      printf("Commission: $%1.2f\n", commission);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf15(%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    12d5 <main+0x1b5>
movss  0xe8f(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11a2 <main+0x82>
movss  -0xc(%rbp),%xmm0
movss  0xeac(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xea4(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1295 <main+0x175>
movss  0xe5a(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11db <main+0xbb>
movss  -0xc(%rbp),%xmm0
movss  0xe6b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe63(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1290 <main+0x170>
movss  0xe25(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1214 <main+0xf4>
movss  -0xc(%rbp),%xmm0
movss  0xe2a(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe22(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    128b <main+0x16b>
movss  0xdf0(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    124d <main+0x12d>
movss  -0xc(%rbp),%xmm0
movss  0xde9(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xde1(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1286 <main+0x166>
movss  0xdbb(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1281 <main+0x161>
movss  -0xc(%rbp),%xmm0
movss  0xda8(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xda0(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1286 <main+0x166>
jmp    128b <main+0x16b>
jmp    1290 <main+0x170>
jmp    1295 <main+0x175>
movss  0xd9f(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    12b9 <main+0x199>
movss  0xd8d(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12d0 <main+0x1b0>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd93(%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    0xf15(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf20(%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    0xed8(%rip),%r14
lea    0xeea(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xee1(%rip),%r12
jmp    11c0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm0,(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0xe89(%rip),%xmm0
movss  (%rsp),%xmm2
jne    11c0 <main+0xa0>
jnp    1157 <main+0x37>
movss  0xe38(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11f0 <main+0xd0>
mulss  0xe5f(%rip),%xmm0
addss  0xe5b(%rip),%xmm0
jmp    1270 <main+0x150>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  0xe0c(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1210 <main+0xf0>
mulss  0xe27(%rip),%xmm0
addss  0xe23(%rip),%xmm0
jmp    1270 <main+0x150>
nop
movss  0xdf0(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    122f <main+0x10f>
mulss  0xdff(%rip),%xmm0
addss  0xdfb(%rip),%xmm0
jmp    1270 <main+0x150>
movss  0xdd5(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    124e <main+0x12e>
mulss  0xdd8(%rip),%xmm0
addss  0xdd4(%rip),%xmm0
jmp    1270 <main+0x150>
movss  0xdba(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1273 <main+0x153>
mulss  0xdb1(%rip),%xmm0
addss  0xdad(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movaps %xmm0,%xmm2
movss  0xdc1(%rip),%xmm0
ucomiss %xmm2,%xmm0
ja     1190 <main+0x70>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
movss  %xmm2,(%rsp)
call   1030 <printf@plt>
movss  (%rsp),%xmm0
jmp    1190 <main+0x70>

LLVM IR (-O0):
@.str = [25 x i8] c"Enter value of a trade: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [20 x i8] c"Commission: $%1.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
br label %4
4: ; preds = %52, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 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 %53
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 %44
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 %43
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 %42
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 %41
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 0x3F4D7DBF40000000, float %38, float 2.550000e+02)
store float %39, float* %2
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40, %31
br label %42
42: ; preds = %41, %25
br label %43
43: ; preds = %42, %19
br label %44
44: ; preds = %43, %13
%45 = load float, float* %2
%46 = fcmp olt float %45, 3.900000e+01
br i1 %46, label %47, label %48
47: ; preds = %44
store float 3.900000e+01, float* %2
br label %52
48: ; preds = %44
%49 = load float, float* %2
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %50)
br label %52
52: ; preds = %48, %47
br label %4
53: ; preds = %9
ret i32 0
}

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