// File: /workspace/github_c_makefile_star2_O2/georgeweigt[P]sassafras/sassafras.c
// Function: incbeta
double
incbeta(double a, double b, double x)
{
	// begin altered source
	// if (x < 0.0 || x > 1.0) return 1.0/0.0;
	if (x <= 0.0)
		return 0.0;
	if (x >= 1.0)
		return 1.0;
	// end altered source

	/*The continued fraction converges nicely for x < (a+1)/(a+b+2)*/
	if (x > (a+1.0)/(a+b+2.0)) {
		return (1.0-incbeta(b,a,1.0-x)); /*Use the fact that beta is symmetrical.*/
	}

	/*Find the first part before the continued fraction.*/
	const double lbeta_ab = lgamma(a)+lgamma(b)-lgamma(a+b);
	const double front = exp(log(x)*a+log(1.0-x)*b-lbeta_ab) / a;

	/*Use Lentz's algorithm to evaluate the continued fraction.*/
	double f = 1.0, c = 1.0, d = 0.0;

	int i, m;
	for (i = 0; i <= 200; ++i) {
		m = i/2;

		double numerator;
		if (i == 0) {
			numerator = 1.0; /*First numerator is 1.0.*/
		} else if (i % 2 == 0) {
			numerator = (m*(b-m)*x)/((a+2.0*m-1.0)*(a+2.0*m)); /*Even term.*/
		} else {
			numerator = -((a+m)*(a+b+m)*x)/((a+2.0*m)*(a+2.0*m+1)); /*Odd term.*/
		}

		/*Do an iteration of Lentz's algorithm.*/
		d = 1.0 + numerator * d;
		if (fabs(d) < TINY) d = TINY;
		d = 1.0 / d;

		c = 1.0 + numerator / c;
		if (fabs(c) < TINY) c = TINY;

		const double cd = c*d;
		f *= cd;

		/*Check for stop.*/
		if (fabs(1.0-cd) < STOP) {
			return front * (f-1.0);
		}
	}

	return 1.0/0.0; /*Needed more loops, did not converge.*/
}

// Assembly:
xorpd %xmm13, %xmm13
ucomisd %xmm2, %xmm13
jae 0x3c8d
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movapd %xmm2, %xmm4
movsd 0x78c9(%rip), %xmm13    # 0xb2c8
ucomisd %xmm13, %xmm2
jae 0x3c88
movapd %xmm0, %xmm3
movsd 0x78b2(%rip), %xmm0     # 0xb2c8
addsd %xmm3, %xmm0
movapd %xmm3, %xmm5
addsd %xmm1, %xmm5
movsd 0x78a6(%rip), %xmm2     # 0xb2d0
addsd %xmm5, %xmm2
divsd %xmm2, %xmm0
ucomisd %xmm0, %xmm4
jbe 0x3a64
movsd 0x7888(%rip), %xmm2     # 0xb2c8
subsd %xmm4, %xmm2
movapd %xmm1, %xmm0
movapd %xmm3, %xmm1
callq 0x39da
movsd 0x786e(%rip), %xmm13    # 0xb2c8
subsd %xmm0, %xmm13
jmp 0x3c88
movapd %xmm3, %xmm0
movsd %xmm3, -0x20(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm4, -0x10(%rbp)
movsd %xmm5, -0x28(%rbp)
callq 0x2170
movsd %xmm0, -0x8(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x2170
addsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x2170
movsd -0x8(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x2120
movsd %xmm0, -0x30(%rbp)
movsd 0x77ff(%rip), %xmm0     # 0xb2c8
subsd -0x10(%rbp), %xmm0
callq 0x2120
mulsd -0x18(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
mulsd -0x20(%rbp), %xmm1
addsd %xmm1, %xmm0
subsd -0x8(%rbp), %xmm0
callq 0x2220
movsd 0x77cf(%rip), %xmm14    # 0xb2c8
movsd -0x20(%rbp), %xmm12
movapd %xmm0, %xmm13
divsd %xmm12, %xmm13
xorl %eax, %eax
xorpd %xmm0, %xmm0
movapd 0x7789(%rip), %xmm1     # 0xb2a0
movsd 0x77c9(%rip), %xmm2     # 0xb2e8
movsd 0x77c9(%rip), %xmm3     # 0xb2f0
movsd 0x77c9(%rip), %xmm4     # 0xb2f8
movsd 0x77a9(%rip), %xmm5     # 0xb2e0
movapd 0x7751(%rip), %xmm7     # 0xb290
movapd %xmm14, %xmm8
movapd %xmm14, %xmm6
movapd %xmm14, %xmm9
testl %eax, %eax
je 0x3be7
cmpl $0xc9, %eax
je 0x3c7f
movl %eax, %ecx
shrl %ecx
cvtsi2sd %ecx, %xmm11
movapd %xmm11, %xmm10
addsd %xmm11, %xmm10
testb $0x1, %al
jne 0x3ba9
movsd -0x18(%rbp), %xmm9
subsd %xmm11, %xmm9
mulsd %xmm11, %xmm9
mulsd -0x10(%rbp), %xmm9
addsd %xmm12, %xmm10
movapd %xmm10, %xmm11
addsd %xmm5, %xmm11
mulsd %xmm10, %xmm11
divsd %xmm11, %xmm9
jmp 0x3be7
movsd -0x28(%rbp), %xmm9
addsd %xmm11, %xmm9
addsd %xmm12, %xmm11
xorpd %xmm7, %xmm11
mulsd %xmm9, %xmm11
mulsd -0x10(%rbp), %xmm11
addsd %xmm12, %xmm10
movapd %xmm10, %xmm9
addsd %xmm14, %xmm9
mulsd %xmm10, %xmm9
divsd %xmm9, %xmm11
movapd %xmm11, %xmm9
mulsd %xmm9, %xmm0
addsd %xmm14, %xmm0
movapd %xmm14, %xmm10
divsd %xmm0, %xmm10
andpd %xmm1, %xmm0
cmpltsd %xmm2, %xmm0
movapd %xmm0, %xmm11
andnpd %xmm10, %xmm11
andpd %xmm3, %xmm0
orpd %xmm11, %xmm0
divsd %xmm8, %xmm9
addsd %xmm14, %xmm9
movapd %xmm9, %xmm8
andpd %xmm1, %xmm8
cmpltsd %xmm2, %xmm8
movapd %xmm8, %xmm10
andnpd %xmm9, %xmm10
andpd %xmm2, %xmm8
orpd %xmm10, %xmm8
movapd %xmm8, %xmm9
mulsd %xmm0, %xmm9
mulsd %xmm9, %xmm6
movapd %xmm14, %xmm10
subsd %xmm9, %xmm10
andpd %xmm1, %xmm10
incl %eax
ucomisd %xmm10, %xmm4
jbe 0x3b49
addsd 0x7668(%rip), %xmm6     # 0xb2e0
mulsd %xmm6, %xmm13
jmp 0x3c88
movsd 0x7650(%rip), %xmm13    # 0xb2d8
addq $0x30, %rsp
popq %rbp
movapd %xmm13, %xmm0
retq