// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/hts.c
// Function: hts_idx_finish
void hts_idx_finish(hts_idx_t *idx, uint64_t final_offset)
{
    int i;
    if (idx == NULL || idx->z.finished) return; // do not run this function on an empty index or 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], META_BIN(idx), idx->z.off_beg, final_offset);
        insert_to_b(idx->bidx[idx->z.save_tid], META_BIN(idx), 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:
testq %rdi, %rdi
je 0x4f8ca
movq %rdi, %r8
cmpl $0x0, 0x54(%rdi)
je 0x4f8cb
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movslq 0x50(%r8), %rax
testq %rax, %rax
movq %r8, 0x8(%rsp)
js 0x4faf8
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 0x52225
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0x4f946
movq $0x1, (%r13)
leaq 0x4(%r13), %r15
movl $0x1, %edi
movl $0x10, %esi
callq 0x6470
movq %rax, 0x10(%r13)
xorl %ecx, %ecx
jmp 0x4f978
leaq 0x4(%r13), %r15
movl 0x4(%r13), %ecx
cmpl (%r13), %ecx
jne 0x4f974
addl %ecx, %ecx
movl %ecx, (%r13)
movq 0x10(%r13), %rdi
movslq %ecx, %rsi
shlq $0x4, %rsi
callq 0x6c80
movq %rax, 0x10(%r13)
movl 0x4(%r13), %ecx
jmp 0x4f978
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 0x52225
movl %eax, %eax
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x20(%r15), %r13
cmpl $0x0, (%r12)
je 0x4f9f2
movq $0x1, (%r13)
leaq 0x4(%r13), %r15
movl $0x1, %edi
movl $0x10, %esi
callq 0x6470
movq %rax, 0x10(%r13)
xorl %ecx, %ecx
jmp 0x4fa24
leaq 0x4(%r13), %r15
movl 0x4(%r13), %ecx
cmpl (%r13), %ecx
jne 0x4fa20
addl %ecx, %ecx
movl %ecx, (%r13)
movq 0x10(%r13), %rdi
movslq %ecx, %rsi
shlq $0x4, %rsi
callq 0x6c80
movq %rax, 0x10(%r13)
movl 0x4(%r13), %ecx
jmp 0x4fa24
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 0x52225
movl %eax, %eax
leaq (%rax,%rax,2), %r12
shlq $0x3, %r12
addq 0x20(%r14), %r12
cmpl $0x0, (%r15)
je 0x4faa4
movq $0x1, (%r12)
leaq 0x4(%r12), %rbx
movl $0x1, %edi
movl $0x10, %esi
callq 0x6470
movq %rax, 0x10(%r12)
xorl %ecx, %ecx
jmp 0x4fadc
leaq 0x4(%r12), %rbx
movl 0x4(%r12), %ecx
cmpl (%r12), %ecx
jne 0x4fad7
addl %ecx, %ecx
movl %ecx, (%r12)
movq 0x10(%r12), %rdi
movslq %ecx, %rsi
shlq $0x4, %rsi
callq 0x6c80
movq %rax, 0x10(%r12)
movl 0x4(%r12), %ecx
jmp 0x4fadc
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 0x4ffd8
xorl %r15d, %r15d
xorl %edx, %edx
cmpl $0x0, (%r8)
sete %dl
movq %r8, %rdi
movl %r15d, %esi
callq 0x4ffef
movq 0x8(%rsp), %r8
movq 0x28(%r8), %rax
movq (%rax,%r15,8), %rsi
testq %rsi, %rsi
je 0x4ffc8
movq %r15, 0x38(%rsp)
movl 0x8(%r8), %r11d
movl (%rsi), %edx
testl %r11d, %r11d
movq %rsi, 0x18(%rsp)
movl %edx, 0x14(%rsp)
jle 0x4fe3b
movl %edx, %eax
movq %rax, 0x20(%rsp)
movl %edx, %edi
movl %edx, %r9d
leal (%r11,%r11,2), %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
shll %cl, %r10d
xorl %eax, %eax
testl %edx, %edx
jne 0x4fb80
leal -0x1(%r11), %ecx
movl %eax, %edx
cmpl $0x1, %r11d
movl %ecx, %r11d
jg 0x4fb59
jmp 0x4fe3d
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(%rsi), %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 0x4fbcc
incl %r14d
movl %r9d, %eax
cmpl %r9d, %r14d
jne 0x4fb9d
jmp 0x4fb6c
movq 0x18(%rsi), %rax
movl %r14d, %r12d
movl (%rax,%r12,4), %eax
cmpl 0xc(%r8), %eax
jae 0x4fbbf
cmpl 0x50(%rsp), %eax
jb 0x4fbbf
leaq (%r12,%r12,2), %r15
shlq $0x3, %r15
addq 0x20(%rsi), %r15
cmpl 0x8(%r8), %r11d
jge 0x4fc26
movslq 0x4(%r15), %rdi
cmpq $0x2, %rdi
movq 0x20(%rsp), %rdx
jl 0x4fc2b
movq 0x10(%r15), %rsi
callq 0x4f3c1
movq 0x30(%rsp), %r11
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %r8
movl (%rsi), %eax
movl %eax, 0x14(%rsp)
movl %eax, %edx
jmp 0x4fc2b
movq 0x20(%rsp), %rdx
movq 0x10(%r15), %rdi
movslq 0x4(%r15), %r9
movq %r9, %rax
shlq $0x4, %rax
movq -0x8(%rdi,%rax), %rax
shrq $0x10, %rax
movq (%rdi), %rcx
shrq $0x10, %rcx
subq %rcx, %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
movq %rdx, 0x20(%rsp)
ja 0x4fcee
movq %r9, 0x48(%rsp)
testl %edx, %edx
movq %rdi, 0x40(%rsp)
je 0x4fd17
movq %rsi, %rax
movq 0x18(%rsi), %rsi
movl (%rsi,%r12,4), %r9d
decl %r9d
shrl $0x3, %r9d
leal -0x1(%rdx), %r11d
movl %r9d, %r12d
andl %r11d, %r12d
movq 0x10(%rax), %rax
movl $0x1, %r8d
movl %r12d, %r10d
movl %r10d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %edx
leal (%r10,%r10), %ecx
andl $0x1e, %ecx
movl %edx, %edi
shrl %cl, %edi
testb $0x2, %dil
jne 0x4fcf8
testb $0x1, %dil
jne 0x4fcc2
movl %r10d, %edi
cmpl %r9d, (%rsi,%rdi,4)
je 0x4fcf8
addl %r8d, %r10d
andl %r11d, %r10d
incl %r8d
cmpl %r12d, %r10d
jne 0x4fc99
movq 0x20(%rsp), %rax
movl %eax, %edi
movl %eax, %r9d
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %r11
jmp 0x4fbbf
movl %edx, %edi
movl %edx, %r9d
jmp 0x4fbbf
shrl %cl, %edx
testb $0x3, %dl
movq 0x20(%rsp), %rdx
cmovnel %edx, %r10d
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %r11
jmp 0x4fd1a
xorl %r10d, %r10d
movl %edx, %edi
movl %edx, %r9d
cmpl %edx, %r10d
je 0x4fbbf
movq 0x20(%rsi), %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 0x4fda0
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
movslq %ecx, %rax
movq %rax, %rsi
shlq $0x4, %rsi
incl %eax
movl %eax, (%r12)
movq 0x10(%r12), %rdi
addq $0x10, %rsi
callq 0x6c80
movq %rax, 0x10(%r12)
movl 0x4(%r12), %ecx
movq 0x10(%r15), %rsi
movslq 0x4(%r15), %rdx
jmp 0x4fdaa
movq 0x10(%r12), %rax
movq 0x40(%rsp), %rsi
movslq %ecx, %rdi
shlq $0x4, %rdi
addq %rax, %rdi
shlq $0x4, %rdx
callq 0x6570
movl 0x4(%r15), %eax
addl %eax, 0x4(%r12)
movq 0x10(%r15), %rdi
callq 0x68a0
movq 0x18(%rsp), %rsi
movl (%rsi), %eax
movl %r14d, %ecx
movl %r14d, 0x14(%rsp)
movq %rcx, 0x20(%rsp)
movl %r14d, %edi
movl %r14d, %r9d
cmpl %r14d, %eax
movq 0x8(%rsp), %r8
movq 0x30(%rsp), %r11
je 0x4fbbf
movq 0x10(%rsi), %rcx
movl (%rcx,%rbx,4), %edx
movl %eax, 0x14(%rsp)
movl %eax, %edi
movq %rdi, 0x20(%rsp)
movl %eax, %r9d
testl %r13d, %edx
jne 0x4fbbf
btsl %ebp, %edx
movl %edx, (%rcx,%rbx,4)
decl 0x4(%rsi)
movl (%rsi), %r9d
movl %r9d, %eax
movq %rax, 0x20(%rsp)
movl %r9d, %edi
movl %r9d, 0x14(%rsp)
jmp 0x4fbbf
movl %edx, %edi
testl %edi, %edi
je 0x4feb9
movq %rsi, %rax
leal -0x1(%rdi), %esi
movq 0x10(%rax), %r8
xorl %edx, %edx
movl $0x1, %eax
movq 0x38(%rsp), %r15
movl 0x14(%rsp), %ebx
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 0x4fea3
testb $0x1, %r10b
jne 0x4fe8f
movq 0x18(%rsp), %r10
movq 0x18(%r10), %r10
movl %edx, %r11d
cmpl $0x0, (%r10,%r11,4)
je 0x4fea3
addl %eax, %edx
incl %eax
andl %esi, %edx
jne 0x4fe5b
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rsi
jmp 0x4feef
shrl %cl, %r9d
testb $0x3, %r9b
cmovnel %edi, %edx
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rsi
jmp 0x4fec4
xorl %edx, %edx
movq 0x38(%rsp), %r15
movl 0x14(%rsp), %ebx
cmpl %edi, %edx
je 0x4feef
movq 0x20(%rsi), %rax
movl %edx, %ecx
leaq (%rcx,%rcx,2), %rcx
movslq 0x4(%rax,%rcx,8), %rdi
movq 0x10(%rax,%rcx,8), %rsi
callq 0x4f3c1
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %r8
movl (%rsi), %ebx
movl %ebx, %edi
testl %edi, %edi
je 0x4ffc8
xorl %edx, %edx
movq 0x10(%rsi), %rax
movl %edx, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
leal (%rdx,%rdx), %ecx
shrl %cl, %eax
testb $0x3, %al
jne 0x4ffbe
movq 0x18(%rsi), %rcx
movl %edx, %eax
movl (%rcx,%rax,4), %ecx
cmpl 0xc(%r8), %ecx
jae 0x4ffbe
movq 0x20(%rsi), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rcx
movl 0x4(%rcx), %edi
movl $0x1, %esi
cmpl $0x2, %edi
jl 0x4ffb4
xorl %esi, %esi
movl $0x1, %eax
movl $0x10, %r8d
movq 0x10(%rcx), %r9
movslq %esi, %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 0x4ff83
leaq (%r9,%r8), %rdi
incl %esi
movups (%rdi), %xmm0
movups %xmm0, 0x10(%r10,%r9)
movl 0x4(%rcx), %edi
jmp 0x4ff97
movq 0x8(%r9,%r8), %rbx
cmpq %rbx, %r11
jae 0x4ff97
addq %r10, %r9
addq $0x8, %r9
movq %rbx, (%r9)
incq %rax
movslq %edi, %r9
addq $0x10, %r8
cmpq %r9, %rax
jl 0x4ff4b
movq 0x18(%rsp), %rax
movl (%rax), %ebx
incl %esi
movq 0x8(%rsp), %r8
movl %esi, 0x4(%rcx)
movl %ebx, %edi
movq 0x18(%rsp), %rsi
incl %edx
cmpl %edi, %edx
jne 0x4fef9
incq %r15
movslq 0x14(%r8), %rax
cmpq %rax, %r15
jl 0x4fb06
movl $0x1, 0x54(%r8)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq