#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__ bp_sw_Gammln(double);
int /*<<< orphan*/ bp_sw_fatal(char *);
double exp(scalar_t__);
double fabs(double);
double log(double);
double bp_sw_IncompleteGamma(double a, double x) {
  int iter;
  if (a <= 0.)
    bp_sw_fatal("IncompleteGamma(): a must be > 0");
  if (x < 0.)
    bp_sw_fatal("IncompleteGamma(): x must be >= 0");
  if (x > a + 1) {
    double oldp;
    double nu0, nu1;
    double de0, de1;
    nu0 = 0.;
    de0 = 1.;
    nu1 = 1.;
    de1 = x;
    oldp = nu1;
    for (iter = 1; iter < 100; iter++) {
      nu0 = nu1 + ((double)iter - a) * nu0;
      de0 = de1 + ((double)iter - a) * de0;
      nu1 = x * nu0 + (double)iter * nu1;
      de1 = x * de0 + (double)iter * de1;
      if (de1) {
        nu0 /= de1;
        de0 /= de1;
        nu1 /= de1;
        de1 = 1.;
      }
      if (fabs((nu1 - oldp) / nu1) < 1.e-7)
        return nu1 * exp(a * log(x) - x - bp_sw_Gammln(a));
      oldp = nu1;
    }
    bp_sw_fatal("IncompleteGamma(): failed to converge using continued "
                "fraction approx");
  } else {
    double p;
    double val;
    p = val = 1. / a;
    for (iter = 1; iter < 10000; iter++) {
      val *= x / (a + (double)iter);
      p += val;
      if (fabs(val / p) < 1.e-7)
        return 1. - p * exp(a * log(x) - x - bp_sw_Gammln(a));
    }
    bp_sw_fatal("IncompleteGamma(): failed to converge using series approx");
  }
  return 0.;
}


