#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 */
scalar_t__ DBL_EPSILON;
double const HUGE_VAL;
int /*<<< orphan*/ assert(int);
double exp(double const);
scalar_t__ fabs(int);
double pow(double const, double const);
double tgamma(double const);
double __attribute__((const)) gamma_contfrac(const double x, const double a) {
  int i;
  double f, c, d, dn, cn, term;
  assert(x >= 0.);
  assert(a > 0.);
  if (x == 0.) {
    return 1.;
  }
  if (x == HUGE_VAL) {
    return 0.;
  }
  f = 1e-300 + 1. / (x + 1. - a);
  c = (x + 1. - a) + 1.e300;
  d = 1. / (x + 1. - a);
  for (i = 1;; i++) {
    dn = (x + 2. * i + 1. - a) - (i * (i - a)) * d;
    if (dn == 0.)
      dn = 1e-300;
    cn = (x + 2. * i + 1. - a) - (i * (i - a)) / c;
    if (cn == 0.)
      cn = 1e-300;
    dn = 1. / dn;
    term = cn * dn;
    f *= term;
    if (fabs(1. - term) < DBL_EPSILON)
      break;
    c = cn;
    d = dn;
  }
  f *= exp(-x) * pow(x, a) / tgamma(a);
  assert(f >= 0. && f <= 1.);
  return f;
}


