// File: /workspace/github_c_makefile_star2_O3/lh3[P]bgt/vcf.c
// Function: bcf_hdr_parse_line2
int bcf_hdr_parse_line2(const char *str, uint32_t *info, int *id_beg, int *id_end)
{
	const char *p, *q;
	int ctype;
	int type = -1; // Type
	int num = -1; // Number
	int var = -1; // A, G, ., or fixed
	int ctg_len = -1;

	if (*str != '#' && str[1] != '#') return -1;
	*id_beg = *id_end = *info = -1;
	p = str + 2;
	for (q = p; *q && *q != '='; ++q); // FIXME: do we need to check spaces?
	if (*q == 0) return -2;
	if (q - p == 4 && strncmp(p, "INFO", 4) == 0) ctype = BCF_HL_INFO;
	else if (q - p == 6 && strncmp(p, "FILTER", 6) == 0) ctype = BCF_HL_FLT;
	else if (q - p == 6 && strncmp(p, "FORMAT", 6) == 0) ctype = BCF_HL_FMT;
	else if (q - p == 6 && strncmp(p, "contig", 6) == 0) ctype = BCF_HL_CTG;
	else return -3;
	for (; *q && *q != '<'; ++q);
	if (*q == 0) return -3;
	p = q + 1; // now p points to the first character following '<'
	while (*p && *p != '>') {
		int which = 0;
		char *tmp;
		const char *val;
		for (q = p; *q && *q != '='; ++q);
		if (*q == 0) break;
		if (q - p == 2 && strncmp(p, "ID", 2) == 0) which = 1; // ID
		else if (q - p == 4 && strncmp(p, "Type", 4) == 0) which = 2; // Number
		else if (q - p == 6 && strncmp(p, "Number", 6) == 0) which = 3; // Type
		else if (q - p == 6 && strncmp(p, "length", 6) == 0) which = 4; // length
		val = q + 1;
		if (*val == '"') { // quoted string
			for (q = val + 1; *q && *q != '"'; ++q)
				if (*q == '\\' && *(q+1) != 0) ++q;
			if (*q != '"') return -4; // open double quotation mark
			p = q + 1;
			if (*p == ',') ++p;
			continue;
		}
		for (q = val; *q && *q != ',' && *q != '>'; ++q); // parse val
		if (which == 1) {
			*id_beg = val - str; *id_end = q - str;
		} else if (which == 2) {
			if (q - val == 7 && strncmp(val, "Integer", 7) == 0) type = BCF_HT_INT;
			else if (q - val == 5 && strncmp(val, "Float", 5) == 0) type = BCF_HT_REAL;
			else if (q - val == 6 && strncmp(val, "String", 6) == 0) type = BCF_HT_STR;
			else if (q - val == 4 && strncmp(val, "Flag", 4) == 0) type = BCF_HT_FLAG;
		} else if (which == 3) {
			if (*val == 'A') var = BCF_VL_A;
			else if (*val == 'G') var = BCF_VL_G;
			else if (*val == 'R') var = BCF_VL_R;
			else if (isdigit(*val)) var = BCF_VL_FIXED, num = strtol(val, &tmp, 10);
			else var = BCF_VL_VAR;
			if (var != BCF_VL_FIXED) num = 0xfffff;
		} else if (which == 4) {
			if (isdigit(*val)) ctg_len = strtol(val, &tmp, 10);
		}
		p = q + 1;
	}
	if (ctype == BCF_HL_CTG) {
		if (ctg_len > 0) return ctg_len;
		else return -5;
	} else {
		if (ctype == BCF_HL_FLT) num = 0;
		if (type == BCF_HT_FLAG) {
			if (num != 0 && hts_verbose >= 2)
				fprintf(stderr, "[W::%s] ignore Number for a Flag\n", __func__);
			num = 0, var = BCF_VL_FIXED; // if Flag VCF type, force to change num to 0
		}
		if (num == 0) type = BCF_HT_FLAG, var = BCF_VL_FIXED; // conversely, if num==0, force the type to Flag
		if (*id_beg < 0 || type < 0 || num < 0 || var < 0) return -5; // missing information
		*info = (uint32_t)num<<12 | var<<8 | type<<4 | ctype;
		//printf("%d, %s, %d, %d, [%d,%d]\n", ctype, bcf_type_name[type], var, num, *id_beg, *id_end);
		return 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %r13
cmpb $0x23, (%rdi)
je 0xad0d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpb $0x23, 0x1(%r13)
jne 0xad7d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%r14)
movl %eax, (%rcx)
movl %eax, (%rdx)
leaq 0x2(%r13), %rbx
leaq 0x3(%r13), %r12
xorl %eax, %eax
movzbl -0x1(%r12), %esi
testl %esi, %esi
je 0xad78
cmpl $0x3d, %esi
je 0xad3a
incq %r12
incq %rax
jmp 0xad23
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
cmpq $0x6, %rax
je 0xad8e
cmpq $0x4, %rax
jne 0xad7d
movq %rcx, 0x48(%rsp)
movq %rdx, %r15
leaq 0x14f1f(%rip), %rsi     # 0x1fc79
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
jne 0xad7d
movl $0x1, 0x24(%rsp)
jmp 0xae03
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, 0x48(%rsp)
movq %rdx, %r15
leaq 0x14493(%rip), %rsi     # 0x1f230
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0xadeb
leaq 0x14a61(%rip), %rsi     # 0x1f816
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0xadfb
leaq 0x1446a(%rip), %rsi     # 0x1f237
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
jne 0xad7d
movl $0x3, 0x24(%rsp)
movb $0x1, %r8b
jmp 0xae06
xorl %r8d, %r8d
movb $0x1, %dil
movl $0x0, 0x24(%rsp)
jmp 0xae08
movl $0x2, 0x24(%rsp)
xorl %r8d, %r8d
xorl %edi, %edi
movb $0x3d, %al
movq %r15, %r10
testb %al, %al
je 0xad7d
movzbl %al, %eax
cmpl $0x3c, %eax
je 0xae26
movb (%r12), %al
incq %r12
jmp 0xae0d
movl %r13d, %eax
negl %eax
movq %rax, 0x58(%rsp)
movl $0x1, %eax
subl %r13d, %eax
movq %rax, 0x50(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x30(%rsp)
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x40(%rsp)
movq %r14, 0x28(%rsp)
movzbl (%r12), %eax
testl %eax, %eax
je 0xb1cb
cmpl $0x3e, %eax
je 0xb1cb
leaq 0x1(%r12), %r14
xorl %ebp, %ebp
movq %r14, %r13
movl %eax, %ecx
testb %cl, %cl
je 0xb1c6
movzbl %cl, %ecx
cmpl $0x3d, %ecx
je 0xaea5
movb (%r13), %cl
incq %r13
incq %r14
incq %rbp
jmp 0xae86
cmpq $0x6, %rbp
movl %r8d, 0x20(%rsp)
movl %edi, 0xc(%rsp)
je 0xaf0b
cmpq $0x4, %rbp
je 0xaed0
cmpq $0x2, %rbp
jne 0xaf01
cmpb $0x49, %al
jne 0xaf01
cmpb $0x44, 0x1(%r12)
jne 0xaf01
movb $0x1, %al
jmp 0xaf03
movl $0x4, %edx
movq %r12, %rdi
leaq 0x1435f(%rip), %rsi     # 0x1f23e
movq %r10, %rbx
movl %r15d, 0x10(%rsp)
callq 0x2090
movl 0xc(%rsp), %edi
movl 0x10(%rsp), %r15d
movq %rbx, %r10
movl 0x20(%rsp), %r8d
testl %eax, %eax
je 0xaf4d
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
jmp 0xaf6c
movl %r15d, 0x10(%rsp)
movq %r10, %rbx
movl $0x6, %edx
movq %r12, %rdi
leaq 0x14321(%rip), %rsi     # 0x1f243
callq 0x2090
testl %eax, %eax
je 0xaf53
movl $0x6, %edx
movq %r12, %rdi
leaq 0x14310(%rip), %rsi     # 0x1f24a
callq 0x2090
testl %eax, %eax
sete %sil
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0xaf5b
movb $0x1, %cl
xorl %eax, %eax
jmp 0xaf05
movb $0x1, %dl
xorl %eax, %eax
xorl %ecx, %ecx
xorl %esi, %esi
movq %rbx, %r10
movl 0x10(%rsp), %r15d
movl 0x20(%rsp), %r8d
movl 0xc(%rsp), %edi
movsbq (%r13), %r9
cmpq $0x22, %r9
jne 0xafa7
incq %r13
movq 0x28(%rsp), %r14
movzbl (%r13), %eax
cmpl $0x5c, %eax
je 0xaf98
testl %eax, %eax
je 0xb1fe
cmpl $0x22, %eax
jne 0xafa2
jmp 0xb007
cmpb $0x0, 0x1(%r13)
je 0xafa2
incq %r13
incq %r13
jmp 0xaf7f
movzbl %r9b, %edi
leaq (%r12,%rbp), %r8
addq $0x2, %r8
xorl %ebx, %ebx
movq %r9, 0x38(%rsp)
cmpb $0x3e, %r9b
ja 0xafd4
movzbl %r9b, %r9d
movabsq $0x4000100000000001, %r11 # imm = 0x4000100000000001
btq %r9, %r11
jb 0xafdd
movb (%r8,%rbx), %r9b
incq %rbx
jmp 0xafba
testb %al, %al
je 0xb01d
addl 0x58(%rsp), %r14d
movl %r14d, (%r10)
movq 0x50(%rsp), %rax
addl %r12d, %eax
leal (%rbx,%rbp), %ecx
addl %eax, %ecx
movq 0x48(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %r14
jmp 0xb1ae
leaq 0x1(%r13), %r12
leaq 0x2(%r13), %rax
cmpb $0x2c, 0x1(%r13)
cmoveq %rax, %r12
jmp 0xae64
testb %cl, %cl
je 0xb068
leaq -0x4(%rbx), %rax
cmpq $0x3, %rax
movq 0x28(%rsp), %r14
movl 0xc(%rsp), %edi
ja 0xb1b2
movq %r10, 0x10(%rsp)
leaq 0x14160(%rip), %rcx     # 0x1f1a4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %edx
movq %r13, %rdi
leaq 0x1420a(%rip), %rsi     # 0x1f266
callq 0x2090
testl %eax, %eax
jmp 0xb13d
testb %dl, %dl
movq 0x28(%rsp), %r14
je 0xb0a3
movl $0xfffff, %eax          # imm = 0xFFFFF
cmpl $0x41, %edi
je 0xb152
movq %rax, 0x30(%rsp)
cmpl $0x52, %edi
je 0xb148
cmpl $0x47, %edi
jne 0xb161
movl $0x3, 0x1c(%rsp)
jmp 0xb1ae
testb %sil, %sil
je 0xb1ae
movl %r15d, 0x10(%rsp)
movq %r10, %r15
callq 0x2460
movq (%rax), %rax
movq 0x38(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xb1a6
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
movl $0xa, %edx
callq 0x2270
movq %rax, 0x40(%rsp)
jmp 0xb1a6
movl $0x6, %edx
movq %r13, %rdi
leaq 0x14168(%rip), %rsi     # 0x1f25f
callq 0x2090
testl %eax, %eax
movl $0x3, %eax
jmp 0xb13d
movl $0x7, %edx
movq %r13, %rdi
leaq 0x1413d(%rip), %rsi     # 0x1f251
callq 0x2090
testl %eax, %eax
movl $0x1, %eax
jmp 0xb13d
movl $0x5, %edx
movq %r13, %rdi
leaq 0x14128(%rip), %rsi     # 0x1f259
callq 0x2090
testl %eax, %eax
movl $0x2, %eax
cmovel %eax, %r15d
movq 0x10(%rsp), %r10
jmp 0xb1ae
movl $0x4, 0x1c(%rsp)
jmp 0xb1ae
movq %rax, 0x30(%rsp)
movl $0x2, 0x1c(%rsp)
jmp 0xb1ae
movl %r15d, 0x10(%rsp)
movq %r10, %r15
callq 0x2460
movq (%rax), %rax
movq 0x38(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0xb187
movl $0x1, 0x1c(%rsp)
jmp 0xb1a6
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
movl $0xa, %edx
callq 0x2270
movq %rax, 0x30(%rsp)
movl $0x0, 0x1c(%rsp)
movq %r15, %r10
movl 0x10(%rsp), %r15d
movl 0xc(%rsp), %edi
addq %rbp, %r12
addq %rbx, %r12
addq $0x2, %r12
movl 0x20(%rsp), %r8d
jmp 0xae64
movq 0x28(%rsp), %r14
testb %r8b, %r8b
je 0xb1e4
movq 0x40(%rsp), %rax
testl %eax, %eax
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
cmovgl %eax, %ebp
jmp 0xad7d
xorl %ebx, %ebx
testb %dil, %dil
movq 0x30(%rsp), %rax
cmovnel %ebx, %eax
testl %r15d, %r15d
je 0xb208
movl %eax, %ebx
movl 0x1c(%rsp), %ecx
jmp 0xb21a
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
jmp 0xad7d
testl %eax, %eax
je 0xb218
leaq 0x1b03d(%rip), %rax     # 0x26250
cmpl $0x2, (%rax)
jge 0xb262
xorl %ecx, %ecx
testl %ebx, %ebx
cmovel %ebx, %r15d
cmovel %ebx, %ecx
cmpl $0x0, (%r10)
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
js 0xad7d
movl %r15d, %eax
orl %ebx, %eax
js 0xad7d
testl %ecx, %ecx
js 0xad7d
shll $0xc, %ebx
addl 0x24(%rsp), %ebx
shll $0x8, %ecx
orl %ebx, %ecx
shll $0x4, %r15d
orl %ecx, %r15d
movl %r15d, (%r14)
xorl %ebp, %ebp
jmp 0xad7d
movl %r15d, %r12d
movq %r10, %r15
callq 0x2b5f
movq %r15, %r10
movl %r12d, %r15d
jmp 0xb218