x86 assembly (clang, -O0):
<bp_sw_IncompleteGamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     116f <bp_sw_IncompleteGamma+0x2f>
lea    0xeb6(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1189 <bp_sw_IncompleteGamma+0x49>
lea    0xebd(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe6a(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    13af <bp_sw_IncompleteGamma+0x26f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe3e(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    139e <bp_sw_IncompleteGamma+0x25e>
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    128d <bp_sw_IncompleteGamma+0x14d>
jp     128d <bp_sw_IncompleteGamma+0x14d>
jmp    12d3 <bp_sw_IncompleteGamma+0x193>
movsd  -0x48(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd32(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
movaps 0xd27(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd13(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1386 <bp_sw_IncompleteGamma+0x246>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <bp_sw_Gammln@plt>
movsd  -0x68(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1508 <bp_sw_IncompleteGamma+0x3c8>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e2 <bp_sw_IncompleteGamma+0xa2>
lea    0xcbe(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
jmp    1500 <bp_sw_IncompleteGamma+0x3c0>
movsd  0xc49(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x2710,-0x1c(%rbp)
jge    14f4 <bp_sw_IncompleteGamma+0x3b4>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm1
divsd  -0x50(%rbp),%xmm1
movaps 0xbf5(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xbe1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    14e1 <bp_sw_IncompleteGamma+0x3a1>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <bp_sw_Gammln@plt>
movsd  -0x80(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xb2d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1508 <bp_sw_IncompleteGamma+0x3c8>
jmp    14e6 <bp_sw_IncompleteGamma+0x3a6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13cd <bp_sw_IncompleteGamma+0x28d>
lea    0xbae(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bp_sw_IncompleteGamma>:
sub    $0x28,%rsp
movapd %xmm1,%xmm12
movapd %xmm0,%xmm11
xorpd  %xmm0,%xmm0
ucomisd %xmm11,%xmm0
movsd  %xmm11,0x8(%rsp)
movsd  %xmm1,(%rsp)
jb     1182 <bp_sw_IncompleteGamma+0x42>
lea    0xeb4(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
xorpd  %xmm0,%xmm0
movsd  (%rsp),%xmm12
movsd  0x8(%rsp),%xmm11
ucomisd %xmm12,%xmm0
jbe    11a2 <bp_sw_IncompleteGamma+0x62>
lea    0xeb1(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
movsd  (%rsp),%xmm12
movsd  0x8(%rsp),%xmm11
movsd  0xe56(%rip),%xmm0
addsd  %xmm11,%xmm0
ucomisd %xmm0,%xmm12
jbe    12a0 <bp_sw_IncompleteGamma+0x160>
mov    $0x1,%eax
xorpd  %xmm9,%xmm9
movsd  0xe33(%rip),%xmm8
movapd 0xe3a(%rip),%xmm10
movsd  0xe2a(%rip),%xmm3
movapd %xmm12,%xmm2
movapd %xmm8,%xmm4
movapd %xmm8,%xmm0
xorpd  %xmm5,%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm0,%xmm7
mulsd  %xmm1,%xmm7
movapd %xmm2,%xmm6
mulsd  %xmm1,%xmm6
subsd  %xmm11,%xmm1
mulsd  %xmm1,%xmm5
addsd  %xmm0,%xmm5
mulsd  %xmm1,%xmm4
addsd  %xmm2,%xmm4
movapd %xmm12,%xmm1
mulsd  %xmm5,%xmm1
addsd  %xmm7,%xmm1
movapd %xmm12,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm6,%xmm2
ucomisd %xmm9,%xmm2
unpcklpd %xmm1,%xmm5
jne    1253 <bp_sw_IncompleteGamma+0x113>
jnp    1264 <bp_sw_IncompleteGamma+0x124>
divsd  %xmm2,%xmm4
unpcklpd %xmm2,%xmm2
divpd  %xmm2,%xmm5
movapd %xmm8,%xmm2
movapd %xmm5,%xmm6
unpckhpd %xmm5,%xmm6
movapd %xmm6,%xmm1
subsd  %xmm0,%xmm1
divsd  %xmm6,%xmm1
andpd  %xmm10,%xmm1
ucomisd %xmm1,%xmm3
ja     1322 <bp_sw_IncompleteGamma+0x1e2>
add    $0x1,%eax
movapd %xmm6,%xmm0
cmp    $0x64,%eax
jne    1200 <bp_sw_IncompleteGamma+0xc0>
lea    0xdc5(%rip),%rdi
jmp    1314 <bp_sw_IncompleteGamma+0x1d4>
movsd  0xd58(%rip),%xmm2
divsd  %xmm11,%xmm2
mov    $0x1,%eax
movapd 0xd56(%rip),%xmm0
movsd  0xd46(%rip),%xmm1
movapd %xmm2,%xmm6
cs nopw 0x0(%rax,%rax,1)
movapd %xmm2,%xmm3
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
addsd  %xmm11,%xmm4
movapd %xmm12,%xmm2
divsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm2,%xmm6
movapd %xmm2,%xmm3
divsd  %xmm6,%xmm3
andpd  %xmm0,%xmm3
ucomisd %xmm3,%xmm1
ja     1375 <bp_sw_IncompleteGamma+0x235>
add    $0x1,%eax
cmp    $0x2710,%eax
jne    12d0 <bp_sw_IncompleteGamma+0x190>
lea    0xd95(%rip),%rdi
call   1040 <bp_sw_fatal@plt>
xorpd  %xmm0,%xmm0
add    $0x28,%rsp
ret
movapd %xmm12,%xmm0
movapd %xmm6,0x10(%rsp)
call   1060 <log@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
call   1030 <bp_sw_Gammln@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1050 <exp@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
ret
movapd %xmm12,%xmm0
movsd  %xmm6,0x10(%rsp)
call   1060 <log@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
call   1030 <bp_sw_Gammln@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1050 <exp@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xc31(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"IncompleteGamma(): a must be > 0\00"
@.str.1 = [34 x i8] c"IncompleteGamma(): x must be >= 0\00"
@.str.2 = [70 x i8] c"IncompleteGamma(): failed to converge using continued fraction approx\00"
@.str.3 = [58 x i8] c"IncompleteGamma(): failed to converge using series approx\00"
define double @bp_sw_IncompleteGamma(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
%13 = alloca double
store double %0, double* %4
store double %1, double* %5
%14 = load double, double* %4
%15 = fcmp ole double %14, 0.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @bp_sw_fatal(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = load double, double* %5
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @bp_sw_fatal(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
%24 = load double, double* %5
%25 = load double, double* %4
%26 = fadd double %25, 1.000000e+00
%27 = fcmp ogt double %24, %26
br i1 %27, label %28, label %105
28: ; preds = %23
store double 0.000000e+00, double* %8
store double 1.000000e+00, double* %10
store double 1.000000e+00, double* %9
%29 = load double, double* %5
store double %29, double* %11
%30 = load double, double* %9
store double %30, double* %7
store i32 1, i32* %6
br label %31
31: ; preds = %100, %28
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 100
br i1 %33, label %34, label %103
34: ; preds = %31
%35 = load double, double* %9
%36 = load i32, i32* %6
%37 = sitofp i32 %36 to double
%38 = load double, double* %4
%39 = fsub double %37, %38
%40 = load double, double* %8
%41 = call double @llvm.fmuladd.f64(double %39, double %40, double %35)
store double %41, double* %8
%42 = load double, double* %11
%43 = load i32, i32* %6
%44 = sitofp i32 %43 to double
%45 = load double, double* %4
%46 = fsub double %44, %45
%47 = load double, double* %10
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double %42)
store double %48, double* %10
%49 = load double, double* %5
%50 = load double, double* %8
%51 = load i32, i32* %6
%52 = sitofp i32 %51 to double
%53 = load double, double* %9
%54 = fmul double %52, %53
%55 = call double @llvm.fmuladd.f64(double %49, double %50, double %54)
store double %55, double* %9
%56 = load double, double* %5
%57 = load double, double* %10
%58 = load i32, i32* %6
%59 = sitofp i32 %58 to double
%60 = load double, double* %11
%61 = fmul double %59, %60
%62 = call double @llvm.fmuladd.f64(double %56, double %57, double %61)
store double %62, double* %11
%63 = load double, double* %11
%64 = fcmp une double %63, 0.000000e+00
br i1 %64, label %65, label %75
65: ; preds = %34
%66 = load double, double* %11
%67 = load double, double* %8
%68 = fdiv double %67, %66
store double %68, double* %8
%69 = load double, double* %11
%70 = load double, double* %10
%71 = fdiv double %70, %69
store double %71, double* %10
%72 = load double, double* %11
%73 = load double, double* %9
%74 = fdiv double %73, %72
store double %74, double* %9
store double 1.000000e+00, double* %11
br label %75
75: ; preds = %65, %34
%76 = load double, double* %9
%77 = load double, double* %7
%78 = fsub double %76, %77
%79 = load double, double* %9
%80 = fdiv double %78, %79
%81 = call double @llvm.fabs.f64(double %80)
%82 = fcmp olt double %81, 0x3E7AD7F29ABCAF48
br i1 %82, label %83, label %98
83: ; preds = %75
%84 = load double, double* %9
%85 = load double, double* %4
%86 = load double, double* %5
%87 = call double @log(double %86)
%88 = load double, double* %5
%89 = fneg double %88
%90 = call double @llvm.fmuladd.f64(double %85, double %87, double %89)
%91 = load double, double* %4
%92 = call i64 @bp_sw_Gammln(double %91)
%93 = sitofp i64 %92 to double
%94 = fsub double %90, %93
%95 = fptosi double %94 to i64
%96 = call double @exp(i64 %95)
%97 = fmul double %84, %96
store double %97, double* %3
br label %151
98: ; preds = %75
%99 = load double, double* %9
store double %99, double* %7
br label %100
100: ; preds = %98
%101 = load i32, i32* %6
%102 = add nsw i32 %101, 1
store i32 %102, i32* %6
br label %31
103: ; preds = %31
%104 = call i32 @bp_sw_fatal(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
br label %150
105: ; preds = %23
%106 = load double, double* %4
%107 = fdiv double 1.000000e+00, %106
store double %107, double* %13
store double %107, double* %12
store i32 1, i32* %6
br label %108
108: ; preds = %145, %105
%109 = load i32, i32* %6
%110 = icmp slt i32 %109, 10000
br i1 %110, label %111, label %148
111: ; preds = %108
%112 = load double, double* %5
%113 = load double, double* %4
%114 = load i32, i32* %6
%115 = sitofp i32 %114 to double
%116 = fadd double %113, %115
%117 = fdiv double %112, %116
%118 = load double, double* %13
%119 = fmul double %118, %117
store double %119, double* %13
%120 = load double, double* %13
%121 = load double, double* %12
%122 = fadd double %121, %120
store double %122, double* %12
%123 = load double, double* %13
%124 = load double, double* %12
%125 = fdiv double %123, %124
%126 = call double @llvm.fabs.f64(double %125)
%127 = fcmp olt double %126, 0x3E7AD7F29ABCAF48
br i1 %127, label %128, label %144
128: ; preds = %111
%129 = load double, double* %12
%130 = load double, double* %4
%131 = load double, double* %5
%132 = call double @log(double %131)
%133 = load double, double* %5
%134 = fneg double %133
%135 = call double @llvm.fmuladd.f64(double %130, double %132, double %134)
%136 = load double, double* %4
%137 = call i64 @bp_sw_Gammln(double %136)
%138 = sitofp i64 %137 to double
%139 = fsub double %135, %138
%140 = fptosi double %139 to i64
%141 = call double @exp(i64 %140)
%142 = fneg double %129
%143 = call double @llvm.fmuladd.f64(double %142, double %141, double 1.000000e+00)
store double %143, double* %3
br label %151
144: ; preds = %111
br label %145
145: ; preds = %144
%146 = load i32, i32* %6
%147 = add nsw i32 %146, 1
store i32 %147, i32* %6
br label %108
148: ; preds = %108
%149 = call i32 @bp_sw_fatal(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %150
150: ; preds = %148, %103
store double 0.000000e+00, double* %3
br label %151
151: ; preds = %150, %128, %83
%152 = load double, double* %3
ret double %152
}

LLVM IR (-O2):
@.str = [33 x i8] c"IncompleteGamma(): a must be > 0\00"
@.str.1 = [34 x i8] c"IncompleteGamma(): x must be >= 0\00"
@.str.2 = [70 x i8] c"IncompleteGamma(): failed to converge using continued fraction approx\00"
@.str.3 = [58 x i8] c"IncompleteGamma(): failed to converge using series approx\00"
define double @bp_sw_IncompleteGamma(double %0, double %1) {
%3 = fcmp ugt double %0, 0.000000e+00
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @bp_sw_fatal(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = fcmp olt double %1, 0.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @bp_sw_fatal(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = fadd double %0, 1.000000e+00
%12 = fcmp olt double %11, %1
br i1 %12, label %17, label %60
13: ; preds = %39
%14 = add nuw nsw i32 %22, 1
%15 = icmp eq i32 %14, 100
%16 = extractelement <2 x double> %42, i64 0
br i1 %15, label %58, label %17
17: ; preds = %10, %13
%18 = phi double [ %41, %13 ], [ %1, %10 ]
%19 = phi double [ %40, %13 ], [ 1.000000e+00, %10 ]
%20 = phi double [ %43, %13 ], [ 1.000000e+00, %10 ]
%21 = phi double [ %16, %13 ], [ 0.000000e+00, %10 ]
%22 = phi i32 [ %14, %13 ], [ 1, %10 ]
%23 = sitofp i32 %22 to double
%24 = fsub double %23, %0
%25 = tail call double @llvm.fmuladd.f64(double %24, double %21, double %20)
%26 = tail call double @llvm.fmuladd.f64(double %24, double %19, double %18)
%27 = fmul double %20, %23
%28 = tail call double @llvm.fmuladd.f64(double %1, double %25, double %27)
%29 = fmul double %18, %23
%30 = tail call double @llvm.fmuladd.f64(double %1, double %26, double %29)
%31 = fcmp une double %30, 0.000000e+00
%32 = insertelement <2 x double> poison, double %25, i64 0
%33 = insertelement <2 x double> %32, double %28, i64 1
br i1 %31, label %34, label %39
34: ; preds = %17
%35 = fdiv double %26, %30
%36 = insertelement <2 x double> poison, double %30, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = fdiv <2 x double> %33, %37
br label %39
39: ; preds = %34, %17
%40 = phi double [ %35, %34 ], [ %26, %17 ]
%41 = phi double [ 1.000000e+00, %34 ], [ %30, %17 ]
%42 = phi <2 x double> [ %38, %34 ], [ %33, %17 ]
%43 = extractelement <2 x double> %42, i64 1
%44 = fsub double %43, %20
%45 = fdiv double %44, %43
%46 = tail call double @llvm.fabs.f64(double %45)
%47 = fcmp olt double %46, 0x3E7AD7F29ABCAF48
br i1 %47, label %48, label %13
48: ; preds = %39
%49 = tail call double @log(double %1)
%50 = fneg double %1
%51 = tail call double @llvm.fmuladd.f64(double %0, double %49, double %50)
%52 = tail call i64 @bp_sw_Gammln(double %0)
%53 = sitofp i64 %52 to double
%54 = fsub double %51, %53
%55 = fptosi double %54 to i64
%56 = tail call double @exp(i64 %55)
%57 = fmul double %43, %56
br label %90
58: ; preds = %13
%59 = tail call i32 @bp_sw_fatal(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
br label %90
60: ; preds = %10
%61 = fdiv double 1.000000e+00, %0
br label %65
62: ; preds = %65
%63 = add nuw nsw i32 %68, 1
%64 = icmp eq i32 %63, 10000
br i1 %64, label %88, label %65
65: ; preds = %60, %62
%66 = phi double [ %61, %60 ], [ %72, %62 ]
%67 = phi double [ %61, %60 ], [ %73, %62 ]
%68 = phi i32 [ 1, %60 ], [ %63, %62 ]
%69 = sitofp i32 %68 to double
%70 = fadd double %69, %0
%71 = fdiv double %1, %70
%72 = fmul double %66, %71
%73 = fadd double %67, %72
%74 = fdiv double %72, %73
%75 = tail call double @llvm.fabs.f64(double %74)
%76 = fcmp olt double %75, 0x3E7AD7F29ABCAF48
br i1 %76, label %77, label %62
77: ; preds = %65
%78 = tail call double @log(double %1)
%79 = fneg double %1
%80 = tail call double @llvm.fmuladd.f64(double %0, double %78, double %79)
%81 = tail call i64 @bp_sw_Gammln(double %0)
%82 = sitofp i64 %81 to double
%83 = fsub double %80, %82
%84 = fptosi double %83 to i64
%85 = tail call double @exp(i64 %84)
%86 = fneg double %73
%87 = tail call double @llvm.fmuladd.f64(double %86, double %85, double 1.000000e+00)
br label %90
88: ; preds = %62
%89 = tail call i32 @bp_sw_fatal(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %58, %88, %77, %48
%91 = phi double [ %57, %48 ], [ %87, %77 ], [ 0.000000e+00, %88 ], [ 0.000000e+00, %58 ]
ret double %91
}