// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_parse_lines
static int sam_hrecs_parse_lines(sam_hrecs_t *hrecs, const char *hdr, size_t len) {
    size_t i, lno;

    if (!hrecs || len > SSIZE_MAX)
        return -1;

    if (!len)
        len = strlen(hdr);

    if (len < 3) {
        if (len == 0 || *hdr == '\0') return 0;
        sam_hrecs_error("Header line too short", hdr, len, 1);
        return -1;
    }

    for (i = 0, lno = 1; i < len - 3 && hdr[i] != '\0'; i++, lno++) {
        khint32_t type;
        khint_t k;

        int l_start = i, new;
        sam_hrec_type_t *h_type;
        sam_hrec_tag_t *h_tag, *last;

        if (hdr[i] != '@') {
            sam_hrecs_error("Header line does not start with '@'",
                          &hdr[l_start], len - l_start, lno);
            return -1;
        }

        if (!isalpha_c(hdr[i+1]) || !isalpha_c(hdr[i+2])) {
            sam_hrecs_error("Header line does not have a two character key",
                          &hdr[l_start], len - l_start, lno);
            return -1;
        }
        type = TYPEKEY(&hdr[i+1]);

        i += 3;
        if (i == len || hdr[i] == '\n')
            continue;

        // Add the header line type
        if (!(h_type = pool_alloc(hrecs->type_pool)))
            return -1;
        k = kh_put(sam_hrecs_t, hrecs->h, type, &new);
        if (new < 0)
            return -1;

        h_type->type = type;

        // Add to end of global list
        sam_hrecs_global_list_add(hrecs, h_type, NULL);

        // Form the ring, either with self or other lines of this type
        if (!new) {
            sam_hrec_type_t *t = kh_val(hrecs->h, k), *p;
            p = t->prev;

            assert(p->next == t);
            p->next = h_type;
            h_type->prev = p;

            t->prev = h_type;
            h_type->next = t;
        } else {
            kh_val(hrecs->h, k) = h_type;
            h_type->prev = h_type->next = h_type;
        }

        // Parse the tags on this line
        last = NULL;
        if (type == TYPEKEY("CO")) {
            size_t j;

            if (i == len || hdr[i] != '\t') {
                sam_hrecs_error("Missing tab",
                              &hdr[l_start], len - l_start, lno);
                return -1;
            }

            for (j = ++i; j < len && hdr[j] != '\0' && hdr[j] != '\n'; j++)
                ;

            if (!(h_type->tag = h_tag = pool_alloc(hrecs->tag_pool)))
                return -1;
            h_tag->str = string_ndup(hrecs->str_pool, &hdr[i], j-i);
            h_tag->len = j-i;
            h_tag->next = NULL;
            if (!h_tag->str)
                return -1;

            i = j;

        } else {
            do {
                size_t j;

                if (i == len || hdr[i] != '\t') {
                    sam_hrecs_error("Missing tab",
                                  &hdr[l_start], len - l_start, lno);
                    return -1;
                }

                for (j = ++i; j < len && hdr[j] != '\0' && hdr[j] != '\n' && hdr[j] != '\t'; j++)
                    ;

                if (j - i < 3 || hdr[i + 2] != ':') {
                    sam_hrecs_error("Malformed key:value pair",
                                   &hdr[l_start], len - l_start, lno);
                    return -1;
                }

                if (!(h_tag = pool_alloc(hrecs->tag_pool)))
                    return -1;
                h_tag->str = string_ndup(hrecs->str_pool, &hdr[i], j-i);
                h_tag->len = j-i;
                h_tag->next = NULL;
                if (!h_tag->str)
                    return -1;

                if (last)
                    last->next = h_tag;
                else
                    h_type->tag = h_tag;

                last = h_tag;
                i = j;
            } while (i < len && hdr[i] != '\0' && hdr[i] != '\n');
        }

        /* Update RG/SQ hashes */
        if (-1 == sam_hrecs_update_hashes(hrecs, type, h_type))
            return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
sete %al
testq %rdx, %rdx
sets %cl
orb %al, %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x87298
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
jne 0x86e61
movq %r14, %rdi
callq 0x41d0
movq %rax, %r15
cmpq $0x3, %r15
jae 0x86e9d
xorl %eax, %eax
testq %r15, %r15
je 0x87298
cmpb $0x0, (%r14)
je 0x87298
leaq 0x1dbd5(%rip), %rdi     # 0xa4a58
movl $0x1, %ecx
movq %r14, %rsi
movq %r15, %rdx
callq 0x8cd60
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x87298
movq %r15, %rax
addq $-0x3, %rax
movq %rax, 0x50(%rsp)
je 0x87296
movq %rbx, 0x10(%rsp)
movl $0x1, %r13d
xorl %r12d, %r12d
movb (%r14,%r12), %al
testb %al, %al
je 0x87296
cmpb $0x40, %al
jne 0x86f05
movzbl 0x1(%r14,%r12), %ebp
callq 0x4510
movq (%rax), %rax
testb $0x4, 0x1(%rax,%rbp,2)
je 0x86eef
movzbl 0x2(%r14,%r12), %ecx
testb $0x4, 0x1(%rax,%rcx,2)
jne 0x86f41
movslq %r12d, %rax
leaq (%r14,%rax), %rsi
movq %r15, %rdx
subq %rax, %rdx
leaq 0x1db8f(%rip), %rdi     # 0xa4a92
jmp 0x86f19
movslq %r12d, %rax
leaq (%r14,%rax), %rsi
movq %r15, %rdx
subq %rax, %rdx
leaq 0x1db55(%rip), %rdi     # 0xa4a6e
movq %r13, %rcx
callq 0x8cd60
movl $0x1, %ebx
testb $0x3, %bl
jne 0x86e93
incq %r12
incq %r13
cmpq 0x50(%rsp), %r12
jb 0x86ebd
jmp 0x87296
leaq 0x3(%r12), %rax
movl $0x4, %ebx
cmpq %r15, %rax
je 0x86f57
cmpb $0xa, (%r14,%rax)
jne 0x86f5c
movq %rax, %r12
jmp 0x86f26
movq %rax, 0x8(%rsp)
movzbl 0x2(%r14,%r12), %eax
movl %eax, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x5a822
movl $0x1, %ebx
testq %rax, %rax
je 0x86ff0
movq %rax, 0x28(%rsp)
shll $0x8, %ebp
addl 0x18(%rsp), %ebp
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl %ebp, %esi
leaq 0x3c(%rsp), %rdx
callq 0x8cdad
movl 0x3c(%rsp), %ecx
testl %ecx, %ecx
js 0x86ff0
movq 0x28(%rsp), %rsi
movl %ebp, 0x28(%rsi)
movq 0x10(%rsp), %rdi
xorl %edx, %edx
movl %ecx, 0x18(%rsp)
movl %eax, 0x20(%rsp)
callq 0x8cf08
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x20(%rsp), %ecx
cmpl $0x0, 0x18(%rsp)
je 0x86ffa
movq 0x28(%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
movq %rdx, (%rdx)
movq %rdx, 0x8(%rdx)
jmp 0x8701e
movq 0x8(%rsp), %r12
jmp 0x86f26
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rcx
cmpq %rax, (%rcx)
jne 0x872a7
movq 0x28(%rsp), %rdx
movq %rdx, (%rcx)
movq %rcx, 0x8(%rdx)
movq %rdx, 0x8(%rax)
movq %rax, (%rdx)
cmpl $0x434f, %ebp           # imm = 0x434F
movq 0x8(%rsp), %rdx
jne 0x870d7
cmpb $0x9, (%r14,%rdx)
jne 0x87238
addq $0x4, %r12
movq %r12, %rcx
cmpq %r15, %r12
jae 0x87062
movq %r12, %rcx
movzbl (%r14,%rcx), %eax
testl %eax, %eax
je 0x87062
cmpl $0xa, %eax
je 0x87062
incq %rcx
cmpq %rcx, %r15
jne 0x87049
movq %r15, %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x5a822
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rax)
testq %rcx, %rcx
je 0x87265
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
leaq (%r14,%r12), %rsi
movq 0x8(%rsp), %rdx
subq %r12, %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
callq 0x5aab0
movq 0x20(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0x18(%rsp), %rdx
movl %edx, 0x10(%rcx)
movq $0x0, (%rcx)
testq %rax, %rax
setne %al
cmovneq 0x8(%rsp), %r12
jmp 0x87267
movslq %r12d, %rax
leaq (%r14,%rax), %rcx
movq %rcx, 0x18(%rsp)
movq %r15, %rcx
subq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpq %r15, %rdx
je 0x871c3
cmpb $0x9, (%r14,%rdx)
jne 0x871c3
leaq 0x1(%rdx), %rsi
movq %rsi, %r12
cmpq %r15, %rsi
jae 0x87139
movq %rsi, %r12
movzbl (%r14,%r12), %eax
cmpl $0xa, %eax
ja 0x8712e
movl $0x601, %ecx            # imm = 0x601
btl %eax, %ecx
jb 0x87139
incq %r12
cmpq %r12, %r15
jne 0x8711a
movq %r15, %r12
movq %r12, %rax
movq %rsi, 0x8(%rsp)
subq %rsi, %rax
cmpq $0x3, %rax
jb 0x871e6
cmpb $0x3a, 0x3(%r14,%rdx)
jne 0x871e6
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x5a822
testq %rax, %rax
je 0x871ff
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rdi
movq 0x8(%rsp), %rcx
leaq (%r14,%rcx), %rsi
movq 0x40(%rsp), %rdx
movq %rax, 0x48(%rsp)
callq 0x5aab0
movq 0x48(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0x40(%rsp), %rdx
movl %edx, 0x10(%rcx)
movq $0x0, (%rcx)
testq %rax, %rax
je 0x871ff
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x87223
movq %rcx, (%rax)
jmp 0x8722c
leaq 0x1d942(%rip), %rdi     # 0xa4b0c
movq 0x18(%rsp), %rsi
movq %rdx, %r12
movq 0x20(%rsp), %rdx
movq %r13, %rcx
callq 0x8cd60
movq %r12, %rdx
xorl %eax, %eax
jmp 0x87206
leaq 0x1d92b(%rip), %rdi     # 0xa4b18
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rcx
callq 0x8cd60
xorl %eax, %eax
movq 0x8(%rsp), %rdx
testb %al, %al
je 0x8725d
cmpq %r15, %rdx
jae 0x87275
movzbl (%r14,%rdx), %eax
cmpl $0xa, %eax
je 0x87275
testl %eax, %eax
jne 0x870f7
jmp 0x87275
movq 0x28(%rsp), %rax
movq %rcx, 0x20(%rax)
movb $0x1, %al
movq %r12, %rdx
movq %rcx, 0x30(%rsp)
jmp 0x87206
movslq %r12d, %rax
leaq (%r14,%rax), %rsi
movq %r15, %rdx
subq %rax, %rdx
leaq 0x1d8c0(%rip), %rdi     # 0xa4b0c
movq %r13, %rcx
callq 0x8cd60
movq 0x8(%rsp), %rdx
xorl %eax, %eax
jmp 0x8726a
movq %rdx, %r12
jmp 0x86f26
xorl %eax, %eax
movq %r12, %rdx
movq %rdx, %r12
testb %al, %al
je 0x86f26
movq 0x10(%rsp), %rdi
movl %ebp, %esi
movq %rdx, %r12
movq 0x28(%rsp), %rdx
callq 0x89c4a
xorl %ebx, %ebx
cmpl $-0x1, %eax
sete %bl
jmp 0x86f26
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d812(%rip), %rdi     # 0xa4ac0
leaq 0x1d437(%rip), %rsi     # 0xa46ec
leaq 0x1d811(%rip), %rcx     # 0xa4acd
movl $0x33f, %edx            # imm = 0x33F
callq 0x42f0