// File: /workspace/github_c_makefile_star2_O3/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
movq %rdi, 0x10(%rsp)
testq %rdi, %rdi
sete %al
testq %rdx, %rdx
sets %cl
orb %al, %cl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x84ca6
movq %rsi, %r15
testq %rdx, %rdx
jne 0x848f5
movq %r15, %rdi
callq 0x41d0
movq %rax, %rdx
cmpq $0x3, %rdx
jae 0x84924
xorl %eax, %eax
testq %rdx, %rdx
je 0x84ca6
cmpb $0x0, (%r15)
je 0x84ca6
leaq 0x1d8c0(%rip), %rdi     # 0xa21d7
movl $0x1, %ecx
movq %r15, %rsi
jmp 0x84c9c
movq %rdx, %rax
addq $-0x3, %rax
movq %rax, 0x50(%rsp)
je 0x84c4a
movq %rdx, 0x20(%rsp)
movl $0x1, %r12d
leaq 0x1d8a5(%rip), %rdi     # 0xa21ed
xorl %ebp, %ebp
movq %r15, 0x8(%rsp)
movb (%r15,%rbp), %al
testb %al, %al
je 0x84c4a
cmpb $0x40, %al
jne 0x84c5e
movzbl 0x1(%r15,%rbp), %r13d
callq 0x4510
movq (%rax), %rax
testb $0x4, 0x1(%rax,%r13,2)
je 0x84c57
movzbl 0x2(%r15,%rbp), %r14d
testb $0x4, 0x1(%rax,%r14,2)
movq 0x20(%rsp), %rdx
je 0x84c65
movq %r12, 0x18(%rsp)
leaq 0x3(%rbp), %rbx
cmpb $0xa, 0x3(%r15,%rbp)
je 0x84b24
movq %rbp, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x57daa
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x84ca1
movq %r13, %rsi
shll $0x8, %esi
orl %r14d, %esi
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movq %rsi, 0x40(%rsp)
leaq 0x3c(%rsp), %rdx
callq 0x8a426
movl 0x3c(%rsp), %ebp
testl %ebp, %ebp
js 0x84ca1
movl %eax, %r15d
movq 0x40(%rsp), %r12
movq 0x30(%rsp), %r13
movl %r12d, 0x28(%r13)
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x8a594
movq (%r14), %rax
movq 0x20(%rax), %rax
movl %r15d, %ecx
testl %ebp, %ebp
je 0x84a3a
movq %r13, (%rax,%rcx,8)
movq %r13, (%r13)
movq %r13, 0x8(%r13)
movq 0x8(%rsp), %r15
jmp 0x84a5f
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rcx
cmpq %rax, (%rcx)
movq 0x8(%rsp), %r15
jne 0x84cc3
movq %r13, (%rcx)
movq %rcx, 0x8(%r13)
movq %r13, 0x8(%rax)
movq %rax, (%r13)
cmpl $0x434f, %r12d          # imm = 0x434F
jne 0x84b4e
cmpb $0x9, (%r15,%rbx)
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rbp
jne 0x84cb5
addq $0x4, %rbp
movq %rbp, %r13
cmpq %rdx, %rbp
jae 0x84aa9
movq %rbp, %r13
movzbl (%r15,%r13), %eax
testl %eax, %eax
je 0x84aa9
cmpl $0xa, %eax
je 0x84aa9
incq %r13
cmpq %r13, %rdx
jne 0x84a90
movq %rdx, %r13
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x57daa
movq %rax, %r15
movq 0x30(%rsp), %rax
movq %r15, 0x20(%rax)
testq %r15, %r15
je 0x84ca1
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x8(%rsp), %rax
leaq (%rax,%rbp), %rsi
movq %r13, %r12
subq %rbp, %r12
movq %r12, %rdx
callq 0x5801b
movq %rax, 0x8(%r15)
movl %r12d, 0x10(%r15)
movq $0x0, (%r15)
testq %rax, %rax
je 0x84ca1
movq 0x10(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x8753f
movq %r13, %rbx
cmpl $-0x1, %eax
je 0x84ca1
incq %rbx
movq 0x18(%rsp), %r12
incq %r12
movq %rbx, %rbp
cmpq 0x50(%rsp), %rbx
movq 0x8(%rsp), %r15
leaq 0x1d6aa(%rip), %rdi     # 0xa21ed
jb 0x8494f
jmp 0x84c4a
addq $0x20, %r13
movq %r13, 0x48(%rsp)
xorl %r14d, %r14d
movq 0x20(%rsp), %rdx
cmpq %rdx, %rbx
je 0x84c6e
movq 0x8(%rsp), %r15
cmpb $0x9, (%r15,%rbx)
jne 0x84c7c
leaq 0x1(%rbx), %rbp
movq %rbp, %r13
cmpq %rdx, %rbp
jae 0x84ba6
movq %rbp, %r13
movl $0x601, %ecx            # imm = 0x601
movzbl (%r15,%r13), %eax
cmpl $0xa, %eax
ja 0x84b9b
btl %eax, %ecx
jb 0x84ba6
incq %r13
cmpq %r13, %rdx
jne 0x84b8c
movq %rdx, %r13
movq %r13, %r12
subq %rbp, %r12
cmpq $0x3, %r12
jb 0x84c4e
cmpb $0x3a, 0x3(%r15,%rbx)
jne 0x84c4e
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x57daa
testq %rax, %rax
je 0x84ca1
movq %rax, %r15
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
addq 0x8(%rsp), %rbp
movq %rbp, %rsi
movq %r12, %rdx
callq 0x5801b
movq %rax, 0x8(%r15)
movl %r12d, 0x10(%r15)
movq $0x0, (%r15)
testq %rax, %rax
je 0x84ca1
testq %r14, %r14
cmoveq 0x48(%rsp), %r14
movq %r15, (%r14)
cmpq 0x20(%rsp), %r13
jae 0x84b04
movq 0x8(%rsp), %rax
movzbl (%rax,%r13), %eax
cmpl $0xa, %eax
je 0x84b04
movq %r13, %rbx
movq %r15, %r14
testl %eax, %eax
jne 0x84b5a
jmp 0x84b04
xorl %eax, %eax
jmp 0x84ca6
leaq 0x1d642(%rip), %rdi     # 0xa2297
jmp 0x84c83
leaq 0x1d5b3(%rip), %rdi     # 0xa2211
movq 0x20(%rsp), %rdx
jmp 0x84c8d
leaq 0x1d5a5(%rip), %rdi     # 0xa2211
jmp 0x84c8d
leaq 0x1d616(%rip), %rdi     # 0xa228b
movq 0x8(%rsp), %r15
jmp 0x84c83
leaq 0x1d608(%rip), %rdi     # 0xa228b
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %rbp
movslq %ebp, %rax
addq %rax, %r15
subq %rax, %rdx
movq %r15, %rsi
movq %r12, %rcx
callq 0x8a3d9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d5cf(%rip), %rdi     # 0xa228b
movq 0x18(%rsp), %r12
jmp 0x84c8d
leaq 0x1d575(%rip), %rdi     # 0xa223f
leaq 0x1d19a(%rip), %rsi     # 0xa1e6b
leaq 0x1d574(%rip), %rcx     # 0xa224c
movl $0x33f, %edx            # imm = 0x33F
callq 0x42f0