// File: /workspace/github_c_makefile_star2_O3/DReichLab[P]adna/hts.c
// Function: hts_idx_finish
void hts_idx_finish(hts_idx_t *idx, uint64_t final_offset)
{
	int i;
	if (idx->z.finished) return; // do not run this function multiple times
	if (idx->z.save_tid >= 0) {
		insert_to_b(idx->bidx[idx->z.save_tid], idx->z.save_bin, idx->z.save_off, final_offset);
		insert_to_b(idx->bidx[idx->z.save_tid], idx->n_bins + 1, idx->z.off_beg, final_offset);
		insert_to_b(idx->bidx[idx->z.save_tid], idx->n_bins + 1, idx->z.n_mapped, idx->z.n_unmapped);
	}
	for (i = 0; i < idx->n; ++i) {
		update_loff(idx, i, (idx->fmt == HTS_FMT_CSI));
		compress_binning(idx, i);
	}
	idx->z.finished = 1;
}

// Assembly:
cmpl $0x0, 0x54(%rdi)
je 0x5fde
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r8
movslq 0x50(%rdi), %rax
testq %rax, %rax
movq %rdi, 0x8(%rsp)
js 0x620e
movq %rsi, %r14
movq 0x28(%r8), %rcx
movq (%rcx,%rax,8), %r15
movl 0x44(%r8), %esi
movq 0x60(%r8), %rbx
leaq 0x5c(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x8732
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0x605c
movq $0x1, (%r13)
leaq 0x4(%r13), %r15
movl $0x1, %edi
movl $0x10, %esi
callq 0x21f0
movq %rax, 0x10(%r13)
xorl %ecx, %ecx
jmp 0x608e
leaq 0x4(%r13), %r15
movl 0x4(%r13), %ecx
cmpl (%r13), %ecx
jne 0x608a
leal (%rcx,%rcx), %eax
movl %eax, (%r13)
movq 0x10(%r13), %rdi
shll $0x5, %ecx
movslq %ecx, %rsi
callq 0x22e0
movq %rax, 0x10(%r13)
movl 0x4(%r13), %ecx
jmp 0x608e
movq 0x10(%r13), %rax
movq 0x8(%rsp), %rdi
movslq %ecx, %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movq %rbx, (%rax,%rdx)
incl %ecx
movl %ecx, (%r15)
movq %r14, 0x8(%rax,%rdx)
movq 0x28(%rdi), %rax
movslq 0x50(%rdi), %rcx
movq (%rax,%rcx,8), %r15
movl 0xc(%rdi), %esi
incl %esi
movq 0x68(%rdi), %rbx
leaq 0x60(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x8732
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0x6108
movq $0x1, (%r13)
leaq 0x4(%r13), %r15
movl $0x1, %edi
movl $0x10, %esi
callq 0x21f0
movq %rax, 0x10(%r13)
xorl %ecx, %ecx
jmp 0x613a
leaq 0x4(%r13), %r15
movl 0x4(%r13), %ecx
cmpl (%r13), %ecx
jne 0x6136
leal (%rcx,%rcx), %eax
movl %eax, (%r13)
movq 0x10(%r13), %rdi
shll $0x5, %ecx
movslq %ecx, %rsi
callq 0x22e0
movq %rax, 0x10(%r13)
movl 0x4(%r13), %ecx
jmp 0x613a
movq 0x10(%r13), %rax
movq 0x8(%rsp), %rdi
movslq %ecx, %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movq %rbx, (%rax,%rdx)
incl %ecx
movl %ecx, (%r15)
movq %r14, 0x8(%rax,%rdx)
movq 0x28(%rdi), %rax
movslq 0x50(%rdi), %rcx
movq (%rax,%rcx,8), %r14
movl 0xc(%rdi), %esi
incl %esi
movups 0x78(%rdi), %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x64(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x8732
movl %eax, %eax
leaq (%rax,%rax,2), %r12
shlq $0x3, %r12
addq 0x20(%r14), %r12
cmpl $0x0, (%r15)
je 0x61ba
movq $0x1, (%r12)
leaq 0x4(%r12), %rbx
movl $0x1, %edi
movl $0x10, %esi
callq 0x21f0
movq %rax, 0x10(%r12)
xorl %ecx, %ecx
jmp 0x61f2
leaq 0x4(%r12), %rbx
movl 0x4(%r12), %ecx
cmpl (%r12), %ecx
jne 0x61ed
leal (%rcx,%rcx), %eax
movl %eax, (%r12)
movq 0x10(%r12), %rdi
shll $0x5, %ecx
movslq %ecx, %rsi
callq 0x22e0
movq %rax, 0x10(%r12)
movl 0x4(%r12), %ecx
jmp 0x61f2
movq 0x10(%r12), %rax
movq 0x8(%rsp), %r8
movaps 0x20(%rsp), %xmm0
movslq %ecx, %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
incl %ecx
movl %ecx, (%rbx)
movups %xmm0, (%rax,%rdx)
cmpl $0x0, 0x14(%r8)
jle 0x66de
xorl %r15d, %r15d
xorl %edx, %edx
cmpl $0x0, (%r8)
sete %dl
movq %r8, %rdi
movl %r15d, %esi
callq 0x66f5
movq 0x8(%rsp), %r8
movq 0x28(%r8), %rax
movq (%rax,%r15,8), %r9
testq %r9, %r9
je 0x66ce
movq %r15, 0x38(%rsp)
movl 0x8(%r8), %r11d
movl (%r9), %esi
testl %r11d, %r11d
movq %r9, 0x18(%rsp)
movl %esi, 0x14(%rsp)
jle 0x6549
movl %esi, %eax
movq %rax, 0x20(%rsp)
movl %esi, %edx
movl %esi, %edi
leal (%r11,%r11,2), %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
shll %cl, %r10d
xorl %eax, %eax
testl %esi, %esi
jne 0x6296
leal -0x1(%r11), %ecx
movl %eax, %esi
cmpl $0x1, %r11d
movl %ecx, %r11d
jg 0x626f
jmp 0x654b
notl %r10d
movl $0x92492493, %eax       # imm = 0x92492493
imulq %rax, %r10
shrq $0x22, %r10
movq %r10, 0x50(%rsp)
xorl %r14d, %r14d
movq %r11, 0x30(%rsp)
movq 0x10(%r9), %rax
leal (%r14,%r14), %ebp
andl $0x1e, %ebp
movl $0x3, %r13d
movl %ebp, %ecx
shll %cl, %r13d
movl %r14d, %ebx
shrl $0x4, %ebx
testl %r13d, (%rax,%rbx,4)
je 0x62e1
incl %r14d
movl %edi, %eax
cmpl %edi, %r14d
jne 0x62b3
jmp 0x6282
movq 0x18(%r9), %rax
movl %r14d, %r12d
movl (%rax,%r12,4), %eax
cmpl 0xc(%r8), %eax
jae 0x62d5
cmpl 0x50(%rsp), %eax
jb 0x62d5
leaq (%r12,%r12,2), %r15
shlq $0x3, %r15
addq 0x20(%r9), %r15
cmpl 0x8(%r8), %r11d
jge 0x6338
movslq 0x4(%r15), %rdi
cmpq $0x2, %rdi
jl 0x6338
movq 0x10(%r15), %rsi
callq 0x5b6a
movq 0x30(%rsp), %r11
movq 0x18(%rsp), %r9
movq 0x8(%rsp), %r8
movl (%r9), %eax
movl %eax, 0x14(%rsp)
movq %rax, 0x20(%rsp)
movq 0x10(%r15), %rsi
movslq 0x4(%r15), %rdx
movq %rdx, %rax
shlq $0x4, %rax
movq -0x8(%rsi,%rax), %rax
shrq $0x10, %rax
movq (%rsi), %rcx
shrq $0x10, %rcx
subq %rcx, %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
ja 0x6401
movq %rdx, 0x48(%rsp)
movq 0x20(%rsp), %rcx
testl %ecx, %ecx
je 0x6433
movq %rsi, 0x40(%rsp)
movq 0x18(%r9), %rsi
movl (%rsi,%r12,4), %edi
decl %edi
movl %edi, %eax
shrl $0x3, %eax
leal -0x1(%rcx), %r12d
movl %eax, %r11d
andl %r12d, %r11d
movl %edi, %ecx
shrl $0x6, %ecx
andl $-0x8, %edi
xorl %ecx, %edi
orl $0x1, %edi
andl %r12d, %edi
movq 0x10(%r9), %r8
movl %r11d, %r10d
movl %r10d, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %edx
leal (%r10,%r10), %ecx
andl $0x1e, %ecx
movl %edx, %r9d
shrl %cl, %r9d
testb $0x2, %r9b
jne 0x640f
testb $0x1, %r9b
jne 0x63d9
movl %r10d, %r9d
cmpl %eax, (%rsi,%r9,4)
je 0x640f
addl %edi, %r10d
andl %r12d, %r10d
cmpl %r11d, %r10d
jne 0x63ad
movq 0x20(%rsp), %rax
movl %eax, %edx
movl %eax, %edi
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
movq 0x30(%rsp), %r11
jmp 0x62d5
movq 0x20(%rsp), %rax
movl %eax, %edx
movl %eax, %edi
jmp 0x62d5
shrl %cl, %edx
testb $0x3, %dl
movq 0x20(%rsp), %rcx
cmovnel %ecx, %r10d
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
movq 0x30(%rsp), %r11
movq 0x40(%rsp), %rsi
jmp 0x6436
xorl %r10d, %r10d
movl %ecx, %edx
movl %ecx, %edi
cmpl %ecx, %r10d
je 0x62d5
movq 0x20(%r9), %rax
movl %r10d, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %r12
movl 0x4(%r12), %ecx
movq 0x48(%rsp), %rdx
leal (%rcx,%rdx), %eax
cmpl (%r12), %eax
jle 0x64b3
decl %eax
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
incl %ecx
movl %ecx, (%r12)
movq 0x10(%r12), %rdi
shll $0x4, %ecx
movslq %ecx, %rsi
callq 0x22e0
movq %rax, 0x10(%r12)
movl 0x4(%r12), %ecx
movq 0x10(%r15), %rsi
movl 0x4(%r15), %edx
jmp 0x64b8
movq 0x10(%r12), %rax
movslq %ecx, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
shll $0x4, %edx
movslq %edx, %rdx
callq 0x2240
movl 0x4(%r15), %eax
addl %eax, 0x4(%r12)
movq 0x10(%r15), %rdi
callq 0x2050
movq 0x18(%rsp), %r9
movl (%r9), %eax
movl %r14d, %ecx
movl %r14d, 0x14(%rsp)
movq %rcx, 0x20(%rsp)
movl %r14d, %edx
movl %r14d, %edi
cmpl %r14d, %eax
movq 0x8(%rsp), %r8
movq 0x30(%rsp), %r11
je 0x62d5
movq 0x10(%r9), %rcx
movl (%rcx,%rbx,4), %esi
movl %eax, 0x14(%rsp)
movl %eax, %edx
movq %rdx, 0x20(%rsp)
movl %eax, %edi
testl %r13d, %esi
jne 0x62d5
btsl %ebp, %esi
movl %esi, (%rcx,%rbx,4)
decl 0x4(%r9)
movl (%r9), %edi
movl %edi, %eax
movq %rax, 0x20(%rsp)
movl %edi, %edx
movl %edi, 0x14(%rsp)
jmp 0x62d5
movl %esi, %edx
testl %edx, %edx
je 0x65c2
leal -0x1(%rdx), %eax
movl %eax, %edi
andl $0x1, %edi
movq 0x10(%r9), %r8
xorl %esi, %esi
movq 0x38(%rsp), %r15
movl 0x14(%rsp), %ebx
movl %esi, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %r9d
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %r9d, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x65ac
testb $0x1, %r10b
jne 0x659a
movq 0x18(%rsp), %r10
movq 0x18(%r10), %r10
movl %esi, %r11d
cmpl $0x0, (%r10,%r11,4)
je 0x65ac
addl %edi, %esi
andl %eax, %esi
jne 0x6566
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
jmp 0x65f9
shrl %cl, %r9d
testb $0x3, %r9b
cmovnel %edx, %esi
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %r9
jmp 0x65cd
xorl %esi, %esi
movq 0x38(%rsp), %r15
movl 0x14(%rsp), %ebx
cmpl %edx, %esi
je 0x65f9
movq 0x20(%r9), %rax
movl %esi, %ecx
leaq (%rcx,%rcx,2), %rcx
movslq 0x4(%rax,%rcx,8), %rdi
movq 0x10(%rax,%rcx,8), %rsi
callq 0x5b6a
movq 0x18(%rsp), %r9
movq 0x8(%rsp), %r8
movl (%r9), %ebx
movl %ebx, %edx
testl %edx, %edx
je 0x66ce
xorl %esi, %esi
movq 0x10(%r9), %rax
movl %esi, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
leal (%rsi,%rsi), %ecx
shrl %cl, %eax
testb $0x3, %al
jne 0x66c4
movq 0x18(%r9), %rcx
movl %esi, %eax
movl (%rcx,%rax,4), %ecx
cmpl 0xc(%r8), %ecx
jae 0x66c4
movq 0x20(%r9), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rcx
movl 0x4(%rcx), %edi
movl $0x1, %edx
cmpl $0x2, %edi
jl 0x66bf
xorl %edx, %edx
movl $0x1, %eax
movl $0x10, %r8d
movq 0x10(%rcx), %r9
movslq %edx, %r10
shlq $0x4, %r10
movq 0x8(%r9,%r10), %r11
movq %r11, %rbx
shrq $0x10, %rbx
movq (%r9,%r8), %r14
shrq $0x10, %r14
cmpq %r14, %rbx
jae 0x668d
leaq (%r9,%r8), %rdi
incl %edx
movups (%rdi), %xmm0
movups %xmm0, 0x10(%r10,%r9)
movl 0x4(%rcx), %edi
jmp 0x66a1
movq 0x8(%r9,%r8), %rbx
cmpq %rbx, %r11
jae 0x66a1
addq %r10, %r9
addq $0x8, %r9
movq %rbx, (%r9)
incq %rax
movslq %edi, %r9
addq $0x10, %r8
cmpq %r9, %rax
jl 0x6655
movq 0x18(%rsp), %r9
movl (%r9), %ebx
incl %edx
movq 0x8(%rsp), %r8
movl %edx, 0x4(%rcx)
movl %ebx, %edx
incl %esi
cmpl %edx, %esi
jne 0x6603
incq %r15
movslq 0x14(%r8), %rax
cmpq %rax, %r15
jl 0x621c
movl $0x1, 0x54(%r8)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq