// File: /workspace/github_c_makefile_star2_O3/lh3[P]bgt/bgt.c
// Function: bgtm_hapcnt
bgt_hapcnt_t *bgtm_hapcnt(const bgtm_t *bm, int *n_hap)
{
	int i, j, absent, n;
	khint_t k;
	khash_t(hc) *h;
	bgt_hapcnt_t *hc;
	if (bm->hap == 0 || bm->n_out == 0) return 0;
	h = kh_init(hc);
	for (i = 0; i < bm->n_out<<1; ++i) {
		k = kh_put(hc, h, bm->hap[i], &absent);
		if (absent) kh_val(h, k) = kh_size(h) - 1;
	}
	n = kh_size(h);
	hc = (bgt_hapcnt_t*)calloc(n, sizeof(bgt_hapcnt_t));
	for (i = 0; i < n; ++i)
		hc[i].cnt = (int*)calloc(bm->n_groups, sizeof(int));
	for (k = 0; k < kh_end(h); ++k)
		if (kh_exist(h, k))
			hc[kh_val(h, k)].hap = kh_key(h, k);
	for (i = 0; i < bm->n_out<<1; ++i) {
		int t;
		k = kh_get(hc, h, bm->hap[i]);
		t = kh_val(h, k);
		++hc[t].tot;
		for (j = 0; j < bm->n_groups; ++j)
			if (bm->group[i>>1] & 1U<<j)
				++hc[t].cnt[j];
	}
	kh_destroy(hc, h);
	ks_introsort(hc, n, hc);
	*n_hap = n;
	return hc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
cmpq $0x0, 0xb0(%rdi)
je 0x1b4c3
movq %rdi, 0x28(%rsp)
movl 0x4(%rdi), %ebp
testl %ebp, %ebp
je 0x1b4c3
movq %rsi, 0x38(%rsp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x2220
movq %rax, %r15
leal (,%rbp,2), %eax
testl %eax, %eax
movq %r15, 0x30(%rsp)
jle 0x1b4cb
xorl %ebx, %ebx
movsd 0x3e58(%rip), %xmm1     # 0x1ee38
movsd 0x3e58(%rip), %xmm2     # 0x1ee40
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x28(%rsp), %rsi
movq 0xb0(%rsi), %rdx
movq (%rdx,%rbx,8), %rdx
movq %rdx, 0x10(%rsp)
cmpl %ecx, %eax
jb 0x1b267
movl 0x4(%r15), %r8d
leal (%r8,%r8), %edx
cmpl %r14d, %edx
movl $0x0, %edx
sbbl %edx, %edx
orl $0x1, %edx
addl %r14d, %edx
decl %edx
movl %edx, %esi
shrl %esi
orl %edx, %esi
movl %esi, %edx
shrl $0x2, %edx
orl %esi, %edx
movl %edx, %esi
shrl $0x4, %esi
orl %edx, %esi
movl %esi, %edi
shrl $0x8, %edi
orl %esi, %edi
movl %edi, %edx
shrl $0x10, %edx
orl %edi, %edx
incl %edx
cmpl $0x5, %edx
movl $0x4, %esi
cmovael %edx, %esi
cvtsi2sd %rsi, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %rdi
movq %r8, 0x18(%rsp)
cmpl %edi, %r8d
jae 0x1b267
movq %rdi, 0x20(%rsp)
movq %rbx, 0x40(%rsp)
movl %esi, %ebx
shrl $0x2, %ebx
andl $-0x4, %ebx
cmpl $0x10, %edx
movl $0x4, %eax
cmovbl %eax, %ebx
movq %rbx, %rdi
movq %rsi, 0x8(%rsp)
callq 0x22e0
movq %rax, %r12
movq %rax, %rdi
movl $0xaa, %esi
movq %rbx, %rdx
callq 0x21e0
movq 0x8(%rsp), %rcx
cmpl %ecx, %r14d
jae 0x1b0f8
movq 0x18(%r15), %rdi
movl %ecx, %ebx
leaq (,%rbx,8), %rsi
callq 0x2330
movq %rax, 0x18(%r15)
movq 0x20(%r15), %rdi
shlq $0x2, %rbx
movq %rbx, %rsi
callq 0x2330
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%r15)
testl %r14d, %r14d
je 0x1b239
leal -0x1(%rcx), %eax
xorl %edx, %edx
movl %edx, %r10d
shrl $0x4, %r10d
movl (%r13,%r10,4), %r11d
leal (%rdx,%rdx), %ecx
andl $0x1e, %ecx
movl %r11d, %esi
shrl %cl, %esi
testb $0x3, %sil
jne 0x1b1f8
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdi
movq (%rsi,%rdx,8), %r9
movl (%rdi,%rdx,4), %r8d
btsl %ecx, %r11d
movl %r11d, (%r13,%r10,4)
movq %r9, %rbx
shrq $0x21, %rbx
movl %r9d, %ecx
shll $0xb, %ecx
xorl %ecx, %ebx
xorl %r9d, %ebx
movl %eax, %r11d
andl %ebx, %r11d
movl %r11d, %r10d
shrl $0x4, %r10d
movl (%r12,%r10,4), %ebp
leal (%r11,%r11), %ecx
andl $0x1e, %ecx
movl $0x2, %r15d
shll %cl, %r15d
testl %ebp, %r15d
jne 0x1b1a4
movl %ebx, %ecx
shrl $0x3, %ecx
shll $0x3, %ebx
xorl %ecx, %ebx
orl $0x1, %ebx
andl %eax, %ebx
addl %ebx, %r11d
andl %eax, %r11d
movl %r11d, %r10d
shrl $0x4, %r10d
movl (%r12,%r10,4), %ebp
leal (%r11,%r11), %ecx
andl $0x1e, %ecx
movl $0x2, %r15d
shll %cl, %r15d
testl %ebp, %r15d
je 0x1b17e
notl %r15d
andl %ebp, %r15d
movl %r15d, (%r12,%r10,4)
movl %r11d, %ebx
cmpl %r14d, %r11d
jae 0x1b1eb
movl (%r13,%r10,4), %r11d
shrl %cl, %r11d
testb $0x3, %r11b
jne 0x1b1eb
movq (%rsi,%rbx,8), %r11
movq %r9, (%rsi,%rbx,8)
movl (%rdi,%rbx,4), %r9d
movl $0x1, %ebp
shll %cl, %ebp
movl %r8d, (%rdi,%rbx,4)
orl %ebp, (%r13,%r10,4)
movl %r9d, %r8d
movq %r11, %r9
jmp 0x1b137
movq %r9, (%rsi,%rbx,8)
movl %r8d, (%rdi,%rbx,4)
movq 0x30(%rsp), %r15
incq %rdx
cmpl %edx, %r14d
jne 0x1b0fd
movq 0x8(%rsp), %rax
cmpl %eax, %r14d
jbe 0x1b239
movq 0x18(%r15), %rdi
movl %eax, %ebx
leaq (,%rbx,8), %rsi
callq 0x2330
movq %rax, 0x18(%r15)
movq 0x20(%r15), %rdi
shlq $0x2, %rbx
movq %rbx, %rsi
callq 0x2330
movq %rax, 0x20(%r15)
movq %r13, %rdi
callq 0x2050
movq 0x8(%rsp), %r9
movq 0x40(%rsp), %rbx
movsd 0x3be5(%rip), %xmm1     # 0x1ee38
movsd 0x3be5(%rip), %xmm2     # 0x1ee40
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %r10
jmp 0x1b273
movq %r13, %r12
movl %r14d, %r9d
movl %ecx, %r10d
movl %eax, %r13d
leal -0x1(%r9), %esi
movq 0x10(%rsp), %rcx
movq %rcx, %rdi
shrq $0x21, %rdi
movl %ecx, %eax
shll $0xb, %eax
xorl %eax, %edi
xorl %ecx, %edi
movl %esi, %edx
andl %edi, %edx
movl %edx, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %eax
leal (%rdx,%rdx), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x1b2a9
movl %edx, %eax
jmp 0x1b346
movq %r10, 0x20(%rsp)
movl %edi, %eax
shrl $0x3, %eax
shll $0x3, %edi
xorl %eax, %edi
orl $0x1, %edi
andl %esi, %edi
movq %r9, %r14
movl %r9d, %eax
movl %edx, %r8d
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%r12,%rcx,4), %r9d
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %r9d, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x1b322
testb $0x1, %r10b
jne 0x1b2fb
movq 0x18(%r15), %r10
movl %r8d, %r11d
movq 0x10(%rsp), %rbp
cmpq %rbp, (%r10,%r11,8)
je 0x1b322
btl %ecx, %r9d
cmovbl %r8d, %eax
addl %edi, %r8d
andl %esi, %r8d
cmpl %edx, %r8d
jne 0x1b2c6
movb $0x1, %cl
movq %r14, %r9
movl %r9d, %esi
cmpl %r9d, %eax
movq 0x20(%rsp), %r10
je 0x1b339
jmp 0x1b346
shrl %cl, %r9d
testb $0x2, %r9b
sete %cl
movl %r8d, %edx
movl %eax, %esi
movq %r14, %r9
movq 0x20(%rsp), %r10
cmpl %r9d, %esi
cmovel %edx, %esi
testb %cl, %cl
cmovnel %edx, %esi
movl %esi, %eax
movl %eax, %edx
shrl $0x4, %edx
movl (%r12,%rdx,4), %esi
leal (%rax,%rax), %ecx
andl $0x1e, %ecx
movl %esi, %edi
shrl %cl, %edi
testb $0x2, %dil
jne 0x1b394
testb $0x1, %dil
je 0x1b3cb
movq 0x18(%r15), %rdi
movl $0x3, %r8d
shll %cl, %r8d
movl %eax, %eax
movq 0x10(%rsp), %rcx
movq %rcx, (%rdi,%rax,8)
notl %r8d
andl %r8d, %esi
movl %esi, (%r12,%rdx,4)
movl 0x4(%r15), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%r15)
jmp 0x1b3c4
movq 0x18(%r15), %rdi
movl %eax, %eax
movl $0x3, %r8d
shll %cl, %r8d
movq 0x10(%rsp), %rcx
movq %rcx, (%rdi,%rax,8)
notl %r8d
andl %r8d, %esi
movl %esi, (%r12,%rdx,4)
movl 0x4(%r15), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%r15)
incl %r13d
movq 0x20(%r15), %rdx
movl %ecx, (%rdx,%rax,4)
movl %r13d, %eax
movq 0x28(%rsp), %rsi
incq %rbx
movl 0x4(%rsi), %ebp
leal (,%rbp,2), %ecx
movslq %ecx, %rdx
movq %r12, %r13
movl %r9d, %r14d
movl %r10d, %ecx
cmpq %rdx, %rbx
jl 0x1aff7
movl %eax, 0x8(%r15)
movl %r10d, 0xc(%r15)
movq %r9, 0x8(%rsp)
movl %r9d, (%r15)
movq %r12, 0x10(%r15)
movslq 0x4(%r15), %rbx
movl $0x18, %esi
movq %rbx, %rdi
callq 0x2220
movq %rax, %r13
movq %rbx, 0x18(%rsp)
testq %rbx, %rbx
jle 0x1b45f
movq 0x28(%rsp), %rax
movslq 0x8(%rax), %rbx
movq 0x18(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %r14
xorl %r15d, %r15d
movl $0x4, %esi
movq %rbx, %rdi
callq 0x2220
movq %rax, 0x10(%r13,%r15)
addq $0x18, %r15
cmpq %r15, %r14
jne 0x1b444
movq 0x8(%rsp), %rax
testl %eax, %eax
sete 0x10(%rsp)
je 0x1b4f8
movl %eax, %edx
xorl %esi, %esi
xorl %edi, %edi
movq 0x30(%rsp), %r15
movl %edi, %ecx
shrl $0x4, %ecx
movl (%r12,%rcx,4), %r8d
movl %esi, %ecx
andb $0x1e, %cl
shrl %cl, %r8d
testb $0x3, %r8b
jne 0x1b4ac
movq 0x18(%r15), %rcx
movq 0x20(%r15), %r8
movq (%rcx,%rdi,8), %rcx
movslq (%r8,%rdi,4), %r8
leaq (%r8,%r8,2), %r8
movq %rcx, (%r13,%r8,8)
incq %rdi
addl $0x2, %esi
cmpq %rdi, %rdx
jne 0x1b47c
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x1b50e
xorl %r13d, %r13d
jmp 0x1b684
xorl %r12d, %r12d
movl $0x18, %esi
xorl %edi, %edi
callq 0x2220
movq %rax, %r13
movb $0x1, 0x10(%rsp)
xorl %edx, %edx
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
jmp 0x1b50e
xorl %edx, %edx
movb $0x1, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %r15
leal (,%rbp,2), %ecx
testl %ecx, %ecx
jle 0x1b644
movq 0x28(%rsp), %rax
movq 0xb0(%rax), %rax
movq %rax, 0x20(%rsp)
leal -0x1(%rdx), %ebx
movq 0x20(%r15), %r8
xorl %r9d, %r9d
movl $0x0, %r14d
cmpb $0x0, 0x10(%rsp)
jne 0x1b5d5
movq 0x20(%rsp), %rax
movq (%rax,%r9,8), %r10
movq %r10, %r11
shrq $0x21, %r11
movl %r10d, %ecx
shll $0xb, %ecx
xorl %ecx, %r11d
xorl %r10d, %r11d
movl %ebx, %edi
andl %r11d, %edi
movl %r11d, %ecx
shrl $0x3, %ecx
shll $0x3, %r11d
xorl %ecx, %r11d
orl $0x1, %r11d
andl %ebx, %r11d
movl %edi, %r14d
movl %r14d, %ecx
shrl $0x4, %ecx
movl (%r12,%rcx,4), %esi
leal (%r14,%r14), %ecx
andl $0x1e, %ecx
movl %esi, %r15d
shrl %cl, %r15d
testb $0x2, %r15b
jne 0x1b5c6
testb $0x1, %r15b
jne 0x1b5b6
movq 0x30(%rsp), %rax
movq 0x18(%rax), %r15
movl %r14d, %eax
cmpq %r10, (%r15,%rax,8)
je 0x1b5c6
addl %r11d, %r14d
andl %ebx, %r14d
cmpl %edi, %r14d
jne 0x1b581
movl %edx, %r14d
jmp 0x1b5d0
shrl %cl, %esi
testb $0x3, %sil
cmovnel %edx, %r14d
movq 0x30(%rsp), %r15
movl %r14d, %eax
movslq (%r8,%rax,4), %rax
leaq (%rax,%rax,2), %rsi
incl 0x8(%r13,%rsi,8)
movq 0x28(%rsp), %rax
movl 0x8(%rax), %ecx
testl %ecx, %ecx
jle 0x1b62f
leaq (,%rsi,8), %rdi
addq %r13, %rdi
movq 0x20(%rax), %r10
movl %r9d, %r11d
shrl %r11d
xorl %r14d, %r14d
movq %rax, %rsi
movl (%r10,%r11,4), %eax
btl %r14d, %eax
jae 0x1b621
movq 0x10(%rdi), %rax
incl (%rax,%r14,4)
movl 0x8(%rsi), %ecx
incq %r14
movslq %ecx, %rax
cmpq %rax, %r14
jl 0x1b60c
movl 0x4(%rsi), %ebp
incq %r9
leal (,%rbp,2), %eax
cltq
cmpq %rax, %r9
jl 0x1b538
testq %r15, %r15
je 0x1b66b
movq 0x18(%r15), %rdi
callq 0x2050
movq %r12, %rdi
callq 0x2050
movq 0x20(%r15), %rdi
callq 0x2050
movq %r15, %rdi
callq 0x2050
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x1ac8f
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movl %ecx, (%rax)
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq