// File: /workspace/github_c_makefile_star2_O1/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 0x5efe
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r8
movslq 0x50(%rdi), %rax
testq %rax, %rax
movq %rdi, (%rsp)
js 0x60ef
movq %rsi, %r14
movq 0x28(%r8), %rcx
movq (%rcx,%rax,8), %r15
movl 0x44(%r8), %esi
movq 0x60(%r8), %rbx
leaq 0x3c(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x851b
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0x5f73
movq $0x1, (%r13)
movl $0x1, %edi
movl $0x10, %esi
callq 0x21f0
movq %rax, 0x10(%r13)
movl (%r13), %eax
cmpl %eax, 0x4(%r13)
jne 0x5f97
leal (%rax,%rax), %ecx
movl %ecx, (%r13)
movq 0x10(%r13), %rdi
shll $0x5, %eax
movslq %eax, %rsi
callq 0x22e0
movq %rax, 0x10(%r13)
movq 0x10(%r13), %rax
movslq 0x4(%r13), %rcx
leal 0x1(%rcx), %edx
shlq $0x4, %rcx
movq %rbx, (%rax,%rcx)
movl %edx, 0x4(%r13)
movq %r14, 0x8(%rax,%rcx)
movq (%rsp), %rdx
movq 0x28(%rdx), %rax
movslq 0x50(%rdx), %rcx
movq (%rax,%rcx,8), %r15
movl 0xc(%rdx), %esi
incl %esi
movq 0x68(%rdx), %rbx
leaq 0x40(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x851b
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0x600c
movq $0x1, (%r13)
movl $0x1, %edi
movl $0x10, %esi
callq 0x21f0
movq %rax, 0x10(%r13)
movl (%r13), %eax
cmpl %eax, 0x4(%r13)
jne 0x6030
leal (%rax,%rax), %ecx
movl %ecx, (%r13)
movq 0x10(%r13), %rdi
shll $0x5, %eax
movslq %eax, %rsi
callq 0x22e0
movq %rax, 0x10(%r13)
movq 0x10(%r13), %rax
movslq 0x4(%r13), %rcx
leal 0x1(%rcx), %edx
shlq $0x4, %rcx
movq %rbx, (%rax,%rcx)
movl %edx, 0x4(%r13)
movq %r14, 0x8(%rax,%rcx)
movq (%rsp), %rdx
movq 0x28(%rdx), %rax
movslq 0x50(%rdx), %rcx
movq (%rax,%rcx,8), %r14
movl 0xc(%rdx), %esi
incl %esi
movq 0x78(%rdx), %r12
movq 0x80(%rdx), %rbx
leaq 0x44(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x851b
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r14), %r13
cmpl $0x0, (%r15)
je 0x60ab
movq $0x1, (%r13)
movl $0x1, %edi
movl $0x10, %esi
callq 0x21f0
movq %rax, 0x10(%r13)
movl (%r13), %eax
cmpl %eax, 0x4(%r13)
jne 0x60cf
leal (%rax,%rax), %ecx
movl %ecx, (%r13)
movq 0x10(%r13), %rdi
shll $0x5, %eax
movslq %eax, %rsi
callq 0x22e0
movq %rax, 0x10(%r13)
movq 0x10(%r13), %rax
movslq 0x4(%r13), %rcx
leal 0x1(%rcx), %edx
shlq $0x4, %rcx
movq %r12, (%rax,%rcx)
movl %edx, 0x4(%r13)
movq %rbx, 0x8(%rax,%rcx)
movq (%rsp), %r8
cmpl $0x0, 0x14(%r8)
jle 0x651a
xorl %r14d, %r14d
xorl %edx, %edx
cmpl $0x0, (%r8)
sete %dl
movq %r8, %rdi
movl %r14d, %esi
callq 0x6531
movq (%rsp), %r8
movq 0x28(%r8), %rax
movq (%rax,%r14,8), %rdx
testq %rdx, %rdx
je 0x650a
movq %r14, 0x20(%rsp)
movl 0x8(%r8), %r9d
testl %r9d, %r9d
movq %rdx, 0x8(%rsp)
jle 0x63a4
leal (%r9,%r9,2), %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
shll %cl, %r10d
cmpl $0x0, (%rdx)
je 0x6393
notl %r10d
movl $0x92492493, %eax       # imm = 0x92492493
imulq %rax, %r10
shrq $0x22, %r10
xorl %r14d, %r14d
movq %r9, 0x18(%rsp)
movq %r10, 0x10(%rsp)
movq 0x10(%rdx), %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 0x619f
incl %r14d
cmpl (%rdx), %r14d
jne 0x6170
jmp 0x6393
movq 0x18(%rdx), %rax
movl %r14d, %r12d
movl (%rax,%r12,4), %eax
cmpl 0xc(%r8), %eax
jae 0x6192
cmpl %r10d, %eax
jb 0x6192
leaq (%r12,%r12,2), %r15
shlq $0x3, %r15
addq 0x20(%rdx), %r15
cmpl 0x8(%r8), %r9d
jge 0x61ed
movslq 0x4(%r15), %rdi
cmpq $0x2, %rdi
jl 0x61ed
movq 0x10(%r15), %rsi
callq 0x5a8b
movq 0x10(%rsp), %r10
movq 0x18(%rsp), %r9
movq 0x8(%rsp), %rdx
movq (%rsp), %r8
movq 0x10(%r15), %rax
movslq 0x4(%r15), %rdi
movq %rdi, %rcx
shlq $0x4, %rcx
movq -0x8(%rax,%rcx), %rcx
shrq $0x10, %rcx
movq (%rax), %rax
shrq $0x10, %rax
subq %rax, %rcx
cmpq $0xffff, %rcx           # imm = 0xFFFF
ja 0x6192
movl (%rdx), %eax
testl %eax, %eax
je 0x62c6
movq %rdi, 0x30(%rsp)
movq 0x18(%rdx), %rdi
movl (%rdi,%r12,4), %r8d
decl %r8d
movl %r8d, %r9d
shrl $0x3, %r9d
movq %rax, 0x28(%rsp)
leal -0x1(%rax), %r10d
movl %r10d, %r11d
andl %r9d, %r11d
movl %r8d, %eax
shrl $0x6, %eax
andl $-0x8, %r8d
xorl %eax, %r8d
orl $0x1, %r8d
andl %r10d, %r8d
movq 0x10(%rdx), %r12
movl %r11d, %esi
movl %esi, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %eax
leal (%rsi,%rsi), %ecx
andl $0x1e, %ecx
movl %eax, %edx
shrl %cl, %edx
testb $0x2, %dl
jne 0x62a0
testb $0x1, %dl
jne 0x628c
movl %esi, %edx
cmpl %r9d, (%rdi,%rdx,4)
je 0x62a0
addl %r8d, %esi
andl %r10d, %esi
cmpl %r11d, %esi
jne 0x6267
movq 0x28(%rsp), %rax
movl %eax, %esi
jmp 0x62ac
shrl %cl, %eax
testb $0x3, %al
movq 0x28(%rsp), %rax
cmovnel %eax, %esi
movq (%rsp), %r8
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x30(%rsp), %rdi
jmp 0x62c8
xorl %esi, %esi
cmpl %eax, %esi
je 0x6192
movq 0x20(%rdx), %rax
movl %esi, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %r12
addl 0x4(%r12), %edi
cmpl (%r12), %edi
jle 0x6328
decl %edi
movl %edi, %eax
sarl %eax
orl %edi, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x10, %eax
orl %ecx, %eax
incl %eax
movl %eax, (%r12)
movq 0x10(%r12), %rdi
shll $0x4, %eax
movslq %eax, %rsi
callq 0x22e0
movq %rax, 0x10(%r12)
movslq 0x4(%r12), %rdi
shlq $0x4, %rdi
addq 0x10(%r12), %rdi
movq 0x10(%r15), %rsi
movslq 0x4(%r15), %rdx
shlq $0x4, %rdx
callq 0x2240
movl 0x4(%r15), %eax
addl %eax, 0x4(%r12)
movq 0x10(%r15), %rdi
callq 0x2050
movq 0x8(%rsp), %rdx
cmpl %r14d, (%rdx)
movq (%rsp), %r8
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r10
je 0x6192
movq 0x10(%rdx), %rax
movl (%rax,%rbx,4), %ecx
testl %r13d, %ecx
jne 0x6192
btsl %ebp, %ecx
movl %ecx, (%rax,%rbx,4)
decl 0x4(%rdx)
jmp 0x6192
leal -0x1(%r9), %eax
cmpl $0x1, %r9d
movl %eax, %r9d
jg 0x613d
movl (%rdx), %eax
testl %eax, %eax
je 0x640b
leal -0x1(%rax), %esi
movl %esi, %edi
andl $0x1, %edi
movq 0x10(%rdx), %r8
xorl %edx, %edx
movq 0x20(%rsp), %r14
movl %edx, %ecx
shrl $0x4, %ecx
movl (%r8,%rcx,4), %r9d
leal (%rdx,%rdx), %ecx
andl $0x1e, %ecx
movl %r9d, %r10d
shrl %cl, %r10d
testb $0x2, %r10b
jne 0x63fb
testb $0x1, %r10b
jne 0x63f1
movq 0x8(%rsp), %r10
movq 0x18(%r10), %r10
movl %edx, %r11d
cmpl $0x0, (%r10,%r11,4)
je 0x63fb
addl %edi, %edx
andl %esi, %edx
jne 0x63bd
movl %eax, %edx
jmp 0x6405
shrl %cl, %r9d
testb $0x3, %r9b
cmovnel %eax, %edx
movq (%rsp), %r8
jmp 0x6412
xorl %edx, %edx
movq 0x20(%rsp), %r14
cmpl %eax, %edx
je 0x6438
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %edx, %ecx
leaq (%rcx,%rcx,2), %rcx
movslq 0x4(%rax,%rcx,8), %rdi
movq 0x10(%rax,%rcx,8), %rsi
callq 0x5a8b
movq (%rsp), %r8
movq 0x8(%rsp), %rsi
cmpl $0x0, (%rsi)
je 0x650a
xorl %eax, %eax
movq 0x10(%rsi), %rcx
movl %eax, %edx
shrl $0x4, %edx
movl (%rcx,%rdx,4), %edx
leal (%rax,%rax), %ecx
shrl %cl, %edx
testb $0x3, %dl
jne 0x6500
movq 0x18(%rsi), %rdx
movl %eax, %ecx
movl (%rdx,%rcx,4), %edx
cmpl 0xc(%r8), %edx
jae 0x6500
movq 0x20(%rsi), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rcx
movl $0x1, %edx
cmpl $0x2, 0x4(%rcx)
jl 0x64f8
xorl %edx, %edx
movl $0x1, %esi
movl $0x10, %edi
movq 0x10(%rcx), %r8
movslq %edx, %r9
shlq $0x4, %r9
movq 0x8(%r8,%r9), %r10
movq %r10, %r11
shrq $0x10, %r11
movq (%r8,%rdi), %rbx
shrq $0x10, %rbx
cmpq %rbx, %r11
jae 0x64ce
leaq (%r8,%rdi), %r10
incl %edx
movups (%r10), %xmm0
movups %xmm0, 0x10(%r9,%r8)
jmp 0x64e2
movq 0x8(%r8,%rdi), %r11
cmpq %r11, %r10
jae 0x64e2
addq %r9, %r8
addq $0x8, %r8
movq %r11, (%r8)
incq %rsi
movslq 0x4(%rcx), %r8
addq $0x10, %rdi
cmpq %r8, %rsi
jl 0x6498
incl %edx
movq (%rsp), %r8
movl %edx, 0x4(%rcx)
movq 0x8(%rsp), %rsi
incl %eax
cmpl (%rsi), %eax
jne 0x6448
incq %r14
movslq 0x14(%r8), %rax
cmpq %rax, %r14
jl 0x60fd
movl $0x1, 0x54(%r8)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq