// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %rbx
movq %rdi, 0x48(%rsp)
addq $0x2, %rbx
leaq 0x8(%rsp), %rax
movq %rbx, (%rax)
movl $0xffffffff, 0x40(%rsp) # imm = 0xFFFFFFFF
xorl %edi, %edi
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq 0x2055a(%rip), %rdx     # 0x28428
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq $0x0, 0x58(%rsp)
xorl %esi, %esi
xorl %r8d, %r8d
movl $0xffffffff, 0x3c(%rsp) # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movzbl (%rbx), %r15d
cmpl $0x9, %r15d
je 0x7eff
testl %r15d, %r15d
jne 0x7fe9
movb $0x0, (%rbx)
cmpl $0x4, %r14d
ja 0x7fc7
movl %r14d, %eax
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x8(%rsp), %rsi
jmp 0x7fc7
movq %r12, 0x50(%rsp)
movq 0x8(%rsp), %r12
movzbl (%r12), %eax
cmpl $0x2a, %eax
je 0x7ff1
movq %rsi, 0x28(%rsp)
cmpl $0x3a, %eax
jne 0x7ffb
callq 0x23a0
movq (%rax), %rax
movsbq 0x1(%r12), %rcx
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x8078
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
jmp 0x8090
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
jmp 0x7fc7
movq 0x8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x2d, %eax
je 0x7f93
cmpl $0x2b, %eax
jne 0x805c
xorl %ecx, %ecx
cmpb $0x2b, %al
setne %cl
movl %ecx, 0x40(%rsp)
jmp 0x7fc7
movq 0x8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x2d, %eax
je 0x7fbc
movl $0x1, %r13d
cmpl $0x2b, %eax
jne 0x806d
xorl %ecx, %ecx
cmpb $0x2b, %al
setne %cl
movl %ecx, 0x3c(%rsp)
incl %r14d
leaq 0x1(%rbx), %rax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
testb %r15b, %r15b
sete %r13b
addl %r13d, %r13d
testl %r13d, %r13d
jne 0x81df
incq %rbx
jmp 0x7eec
xorl %r12d, %r12d
xorl %ebp, %ebp
jmp 0x8095
movl %r8d, 0x14(%rsp)
movq %rdi, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
movsbq %al, %rax
movq %rax, 0x60(%rsp)
callq 0x23a0
movq %rax, %rbp
movq (%rax), %rax
movl $0x4, %r14d
movl $0x2, %r13d
movq 0x60(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x80c3
movq 0x50(%rsp), %r12
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
leaq 0x203d3(%rip), %rdx     # 0x28428
movl 0x14(%rsp), %r8d
jmp 0x7fe0
movl $0x3, %r14d
movl $0x1, %r13d
jmp 0x7fe0
movl $0x1, %r14d
jmp 0x7fe0
incq %r12
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq %rax, %r12
movq 0x28(%rsp), %rsi
leaq 0x2038c(%rip), %rdx     # 0x28428
leaq 0x1(%rbx), %rax
testb %r15b, %r15b
movl $0x0, %edi
cmovneq %rax, %rdi
movl $0x4, %r14d
movl $0x1, %r8d
movl $0x2, %r13d
jmp 0x7fe0
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq %rax, 0x18(%rsp)
movq (%rbp), %rax
movq 0x30(%rsp), %rdi
movsbq (%rdi), %rcx
testb $0x1, 0x1(%rax,%rcx,2)
jne 0x812d
xorl %r13d, %r13d
cmpb $0x3a, %cl
jne 0x81a9
movsbq 0x1(%rdi), %rcx
movb $0x1, %bpl
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
testb $0x8, 0x1(%rax,%rcx,2)
je 0x81b6
incq %rdi
leaq 0x30(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq %rax, %r12
jmp 0x81b6
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x2220
movq 0x8(%rsp), %rcx
movzbl (%rcx), %edx
leal -0x44(%rdx), %esi
cmpl $0xa, %esi
ja 0x8173
movl $0x601, %edi            # imm = 0x601
btl %esi, %edi
jae 0x8173
movq 0x18(%rsp), %rsi
addl %eax, %esi
movq %rsi, 0x18(%rsp)
addl $-0x49, %edx
cmpl $0xa, %edx
ja 0x8188
movl $0x411, %esi            # imm = 0x411
btl %edx, %esi
jae 0x8188
addl %eax, %r12d
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%rsp)
movq (%rbp), %rax
movsbq 0x1(%rcx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x8139
xorl %r13d, %r13d
movb $0x1, %bpl
jmp 0x81b6
movl $0x2, %r13d
xorl %ebp, %ebp
movq 0x50(%rsp), %r12
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl 0x14(%rsp), %r8d
testb %bpl, %bpl
movq 0x18(%rsp), %rbp
leaq 0x20254(%rip), %rdx     # 0x28428
je 0x7fe0
jmp 0x809c
cmpl $0x2, %r13d
jne 0x83d6
cmpl $0x4, %r14d
setne %cl
testl %r8d, %r8d
setne %al
sete %dl
movq %rbp, %r13
xorl %ebp, %ebp
orb %cl, %al
cmovel %ebp, %r12d
cmovel %ebp, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %dl, %cl
jne 0x83db
leaq 0x44(%rsp), %rax
movl %ebp, (%rax)
leaq 0x30(%rsp), %rax
movq $0x0, (%rax)
movq 0x48(%rsp), %r14
movq %rdi, 0x20(%rsp)
movq %r14, %rdi
callq 0x4bc1
movq %r12, %r15
movl %eax, %r12d
addl %r12d, %r12d
orl 0x3c(%rsp), %r12d
movq %r14, %rdi
movq 0x58(%rsp), %rsi
callq 0x4bc1
movl %eax, %ebx
addl %ebx, %ebx
orl 0x40(%rsp), %ebx
movl %ebp, (%rsp)
movq %r14, %rdi
movl %r12d, %esi
movl %ebx, %edx
movq %r13, 0x18(%rsp)
movl %r13d, %ecx
movq %r15, %r13
movl %r15d, %r8d
movq $-0x1, %r9
callq 0x53de
movq %rax, %rbp
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x44(%rsp), %rdx
callq 0x6640
testl %eax, %eax
je 0x83d2
movq 0x50(%r14), %rcx
movq 0x18(%rbp), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r14
movl %eax, 0x4(%rcx,%rdx)
movl 0x44(%rsp), %esi
movl %esi, (%rcx,%rdx)
movq 0x30(%rsp), %rsi
movq %rsi, 0x8(%rcx,%rdx)
leaq 0x201c5(%rip), %rdx     # 0x28492
movl %eax, %edi
callq 0x6199
testq %rax, %rax
je 0x82f8
cmpb $0x69, (%rax)
jne 0x82f8
movl 0x1(%rax), %ecx
movl %ecx, 0xc(%rbp)
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
movq %rax, %rdx
callq 0x62c4
movl %eax, 0x4(%r14)
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
leaq 0x2018e(%rip), %rdx     # 0x28495
callq 0x6199
testq %rax, %rax
je 0x8357
movq 0x18(%rsp), %rsi
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x8343
cmpb $0x69, (%rax)
jne 0x8343
movq 0x48(%rsp), %rcx
movq 0x10(%rcx), %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(%r14), %edi
movq 0x8(%r14), %rsi
movq %rax, %rdx
callq 0x62c4
movl %eax, 0x4(%r14)
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
leaq 0x20132(%rip), %rdx     # 0x28498
callq 0x6199
testq %rax, %rax
je 0x83b3
cmpl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
je 0x839f
cmpb $0x69, (%rax)
jne 0x839f
movq 0x48(%rsp), %rcx
movq 0x10(%rcx), %rcx
shrl %ebx
shlq $0x6, %rbx
movl (%rcx,%rbx), %edx
addl 0x1(%rax), %r13d
cmpl %r13d, %edx
cmovgl %edx, %r13d
movl %r13d, (%rcx,%rbx)
movl 0x4(%r14), %edi
movq 0x8(%r14), %rsi
movq %rax, %rdx
callq 0x62c4
movl %eax, 0x4(%r14)
cmpl $0x0, 0x4(%r14)
jne 0x83d2
movq 0x8(%r14), %rdi
callq 0x2040
movq $0x0, 0x8(%r14)
movl $0x0, (%r14)
xorl %eax, %eax
jmp 0x83db
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq