// File: /workspace/github_c_makefile_star2_O2/skoren[P]bacValidation/bamcat.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:
testq %rdi, %rdi
je 0x7533
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movabsq $0x100000000, %rsi      # imm = 0x100000000
movl $0x2401, %r8d           # imm = 0x2401
leaq 0x8563(%rip), %r15      # 0xf800
xorl %r13d, %r13d
movq $0x0, -0x40(%rbp)
xorl %edx, %edx
movq %rdx, -0x38(%rbp)
movb (%r14), %cl
testb %cl, %cl
je 0x7518
pushq $0x1
popq %rax
xorl %ebx, %ebx
movq %r14, %r9
cmpb $0xd, %cl
ja 0x72cf
movzbl %cl, %edx
btl %edx, %r8d
jb 0x72dd
movb 0x1(%r9), %cl
incq %r9
addq %rsi, %rbx
incl %eax
jmp 0x72c1
cmpb $0xa, %cl
je 0x72f7
cmpl $0xd, %edx
jne 0x72fa
xorl %ecx, %ecx
cmpb $0xa, 0x1(%r9)
sete %cl
leaq (%r9,%rcx,2), %r9
jmp 0x72fa
incq %r9
movq %r9, -0x48(%rbp)
testl %eax, %eax
je 0x734d
movslq %eax, %r12
testq %r13, %r13
je 0x731d
cmpq %r12, -0x40(%rbp)
jae 0x7335
movq %r13, %rdi
movq %r12, %rsi
callq 0x3590
jmp 0x7325
movq %r12, %rdi
callq 0x3470
movq %rax, %r13
testq %rax, %rax
je 0x7574
movq %r12, -0x40(%rbp)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3260
sarq $0x20, %rbx
movb $0x0, (%r13,%rbx)
cmpb $0x40, (%r13)
movq %r13, -0x30(%rbp)
jne 0x7536
leaq 0x1(%r13), %rax
pushq $-0x1
popq %rcx
movzbl (%rax), %edx
testl %edx, %edx
je 0x737a
cmpl $0x9, %edx
je 0x737a
incq %rax
decq %rcx
incq %r13
jmp 0x7363
cmpq $-0x3, %rcx
jne 0x7542
pushq $0x10
popq %rdi
callq 0x3470
movq %rax, %r12
movq -0x30(%rbp), %rcx
movb 0x1(%rcx), %al
movb %al, (%r12)
movb 0x2(%rcx), %al
movb %al, 0x1(%r12)
andq $0x0, 0x8(%r12)
movq %r12, %rdi
callq 0x93ba
xorl %edx, %edx
movb 0x1(%r13), %cl
incq %r13
decq %rdx
cmpb $0x9, %cl
je 0x73b2
cmpq $-0x2, %rdx
jne 0x7556
movslq %eax, %rbx
testb %cl, %cl
je 0x748d
leaq 0x8453(%rip), %rax      # 0xf830
movq (%rax,%rbx,8), %rax
movq %r13, %r14
movzbl (%r14), %ecx
testl %ecx, %ecx
je 0x73f1
cmpl $0x9, %ecx
jne 0x7401
testq %rax, %rax
jne 0x7406
cmpq $0x0, (%r15,%rbx,8)
jne 0x7406
testb %cl, %cl
je 0x7413
incq %r14
jmp 0x73e4
leaq 0x3(%r13), %rsi
leaq -0x1(%r14), %rdx
movq %r13, %rdi
jmp 0x7421
leaq -0x1(%r14), %rdx
leaq 0x448b(%rip), %rdi      # 0xb8a9
movq %r13, %rsi
callq 0x93f2
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
callq 0x89dc
testq %rax, %rax
je 0x7455
movsbl (%r13), %esi
movsbl 0x1(%r13), %edx
leaq 0x4462(%rip), %rdi      # 0xb8ac
movq -0x30(%rbp), %rcx
xorl %eax, %eax
callq 0x8ad8
movq 0x8(%r12), %rdi
movq %r13, %rsi
callq 0x8243
movq %rax, 0x8(%r12)
xorl %edx, %edx
movzbl (%r14,%rdx), %ecx
cmpl $0x9, %ecx
jne 0x7478
incq %rdx
jmp 0x7469
testl %ecx, %ecx
je 0x7482
cmpq $0x1, %rdx
jne 0x74f1
addq %rdx, %r14
movq %r14, %r13
jmp 0x73ce
pushq $0x18
popq %rdi
callq 0x3470
andq $0x0, 0x8(%rax)
movq %rax, (%rax)
movq %r12, 0x10(%rax)
movq -0x38(%rbp), %rdx
testq %rdx, %rdx
je 0x74d1
movq (%rdx), %rcx
movq %rax, 0x8(%rcx)
movq %rax, (%rdx)
movq -0x48(%rbp), %r14
movq -0x30(%rbp), %r13
movabsq $0x100000000, %rsi      # imm = 0x100000000
movl $0x2401, %r8d           # imm = 0x2401
jmp 0x72ae
movq %rax, %rdx
movq -0x30(%rbp), %r13
movabsq $0x100000000, %rsi      # imm = 0x100000000
movl $0x2401, %r8d           # imm = 0x2401
movq -0x48(%rbp), %r14
jmp 0x72aa
leaq 0x4378(%rip), %rdi      # 0xb870
movq -0x30(%rbp), %rsi
xorl %eax, %eax
callq 0x8ad8
movq -0x38(%rbp), %rdi
callq 0x5902
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %r13
movq %r13, %rdi
callq 0x33d0
movq -0x38(%rbp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
leaq 0x42a4(%rip), %rdi      # 0xb7e1
movq %r13, %rsi
jmp 0x754d
leaq 0x42c8(%rip), %rdi      # 0xb811
movq -0x30(%rbp), %rsi
xorl %eax, %eax
callq 0x8ad8
jmp 0x7503
notl %edx
leaq 0x4311(%rip), %rdi      # 0xb870
movq -0x30(%rbp), %rsi
xorl %eax, %eax
callq 0x8ad8
movq %r12, %rdi
callq 0x33d0
jmp 0x7503
leaq 0x4245(%rip), %rdi      # 0xb7c0
xorl %eax, %eax
callq 0x8ad8
xorl %r13d, %r13d
jmp 0x7518