// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, %r14
movq %rdi, %rbp
movl $0x0, 0xc(%rsp)
movq $0x0, 0x10(%rsp)
testl %esi, %esi
je 0x15ea0
leaq 0x8580a(%rip), %rsi     # 0x9b5c4
movq %rbp, %rdi
callq 0xa4a5
testq %rax, %rax
je 0x15f74
movq %rax, %r15
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r12
movaps %xmm0, (%r12)
movq $0x0, 0x10(%r12)
xorl %ebx, %ebx
movl %ebx, %r13d
movq %r15, %rdi
movl $0xa, %esi
movq %r12, %rdx
callq 0xdc2d
testl %eax, %eax
js 0x15f51
cmpq $0x0, 0x20(%rsp)
je 0x15de9
movq %r13, %rcx
testl %ecx, %ecx
jne 0x15e3f
movq %r12, %rdi
callq 0x15be6
movq %r13, %rcx
testl %eax, %eax
je 0x15e3f
movl $0x3, %edi
leaq 0x83497(%rip), %rsi     # 0x992c2
leaq 0x8349d(%rip), %rdx     # 0x992cf
movq %rbp, %rcx
xorl %eax, %eax
callq 0x14378
movq %r13, %rcx
leal 0x1(%rcx), %ebx
cmpl 0xc(%rsp), %ebx
jbe 0x15e75
movl %ebx, %esi
leaq 0x83471(%rip), %rax     # 0x992c2
movq %rax, (%rsp)
movl $0x8, %edi
movl $0x4, %edx
leaq 0xc(%rsp), %rcx
leaq 0x10(%rsp), %r8
xorl %r9d, %r9d
callq 0x16026
testl %eax, %eax
js 0x15e96
movq 0x30(%rsp), %rdi
callq 0x4930
movq 0x10(%rsp), %rcx
movq %r13, %rdx
movl %edx, %edx
movq %rax, (%rcx,%rdx,8)
testq %rax, %rax
jne 0x15de6
movl $0x4, %ecx
jmp 0x15f6f
movq %r14, 0x18(%rsp)
leaq 0x1(%rbp), %r14
xorl %esi, %esi
movq %rbp, %rbx
movzbl -0x1(%r14), %eax
cmpl $0x2c, %eax
je 0x15ebc
testl %eax, %eax
jne 0x15f3a
movq %rsi, %r12
leal 0x1(%rsi), %r15d
cmpl 0xc(%rsp), %r15d
jbe 0x15eff
movl %r15d, %esi
leaq 0x833ee(%rip), %rax     # 0x992c2
movq %rax, (%rsp)
xorl %r13d, %r13d
movl $0x8, %edi
movl $0x4, %edx
leaq 0xc(%rsp), %rcx
leaq 0x10(%rsp), %r8
xorl %r9d, %r9d
callq 0x16026
testl %eax, %eax
js 0x15f8b
movq %rbx, %r13
subq %rbp, %r13
leaq 0x1(%r13), %rdi
movl $0x1, %esi
callq 0x4300
movq 0x10(%rsp), %rcx
movq %r12, %rsi
movl %esi, %edx
movq %rax, (%rcx,%rdx,8)
testq %rax, %rax
je 0x15f86
movq %rax, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x4250
movl %r15d, %esi
movq %r14, %rbp
incq %rbx
cmpb $0x0, -0x1(%r14)
leaq 0x1(%r14), %r14
jne 0x15eae
movb $0x1, %r13b
jmp 0x15f8e
movl $0x4, %ecx
cmpl $-0x1, %eax
jne 0x15f6f
movq %r15, %rdi
callq 0xd4a4
movq 0x30(%rsp), %rdi
callq 0x45c0
xorl %ecx, %ecx
movq %r13, %rsi
jmp 0x15f7b
movl $0x1, %ecx
xorl %esi, %esi
testl %ecx, %ecx
je 0x15f98
cmpl $0x4, %ecx
je 0x15fc5
jmp 0x15ff6
xorl %r13d, %r13d
jmp 0x15f8e
movq %r12, %rsi
testb %r13b, %r13b
movq 0x18(%rsp), %r14
je 0x15fc5
movq 0x10(%rsp), %rdi
movq %rsi, %rbx
movl %ebx, %esi
shlq $0x3, %rsi
callq 0x4840
testq %rax, %rax
je 0x15fc2
movq %rax, 0x10(%rsp)
cmpl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
jae 0x16007
movl %ebx, (%r14)
jmp 0x15ff8
movq %rbx, %rsi
testl %esi, %esi
je 0x15fe6
movq 0x10(%rsp), %r14
movl %esi, %r15d
xorl %ebx, %ebx
movq (%r14,%rbx,8), %rdi
callq 0x45c0
incq %rbx
cmpq %rbx, %r15
jne 0x15fd3
jmp 0x15fe8
xorl %ebx, %ebx
movl %ebx, 0xc(%rsp)
movq 0x10(%rsp), %rdi
callq 0x45c0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x832e6(%rip), %rdi     # 0x992f4
leaq 0x832eb(%rip), %rsi     # 0x99300
leaq 0x832ea(%rip), %rcx     # 0x99306
movl $0x836, %edx            # imm = 0x836
callq 0x42f0