#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 */
double BSAmericanCallApprox(double, double, double, double, double, double);
int /*<<< orphan*/ assert(int);
double BSAmericanApprox(int fCall, double S, double X, double T, double r,
                        double b, double v) {
  double result;
  assert(((S) == (S)) && (S) >= 0.000001 && (S) <= 1000000000000.0);
  assert(((X) == (X)) && (X) >= 0.000001 && (X) <= 1000000000000.0);
  assert(((T) == (T)) && (T) >= (1.0 / (253.0 * 24.0)) && (T) <= (20.0));
  assert(((r) == (r)) && (r) >= 0.0 && (r) <= 1000.0);
  assert(((v) == (v)) && (v) >= 0.0000001 && v <= 100.99999);
  if (fCall)
    result = BSAmericanCallApprox(S, X, T, r, b, v);
  else {
    result = BSAmericanCallApprox(X, S, T, r - b, -b, v);
  }
  assert(((result) == (result)));
  return result;
}


x86 assembly (clang, -O0):
<BSAmericanApprox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x41(%rbp)
jne    1193 <BSAmericanApprox+0x73>
jp     1193 <BSAmericanApprox+0x73>
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe8d(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x41(%rbp)
jb     1193 <BSAmericanApprox+0x73>
movsd  0xe80(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
setae  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x42(%rbp)
jne    11ea <BSAmericanApprox+0xca>
jp     11ea <BSAmericanApprox+0xca>
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe36(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x42(%rbp)
jb     11ea <BSAmericanApprox+0xca>
movsd  0xe29(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x20(%rbp),%xmm0
mov    %al,-0x43(%rbp)
jne    1241 <BSAmericanApprox+0x121>
jp     1241 <BSAmericanApprox+0x121>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xdef(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x43(%rbp)
jb     1241 <BSAmericanApprox+0x121>
movsd  0xde2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
setae  %al
mov    %al,-0x43(%rbp)
mov    -0x43(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x28(%rbp),%xmm0
mov    %al,-0x44(%rbp)
jne    1293 <BSAmericanApprox+0x173>
jp     1293 <BSAmericanApprox+0x173>
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x44(%rbp)
jb     1293 <BSAmericanApprox+0x173>
movsd  0xd98(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
setae  %al
mov    %al,-0x44(%rbp)
mov    -0x44(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x38(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x38(%rbp),%xmm0
mov    %al,-0x45(%rbp)
jne    12ea <BSAmericanApprox+0x1ca>
jp     12ea <BSAmericanApprox+0x1ca>
movsd  -0x38(%rbp),%xmm0
xor    %eax,%eax
movsd  0xd5e(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x45(%rbp)
jb     12ea <BSAmericanApprox+0x1ca>
movsd  0xd51(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
setae  %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
je     132e <BSAmericanApprox+0x20e>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
call   1030 <BSAmericanCallApprox@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1372 <BSAmericanApprox+0x252>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
subsd  -0x30(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
movsd  -0x38(%rbp),%xmm5
call   1030 <BSAmericanCallApprox@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x40(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSAmericanApprox>:
push   %rbx
sub    $0x40,%rsp
ucomisd %xmm0,%xmm0
setnp  %al
ucomisd 0xecc(%rip),%xmm0
setae  %cl
and    %al,%cl
movsd  0xec7(%rip),%xmm6
movsd  %xmm0,0x28(%rsp)
ucomisd %xmm0,%xmm6
movsd  %xmm5,0x8(%rsp)
movaps %xmm4,0x30(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
mov    %edi,%ebx
setae  %al
and    %cl,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe74(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe6f(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe51(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe4c(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
call   1040 <assert@plt>
xorpd  %xmm0,%xmm0
movsd  0x20(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setae  %al
movsd  0xe2a(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe0c(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe07(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
call   1040 <assert@plt>
test   %ebx,%ebx
je     125e <BSAmericanApprox+0x13e>
movsd  0x28(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movapd 0x30(%rsp),%xmm4
jmp    1288 <BSAmericanApprox+0x168>
movapd 0x30(%rsp),%xmm4
movsd  0x20(%rsp),%xmm3
subsd  %xmm4,%xmm3
xorpd  0xdca(%rip),%xmm4
movsd  0x10(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x8(%rsp),%xmm5
call   1030 <BSAmericanCallApprox@plt>
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
ucomisd %xmm0,%xmm0
setnp  %dil
call   1040 <assert@plt>
movsd  0x8(%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @BSAmericanApprox(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%16 = load double, double* %9
%17 = load double, double* %9
%18 = fcmp oeq double %16, %17
br i1 %18, label %19, label %25
19: ; preds = %7
%20 = load double, double* %9
%21 = fcmp oge double %20, 0x3EB0C6F7A0B5ED8D
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load double, double* %9
%24 = fcmp ole double %23, 1.000000e+12
br label %25
25: ; preds = %22, %19, %7
%26 = phi i1 [ false, %19 ], [ false, %7 ], [ %24, %22 ]
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load double, double* %10
%30 = load double, double* %10
%31 = fcmp oeq double %29, %30
br i1 %31, label %32, label %38
32: ; preds = %25
%33 = load double, double* %10
%34 = fcmp oge double %33, 0x3EB0C6F7A0B5ED8D
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load double, double* %10
%37 = fcmp ole double %36, 1.000000e+12
br label %38
38: ; preds = %35, %32, %25
%39 = phi i1 [ false, %32 ], [ false, %25 ], [ %37, %35 ]
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load double, double* %11
%43 = load double, double* %11
%44 = fcmp oeq double %42, %43
br i1 %44, label %45, label %51
45: ; preds = %38
%46 = load double, double* %11
%47 = fcmp oge double %46, 0x3F2596179C29D2CE
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load double, double* %11
%50 = fcmp ole double %49, 2.000000e+01
br label %51
51: ; preds = %48, %45, %38
%52 = phi i1 [ false, %45 ], [ false, %38 ], [ %50, %48 ]
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load double, double* %12
%56 = load double, double* %12
%57 = fcmp oeq double %55, %56
br i1 %57, label %58, label %64
58: ; preds = %51
%59 = load double, double* %12
%60 = fcmp oge double %59, 0.000000e+00
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load double, double* %12
%63 = fcmp ole double %62, 1.000000e+03
br label %64
64: ; preds = %61, %58, %51
%65 = phi i1 [ false, %58 ], [ false, %51 ], [ %63, %61 ]
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = load double, double* %14
%69 = load double, double* %14
%70 = fcmp oeq double %68, %69
br i1 %70, label %71, label %77
71: ; preds = %64
%72 = load double, double* %14
%73 = fcmp oge double %72, 0x3E7AD7F29ABCAF48
br i1 %73, label %74, label %77
74: ; preds = %71
%75 = load double, double* %14
%76 = fcmp ole double %75, 0x40593FFFD60E94EE
br label %77
77: ; preds = %74, %71, %64
%78 = phi i1 [ false, %71 ], [ false, %64 ], [ %76, %74 ]
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = load i32, i32* %8
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %91
83: ; preds = %77
%84 = load double, double* %9
%85 = load double, double* %10
%86 = load double, double* %11
%87 = load double, double* %12
%88 = load double, double* %13
%89 = load double, double* %14
%90 = call double @BSAmericanCallApprox(double %84, double %85, double %86, double %87, double %88, double %89)
store double %90, double* %15
br label %102
91: ; preds = %77
%92 = load double, double* %10
%93 = load double, double* %9
%94 = load double, double* %11
%95 = load double, double* %12
%96 = load double, double* %13
%97 = fsub double %95, %96
%98 = load double, double* %13
%99 = fneg double %98
%100 = load double, double* %14
%101 = call double @BSAmericanCallApprox(double %92, double %93, double %94, double %97, double %99, double %100)
store double %101, double* %15
br label %102
102: ; preds = %91, %83
%103 = load double, double* %15
%104 = load double, double* %15
%105 = fcmp oeq double %103, %104
%106 = zext i1 %105 to i32
%107 = call i32 @assert(i32 %106)
%108 = load double, double* %15
ret double %108
}

LLVM IR (-O2):
define double @BSAmericanApprox(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = fcmp ord double %1, 0.000000e+00
%9 = fcmp oge double %1, 0x3EB0C6F7A0B5ED8D
%10 = and i1 %8, %9
%11 = fcmp ole double %1, 1.000000e+12
%12 = and i1 %11, %10
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = fcmp ord double %2, 0.000000e+00
%16 = fcmp oge double %2, 0x3EB0C6F7A0B5ED8D
%17 = and i1 %15, %16
%18 = fcmp ole double %2, 1.000000e+12
%19 = and i1 %18, %17
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = fcmp ord double %3, 0.000000e+00
%23 = fcmp oge double %3, 0x3F2596179C29D2CE
%24 = and i1 %22, %23
%25 = fcmp ole double %3, 2.000000e+01
%26 = and i1 %25, %24
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = fcmp oge double %4, 0.000000e+00
%30 = fcmp ole double %4, 1.000000e+03
%31 = and i1 %29, %30
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = fcmp ord double %6, 0.000000e+00
%35 = fcmp oge double %6, 0x3E7AD7F29ABCAF48
%36 = and i1 %34, %35
%37 = fcmp ole double %6, 0x40593FFFD60E94EE
%38 = and i1 %37, %36
%39 = zext i1 %38 to i32
%40 = tail call i32 @assert(i32 %39)
%41 = icmp eq i32 %0, 0
br i1 %41, label %44, label %42
42: ; preds = %7
%43 = tail call double @BSAmericanCallApprox(double %1, double %2, double %3, double %4, double %5, double %6)
br label %48
44: ; preds = %7
%45 = fsub double %4, %5
%46 = fneg double %5
%47 = tail call double @BSAmericanCallApprox(double %2, double %1, double %3, double %45, double %46, double %6)
br label %48
48: ; preds = %44, %42
%49 = phi double [ %43, %42 ], [ %47, %44 ]
%50 = fcmp ord double %49, 0.000000e+00
%51 = zext i1 %50 to i32
%52 = tail call i32 @assert(i32 %51)
ret double %49
}