double log_btiln(double a, double b, double n) {
  double b1 = b - 1.;
  int i;
  int niter = ceil(log(1e8) / log(2));
  double umin = 0., umax = 1., u = 0.5;
  double un;
  for (i = 0; i < niter; i++) {
    un = pow(u, n);
    double fprim = a / u - b1 * (1. / (1. - u) - (n + 1) * un / (1. - un * u));
    if (fprim > 0)
      umin = u;
    else
      umax = u;
    u = (umin + umax) / 2.;
  }
  double neg_fsecund = a / u / u + b * (1. / (1. - u) / (1. - u) -
                                        (n + 1.) * (n * un / u + un * un) /
                                            (1 - un * u) / (1 - un * u));
  double f = a * log(u) - (b1) * (log(1 - un * u) - log(1 - u));
  return (f - log(neg_fsecund / 2. / 3.1416) * 0.5);
}


x86 assembly (clang, -O0):
<log_btiln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeb1(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb0(%rip),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  0xe96(%rip),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe4c(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12cb <log_btiln+0x19b>
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm1
divsd  -0x40(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe11(%rip),%xmm3
subsd  -0x40(%rbp),%xmm3
movsd  0xe04(%rip),%xmm2
divsd  %xmm3,%xmm2
movsd  0xdf8(%rip),%xmm3
addsd  -0x18(%rbp),%xmm3
mulsd  -0x48(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm4
movsd  0xdc1(%rip),%xmm5
addsd  %xmm5,%xmm4
divsd  %xmm4,%xmm3
subsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1298 <log_btiln+0x168>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12a2 <log_btiln+0x172>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xd5c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c0 <log_btiln+0x90>
movsd  -0x8(%rbp),%xmm1
divsd  -0x40(%rbp),%xmm1
divsd  -0x40(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xd21(%rip),%xmm3
subsd  -0x40(%rbp),%xmm3
movsd  0xd14(%rip),%xmm2
divsd  %xmm3,%xmm2
movsd  0xd08(%rip),%xmm3
subsd  -0x40(%rbp),%xmm3
divsd  %xmm3,%xmm2
movsd  0xcf7(%rip),%xmm3
addsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm5
mulsd  -0x48(%rbp),%xmm5
divsd  -0x40(%rbp),%xmm5
movsd  -0x48(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm3
movsd  -0x48(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm4
movsd  0xca0(%rip),%xmm5
addsd  %xmm5,%xmm4
divsd  %xmm4,%xmm3
movsd  -0x48(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm4
movsd  0xc6b(%rip),%xmm5
addsd  %xmm5,%xmm4
divsd  %xmm4,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xbff(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xbe6(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x90(%rbp),%xmm3
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
movaps %xmm0,%xmm4
movsd  -0x78(%rbp),%xmm0
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xb84(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xb88(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movsd  -0x70(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xb3b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_btiln>:
push   %rbx
sub    $0x70,%rsp
movsd  %xmm0,0x18(%rsp)
movsd  0xecd(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
addsd  %xmm1,%xmm0
movsd  0xec3(%rip),%xmm3
movsd  %xmm2,0x38(%rsp)
movapd %xmm2,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm1,0x50(%rsp)
xorpd  0xecf(%rip),%xmm0
movapd %xmm0,0x60(%rsp)
movsd  0xea1(%rip),%xmm4
mov    $0x1b,%ebx
xorpd  %xmm1,%xmm1
movapd %xmm3,%xmm2
jmp    11b4 <log_btiln+0x94>
xchg   %ax,%ax
xorpd  %xmm3,%xmm3
cmpltsd %xmm2,%xmm3
movapd 0x40(%rsp),%xmm2
andpd  %xmm3,%xmm2
andnpd %xmm4,%xmm3
orpd   %xmm3,%xmm2
movapd %xmm2,%xmm4
addsd  %xmm1,%xmm4
mulsd  0xe65(%rip),%xmm4
add    $0xffffffff,%ebx
je     1253 <log_btiln+0x133>
movsd  %xmm1,0x20(%rsp)
movapd %xmm2,0x40(%rsp)
movapd %xmm4,(%rsp)
movapd %xmm4,%xmm0
movsd  0x38(%rsp),%xmm1
call   1040 <pow@plt>
movsd  0x18(%rsp),%xmm1
divsd  (%rsp),%xmm1
movsd  0xe21(%rip),%xmm5
movapd %xmm5,%xmm3
subsd  (%rsp),%xmm3
movapd 0x50(%rsp),%xmm4
mulsd  %xmm0,%xmm4
movapd %xmm0,%xmm2
mulsd  (%rsp),%xmm2
subsd  %xmm2,%xmm5
unpcklpd %xmm5,%xmm3
movapd 0xe2d(%rip),%xmm2
unpcklpd %xmm4,%xmm2
movapd (%rsp),%xmm4
divpd  %xmm3,%xmm2
movapd %xmm2,%xmm3
unpckhpd %xmm2,%xmm3
subsd  %xmm3,%xmm2
mulsd  0x60(%rsp),%xmm2
addsd  %xmm1,%xmm2
ucomisd 0xde2(%rip),%xmm2
movapd %xmm4,%xmm1
ja     1180 <log_btiln+0x60>
movsd  0x20(%rsp),%xmm1
jmp    1180 <log_btiln+0x60>
movapd 0xdd5(%rip),%xmm5
xorpd  %xmm0,%xmm5
movsd  0x18(%rsp),%xmm1
divsd  %xmm4,%xmm1
divsd  %xmm4,%xmm1
movsd  0xd93(%rip),%xmm6
movsd  0x38(%rsp),%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm4,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
movapd 0x50(%rsp),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm4,%xmm5
addsd  %xmm6,%xmm5
movapd %xmm5,0x20(%rsp)
subsd  %xmm4,%xmm6
movapd %xmm6,%xmm0
movapd %xmm6,0x40(%rsp)
movapd 0xd87(%rip),%xmm2
unpcklpd %xmm3,%xmm2
unpcklpd %xmm5,%xmm0
divpd  %xmm0,%xmm2
divpd  %xmm0,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
subsd  %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm4,%xmm0
call   1030 <log@plt>
movsd  %xmm0,(%rsp)
movaps 0x20(%rsp),%xmm0
call   1030 <log@plt>
movsd  %xmm0,0x20(%rsp)
movapd 0x40(%rsp),%xmm0
call   1030 <log@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0x60(%rsp),%xmm1
movsd  (%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xccc(%rip),%xmm0
divsd  0xccc(%rip),%xmm0
call   1030 <log@plt>
mulsd  0xcb7(%rip),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @log_btiln(double %0, double %1, double %2) {
%4 = fadd double %1, -1.000000e+00
%5 = fadd double %2, 1.000000e+00
%6 = fneg double %4
br label %7
7: ; preds = %3, %7
%8 = phi i32 [ 0, %3 ], [ %31, %7 ]
%9 = phi double [ 0.000000e+00, %3 ], [ %28, %7 ]
%10 = phi double [ 1.000000e+00, %3 ], [ %27, %7 ]
%11 = phi double [ 5.000000e-01, %3 ], [ %30, %7 ]
%12 = tail call double @pow(double %11, double %2)
%13 = fdiv double %0, %11
%14 = fsub double 1.000000e+00, %11
%15 = fmul double %5, %12
%16 = fneg double %12
%17 = tail call double @llvm.fmuladd.f64(double %16, double %11, double 1.000000e+00)
%18 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %15, i64 1
%19 = insertelement <2 x double> poison, double %14, i64 0
%20 = insertelement <2 x double> %19, double %17, i64 1
%21 = fdiv <2 x double> %18, %20
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%23 = fsub <2 x double> %21, %22
%24 = extractelement <2 x double> %23, i64 0
%25 = tail call double @llvm.fmuladd.f64(double %6, double %24, double %13)
%26 = fcmp ogt double %25, 0.000000e+00
%27 = select i1 %26, double %10, double %11
%28 = select i1 %26, double %11, double %9
%29 = fadd double %28, %27
%30 = fmul double %29, 5.000000e-01
%31 = add nuw nsw i32 %8, 1
%32 = icmp eq i32 %31, 27
br i1 %32, label %33, label %7
33: ; preds = %7
%34 = fdiv double %0, %30
%35 = fdiv double %34, %30
%36 = fsub double 1.000000e+00, %30
%37 = fmul double %12, %2
%38 = fdiv double %37, %30
%39 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %38)
%40 = fmul double %5, %39
%41 = tail call double @llvm.fmuladd.f64(double %16, double %30, double 1.000000e+00)
%42 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %40, i64 1
%43 = insertelement <2 x double> poison, double %36, i64 0
%44 = insertelement <2 x double> %43, double %41, i64 1
%45 = fdiv <2 x double> %42, %44
%46 = fdiv <2 x double> %45, %44
%47 = shufflevector <2 x double> %46, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%48 = fsub <2 x double> %46, %47
%49 = extractelement <2 x double> %48, i64 0
%50 = tail call double @llvm.fmuladd.f64(double %1, double %49, double %35)
%51 = tail call double @log(double %30)
%52 = tail call double @log(double %41)
%53 = tail call double @log(double %36)
%54 = fsub double %52, %53
%55 = fmul double %54, %6
%56 = tail call double @llvm.fmuladd.f64(double %0, double %51, double %55)
%57 = fmul double %50, 5.000000e-01
%58 = fdiv double %57, 3.141600e+00
%59 = tail call double @log(double %58)
%60 = fneg double %59
%61 = tail call double @llvm.fmuladd.f64(double %60, double 5.000000e-01, double %56)
ret double %61
}