// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hts.c
// Function: hts_readlist
char **hts_readlist(const char *string, int is_file, int *_n)
{
    unsigned int m = 0, n = 0;
    char **s = 0, **s_new;
    if ( is_file )
    {
        BGZF *fp = bgzf_open(string, "r");
        if ( !fp ) return NULL;

        kstring_t str;
        int ret;
        str.s = 0; str.l = str.m = 0;
        while ((ret = bgzf_getline(fp, '\n', &str)) >= 0)
        {
            if (str.l == 0) continue;
            if (n == 0 && hts_is_utf16_text(&str))
                hts_log_warning("'%s' appears to be encoded as UTF-16", string);
            if (hts_resize(char*, n + 1, &m, &s, 0) < 0)
                goto err;
            s[n] = strdup(str.s);
            if (!s[n])
                goto err;
            n++;
        }
        if (ret < -1) // Read error
            goto err;
        bgzf_close(fp);
        free(str.s);
    }
    else
    {
        const char *q = string, *p = string;
        while ( 1 )
        {
            if (*p == ',' || *p == 0)
            {
                if (hts_resize(char*, n + 1, &m, &s, 0) < 0)
                    goto err;
                s[n] = (char*)calloc(p - q + 1, 1);
                if (!s[n])
                    goto err;
                strncpy(s[n++], q, p - q);
                q = p + 1;
            }
            if ( !*p ) break;
            p++;
        }
    }
    // Try to shrink s to the minimum size needed
    s_new = (char**)realloc(s, n * sizeof(char*));
    if (!s_new)
        goto err;

    s = s_new;
    assert(n < INT_MAX); // hts_resize() should ensure this
    *_n = n;
    return s;

 err:
    for (m = 0; m < n; m++)
        free(s[m]);
    free(s);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rdi, %r12
movl $0x0, 0x14(%rsp)
movq $0x0, 0x18(%rsp)
testl %esi, %esi
je 0x1590b
leaq 0x82da4(%rip), %rsi     # 0x985cb
movq %r12, %rdi
callq 0xa550
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
je 0x15a3b
movq %rbx, 0x20(%rsp)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
xorl %r14d, %r14d
xorl %r13d, %r13d
movl %r13d, %ebp
movq %r15, %rdi
movl $0xa, %esi
movq %rbx, %rdx
callq 0xdb70
testl %eax, %eax
js 0x159cb
cmpq $0x0, 0x30(%rsp)
je 0x1585e
testl %ebp, %ebp
jne 0x158ab
movq %rbx, %rdi
callq 0x1564f
testl %eax, %eax
je 0x158ab
movl $0x3, %edi
leaq 0x80ac8(%rip), %rsi     # 0x96362
leaq 0x80ace(%rip), %rdx     # 0x9636f
movq %r12, %rcx
xorl %eax, %eax
callq 0x13de5
leal 0x1(%rbp), %r13d
cmpl 0x14(%rsp), %r13d
jbe 0x158ed
movl %r13d, %esi
leaq 0x80aa2(%rip), %rax     # 0x96362
movq %rax, (%rsp)
movl $0x8, %edi
movl $0x4, %edx
leaq 0x14(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %r9d, %r9d
callq 0x15a69
testl %eax, %eax
js 0x15a11
movq 0x18(%rsp), %r14
movq 0x40(%rsp), %rdi
callq 0x4930
movl %ebp, %ecx
movq %rax, (%r14,%rcx,8)
testq %rax, %rax
jne 0x1585b
jmp 0x15a11
movq %rbx, 0x20(%rsp)
leaq 0x1(%r12), %r14
movq $0x0, 0x28(%rsp)
movq %r12, %rbx
xorl %ebp, %ebp
movzbl -0x1(%r14), %eax
cmpl $0x2c, %eax
je 0x15935
testl %eax, %eax
jne 0x159ba
leal 0x1(%rbp), %r15d
cmpl 0x14(%rsp), %r15d
jbe 0x1597c
movl %r15d, %esi
leaq 0x80a18(%rip), %rax     # 0x96362
movq %rax, (%rsp)
movl $0x8, %edi
movl $0x4, %edx
leaq 0x14(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %r9d, %r9d
callq 0x15a69
testl %eax, %eax
js 0x15a11
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rbx, %r13
subq %r12, %r13
leaq 0x1(%r13), %rdi
movl $0x1, %esi
callq 0x4300
movl %ebp, %ecx
movq 0x28(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
je 0x15a11
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4250
cmpb $0x0, -0x1(%r14)
movq %r14, %r12
jne 0x159bd
jmp 0x159e5
movl %ebp, %r15d
incq %r14
incq %rbx
movl %r15d, %ebp
jmp 0x15923
cmpl $-0x1, %eax
jne 0x15a11
movq %r15, %rdi
callq 0xd3cd
movq 0x40(%rsp), %rdi
callq 0x45c0
movl %ebp, %r15d
movq 0x18(%rsp), %rdi
movl %r15d, %esi
shlq $0x3, %rsi
callq 0x4840
testq %rax, %rax
je 0x15a0e
cmpl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
jae 0x15a4a
movq 0x20(%rsp), %rcx
movl %r15d, (%rcx)
jmp 0x15a3b
movl %r15d, %ebp
movq 0x18(%rsp), %rbx
testl %ebp, %ebp
je 0x15a31
movl %ebp, %r14d
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x45c0
incq %r15
cmpq %r15, %r14
jne 0x15a20
movq %rbx, %rdi
callq 0x45c0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x80943(%rip), %rdi     # 0x96394
leaq 0x80948(%rip), %rsi     # 0x963a0
leaq 0x80947(%rip), %rcx     # 0x963a6
movl $0x836, %edx            # imm = 0x836
callq 0x42f0