// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/gfa-io.c
// Function: gfa_parse_S
int gfa_parse_S(gfa_t *g, char *s)
{
	int i, is_ok = 0;
	char *p, *q, *seg = 0, *seq = 0, *rest = 0;
	uint32_t sid, len = 0;
	for (i = 0, p = q = s + 2;; ++p) {
		if (*p == 0 || *p == '\t') {
			int c = *p;
			*p = 0;
			if (i == 0) seg = q;
			else if (i == 1) {
				seq = q[0] == '*'? 0 : gfa_strdup(q);
				is_ok = 1, rest = c? p + 1 : 0;
				break;
			}
			++i, q = p + 1;
			if (c == 0) break;
		}
	}
	if (is_ok) { // all mandatory fields read
		int l_aux, m_aux = 0, LN = -1;
		uint8_t *aux = 0, *s_LN = 0;
		gfa_seg_t *s;
		l_aux = gfa_aux_parse(rest, &aux, &m_aux); // parse optional tags
		s_LN = l_aux? gfa_aux_get(l_aux, aux, "LN") : 0;
		if (s_LN && s_LN[0] == 'i') {
			LN = *(int32_t*)(s_LN + 1);
			l_aux = gfa_aux_del(l_aux, aux, s_LN);
		}
		if (seq == 0) {
			if (LN >= 0) len = LN;
		} else len = strlen(seq);
		if (LN >= 0 && len != LN && gfa_verbose >= 2)
			fprintf(stderr, "[W] for segment '%s', LN:i:%d tag is different from sequence length %d\n", seg, LN, len);
		sid = gfa_add_seg(g, seg);
		s = &g->seg[sid];
		s->len = len, s->seq = seq;
		if (l_aux > 0) {
			uint8_t *s_SN = 0, *s_SO = 0, *s_SR = 0;
			s_SN = gfa_aux_get(l_aux, aux, "SN");
			if (s_SN && *s_SN == 'Z') { // then parse stable tags
				s->snid = gfa_sseq_add(g, (char*)(s_SN + 1)), s->soff = 0;
				l_aux = gfa_aux_del(l_aux, aux, s_SN);
				s_SO = gfa_aux_get(l_aux, aux, "SO");
				if (s_SO && *s_SO == 'i') {
					s->soff = *(int32_t*)(s_SO + 1);
					l_aux = gfa_aux_del(l_aux, aux, s_SO);
				}
			}
			s_SR = gfa_aux_get(l_aux, aux, "SR");
			if (s_SR && *s_SR == 'i') {
				s->rank = *(int32_t*)(s_SR + 1);
				if (s->rank > g->max_rank) g->max_rank = s->rank;
				l_aux = gfa_aux_del(l_aux, aux, s_SR);
			}
			gfa_sseq_update(g, s);
		}
		if (l_aux > 0)
			s->aux.m_aux = m_aux, s->aux.l_aux = l_aux, s->aux.aux = aux;
		else if (aux)
			free(aux);
	} else return -1;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x2(%rsi), %rdi
addq $0x3, %r12
xorl %r14d, %r14d
pushq $-0x1
popq %rax
xorl %ecx, %ecx
movzbl -0x1(%r12), %ebp
cmpl $0x9, %ebp
je 0x62ea
testl %ebp, %ebp
jne 0x630c
movb $0x0, -0x1(%r12)
testl %ecx, %ecx
je 0x62fb
cmpl $0x1, %ecx
jne 0x62fe
jmp 0x6311
movq %rdi, %r14
testb %bpl, %bpl
je 0x64c4
incl %ecx
movq %r12, %rdi
incq %r12
jmp 0x62db
xorl %r13d, %r13d
cmpb $0x2a, (%rdi)
jne 0x631e
xorl %r15d, %r15d
jmp 0x6326
callq 0x3f1e
movq %rax, %r15
testb %bpl, %bpl
cmoveq %r13, %r12
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x10(%rsp), %rsi
andq $0x0, (%rsi)
movq %r12, %rdi
callq 0x5780
pushq $-0x1
popq %r12
testl %eax, %eax
je 0x6385
movl %eax, %ebp
movq 0x10(%rsp), %r13
leaq 0x1d0ee(%rip), %rdx     # 0x2344a
movl %eax, %edi
movq %r13, %rsi
callq 0x537e
testq %rax, %rax
je 0x6387
cmpb $0x69, (%rax)
jne 0x6387
movl 0x1(%rax), %r12d
movl %ebp, %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x545e
movl %eax, %ebp
jmp 0x6387
xorl %ebp, %ebp
testq %r15, %r15
je 0x6399
movq %r15, %rdi
callq 0x2110
movq %rax, %r13
jmp 0x63a3
xorl %r13d, %r13d
testl %r12d, %r12d
cmovgl %r12d, %r13d
testl %r12d, %r12d
js 0x63bd
cmpl %r12d, %r13d
je 0x63bd
leaq 0x27e3c(%rip), %rax     # 0x2e1f0
cmpl $0x2, (%rax)
jge 0x64d3
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f7f
movq 0x10(%rbx), %r14
movl %eax, %eax
shlq $0x6, %rax
movl %r13d, (%r14,%rax)
movq %r15, 0x20(%r14,%rax)
movq 0x10(%rsp), %r15
testl %ebp, %ebp
jle 0x64ba
addq %rax, %r14
leaq 0x1d0a3(%rip), %rdx     # 0x23495
movl %ebp, %edi
movq %r15, %rsi
callq 0x537e
testq %rax, %rax
je 0x6460
movq %rax, %r12
cmpb $0x5a, (%rax)
jne 0x6460
movq %r12, %rsi
incq %rsi
movq %rbx, %rdi
callq 0x43e8
movl %eax, 0x8(%r14)
andl $0x0, 0xc(%r14)
movl %ebp, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x545e
movl %eax, %ebp
leaq 0x1d062(%rip), %rdx     # 0x23498
movl %eax, %edi
movq %r15, %rsi
callq 0x537e
testq %rax, %rax
je 0x6460
cmpb $0x69, (%rax)
jne 0x6460
movl 0x1(%rax), %ecx
movl %ecx, 0xc(%r14)
movl %ebp, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x545e
movl %eax, %ebp
leaq 0x1d034(%rip), %rdx     # 0x2349b
movl %ebp, %edi
movq %r15, %rsi
callq 0x537e
testq %rax, %rax
je 0x6499
cmpb $0x69, (%rax)
jne 0x6499
movl 0x1(%rax), %ecx
movl %ecx, 0x10(%r14)
cmpl 0x8(%rbx), %ecx
jbe 0x648a
movl %ecx, 0x8(%rbx)
movl %ebp, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x545e
movl %eax, %ebp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4571
testl %ebp, %ebp
jle 0x64ba
movl 0xc(%rsp), %eax
movl %eax, 0x30(%r14)
movl %ebp, 0x34(%r14)
movq %r15, 0x38(%r14)
jmp 0x64c2
movq %r15, %rdi
callq 0x2040
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x27b1e(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
leaq 0x1cf69(%rip), %rsi     # 0x2344d
movq %r14, %rdx
movl %r12d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x2210
jmp 0x63bd