#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 DBL_DIG;
char EOF;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getchar();
double pow(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int scanf(char *, double *);
int /*<<< orphan*/ stderr;
int main(void) {
  const double EPSILON = 1.0 * pow(10.0, (DBL_DIG - 1) * -1.0);
  double commission = 0.0;
  double value = 0.0;
  char c = '\0';
  while (1) {
    printf("Enter value of trade (0 to quit): ");
    while (scanf("%lf", &value) != 1) {
      fprintf(stderr, "Input invalid. Please try again.\n");
      while ((c = getchar()) != '\n' && c != EOF)
        continue;
      continue;
    }
    while ((c = getchar()) != '\n' && c != EOF)
      continue;
    if (value <= EPSILON) {
      break;
    } else if (value < 0.0) {
      fprintf(stderr,
              "The value of trade cannot be negative. Please try again.\n");
      continue;
    } else {
      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 = 155.00f + .0011f * value;
      } else {
        commission = 255.00f + .0009f * value;
      }
      if (commission < 39.00f)
        commission = 39.00f;
      printf("Commission: $%.2lf\n", commission);
    }
  }
  puts("Thank you for using our application!");
  getchar();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe89(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  0xe71(%rip),%xmm0
call   1080 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe59(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     124b <main+0xeb>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x22(%rbp)
je     1231 <main+0xd1>
movsbl -0x21(%rbp),%eax
mov    0x2dc2(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    1241 <main+0xe1>
jmp    1246 <main+0xe6>
jmp    1200 <main+0xa0>
jmp    11d2 <main+0x72>
jmp    1250 <main+0xf0>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x23(%rbp)
je     1281 <main+0x121>
movsbl -0x21(%rbp),%eax
mov    0x2d72(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
test   $0x1,%al
jne    1291 <main+0x131>
jmp    1296 <main+0x136>
jmp    1250 <main+0xf0>
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12af <main+0x14f>
jmp    142d <main+0x2cd>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    12d7 <main+0x177>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11c4 <main+0x64>
movsd  0xd39(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1311 <main+0x1b1>
movsd  -0x20(%rbp),%xmm0
movsd  0xd81(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd7d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    13f0 <main+0x290>
movsd  0xd07(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    134b <main+0x1eb>
movsd  -0x20(%rbp),%xmm0
movsd  0xd37(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd33(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    13eb <main+0x28b>
movsd  0xcd5(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1385 <main+0x225>
movsd  -0x20(%rbp),%xmm0
movsd  0xced(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xce9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    13e6 <main+0x286>
movsd  0xca3(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    13bf <main+0x25f>
movsd  -0x20(%rbp),%xmm0
movsd  0xca3(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc9f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    13e1 <main+0x281>
movsd  -0x20(%rbp),%xmm0
movsd  0xc6c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc68(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    13e6 <main+0x286>
jmp    13eb <main+0x28b>
jmp    13f0 <main+0x290>
movsd  0xc90(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1410 <main+0x2b0>
movsd  0xc7d(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xcf7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1428 <main+0x2c8>
jmp    11c4 <main+0x64>
lea    0xcf3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
add    $0xffffffff,%eax
cvtsi2sd %eax,%xmm0
xorpd  0xe7a(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  0xe7e(%rip),%xmm0
call   1080 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xeeb(%rip),%r14
lea    0xf07(%rip),%r15
lea    0x8(%rsp),%rbx
mov    0x2e28(%rip),%r12
mov    0x2e09(%rip),%r13
lea    0xef1(%rip),%rbp
jmp    11e0 <main+0x80>
mov    0x0(%r13),%edi
lea    0xf06(%rip),%rsi
call   1060 <fprintf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1230 <main+0xd0>
mov    0x0(%r13),%edi
mov    %rbp,%rsi
call   1060 <fprintf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11f0 <main+0x90>
cmp    (%r12),%al
jne    1210 <main+0xb0>
jmp    11f0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1241 <main+0xe1>
cmp    (%r12),%al
jne    1230 <main+0xd0>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jae    131f <main+0x1bf>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     11d0 <main+0x70>
movsd  0xdab(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1290 <main+0x130>
mulsd  0xdfd(%rip),%xmm1
addsd  0xdfd(%rip),%xmm1
jmp    1300 <main+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0xd88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12b0 <main+0x150>
mulsd  0xdc2(%rip),%xmm1
addsd  0xdc2(%rip),%xmm1
jmp    1300 <main+0x1a0>
movsd  0xd70(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12d0 <main+0x170>
mulsd  0xd92(%rip),%xmm1
addsd  0xd92(%rip),%xmm1
jmp    1300 <main+0x1a0>
movsd  0xd58(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12f0 <main+0x190>
mulsd  0xd62(%rip),%xmm1
addsd  0xd62(%rip),%xmm1
jmp    1300 <main+0x1a0>
mulsd  0xd40(%rip),%xmm1
addsd  0xd40(%rip),%xmm1
movsd  0xd80(%rip),%xmm0
maxsd  %xmm1,%xmm0
lea    0xe08(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11e0 <main+0x80>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_DIG = global i32 0
@.str = [35 x i8] c"Enter value of trade (0 to quit): \00"
@.str.1 = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"Input invalid. Please try again.\0A\00"
@EOF = global i8 0
@.str.3 = [58 x i8] c"The value of trade cannot be negative. Please try again.\0A\00"
@.str.4 = [20 x i8] c"Commission: $%.2lf\0A\00"
@.str.5 = [37 x i8] c"Thank you for using our application!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i8
store i32 0, i32* %1
%6 = load i32, i32* @DBL_DIG
%7 = sub nsw i32 %6, 1
%8 = sitofp i32 %7 to double
%9 = fmul double %8, -1.000000e+00
%10 = fptosi double %9 to i32
%11 = call double @pow(double 1.000000e+01, i32 %10)
%12 = fmul double 1.000000e+00, %11
store double %12, double* %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
store i8 0, i8* %5
br label %13
13: ; preds = %0, %57, %98
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %34, %13
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %33, %18
%22 = call signext i8 (...) @getchar()
store i8 %22, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = load i8, i8* @EOF
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %27, %29
br label %31
31: ; preds = %25, %21
%32 = phi i1 [ false, %21 ], [ %30, %25 ]
br i1 %32, label %33, label %34
33: ; preds = %31
br label %21
34: ; preds = %31
br label %15
35: ; preds = %15
br label %36
36: ; preds = %48, %35
%37 = call signext i8 (...) @getchar()
store i8 %37, i8* %5
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 10
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i8, i8* %5
%42 = sext i8 %41 to i32
%43 = load i8, i8* @EOF
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %42, %44
br label %46
46: ; preds = %40, %36
%47 = phi i1 [ false, %36 ], [ %45, %40 ]
br i1 %47, label %48, label %49
48: ; preds = %46
br label %36
49: ; preds = %46
%50 = load double, double* %4
%51 = load double, double* %2
%52 = fcmp ole double %50, %51
br i1 %52, label %53, label %54
53: ; preds = %49
br label %99
54: ; preds = %49
%55 = load double, double* %4
%56 = fcmp olt double %55, 0.000000e+00
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %13
60: ; preds = %54
%61 = load double, double* %4
%62 = fcmp olt double %61, 2.500000e+03
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load double, double* %4
%65 = call double @llvm.fmuladd.f64(double 0x3F916872C0000000, double %64, double 3.000000e+01)
store double %65, double* %3
br label %90
66: ; preds = %60
%67 = load double, double* %4
%68 = fcmp olt double %67, 6.250000e+03
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load double, double* %4
%71 = call double @llvm.fmuladd.f64(double 0x3F7B089A00000000, double %70, double 5.600000e+01)
store double %71, double* %3
br label %89
72: ; preds = %66
%73 = load double, double* %4
%74 = fcmp olt double %73, 2.000000e+04
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = load double, double* %4
%77 = call double @llvm.fmuladd.f64(double 0x3F6BDA5120000000, double %76, double 7.600000e+01)
store double %77, double* %3
br label %88
78: ; preds = %72
%79 = load double, double* %4
%80 = fcmp olt double %79, 5.000000e+04
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = load double, double* %4
%83 = call double @llvm.fmuladd.f64(double 0x3F5205BC00000000, double %82, double 1.550000e+02)
store double %83, double* %3
br label %87
84: ; preds = %78
%85 = load double, double* %4
%86 = call double @llvm.fmuladd.f64(double 0x3F4D7DBF40000000, double %85, double 2.550000e+02)
store double %86, double* %3
br label %87
87: ; preds = %84, %81
br label %88
88: ; preds = %87, %75
br label %89
89: ; preds = %88, %69
br label %90
90: ; preds = %89, %63
%91 = load double, double* %3
%92 = fcmp olt double %91, 3.900000e+01
br i1 %92, label %93, label %94
93: ; preds = %90
store double 3.900000e+01, double* %3
br label %94
94: ; preds = %93, %90
%95 = load double, double* %3
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %95)
br label %97
97: ; preds = %94
br label %98
98: ; preds = %97
br label %13
99: ; preds = %53
%100 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%101 = call signext i8 (...) @getchar()
%102 = load i32, i32* @EXIT_SUCCESS
ret i32 %102
}

LLVM IR (-O2):
@DBL_DIG = global i32 0
@.str = [35 x i8] c"Enter value of trade (0 to quit): \00"
@.str.1 = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"Input invalid. Please try again.\0A\00"
@EOF = global i8 0
@.str.3 = [58 x i8] c"The value of trade cannot be negative. Please try again.\0A\00"
@.str.4 = [20 x i8] c"Commission: $%.2lf\0A\00"
@.str.5 = [37 x i8] c"Thank you for using our application!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca double
%2 = load i32, i32* @DBL_DIG
%3 = add nsw i32 %2, -1
%4 = sitofp i32 %3 to double
%5 = fneg double %4
%6 = fptosi double %5 to i32
%7 = tail call double @pow(double 1.000000e+01, i32 %6)
%8 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
br label %9
9: ; preds = %40, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %14, %9
br label %26
14: ; preds = %20
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%16 = icmp eq i32 %15, 1
br i1 %16, label %13, label %17
17: ; preds = %9, %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %20, %17
%21 = call signext i8 (...) @getchar()
%22 = icmp ne i8 %21, 10
%23 = load i8, i8* @EOF
%24 = icmp ne i8 %21, %23
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %20, label %14
26: ; preds = %13, %26
%27 = call signext i8 (...) @getchar()
%28 = icmp ne i8 %27, 10
%29 = load i8, i8* @EOF
%30 = icmp ne i8 %27, %29
%31 = select i1 %28, i1 %30, i1 false
br i1 %31, label %26, label %32
32: ; preds = %26
%33 = load double, double* %1
%34 = fcmp ugt double %33, %7
br i1 %34, label %35, label %64
35: ; preds = %32
%36 = fcmp olt double %33, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %35
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %37, %59
br label %9
41: ; preds = %35
%42 = fcmp olt double %33, 2.500000e+03
br i1 %42, label %43, label %45
43: ; preds = %41
%44 = call double @llvm.fmuladd.f64(double %33, double 0x3F916872C0000000, double 3.000000e+01)
br label %59
45: ; preds = %41
%46 = fcmp olt double %33, 6.250000e+03
br i1 %46, label %47, label %49
47: ; preds = %45
%48 = call double @llvm.fmuladd.f64(double %33, double 0x3F7B089A00000000, double 5.600000e+01)
br label %59
49: ; preds = %45
%50 = fcmp olt double %33, 2.000000e+04
br i1 %50, label %51, label %53
51: ; preds = %49
%52 = call double @llvm.fmuladd.f64(double %33, double 0x3F6BDA5120000000, double 7.600000e+01)
br label %59
53: ; preds = %49
%54 = fcmp olt double %33, 5.000000e+04
br i1 %54, label %55, label %57
55: ; preds = %53
%56 = call double @llvm.fmuladd.f64(double %33, double 0x3F5205BC00000000, double 1.550000e+02)
br label %59
57: ; preds = %53
%58 = call double @llvm.fmuladd.f64(double %33, double 0x3F4D7DBF40000000, double 2.550000e+02)
br label %59
59: ; preds = %47, %55, %57, %51, %43
%60 = phi double [ %44, %43 ], [ %48, %47 ], [ %52, %51 ], [ %56, %55 ], [ %58, %57 ]
%61 = fcmp olt double %60, 3.900000e+01
%62 = select i1 %61, double 3.900000e+01, double %60
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %62)
br label %40
64: ; preds = %32
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%66 = call signext i8 (...) @getchar()
%67 = load i32, i32* @EXIT_SUCCESS
ret i32 %67
}