// File: karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_readlines
char **hts_readlines(const char *fn, int *_n)
{
    int m = 0, n = 0, dret;
    char **s = 0;
#if KS_BGZF
    BGZF *fp = bgzf_open(fn, "r");
#else
    gzFile fp = gzopen(fn, "r");
#endif
    if ( fp ) { // read from file
        kstream_t *ks;
        kstring_t str;
        str.s = 0; str.l = str.m = 0;
        ks = ks_init(fp);
        while (ks_getuntil(ks, KS_SEP_LINE, &str, &dret) >= 0) {
            if (str.l == 0) continue;
            if (m == n) {
                m = m? m<<1 : 16;
                s = (char**)realloc(s, m * sizeof(char*));
            }
            s[n++] = strdup(str.s);
        }
        ks_destroy(ks);
        #if KS_BGZF
            bgzf_close(fp);
        #else
            gzclose(fp);
        #endif
        s = (char**)realloc(s, n * sizeof(char*));
        free(str.s);
    } else if (*fn == ':') { // read from string
        const char *q, *p;
        for (q = p = fn + 1;; ++p)
            if (*p == ',' || *p == 0) {
                if (m == n) {
                    m = m? m<<1 : 16;
                    s = (char**)realloc(s, m * sizeof(char*));
                }
                s[n] = (char*)calloc(p - q + 1, 1);
                strncpy(s[n++], q, p - q);
                q = p + 1;
                if (*p == 0) break;
            }
    } else return 0;
    s = (char**)realloc(s, n * sizeof(char*));
    *_n = n;
    return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6708e(%rip), %rsi     # 0x7b9ef
callq 0x62d50
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x14a57
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x38(%rbp), %rdi
callq 0x10c30
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl $0x2, %esi
leaq -0x58(%rbp), %rdx
leaq -0x24(%rbp), %rcx
callq 0x14630
cmpl $0x0, %eax
jl 0x14a22
cmpq $0x0, -0x58(%rbp)
jne 0x149be
jmp 0x1499a
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x149fb
cmpl $0x0, -0x1c(%rbp)
je 0x149d6
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x6c(%rbp)
jmp 0x149e0
movl $0x10, %eax
movl %eax, -0x6c(%rbp)
jmp 0x149e0
movl -0x6c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x4990
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rdi
callq 0x4aa0
movq %rax, %rdx
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1499a
movq -0x40(%rbp), %rdi
callq 0x10c90
movq -0x38(%rbp), %rdi
callq 0x65880
movq -0x30(%rbp), %rdi
movslq -0x20(%rbp), %rsi
shlq $0x3, %rsi
callq 0x4990
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rdi
callq 0x46a0
jmp 0x14b5f
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x14b53
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
je 0x14a93
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x14b3e
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x14ad0
cmpl $0x0, -0x1c(%rbp)
je 0x14aab
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x70(%rbp)
jmp 0x14ab5
movl $0x10, %eax
movl %eax, -0x70(%rbp)
jmp 0x14ab5
movl -0x70(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x1c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x4990
movq %rax, -0x30(%rbp)
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rax
subq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x4370
movq %rax, %rdx
movq -0x30(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x60(%rbp), %rax
subq %rax, %rdx
callq 0x42c0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x14b3c
jmp 0x14b51
jmp 0x14b3e
jmp 0x14b40
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x14a77
jmp 0x14b5d
movq $0x0, -0x8(%rbp)
jmp 0x14b85
jmp 0x14b5f
movq -0x30(%rbp), %rdi
movslq -0x20(%rbp), %rsi
shlq $0x3, %rsi
callq 0x4990
movq %rax, -0x30(%rbp)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nop