#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 *, ...);
int main(void) {
  int num;
  float commission, price, competitor, value;
  printf("Enter number of shares: ");
  scanf("%d", &num);
  printf("Enter price per share: ");
  scanf("%f", &price);
  value = num * price;
  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", commission);
  printf("Rivals comission: $%.2f\n",
         33.00f + (num > 2000 ? num * .02f : num * .03f));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf29(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf24(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe7a(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11b7 <main+0x97>
movss  -0x18(%rbp),%xmm0
movss  0xe9f(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe97(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12d1 <main+0x1b1>
movss  0xe45(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11f0 <main+0xd0>
movss  -0x18(%rbp),%xmm0
movss  0xe5e(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe56(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12cc <main+0x1ac>
movss  0xe10(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1229 <main+0x109>
movss  -0x18(%rbp),%xmm0
movss  0xe1d(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe15(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12c7 <main+0x1a7>
movss  0xddb(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1262 <main+0x142>
movss  -0x18(%rbp),%xmm0
movss  0xddc(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xdd4(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12c2 <main+0x1a2>
movss  0xda6(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    129b <main+0x17b>
movss  -0x18(%rbp),%xmm0
movss  0xd9b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd93(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12bd <main+0x19d>
movss  -0x18(%rbp),%xmm0
movss  0xd6c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd64(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    12c2 <main+0x1a2>
jmp    12c7 <main+0x1a7>
jmp    12cc <main+0x1ac>
jmp    12d1 <main+0x1b1>
movss  0xd6b(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    12f0 <main+0x1d0>
movss  0xd59(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd8b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x7d0,-0x8(%rbp)
jle    132f <main+0x20f>
cvtsi2ssl -0x8(%rbp),%xmm0
movss  0xd2b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1345 <main+0x225>
cvtsi2ssl -0x8(%rbp),%xmm0
movss  0xd0c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  0xcfe(%rip),%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd3d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf29(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf33(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cvtsi2ssl (%rsp),%xmm0
mulss  0x4(%rsp),%xmm0
movss  0xe8c(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    118e <main+0x6e>
mulss  0xebb(%rip),%xmm0
addss  0xeb7(%rip),%xmm0
jmp    121a <main+0xfa>
movss  0xe6e(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11ad <main+0x8d>
mulss  0xe91(%rip),%xmm0
addss  0xe8d(%rip),%xmm0
jmp    121a <main+0xfa>
movss  0xe53(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11cc <main+0xac>
mulss  0xe6a(%rip),%xmm0
addss  0xe66(%rip),%xmm0
jmp    121a <main+0xfa>
movss  0xe38(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11eb <main+0xcb>
mulss  0xe43(%rip),%xmm0
addss  0xe3f(%rip),%xmm0
jmp    121a <main+0xfa>
movss  0xe1d(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    120a <main+0xea>
mulss  0xe1c(%rip),%xmm0
addss  0xe18(%rip),%xmm0
jmp    121a <main+0xfa>
mulss  0xe02(%rip),%xmm0
addss  0xdfe(%rip),%xmm0
movss  0xe22(%rip),%xmm1
maxss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    (%rsp),%eax
xor    %ecx,%ecx
cmp    $0x7d1,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
setge  %cl
lea    0xdf6(%rip),%rax
mulss  (%rax,%rcx,4),%xmm0
addss  0xde5(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe30(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter number of shares: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter price per share: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [19 x i8] c"Commission: $%.2f\0A\00"
@.str.5 = [25 x i8] c"Rivals comission: $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%11 = load i32, i32* %2
%12 = sitofp i32 %11 to float
%13 = load float, float* %4
%14 = fmul float %12, %13
store float %14, float* %6
%15 = load float, float* %6
%16 = fcmp olt float %15, 2.500000e+03
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = load float, float* %6
%19 = call float @llvm.fmuladd.f32(float 0x3F916872C0000000, float %18, float 3.000000e+01)
store float %19, float* %3
br label %51
20: ; preds = %0
%21 = load float, float* %6
%22 = fcmp olt float %21, 6.250000e+03
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load float, float* %6
%25 = call float @llvm.fmuladd.f32(float 0x3F7B089A00000000, float %24, float 5.600000e+01)
store float %25, float* %3
br label %50
26: ; preds = %20
%27 = load float, float* %6
%28 = fcmp olt float %27, 2.000000e+04
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load float, float* %6
%31 = call float @llvm.fmuladd.f32(float 0x3F6BDA5120000000, float %30, float 7.600000e+01)
store float %31, float* %3
br label %49
32: ; preds = %26
%33 = load float, float* %6
%34 = fcmp olt float %33, 5.000000e+04
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load float, float* %6
%37 = call float @llvm.fmuladd.f32(float 0x3F6205BC00000000, float %36, float 1.000000e+02)
store float %37, float* %3
br label %48
38: ; preds = %32
%39 = load float, float* %6
%40 = fcmp olt float %39, 5.000000e+05
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load float, float* %6
%43 = call float @llvm.fmuladd.f32(float 0x3F5205BC00000000, float %42, float 1.550000e+02)
store float %43, float* %3
br label %47
44: ; preds = %38
%45 = load float, float* %6
%46 = call float @llvm.fmuladd.f32(float 0x3F4D7DBF40000000, float %45, float 2.550000e+02)
store float %46, float* %3
br label %47
47: ; preds = %44, %41
br label %48
48: ; preds = %47, %35
br label %49
49: ; preds = %48, %29
br label %50
50: ; preds = %49, %23
br label %51
51: ; preds = %50, %17
%52 = load float, float* %3
%53 = fcmp olt float %52, 3.900000e+01
br i1 %53, label %54, label %55
54: ; preds = %51
store float 3.900000e+01, float* %3
br label %55
55: ; preds = %54, %51
%56 = load float, float* %3
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), double %57)
%59 = load i32, i32* %2
%60 = icmp sgt i32 %59, 2000
br i1 %60, label %61, label %65
61: ; preds = %55
%62 = load i32, i32* %2
%63 = sitofp i32 %62 to float
%64 = fmul float %63, 0x3F947AE140000000
br label %69
65: ; preds = %55
%66 = load i32, i32* %2
%67 = sitofp i32 %66 to float
%68 = fmul float %67, 0x3F9EB851E0000000
br label %69
69: ; preds = %65, %61
%70 = phi float [ %64, %61 ], [ %68, %65 ]
%71 = fadd float 3.300000e+01, %70
%72 = fpext float %71 to double
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %72)
ret i32 0
}

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