#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 == 0.0f) {
      return 0;
    } else if (value < 2500.00f) {
      commission = 30.00f + 0.017f * value;
    } else if (value < 6250.00f) {
      commission = 56.00f + 0.0066f * value;
    } else if (value < 20000.00f) {
      commission = 76.00f + 0.0034f * value;
    } else if (value < 50000.00f) {
      commission = 100.00f + 0.0022f * value;
    } else {
      commission = 255.00f + 0.0009f * value;
    }
    if (commission < 39.00f) {
      commission = 39.00f;
    }
    printf("Commission: $%.2f\n", commission);
    printf("Enter value of trade: ");
    scanf("%f", &value);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0f(%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    12ff <main+0x1df>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    118c <main+0x6c>
jp     118c <main+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    12ff <main+0x1df>
movss  0xe6c(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11c5 <main+0xa5>
movss  -0xc(%rbp),%xmm0
movss  0xe85(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe7d(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    12a1 <main+0x181>
movss  0xe37(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11fe <main+0xde>
movss  -0xc(%rbp),%xmm0
movss  0xe44(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe3c(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    129c <main+0x17c>
movss  0xe02(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1237 <main+0x117>
movss  -0xc(%rbp),%xmm0
movss  0xe03(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xdfb(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1297 <main+0x177>
movss  0xdcd(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1270 <main+0x150>
movss  -0xc(%rbp),%xmm0
movss  0xdc2(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xdba(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1292 <main+0x172>
movss  -0xc(%rbp),%xmm0
movss  0xd93(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd8b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1297 <main+0x177>
jmp    129c <main+0x17c>
jmp    12a1 <main+0x181>
jmp    12a6 <main+0x186>
movss  0xd8a(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    12c5 <main+0x1a5>
movss  0xd78(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd62(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114d <main+0x2d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xf11(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf1a(%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    0xeee(%rip),%r14
lea    0xecd(%rip),%r15
lea    0xedd(%rip),%r12
lea    0x4(%rsp),%rbx
jmp    11e7 <main+0xc7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mulss  0xe98(%rip),%xmm0
addss  0xe94(%rip),%xmm0
movss  0xe90(%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 0xe5d(%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  0xe1f(%rip),%xmm0
addss  0xe1b(%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  0xdeb(%rip),%xmm0
addss  0xde7(%rip),%xmm0
jmp    11a0 <main+0x80>
movss  0xdc2(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1264 <main+0x144>
mulss  0xdc1(%rip),%xmm0
addss  0xdbd(%rip),%xmm0
jmp    11a0 <main+0x80>
mulss  0xda4(%rip),%xmm0
addss  0xda0(%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 = [19 x i8] c"Commission: $%.2f\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 = %48, %0
%7 = load float, float* %3
%8 = fcmp une float %7, 0.000000e+00
br i1 %8, label %9, label %54
9: ; preds = %6
%10 = load float, float* %3
%11 = fcmp oeq float %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 0, i32* %1
br label %54
13: ; preds = %9
%14 = load float, float* %3
%15 = fcmp olt float %14, 2.500000e+03
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load float, float* %3
%18 = call float @llvm.fmuladd.f32(float 0x3F916872C0000000, float %17, float 3.000000e+01)
store float %18, float* %2
br label %43
19: ; preds = %13
%20 = load float, float* %3
%21 = fcmp olt float %20, 6.250000e+03
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load float, float* %3
%24 = call float @llvm.fmuladd.f32(float 0x3F7B089A00000000, float %23, float 5.600000e+01)
store float %24, float* %2
br label %42
25: ; preds = %19
%26 = load float, float* %3
%27 = fcmp olt float %26, 2.000000e+04
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load float, float* %3
%30 = call float @llvm.fmuladd.f32(float 0x3F6BDA5120000000, float %29, float 7.600000e+01)
store float %30, float* %2
br label %41
31: ; preds = %25
%32 = load float, float* %3
%33 = fcmp olt float %32, 5.000000e+04
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load float, float* %3
%36 = call float @llvm.fmuladd.f32(float 0x3F6205BC00000000, float %35, float 1.000000e+02)
store float %36, float* %2
br label %40
37: ; preds = %31
%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, %28
br label %42
42: ; preds = %41, %22
br label %43
43: ; preds = %42, %16
br label %44
44: ; preds = %43
%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 %48
48: ; preds = %47, %44
%49 = load float, float* %2
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
br label %6
54: ; preds = %12, %6
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter value of trade: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [19 x i8] c"Commission: $%.2f\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 oeq float %5, 0.000000e+00
br i1 %6, label %36, label %7
7: ; preds = %0, %26
%8 = phi float [ %34, %26 ], [ %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 %26
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 %26
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 %26
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 %26
24: ; preds = %20
%25 = call float @llvm.fmuladd.f32(float %8, float 0x3F4D7DBF40000000, float 2.550000e+02)
br label %26
26: ; preds = %10, %18, %24, %22, %14
%27 = phi float [ %11, %10 ], [ %15, %14 ], [ %19, %18 ], [ %23, %22 ], [ %25, %24 ]
%28 = fcmp olt float %27, 3.900000e+01
%29 = select i1 %28, float 3.900000e+01, float %27
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%34 = load float, float* %1
%35 = fcmp oeq float %34, 0.000000e+00
br i1 %35, label %36, label %7
36: ; preds = %26, %0
ret i32 0
}