// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/bcftools/vcf.c
// Function: vcf_hdr_read
bcf_hdr_t *vcf_hdr_read(bcf_t *bp)
{
	kstring_t meta, smpl;
	int dret;
	vcf_t *v;
	bcf_hdr_t *h;
	if (!bp->is_vcf) return bcf_hdr_read(bp);
	h = calloc(1, sizeof(bcf_hdr_t));
	v = (vcf_t*)bp->v;
	v->line.l = 0;
	memset(&meta, 0, sizeof(kstring_t));
	memset(&smpl, 0, sizeof(kstring_t));
	while (ks_getuntil(v->ks, '\n', &v->line, &dret) >= 0) {
		if (v->line.l < 2) continue;
		if (v->line.s[0] != '#') {
            free(meta.s);
            free(smpl.s);
            free(h);
            return 0; // no sample line
        }
		if (v->line.s[0] == '#' && v->line.s[1] == '#') {
			kputsn(v->line.s, v->line.l, &meta); kputc('\n', &meta);
		} else if (v->line.s[0] == '#') {
			int k;
			ks_tokaux_t aux;
			char *p;
			for (p = kstrtok(v->line.s, "\t\n", &aux), k = 0; p; p = kstrtok(0, 0, &aux), ++k) {
				if (k >= 9) {
					kputsn(p, aux.p - p, &smpl);
					kputc('\0', &smpl);
				}
			}
			break;
		}
	}
	kputc('\0', &meta);
	h->name = 0;
	h->sname = smpl.s; h->l_smpl = smpl.l;
	h->txt = meta.s; h->l_txt = meta.l;
	bcf_hdr_sync(h);
	return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
cmpl $0x0, (%rdi)
je 0xd15e
movl $0x1, %edi
movl $0x40, %esi
callq 0x2260
movq %rax, %rbp
movq 0x8(%rbx), %r14
leaq 0x20(%r14), %r12
movq $0x0, 0x20(%r14)
movq $0x0, 0x18(%rsp)
leaq 0x34(%rsp), %r13
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
movq 0x10(%r14), %rdi
movl $0xa, %esi
movq %r12, %rdx
movq %r13, %rcx
callq 0xd2e8
testl %eax, %eax
js 0xd0ce
movq (%r12), %rax
cmpq $0x2, %rax
jb 0xcf86
movq %rbp, 0x20(%rsp)
movq 0x30(%r14), %rbp
cmpb $0x23, (%rbp)
jne 0xd174
cmpb $0x23, 0x1(%rbp)
jne 0xd18a
movslq %eax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x28(%rsp)
addq %rcx, %rax
incq %rax
cmpq 0x10(%rsp), %rax
jae 0xcfea
movq 0x10(%rsp), %rbx
jmp 0xd02c
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rbx
shrq $0x10, %rbx
orq %rax, %rbx
incq %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x23d0
movq %rax, %r15
movq %r15, 0x8(%rsp)
movq 0x18(%rsp), %r15
movq 0x8(%rsp), %rax
leaq (%rax,%r15), %rdi
movq %rbp, %rsi
movq 0x28(%rsp), %rbp
movq %rbp, %rdx
callq 0x22e0
movq 0x8(%rsp), %rdi
leaq (%r15,%rbp), %rax
movb $0x0, (%rdi,%rax)
addq %rbp, %r15
incq %r15
cmpq %rbx, %r15
movq %r15, 0x18(%rsp)
jae 0xd076
movq %rbx, 0x10(%rsp)
movq %rdi, %r15
jmp 0xd0bd
movq %rax, %rbx
movq %r15, %rax
shrq %rax
orq %r15, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x10(%rsp)
callq 0x23d0
movq %rax, %r15
movq %rbx, %rax
movw $0xa, (%r15,%rax)
movq 0x20(%rsp), %rbp
jmp 0xcf86
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rax
leaq 0x1(%r14), %rbx
cmpq %rax, %rbx
jb 0xd126
movq %rbx, %rax
shrq %rax
orq %rbx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %r15, %rdi
callq 0x23d0
movq %rax, %r15
movw $0x0, (%r15,%r14)
movq $0x0, 0x18(%rbp)
movq %r13, 0x20(%rbp)
movl %r12d, 0xc(%rbp)
movq %r15, 0x28(%rbp)
movl %ebx, 0x10(%rbp)
movq %rbp, %rdi
callq 0xb602
movq %rbp, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb51c
movq %r15, %rdi
callq 0x2060
movq 0x20(%rsp), %rdi
callq 0x2060
xorl %ebp, %ebp
jmp 0xd14c
leaq 0xe033(%rip), %rsi      # 0x1b1c4
leaq 0x38(%rsp), %rdx
movq %rbp, %rdi
callq 0x7466
testq %rax, %rax
je 0xd2d8
movq %rax, %r13
xorl %r12d, %r12d
leaq 0x38(%rsp), %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
cmpl $0x9, %r12d
jb 0xd2b3
movl 0x60(%rsp), %eax
subl %r13d, %eax
movslq %eax, %rdx
movq 0x8(%rsp), %rax
addq %rdx, %rax
incq %rax
cmpq %rbp, %rax
jae 0xd1e9
movq %r14, %rbx
jmp 0xd231
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rbp
shrq $0x10, %rbp
orq %rax, %rbp
incq %rbp
movq %r14, %rdi
movq %rbp, %rsi
movq %rdx, %rbx
callq 0x23d0
movq %rbx, %rdx
movq %rax, %rbx
movq 0x8(%rsp), %r14
leaq (%rbx,%r14), %rdi
movq %r13, %rsi
movq %rdx, %r13
callq 0x22e0
leaq (%r14,%r13), %rax
movb $0x0, (%rbx,%rax)
addq %r13, %r14
incq %r14
cmpq %rbp, %r14
movq %r14, 0x8(%rsp)
jb 0xd2a5
movq %rax, %r13
movq %r14, %rax
shrq %rax
orq %r14, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rbp
shrq $0x10, %rbp
orq %rcx, %rbp
incq %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x23d0
movq %rax, %rbx
movq %r13, %rax
movq %rbx, %r14
movw $0x0, (%rbx,%rax)
leaq 0x38(%rsp), %rbx
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x7466
movq %rax, %r13
incl %r12d
testq %rax, %rax
jne 0xd1c0
movq 0x8(%rsp), %r12
movq %r14, %r13
jmp 0xd2de
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x20(%rsp), %rbp
jmp 0xd0d4