// File: /workspace/github_c_makefile_star2_O0/skoren[P]bacValidation/bamcat.c
// Function: sam_header_line_parse
static HeaderLine *sam_header_line_parse(const char *headerLine)
{
    HeaderLine *hline;
    HeaderTag *tag;
    const char *from, *to;
    from = headerLine;

    if ( *from != '@' ) {
		debug("[sam_header_line_parse] expected '@', got [%s]\n", headerLine);
		return 0;
	}
    to = ++from;

    while (*to && *to!='\t') to++;
    if ( to-from != 2 ) {
		debug("[sam_header_line_parse] expected '@XY', got [%s]\nHint: The header tags must be tab-separated.\n", headerLine);
		return 0;
	}
    
    hline = malloc(sizeof(HeaderLine));
    hline->type[0] = from[0];
    hline->type[1] = from[1];
    hline->tags = NULL;

    int itype = tag_exists(hline->type, types);
    
    from = to;
    while (*to && *to=='\t') to++;
    if ( to-from != 1 ) {
        debug("[sam_header_line_parse] multiple tabs on line [%s] (%d)\n", headerLine,(int)(to-from));
        free(hline);
		return 0;
	}
    from = to;
    while (*from)
    {
        while (*to && *to!='\t') to++;

        if ( !required_tags[itype] && !optional_tags[itype] )
        {
            // CO is a special case, it can contain anything, including tabs
            if ( *to ) { to++; continue; }
            tag = new_tag("  ",from,to-1);
        }
        else
            tag = new_tag(from,from+3,to-1);

        if ( header_line_has_tag(hline,tag->key) ) 
                debug("The tag '%c%c' present (at least) twice on line [%s]\n", tag->key[0],tag->key[1], headerLine);
        hline->tags = list_append(hline->tags, tag);

        from = to;
        while (*to && *to=='\t') to++;
        if ( *to && to-from != 1 ) {
			debug("[sam_header_line_parse] multiple tabs on line [%s] (%d)\n", headerLine,(int)(to-from));
			return 0;
		}

        from = to;
    }
    return hline;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
je 0xb0bf
movq -0x10(%rbp), %rsi
leaq 0x764d(%rip), %rdi      # 0x126f8
movb $0x0, %al
callq 0xb9c0
movq $0x0, -0x8(%rbp)
jmp 0xb3b7
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x35(%rbp)
je 0xb0f0
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
setne %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0xb0f9
jmp 0xb107
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb0cf
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
cmpq $0x2, %rax
je 0xb137
movq -0x10(%rbp), %rsi
leaq 0x7605(%rip), %rdi      # 0x12728
movb $0x0, %al
callq 0xb9c0
movq $0x0, -0x8(%rbp)
jmp 0xb3b7
movl $0x10, %edi
callq 0x3520
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movb (%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rdi
leaq 0xc6ca(%rip), %rsi      # 0x17840
callq 0xdb00
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x36(%rbp)
je 0xb1a7
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
sete %al
movb %al, -0x36(%rbp)
movb -0x36(%rbp), %al
testb $0x1, %al
jne 0xb1b0
jmp 0xb1be
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb186
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
cmpq $0x1, %rax
je 0xb204
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
leaq 0x75a0(%rip), %rdi      # 0x12787
movb $0x0, %al
callq 0xb9c0
movq -0x18(%rbp), %rdi
callq 0x3490
movq $0x0, -0x8(%rbp)
jmp 0xb3b7
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpb $0x0, (%rax)
je 0xb3af
jmp 0xb21b
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x37(%rbp)
je 0xb23c
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
setne %al
movb %al, -0x37(%rbp)
movb -0x37(%rbp), %al
testb $0x1, %al
jne 0xb245
jmp 0xb253
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb21b
movslq -0x34(%rbp), %rcx
leaq 0xc642(%rip), %rax      # 0x178a0
cmpq $0x0, (%rax,%rcx,8)
jne 0xb2af
movslq -0x34(%rbp), %rcx
leaq 0xc600(%rip), %rax      # 0x17870
cmpq $0x0, (%rax,%rcx,8)
jne 0xb2af
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0xb291
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb20c
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $-0x1, %rdx
leaq 0x751c(%rip), %rdi      # 0x127c0
callq 0xdb90
movq %rax, -0x20(%rbp)
jmp 0xb2cc
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x3, %rsi
movq -0x30(%rbp), %rdx
addq $-0x1, %rdx
callq 0xdb90
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xb7d0
cmpq $0x0, %rax
je 0xb300
movq -0x20(%rbp), %rax
movsbl (%rax), %esi
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %edx
movq -0x10(%rbp), %rcx
leaq 0x74ca(%rip), %rdi      # 0x127c3
movb $0x0, %al
callq 0xb9c0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0xaae0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x38(%rbp)
je 0xb345
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
sete %al
movb %al, -0x38(%rbp)
movb -0x38(%rbp), %al
testb $0x1, %al
jne 0xb34e
jmp 0xb35c
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb324
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xb3a2
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
cmpq $0x1, %rax
je 0xb3a2
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
leaq 0x73f6(%rip), %rdi      # 0x12787
movb $0x0, %al
callq 0xb9c0
movq $0x0, -0x8(%rbp)
jmp 0xb3b7
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xb20c
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)