#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 fabs(double);
double rq_pricing_blackscholes_delta(int, double, double, double, double,
                                     double, double, double);
double rq_pricing_blackscholes_gen(int, double, double, double, double, double,
                                   double);
double critical_value(int call, double X_inner, double X_outer, double T,
                      double r, double b, double v) {
  double Si;
  double ci;
  double di;
  double epsilon;
  Si = X_inner;
  ci = rq_pricing_blackscholes_gen(call, Si, X_inner, T, r, b, v);
  di = rq_pricing_blackscholes_delta(call, Si, X_inner, r, b, v, T, T);
  epsilon = 0.000001;
  while (fabs(ci - X_outer) > epsilon) {
    Si = Si - (ci - X_outer) / di;
    ci = rq_pricing_blackscholes_gen(call, Si, X_inner, T, r, b, v);
    di = rq_pricing_blackscholes_delta(call, Si, X_inner, r, b, v, T, T);
  }
  return Si;
}


x86 assembly (clang, -O0):
<critical_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
call   1030 <rq_pricing_blackscholes_gen@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x20(%rbp),%xmm5
movsd  -0x20(%rbp),%xmm6
call   1040 <rq_pricing_blackscholes_delta@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xe4a(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xe44(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1258 <critical_value+0x138>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
call   1030 <rq_pricing_blackscholes_gen@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x20(%rbp),%xmm5
movsd  -0x20(%rbp),%xmm6
call   1040 <rq_pricing_blackscholes_delta@plt>
movsd  %xmm0,-0x50(%rbp)
jmp    11bb <critical_value+0x9b>
movsd  -0x40(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<critical_value>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
movaps %xmm0,%xmm1
call   1030 <rq_pricing_blackscholes_gen@plt>
movaps %xmm0,0x40(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
movsd  0x30(%rsp),%xmm4
movsd  0x18(%rsp),%xmm5
movaps %xmm5,%xmm6
call   1040 <rq_pricing_blackscholes_delta@plt>
movapd 0x40(%rsp),%xmm3
movsd  0x38(%rsp),%xmm2
subsd  %xmm2,%xmm3
movapd 0xe64(%rip),%xmm1
andpd  %xmm3,%xmm1
ucomisd 0xe68(%rip),%xmm1
jbe    1259 <critical_value+0x139>
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
divsd  %xmm0,%xmm3
movsd  0x10(%rsp),%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
movsd  0x30(%rsp),%xmm5
call   1030 <rq_pricing_blackscholes_gen@plt>
movapd %xmm0,0x40(%rsp)
mov    %ebx,%edi
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
movsd  0x30(%rsp),%xmm4
movsd  0x18(%rsp),%xmm5
movaps %xmm5,%xmm6
call   1040 <rq_pricing_blackscholes_delta@plt>
movapd 0x40(%rsp),%xmm3
movsd  0x38(%rsp),%xmm2
subsd  %xmm2,%xmm3
movapd %xmm3,%xmm1
andpd  0xdb7(%rip),%xmm1
ucomisd 0xdbf(%rip),%xmm1
ja     11c0 <critical_value+0xa0>
jmp    1265 <critical_value+0x145>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @critical_value(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
%16 = alloca double
%17 = alloca double
%18 = 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
%19 = load double, double* %9
store double %19, double* %15
%20 = load i32, i32* %8
%21 = load double, double* %15
%22 = load double, double* %9
%23 = load double, double* %11
%24 = load double, double* %12
%25 = load double, double* %13
%26 = load double, double* %14
%27 = call double @rq_pricing_blackscholes_gen(i32 %20, double %21, double %22, double %23, double %24, double %25, double %26)
store double %27, double* %16
%28 = load i32, i32* %8
%29 = load double, double* %15
%30 = load double, double* %9
%31 = load double, double* %12
%32 = load double, double* %13
%33 = load double, double* %14
%34 = load double, double* %11
%35 = load double, double* %11
%36 = call double @rq_pricing_blackscholes_delta(i32 %28, double %29, double %30, double %31, double %32, double %33, double %34, double %35)
store double %36, double* %17
store double 0x3EB0C6F7A0B5ED8D, double* %18
br label %37
37: ; preds = %44, %7
%38 = load double, double* %16
%39 = load double, double* %10
%40 = fsub double %38, %39
%41 = call double @llvm.fabs.f64(double %40)
%42 = load double, double* %18
%43 = fcmp ogt double %41, %42
br i1 %43, label %44, label %69
44: ; preds = %37
%45 = load double, double* %15
%46 = load double, double* %16
%47 = load double, double* %10
%48 = fsub double %46, %47
%49 = load double, double* %17
%50 = fdiv double %48, %49
%51 = fsub double %45, %50
store double %51, double* %15
%52 = load i32, i32* %8
%53 = load double, double* %15
%54 = load double, double* %9
%55 = load double, double* %11
%56 = load double, double* %12
%57 = load double, double* %13
%58 = load double, double* %14
%59 = call double @rq_pricing_blackscholes_gen(i32 %52, double %53, double %54, double %55, double %56, double %57, double %58)
store double %59, double* %16
%60 = load i32, i32* %8
%61 = load double, double* %15
%62 = load double, double* %9
%63 = load double, double* %12
%64 = load double, double* %13
%65 = load double, double* %14
%66 = load double, double* %11
%67 = load double, double* %11
%68 = call double @rq_pricing_blackscholes_delta(i32 %60, double %61, double %62, double %63, double %64, double %65, double %66, double %67)
store double %68, double* %17
br label %37
69: ; preds = %37
%70 = load double, double* %15
ret double %70
}

LLVM IR (-O2):
define double @critical_value(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = tail call double @rq_pricing_blackscholes_gen(i32 %0, double %1, double %1, double %3, double %4, double %5, double %6)
%9 = tail call double @rq_pricing_blackscholes_delta(i32 %0, double %1, double %1, double %4, double %5, double %6, double %3, double %3)
%10 = fsub double %8, %2
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fcmp ogt double %11, 0x3EB0C6F7A0B5ED8D
br i1 %12, label %13, label %24
13: ; preds = %7, %13
%14 = phi double [ %21, %13 ], [ %10, %7 ]
%15 = phi double [ %18, %13 ], [ %1, %7 ]
%16 = phi double [ %20, %13 ], [ %9, %7 ]
%17 = fdiv double %14, %16
%18 = fsub double %15, %17
%19 = tail call double @rq_pricing_blackscholes_gen(i32 %0, double %18, double %1, double %3, double %4, double %5, double %6)
%20 = tail call double @rq_pricing_blackscholes_delta(i32 %0, double %18, double %1, double %4, double %5, double %6, double %3, double %3)
%21 = fsub double %19, %2
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fcmp ogt double %22, 0x3EB0C6F7A0B5ED8D
br i1 %23, label %13, label %24
24: ; preds = %13, %7
%25 = phi double [ %1, %7 ], [ %18, %13 ]
ret double %25
}