// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gfa-io.c
// Function: gfa_parse_L
int gfa_parse_L(gfa_t *g, char *s)
{
	int i, oriv = -1, oriw = -1, is_ok = 0;
	char *p, *q, *segv = 0, *segw = 0, *rest = 0;
	int32_t ov = INT32_MAX, ow = INT32_MAX;
	for (i = 0, p = q = s + 2;; ++p) {
		if (*p == 0 || *p == '\t') {
			int c = *p;
			*p = 0;
			if (i == 0) {
				segv = q;
			} else if (i == 1) {
				if (*q != '+' && *q != '-') return -2;
				oriv = (*q != '+');
			} else if (i == 2) {
				segw = q;
			} else if (i == 3) {
				if (*q != '+' && *q != '-') return -2;
				oriw = (*q != '+');
			} else if (i == 4) {
				if (*q == '*') {
					ov = ow = 0;
				} else if (*q == ':') {
					ov = INT32_MAX;
					ow = isdigit(*(q+1))? strtol(q+1, &q, 10) : INT32_MAX;
				} else if (isdigit(*q)) {
					char *r;
					ov = strtol(q, &r, 10);
					if (isupper(*r)) { // CIGAR
						ov = ow = 0;
						do {
							long l;
							l = strtol(q, &q, 10);
							if (*q == 'M' || *q == 'D' || *q == 'N') ov += l;
							if (*q == 'M' || *q == 'I' || *q == 'S') ow += l;
							++q;
						} while (isdigit(*q));
					} else if (*r == ':') { // overlap lengths
						ow = isdigit(*(r+1))? strtol(r+1, &r, 10) : INT32_MAX;
					} else break;
				} else break;
				is_ok = 1, rest = c? p + 1 : 0;
				break;
			}
			++i, q = p + 1;
			if (c == 0) break;
		}
	}
	if (i == 4 && is_ok == 0) ov = ow = 0, is_ok = 1; // no overlap field
	if (is_ok) {
		uint32_t v, w;
		int l_aux, m_aux = 0;
		uint8_t *aux = 0;
		gfa_arc_t *arc;
		v = gfa_add_seg(g, segv) << 1 | oriv;
		w = gfa_add_seg(g, segw) << 1 | oriw;
		arc = gfa_add_arc1(g, v, w, ov, ow, -1, 0);
		l_aux = gfa_aux_parse(rest, &aux, &m_aux); // parse optional tags
		if (l_aux) {
			gfa_aux_t *a = &g->link_aux[arc->link_id];
			uint8_t *s_L1, *s_L2, *s_SR;
			a->l_aux = l_aux, a->m_aux = m_aux, a->aux = aux;
			s_SR = gfa_aux_get(a->l_aux, a->aux, "SR");
			if (s_SR && s_SR[0] == 'i') {
				arc->rank = *(int32_t*)(s_SR+1);
				a->l_aux = gfa_aux_del(a->l_aux, a->aux, s_SR);
			}
			s_L1 = gfa_aux_get(a->l_aux, a->aux, "L1");
			if (s_L1) {
				if (ov != INT32_MAX && s_L1[0] == 'i')
					g->seg[v>>1].len = g->seg[v>>1].len > ov + *(int32_t*)(s_L1+1)? g->seg[v>>1].len : ov + *(int32_t*)(s_L1+1);
				a->l_aux = gfa_aux_del(a->l_aux, a->aux, s_L1);
			}
			s_L2 = gfa_aux_get(a->l_aux, a->aux, "L2");
			if (s_L2) {
				if (ow != INT32_MAX && s_L2[0] == 'i')
					g->seg[w>>1].len = g->seg[w>>1].len > ow + *(int32_t*)(s_L2+1)? g->seg[w>>1].len : ow + *(int32_t*)(s_L2+1);
				a->l_aux = gfa_aux_del(a->l_aux, a->aux, s_L2);
			}
			if (a->l_aux == 0) {
				free(a->aux);
				a->aux = 0, a->m_aux = 0;
			}
		}
	} else return -1;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
leaq 0x2(%rsi), %r15
movq %r15, 0x18(%rsp)
addq $0x3, %r14
xorl %r12d, %r12d
pushq $-0x1
popq %r13
leaq 0x1cf03(%rip), %rcx     # 0x23428
pushq $-0x2
popq %rax
xorl %esi, %esi
movl %r13d, %ebp
xorl %edx, %edx
movzbl -0x1(%r14), %ebx
cmpl $0x9, %ebx
je 0x653d
testl %ebx, %ebx
jne 0x65a6
movb $0x0, -0x1(%r14)
cmpl $0x4, %edx
ja 0x659d
movl %edx, %r8d
movslq (%rcx,%r8,4), %r8
addq %rcx, %r8
jmpq *%r8
movq %r15, %rsi
jmp 0x659d
movq %r15, %r12
jmp 0x659d
movzbl (%r15), %r8d
cmpl $0x2d, %r8d
je 0x6572
cmpl $0x2b, %r8d
jne 0x67f0
xorl %r13d, %r13d
cmpb $0x2b, %r8b
setne %r13b
jmp 0x659d
movzbl (%r15), %r8d
cmpl $0x2d, %r8d
je 0x6593
cmpl $0x2b, %r8d
jne 0x67f0
xorl %ebp, %ebp
cmpb $0x2b, %r8b
setne %bpl
incl %edx
testb %bl, %bl
je 0x65ab
movq %r14, %r15
incq %r14
jmp 0x652f
movq %r12, 0x40(%rsp)
movq %r14, 0x18(%rsp)
cmpl $0x4, %edx
sete %al
movb $0x1, %r12b
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
andb %r12b, %al
cmovnel %ecx, %r8d
cmovnel %ecx, %r9d
cmpb %al, %r12b
je 0x65e7
pushq $-0x1
popq %rax
jmp 0x67f0
leaq 0x34(%rsp), %rax
andl $0x0, (%rax)
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
movq %rdi, %rbx
movq %r8, 0x10(%rsp)
movq %r9, %r12
callq 0x3f7f
movl %eax, %r15d
addl %r15d, %r15d
orl %ebp, %r15d
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x3f7f
movl %eax, %ebp
addl %ebp, %ebp
orl %r13d, %ebp
andl $0x0, (%rsp)
pushq $-0x1
popq %r9
movq %rbx, %rdi
movq %r15, 0x8(%rsp)
movl %r15d, %esi
movl %ebp, %edx
movq %r12, 0x40(%rsp)
movl %r12d, %ecx
movq 0x10(%rsp), %r8
callq 0x4639
movq %rax, %r13
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x34(%rsp), %rdx
callq 0x5780
testl %eax, %eax
je 0x67ee
movq %rbx, %r15
movq 0x50(%rbx), %rcx
movq 0x18(%r13), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r14
movl %eax, 0x4(%rcx,%rdx)
movl 0x34(%rsp), %esi
movl %esi, (%rcx,%rdx)
movq 0x28(%rsp), %rsi
movq %rsi, 0x8(%rcx,%rdx)
leaq 0x1ce03(%rip), %rdx     # 0x2349b
movl %eax, %edi
callq 0x537e
testq %rax, %rax
je 0x671b
cmpb $0x69, (%rax)
movl 0x4(%r14), %edi
jne 0x671f
movl 0x1(%rax), %ecx
movl %ecx, 0xc(%r13)
movq 0x8(%r14), %rsi
movq %rax, %rdx
callq 0x545e
movl %eax, %edi
movl %eax, 0x4(%r14)
jmp 0x671f
movq %r15, 0x18(%rsp)
movzbl (%r15), %eax
cmpl $0x2a, %eax
movq %r12, 0x40(%rsp)
je 0x67ff
movq %rsi, 0x8(%rsp)
movq %rdi, 0x20(%rsp)
cmpl $0x3a, %eax
jne 0x680a
callq 0x23a0
movq (%rax), %rax
movsbq 0x1(%r15), %rcx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x684a
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
jmp 0x6866
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
leaq 0x1cd74(%rip), %rdx     # 0x2349e
callq 0x537e
testq %rax, %rax
je 0x677b
movq 0x40(%rsp), %rsi
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x6763
cmpb $0x69, (%rax)
jne 0x6763
movq 0x10(%r15), %rcx
movq 0x8(%rsp), %rdi
shrl %edi
shlq $0x6, %rdi
movl (%rcx,%rdi), %edx
addl 0x1(%rax), %esi
cmpl %esi, %edx
cmovgl %edx, %esi
movl %esi, (%rcx,%rdi)
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
movq %rax, %rdx
callq 0x545e
movl %eax, %edi
movl %eax, 0x4(%r14)
jmp 0x677f
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
leaq 0x1cd17(%rip), %rdx     # 0x234a1
callq 0x537e
testq %rax, %rax
je 0x67d4
movq 0x10(%rsp), %rsi
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x67be
cmpb $0x69, (%rax)
jne 0x67be
movq 0x10(%r15), %rcx
shrl %ebp
shlq $0x6, %rbp
movl (%rcx,%rbp), %edx
addl 0x1(%rax), %esi
cmpl %esi, %edx
cmovgl %edx, %esi
movl %esi, (%rcx,%rbp)
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
movq %rax, %rdx
callq 0x545e
movl %eax, 0x4(%r14)
jmp 0x67d8
movl 0x4(%r14), %eax
testl %eax, %eax
jne 0x67ee
movq 0x8(%r14), %rdi
callq 0x2040
andq $0x0, 0x8(%r14)
andl $0x0, (%r14)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r8d, %r8d
xorl %r9d, %r9d
jmp 0x68e8
movsbq %al, %rax
movq %rax, 0x10(%rsp)
callq 0x23a0
movq (%rax), %rcx
movb $0x1, %r12b
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq 0x10(%rsp), %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
jne 0x6872
xorl %r14d, %r14d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movb $0x1, %al
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rsi
jmp 0x65cd
incq %r15
leaq 0x18(%rsp), %rsi
pushq $0xa
popq %rdx
movq %r15, %rdi
callq 0x2220
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq %rax, %r8
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rsi
jmp 0x68e8
leaq 0x28(%rsp), %rsi
movq %rax, 0x38(%rsp)
pushq $0xa
popq %rdx
movq %r15, %rdi
callq 0x2220
movq %rax, %r9
movq 0x38(%rsp), %rax
movq (%rax), %rax
leaq 0x28(%rsp), %rcx
movq (%rcx), %rdi
movsbq (%rdi), %rcx
testb $0x1, 0x1(%rax,%rcx,2)
jne 0x68f8
cmpb $0x3a, %cl
movq 0x8(%rsp), %rsi
jne 0x6986
movsbq 0x1(%rdi), %rcx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
testb $0x8, 0x1(%rax,%rcx,2)
je 0x68e3
incq %rdi
leaq 0x28(%rsp), %rsi
pushq $0xa
popq %rdx
movq %r9, %r15
callq 0x2220
movq %r15, %r9
movq 0x8(%rsp), %rsi
movq %rax, %r8
movq 0x20(%rsp), %rdi
xorl %r12d, %r12d
testb %bl, %bl
cmoveq %r12, %r14
movb $0x1, %al
jmp 0x65cd
xorl %r8d, %r8d
xorl %r9d, %r9d
movq %r8, 0x10(%rsp)
movq %r9, %r12
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x2220
movq 0x18(%rsp), %rcx
movzbl (%rcx), %edx
leal -0x44(%rdx), %esi
cmpl $0xa, %esi
ja 0x6977
movl $0x601, %edi            # imm = 0x601
btl %esi, %edi
movq %r12, %r9
jae 0x6936
addl %eax, %r9d
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r8
addl $-0x49, %edx
cmpl $0xa, %edx
ja 0x6955
movl $0x411, %edi            # imm = 0x411
btl %edx, %edi
jae 0x6955
addl %eax, %r8d
movq 0x38(%rsp), %rax
leaq 0x1(%rcx), %r15
movq %r15, 0x18(%rsp)
movq (%rax), %rax
movsbq 0x1(%rcx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x68fe
jmp 0x68e3
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r8
movq %r12, %r9
jmp 0x6940
xorl %r14d, %r14d
movb $0x1, %al
movq 0x20(%rsp), %rdi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
jmp 0x65cd