// File: /workspace/github_c_makefile_star2_O0/lh3[P]bgt/bgt.c
// Function: bgt_al_parse
int bgt_al_parse(const char *al, bgt_allele_t *a) // TODO: add bgt_al_atomize()
{
	char *p = (char*)al, *ref = 0, *alt = 0;
	int sep = ':', off, tmp, i;
	a->chr.l = 0; a->al = 0; a->pos = -1; a->rlen = -1; a->rid = -1;
	for (; *p && *p != sep; ++p);
	if (*p == 0) return -1;
	kputsn(al, p - al, &a->chr); kputc(0, &a->chr);
	++p; // skip the delimiter
	if (!isdigit(*p)) return -1;
	a->pos = strtol(p, &p, 10) - 1; // read position
	if (*p != sep) return -1;
	++p; // skip the delimiter
	if (isdigit(*p)) {
		a->rlen = strtol(p, &p, 10);
	} else if (isalpha(*p)) {
		ref = p;
		for (; isalpha(*p); ++p);
		a->rlen = p - ref;
	} else if (*p == sep) { // a reference allele
		a->rlen = -1;
	}
	if (*p != sep) return -1;
	alt = ++p;
	if (a->rlen < 0) {
		for (i = 0; isalpha(alt[i]); ++i);
		a->rlen = i;
	}
	for (off = 0; *p && isalpha(*p); ++p)
		if (ref && toupper(*p) == toupper(ref[off])) ++off;
		else break;
	a->pos += off; a->rlen -= off;
	tmp = a->chr.l;
	kputs(alt + off, &a->chr);
	a->al = a->chr.s + tmp;
	if (ref) {
		int l_alt = a->chr.s + a->chr.l - a->al;
		int min_l = l_alt < a->rlen? l_alt : a->rlen;
		ref += off;
		for (off = 0; off < min_l && isalpha(ref[a->rlen - 1 - off]) && toupper(ref[a->rlen - 1 - off]) == toupper(a->al[l_alt - 1 - off]); ++off);
		a->rlen -= off;
		a->al[l_alt - off] = 0;
		a->chr.l -= off;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x3a, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x24(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x49(%rbp)
je 0x1e868
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x34(%rbp), %eax
setne %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x1e871
jmp 0x1e881
jmp 0x1e873
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1e847
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1e899
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eca8
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
movq -0x18(%rbp), %rdx
callq 0x1d010
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0x1d1a0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
callq 0x2480
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x1e8f6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eca8
movq -0x20(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0xa, %edx
callq 0x2280
subq $0x1, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x34(%rbp), %eax
je 0x1e92d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eca8
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
callq 0x2480
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1e979
movq -0x20(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0xa, %edx
callq 0x2280
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0x1ea02
callq 0x2480
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x1e9e7
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x2480
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x1e9d1
jmp 0x1e9c3
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1e9a1
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
jmp 0x1ea00
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x34(%rbp), %eax
jne 0x1e9fe
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
jmp 0x1ea00
jmp 0x1ea02
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x34(%rbp), %eax
je 0x1ea1a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eca8
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jge 0x1ea77
movl $0x0, -0x40(%rbp)
callq 0x2480
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x1ea6d
jmp 0x1ea62
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1ea3b
movl -0x40(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x28(%rax)
movl $0x0, -0x38(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a(%rbp)
je 0x1eab3
callq 0x2480
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0x1eabc
jmp 0x1eb0c
cmpq $0x0, -0x28(%rbp)
je 0x1eaf7
movq -0x20(%rbp), %rax
movsbl (%rax), %edi
callq 0x20d0
movl %eax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x20d0
movl %eax, %ecx
movl -0x50(%rbp), %eax
cmpl %ecx, %eax
jne 0x1eaf7
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1eaf9
jmp 0x1eb0c
jmp 0x1eafb
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1ea7e
movl -0x38(%rbp), %ecx
movq -0x18(%rbp), %rax
addl 0x24(%rax), %ecx
movl %ecx, 0x24(%rax)
movl -0x38(%rbp), %edx
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x38(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x1d160
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x3c(%rbp), %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x1eca1
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
addq (%rcx), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x1eb99
movl -0x44(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x1eba3
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x38(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %ecx
xorl %eax, %eax
cmpl -0x48(%rbp), %ecx
movb %al, -0x55(%rbp)
jge 0x1ec53
callq 0x2480
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rdx
movl 0x28(%rdx), %edx
subl $0x1, %edx
subl -0x38(%rbp), %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x400, %ecx            # imm = 0x400
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x55(%rbp)
je 0x1ec53
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x28(%rcx), %ecx
subl $0x1, %ecx
subl -0x38(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0x20d0
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x44(%rbp), %ecx
subl $0x1, %ecx
subl -0x38(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0x20d0
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x1ec5c
jmp 0x1ec6c
jmp 0x1ec5e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1ebc1
movl -0x38(%rbp), %edx
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x44(%rbp), %ecx
subl -0x38(%rbp), %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movslq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)