// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: update_loff
static void update_loff(hts_idx_t *idx, int i, int free_lidx)
{
    bidx_t *bidx = idx->bidx[i];
    lidx_t *lidx = &idx->lidx[i];
    khint_t k;
    int l;
    uint64_t offset0 = 0;
    if (bidx) {
        k = kh_get(bin, bidx, META_BIN(idx));
        if (k != kh_end(bidx))
            offset0 = kh_val(bidx, k).list[0].u;
        for (l = 0; l < lidx->n && lidx->offset[l] == (uint64_t)-1; ++l)
            lidx->offset[l] = offset0;
    } else l = 1;
    for (; l < lidx->n; ++l) // fill missing values
        if (lidx->offset[l] == (uint64_t)-1)
            lidx->offset[l] = lidx->offset[l-1];
    if (bidx == 0) return;
    for (k = kh_begin(bidx); k != kh_end(bidx); ++k) // set loff
        if (kh_exist(bidx, k))
        {
            if ( kh_key(bidx, k) < idx->n_bins )
            {
                int bot_bin = hts_bin_bot(kh_key(bidx, k), idx->n_lvls);
                // disable linear index if bot_bin out of bounds
                kh_val(bidx, k).loff = bot_bin < lidx->n ? lidx->offset[bot_bin] : 0;
            }
            else
                kh_val(bidx, k).loff = 0;
        }
    if (free_lidx) {
        free(lidx->offset);
        lidx->m = lidx->n = 0;
        lidx->offset = 0;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rdi, %r14
movq 0x28(%rdi), %rax
movslq %esi, %r12
movq (%rax,%r12,8), %r15
shlq $0x4, %r12
addq 0x30(%rdi), %r12
testq %r15, %r15
je 0xe742
movl 0xc(%r14), %esi
incl %esi
movq %r15, %rdi
callq 0xf2d4
xorl %ecx, %ecx
cmpl (%r15), %eax
jne 0xe74b
xorl %eax, %eax
jmp 0xe75d
movl (%r12), %esi
pushq $0x1
popq %rax
jmp 0xe789
movq 0x20(%r15), %rdx
movl %eax, %eax
imulq $0x18, %rax, %rax
movq 0x10(%rdx,%rax), %rax
movq (%rax), %rax
movl (%r12), %esi
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
cmpq %rcx, %rdx
je 0xe787
movq 0x8(%r12), %rdi
cmpq $-0x1, (%rdi,%rcx,8)
jne 0xe785
movq %rax, (%rdi,%rcx,8)
incq %rcx
jmp 0xe76b
movl %ecx, %edx
movl %edx, %eax
movslq %esi, %rcx
cmpq %rcx, %rax
jge 0xe7ab
movq 0x8(%r12), %rdx
cmpq $-0x1, (%rdx,%rax,8)
jne 0xe7a6
movq -0x8(%rdx,%rax,8), %rdi
movq %rdi, (%rdx,%rax,8)
incq %rax
jmp 0xe78c
testq %r15, %r15
je 0xe862
movl (%r15), %edi
xorl %r8d, %r8d
pushq $-0x1
popq %r9
pushq $0x7
popq %r10
cmpq %rdi, %r8
je 0xe84c
movq 0x10(%r15), %rax
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%rax,%rcx,4), %eax
leal (%r8,%r8), %ecx
shrl %cl, %eax
testb $0x3, %al
jne 0xe844
movq 0x18(%r15), %rax
movl (%rax,%r8,4), %r11d
cmpl 0xc(%r14), %r11d
jae 0xe835
movl 0x8(%r14), %r13d
xorl %ecx, %ecx
movl %r11d, %eax
testl %eax, %eax
je 0xe807
decl %eax
sarl $0x3, %eax
addl $0x3, %ecx
jmp 0xe7f9
movl %r9d, %eax
shll %cl, %eax
notl %eax
xorl %edx, %edx
divl %r10d
subl %eax, %r11d
leal (%r13,%r13,2), %eax
subl %ecx, %eax
movl %eax, %ecx
shll %cl, %r11d
cmpl %esi, %r11d
jge 0xe835
movq 0x8(%r12), %rax
movslq %r11d, %rcx
movq (%rax,%rcx,8), %rax
jmp 0xe837
xorl %eax, %eax
movq 0x20(%r15), %rcx
imulq $0x18, %r8, %rdx
movq %rax, 0x8(%rcx,%rdx)
incq %r8
jmp 0xe7c2
testl %ebx, %ebx
je 0xe862
movq 0x8(%r12), %rdi
callq 0x4600
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq