#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*/ assert(int);
double delta_call(double, double, double, double, double, double);
double delta_put(double, double, double, double, double, double);
double const fabs(double);
double gbs_call(double, double, double, double, double, double);
double gbs_put(double, double, double, double, double, double);
double CriticalValueChooser(double S, double Xc, double Xp, double T, double Tc,
                            double Tp, double r, double b, double v) {
  double Sv, ci, Pi, dc, dp, yi, di;
  const double epsilon = 0.001;
  assert(((S) == (S)) && (S) >= 0.000001 && (S) <= 1000000000000.0);
  assert(((T) == (T)) && (T) >= (1.0 / (253.0 * 24.0)) && (T) <= (20.0));
  Sv = S;
  ci = gbs_call(Sv, Xc, Tc - T, r, b, v);
  Pi = gbs_put(Sv, Xp, Tp - T, r, b, v);
  dc = delta_call(Sv, Xc, Tc - T, r, b, v);
  dp = delta_put(Sv, Xp, Tp - T, r, b, v);
  yi = ci - Pi;
  di = dc - dp;
  while (fabs(yi) > epsilon) {
    Sv = Sv - (yi) / di;
    ci = gbs_call(Sv, Xc, Tc - T, r, b, v);
    Pi = gbs_put(Sv, Xp, Tp - T, r, b, v);
    dc = delta_call(Sv, Xc, Tc - T, r, b, v);
    dp = delta_put(Sv, Xp, Tp - T, r, b, v);
    yi = ci - Pi;
    di = dc - dp;
  }
  return Sv;
}


x86 assembly (clang, -O0):
<CriticalValueChooser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x8(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x8(%rbp),%xmm0
mov    %al,-0x81(%rbp)
jne    11f9 <CriticalValueChooser+0x99>
jp     11f9 <CriticalValueChooser+0x99>
movsd  -0x8(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe35(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x81(%rbp)
jb     11f9 <CriticalValueChooser+0x99>
movsd  0xe25(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
setae  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x20(%rbp),%xmm0
mov    %al,-0x82(%rbp)
jne    125c <CriticalValueChooser+0xfc>
jp     125c <CriticalValueChooser+0xfc>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xde2(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x82(%rbp)
jb     125c <CriticalValueChooser+0xfc>
movsd  0xdd2(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
setae  %al
mov    %al,-0x82(%rbp)
mov    -0x82(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1030 <gbs_call@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1060 <gbs_put@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1040 <delta_call@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1050 <delta_put@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1070 <fabs@plt>
movsd  0xca6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1453 <CriticalValueChooser+0x2f3>
movsd  -0x48(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
divsd  -0x78(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1030 <gbs_call@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1060 <gbs_put@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1040 <delta_call@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  0x10(%rbp),%xmm5
call   1050 <delta_put@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1348 <CriticalValueChooser+0x1e8>
movsd  -0x48(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CriticalValueChooser>:
sub    $0x68,%rsp
movsd  %xmm7,0x18(%rsp)
movsd  %xmm6,0x10(%rsp)
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x40(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x8(%rsp)
ucomisd %xmm0,%xmm0
setnp  %al
ucomisd 0xe6d(%rip),%xmm0
setae  %cl
and    %al,%cl
movsd  0xe68(%rip),%xmm1
ucomisd %xmm0,%xmm1
setae  %al
and    %cl,%al
movzbl %al,%edi
call   1070 <assert@plt>
movsd  0x20(%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe4a(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe45(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
call   1070 <assert@plt>
movsd  0x28(%rsp),%xmm2
subsd  0x20(%rsp),%xmm2
movsd  %xmm2,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1030 <gbs_call@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x30(%rsp),%xmm2
subsd  0x20(%rsp),%xmm2
movsd  %xmm2,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1060 <gbs_put@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1040 <delta_call@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1050 <delta_put@plt>
movapd 0x50(%rsp),%xmm2
subsd  0x48(%rsp),%xmm2
movapd 0xd6b(%rip),%xmm1
andpd  %xmm2,%xmm1
ucomisd 0xd4f(%rip),%xmm1
jbe    13e4 <CriticalValueChooser+0x294>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
divsd  %xmm1,%xmm2
movsd  0x8(%rsp),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x38(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1030 <gbs_call@plt>
movapd %xmm0,0x50(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1060 <gbs_put@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1040 <delta_call@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x70(%rsp),%xmm5
call   1050 <delta_put@plt>
movsd  0x20(%rsp),%xmm1
movapd 0x50(%rsp),%xmm2
subsd  0x48(%rsp),%xmm2
subsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
andpd  0xc5a(%rip),%xmm0
ucomisd 0xc42(%rip),%xmm0
ja     12f0 <CriticalValueChooser+0x1a0>
movsd  0x8(%rsp),%xmm0
add    $0x68,%rsp
ret

LLVM IR (-O0):
define double @CriticalValueChooser(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
store double %0, double* %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store double %6, double* %16
store double %7, double* %17
store double %8, double* %18
store double 1.000000e-03, double* %26
%27 = load double, double* %10
%28 = load double, double* %10
%29 = fcmp oeq double %27, %28
br i1 %29, label %30, label %36
30: ; preds = %9
%31 = load double, double* %10
%32 = fcmp oge double %31, 0x3EB0C6F7A0B5ED8D
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load double, double* %10
%35 = fcmp ole double %34, 1.000000e+12
br label %36
36: ; preds = %33, %30, %9
%37 = phi i1 [ false, %30 ], [ false, %9 ], [ %35, %33 ]
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load double, double* %13
%41 = load double, double* %13
%42 = fcmp oeq double %40, %41
br i1 %42, label %43, label %49
43: ; preds = %36
%44 = load double, double* %13
%45 = fcmp oge double %44, 0x3F2596179C29D2CE
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load double, double* %13
%48 = fcmp ole double %47, 2.000000e+01
br label %49
49: ; preds = %46, %43, %36
%50 = phi i1 [ false, %43 ], [ false, %36 ], [ %48, %46 ]
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load double, double* %10
store double %53, double* %19
%54 = load double, double* %19
%55 = load double, double* %11
%56 = load double, double* %14
%57 = load double, double* %13
%58 = fsub double %56, %57
%59 = load double, double* %16
%60 = load double, double* %17
%61 = load double, double* %18
%62 = call double @gbs_call(double %54, double %55, double %58, double %59, double %60, double %61)
store double %62, double* %20
%63 = load double, double* %19
%64 = load double, double* %12
%65 = load double, double* %15
%66 = load double, double* %13
%67 = fsub double %65, %66
%68 = load double, double* %16
%69 = load double, double* %17
%70 = load double, double* %18
%71 = call double @gbs_put(double %63, double %64, double %67, double %68, double %69, double %70)
store double %71, double* %21
%72 = load double, double* %19
%73 = load double, double* %11
%74 = load double, double* %14
%75 = load double, double* %13
%76 = fsub double %74, %75
%77 = load double, double* %16
%78 = load double, double* %17
%79 = load double, double* %18
%80 = call double @delta_call(double %72, double %73, double %76, double %77, double %78, double %79)
store double %80, double* %22
%81 = load double, double* %19
%82 = load double, double* %12
%83 = load double, double* %15
%84 = load double, double* %13
%85 = fsub double %83, %84
%86 = load double, double* %16
%87 = load double, double* %17
%88 = load double, double* %18
%89 = call double @delta_put(double %81, double %82, double %85, double %86, double %87, double %88)
store double %89, double* %23
%90 = load double, double* %20
%91 = load double, double* %21
%92 = fsub double %90, %91
store double %92, double* %24
%93 = load double, double* %22
%94 = load double, double* %23
%95 = fsub double %93, %94
store double %95, double* %25
br label %96
96: ; preds = %100, %49
%97 = load double, double* %24
%98 = call double @fabs(double %97)
%99 = fcmp ogt double %98, 1.000000e-03
br i1 %99, label %100, label %148
100: ; preds = %96
%101 = load double, double* %19
%102 = load double, double* %24
%103 = load double, double* %25
%104 = fdiv double %102, %103
%105 = fsub double %101, %104
store double %105, double* %19
%106 = load double, double* %19
%107 = load double, double* %11
%108 = load double, double* %14
%109 = load double, double* %13
%110 = fsub double %108, %109
%111 = load double, double* %16
%112 = load double, double* %17
%113 = load double, double* %18
%114 = call double @gbs_call(double %106, double %107, double %110, double %111, double %112, double %113)
store double %114, double* %20
%115 = load double, double* %19
%116 = load double, double* %12
%117 = load double, double* %15
%118 = load double, double* %13
%119 = fsub double %117, %118
%120 = load double, double* %16
%121 = load double, double* %17
%122 = load double, double* %18
%123 = call double @gbs_put(double %115, double %116, double %119, double %120, double %121, double %122)
store double %123, double* %21
%124 = load double, double* %19
%125 = load double, double* %11
%126 = load double, double* %14
%127 = load double, double* %13
%128 = fsub double %126, %127
%129 = load double, double* %16
%130 = load double, double* %17
%131 = load double, double* %18
%132 = call double @delta_call(double %124, double %125, double %128, double %129, double %130, double %131)
store double %132, double* %22
%133 = load double, double* %19
%134 = load double, double* %12
%135 = load double, double* %15
%136 = load double, double* %13
%137 = fsub double %135, %136
%138 = load double, double* %16
%139 = load double, double* %17
%140 = load double, double* %18
%141 = call double @delta_put(double %133, double %134, double %137, double %138, double %139, double %140)
store double %141, double* %23
%142 = load double, double* %20
%143 = load double, double* %21
%144 = fsub double %142, %143
store double %144, double* %24
%145 = load double, double* %22
%146 = load double, double* %23
%147 = fsub double %145, %146
store double %147, double* %25
br label %96
148: ; preds = %96
%149 = load double, double* %19
ret double %149
}

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