#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 fnkCa(double, double, double, double, double, double, double, double,
             double, double);
double finddCa(double dCa0, double pH0, double Ca, double M, double P,
               double K1, double K2, double Kw, double Ks, double f0,
               double IB0) {
  double dCaa, fnka, df, ddCa;
  double tol = 1e-3;
  int iter = 0;
  int itermax = 50;
  double fnk = fnkCa(dCa0, pH0, M, P, K1, K2, Kw, Ks, f0, IB0) - Ca;
  double dCa = dCa0;
  dCa0 = dCa + 1;
  while ((fabs(dCa - dCa0) > tol) && (iter <= itermax)) {
    iter = iter + 1;
    dCa0 = dCa;
    if (dCa != 0) {
      ddCa = dCa * tol;
    } else {
      ddCa = tol;
    }
    dCaa = dCa - ddCa;
    fnka = fnkCa(dCaa, pH0, M, P, K1, K2, Kw, Ks, f0, IB0) - Ca;
    df = (fnk - fnka) / (dCa - dCaa);
    if (df == 0) {
      dCa = dCa0 + 1.1 * tol;
    } else {
      dCa = dCa0 - fnk / df;
    }
    fnk = fnkCa(dCa, pH0, M, P, K1, K2, Kw, Ks, f0, IB0) - Ca;
  }
  return dCa;
}


