// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: hts_itr_off
uint64_t hts_itr_off(const hts_idx_t* idx, int tid) {

    int i;
    bidx_t* bidx;
    uint64_t off0 = (uint64_t) -1;
    khint_t k;
    switch (tid) {
    case HTS_IDX_START:
        // Find the smallest offset, note that sequence ids may not be ordered sequentially
        for (i = 0; i < idx->n; i++) {
            bidx = idx->bidx[i];
            k = kh_get(bin, bidx, META_BIN(idx));
            if (k == kh_end(bidx))
                continue;

            if (off0 > kh_val(bidx, k).list[0].u)
                off0 = kh_val(bidx, k).list[0].u;
        }
        if (off0 == (uint64_t) -1 && idx->n_no_coor)
            off0 = 0;
        // only no-coor reads in this bam
        break;
    case HTS_IDX_NOCOOR:
        /* No-coor reads sort after all of the mapped reads.  The position
           is not stored in the index itself, so need to find the end
           offset for the last mapped read.  A loop is needed here in
           case references at the end of the file have no mapped reads,
           or sequence ids are not ordered sequentially.
           See issue samtools#568 and commits b2aab8, 60c22d and cc207d. */
        for (i = 0; i < idx->n; i++) {
            bidx = idx->bidx[i];
            k = kh_get(bin, bidx, META_BIN(idx));
            if (k != kh_end(bidx)) {
                if (off0 == (uint64_t) -1 || off0 < kh_val(bidx, k).list[0].v) {
                    off0 = kh_val(bidx, k).list[0].v;
                }
            }
        }
        if (off0 == (uint64_t) -1 && idx->n_no_coor)
            off0 = 0;
        // only no-coor reads in this bam
        break;
    case HTS_IDX_REST:
        off0 = 0;
        break;
    case HTS_IDX_NONE:
        off0 = 0;
        break;
    }

    return off0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $-0x1, -0x20(%rbp)
movl -0xc(%rbp), %eax
addl $0x5, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x3, %eax
ja 0x20dea
movq -0x30(%rbp), %rax
leaq 0xcedf5(%rip), %rcx     # 0xefa4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x20cfa
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xc(%rax), %esi
addl $0x1, %esi
callq 0x20ab0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x20cae
jmp 0x20cec
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0x24(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
cmpq (%rcx), %rax
jbe 0x20cea
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x20cec
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x20c67
cmpq $-0x1, -0x20(%rbp)
jne 0x20d14
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x20d14
movq $0x0, -0x20(%rbp)
jmp 0x20dea
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x20dbc
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xc(%rax), %esi
addl $0x1, %esi
callq 0x20ab0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0x20dac
cmpq $-0x1, -0x20(%rbp)
je 0x20d8c
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0x24(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jae 0x20daa
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x20dac
jmp 0x20dae
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x20d20
cmpq $-0x1, -0x20(%rbp)
jne 0x20dd6
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x20dd6
movq $0x0, -0x20(%rbp)
jmp 0x20dea
movq $0x0, -0x20(%rbp)
jmp 0x20dea
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)