#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 */
int /*<<< orphan*/ chiGammaFlagError(char *);
double exp(double);
double fabs(double);
double gammln(double);
double log(double);
void gcf(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 <= 10000000; 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 > 10000000) {
    chiGammaFlagError("a too large, ITMAX too small in gcf");
    return;
  }
  *gammcf = exp(-x + a * log(x) - (*gln)) * h;
}


x86 assembly (clang, -O0):
<gcf>:
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   1060 <gammln@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe8c(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe68(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x989680,-0x24(%rbp)
jg     12f6 <gcf+0x1b6>
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  0xe34(%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 0xe1a(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdee(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1239 <gcf+0xf9>
movsd  0xddc(%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 0xdd3(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xda7(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1280 <gcf+0x140>
movsd  0xd95(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd78(%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  0xd43(%rip),%xmm0
subsd  %xmm0,%xmm1
movaps 0xd68(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd4c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12e3 <gcf+0x1a3>
jmp    12f6 <gcf+0x1b6>
jmp    12e8 <gcf+0x1a8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b3 <gcf+0x73>
cmpl   $0x989680,-0x24(%rbp)
jle    1314 <gcf+0x1d4>
lea    0xd36(%rip),%rdi
call   1030 <chiGammaFlagError@plt>
jmp    1378 <gcf+0x238>
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   1050 <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   1040 <exp@plt>
mulsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcf>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
call   1060 <gammln@plt>
movsd  (%rsp),%xmm14
movsd  %xmm0,(%rbx)
movsd  0xe90(%rip),%xmm8
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm13
addsd  %xmm8,%xmm1
subsd  %xmm14,%xmm1
movapd %xmm8,%xmm4
divsd  %xmm1,%xmm4
movsd  0xe71(%rip),%xmm12
mov    $0x1,%eax
mov    $0xffffffff,%ecx
movsd  0xe66(%rip),%xmm9
movapd 0xe7e(%rip),%xmm0
movsd  0xe5e(%rip),%xmm5
movsd  0xe5d(%rip),%xmm10
movapd 0xe64(%rip),%xmm11
movsd  0xe53(%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     1224 <gcf+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,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm3,%xmm4
addsd  %xmm10,%xmm3
andpd  %xmm11,%xmm3
ucomisd %xmm3,%xmm15
ja     128b <gcf+0x14b>
add    $0x1,%eax
add    $0xffffffff,%ecx
cmp    $0xff67697f,%ecx
jne    11e0 <gcf+0xa0>
lea    0xdc1(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <chiGammaFlagError@plt>
movapd %xmm13,%xmm0
movsd  %xmm4,0x10(%rsp)
call   1050 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  (%rbx),%xmm0
call   1040 <exp@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"a too large, ITMAX too small in gcf\00"
define void @gcf(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, 10000000
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, 10000000
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 @chiGammaFlagError(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %95
81: ; preds = %76
%82 = load double, double* %7
%83 = fneg double %82
%84 = load double, double* %6
%85 = load double, double* %7
%86 = call double @log(double %85)
%87 = call double @llvm.fmuladd.f64(double %84, double %86, double %83)
%88 = load double*, double** %8
%89 = load double, double* %88
%90 = fsub double %87, %89
%91 = call double @exp(double %90)
%92 = load double, double* %15
%93 = fmul double %91, %92
%94 = load double*, double** %5
store double %93, double* %94
br label %95
95: ; preds = %81, %79
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"a too large, ITMAX too small in gcf\00"
define void @gcf(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 %12
9: ; preds = %12
%10 = add nuw nsw i32 %14, 1
%11 = icmp eq i32 %10, 10000001
br i1 %11, label %39, label %12
12: ; preds = %4, %9
%13 = phi double [ %8, %4 ], [ %35, %9 ]
%14 = phi i32 [ 1, %4 ], [ %10, %9 ]
%15 = phi double [ %8, %4 ], [ %33, %9 ]
%16 = phi double [ 0x46293E5939A08CE9, %4 ], [ %31, %9 ]
%17 = phi double [ %7, %4 ], [ %23, %9 ]
%18 = sub nsw i32 0, %14
%19 = sitofp i32 %18 to double
%20 = sitofp i32 %14 to double
%21 = fsub double %20, %1
%22 = fmul double %21, %19
%23 = fadd double %17, 2.000000e+00
%24 = tail call double @llvm.fmuladd.f64(double %22, double %15, double %23)
%25 = tail call double @llvm.fabs.f64(double %24)
%26 = fcmp olt double %25, 1.000000e-30
%27 = fdiv double %22, %16
%28 = fadd double %23, %27
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp olt double %29, 1.000000e-30
%31 = select i1 %30, double 1.000000e-30, double %28
%32 = fdiv double 1.000000e+00, %24
%33 = select i1 %26, double 0x46293E5939A08CE9, double %32
%34 = fmul double %33, %31
%35 = fmul double %13, %34
%36 = fadd double %34, -1.000000e+00
%37 = tail call double @llvm.fabs.f64(double %36)
%38 = fcmp olt double %37, 3.000000e-07
br i1 %38, label %41, label %9
39: ; preds = %9
%40 = tail call i32 @chiGammaFlagError(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %49
41: ; preds = %12
%42 = fneg double %2
%43 = tail call double @log(double %2)
%44 = tail call double @llvm.fmuladd.f64(double %1, double %43, double %42)
%45 = load double, double* %3
%46 = fsub double %44, %45
%47 = tail call double @exp(double %46)
%48 = fmul double %35, %47
store double %48, double* %0
br label %49
49: ; preds = %41, %39
ret void
}