x86 assembly (clang, -O0):
<finddCa>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  0x20(%rbp),%xmm8
movsd  0x18(%rbp),%xmm8
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  0xeab(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x32,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movsd  -0x40(%rbp),%xmm6
movsd  0x10(%rbp),%xmm7
movsd  0x18(%rbp),%xmm9
movsd  0x20(%rbp),%xmm8
movsd  %xmm9,(%rsp)
movsd  %xmm8,0x8(%rsp)
call   1030 <fnkCa@plt>
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xe2e(%rip),%xmm0
addsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x80(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movaps 0xe33(%rip),%xmm1
pand   %xmm1,%xmm0
xor    %eax,%eax
ucomisd -0x68(%rbp),%xmm0
mov    %al,-0x81(%rbp)
jbe    1213 <finddCa+0x103>
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
setle  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    1226 <finddCa+0x116>
jmp    1399 <finddCa+0x289>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x80(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1256 <finddCa+0x146>
jp     1256 <finddCa+0x146>
jmp    126a <finddCa+0x15a>
movsd  -0x80(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1274 <finddCa+0x164>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x80(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movsd  -0x40(%rbp),%xmm6
movsd  0x10(%rbp),%xmm7
movsd  0x18(%rbp),%xmm9
movsd  0x20(%rbp),%xmm8
movsd  %xmm9,(%rsp)
movsd  %xmm8,0x8(%rsp)
call   1030 <fnkCa@plt>
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x78(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    132c <finddCa+0x21c>
jp     132c <finddCa+0x21c>
movsd  -0x8(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  0xcf6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1344 <finddCa+0x234>
movsd  -0x8(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
divsd  -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movsd  -0x40(%rbp),%xmm6
movsd  0x10(%rbp),%xmm7
movsd  0x18(%rbp),%xmm9
movsd  0x20(%rbp),%xmm8
movsd  %xmm9,(%rsp)
movsd  %xmm8,0x8(%rsp)
call   1030 <fnkCa@plt>
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    11dc <finddCa+0xcc>
movsd  -0x80(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finddCa>:
push   %rbx
sub    $0x60,%rsp
movaps %xmm7,%xmm8
movsd  %xmm2,0x50(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0x80(%rsp),%xmm9
movsd  0x78(%rsp),%xmm2
movsd  0x70(%rsp),%xmm7
movsd  %xmm9,0x8(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm3,0x28(%rsp)
movaps %xmm3,%xmm2
movsd  %xmm4,0x30(%rsp)
movaps %xmm4,%xmm3
movsd  %xmm5,0x38(%rsp)
movapd %xmm5,%xmm4
movsd  %xmm6,0x40(%rsp)
movaps %xmm6,%xmm5
movsd  %xmm8,0x48(%rsp)
movaps %xmm8,%xmm6
call   1030 <fnkCa@plt>
movsd  0x10(%rsp),%xmm3
movsd  0xe70(%rip),%xmm1
addsd  %xmm3,%xmm1
movapd %xmm3,%xmm2
subsd  %xmm1,%xmm2
andpd  0xe7c(%rip),%xmm2
ucomisd 0xe5c(%rip),%xmm2
jbe    132f <finddCa+0x21f>
xor    %ebx,%ebx
movsd  0xe4c(%rip),%xmm2
nopl   0x0(%rax)
movsd  %xmm3,0x10(%rsp)
subsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm2,%xmm0
movapd %xmm3,%xmm1
xorpd  %xmm4,%xmm4
cmpneqsd %xmm4,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
subsd  %xmm1,%xmm3
movsd  %xmm3,0x58(%rsp)
movsd  0x80(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x78(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm3,%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
movsd  0x38(%rsp),%xmm4
movsd  0x40(%rsp),%xmm5
movsd  0x48(%rsp),%xmm6
movsd  0x70(%rsp),%xmm7
call   1030 <fnkCa@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
subsd  0x50(%rsp),%xmm0
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
subsd  0x58(%rsp),%xmm0
divsd  %xmm0,%xmm1
ucomisd 0xd9e(%rip),%xmm1
jne    1290 <finddCa+0x180>
jp     1290 <finddCa+0x180>
movapd %xmm2,%xmm9
addsd  0xd84(%rip),%xmm9
jmp    129e <finddCa+0x18e>
xchg   %ax,%ax
divsd  %xmm1,%xmm3
movapd %xmm2,%xmm9
subsd  %xmm3,%xmm9
movsd  0x48(%rsp),%xmm6
movsd  0x40(%rsp),%xmm5
movsd  0x38(%rsp),%xmm4
movsd  0x30(%rsp),%xmm3
movsd  0x28(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
movsd  0x80(%rsp),%xmm0
movsd  0x78(%rsp),%xmm8
movsd  0x70(%rsp),%xmm7
movsd  %xmm9,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm8,(%rsp)
movapd %xmm9,%xmm0
call   1030 <fnkCa@plt>
movsd  0x18(%rsp),%xmm4
movapd %xmm4,%xmm1
subsd  0x10(%rsp),%xmm1
andpd  0xd13(%rip),%xmm1
movsd  0xcf3(%rip),%xmm2
ucomisd %xmm2,%xmm1
jbe    1333 <finddCa+0x223>
lea    0x1(%rbx),%eax
movapd %xmm4,%xmm3
cmp    $0x32,%ebx
mov    %eax,%ebx
jb     11c0 <finddCa+0xb0>
jmp    1333 <finddCa+0x223>
movapd %xmm3,%xmm4
movapd %xmm4,%xmm0
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @finddCa(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10) {
%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
%27 = alloca double
%28 = alloca i32
%29 = alloca i32
%30 = alloca double
%31 = alloca double
store double %0, double* %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double %8, double* %20
store double %9, double* %21
store double %10, double* %22
store double 1.000000e-03, double* %27
store i32 0, i32* %28
store i32 50, i32* %29
%32 = load double, double* %12
%33 = load double, double* %13
%34 = load double, double* %15
%35 = load double, double* %16
%36 = load double, double* %17
%37 = load double, double* %18
%38 = load double, double* %19
%39 = load double, double* %20
%40 = load double, double* %21
%41 = load double, double* %22
%42 = call double @fnkCa(double %32, double %33, double %34, double %35, double %36, double %37, double %38, double %39, double %40, double %41)
%43 = load double, double* %14
%44 = fsub double %42, %43
store double %44, double* %30
%45 = load double, double* %12
store double %45, double* %31
%46 = load double, double* %31
%47 = fadd double %46, 1.000000e+00
store double %47, double* %12
br label %48
48: ; preds = %109, %11
%49 = load double, double* %31
%50 = load double, double* %12
%51 = fsub double %49, %50
%52 = call double @llvm.fabs.f64(double %51)
%53 = load double, double* %27
%54 = fcmp ogt double %52, %53
br i1 %54, label %55, label %59
55: ; preds = %48
%56 = load i32, i32* %28
%57 = load i32, i32* %29
%58 = icmp sle i32 %56, %57
br label %59
59: ; preds = %55, %48
%60 = phi i1 [ false, %48 ], [ %58, %55 ]
br i1 %60, label %61, label %123
61: ; preds = %59
%62 = load i32, i32* %28
%63 = add nsw i32 %62, 1
store i32 %63, i32* %28
%64 = load double, double* %31
store double %64, double* %12
%65 = load double, double* %31
%66 = fcmp une double %65, 0.000000e+00
br i1 %66, label %67, label %71
67: ; preds = %61
%68 = load double, double* %31
%69 = load double, double* %27
%70 = fmul double %68, %69
store double %70, double* %26
br label %73
71: ; preds = %61
%72 = load double, double* %27
store double %72, double* %26
br label %73
73: ; preds = %71, %67
%74 = load double, double* %31
%75 = load double, double* %26
%76 = fsub double %74, %75
store double %76, double* %23
%77 = load double, double* %23
%78 = load double, double* %13
%79 = load double, double* %15
%80 = load double, double* %16
%81 = load double, double* %17
%82 = load double, double* %18
%83 = load double, double* %19
%84 = load double, double* %20
%85 = load double, double* %21
%86 = load double, double* %22
%87 = call double @fnkCa(double %77, double %78, double %79, double %80, double %81, double %82, double %83, double %84, double %85, double %86)
%88 = load double, double* %14
%89 = fsub double %87, %88
store double %89, double* %24
%90 = load double, double* %30
%91 = load double, double* %24
%92 = fsub double %90, %91
%93 = load double, double* %31
%94 = load double, double* %23
%95 = fsub double %93, %94
%96 = fdiv double %92, %95
store double %96, double* %25
%97 = load double, double* %25
%98 = fcmp oeq double %97, 0.000000e+00
br i1 %98, label %99, label %103
99: ; preds = %73
%100 = load double, double* %12
%101 = load double, double* %27
%102 = call double @llvm.fmuladd.f64(double 1.100000e+00, double %101, double %100)
store double %102, double* %31
br label %109
103: ; preds = %73
%104 = load double, double* %12
%105 = load double, double* %30
%106 = load double, double* %25
%107 = fdiv double %105, %106
%108 = fsub double %104, %107
store double %108, double* %31
br label %109
109: ; preds = %103, %99
%110 = load double, double* %31
%111 = load double, double* %13
%112 = load double, double* %15
%113 = load double, double* %16
%114 = load double, double* %17
%115 = load double, double* %18
%116 = load double, double* %19
%117 = load double, double* %20
%118 = load double, double* %21
%119 = load double, double* %22
%120 = call double @fnkCa(double %110, double %111, double %112, double %113, double %114, double %115, double %116, double %117, double %118, double %119)
%121 = load double, double* %14
%122 = fsub double %120, %121
store double %122, double* %30
br label %48
123: ; preds = %59
%124 = load double, double* %31
ret double %124
}

LLVM IR (-O2):
define double @finddCa(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10) {
%12 = tail call double @fnkCa(double %0, double %1, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10)
%13 = fadd double %0, 1.000000e+00
%14 = fsub double %0, %13
%15 = tail call double @llvm.fabs.f64(double %14)
%16 = fcmp ogt double %15, 1.000000e-03
br i1 %16, label %17, label %46
17: ; preds = %11, %38
%18 = phi double [ %40, %38 ], [ %12, %11 ]
%19 = phi double [ %39, %38 ], [ %0, %11 ]
%20 = phi i32 [ %22, %38 ], [ 0, %11 ]
%21 = fsub double %18, %2
%22 = add nuw nsw i32 %20, 1
%23 = fcmp une double %19, 0.000000e+00
%24 = fmul double %19, 1.000000e-03
%25 = select i1 %23, double %24, double 1.000000e-03
%26 = fsub double %19, %25
%27 = tail call double @fnkCa(double %26, double %1, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10)
%28 = fsub double %27, %2
%29 = fsub double %21, %28
%30 = fsub double %19, %26
%31 = fdiv double %29, %30
%32 = fcmp oeq double %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %17
%34 = fadd double %19, 1.100000e-03
br label %38
35: ; preds = %17
%36 = fdiv double %21, %31
%37 = fsub double %19, %36
br label %38
38: ; preds = %35, %33
%39 = phi double [ %34, %33 ], [ %37, %35 ]
%40 = tail call double @fnkCa(double %39, double %1, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10)
%41 = fsub double %39, %19
%42 = tail call double @llvm.fabs.f64(double %41)
%43 = fcmp ogt double %42, 1.000000e-03
%44 = icmp ult i32 %20, 50
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %17, label %46
46: ; preds = %38, %11
%47 = phi double [ %0, %11 ], [ %39, %38 ]
ret double %47
}