// File: /workspace/github_c_makefile_star2_O3/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 0x16628
movq %rdi, %r15
movb (%rdi), %al
testb %al, %al
je 0x16628
movabsq $0x100000000, %rsi      # imm = 0x100000000
movl $0x2401, %edi           # imm = 0x2401
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
movq %r15, %r13
movl $0x1, %ecx
xorl %ebx, %ebx
cmpb $0xd, %al
ja 0x16344
movzbl %al, %edx
btl %edx, %edi
jb 0x16352
movb 0x1(%r15), %al
incq %r15
addq %rsi, %rbx
incl %ecx
jmp 0x16338
cmpb $0xa, %al
je 0x1636b
cmpl $0xd, %edx
jne 0x1636e
xorl %eax, %eax
cmpb $0xa, 0x1(%r15)
sete %al
leaq (%r15,%rax,2), %r15
jmp 0x1636e
incq %r15
testl %ecx, %ecx
je 0x163be
movslq %ecx, %rbp
testq %r12, %r12
je 0x1638e
cmpq %rbp, 0x8(%rsp)
jae 0x163a7
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3430
jmp 0x16396
movq %rbp, %rdi
callq 0x33e0
movq %rax, %r12
testq %rax, %rax
je 0x1663d
movq %rbp, 0x8(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3370
sarq $0x20, %rbx
movb $0x0, (%r12,%rbx)
cmpb $0x40, (%r12)
jne 0x165ca
leaq 0x1(%r12), %rcx
movq $-0x1, %rax
movq %r12, %rbp
movzbl (%rcx), %edx
testl %edx, %edx
je 0x163ef
cmpl $0x9, %edx
je 0x163ef
incq %rcx
decq %rax
incq %rbp
jmp 0x163d8
cmpq $-0x3, %rax
jne 0x165d3
movq %r14, (%rsp)
movl $0x10, %edi
callq 0x33e0
movq %rax, %r13
movb 0x1(%r12), %al
movb %al, (%r13)
movb 0x2(%r12), %cl
movb %cl, 0x1(%r13)
movq $0x0, 0x8(%r13)
movq 0xd545(%rip), %rsi      # 0x23970
movq $-0x1, %r14
testq %rsi, %rsi
je 0x1646b
leaq 0xd53a(%rip), %rdi      # 0x23978
xorl %edx, %edx
movabsq $0x100000000, %r8       # imm = 0x100000000
cmpb %al, (%rsi)
jne 0x16453
cmpb %cl, 0x1(%rsi)
je 0x16464
movq (%rdi), %rsi
addq %r8, %rdx
addq $0x8, %rdi
testq %rsi, %rsi
jne 0x1644a
jmp 0x1646b
sarq $0x20, %rdx
movq %rdx, %r14
xorl %edx, %edx
leaq 0xd52c(%rip), %rsi      # 0x239a0
movb 0x1(%rbp), %al
incq %rbp
decq %rdx
cmpb $0x9, %al
je 0x16474
cmpq $-0x2, %rdx
jne 0x165e6
testb %al, %al
movq %r12, 0x10(%rsp)
je 0x16575
leaq 0xd531(%rip), %rcx      # 0x239d0
movq (%rcx,%r14,8), %rcx
movq %rbp, %rbx
movzbl (%rbx), %edx
testl %edx, %edx
je 0x164b2
cmpl $0x9, %edx
jne 0x164c2
testq %rcx, %rcx
jne 0x164c7
cmpq $0x0, (%rsi,%r14,8)
jne 0x164c7
testb %dl, %dl
je 0x164d8
incq %rbx
jmp 0x164a6
leaq -0x1(%rbx), %rcx
movzbl 0x1(%rbp), %esi
addq $0x3, %rbp
movzbl %al, %edi
jmp 0x164e6
leaq -0x1(%rbx), %rcx
movl $0x20, %edi
movl $0x20, %esi
movq %rbp, %rdx
callq 0x17686
movq %rax, %rbp
movq 0x8(%r13), %r12
testq %r12, %r12
je 0x1651c
movsbl (%rbp), %esi
movq %r12, %rax
movq 0x10(%rax), %rcx
cmpb %sil, (%rcx)
jne 0x16513
movsbl 0x1(%rcx), %edx
cmpb 0x1(%rbp), %dl
je 0x16560
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x16501
movq %r12, %rdi
movq %rbp, %rsi
callq 0x160c5
movq %rax, 0x8(%r13)
xorl %edx, %edx
movq 0x10(%rsp), %r12
leaq 0xd467(%rip), %rsi      # 0x239a0
movzbl (%rbx,%rdx), %eax
cmpl $0x9, %eax
jne 0x16547
incq %rdx
jmp 0x16539
testl %eax, %eax
je 0x16575
addq %rdx, %rbx
movq %rbx, %rbp
cmpq $0x1, %rdx
je 0x16498
jmp 0x16603
leaq 0x6ad7(%rip), %rdi      # 0x1d03e
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x45d0
jmp 0x1651c
movl $0x18, %edi
callq 0x33e0
movq %rax, (%rax)
movq $0x0, 0x8(%rax)
movq %r13, 0x10(%rax)
movq (%rsp), %r14
testq %r14, %r14
je 0x165a3
movq (%r14), %rcx
movq %rax, 0x8(%rcx)
movq %rax, (%r14)
jmp 0x165a6
movq %rax, %r14
movabsq $0x100000000, %rsi      # imm = 0x100000000
movl $0x2401, %edi           # imm = 0x2401
movb (%r15), %al
testb %al, %al
jne 0x1632e
movq %r12, %rdi
callq 0x3060
jmp 0x1662b
leaq 0x69a5(%rip), %rdi      # 0x1cf76
jmp 0x165da
leaq 0x69cc(%rip), %rdi      # 0x1cfa6
movq %r12, %rsi
xorl %eax, %eax
callq 0x45d0
jmp 0x16618
notl %edx
leaq 0x6a16(%rip), %rdi      # 0x1d005
movq %r12, %rsi
xorl %eax, %eax
callq 0x45d0
movq %r13, %rdi
callq 0x3060
jmp 0x16614
leaq 0x69fb(%rip), %rdi      # 0x1d005
movq %r12, %rsi
xorl %eax, %eax
callq 0x45d0
movq (%rsp), %r14
movq %r14, %rdi
callq 0x15ff8
movq %r12, %rdi
callq 0x3060
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6911(%rip), %rdi      # 0x1cf55
xorl %eax, %eax
callq 0x45d0
jmp 0x1662b