#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 trade = 0, commission = 0;
  printf("enter the amount and price of trade:\n");
  scanf("%f", &trade);
  if (trade < 2500.00f) {
    commission = 30.00f + .017f * trade;
  } else if (trade < 6250.00f) {
    commission = 76.00f + .0066f * trade;
  } else if (trade < 20000.00f) {
    commission = 100.00f + .0034 * trade;
  } else if (trade < 50000.00f) {
    commission = 155.00f + .0022 * trade;
  } else {
    commission = 255.00f + .0009 * trade;
  }
  if (commission < 39.00f) {
    commission = 39.00f;
  }
  printf("commission: %.2f\n", commission);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  0xe9b(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1196 <main+0x76>
movss  -0x8(%rbp),%xmm0
movss  0xe9c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe94(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    128a <main+0x16a>
movss  0xe66(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11cf <main+0xaf>
movss  -0x8(%rbp),%xmm0
movss  0xe5b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe53(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1285 <main+0x165>
movss  0xe31(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1210 <main+0xf0>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe56(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe52(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1280 <main+0x160>
movss  0xdf4(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1251 <main+0x131>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe05(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe01(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    127b <main+0x15b>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdc6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc2(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1280 <main+0x160>
jmp    1285 <main+0x165>
jmp    128a <main+0x16a>
movss  0xd8e(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    12a9 <main+0x189>
movss  0xd7c(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
movss  0xe9c(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    117b <main+0x4b>
mulss  0xea7(%rip),%xmm0
addss  0xea3(%rip),%xmm0
jmp    11f4 <main+0xc4>
movss  0xe81(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    119a <main+0x6a>
mulss  0xe80(%rip),%xmm0
addss  0xe7c(%rip),%xmm0
jmp    11f4 <main+0xc4>
movss  0xe66(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11bd <main+0x8d>
cvtss2sd %xmm0,%xmm0
mulsd  0xe95(%rip),%xmm0
addsd  0xe95(%rip),%xmm0
jmp    11f0 <main+0xc0>
movss  0xe47(%rip),%xmm1
ucomiss %xmm0,%xmm1
cvtss2sd %xmm0,%xmm0
jbe    11e0 <main+0xb0>
mulsd  0xe62(%rip),%xmm0
addsd  0xe62(%rip),%xmm0
jmp    11f0 <main+0xc0>
mulsd  0xe40(%rip),%xmm0
addsd  0xe40(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xe24(%rip),%xmm1
maxss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"enter the amount and price of trade:\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [18 x i8] c"commission: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 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* %2)
%6 = load float, float* %2
%7 = fcmp olt float %6, 2.500000e+03
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load float, float* %2
%10 = call float @llvm.fmuladd.f32(float 0x3F916872C0000000, float %9, float 3.000000e+01)
store float %10, float* %3
br label %41
11: ; preds = %0
%12 = load float, float* %2
%13 = fcmp olt float %12, 6.250000e+03
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load float, float* %2
%16 = call float @llvm.fmuladd.f32(float 0x3F7B089A00000000, float %15, float 7.600000e+01)
store float %16, float* %3
br label %40
17: ; preds = %11
%18 = load float, float* %2
%19 = fcmp olt float %18, 2.000000e+04
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load float, float* %2
%22 = fpext float %21 to double
%23 = call double @llvm.fmuladd.f64(double 3.400000e-03, double %22, double 1.000000e+02)
%24 = fptrunc double %23 to float
store float %24, float* %3
br label %39
25: ; preds = %17
%26 = load float, float* %2
%27 = fcmp olt float %26, 5.000000e+04
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load float, float* %2
%30 = fpext float %29 to double
%31 = call double @llvm.fmuladd.f64(double 2.200000e-03, double %30, double 1.550000e+02)
%32 = fptrunc double %31 to float
store float %32, float* %3
br label %38
33: ; preds = %25
%34 = load float, float* %2
%35 = fpext float %34 to double
%36 = call double @llvm.fmuladd.f64(double 9.000000e-04, double %35, double 2.550000e+02)
%37 = fptrunc double %36 to float
store float %37, float* %3
br label %38
38: ; preds = %33, %28
br label %39
39: ; preds = %38, %20
br label %40
40: ; preds = %39, %14
br label %41
41: ; preds = %40, %8
%42 = load float, float* %3
%43 = fcmp olt float %42, 3.900000e+01
br i1 %43, label %44, label %45
44: ; preds = %41
store float 3.900000e+01, float* %3
br label %45
45: ; preds = %44, %41
%46 = load float, float* %3
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %47)
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [18 x i8] c"commission: %.2f\0A\00"
@str = [37 x i8] c"enter the amount and price of trade:\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 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 olt float %5, 2.500000e+03
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call float @llvm.fmuladd.f32(float %5, float 0x3F916872C0000000, float 3.000000e+01)
br label %28
9: ; preds = %0
%10 = fcmp olt float %5, 6.250000e+03
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call float @llvm.fmuladd.f32(float %5, float 0x3F7B089A00000000, float 7.600000e+01)
br label %28
13: ; preds = %9
%14 = fcmp olt float %5, 2.000000e+04
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = fpext float %5 to double
%17 = call double @llvm.fmuladd.f64(double %16, double 3.400000e-03, double 1.000000e+02)
%18 = fptrunc double %17 to float
br label %28
19: ; preds = %13
%20 = fcmp olt float %5, 5.000000e+04
%21 = fpext float %5 to double
br i1 %20, label %22, label %25
22: ; preds = %19
%23 = call double @llvm.fmuladd.f64(double %21, double 2.200000e-03, double 1.550000e+02)
%24 = fptrunc double %23 to float
br label %28
25: ; preds = %19
%26 = call double @llvm.fmuladd.f64(double %21, double 9.000000e-04, double 2.550000e+02)
%27 = fptrunc double %26 to float
br label %28
28: ; preds = %11, %22, %25, %15, %7
%29 = phi float [ %8, %7 ], [ %12, %11 ], [ %18, %15 ], [ %24, %22 ], [ %27, %25 ]
%30 = fcmp olt float %29, 3.900000e+01
%31 = select i1 %30, float 3.900000e+01, float %29
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %32)
ret i32 0
}