// File: /workspace/github_c_makefile_star2_O1/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
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpb $0x23, (%rsi)
jne 0xb3a1
movq %rsi, %rbx
movq %rdi, %r15
cmpb $0x23, 0x1(%rsi)
jne 0xb203
leaq 0x4(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movq %rbx, %rdi
callq 0xaa58
testl %eax, %eax
js 0xb3a1
movl %eax, %ebp
movslq 0xc(%rsp), %r12
movslq 0x10(%rsp), %r13
subq %r13, %r12
leaq 0x1(%r12), %rdi
callq 0x22e0
movq %rax, %r14
addq %r13, %rbx
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2080
movb $0x0, (%r14,%r12)
testl %ebp, %ebp
je 0xb2ff
movq 0x38(%r15), %rbx
leaq 0x14(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xb3b3
cmpl $0x0, (%r15)
je 0xb350
movq 0x20(%rbx), %rcx
movl %eax, %eax
shlq $0x4, %rax
movups 0x14026(%rip), %xmm0    # 0x1f210
movups %xmm0, (%rcx,%rax)
movl 0x4(%rbx), %ecx
decl %ecx
movq 0x20(%rbx), %rdx
movl %ecx, 0xc(%rdx,%rax)
movl %ebp, (%rdx,%rax)
jmp 0xb39e
movq 0x40(%r15), %r15
leaq 0x1(%rbx), %r13
movq %rbx, %r12
xorl %r14d, %r14d
movzbl -0x1(%r13), %eax
cmpl $0x9, %eax
je 0xb223
testl %eax, %eax
jne 0xb2a4
cmpl $0x9, %r14d
jl 0xb2b9
movl %r14d, 0x8(%rsp)
movq %r15, %r14
movq %r12, %r15
subq %rbx, %r15
leaq 0x1(%r15), %rdi
callq 0x22e0
movq %rax, %rbp
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %r15
callq 0x2080
movq %rbp, %rax
subq %rbx, %rax
movb $0x0, (%rax,%r12)
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x4(%rsp), %rdx
callq 0xb3b3
cmpl $0x0, 0x4(%rsp)
je 0xb2a8
movq 0x20(%r15), %rcx
movl %eax, %eax
shlq $0x4, %rax
movups 0x13f85(%rip), %xmm0    # 0x1f210
movups %xmm0, (%rcx,%rax)
movl 0x4(%r15), %ecx
decl %ecx
movq 0x20(%r15), %rdx
movl %ecx, 0xc(%rdx,%rax)
movl 0x8(%rsp), %r14d
jmp 0xb2b9
xorl %eax, %eax
jmp 0xb2c8
leaq 0x1afa1(%rip), %rax     # 0x26250
cmpl $0x2, (%rax)
movl 0x8(%rsp), %r14d
jge 0xb2db
incl %r14d
cmpb $0x0, -0x1(%r13)
sete %al
cmovneq %r13, %rbx
incq %r13
incq %r12
testb %al, %al
je 0xb211
jmp 0xb39e
movq 0x1ad16(%rip), %rax     # 0x25ff8
movq (%rax), %rdi
leaq 0x13fe6(%rip), %rsi     # 0x1f2d2
leaq 0x13fd0(%rip), %rdx     # 0x1f2c3
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2250
jmp 0xb2b9
movq 0x30(%r15), %rbx
leaq 0x14(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xb3b3
cmpl $0x0, (%r15)
je 0xb380
movq 0x20(%rbx), %rcx
movl %eax, %eax
shlq $0x4, %rax
movups 0x13ee3(%rip), %xmm0    # 0x1f210
movups %xmm0, (%rcx,%rax)
movl 0x4(%rsp), %ecx
movq 0x20(%rbx), %rdx
leaq (%rdx,%rax), %rsi
movl %ecx, %edi
andl $0xf, %edi
movl %ecx, (%rsi,%rdi,4)
movl 0x4(%rbx), %ecx
decl %ecx
movl %ecx, 0xc(%rdx,%rax)
jmp 0xb39e
leaq 0x1aef9(%rip), %rax     # 0x26250
cmpl $0x2, (%rax)
jl 0xb396
movq 0x1ac95(%rip), %rax     # 0x25ff8
movq (%rax), %rdi
leaq 0x13f27(%rip), %rsi     # 0x1f294
leaq 0x13f4f(%rip), %rdx     # 0x1f2c3
movq %r14, %rcx
xorl %eax, %eax
callq 0x2250
jmp 0xb396
movl %eax, %eax
shlq $0x4, %rax
addq 0x20(%rbx), %rax
movl 0x4(%rsp), %ecx
movl %ecx, %edx
andl $0xf, %edx
movl %ecx, (%rax,%rdx,4)
movq %r14, %rdi
callq 0x2050
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq