// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/vcf.c
// Function: vcf_hdr_read
bcf_hdr_t *vcf_hdr_read(htsFile *fp)
{
	if (!fp->is_bin) {
		kstring_t txt, *s = &fp->line;
		bcf_hdr_t *h;
		h = bcf_hdr_init();
		txt.l = txt.m = 0; txt.s = 0;
		while (hts_getline(fp, KS_SEP_LINE, s) >= 0) {
			if (s->l == 0) continue;
			if (s->s[0] != '#') {
				if (hts_verbose >= 2)
					fprintf(stderr, "[E::%s] no sample line\n", __func__);
				free(txt.s);
				bcf_hdr_destroy(h);
				return 0;
			}
			if (s->s[1] != '#' && fp->fn_aux) { // insert contigs here
				int dret;
				gzFile f;
				kstream_t *ks;
				kstring_t tmp;
				tmp.l = tmp.m = 0; tmp.s = 0;
				f = gzopen(fp->fn_aux, "r");
				ks = ks_init(f);
				while (ks_getuntil(ks, 0, &tmp, &dret) >= 0) {
					int c;
					kputs("##contig=<ID=", &txt); kputs(tmp.s, &txt);
					ks_getuntil(ks, 0, &tmp, &dret);
					kputs(",length=", &txt); kputw(atol(tmp.s), &txt);
					kputsn(">\n", 2, &txt);
					if (dret != '\n')
						while ((c = ks_getc(ks)) != '\n' && c != -1); // skip the rest of the line
				}
				free(tmp.s);
				ks_destroy(ks);
				gzclose(f);
			}
			kputsn(s->s, s->l, &txt);
			if (s->s[1] != '#') break;
			kputc('\n', &txt);
		}
		h->l_text = txt.l + 1; // including NULL
		h->m_text = txt.m;
		h->text = txt.s;
		bcf_hdr_parse(h);
		return h;
	} else return bcf_hdr_read((BGZF*)fp->fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
testb $0x1, (%rdi)
jne 0xaa7e
leaq 0x10(%r14), %r15
callq 0xa4b6
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %r12
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
pushq $0x2
popq %rbp
leaq 0x10(%rsp), %rbx
leaq 0x4(%rsp), %r13
movq %r15, 0x30(%rsp)
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x6081
testl %eax, %eax
js 0xaa95
movq (%r15), %rsi
testq %rsi, %rsi
je 0xa8de
movq 0x20(%r14), %rdi
cmpb $0x23, (%rdi)
jne 0xaabc
cmpb $0x23, 0x1(%rdi)
je 0xaa5c
movq 0x30(%r14), %rax
testq %rax, %rax
je 0xaa5c
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %rax, %rdi
leaq 0xe8c1(%rip), %rsi      # 0x191f8
callq 0x2380
movq %rax, 0x38(%rsp)
movq %rax, %rdi
callq 0x5584
movq %rax, %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xab11
testl %eax, %eax
js 0xaa33
leaq 0xe9e4(%rip), %rdi      # 0x1934d
movq %r12, %rsi
callq 0xab21
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xab21
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xab11
leaq 0xe9c8(%rip), %rdi      # 0x1935b
movq %r12, %rsi
callq 0xab21
movq 0x20(%rsp), %rdi
callq 0x2390
movl %eax, %edi
movq %r12, %rsi
callq 0xab44
leaq 0xefd4(%rip), %rdi      # 0x1998a
movl %ebp, %esi
movq %r12, %rdx
callq 0xac22
cmpl $0xa, 0x4(%rsp)
je 0xa94c
movl 0x8(%r15), %edx
movl (%r15), %ecx
movl 0x4(%r15), %eax
testb $0x3, %dl
je 0xa9df
cmpl %eax, %ecx
jge 0xa94c
movq 0x18(%r15), %rsi
cmpl %eax, %ecx
jl 0xaa20
andl $0x0, (%r15)
movq 0x10(%r15), %rdi
sarl $0x2, %edx
callq 0x2240
movl %eax, 0x4(%r15)
movl 0x8(%r15), %edx
movl %edx, %ecx
sarl $0x2, %ecx
cmpl %ecx, %eax
jge 0xaa11
andl $-0x4, %edx
incl %edx
movl %edx, 0x8(%r15)
testl %eax, %eax
je 0xa94c
movl (%r15), %ecx
movq 0x18(%r15), %rsi
movslq %ecx, %rdi
incl %ecx
movl %ecx, (%r15)
cmpb $0xa, (%rsi,%rdi)
jne 0xa9d2
jmp 0xa94c
movq 0x20(%rsp), %rdi
callq 0x2050
movq %r15, %rdi
callq 0x55bd
movq 0x38(%rsp), %rdi
callq 0x2040
movq 0x10(%r14), %rsi
movq 0x20(%r14), %rdi
movq 0x30(%rsp), %r15
movq %r12, %rdx
callq 0xac22
movq 0x20(%r14), %rax
cmpb $0x23, 0x1(%rax)
jne 0xaa95
pushq $0xa
popq %rdi
movq %r12, %rsi
callq 0xacb6
jmp 0xa8de
movq 0x38(%r14), %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa5ac
movl 0x40(%rsp), %eax
incl %eax
movq 0x8(%rsp), %rbx
movl %eax, (%rbx)
movl 0x48(%rsp), %eax
movl %eax, 0x4(%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x48(%rbx)
movq %rbx, %rdi
callq 0xa30d
jmp 0xaade
leaq 0x1678d(%rip), %rax     # 0x21250
cmpl $0x2, (%rax)
jge 0xaaf0
movq 0x50(%rsp), %rdi
callq 0x2050
movq 0x8(%rsp), %rdi
callq 0xa500
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x16501(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0xe827(%rip), %rsi      # 0x19328
leaq 0xe838(%rip), %rdx      # 0x19340
xorl %eax, %eax
callq 0x2250
jmp 0xaac8