// File: /workspace/github_c_makefile_star2_O2/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
pushq $-0x1
popq %rbx
je 0x6987a
movl %ebx, %eax
jmp 0x69c45
movq %rsi, %r12
testq %rdx, %rdx
jne 0x6988d
movq %r12, %rdi
callq 0x41d0
movq %rax, %rdx
cmpq $0x3, %rdx
jae 0x698bd
xorl %eax, %eax
testq %rdx, %rdx
je 0x69c45
cmpb $0x0, (%r12)
je 0x69c45
leaq 0x1a217(%rip), %rdi     # 0x83ac7
pushq $0x1
popq %rcx
movq %r12, %rsi
callq 0x6d8b6
jmp 0x69873
leaq -0x3(%rdx), %rbx
pushq $0x1
popq %r15
leaq 0x1a211(%rip), %rdi     # 0x83add
xorl %r13d, %r13d
movq %r12, 0x8(%rsp)
movq %rdx, 0x28(%rsp)
movq %rbx, 0x50(%rsp)
cmpq %rbx, %r13
jae 0x69be8
movb (%r12,%r13), %al
testb %al, %al
je 0x69be8
cmpb $0x40, %al
jne 0x69c2e
movsbl 0x1(%r12,%r13), %ebp
movl %ebp, %edi
callq 0x6d8fd
testl %eax, %eax
je 0x69bf5
movq %r12, %r14
movsbl 0x2(%r12,%r13), %r12d
movl %r12d, %edi
callq 0x6d8fd
testl %eax, %eax
je 0x69bfe
movq %r15, 0x20(%rsp)
leaq 0x3(%r13), %rbx
cmpb $0xa, 0x3(%r14,%r13)
je 0x69bbf
movq %r13, 0x30(%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x49174
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x69c42
movzbl %bpl, %esi
movzbl %r12b, %eax
shll $0x8, %esi
orl %eax, %esi
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl %esi, 0x1c(%rsp)
leaq 0x44(%rsp), %rdx
callq 0x6d916
movl 0x44(%rsp), %r14d
testl %r14d, %r14d
js 0x69c42
movl %eax, %ebp
movq 0x38(%rsp), %r13
movl 0x1c(%rsp), %eax
movl %eax, 0x28(%r13)
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x6da78
movq (%r15), %rax
movq 0x20(%rax), %rax
movl %ebp, %ecx
testl %r14d, %r14d
je 0x699d2
movq %r13, (%rax,%rcx,8)
movq %r13, (%r13)
movq %r13, 0x8(%r13)
movq 0x8(%rsp), %r12
jmp 0x699f7
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rcx
cmpq %rax, (%rcx)
movq 0x8(%rsp), %r12
jne 0x69c62
movq %r13, (%rcx)
movq %rcx, 0x8(%r13)
movq %r13, 0x8(%rax)
movq %rax, (%r13)
cmpl $0x434f, 0x1c(%rsp)     # imm = 0x434F
jne 0x69a4b
cmpb $0x9, (%r12,%rbx)
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %r13
jne 0x69c54
addq $0x4, %r13
cmpq %r13, %rdx
movq %r13, %rax
cmovaq %rdx, %rax
movq %r13, %rbx
cmpq %rdx, %r13
jae 0x69b42
movzbl (%r12,%r13), %ecx
testl %ecx, %ecx
je 0x69b45
cmpl $0xa, %ecx
je 0x69b45
incq %r13
jmp 0x69a27
addq $0x20, %r13
movq %r13, 0x48(%rsp)
xorl %r14d, %r14d
movq 0x28(%rsp), %rdx
cmpq %rdx, %rbx
je 0x69c0f
movq 0x8(%rsp), %r12
cmpb $0x9, (%r12,%rbx)
jne 0x69c1d
leaq 0x1(%rbx), %r15
cmpq %r15, %rdx
movq %r15, %rax
cmovaq %rdx, %rax
movq %r15, %r13
movl $0x601, %esi            # imm = 0x601
cmpq %rdx, %r13
jae 0x69aa4
movzbl (%r12,%r13), %ecx
cmpl $0xa, %ecx
ja 0x69a9f
btl %ecx, %esi
jb 0x69aa7
incq %r13
jmp 0x69a8b
movq %rax, %r13
movq %r13, %r12
subq %r15, %r12
cmpq $0x3, %r12
jb 0x69bec
movq 0x8(%rsp), %rax
cmpb $0x3a, 0x3(%rax,%rbx)
jne 0x69bec
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x49174
testq %rax, %rax
je 0x69c42
movq %rax, %rbp
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
addq 0x8(%rsp), %r15
movq %r15, %rsi
movq %r12, %rdx
callq 0x493ba
movq %rax, 0x8(%rbp)
movl %r12d, 0x10(%rbp)
andq $0x0, (%rbp)
testq %rax, %rax
je 0x69c42
testq %r14, %r14
cmoveq 0x48(%rsp), %r14
movq %rbp, (%r14)
cmpq 0x28(%rsp), %r13
jae 0x69ba0
movq 0x8(%rsp), %rax
movzbl (%rax,%r13), %eax
cmpl $0xa, %eax
je 0x69ba0
movq %r13, %rbx
movq %rbp, %r14
testl %eax, %eax
jne 0x69a57
jmp 0x69ba0
movq %rax, %r13
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x49174
movq %rax, %r12
movq 0x38(%rsp), %rax
movq %r12, 0x20(%rax)
testq %r12, %r12
je 0x69c42
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x8(%rsp), %rax
leaq (%rax,%rbx), %rsi
movq %r13, %r15
subq %rbx, %r15
movq %r15, %rdx
callq 0x493ba
movq %rax, 0x8(%r12)
movl %r15d, 0x10(%r12)
andq $0x0, (%r12)
testq %rax, %rax
je 0x69c42
movq 0x10(%rsp), %rdi
movl 0x1c(%rsp), %esi
movq 0x38(%rsp), %rdx
callq 0x6bb9a
movq %r13, %rbx
cmpl $-0x1, %eax
je 0x69c42
incq %rbx
movq 0x20(%rsp), %r15
incq %r15
movq %rbx, %r13
movq 0x8(%rsp), %r12
movq 0x28(%rsp), %rdx
leaq 0x19eff(%rip), %rdi     # 0x83add
movq 0x50(%rsp), %rbx
jmp 0x698de
xorl %eax, %eax
jmp 0x69c45
leaq 0x19f94(%rip), %rdi     # 0x83b87
jmp 0x69c16
leaq 0x19f05(%rip), %rdi     # 0x83b01
jmp 0x69c08
leaq 0x19efc(%rip), %rdi     # 0x83b01
movq %r14, %r12
movq 0x28(%rsp), %rdx
jmp 0x69c2e
leaq 0x19f65(%rip), %rdi     # 0x83b7b
movq 0x8(%rsp), %r12
jmp 0x69c24
leaq 0x19f57(%rip), %rdi     # 0x83b7b
movq 0x20(%rsp), %r15
movq 0x30(%rsp), %r13
movslq %r13d, %rax
addq %rax, %r12
subq %rax, %rdx
movq %r12, %rsi
movq %r15, %rcx
callq 0x6d8b6
pushq $-0x1
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19f20(%rip), %rdi     # 0x83b7b
movq 0x20(%rsp), %r15
jmp 0x69c2e
leaq 0x19ec6(%rip), %rdi     # 0x83b2f
leaq 0x19aeb(%rip), %rsi     # 0x8375b
leaq 0x19ec5(%rip), %rcx     # 0x83b3c
movl $0x33f, %edx            # imm = 0x33F
callq 0x42f0