// File: /workspace/github_c_makefile_star2_O1/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 %xmm6, %xmm6
ucomisd %xmm2, %xmm6
jae 0x3f09
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movapd %xmm2, %xmm4
movsd 0x7699(%rip), %xmm6     # 0xb2f8
ucomisd %xmm6, %xmm2
jae 0x3f04
movapd %xmm0, %xmm3
movsd 0x7683(%rip), %xmm0     # 0xb2f8
addsd %xmm3, %xmm0
movapd %xmm3, %xmm5
addsd %xmm1, %xmm5
movsd 0x7677(%rip), %xmm2     # 0xb300
addsd %xmm5, %xmm2
divsd %xmm2, %xmm0
ucomisd %xmm0, %xmm4
jbe 0x3cc1
movsd 0x7659(%rip), %xmm2     # 0xb2f8
subsd %xmm4, %xmm2
movapd %xmm1, %xmm0
movapd %xmm3, %xmm1
callq 0x3c3d
movsd 0x7640(%rip), %xmm6     # 0xb2f8
subsd %xmm0, %xmm6
jmp 0x3f04
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 0x75d2(%rip), %xmm0     # 0xb2f8
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 0x75a3(%rip), %xmm6     # 0xb2f8
movsd -0x20(%rbp), %xmm14
divsd %xmm14, %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
movapd 0x7562(%rip), %xmm2     # 0xb2d0
movsd 0x759a(%rip), %xmm3     # 0xb310
movsd 0x759a(%rip), %xmm4     # 0xb318
movsd 0x759a(%rip), %xmm5     # 0xb320
movsd 0x757a(%rip), %xmm7     # 0xb308
movapd %xmm6, %xmm9
movapd %xmm6, %xmm10
movapd %xmm6, %xmm8
movapd %xmm6, %xmm11
testl %eax, %eax
je 0x3e42
movl %eax, %ecx
shrl %ecx
xorps %xmm13, %xmm13
cvtsi2sd %ecx, %xmm13
movapd %xmm13, %xmm12
addsd %xmm13, %xmm12
testb $0x1, %al
jne 0x3dfb
movsd -0x18(%rbp), %xmm11
subsd %xmm13, %xmm11
mulsd %xmm13, %xmm11
mulsd -0x10(%rbp), %xmm11
addsd %xmm14, %xmm12
movapd %xmm12, %xmm13
addsd %xmm7, %xmm13
mulsd %xmm12, %xmm13
divsd %xmm13, %xmm11
movapd %xmm8, %xmm6
jmp 0x3e42
movsd -0x28(%rbp), %xmm11
addsd %xmm13, %xmm11
addsd %xmm14, %xmm13
xorpd 0x74ac(%rip), %xmm13    # 0xb2c0
mulsd %xmm11, %xmm13
mulsd -0x10(%rbp), %xmm13
addsd %xmm14, %xmm12
movapd %xmm12, %xmm11
movapd %xmm8, %xmm6
addsd %xmm8, %xmm11
mulsd %xmm12, %xmm11
divsd %xmm11, %xmm13
movapd %xmm13, %xmm11
mulsd %xmm11, %xmm1
addsd %xmm6, %xmm1
movapd %xmm6, %xmm12
divsd %xmm1, %xmm12
andpd %xmm2, %xmm1
cmpltsd %xmm3, %xmm1
movapd %xmm1, %xmm13
andnpd %xmm12, %xmm13
andpd %xmm4, %xmm1
orpd %xmm13, %xmm1
divsd %xmm10, %xmm11
addsd %xmm6, %xmm11
movapd %xmm11, %xmm10
andpd %xmm2, %xmm10
cmpltsd %xmm3, %xmm10
movapd %xmm10, %xmm12
andnpd %xmm11, %xmm12
andpd %xmm3, %xmm10
orpd %xmm12, %xmm10
movapd %xmm1, %xmm11
mulsd %xmm10, %xmm11
mulsd %xmm11, %xmm9
subsd %xmm11, %xmm6
andpd %xmm2, %xmm6
ucomisd %xmm6, %xmm5
movapd %xmm9, %xmm11
addsd %xmm7, %xmm11
mulsd %xmm0, %xmm11
cmpnltsd %xmm5, %xmm6
movapd %xmm6, %xmm13
andnpd %xmm11, %xmm13
andpd %xmm15, %xmm6
orpd %xmm13, %xmm6
ja 0x3f04
movapd %xmm6, %xmm15
incl %eax
cmpl $0xc9, %eax
movapd %xmm8, %xmm6
jne 0x3d9d
movsd 0x7424(%rip), %xmm6     # 0xb328
addq $0x30, %rsp
popq %rbp
movapd %xmm6, %xmm0
retq