x86 assembly (clang, -O0):
<gamma_contfrac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11be <gamma_contfrac+0x6e>
jp     11be <gamma_contfrac+0x6e>
movsd  0xe4c(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1474 <gamma_contfrac+0x324>
movsd  -0x10(%rbp),%xmm0
mov    0x2e16(%rip),%rax
ucomisd (%rax),%xmm0
jne    11e7 <gamma_contfrac+0x97>
jp     11e7 <gamma_contfrac+0x97>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1474 <gamma_contfrac+0x324>
movsd  0xe11(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe03(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xde2(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xdd8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdbf(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  0xdad(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd83(%rip),%xmm0
addsd  %xmm0,%xmm1
subsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12e7 <gamma_contfrac+0x197>
jp     12e7 <gamma_contfrac+0x197>
movsd  0xd2e(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xcff(%rip),%xmm1
addsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  -0x30(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1350 <gamma_contfrac+0x200>
jp     1350 <gamma_contfrac+0x200>
movsd  0xcc5(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xca8(%rip),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xc78(%rip),%xmm0
subsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
mov    0x2c4b(%rip),%rcx
cmp    (%rcx),%rax
jge    13ab <gamma_contfrac+0x25b>
jmp    13cd <gamma_contfrac+0x27d>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1263 <gamma_contfrac+0x113>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1060 <exp@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <tgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x51(%rbp)
jb     145d <gamma_contfrac+0x30d>
movsd  0xbae(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
setae  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gamma_contfrac>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,(%rsp)
movapd %xmm0,0x20(%rsp)
xorpd  %xmm1,%xmm1
xor    %edi,%edi
ucomisd %xmm1,%xmm0
setae  %dil
call   1050 <assert@plt>
xor    %edi,%edi
movsd  (%rsp),%xmm0
ucomisd 0xe9c(%rip),%xmm0
seta   %dil
call   1050 <assert@plt>
xorpd  %xmm4,%xmm4
movapd 0x20(%rsp),%xmm3
movsd  0xe61(%rip),%xmm0
ucomisd %xmm4,%xmm3
jne    11ab <gamma_contfrac+0x5b>
jnp    1346 <gamma_contfrac+0x1f6>
movapd %xmm3,%xmm1
addsd  %xmm0,%xmm1
subsd  (%rsp),%xmm1
movapd %xmm0,%xmm5
divsd  %xmm1,%xmm5
movsd  0xe40(%rip),%xmm0
addsd  %xmm5,%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  0xe36(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
mov    $0x1,%ebx
mov    0x2dfc(%rip),%r14
jmp    1268 <gamma_contfrac+0x118>
xchg   %ax,%ax
movsd  %xmm5,0x30(%rsp)
divsd  0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm2
cmpeqsd %xmm4,%xmm2
movapd %xmm2,%xmm1
andnpd %xmm0,%xmm1
movsd  0xdef(%rip),%xmm0
andpd  %xmm0,%xmm2
orpd   %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm5,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <fabs@plt>
movsd  0x30(%rsp),%xmm5
xorpd  %xmm4,%xmm4
add    $0x1,%ebx
cmp    (%r14),%rax
movapd 0x20(%rsp),%xmm3
jl     12c5 <gamma_contfrac+0x175>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
movsd  0xd70(%rip),%xmm3
addsd  %xmm3,%xmm0
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm5
movapd %xmm0,%xmm2
subsd  %xmm5,%xmm2
ucomisd %xmm4,%xmm2
movsd  0xd68(%rip),%xmm5
jne    12b8 <gamma_contfrac+0x168>
jnp    11f0 <gamma_contfrac+0xa0>
movapd %xmm3,%xmm5
divsd  %xmm2,%xmm5
jmp    11f0 <gamma_contfrac+0xa0>
movapd 0xd63(%rip),%xmm0
xorpd  %xmm3,%xmm0
call   1060 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1070 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <tgamma@plt>
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
setae  %al
movsd  0xcd1(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
movsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@HUGE_VAL = constant double 0.000000e+00
@DBL_EPSILON = global i64 0
define double @gamma_contfrac(double %0, double %1) {
%3 = fcmp oge double %0, 0.000000e+00
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = fcmp ogt double %1, 0.000000e+00
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = fcmp oeq double %0, 0.000000e+00
br i1 %9, label %57, label %10
10: ; preds = %2
%11 = fadd double %0, 1.000000e+00
%12 = fsub double %11, %1
%13 = fdiv double 1.000000e+00, %12
%14 = fadd double %13, 1.000000e-300
%15 = fadd double %12, 1.000000e+300
br label %16
16: ; preds = %16, %10
%17 = phi i32 [ 1, %10 ], [ %43, %16 ]
%18 = phi double [ %14, %10 ], [ %37, %16 ]
%19 = phi double [ %15, %10 ], [ %33, %16 ]
%20 = phi double [ %13, %10 ], [ %35, %16 ]
%21 = sitofp i32 %17 to double
%22 = tail call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double %0)
%23 = fadd double %22, 1.000000e+00
%24 = fsub double %23, %1
%25 = fsub double %21, %1
%26 = fmul double %25, %21
%27 = fneg double %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %20, double %24)
%29 = fcmp oeq double %28, 0.000000e+00
%30 = fdiv double %26, %19
%31 = fsub double %24, %30
%32 = fcmp oeq double %31, 0.000000e+00
%33 = select i1 %32, double 1.000000e-300, double %31
%34 = fdiv double 1.000000e+00, %28
%35 = select i1 %29, double 0x7E37E43C8800759B, double %34
%36 = fmul double %33, %35
%37 = fmul double %18, %36
%38 = fsub double 1.000000e+00, %36
%39 = fptosi double %38 to i32
%40 = tail call i64 @fabs(i32 %39)
%41 = load i64, i64* @DBL_EPSILON
%42 = icmp slt i64 %40, %41
%43 = add nuw nsw i32 %17, 1
br i1 %42, label %44, label %16
44: ; preds = %16
%45 = fneg double %0
%46 = tail call double @exp(double %45)
%47 = tail call double @pow(double %0, double %1)
%48 = fmul double %46, %47
%49 = tail call double @tgamma(double %1)
%50 = fdiv double %48, %49
%51 = fmul double %37, %50
%52 = fcmp oge double %51, 0.000000e+00
%53 = fcmp ole double %51, 1.000000e+00
%54 = and i1 %52, %53
%55 = zext i1 %54 to i32
%56 = tail call i32 @assert(i32 %55)
br label %57
57: ; preds = %2, %44
%58 = phi double [ %51, %44 ], [ 1.000000e+00, %2 ]
ret double %58
}