// File: /workspace/github_c_makefile_star2_O2/lh3[P]bgt/vcf.c
// Function: bcf_hdr_parse1
int bcf_hdr_parse1(bcf_hdr_t *h, const char *str)
{
	khint_t k;
	if (*str != '#') return -1;
	if (str[1] == '#') {
		uint32_t info;
		int len, ret, id_beg, id_end;
		char *s;

		len = bcf_hdr_parse_line2(str, &info, &id_beg, &id_end);
		if (len < 0) return -1;
		s = (char*)malloc(id_end - id_beg + 1);
		strncpy(s, str + id_beg, id_end - id_beg);
		s[id_end - id_beg] = 0;
		if (len > 0) { // a contig line
			vdict_t *d = (vdict_t*)h->dict[BCF_DT_CTG];
			k = kh_put(vdict, d, s, &ret);
			if (ret == 0) {
				if (hts_verbose >= 2)
					fprintf(stderr, "[W::%s] Duplicated contig name '%s'. Skipped.\n", __func__, s);
				free(s);
			} else {
				kh_val(d, k) = bcf_idinfo_def;
				kh_val(d, k).id = kh_size(d) - 1;
				kh_val(d, k).info[0] = len;
			}
		} else { // a FILTER/INFO/FORMAT line
			vdict_t *d = (vdict_t*)h->dict[BCF_DT_ID];
			k = kh_put(vdict, d, s, &ret);
			if (ret) { // absent from the dict
				kh_val(d, k) = bcf_idinfo_def;
				kh_val(d, k).info[info&0xf] = info;
				kh_val(d, k).id = kh_size(d) - 1;
			} else {
				kh_val(d, k).info[info&0xf] = info;
				free(s);
			}
		}
	} else {
		int i = 0;
		const char *p, *q;
		vdict_t *d = (vdict_t*)h->dict[BCF_DT_ID];
		// add samples
		d = (vdict_t*)h->dict[BCF_DT_SAMPLE];
		for (p = q = str;; ++q) {
			int ret;
			if (*q != '\t' && *q != 0) continue;
			if (++i > 9) {
				char *s;
				s = (char*)malloc(q - p + 1);
				strncpy(s, p, q - p);
				s[q - p] = 0;
				k = kh_put(vdict, d, s, &ret);
				if (ret) { // absent
					kh_val(d, k) = bcf_idinfo_def;
					kh_val(d, k).id = kh_size(d) - 1;
				} else {
					if (hts_verbose >= 2)
						fprintf(stderr, "[W::%s] Duplicated sample name '%s'. Skipped.\n", __func__, s);
				}
			}
			if (*q == 0) break;
			p = q + 1;
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $-0x1
popq %rbx
cmpb $0x23, (%rsi)
jne 0xa080
movq %rsi, %r8
movq %rdi, %r15
cmpb $0x23, 0x1(%rsi)
jne 0x9ef1
leaq 0x4(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movq %r8, %rdi
movq %r8, %r14
callq 0x98a4
testl %eax, %eax
js 0xa080
movl %eax, %ebp
movslq 0xc(%rsp), %r12
movslq 0x10(%rsp), %r13
subq %r13, %r12
leaq 0x1(%r12), %rdi
callq 0x22e0
movq %rax, %rbx
addq %r13, %r14
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2080
movb $0x0, (%rbx,%r12)
testl %ebp, %ebp
je 0x9fde
movq 0x38(%r15), %r14
leaq 0x14(%rsp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa091
cmpl $0x0, (%r15)
je 0xa030
movq 0x20(%r14), %rcx
movl %eax, %eax
shlq $0x4, %rax
movups 0xf2f9(%rip), %xmm0     # 0x191d0
movups %xmm0, (%rcx,%rax)
movl 0x4(%r14), %ecx
decl %ecx
movq 0x20(%r14), %rdx
movl %ecx, 0xc(%rdx,%rax)
movl %ebp, (%rdx,%rax)
jmp 0xa07e
movq 0x40(%r15), %r14
leaq 0x1(%r8), %r15
movb $0x23, %al
movq %r8, %r13
xorl %ebx, %ebx
testb %al, %al
je 0x9f10
movzbl %al, %eax
cmpl $0x9, %eax
jne 0x9fac
cmpl $0x9, %ebx
jl 0x9f9c
movl %ebx, 0x8(%rsp)
movq %r13, %r12
subq %r8, %r12
leaq 0x1(%r12), %rdi
movq %r8, %rbx
callq 0x22e0
movq %rax, %rbp
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2080
movq %rbp, %rax
subq %rbx, %rax
movb $0x0, (%rax,%r13)
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x4(%rsp), %rdx
callq 0xa091
cmpl $0x0, 0x4(%rsp)
je 0x9f8c
movq 0x20(%r14), %rcx
movl %eax, %eax
shlq $0x4, %rax
movups 0xf25c(%rip), %xmm0     # 0x191d0
movups %xmm0, (%rcx,%rax)
movl 0x4(%r14), %ecx
decl %ecx
movq 0x20(%r14), %rdx
movl %ecx, 0xc(%rdx,%rax)
movl 0x8(%rsp), %ebx
jmp 0x9f9c
leaq 0x172bd(%rip), %rax     # 0x21250
cmpl $0x2, (%rax)
movl 0x8(%rsp), %ebx
jge 0x9fba
cmpb $0x0, -0x1(%r15)
je 0xa07e
incl %ebx
movq %r15, %r8
movb (%r15), %al
incq %r15
incq %r13
jmp 0x9f00
movq 0x17037(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0xf2c4(%rip), %rsi      # 0x1928f
leaq 0xf2ae(%rip), %rdx      # 0x19280
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2250
jmp 0x9f9c
movq 0x30(%r15), %r14
leaq 0x14(%rsp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xa091
cmpl $0x0, (%r15)
je 0xa060
movq 0x20(%r14), %rcx
movl %eax, %eax
shlq $0x4, %rax
movups 0xf1c4(%rip), %xmm0     # 0x191d0
movups %xmm0, (%rcx,%rax)
movl 0x4(%rsp), %ecx
movq 0x20(%r14), %rdx
leaq (%rdx,%rax), %rsi
movl %ecx, %edi
andl $0xf, %edi
movl %ecx, (%rsi,%rdi,4)
movl 0x4(%r14), %ecx
decl %ecx
movl %ecx, 0xc(%rdx,%rax)
jmp 0xa07e
leaq 0x17219(%rip), %rax     # 0x21250
cmpl $0x2, (%rax)
jl 0xa076
movq 0x16fb5(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0xf204(%rip), %rsi      # 0x19251
leaq 0xf22c(%rip), %rdx      # 0x19280
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2250
jmp 0xa076
movl %eax, %eax
shlq $0x4, %rax
addq 0x20(%r14), %rax
movl 0x4(%rsp), %ecx
movl %ecx, %edx
andl $0xf, %edx
movl %ecx, (%rax,%rdx,4)
movq %rbx, %rdi
callq 0x2050
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq