// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: bcf_hdr_parse_line
bcf_hrec_t *bcf_hdr_parse_line(const bcf_hdr_t *h, const char *line, int *len)
{
    bcf_hrec_t *hrec = NULL;
    const char *p = line;
    if (p[0] != '#' || p[1] != '#') { *len = 0; return NULL; }
    p += 2;

    const char *q = p;
    while ( *q && *q!='=' && *q != '\n' ) q++;
    ptrdiff_t n = q-p;
    if ( *q!='=' || !n ) // wrong format
        goto malformed_line;

    hrec = (bcf_hrec_t*) calloc(1,sizeof(bcf_hrec_t));
    if (!hrec) { *len = -1; return NULL; }
    hrec->key = (char*) malloc(sizeof(char)*(n+1));
    if (!hrec->key) goto fail;
    memcpy(hrec->key,p,n);
    hrec->key[n] = 0;
    hrec->type = -1;

    p = ++q;
    if ( *p!='<' ) // generic field, e.g. ##samtoolsVersion=0.1.18-r579
    {
        while ( *q && *q!='\n' ) q++;
        hrec->value = (char*) malloc((q-p+1)*sizeof(char));
        if (!hrec->value) goto fail;
        memcpy(hrec->value, p, q-p);
        hrec->value[q-p] = 0;
        *len = q - line + (*q ? 1 : 0); // Skip \n but not \0
        return hrec;
    }

    // structured line, e.g.
    // ##INFO=<ID=PV1,Number=1,Type=Float,Description="P-value for baseQ bias">
    // ##PEDIGREE=<Name_0=G0-ID,Name_1=G1-ID,Name_3=GN-ID>
    int nopen = 1;
    while ( *q && *q!='\n' && nopen>0 )
    {
        p = ++q;
        while ( *q && *q==' ' ) { p++; q++; }
        // ^[A-Za-z_][0-9A-Za-z_.]*$
        if (p==q && *q && (isalpha_c(*q) || *q=='_'))
        {
            q++;
            while ( *q && (isalnum_c(*q) || *q=='_' || *q=='.') ) q++;
        }
        n = q-p;
        int m = 0;
        while ( *q && *q==' ' ) { q++; m++; }
        if ( *q!='=' || !n )
            goto malformed_line;

        if (bcf_hrec_add_key(hrec, p, q-p-m) < 0) goto fail;
        p = ++q;
        while ( *q && *q==' ' ) { p++; q++; }

        int quoted = 0;
        char ending = '\0';
        switch (*p) {
        case '"':
            quoted = 1;
            ending = '"';
            p++;
            break;
        case '[':
            quoted = 1;
            ending = ']';
            break;
        }
        if ( quoted ) q++;
        while ( *q && *q != '\n' )
        {
            if ( quoted ) { if ( *q==ending && !is_escaped(p,q) ) break; }
            else
            {
                if ( *q=='<' ) nopen++;
                if ( *q=='>' ) nopen--;
                if ( !nopen ) break;
                if ( *q==',' && nopen==1 ) break;
            }
            q++;
        }
        const char *r = q;
        if (quoted && ending == ']') {
            if (*q == ending) {
                r++;
                q++;
                quoted = 0;
            } else {
                char buffer[320];
                hts_log_error("Missing ']' in header line %s",
                              hts_strprint(buffer, sizeof(buffer), '"',
                                           line, q-line));
                goto fail;
            }
        }
        while ( r > p && r[-1] == ' ' ) r--;
        if (bcf_hrec_set_val(hrec, hrec->nkeys-1, p, r-p, quoted) < 0)
            goto fail;
        if ( quoted && *q==ending ) q++;
        if ( *q=='>' )
        {
            if (nopen) nopen--;     // this can happen with nested angle brackets <>
            q++;
        }
    }
    if ( nopen )
        hts_log_warning("Incomplete header line, trying to proceed anyway:\n\t[%s]\n\t[%d]",line,q[0]);

    // Skip to end of line
    int nonspace = 0;
    p = q;
    while ( *q && *q!='\n' ) { nonspace |= !isspace_c(*q); q++; }
    if (nonspace) {
        char buffer[320];
        hts_log_warning("Dropped trailing junk from header line '%s'",
                        hts_strprint(buffer, sizeof(buffer),
                                     '"', line, q - line));
    }

    *len = q - line + (*q ? 1 : 0);
    return hrec;

 fail:
    *len = -1;
    bcf_hrec_destroy(hrec);
    return NULL;

 malformed_line:
    {
        char buffer[320];
        while ( *q && *q!='\n' ) q++;  // Ensure *len includes full line
        hts_log_error("Could not parse the header line: %s",
                      hts_strprint(buffer, sizeof(buffer),
                                   '"', line, q - line));
        *len = q - line + (*q ? 1 : 0);
        bcf_hrec_destroy(hrec);
        return NULL;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdx, %rbx
cmpb $0x23, (%rsi)
jne 0x2c4a2
movq %rsi, %r15
cmpb $0x23, 0x1(%rsi)
jne 0x2c4a2
leaq 0x2(%r15), %r12
movl $0x3, %ebp
movabsq $0x2000000000000401, %rax # imm = 0x2000000000000401
movzbl -0x1(%r15,%rbp), %ecx
cmpq $0x3d, %rcx
ja 0x2c49d
btq %rcx, %rax
jb 0x2c4c0
incq %rbp
jmp 0x2c48b
movl $0x0, (%rbx)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x3d, %cl
setne %al
cmpq $0x3, %rbp
sete %cl
orb %al, %cl
jne 0x2c7c6
movl $0x1, %edi
movl $0x30, %esi
callq 0x42f0
testq %rax, %rax
je 0x2c834
movq %rax, %r14
movq %rbx, 0x8(%rsp)
leaq -0x2(%rbp), %rdi
callq 0x46a0
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x2c8aa
movq %rax, %r13
leaq -0x3(%rbp), %rdx
movq %rax, %rdi
movq %r12, %rsi
callq 0x43c0
movb $0x0, -0x3(%r13,%rbp)
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
leaq (%r15,%rbp), %r12
cmpb $0x3c, (%r15,%rbp)
jne 0x2c83f
movl $0x1, %r13d
movsbl (%r12), %r8d
testl %r8d, %r8d
je 0x2c8c2
cmpb $0xa, %r8b
je 0x2c8c2
testl %r13d, %r13d
jle 0x2c8c2
movb 0x1(%r12), %bpl
incq %r12
cmpb $0x20, %bpl
je 0x2c560
movq %r12, %rax
testb %bpl, %bpl
je 0x2c59f
callq 0x4510
movq (%rax), %rcx
cmpb $0x5f, %bpl
je 0x2c63c
movzbl %bpl, %eax
movzwl (%rcx,%rax,2), %edx
movq %r12, %rax
andl $0x400, %edx            # imm = 0x400
jne 0x2c63c
movb (%rax), %dl
cmpb $0x20, %dl
jne 0x2c5ba
xorl %ecx, %ecx
movb 0x1(%rax,%rcx), %dl
incq %rcx
cmpb $0x20, %dl
je 0x2c5a8
leaq (%rax,%rcx), %rbp
jmp 0x2c5bf
movq %rax, %rbp
xorl %ecx, %ecx
cmpb $0x3d, %dl
setne %dl
cmpq %r12, %rax
sete %al
movl $0x4, %esi
orb %dl, %al
jne 0x2c62c
addq %r12, %rcx
movq %rbp, %rdx
subq %rcx, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2c01c
movl $0x5, %esi
testl %eax, %eax
js 0x2c62c
leaq 0x1(%rbp), %rdx
cmpb $0x20, 0x1(%rbp)
jne 0x2c609
cmpb $0x20, 0x1(%rdx)
leaq 0x1(%rdx), %rdx
je 0x2c5fb
leaq -0x1(%rdx), %rbp
movzbl (%rdx), %ecx
cmpl $0x5b, %ecx
je 0x2c66d
xorl %eax, %eax
cmpl $0x22, %ecx
jne 0x2c67e
incq %rdx
movl $0x22, %r9d
movl $0x1, %ebx
movb $0x1, %al
xorl %ecx, %ecx
jmp 0x2c685
movq %rbp, %r12
testl %esi, %esi
je 0x2c53f
jmp 0x2c892
leaq 0x1(%r12), %rax
movb 0x1(%r12), %dl
testb %dl, %dl
je 0x2c59f
movzbl %dl, %esi
testb $0x8, (%rcx,%rsi,2)
jne 0x2c665
cmpb $0x5f, %dl
je 0x2c665
cmpl $0x2e, %esi
jne 0x2c59f
movb 0x1(%rax), %dl
incq %rax
jmp 0x2c646
movl $0x5d, %r9d
movl $0x1, %ebx
movb $0x1, %al
movb $0x1, %cl
jmp 0x2c685
xorl %ebx, %ebx
xorl %ecx, %ecx
xorl %r9d, %r9d
movzbl %al, %esi
leaq (%rsi,%rbp), %r12
incq %r12
movzbl (%r12), %esi
testl %esi, %esi
je 0x2c706
cmpl $0xa, %esi
je 0x2c706
testb %al, %al
je 0x2c6ce
movsbl %sil, %edi
cmpl %edi, %r9d
jne 0x2c6f6
leaq -0x1(%r12), %r10
cmpq %rdx, %r10
jb 0x2c706
xorl %edi, %edi
cmpb $0x5c, (%r10)
jne 0x2c6c6
incl %edi
decq %r10
cmpq %rdx, %r10
jae 0x2c6b6
testb $0x1, %dil
jne 0x2c6f6
jmp 0x2c706
xorl %edi, %edi
cmpb $0x3c, %sil
sete %dil
addl %edi, %r13d
xorl %edi, %edi
cmpb $0x3e, %sil
sete %dil
subl %edi, %r13d
je 0x2c6fb
cmpb $0x2c, %sil
jne 0x2c6f6
cmpl $0x1, %r13d
je 0x2c700
incq %r12
jmp 0x2c68f
xorl %r13d, %r13d
jmp 0x2c706
movl $0x1, %r13d
andb %cl, %al
cmpb $0x1, %al
jne 0x2c717
cmpb $0x5d, %sil
jne 0x2c782
incq %r12
xorl %ebx, %ebx
movl %r9d, %ebp
movq %r12, %rsi
subq %rdx, %rsi
movq %r12, %rax
movq %rsi, %rcx
cmpq %rdx, %rax
jbe 0x2c739
cmpb $0x20, -0x1(%rax)
leaq -0x1(%rax), %rax
leaq -0x1(%rcx), %rsi
je 0x2c723
movl 0x18(%r14), %esi
decl %esi
movq %r14, %rdi
movl %ebx, %r8d
callq 0x2c100
testl %eax, %eax
js 0x2c7bc
testl %ebx, %ebx
je 0x2c761
movsbl (%r12), %eax
xorl %ecx, %ecx
cmpl %eax, %ebp
sete %cl
addq %rcx, %r12
xorl %esi, %esi
movl %r13d, %eax
subl $0x1, %eax
cmovbl %esi, %eax
xorl %ecx, %ecx
cmpb $0x3e, (%r12)
sete %cl
cmovel %eax, %r13d
addq %rcx, %r12
jmp 0x2c62f
movq %r12, %r8
subq %r15, %r8
movl $0x140, %esi            # imm = 0x140
leaq 0x10(%rsp), %rdi
movl $0x22, %edx
movq %r15, %rcx
callq 0x2a3a0
movl $0x1, %edi
leaq 0x81eb7(%rip), %rsi     # 0xae662
leaq 0x81ec3(%rip), %rdx     # 0xae675
movq %rax, %rcx
xorl %eax, %eax
callq 0x9774
movl $0x5, %esi
jmp 0x2c62f
leaq (%r15,%rbp), %r12
decq %r12
xorl %r14d, %r14d
movq %r12, %r13
subq %r15, %r13
movzbl (%r12), %eax
testl %eax, %eax
je 0x2c7ec
cmpl $0xa, %eax
je 0x2c7ec
incq %r12
incq %r13
jmp 0x2c7d6
leaq 0x10(%rsp), %rdi
movl $0x140, %esi            # imm = 0x140
movl $0x22, %edx
movq %r15, %rcx
movq %r13, %r8
callq 0x2a3a0
leaq 0x81e55(%rip), %rsi     # 0xae662
leaq 0x81ee9(%rip), %rdx     # 0xae6fd
movl $0x1, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x9774
cmpb $0x1, (%r12)
sbbl $-0x1, %r13d
movl %r13d, (%rbx)
jmp 0x2c8b5
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
jmp 0x2c4a8
xorl %r13d, %r13d
movzbl (%r15,%rbp), %ebx
testl %ebx, %ebx
je 0x2c858
cmpl $0xa, %ebx
je 0x2c858
incq %rbp
incq %r13
jmp 0x2c842
leaq 0x1(%r13), %rdi
callq 0x46a0
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x2c8aa
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x43c0
movb $0x0, (%r15,%r13)
cmpb $0x1, %bl
sbbl $-0x1, %ebp
movq 0x8(%rsp), %rax
movl %ebp, (%rax)
jmp 0x2c4ab
cmpl $0x1, %esi
je 0x2c967
cmpl $0x4, %esi
jne 0x2c8aa
movq 0x8(%rsp), %rbx
jmp 0x2c7d0
movq 0x8(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq %r14, %rdi
callq 0x2bd39
jmp 0x2c4a8
testl %r13d, %r13d
je 0x2c8e4
leaq 0x81d94(%rip), %rsi     # 0xae662
leaq 0x81dbe(%rip), %rdx     # 0xae693
movl $0x3, %edi
movq %r15, %rcx
xorl %eax, %eax
callq 0x9774
movq %r12, %r13
subq %r15, %r13
xorl %ebp, %ebp
movzbl (%r12), %ebx
testl %ebx, %ebx
je 0x2c916
cmpl $0xa, %ebx
je 0x2c916
callq 0x4510
movq (%rax), %rax
xorl %ecx, %ecx
testb $0x20, 0x1(%rax,%rbx,2)
sete %cl
orl %ecx, %ebp
incq %r12
incq %r13
jmp 0x2c8ec
testl %ebp, %ebp
je 0x2c951
leaq 0x10(%rsp), %rdi
movl $0x140, %esi            # imm = 0x140
movl $0x22, %edx
movq %r15, %rcx
movq %r13, %r8
callq 0x2a3a0
leaq 0x81d27(%rip), %rsi     # 0xae662
leaq 0x81d8f(%rip), %rdx     # 0xae6d1
movl $0x3, %edi
movq %rax, %rcx
xorl %eax, %eax
callq 0x9774
cmpb $0x1, (%r12)
sbbl $-0x1, %r13d
movq 0x8(%rsp), %rax
movl %r13d, (%rax)
jmp 0x2c4ab
jmp 0x2c4ab