// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/tabix.c
// Function: parse_regions
static char **parse_regions(char *regions_fname, char **argv, int argc, int *nregs)
{
    kstring_t str = {0,0,0};
    int iseq = 0, ireg = 0;
    char **regs = NULL;
    *nregs = argc;

    if ( regions_fname )
    {
        // improve me: this is a too heavy machinery for parsing regions...

        regidx_t *idx = regidx_init(regions_fname, NULL, NULL, 0, NULL);
        if ( !idx ) {
            error_errno("Could not build region list for \"%s\"", regions_fname);
        }
        regitr_t *itr = regitr_init(idx);
        if ( !itr ) {
            error_errno("Could not initialize an iterator over \"%s\"",
                        regions_fname);
        }

        (*nregs) += regidx_nregs(idx);
        regs = (char**) malloc(sizeof(char*)*(*nregs));
        if (!regs) error_errno(NULL);

        int nseq;
        char **seqs = regidx_seq_names(idx, &nseq);
        for (iseq=0; iseq<nseq; iseq++)
        {
            if (regidx_overlap(idx, seqs[iseq], 0, HTS_POS_MAX, itr) < 0)
                error_errno("Failed to build overlapping regions list");

            while ( regitr_overlap(itr) )
            {
                str.l = 0;
                if (ksprintf(&str, "%s:%"PRIhts_pos"-%"PRIhts_pos, seqs[iseq], itr->beg+1, itr->end+1) < 0) {
                    error_errno(NULL);
                }
                regs[ireg] = strdup(str.s);
                if (!regs[ireg]) error_errno(NULL);
                ireg++;
            }
        }
        regidx_destroy(idx);
        regitr_destroy(itr);
    }
    free(str.s);

    if ( !ireg )
    {
        if ( argc )
        {
            regs = (char**) malloc(sizeof(char*)*argc);
            if (!regs) error_errno(NULL);
        }
        else
        {
            regs = (char**) malloc(sizeof(char*));
            if (!regs) error_errno(NULL);
            regs[0] = strdup(".");
            if (!regs[0]) error_errno(NULL);
            *nregs = 1;
        }
    }

    for (iseq=0; iseq<argc; iseq++, ireg++) {
        regs[ireg] = strdup(argv[iseq]);
        if (!regs[ireg]) error_errno(NULL);
    }
    return regs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4250
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x8(%rbp)
je 0x78f5
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rsi
movq %r8, %rdx
movq %r8, %rcx
callq 0x2c8f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x7775
movq -0x8(%rbp), %rsi
leaq 0x1025b6(%rip), %rdi    # 0x109d24
movb $0x0, %al
callq 0x5e40
movq -0x50(%rbp), %rdi
callq 0x2d8f0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x779b
movq -0x8(%rbp), %rsi
leaq 0x1025b5(%rip), %rdi    # 0x109d49
movb $0x0, %al
callq 0x5e40
movq -0x50(%rbp), %rdi
callq 0x2b9c0
movl %eax, %ecx
movq -0x20(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x4680
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x77d4
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
movq -0x50(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x2ba10
movq %rax, -0x68(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0x78e3
movq -0x50(%rbp), %rdi
movq -0x68(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x58(%rbp), %r8
xorl %eax, %eax
movl %eax, %edx
movabsq $0x7fffffff7fffffff, %rcx # imm = 0x7FFFFFFF7FFFFFFF
callq 0x2cf00
cmpl $0x0, %eax
jge 0x7832
leaq 0x102549(%rip), %rdi    # 0x109d74
movb $0x0, %al
callq 0x5e40
jmp 0x7834
movq -0x58(%rbp), %rdi
callq 0x2da00
cmpl $0x0, %eax
je 0x78d3
movq $0x0, -0x38(%rbp)
movq -0x68(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq -0x58(%rbp), %rax
movq 0x8(%rax), %r8
addq $0x1, %r8
leaq -0x38(%rbp), %rdi
leaq 0x109b0f(%rip), %rsi    # 0x11138b
movb $0x0, %al
callq 0x8fb0
cmpl $0x0, %eax
jge 0x7893
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
movq -0x28(%rbp), %rdi
callq 0x4950
movq %rax, %rdx
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x78c5
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7834
jmp 0x78d5
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x77ec
movq -0x50(%rbp), %rdi
callq 0x2c7d0
movq -0x58(%rbp), %rdi
callq 0x2d9d0
movq -0x28(%rbp), %rdi
callq 0x45b0
cmpl $0x0, -0x40(%rbp)
jne 0x798a
cmpl $0x0, -0x14(%rbp)
je 0x7933
movslq -0x14(%rbp), %rdi
shlq $0x3, %rdi
callq 0x4680
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x7931
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
jmp 0x7988
movl $0x8, %edi
callq 0x4680
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x7953
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
leaq 0x1084e2(%rip), %rdi    # 0x10fe3c
callq 0x4950
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x797e
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0x798a
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x79e9
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4950
movq %rax, %rdx
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x79d3
xorl %eax, %eax
movl %eax, %edi
movb $0x0, %al
callq 0x5e40
jmp 0x79d5
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x7991
movq -0x48(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)