// File: /workspace/github_cpp_makefile_star2_O1/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 0x115ce
movl (%rax), %esi
testl %esi, %esi
je 0x115e2
movl 0xc(%rdi), %r9d
incl %r9d
leal -0x1(%rsi), %r10d
movl %r10d, %r11d
andl %r9d, %r11d
movq 0x10(%rax), %r14
movl $0x1, %ebp
movl %r11d, %r8d
movl %r8d, %ecx
shrl $0x4, %ecx
movl (%r14,%rcx,4), %r15d
leal (%r8,%r8), %ecx
andl $0x1e, %ecx
movl %r15d, %r12d
shrl %cl, %r12d
testb $0x2, %r12b
jne 0x115d5
testb $0x1, %r12b
jne 0x115bc
movq 0x18(%rax), %r12
movl %r8d, %r13d
cmpl %r9d, (%r12,%r13,4)
je 0x115d5
addl %ebp, %r8d
andl %r10d, %r8d
incl %ebp
cmpl %r11d, %r8d
jne 0x1158c
movl %esi, %r8d
jmp 0x115e5
movl $0x1, %ecx
jmp 0x11627
shrl %cl, %r15d
testb $0x3, %r15b
cmovnel %esi, %r8d
jmp 0x115e5
xorl %r8d, %r8d
xorl %ecx, %ecx
cmpl %esi, %r8d
jne 0x115f0
xorl %esi, %esi
jmp 0x11603
movq 0x20(%rax), %rsi
movl %r8d, %r8d
leaq (%r8,%r8,2), %r8
movq 0x10(%rsi,%r8,8), %rsi
movq (%rsi), %rsi
movl (%rbx), %r8d
testl %r8d, %r8d
jle 0x11627
movq 0x8(%rbx), %r9
xorl %ecx, %ecx
cmpq $-0x1, (%r9,%rcx,8)
jne 0x11627
movq %rsi, (%r9,%rcx,8)
incq %rcx
cmpq %rcx, %r8
jne 0x11611
movl %r8d, %ecx
movl (%rbx), %esi
cmpl %esi, %ecx
jge 0x1164f
movl %ecx, %r8d
shlq $0x3, %r8
addq 0x8(%rbx), %r8
cmpq $-0x1, (%r8)
jne 0x11645
movq -0x8(%r8), %r9
movq %r9, (%r8)
addq $0x8, %r8
incl %ecx
cmpl %ecx, %esi
jg 0x11638
testq %rax, %rax
je 0x11716
movl (%rax), %r8d
testq %r8, %r8
je 0x11703
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 0x116f7
movq 0x18(%rax), %rcx
movl (%rcx,%r10,4), %ebp
cmpl 0xc(%rdi), %ebp
jae 0x116e8
xorl %r14d, %r14d
testl %ebp, %ebp
je 0x116b1
movl %ebp, %ecx
incl %r14d
decl %ecx
movl %ecx, %r15d
sarl $0x3, %r15d
cmpl $0x7, %ecx
movl %r15d, %ecx
ja 0x1169d
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 0x116e8
movq 0x8(%rbx), %rcx
movslq %ebp, %r14
movq (%rcx,%r14,8), %rcx
jmp 0x116ea
xorl %ecx, %ecx
movq 0x20(%rax), %r14
leaq (%r10,%r10,2), %r15
movq %rcx, 0x8(%r14,%r15,8)
incq %r10
cmpq %r8, %r10
jne 0x11671
testl %edx, %edx
je 0x11716
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