// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/vcf.c
// Function: bcf_hdr_parse
int bcf_hdr_parse(bcf_hdr_t *hdr, char *htxt)
{
    int len, done = 0;
    char *p = htxt;

    // Check sanity: "fileformat" string must come as first
    bcf_hrec_t *hrec = bcf_hdr_parse_line(hdr,p,&len);
    if ( !hrec || !hrec->key || strcasecmp(hrec->key,"fileformat") )
        hts_log_warning("The first line should be ##fileformat; is the VCF/BCF header broken?");
    if (bcf_hdr_add_hrec(hdr, hrec) < 0) {
        bcf_hrec_destroy(hrec);
        return -1;
    }

    // The filter PASS must appear first in the dictionary
    hrec = bcf_hdr_parse_line(hdr,"##FILTER=<ID=PASS,Description=\"All filters passed\">",&len);
    if (!hrec || bcf_hdr_add_hrec(hdr, hrec) < 0) {
        bcf_hrec_destroy(hrec);
        return -1;
    }

    // Parse the whole header
    do {
        while (NULL != (hrec = bcf_hdr_parse_line(hdr, p, &len))) {
            if (bcf_hdr_add_hrec(hdr, hrec) < 0) {
                bcf_hrec_destroy(hrec);
                return -1;
            }
            p += len;
        }
        assert(hrec == NULL);
        if (len < 0) {
            // len < 0 indicates out-of-memory, or similar error
            hts_log_error("Could not parse header line: %s", strerror(errno));
            return -1;
        } else if (len > 0) {
            // Bad header line.  bcf_hdr_parse_line() will have logged it.
            // Skip and try again on the next line (p + len will be the start
            // of the next one).
            p += len;
            continue;
        }

        // Next should be the sample line.  If not, it was a malformed
        // header, in which case print a warning and skip (many VCF
        // operations do not really care about a few malformed lines).
        // In the future we may want to add a strict mode that errors in
        // this case.
        if ( strncmp("#CHROM\t",p,7) && strncmp("#CHROM ",p,7) ) {
            char *eol = strchr(p, '\n');
            if (*p != '\0') {
                char buffer[320];
                hts_log_warning("Could not parse header line: %s",
                                hts_strprint(buffer, sizeof(buffer),
                                               '"', p,
                                               eol ? (eol - p) : SIZE_MAX));
            }
            if (eol) {
                p = eol + 1; // Try from the next line.
            } else {
                done = -1; // No more lines left, give up.
            }
        } else {
            done = 1; // Sample line found
        }
    } while (!done);

    if (done < 0) {
        // No sample line is fatal.
        hts_log_error("Could not parse the header, sample line not found");
        return -1;
    }

    if (bcf_hdr_parse_sample_line(hdr,p) < 0)
        return -1;
    if (bcf_hdr_sync(hdr) < 0)
        return -1;
    bcf_hdr_check_sanity(hdr);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
callq 0x3bbb0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x3e8f2
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3e8f2
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xc8ef2(%rip), %rsi     # 0x1077da
callq 0x4500
cmpl $0x0, %eax
je 0x3e90c
movl $0x3, %edi
leaq 0xc8f60(%rip), %rsi     # 0x10785e
leaq 0xc8f67(%rip), %rdx     # 0x10786c
movb $0x0, %al
callq 0x9d90
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3ce30
cmpl $0x0, %eax
jge 0x3e933
movq -0x30(%rbp), %rdi
callq 0x3b040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
movq -0x10(%rbp), %rdi
leaq 0xc8f73(%rip), %rsi     # 0x1078b1
leaq -0x1c(%rbp), %rdx
callq 0x3bbb0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x3e964
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3ce30
cmpl $0x0, %eax
jge 0x3e979
movq -0x30(%rbp), %rdi
callq 0x3b040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
jmp 0x3e97b
jmp 0x3e97d
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
callq 0x3bbb0
movq %rax, %rcx
movq %rcx, -0x30(%rbp)
xorl %eax, %eax
cmpq %rcx, %rax
je 0x3e9d6
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3ce30
cmpl $0x0, %eax
jge 0x3e9c3
movq -0x30(%rbp), %rdi
callq 0x3b040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x3e97d
cmpq $0x0, -0x30(%rbp)
jne 0x3e9df
jmp 0x3e9fe
leaq 0xc8eff(%rip), %rdi     # 0x1078e5
leaq 0xc8c76(%rip), %rsi     # 0x107663
movl $0x507, %edx            # imm = 0x507
leaq 0xc8ef9(%rip), %rcx     # 0x1078f2
callq 0x42d0
cmpl $0x0, -0x1c(%rbp)
jge 0x3ea39
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, %rcx
movl $0x1, %edi
leaq 0xc8e3f(%rip), %rsi     # 0x10785e
leaq 0xc8ef3(%rip), %rdx     # 0x107919
movb $0x0, %al
callq 0x9d90
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
cmpl $0x0, -0x1c(%rbp)
jle 0x3ea55
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x3eb61
jmp 0x3ea57
movq -0x28(%rbp), %rsi
leaq 0xca664(%rip), %rdi     # 0x1090c6
movl $0x7, %edx
callq 0x41f0
cmpl $0x0, %eax
je 0x3eb58
movq -0x28(%rbp), %rsi
leaq 0xc8eb9(%rip), %rdi     # 0x107939
movl $0x7, %edx
callq 0x41f0
cmpl $0x0, %eax
je 0x3eb58
movq -0x28(%rbp), %rdi
movl $0xa, %esi
callq 0x4160
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x3eb3a
leaq -0x180(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x3eae9
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x198(%rbp)
jmp 0x3eaf9
movq $-0x1, %rax
movq %rax, -0x198(%rbp)
jmp 0x3eaf9
movq -0x188(%rbp), %rcx
movq -0x190(%rbp), %rdi
movq -0x198(%rbp), %r8
movl $0x140, %esi            # imm = 0x140
movl $0x22, %edx
callq 0x38530
movq %rax, %rcx
movl $0x3, %edi
leaq 0xc8d32(%rip), %rsi     # 0x10785e
leaq 0xc8de6(%rip), %rdx     # 0x107919
movb $0x0, %al
callq 0x9d90
cmpq $0x0, -0x38(%rbp)
je 0x3eb4f
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x3eb56
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
jmp 0x3eb5f
movl $0x1, -0x20(%rbp)
jmp 0x3eb61
cmpl $0x0, -0x20(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3e97b
cmpl $0x0, -0x20(%rbp)
jge 0x3eb9b
movl $0x1, %edi
leaq 0xc8cda(%rip), %rsi     # 0x10785e
leaq 0xc8db6(%rip), %rdx     # 0x107941
movb $0x0, %al
callq 0x9d90
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3ac80
cmpl $0x0, %eax
jge 0x3ebb6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
movq -0x10(%rbp), %rdi
callq 0x3ae50
cmpl $0x0, %eax
jge 0x3ebcd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3ebdd
movq -0x10(%rbp), %rdi
callq 0x3e670
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopl (%rax)