#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 exp(double);
double fabs(double);
double gammln(double);
double log(double);
void gamma_continued_frac(double *gammcf, double a, double x, double *gln) {
  int i;
  double an, b, c, d, del, h;
  *gln = gammln(a);
  b = x + 1.0 - a;
  c = 1.0 / 1.0e-30;
  d = 1.0 / b;
  h = d;
  for (i = 1; i <= 100; i++) {
    an = -i * (i - a);
    b += 2.0;
    d = an * d + b;
    if (fabs(d) < 1.0e-30)
      d = 1.0e-30;
    c = b + an / c;
    if (fabs(c) < 1.0e-30)
      c = 1.0e-30;
    d = 1.0 / d;
    del = d * c;
    h *= del;
    if (fabs(del - 1.0) < 3.0e-7)
      break;
  }
  if (i > 100)
    *gammcf = exp(-x + a * log(x) - (*gln)) * h;
}


x86 assembly (clang, -O0):
<gamma_continued_frac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <gammln@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe9c(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8d(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe78(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jg     12e3 <gamma_continued_frac+0x1b3>
xor    %eax,%eax
sub    -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe47(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movaps 0xe2d(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe01(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1226 <gamma_continued_frac+0xf6>
movsd  0xdef(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
divsd  -0x40(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movaps 0xde6(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdba(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    126d <gamma_continued_frac+0x13d>
movsd  0xda8(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd8b(%rip),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  0xd56(%rip),%xmm0
subsd  %xmm0,%xmm1
movaps 0xd7b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd5f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12d0 <gamma_continued_frac+0x1a0>
jmp    12e3 <gamma_continued_frac+0x1b3>
jmp    12d5 <gamma_continued_frac+0x1a5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a3 <gamma_continued_frac+0x73>
cmpl   $0x64,-0x24(%rbp)
jle    1351 <gamma_continued_frac+0x221>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
call   1030 <exp@plt>
mulsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gamma_continued_frac>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
call   1050 <gammln@plt>
movsd  (%rsp),%xmm14
movsd  %xmm0,(%rbx)
movsd  0xea0(%rip),%xmm8
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm13
addsd  %xmm8,%xmm1
subsd  %xmm14,%xmm1
movapd %xmm8,%xmm4
divsd  %xmm1,%xmm4
movsd  0xe81(%rip),%xmm12
mov    $0x1,%eax
mov    $0xffffffff,%ecx
movsd  0xe76(%rip),%xmm9
movapd 0xe8e(%rip),%xmm0
movsd  0xe6e(%rip),%xmm5
movsd  0xe6d(%rip),%xmm10
movapd 0xe74(%rip),%xmm11
movsd  0xe63(%rip),%xmm15
movapd %xmm4,%xmm6
movapd %xmm12,%xmm2
xchg   %ax,%ax
xorps  %xmm3,%xmm3
cvtsi2sd %ecx,%xmm3
xorps  %xmm7,%xmm7
cvtsi2sd %eax,%xmm7
subsd  %xmm14,%xmm7
mulsd  %xmm3,%xmm7
addsd  %xmm9,%xmm1
mulsd  %xmm7,%xmm6
movapd %xmm6,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm3,%xmm6
andpd  %xmm0,%xmm6
ucomisd %xmm6,%xmm5
movapd %xmm12,%xmm6
ja     1214 <gamma_continued_frac+0xe4>
movapd %xmm8,%xmm6
divsd  %xmm3,%xmm6
divsd  %xmm2,%xmm7
addsd  %xmm1,%xmm7
movapd %xmm7,%xmm2
andpd  %xmm0,%xmm2
cmpltsd %xmm5,%xmm2
movapd %xmm2,%xmm3
andnpd %xmm7,%xmm3
andpd  %xmm5,%xmm2
orpd   %xmm3,%xmm2
movapd %xmm6,%xmm7
mulsd  %xmm2,%xmm7
movapd %xmm7,%xmm3
addsd  %xmm10,%xmm3
andpd  %xmm11,%xmm3
ucomisd %xmm3,%xmm15
ja     129c <gamma_continued_frac+0x16c>
mulsd  %xmm7,%xmm4
add    $0x1,%eax
add    $0xffffffff,%ecx
cmp    $0xffffff9b,%ecx
jne    11d0 <gamma_continued_frac+0xa0>
movapd %xmm13,%xmm0
movsd  %xmm4,0x10(%rsp)
call   1040 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  (%rbx),%xmm0
call   1030 <exp@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @gamma_continued_frac(double* %0, double %1, double %2, double* %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%16 = load double, double* %6
%17 = call double @gammln(double %16)
%18 = load double*, double** %8
store double %17, double* %18
%19 = load double, double* %7
%20 = fadd double %19, 1.000000e+00
%21 = load double, double* %6
%22 = fsub double %20, %21
store double %22, double* %11
store double 0x46293E5939A08CE9, double* %12
%23 = load double, double* %11
%24 = fdiv double 1.000000e+00, %23
store double %24, double* %13
%25 = load double, double* %13
store double %25, double* %15
store i32 1, i32* %9
br label %26
26: ; preds = %73, %4
%27 = load i32, i32* %9
%28 = icmp sle i32 %27, 100
br i1 %28, label %29, label %76
29: ; preds = %26
%30 = load i32, i32* %9
%31 = sub nsw i32 0, %30
%32 = sitofp i32 %31 to double
%33 = load i32, i32* %9
%34 = sitofp i32 %33 to double
%35 = load double, double* %6
%36 = fsub double %34, %35
%37 = fmul double %32, %36
store double %37, double* %10
%38 = load double, double* %11
%39 = fadd double %38, 2.000000e+00
store double %39, double* %11
%40 = load double, double* %10
%41 = load double, double* %13
%42 = load double, double* %11
%43 = call double @llvm.fmuladd.f64(double %40, double %41, double %42)
store double %43, double* %13
%44 = load double, double* %13
%45 = call double @llvm.fabs.f64(double %44)
%46 = fcmp olt double %45, 1.000000e-30
br i1 %46, label %47, label %48
47: ; preds = %29
store double 1.000000e-30, double* %13
br label %48
48: ; preds = %47, %29
%49 = load double, double* %11
%50 = load double, double* %10
%51 = load double, double* %12
%52 = fdiv double %50, %51
%53 = fadd double %49, %52
store double %53, double* %12
%54 = load double, double* %12
%55 = call double @llvm.fabs.f64(double %54)
%56 = fcmp olt double %55, 1.000000e-30
br i1 %56, label %57, label %58
57: ; preds = %48
store double 1.000000e-30, double* %12
br label %58
58: ; preds = %57, %48
%59 = load double, double* %13
%60 = fdiv double 1.000000e+00, %59
store double %60, double* %13
%61 = load double, double* %13
%62 = load double, double* %12
%63 = fmul double %61, %62
store double %63, double* %14
%64 = load double, double* %14
%65 = load double, double* %15
%66 = fmul double %65, %64
store double %66, double* %15
%67 = load double, double* %14
%68 = fsub double %67, 1.000000e+00
%69 = call double @llvm.fabs.f64(double %68)
%70 = fcmp olt double %69, 3.000000e-07
br i1 %70, label %71, label %72
71: ; preds = %58
br label %76
72: ; preds = %58
br label %73
73: ; preds = %72
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %26
76: ; preds = %71, %26
%77 = load i32, i32* %9
%78 = icmp sgt i32 %77, 100
br i1 %78, label %79, label %93
79: ; preds = %76
%80 = load double, double* %7
%81 = fneg double %80
%82 = load double, double* %6
%83 = load double, double* %7
%84 = call double @log(double %83)
%85 = call double @llvm.fmuladd.f64(double %82, double %84, double %81)
%86 = load double*, double** %8
%87 = load double, double* %86
%88 = fsub double %85, %87
%89 = call double @exp(double %88)
%90 = load double, double* %15
%91 = fmul double %89, %90
%92 = load double*, double** %5
store double %91, double* %92
br label %93
93: ; preds = %79, %76
ret void
}

LLVM IR (-O2):
define void @gamma_continued_frac(double* nocapture writeonly %0, double %1, double %2, double* nocapture %3) {
%5 = tail call double @gammln(double %1)
store double %5, double* %3
%6 = fadd double %2, 1.000000e+00
%7 = fsub double %6, %1
%8 = fdiv double 1.000000e+00, %7
br label %9
9: ; preds = %4, %35
%10 = phi double [ %8, %4 ], [ %36, %35 ]
%11 = phi i32 [ 1, %4 ], [ %37, %35 ]
%12 = phi double [ %8, %4 ], [ %30, %35 ]
%13 = phi double [ 0x46293E5939A08CE9, %4 ], [ %28, %35 ]
%14 = phi double [ %7, %4 ], [ %20, %35 ]
%15 = sub nsw i32 0, %11
%16 = sitofp i32 %15 to double
%17 = sitofp i32 %11 to double
%18 = fsub double %17, %1
%19 = fmul double %18, %16
%20 = fadd double %14, 2.000000e+00
%21 = tail call double @llvm.fmuladd.f64(double %19, double %12, double %20)
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fcmp olt double %22, 1.000000e-30
%24 = fdiv double %19, %13
%25 = fadd double %20, %24
%26 = tail call double @llvm.fabs.f64(double %25)
%27 = fcmp olt double %26, 1.000000e-30
%28 = select i1 %27, double 1.000000e-30, double %25
%29 = fdiv double 1.000000e+00, %21
%30 = select i1 %23, double 0x46293E5939A08CE9, double %29
%31 = fmul double %30, %28
%32 = fadd double %31, -1.000000e+00
%33 = tail call double @llvm.fabs.f64(double %32)
%34 = fcmp olt double %33, 3.000000e-07
br i1 %34, label %47, label %35
35: ; preds = %9
%36 = fmul double %10, %31
%37 = add nuw nsw i32 %11, 1
%38 = icmp eq i32 %37, 101
br i1 %38, label %39, label %9
39: ; preds = %35
%40 = fneg double %2
%41 = tail call double @log(double %2)
%42 = tail call double @llvm.fmuladd.f64(double %1, double %41, double %40)
%43 = load double, double* %3
%44 = fsub double %42, %43
%45 = tail call double @exp(double %44)
%46 = fmul double %36, %45
store double %46, double* %0
br label %47
47: ; preds = %9, %39
ret void
}