// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rbx
cmpb $0x2d, (%rsi)
jne 0x10257
cmpb $0x0, 0x1(%rsi)
je 0x104fa
leaq 0xa8ae(%rip), %rax      # 0x1ab0c
movq %rsi, %rdi
movq %rax, %rsi
callq 0x22c0
movq %rax, %r14
movl $0x1, %edi
movl $0x20, %esi
callq 0x2260
movq %rax, %r13
movq %r14, 0x28(%rsp)
movq %r14, 0x18(%rax)
movl $0x4000, %edi           # imm = 0x4000
callq 0x2360
movq %rax, (%r13)
leaq 0x28(%rbx), %r15
movq 0x28(%rbx), %rdi
leaq 0x4(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %rbx, 0x30(%rsp)
movslq 0x4(%rbx), %rax
leaq 0x8(,%rax,8), %rdx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x21f0
xorl %eax, %eax
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %r15, 0x20(%rsp)
cmpl %ebx, %eax
jl 0x102db
cmpl $0x0, 0x10(%r13)
jne 0x10521
xorl %r15d, %r15d
cmpl %ebx, %eax
jl 0x10327
cmpl $0x0, 0x10(%r13)
jne 0x103e7
movl $0x0, 0x8(%r13)
movq (%r13), %rsi
movq 0x18(%r13), %rdi
movl $0x4000, %edx           # imm = 0x4000
callq 0x2280
movl %eax, %ebx
movl %eax, 0xc(%r13)
xorl %eax, %eax
cmpl $0x3fff, %ebx           # imm = 0x3FFF
jg 0x10327
movl $0x1, 0x10(%r13)
testl %ebx, %ebx
je 0x103e7
movl %eax, %r14d
cmpl %ebx, %eax
jge 0x1034b
movslq %eax, %rcx
addq (%r13), %rcx
movl %eax, %r14d
cmpb $0xa, (%rcx)
je 0x1034b
incl %r14d
incq %rcx
cmpl %r14d, %ebx
jne 0x10338
movl %ebx, %r14d
movq %r12, %rdx
subq %r15, %rdx
movl %r14d, %ecx
subl %eax, %ecx
leal 0x1(%rcx), %esi
movslq %esi, %rsi
cmpq %rsi, %rdx
jae 0x103b2
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, %r12
shrq $0x10, %r12
orq %rax, %r12
incq %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x23d0
movq %rax, %rbp
movl 0x8(%r13), %eax
movl %r14d, %ecx
subl %eax, %ecx
leaq (%r15,%rbp), %rdi
movslq %eax, %rsi
addq (%r13), %rsi
movslq %ecx, %rdx
callq 0x22e0
movslq 0x8(%r13), %rax
movslq %r14d, %rcx
subq %rax, %rcx
addq %rcx, %r15
leal 0x1(%r14), %eax
movl %eax, 0x8(%r13)
movl 0xc(%r13), %ebx
cmpl %ebx, %r14d
jge 0x102de
testq %rbp, %rbp
jne 0x10404
movl $0x1, %r12d
movl $0x1, %edi
movl $0x1, %esi
callq 0x2260
movq %rax, %rbp
movb $0x0, (%rbp,%r15)
testl %r15d, %r15d
js 0x1051c
movl $0x6, %edx
movq %rbp, %rdi
leaq 0xb122(%rip), %rsi      # 0x1b544
callq 0x2090
testl %eax, %eax
movq 0x20(%rsp), %r15
je 0x1043d
movl 0x8(%r13), %eax
movl 0xc(%r13), %ebx
jmp 0x102cc
leaq 0x6(%rbp), %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
js 0x10430
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
incl %ebx
movq (%rsp), %rdi
movq %rsp, %rsi
movl $0xa, %edx
callq 0x22d0
cmpl %eax, %ebx
je 0x1047f
callq 0x2070
movl (%rax), %eax
cmpl $0x16, %eax
je 0x104e6
cmpl $0x22, %eax
je 0x104e6
movq (%rsp), %rdi
incq %rdi
movq %rdi, (%rsp)
movq %rsp, %rsi
callq 0x20e0
ucomisd 0x8bee(%rip), %xmm0     # 0x19088
jne 0x104bb
jp 0x104bb
movsd %xmm0, 0x10(%rsp)
callq 0x2070
movsd 0x10(%rsp), %xmm0
movl (%rax), %eax
cmpl $0x16, %eax
je 0x104e6
cmpl $0x22, %eax
je 0x104e6
movq (%r15), %rax
movq 0x8(%rsp), %rcx
movslq (%rcx), %rcx
movq %rcx, %rdx
addq %r14, %rdx
addsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rdx,8)
decq %r14
cmpl %ecx, %ebx
jl 0x10457
jmp 0x10430
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfac7(%rip), %rax      # 0x1ffc8
movq (%rax), %rdi
callq 0x2310
leaq 0xa5fc(%rip), %rsi      # 0x1ab0c
movl %eax, %edi
callq 0x2140
jmp 0x10269
movq 0x20(%rsp), %r15
movq (%r13), %rdi
callq 0x2060
movq %r13, %rdi
callq 0x2060
movq 0x28(%rsp), %rdi
callq 0x2050
movq %rbp, %rdi
callq 0x2060
movq 0x8(%rsp), %r14
movl (%r14), %eax
fldz
testl %eax, %eax
js 0x10569
fstp %st(0)
movq (%r15), %rcx
incq %rax
fldz
xorl %edx, %edx
faddl (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x1055e
fstpt 0x10(%rsp)
movq 0xfa84(%rip), %rbx      # 0x1fff8
movq (%rbx), %rcx
leaq 0xafcd(%rip), %rdi      # 0x1b54b
movl $0x7, %esi
movl $0x1, %edx
callq 0x24b0
movl (%r14), %edi
testl %edi, %edi
js 0x105c2
movq (%r15), %rax
leaq 0x1(%rdi), %rcx
xorl %edx, %edx
fldt 0x10(%rsp)
fld %st(0)
fdivrl (%rax,%rdx,8)
fstpl (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x105a1
fstp %st(0)
testl %edi, %edi
js 0x105c2
movq %r15, %rsi
movq %r14, %rdx
callq 0x2a2c
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x2220
movslq (%r14), %rax
xorpd %xmm0, %xmm0
cmpq $0x2, %rax
jl 0x1063b
movq (%r15), %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 0x105f4
fstpl 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
movq (%rbx), %rdi
leaq 0xaf18(%rip), %rsi      # 0x1b55d
leaq 0xaf2b(%rip), %rdx      # 0x1b577
movb $0x1, %al
callq 0x2290
movl (%r14), %eax
testl %eax, %eax
xorpd %xmm0, %xmm0
jle 0x106a9
movq (%r15), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq (%rcx,%rax,8), %rcx
addq $-0x8, %rcx
incq %rax
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 0x1067a
fstpl 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movq (%rbx), %rdi
leaq 0xaed6(%rip), %rsi      # 0x1b589
movb $0x1, %al
callq 0x2290
movq 0x30(%rsp), %rcx
movslq 0x4(%rcx), %rax
movq 0x28(%rcx), %rdx
movq 0x30(%rcx), %rcx
testq %rax, %rax
jle 0x106f0
xorl %esi, %esi
movsd 0xadb6(%rip), %xmm0     # 0x1b490
movsd (%rdx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x106da
movsd (%rdx,%rax,8), %xmm0
mulsd 0xad9b(%rip), %xmm0     # 0x1b498
addsd 0x8973(%rip), %xmm0     # 0x19078
movsd %xmm0, (%rcx,%rax,8)
xorl %eax, %eax
jmp 0x104eb