// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/prob1.c
// Function: bcf_p1_read_prior
int bcf_p1_read_prior(bcf_p1aux_t *ma, const char *fn)
{
	gzFile fp;
	kstring_t s;
	kstream_t *ks;
	long double sum;
	int dret, k;
	memset(&s, 0, sizeof(kstring_t));
	fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
	ks = ks_init(fp);
	memset(ma->phi, 0, sizeof(double) * (ma->M + 1));
	while (ks_getuntil(ks, '\n', &s, &dret) >= 0) {
		if (strstr(s.s, "[afs] ") == s.s) {
			char *p = s.s + 6;
			for (k = 0; k <= ma->M; ++k) {
				int x;
				double y;
				x = strtol(p, &p, 10);
				if (x != k && (errno == EINVAL || errno == ERANGE)) return -1;
				++p;
				y = strtod(p, &p);
				if (y == 0. && (errno == EINVAL || errno == ERANGE)) return -1;
				ma->phi[ma->M - k] += y;
			}
		}
	}
	ks_destroy(ks);
	gzclose(fp);
	free(s.s);
	for (sum = 0., k = 0; k <= ma->M; ++k) sum += ma->phi[k];
	fprintf(stderr, "[prior]");
	for (k = 0; k <= ma->M; ++k) ma->phi[k] /= sum;
	for (k = 0; k <= ma->M; ++k) fprintf(stderr, " %d:%.3lg", k, ma->phi[ma->M - k]);
	fputc('\n', stderr);
	for (sum = 0., k = 1; k < ma->M; ++k) sum += ma->phi[ma->M - k] * (2.* k * (ma->M - k) / ma->M / (ma->M - 1));
	fprintf(stderr, "[%s] heterozygosity=%lf, ", __func__, (double)sum);
	for (sum = 0., k = 1; k <= ma->M; ++k) sum += k * ma->phi[ma->M - k] / ma->M;
	fprintf(stderr, "theta=%lf\n", (double)sum);
	bcf_p1_indel_prior(ma, MC_DEF_INDEL);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x9bc5(%rip), %rsi      # 0x19a12
movq %rbx, %rdi
callq 0x2270
testl %eax, %eax
je 0xfe6a
leaq 0xac58(%rip), %rsi      # 0x1aab8
movq %rbx, %rdi
callq 0x22c0
jmp 0xfe87
movq 0x10157(%rip), %rax     # 0x1ffc8
movq (%rax), %rdi
callq 0x2310
leaq 0xac38(%rip), %rsi      # 0x1aab8
movl %eax, %edi
callq 0x2140
movq %rax, %rbx
movl $0x1, %edi
movl $0x20, %esi
callq 0x2260
movq %rax, %r13
movq %rbx, 0x28(%rsp)
movq %rbx, 0x18(%rax)
movl $0x4000, %edi           # imm = 0x4000
callq 0x2360
movq %rax, (%r13)
leaq 0x28(%r14), %rax
movq %rax, (%rsp)
movq 0x28(%r14), %rdi
leaq 0x4(%r14), %rax
movq %rax, 0x10(%rsp)
movq %r14, 0x30(%rsp)
movslq 0x4(%r14), %rax
leaq 0x8(,%rax,8), %rdx
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x21f0
xorl %r12d, %r12d
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jl 0xfefd
cmpl $0x0, 0x10(%r13)
je 0xfefd
xorl %eax, %eax
jmp 0x1002c
xorl %r15d, %r15d
movl 0x8(%r13), %eax
cmpl 0xc(%r13), %eax
jl 0xff4a
cmpl $0x0, 0x10(%r13)
jne 0x10005
movl $0x0, 0x8(%r13)
movq (%r13), %rsi
movq 0x18(%r13), %rdi
movl $0x4000, %edx           # imm = 0x4000
callq 0x2280
movl %eax, 0xc(%r13)
cmpl $0x3fff, %eax           # imm = 0x3FFF
jg 0xff42
movl $0x1, 0x10(%r13)
testl %eax, %eax
je 0x10005
movl 0x8(%r13), %eax
movl 0xc(%r13), %ecx
movl %eax, %ebx
cmpl %ecx, %eax
jge 0xff71
movslq %eax, %rdx
addq (%r13), %rdx
movl %eax, %ebx
cmpb $0xa, (%rdx)
je 0xff71
incl %ebx
incq %rdx
cmpl %ebx, %ecx
jne 0xff61
movl %ecx, %ebx
movq %rbp, %rdx
subq %r15, %rdx
movl %ebx, %ecx
subl %eax, %ecx
leal 0x1(%rcx), %eax
cltq
cmpq %rax, %rdx
jae 0xffcd
movslq %ecx, %rax
addq %r15, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rbp
shrq $0x10, %rbp
orq %rax, %rbp
incq %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x23d0
movq %rax, %r12
leaq (%r12,%r15), %rdi
movslq 0x8(%r13), %rax
movq (%r13), %rsi
addq %rax, %rsi
movslq %ebx, %r14
movq %r14, %rdx
subq %rax, %rdx
callq 0x22e0
movslq 0x8(%r13), %rax
subq %rax, %r14
addq %r14, %r15
leal 0x1(%rbx), %eax
movl %eax, 0x8(%r13)
cmpl 0xc(%r13), %ebx
jge 0xff00
testq %r12, %r12
jne 0x10021
movl $0x1, %ebp
movl $0x1, %edi
movl $0x1, %esi
callq 0x2260
movq %rax, %r12
movb $0x0, (%r12,%r15)
testl %r15d, %r15d
setns %al
testb %al, %al
je 0x1011b
movl $0x6, %edx
movq %r12, %rdi
leaq 0xb429(%rip), %rsi      # 0x1b46c
callq 0x2090
testl %eax, %eax
jne 0xfee5
leaq 0x6(%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax)
js 0xfee5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r15d, %r15d
incl %ebx
movq 0x8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x22d0
cmpl %eax, %ebx
je 0x1009b
callq 0x2070
movl (%rax), %eax
cmpl $0x16, %eax
je 0x10107
cmpl $0x22, %eax
je 0x10107
movq 0x8(%rsp), %rdi
incq %rdi
movq %rdi, 0x8(%rsp)
leaq 0x8(%rsp), %rsi
callq 0x20e0
ucomisd 0x8f66(%rip), %xmm0     # 0x19020
jne 0x100db
jp 0x100db
movsd %xmm0, 0x18(%rsp)
callq 0x2070
movsd 0x18(%rsp), %xmm0
movl (%rax), %eax
cmpl $0x16, %eax
je 0x10107
cmpl $0x22, %eax
je 0x10107
movq (%rsp), %rax
movq (%rax), %rax
movq 0x10(%rsp), %rdx
movslq (%rdx), %rcx
addq %r15, %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
decq %r15
cmpl (%rdx), %ebx
jl 0x10070
jmp 0xfee5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r13), %rdi
callq 0x2060
movq %r13, %rdi
callq 0x2060
movq 0x28(%rsp), %rdi
callq 0x2050
movq %r12, %rdi
callq 0x2060
movq 0x10(%rsp), %r15
movl (%r15), %eax
fldz
testl %eax, %eax
js 0x10167
fstp %st(0)
movq (%rsp), %rcx
movq (%rcx), %rcx
incq %rax
fldz
xorl %edx, %edx
faddl (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x1015c
fstpt 0x18(%rsp)
movq 0xfe86(%rip), %rbx      # 0x1fff8
movq (%rbx), %rcx
leaq 0xb2f7(%rip), %rdi      # 0x1b473
movl $0x7, %esi
movl $0x1, %edx
callq 0x24b0
fldt 0x18(%rsp)
movl (%r15), %eax
testl %eax, %eax
movq 0x30(%rsp), %r14
js 0x101b7
movq (%rsp), %rcx
movq (%rcx), %rcx
incq %rax
xorl %edx, %edx
fld %st(0)
fdivrl (%rcx,%rdx,8)
fstpl (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x101a7
fstp %st(0)
movl (%r15), %edi
testl %edi, %edi
js 0x101cc
movq (%rsp), %rsi
movq %r15, %rdx
callq 0x2a2c
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x2220
movslq (%r15), %rax
xorpd %xmm0, %xmm0
cmpq $0x2, %rax
jl 0x10249
movq (%rsp), %rcx
movq (%rcx), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leal -0x1(%rax), %edx
cvtsi2sd %edx, %xmm1
fldz
movl $0x2, %edx
movl %edx, %esi
xorps %xmm2, %xmm2
cvtsi2sd %rsi, %xmm2
leaq -0x1(%rax), %rsi
xorps %xmm3, %xmm3
cvtsi2sd %esi, %xmm3
mulsd %xmm2, %xmm3
divsd %xmm0, %xmm3
divsd %xmm1, %xmm3
mulsd -0x8(%rcx,%rax,8), %xmm3
movsd %xmm3, 0x50(%rsp)
faddl 0x50(%rsp)
addl $0x2, %edx
movq %rsi, %rax
cmpq $0x1, %rsi
jne 0x10202
fstpl 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
movq (%rbx), %rdi
leaq 0xb232(%rip), %rsi      # 0x1b485
leaq 0xb245(%rip), %rdx      # 0x1b49f
movb $0x1, %al
callq 0x2290
movslq (%r15), %rcx
testq %rcx, %rcx
xorpd %xmm0, %xmm0
jle 0x102bc
movq (%rsp), %rax
movq (%rax), %rdx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
leal 0x1(%rcx), %eax
leaq (%rdx,%rcx,8), %rcx
addq $-0x8, %rcx
fldz
movl $0x1, %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
mulsd (%rcx), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
faddl 0x40(%rsp)
incq %rdx
addq $-0x8, %rcx
cmpq %rdx, %rax
jne 0x1028d
fstpl 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movq (%rbx), %rdi
leaq 0xb1eb(%rip), %rsi      # 0x1b4b1
movb $0x1, %al
callq 0x2290
movslq (%r15), %rax
testq %rax, %rax
jle 0x102fd
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rdx
xorl %esi, %esi
movsd 0xb119(%rip), %xmm0     # 0x1b400
movsd (%rcx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x102e7
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rdx
movsd (%rcx,%rax,8), %xmm0
mulsd 0xb0f6(%rip), %xmm0     # 0x1b408
addsd 0x8cf6(%rip), %xmm0     # 0x19010
movsd %xmm0, (%rdx,%rax,8)
xorl %eax, %eax
jmp 0x1010c