// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/hts.c
// Function: hts_itr_regions
hts_itr_t *hts_itr_regions(const hts_idx_t *idx, hts_reglist_t *reglist, int count, hts_name2id_f getid, void *hdr, hts_itr_multi_query_func *itr_specific, hts_readrec_func *readrec, hts_seek_func *seek, hts_tell_func *tell) {

    int i;

    if (!reglist)
        return NULL;

    hts_itr_t *itr = (hts_itr_t*)calloc(1, sizeof(hts_itr_t));
    if (itr) {
        itr->n_reg = count;
        itr->readrec = readrec;
        itr->seek = seek;
        itr->tell = tell;
        itr->reg_list = reglist;
        itr->finished = 0;
        itr->nocoor = 0;
        itr->multi = 1;

        for (i = 0; i < itr->n_reg; i++) {
            if (itr->reg_list[i].reg) {
                if (!strcmp(itr->reg_list[i].reg, ".")) {
                    itr->reg_list[i].tid = HTS_IDX_START;
                    continue;
                }

                if (!strcmp(itr->reg_list[i].reg, "*")) {
                    itr->reg_list[i].tid = HTS_IDX_NOCOOR;
                    continue;
                }

                itr->reg_list[i].tid = getid(hdr, reglist[i].reg);
                if (itr->reg_list[i].tid < 0) {
                    if (itr->reg_list[i].tid < -1) {
                        hts_log_error("Failed to parse header");
                        hts_itr_destroy(itr);
                        return NULL;
                    } else {
                        hts_log_warning("Region '%s' specifies an unknown reference name. Continue anyway", reglist[i].reg);
                    }
                }
            }
        }

        qsort(itr->reg_list, itr->n_reg, sizeof(hts_reglist_t), compare_regions);
        if (itr_specific(idx, itr) != 0) {
            hts_log_error("Failed to create the multi-region iterator!");
            hts_itr_destroy(itr);
            itr = NULL;
        }
    }

    return itr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x10(%rsp)
testq %rsi, %rsi
je 0x16778
movq %r9, %r14
movq %rcx, %r13
movl %edx, %r15d
movq %rsi, %rbp
movq %rdi, %r12
pushq $0x1
popq %rdi
movl $0x90, %esi
callq 0x4300
testq %rax, %rax
je 0x16778
movq %rax, %rbx
movq %r12, (%rsp)
movq %r14, 0x8(%rsp)
movq 0x60(%rsp), %rax
movq 0x58(%rsp), %rcx
movq 0x50(%rsp), %rdx
movl %r15d, 0x10(%rbx)
movq %rdx, 0x68(%rbx)
movq %rcx, 0x70(%rbx)
movq %rax, 0x78(%rbx)
movq %rbp, 0x28(%rbx)
movl $0x10, (%rbx)
xorl %r14d, %r14d
xorl %r12d, %r12d
movslq %r15d, %rsi
movq 0x28(%rbx), %rdi
cmpq %rsi, %r12
jge 0x16731
movq (%rdi,%r14), %rax
testq %rax, %rax
je 0x16721
movzbl (%rax), %ecx
cmpl $0x2a, %ecx
je 0x166d4
cmpl $0x2e, %ecx
jne 0x166da
cmpb $0x0, 0x1(%rax)
jne 0x166da
movl $0xfffffffd, 0x10(%rdi,%r14) # imm = 0xFFFFFFFD
jmp 0x16721
cmpb $0x0, 0x1(%rax)
je 0x16718
movq (%rbp,%r14), %rsi
movq 0x10(%rsp), %rdi
callq *%r13
movq 0x28(%rbx), %rcx
movl %eax, 0x10(%rcx,%r14)
testl %eax, %eax
jns 0x16721
cmpl $-0x1, %eax
jne 0x16758
movq (%rbp,%r14), %rcx
pushq $0x3
popq %rdi
leaq 0x620a0(%rip), %rsi     # 0x787a8
leaq 0x620c0(%rip), %rdx     # 0x787cf
xorl %eax, %eax
callq 0x110c6
jmp 0x16721
movl $0xfffffffe, 0x10(%rdi,%r14) # imm = 0xFFFFFFFE
incq %r12
movl 0x10(%rbx), %r15d
addq $0x28, %r14
jmp 0x1669d
leaq 0x54(%rip), %rcx        # 0x1678c
pushq $0x28
popq %rdx
callq 0x4990
movq (%rsp), %rdi
movq %rbx, %rsi
callq *0x8(%rsp)
testl %eax, %eax
je 0x1677a
leaq 0x620ba(%rip), %rdx     # 0x78810
jmp 0x1675f
leaq 0x62059(%rip), %rdx     # 0x787b8
leaq 0x62042(%rip), %rsi     # 0x787a8
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
movq %rbx, %rdi
callq 0x14da5
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq