// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rdi, 0x40(%rsp)
leaq 0x2(%rsi), %rbx
movq %rbx, 0x20(%rsp)
addq $0x3, %r15
xorl %edi, %edi
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
leaq 0x20041(%rip), %rax     # 0x28428
xorl %esi, %esi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movzbl -0x1(%r15), %r14d
cmpl $0x9, %r14d
je 0x8400
testl %r14d, %r14d
jne 0x8460
movb $0x0, -0x1(%r15)
cmpl $0x4, %ecx
ja 0x8456
movl %ecx, %edx
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movq %rbx, %rsi
jmp 0x8456
movq %rbx, %rdi
jmp 0x8456
movzbl (%rbx), %edx
cmpl $0x2d, %edx
je 0x8430
cmpl $0x2b, %edx
jne 0x84dc
xorl %r13d, %r13d
cmpb $0x2b, %dl
setne %r13b
jmp 0x8456
movzbl (%rbx), %edx
cmpl $0x2d, %edx
je 0x844d
cmpl $0x2b, %edx
jne 0x84dc
xorl %ebp, %ebp
cmpb $0x2b, %dl
setne %bpl
incl %ecx
testb %r14b, %r14b
je 0x8465
movq %r15, %rbx
incq %r15
jmp 0x83f0
movq %r15, 0x20(%rsp)
xorl %eax, %eax
cmpl $0x4, %ecx
sete %r12b
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmovel %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %r12b, %r12b
je 0x8810
movq %rdi, 0x18(%rsp)
xorl %r15d, %r15d
movl %ecx, %eax
movq %rax, 0x8(%rsp)
movl %ecx, %ebx
jmp 0x8653
movq %rbx, 0x20(%rsp)
movzbl (%rbx), %eax
cmpl $0x2a, %eax
movq %rdi, 0x18(%rsp)
je 0x84e6
movq %rsi, 0x10(%rsp)
cmpl $0x3a, %eax
jne 0x84f0
callq 0x23a0
movq (%rax), %rax
movsbq 0x1(%rbx), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x8521
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
jmp 0x853e
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x8810
xorl %r12d, %r12d
xorl %edx, %edx
jmp 0x8643
movsbq %al, %rax
movq %rax, 0x8(%rsp)
callq 0x23a0
movq (%rax), %rdx
movb $0x1, %r12b
xorl %ecx, %ecx
movq 0x8(%rsp), %rsi
testb $0x8, 0x1(%rdx,%rsi,2)
jne 0x8548
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
jmp 0x847b
incq %rbx
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
movl $0xa, %edx
callq 0x2220
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rax, %r12
movq 0x10(%rsp), %rsi
jmp 0x8643
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
movl $0xa, %edx
movq %rax, 0x38(%rsp)
callq 0x2220
movq 0x38(%rsp), %rcx
movq (%rcx), %rdx
leaq 0x28(%rsp), %rcx
movq (%rcx), %rdi
movsbq (%rdi), %rcx
testb $0x1, 0x1(%rdx,%rcx,2)
jne 0x85bf
movq %rax, 0x8(%rsp)
cmpb $0x3a, %cl
movq 0x10(%rsp), %rsi
jne 0x881f
movsbq 0x1(%rdi), %rcx
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x863c
incq %rdi
leaq 0x28(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq 0x10(%rsp), %rsi
movq %rax, %r12
jmp 0x863c
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq 0x20(%rsp), %rcx
movzbl (%rcx), %edx
leal -0x44(%rdx), %esi
cmpl $0xa, %esi
ja 0x8603
movl $0x601, %edi            # imm = 0x601
btl %esi, %edi
jae 0x8603
movq 0x8(%rsp), %rsi
addl %eax, %esi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rsi
movq 0x38(%rsp), %rdi
addl $-0x49, %edx
cmpl $0xa, %edx
ja 0x8624
movl $0x411, %r8d            # imm = 0x411
btl %edx, %r8d
jae 0x8624
addl %eax, %r12d
leaq 0x1(%rcx), %rbx
movq %rbx, 0x20(%rsp)
movq (%rdi), %rax
movsbq 0x1(%rcx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x85cb
movq 0x8(%rsp), %rax
movl %eax, %edx
movq %r12, 0x8(%rsp)
xorl %eax, %eax
testb %r14b, %r14b
cmoveq %rax, %r15
movl %edx, %ebx
xorl %ecx, %ecx
leaq 0x34(%rsp), %rax
movl %ecx, (%rax)
leaq 0x28(%rsp), %rax
movq $0x0, (%rax)
movq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x4aa4
movl %eax, %r12d
addl %r12d, %r12d
orl %ebp, %r12d
movq %r14, %rbp
movq %r14, %rdi
movq 0x18(%rsp), %rsi
callq 0x4aa4
movl %eax, %r14d
addl %r14d, %r14d
orl %r13d, %r14d
xorl %eax, %eax
movl %eax, (%rsp)
movq %rbp, %rdi
movl %r12d, %esi
movl %r14d, %edx
movl %ebx, 0x18(%rsp)
movl %ebx, %ecx
movq 0x8(%rsp), %r8
movq $-0x1, %r9
callq 0x52e2
movq %rax, %r13
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x34(%rsp), %rdx
callq 0x6628
testl %eax, %eax
je 0x880e
movq 0x50(%rbp), %rcx
movq 0x18(%r13), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r15
movl %eax, 0x4(%rcx,%rdx)
movl 0x34(%rsp), %esi
movl %esi, (%rcx,%rdx)
movq 0x28(%rsp), %rsi
movq %rsi, 0x8(%rcx,%rdx)
leaq 0x1fd8d(%rip), %rdx     # 0x28492
movl %eax, %edi
callq 0x616c
testq %rax, %rax
je 0x8735
cmpb $0x69, (%rax)
movl 0x4(%r15), %edi
jne 0x8739
movl 0x1(%rax), %ecx
movl %ecx, 0xc(%r13)
movq 0x8(%r15), %rsi
movq %rax, %rdx
callq 0x6293
movl %eax, %edi
movl %eax, 0x4(%r15)
jmp 0x8739
movl 0x4(%r15), %edi
movq 0x8(%r15), %rsi
leaq 0x1fd51(%rip), %rdx     # 0x28495
callq 0x616c
testq %rax, %rax
je 0x8792
movl 0x18(%rsp), %esi
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x877a
cmpb $0x69, (%rax)
jne 0x877a
movq 0x10(%rbp), %rcx
shrl %r12d
shlq $0x6, %r12
movl (%rcx,%r12), %edx
addl 0x1(%rax), %esi
cmpl %esi, %edx
cmovgl %edx, %esi
movl %esi, (%rcx,%r12)
movl 0x4(%r15), %edi
movq 0x8(%r15), %rsi
movq %rax, %rdx
callq 0x6293
movl %eax, %edi
movl %eax, 0x4(%r15)
jmp 0x8796
movl 0x4(%r15), %edi
movq 0x8(%r15), %rsi
leaq 0x1fcf7(%rip), %rdx     # 0x28498
callq 0x616c
testq %rax, %rax
movq 0x8(%rsp), %rsi
je 0x87ee
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x87d8
cmpb $0x69, (%rax)
jne 0x87d8
movq 0x10(%rbp), %rcx
shrl %r14d
shlq $0x6, %r14
movl (%rcx,%r14), %edx
addl 0x1(%rax), %esi
cmpl %esi, %edx
cmovgl %edx, %esi
movl %esi, (%rcx,%r14)
movl 0x4(%r15), %edi
movq 0x8(%r15), %rsi
movq %rax, %rdx
callq 0x6293
movl %eax, 0x4(%r15)
jmp 0x87f2
movl 0x4(%r15), %eax
testl %eax, %eax
jne 0x880e
movq 0x8(%r15), %rdi
callq 0x2040
movq $0x0, 0x8(%r15)
movl $0x0, (%r15)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
xorl %ecx, %ecx
jmp 0x847b