// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rdi, %rbx
andl $0x0, 0x14(%rsp)
andq $0x0, 0x18(%rsp)
testl %esi, %esi
je 0x12b05
leaq 0x67b11(%rip), %rsi     # 0x7a526
movq %rbx, %rdi
callq 0x9596
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
je 0x12c2e
movq %r14, 0x28(%rsp)
leaq 0x30(%rsp), %r12
andq $0x0, 0x10(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
pushq $0xa
popq %rbp
movq $0x0, 0x20(%rsp)
xorl %r14d, %r14d
movl %r14d, %r13d
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0xc2ab
testl %eax, %eax
js 0x12bc0
cmpq $0x0, 0x30(%rsp)
je 0x12a55
testl %r13d, %r13d
jne 0x12a9e
movq %r12, %rdi
callq 0x12869
testl %eax, %eax
je 0x12a9e
pushq $0x3
popq %rdi
leaq 0x658c6(%rip), %rsi     # 0x78353
leaq 0x658cc(%rip), %rdx     # 0x78360
movq %rbx, %rcx
xorl %eax, %eax
callq 0x110c6
leal 0x1(%r13), %r14d
cmpl 0x14(%rsp), %r14d
jbe 0x12ae1
movl %r14d, %esi
leaq 0x658a0(%rip), %rax     # 0x78353
movq %rax, (%rsp)
pushq $0x8
popq %rdi
pushq $0x4
popq %rdx
leaq 0x14(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %r9d, %r9d
callq 0x12c5c
testl %eax, %eax
js 0x12c06
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x40(%rsp), %rdi
callq 0x4930
movl %r13d, %ecx
movq 0x20(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
jne 0x12a52
jmp 0x12c06
movq %r14, 0x28(%rsp)
leaq 0x1(%rbx), %r14
movq $0x0, 0x20(%rsp)
movq %rbx, %rbp
xorl %r13d, %r13d
movzbl -0x1(%r14), %eax
cmpl $0x2c, %eax
je 0x12b2f
testl %eax, %eax
jne 0x12baf
leal 0x1(%r13), %r12d
cmpl 0x14(%rsp), %r12d
jbe 0x12b72
movl %r12d, %esi
leaq 0x6580f(%rip), %rax     # 0x78353
movq %rax, (%rsp)
pushq $0x8
popq %rdi
pushq $0x4
popq %rdx
leaq 0x14(%rsp), %rcx
leaq 0x18(%rsp), %r8
xorl %r9d, %r9d
callq 0x12c5c
testl %eax, %eax
js 0x12c06
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %rbp, %r15
subq %rbx, %r15
leaq 0x1(%r15), %rdi
pushq $0x1
popq %rsi
callq 0x4300
movl %r13d, %ecx
movq 0x20(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
je 0x12c06
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4250
cmpb $0x0, -0x1(%r14)
movq %r14, %rbx
jne 0x12bb2
jmp 0x12bda
movl %r13d, %r12d
incq %r14
incq %rbp
movl %r12d, %r13d
jmp 0x12b1d
cmpl $-0x1, %eax
jne 0x12c06
movq %r15, %rdi
callq 0xbc96
movq 0x40(%rsp), %rdi
callq 0x45c0
movl %r13d, %r12d
movq 0x18(%rsp), %rdi
movl %r12d, %esi
shlq $0x3, %rsi
callq 0x4840
testq %rax, %rax
je 0x12c03
cmpl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
jae 0x12c3d
movq 0x28(%rsp), %rcx
movl %r12d, (%rcx)
jmp 0x12c2e
movl %r12d, %r13d
movq 0x18(%rsp), %rbx
movl %r13d, %r14d
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x12c24
movq (%rbx,%r15,8), %rdi
callq 0x45c0
incq %r15
jmp 0x12c11
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 0x65741(%rip), %rdi     # 0x78385
leaq 0x65746(%rip), %rsi     # 0x78391
leaq 0x65745(%rip), %rcx     # 0x78397
movl $0x836, %edx            # imm = 0x836
callq 0x42f0