// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/sam_header.c
// Function: sam_header_parse2
void *sam_header_parse2(const char *headerText)
{
    list_t *hlines = NULL;
    HeaderLine *hline;
    const char *text;
    char *buf=NULL;
    size_t nbuf = 0;
	int tovalidate = 0;

    if ( !headerText )
		return 0;

    text = headerText;
    while ( (text=nextline(&buf, &nbuf, text)) )
    {
        hline = sam_header_line_parse(buf);
        if ( hline && (!tovalidate || sam_header_line_validate(hline)) )
            // With too many (~250,000) reference sequences the header parsing was too slow with list_append.
            hlines = list_append_to_end(hlines, hline);
        else
        {
			if (hline) sam_header_line_free(hline);
			sam_header_free(hlines);
            if ( buf ) free(buf);
            return NULL;
        }
    }
    if ( buf ) free(buf);

    return hlines;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x1608f
movq %rdi, %rbp
leaq 0xcc9c(%rip), %r14      # 0x229a0
leaq 0xcc65(%rip), %r13      # 0x22970
xorl %ebx, %ebx
movq $0x0, 0x10(%rsp)
xorl %r12d, %r12d
movq %rbp, %r15
movq %r12, (%rsp)
cmpb $0x0, (%r15)
je 0x15d76
movq %rbx, %rdi
movl $0x1, %r12d
xorl %ebx, %ebx
movq %r15, %rbp
movabsq $0x100000000, %rcx      # imm = 0x100000000
movl $0x2401, %edx           # imm = 0x2401
movzbl (%rbp), %eax
cmpl $0xd, %eax
ja 0x15d51
btl %eax, %edx
jb 0x15d5c
incq %rbp
addq %rcx, %rbx
incl %r12d
jmp 0x15d43
cmpl $0xa, %eax
je 0x15d7a
cmpl $0xd, %eax
jne 0x15d7d
xorl %eax, %eax
cmpb $0xa, 0x1(%rbp)
sete %al
leaq (%rbp,%rax,2), %rbp
jmp 0x15d7d
xorl %ebp, %ebp
jmp 0x15df8
incq %rbp
testl %r12d, %r12d
je 0x15d9e
movslq %r12d, %r14
testq %rdi, %rdi
je 0x15daa
movq 0x10(%rsp), %rax
cmpq %r14, %rax
jae 0x15db7
movq %r14, %rsi
callq 0x3430
jmp 0x15db2
leaq 0xcbfb(%rip), %r14      # 0x229a0
movq %rdi, %rbx
jmp 0x15df4
movq %r14, %rdi
callq 0x33e0
movq %rax, %r13
jmp 0x15dbd
movq %rax, %r14
movq %rdi, %r13
testq %r13, %r13
je 0x16055
movslq %r12d, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x3370
sarq $0x20, %rbx
movb $0x0, (%r13,%rbx)
movq %r14, 0x10(%rsp)
leaq 0xcbb6(%rip), %r14      # 0x229a0
movq %r13, %rbx
leaq 0xcb7c(%rip), %r13      # 0x22970
movq (%rsp), %r12
testq %rbp, %rbp
je 0x16094
cmpb $0x40, (%rbx)
jne 0x15fc5
leaq 0x1(%rbx), %rcx
movq $-0x1, %rax
movq %rbx, %r12
movzbl (%rcx), %edx
testl %edx, %edx
je 0x15e2f
cmpl $0x9, %edx
je 0x15e2f
incq %rcx
decq %rax
incq %r12
jmp 0x15e18
cmpq $-0x3, %rax
jne 0x15fdb
movl $0x10, %edi
callq 0x33e0
movq %rax, %r15
movb 0x1(%rbx), %al
movb %al, (%r15)
movb 0x2(%rbx), %cl
movb %cl, 0x1(%r15)
movq $0x0, 0x8(%r15)
movq 0xcb0e(%rip), %rsi      # 0x22970
testq %rsi, %rsi
je 0x15e8b
xorl %edx, %edx
cmpb %al, (%rsi)
jne 0x15e72
cmpb %cl, 0x1(%rsi)
je 0x15e86
movq 0x8(%r13,%rdx,8), %rsi
incq %rdx
testq %rsi, %rsi
jne 0x15e69
movq $-0x1, %rdx
movslq %edx, %r13
jmp 0x15e92
movq $-0x1, %r13
xorl %edx, %edx
movb 0x1(%r12), %al
incq %r12
decq %rdx
cmpb $0x9, %al
je 0x15e94
cmpq $-0x2, %rdx
jne 0x15ff5
testb %al, %al
je 0x16013
movq %rbx, 0x8(%rsp)
xorl %eax, %eax
movq %r12, %rbx
leaq 0xcb0a(%rip), %rcx      # 0x229d0
movq (%rcx,%r13,8), %rcx
movzbl (%rbx), %edx
testl %edx, %edx
je 0x15ed6
cmpl $0x9, %edx
jne 0x15eee
testq %rcx, %rcx
jne 0x15ef3
cmpq $0x0, (%r14,%r13,8)
jne 0x15ef3
testb %dl, %dl
je 0x15f01
testb $0x1, %al
jne 0x15fba
incq %rbx
jmp 0x15eca
leaq 0x3(%r12), %rsi
leaq -0x1(%rbx), %rdx
movq %r12, %rdi
jmp 0x15f0f
leaq -0x1(%rbx), %rdx
leaq 0x6012(%rip), %rdi      # 0x1bf1e
movq %r12, %rsi
callq 0x16ebe
movq %rax, %r12
movq 0x8(%r15), %r14
movq %r14, %rax
testq %rax, %rax
je 0x15f4c
movq 0x10(%rax), %rsi
movb (%rsi), %dl
cmpb (%r12), %dl
jne 0x15f40
movb 0x1(%rsi), %dl
cmpb 0x1(%r12), %dl
jne 0x15f40
xorl %edx, %edx
movq %rsi, %rcx
jmp 0x15f46
movq 0x8(%rax), %rax
movb $0x1, %dl
testb %dl, %dl
jne 0x15f1e
jmp 0x15f4e
xorl %ecx, %ecx
testq %rcx, %rcx
jne 0x15f9a
movq %r14, %rdi
movq %r12, %rsi
callq 0x15ad6
movq %rax, 0x8(%r15)
xorl %edx, %edx
leaq 0xca35(%rip), %r14      # 0x229a0
movzbl (%rbx,%rdx), %eax
cmpl $0x9, %eax
jne 0x15f79
incq %rdx
jmp 0x15f6b
testl %eax, %eax
je 0x15f87
cmpq $0x1, %rdx
jne 0x1606f
addq %rdx, %rbx
movq %rbx, %r12
testb %al, %al
sete %al
jne 0x15ebf
jmp 0x15fba
movsbl (%r12), %esi
movsbl 0x1(%r12), %edx
leaq 0x5f75(%rip), %rdi      # 0x1bf21
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x42f1
jmp 0x15f53
movq (%rsp), %r12
movq 0x8(%rsp), %rbx
jmp 0x16017
leaq 0x5e8a(%rip), %rdi      # 0x1be56
movq %rbx, %rsi
xorl %eax, %eax
callq 0x42f1
xorl %r15d, %r15d
jmp 0x1601e
leaq 0x5ea4(%rip), %rdi      # 0x1be86
movq %rbx, %rsi
xorl %eax, %eax
callq 0x42f1
xorl %r15d, %r15d
movq (%rsp), %r12
jmp 0x1601e
notl %edx
leaq 0x5ee7(%rip), %rdi      # 0x1bee5
movq %rbx, %rsi
xorl %eax, %eax
callq 0x42f1
movq %r15, %rdi
callq 0x3060
xorl %r15d, %r15d
movq (%rsp), %r12
leaq 0xc952(%rip), %r13      # 0x22970
testq %r15, %r15
je 0x1609b
movl $0x18, %edi
callq 0x33e0
movq %rax, (%rax)
movq $0x0, 0x8(%rax)
movq %r15, 0x10(%rax)
testq %r12, %r12
je 0x16087
movq (%r12), %rcx
movq %rax, 0x8(%rcx)
movq %rax, (%r12)
movq %rbp, %r15
jmp 0x15d20
leaq 0x5dd9(%rip), %rdi      # 0x1be35
xorl %eax, %eax
callq 0x42f1
movq %r14, 0x10(%rsp)
xorl %ebp, %ebp
jmp 0x15de3
leaq 0x5e6f(%rip), %rdi      # 0x1bee5
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x42f1
jmp 0x16010
movq %rax, %r12
jmp 0x15d19
xorl %r12d, %r12d
jmp 0x160ae
testq %rbx, %rbx
jne 0x160a6
jmp 0x160ae
movq %r12, %rdi
callq 0x15a0c
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x3060
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq