// File: /workspace/github_c_makefile_star2_O2/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 0x98c4
cmpb $0x23, 0x1(%r13)
jne 0x9927
orl $-0x1, (%r14)
orl $-0x1, (%rcx)
orl $-0x1, (%rdx)
leaq 0x2(%r13), %rbx
leaq 0x3(%r13), %r12
xorl %eax, %eax
movzbl -0x1(%r12), %esi
testl %esi, %esi
je 0x9923
cmpl $0x3d, %esi
je 0x98ef
incq %r12
incq %rax
jmp 0x98d8
pushq $-0x3
popq %rbp
cmpq $0x6, %rax
je 0x993b
cmpq $0x4, %rax
jne 0x992a
movq %rcx, 0x48(%rsp)
movq %rdx, %r15
leaq 0x1031c(%rip), %rsi     # 0x19c29
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
jne 0x992a
pushq $0x1
jmp 0x99a3
pushq $-0x2
jmp 0x9929
pushq $-0x1
popq %rbp
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 0xf896(%rip), %rsi      # 0x191e0
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x9991
leaq 0xfe66(%rip), %rsi      # 0x197c6
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x99a1
leaq 0xf871(%rip), %rsi      # 0x191e7
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
jne 0x992a
pushq $0x3
popq %rax
movl %eax, 0x24(%rsp)
movb $0x1, %r8b
jmp 0x99ab
xorl %r8d, %r8d
movb $0x1, %dil
movl $0x0, 0x24(%rsp)
jmp 0x99ad
pushq $0x2
popq %rax
movl %eax, 0x24(%rsp)
xorl %r8d, %r8d
xorl %edi, %edi
movb $0x3d, %al
movq %r15, %r10
testb %al, %al
je 0x992a
movzbl %al, %eax
cmpl $0x3c, %eax
je 0x99cb
movb (%r12), %al
incq %r12
jmp 0x99b2
movl %r13d, %eax
negl %eax
movq %rax, 0x58(%rsp)
pushq $0x1
popq %rax
subl %r13d, %eax
movq %rax, 0x50(%rsp)
pushq $-0x1
popq %r15
pushq $0x6
popq %rdx
movl %r15d, %eax
movq %rax, 0x28(%rsp)
movl %r15d, 0x1c(%rsp)
movq %rax, 0x40(%rsp)
movq %r14, 0x30(%rsp)
movzbl (%r12), %eax
testl %eax, %eax
je 0x9d5d
cmpl $0x3e, %eax
je 0x9d5d
leaq 0x1(%r12), %r14
xorl %r13d, %r13d
movq %r14, %rbp
movl %eax, %ecx
testb %cl, %cl
je 0x9d58
movzbl %cl, %ecx
cmpl $0x3d, %ecx
je 0x9a3f
movb (%rbp), %cl
incq %rbp
incq %r14
incq %r13
jmp 0x9a21
cmpq $0x6, %r13
movl %r8d, 0x20(%rsp)
movl %edi, 0xc(%rsp)
je 0x9aa3
cmpq $0x4, %r13
je 0x9a6a
cmpq $0x2, %r13
jne 0x9a99
cmpb $0x49, %al
jne 0x9a99
cmpb $0x44, 0x1(%r12)
jne 0x9a99
movb $0x1, %al
jmp 0x9a9b
movq %r12, %rdi
leaq 0xf77a(%rip), %rsi      # 0x191ee
pushq $0x4
popq %rdx
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 0x9ae1
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
jmp 0x9b00
movl %r15d, 0x10(%rsp)
movq %r10, %rbx
movq %r12, %rdi
leaq 0xf73e(%rip), %rsi      # 0x191f3
movq %rdx, %r15
callq 0x2090
testl %eax, %eax
je 0x9ae7
movq %r12, %rdi
leaq 0xf72f(%rip), %rsi      # 0x191fa
movq %r15, %rdx
callq 0x2090
testl %eax, %eax
sete %sil
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x9aef
movb $0x1, %cl
xorl %eax, %eax
jmp 0x9a9d
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 (%rbp), %r9
cmpq $0x22, %r9
jne 0x9b3c
incq %rbp
movq 0x30(%rsp), %r14
pushq $0x6
popq %rdx
movzbl (%rbp), %eax
cmpl $0x5c, %eax
je 0x9b2e
testl %eax, %eax
je 0x9d8e
cmpl $0x22, %eax
jne 0x9b37
jmp 0x9b9d
cmpb $0x0, 0x1(%rbp)
je 0x9b37
incq %rbp
incq %rbp
jmp 0x9b16
movzbl %r9b, %edi
leaq (%r12,%r13), %r8
addq $0x2, %r8
xorl %ebx, %ebx
movq %r9, 0x38(%rsp)
cmpb $0x3e, %r9b
ja 0x9b69
movzbl %r9b, %r9d
movabsq $0x4000100000000001, %r11 # imm = 0x4000100000000001
btq %r9, %r11
jb 0x9b72
movb (%r8,%rbx), %r9b
incq %rbx
jmp 0x9b4f
testb %al, %al
je 0x9bb2
addl 0x58(%rsp), %r14d
movl %r14d, (%r10)
movq 0x50(%rsp), %rax
addl %r12d, %eax
leal (%rbx,%r13), %ecx
addl %eax, %ecx
movq 0x48(%rsp), %rax
movl %ecx, (%rax)
movq 0x30(%rsp), %r14
jmp 0x9d3d
leaq 0x1(%rbp), %r12
leaq 0x2(%rbp), %rax
cmpb $0x2c, 0x1(%rbp)
cmoveq %rax, %r12
jmp 0x99fe
testb %cl, %cl
je 0x9bfb
leaq -0x4(%rbx), %rax
cmpq $0x3, %rax
movq 0x30(%rsp), %r14
movl 0xc(%rsp), %edi
ja 0x9d41
movq %r10, 0x10(%rsp)
leaq 0xf57b(%rip), %rcx      # 0x19154
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbp, %rdi
leaq 0xf62a(%rip), %rsi      # 0x19216
pushq $0x4
popq %rdx
callq 0x2090
testl %eax, %eax
jmp 0x9ccd
testb %dl, %dl
movq 0x30(%rsp), %r14
je 0x9c33
cmpl $0x41, %edi
pushq $0x6
popq %rdx
movl $0xfffff, %eax          # imm = 0xFFFFF
je 0x9ce1
cmpl $0x52, %edi
je 0x9cd8
movq %rax, 0x28(%rsp)
cmpl $0x47, %edi
jne 0x9cf3
pushq $0x3
jmp 0x9ce8
testb %sil, %sil
je 0x9d3d
movl %r15d, 0x10(%rsp)
movq %r10, %r15
callq 0x2470
movq (%rax), %rax
movq 0x38(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x9d35
movq %rbp, %rdi
leaq 0x60(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x2270
movq %rax, 0x40(%rsp)
jmp 0x9d35
movq %rbp, %rdi
leaq 0xf58f(%rip), %rsi      # 0x1920f
pushq $0x6
popq %rbp
movq %rbp, %rdx
callq 0x2090
movq %rbp, %rdx
testl %eax, %eax
pushq $0x3
popq %rax
cmovel %eax, %r15d
movq 0x10(%rsp), %r10
jmp 0x9ced
movq %rbp, %rdi
leaq 0xf559(%rip), %rsi      # 0x19201
pushq $0x7
popq %rdx
callq 0x2090
testl %eax, %eax
pushq $0x1
jmp 0x9ccc
movq %rbp, %rdi
leaq 0xf549(%rip), %rsi      # 0x19209
pushq $0x5
popq %rdx
callq 0x2090
testl %eax, %eax
pushq $0x2
popq %rax
cmovel %eax, %r15d
movq 0x10(%rsp), %r10
jmp 0x9d3d
movq %rax, 0x28(%rsp)
pushq $0x4
jmp 0x9ce8
movq %rax, 0x28(%rsp)
pushq $0x2
popq %rax
movl %eax, 0x1c(%rsp)
movl 0xc(%rsp), %edi
jmp 0x9d44
movl %r15d, 0x10(%rsp)
movq %r10, %r15
callq 0x2470
movq (%rax), %rax
movq 0x38(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x9d18
pushq $0x1
popq %rax
movl %eax, 0x1c(%rsp)
jmp 0x9d35
movq %rbp, %rdi
leaq 0x60(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x2270
movq %rax, 0x28(%rsp)
movl $0x0, 0x1c(%rsp)
movq %r15, %r10
movl 0x10(%rsp), %r15d
movl 0xc(%rsp), %edi
pushq $0x6
popq %rdx
addq %r13, %r12
addq %rbx, %r12
addq $0x2, %r12
movl 0x20(%rsp), %r8d
jmp 0x99fe
movq 0x30(%rsp), %r14
testb %r8b, %r8b
je 0x9d74
movq 0x40(%rsp), %rax
testl %eax, %eax
pushq $-0x5
popq %rbp
cmovgl %eax, %ebp
jmp 0x992a
xorl %ebx, %ebx
testb %dil, %dil
movq 0x28(%rsp), %rax
cmovnel %ebx, %eax
testl %r15d, %r15d
je 0x9d95
movl %eax, %ebx
movl 0x1c(%rsp), %ecx
jmp 0x9dd9
pushq $-0x4
jmp 0x9929
testl %eax, %eax
je 0x9dd7
leaq 0x174b0(%rip), %rax     # 0x21250
cmpl $0x2, (%rax)
movl $0x0, %ecx
jl 0x9dd9
movq 0x17247(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0xf460(%rip), %rsi      # 0x1921b
leaq 0xf47b(%rip), %rdx      # 0x1923d
xorl %ebx, %ebx
xorl %eax, %eax
movl %r15d, %r12d
movq %r10, %r15
callq 0x2250
movq %r15, %r10
movl %r12d, %r15d
xorl %ecx, %ecx
testl %ebx, %ebx
cmovel %ebx, %r15d
cmovel %ebx, %ecx
cmpl $0x0, (%r10)
pushq $-0x5
popq %rbp
js 0x992a
movl %r15d, %eax
orl %ebx, %eax
js 0x992a
testl %ecx, %ecx
js 0x992a
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 0x992a