#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 CriticalPart2(int, double, double, double, double);
double CriticalPart3(int, double, double, double, double);
double const fabs(double);
double CriticalPrice(int id, double I1, double t1, double T2, double v,
                     double q) {
  double result;
  double Ii = I1;
  double yi = CriticalPart3(id, Ii, t1, T2, v);
  double di = CriticalPart2(id, Ii, t1, T2, v);
  const double epsilon = 0.00001;
  while (fabs(yi - q) > epsilon) {
    Ii = Ii - (yi - q) / di;
    yi = CriticalPart3(id, Ii, t1, T2, v);
    di = CriticalPart2(id, Ii, t1, T2, v);
  }
  result = Ii;
  return result;
}


x86 assembly (clang, -O0):
<CriticalPrice>:
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  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1050 <CriticalPart3@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1030 <CriticalPart2@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1232 <CriticalPrice+0x102>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1050 <CriticalPart3@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1030 <CriticalPart2@plt>
movsd  %xmm0,-0x50(%rbp)
jmp    11ad <CriticalPrice+0x7d>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CriticalPrice>:
push   %rbx
sub    $0x40,%rsp
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
call   1040 <CriticalPart3@plt>
movaps %xmm0,0x30(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1030 <CriticalPart2@plt>
movapd 0x30(%rsp),%xmm3
movsd  0x28(%rsp),%xmm2
subsd  %xmm2,%xmm3
movapd 0xe7a(%rip),%xmm1
andpd  %xmm3,%xmm1
ucomisd 0xe7e(%rip),%xmm1
jbe    1218 <CriticalPrice+0xf8>
nopl   0x0(%rax,%rax,1)
divsd  %xmm0,%xmm3
movsd  0x8(%rsp),%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1040 <CriticalPart3@plt>
movapd %xmm0,0x30(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1030 <CriticalPart2@plt>
movapd 0x30(%rsp),%xmm3
movsd  0x28(%rsp),%xmm2
subsd  %xmm2,%xmm3
movapd %xmm3,%xmm1
andpd  0xdf2(%rip),%xmm1
ucomisd 0xdfa(%rip),%xmm1
ja     11a0 <CriticalPrice+0x80>
movsd  0x8(%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @CriticalPrice(i32 %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca double
%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
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%18 = load double, double* %8
store double %18, double* %14
%19 = load i32, i32* %7
%20 = load double, double* %14
%21 = load double, double* %9
%22 = load double, double* %10
%23 = load double, double* %11
%24 = call double @CriticalPart3(i32 %19, double %20, double %21, double %22, double %23)
store double %24, double* %15
%25 = load i32, i32* %7
%26 = load double, double* %14
%27 = load double, double* %9
%28 = load double, double* %10
%29 = load double, double* %11
%30 = call double @CriticalPart2(i32 %25, double %26, double %27, double %28, double %29)
store double %30, double* %16
store double 1.000000e-05, double* %17
br label %31
31: ; preds = %37, %6
%32 = load double, double* %15
%33 = load double, double* %12
%34 = fsub double %32, %33
%35 = call double @fabs(double %34)
%36 = fcmp ogt double %35, 1.000000e-05
br i1 %36, label %37, label %57
37: ; preds = %31
%38 = load double, double* %14
%39 = load double, double* %15
%40 = load double, double* %12
%41 = fsub double %39, %40
%42 = load double, double* %16
%43 = fdiv double %41, %42
%44 = fsub double %38, %43
store double %44, double* %14
%45 = load i32, i32* %7
%46 = load double, double* %14
%47 = load double, double* %9
%48 = load double, double* %10
%49 = load double, double* %11
%50 = call double @CriticalPart3(i32 %45, double %46, double %47, double %48, double %49)
store double %50, double* %15
%51 = load i32, i32* %7
%52 = load double, double* %14
%53 = load double, double* %9
%54 = load double, double* %10
%55 = load double, double* %11
%56 = call double @CriticalPart2(i32 %51, double %52, double %53, double %54, double %55)
store double %56, double* %16
br label %31
57: ; preds = %31
%58 = load double, double* %14
store double %58, double* %13
%59 = load double, double* %13
ret double %59
}

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