// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x28(%rdi), %rax
movslq %esi, %rbx
movq (%rax,%rbx,8), %rax
shlq $0x4, %rbx
addq 0x30(%rdi), %rbx
testq %rax, %rax
je 0x11665
movl (%rax), %ecx
testl %ecx, %ecx
je 0x1167f
movl 0xc(%rdi), %r10d
incl %r10d
movq %rcx, (%rsp)
leal -0x1(%rcx), %r11d
movl %r11d, %ebp
andl %r10d, %ebp
movq 0x10(%rax), %r14
movl $0x1, %r15d
xorl %r8d, %r8d
movl %ebp, %r9d
movl %r9d, %ecx
shrl $0x4, %ecx
movl (%r14,%rcx,4), %r12d
leal (%r9,%r9), %ecx
andl $0x1e, %ecx
movl %r12d, %r13d
shrl %cl, %r13d
testb $0x2, %r13b
jne 0x1166e
testb $0x1, %r13b
jne 0x11655
movq 0x18(%rax), %r13
movl %r9d, %esi
cmpl %r10d, (%r13,%rsi,4)
je 0x1166e
addl %r15d, %r9d
andl %r11d, %r9d
incl %r15d
cmpl %ebp, %r9d
jne 0x11624
jmp 0x1169f
movl (%rbx), %esi
movl $0x1, %ecx
jmp 0x116c2
shrl %cl, %r12d
testb $0x3, %r12b
movq (%rsp), %rcx
cmovnel %ecx, %r9d
jmp 0x11682
xorl %r9d, %r9d
cmpl %ecx, %r9d
jne 0x1168c
xorl %r8d, %r8d
jmp 0x1169f
movq 0x20(%rax), %rcx
movl %r9d, %esi
leaq (%rsi,%rsi,2), %rsi
movq 0x10(%rcx,%rsi,8), %rcx
movq (%rcx), %r8
movl (%rbx), %esi
testl %esi, %esi
jle 0x116c0
movq 0x8(%rbx), %r9
xorl %ecx, %ecx
cmpq $-0x1, (%r9,%rcx,8)
jne 0x116c2
movq %r8, (%r9,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x116ab
jmp 0x116e3
xorl %ecx, %ecx
cmpl %esi, %ecx
jge 0x116e3
movq 0x8(%rbx), %r8
movl %ecx, %ecx
cmpq $-0x1, (%r8,%rcx,8)
jne 0x116dc
movq -0x8(%r8,%rcx,8), %r9
movq %r9, (%r8,%rcx,8)
incq %rcx
cmpl %ecx, %esi
jg 0x116cc
testq %rax, %rax
je 0x117aa
movl (%rax), %r8d
testq %r8, %r8
je 0x11797
movq 0x10(%rax), %r9
xorl %r10d, %r10d
movl $0x92492493, %r11d      # imm = 0x92492493
movl %r10d, %ecx
shrl $0x4, %ecx
movl (%r9,%rcx,4), %ebp
leal (%r10,%r10), %ecx
shrl %cl, %ebp
testb $0x3, %bpl
jne 0x1178b
movq 0x18(%rax), %rcx
movl (%rcx,%r10,4), %ebp
cmpl 0xc(%rdi), %ebp
jae 0x1177c
xorl %r14d, %r14d
testl %ebp, %ebp
je 0x11745
movl %ebp, %ecx
incl %r14d
decl %ecx
movl %ecx, %r15d
sarl $0x3, %r15d
cmpl $0x7, %ecx
movl %r15d, %ecx
ja 0x11731
leal (%r14,%r14,2), %ecx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
shll %cl, %r15d
movl 0x8(%rdi), %ecx
notl %r15d
imulq %r11, %r15
shrq $0x22, %r15
subl %r15d, %ebp
subl %r14d, %ecx
leal (%rcx,%rcx,2), %ecx
shll %cl, %ebp
cmpl %esi, %ebp
jge 0x1177c
movq 0x8(%rbx), %rcx
movslq %ebp, %r14
movq (%rcx,%r14,8), %rcx
jmp 0x1177e
xorl %ecx, %ecx
movq 0x20(%rax), %r15
leaq (%r10,%r10,2), %r14
movq %rcx, 0x8(%r15,%r14,8)
incq %r10
cmpq %r8, %r10
jne 0x11705
testl %edx, %edx
je 0x117aa
movq 0x8(%rbx), %rdi
callq 0x4610
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq