// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x9a8c
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
jne 0x9b3c
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0x9aad
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x9b1d
cmpl $0x1, -0x1c(%rbp)
jne 0x9b1b
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x9aca
xorl %eax, %eax
movq %rax, -0x98(%rbp)
jmp 0x9ada
movq -0x30(%rbp), %rdi
callq 0x5700
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x1, -0x20(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x9b03
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x9b0e
xorl %eax, %eax
movq %rax, -0xa0(%rbp)
jmp 0x9b0e
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x9b4f
jmp 0x9b1d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x9b3a
jmp 0x9b4f
jmp 0x9b3c
jmp 0x9b3e
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x9a70
cmpl $0x0, -0x20(%rbp)
je 0x9e3b
movl $0x0, -0x5c(%rbp)
movl $0xffffffff, -0x60(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x5c(%rbp), %rdx
callq 0x8540
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x9bad
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
leaq 0x32884(%rip), %rdx     # 0x3c423
callq 0x7450
movq %rax, -0xa8(%rbp)
jmp 0x9bb8
xorl %eax, %eax
movq %rax, -0xa8(%rbp)
jmp 0x9bb8
movq -0xa8(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x9bf3
movq -0x70(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0x9bf3
movq -0x70(%rbp), %rax
movl 0x1(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x75e0
movl %eax, -0x58(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x9c08
cmpl $0x0, -0x60(%rbp)
jl 0x9c06
movl -0x60(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x9c14
movq -0x40(%rbp), %rdi
callq 0x2110
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x60(%rbp)
jl 0x9c51
movl -0x50(%rbp), %eax
cmpl -0x60(%rbp), %eax
je 0x9c51
leaq 0x3b5b7(%rip), %rax     # 0x451e0
cmpl $0x2, (%rax)
jl 0x9c51
movq 0x3b3c3(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
movl -0x60(%rbp), %ecx
movl -0x50(%rbp), %r8d
leaq 0x327dc(%rip), %rsi     # 0x3c426
movb $0x0, %al
callq 0x2210
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x57a0
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x50(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpl $0x0, -0x58(%rbp)
jle 0x9dff
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
leaq 0x327ac(%rip), %rdx     # 0x3c46e
callq 0x7450
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x9d7a
movq -0x80(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5a, %eax
jne 0x9d7a
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rsi
addq $0x1, %rsi
callq 0x5980
movl %eax, %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x78(%rbp), %rax
movl $0x0, 0xc(%rax)
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
movq -0x80(%rbp), %rdx
callq 0x75e0
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
leaq 0x32745(%rip), %rdx     # 0x3c471
callq 0x7450
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x9d78
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0x9d78
movq -0x88(%rbp), %rax
movl 0x1(%rax), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x75e0
movl %eax, -0x58(%rbp)
jmp 0x9d7a
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
leaq 0x326ec(%rip), %rdx     # 0x3c474
callq 0x7450
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x9df2
movq -0x90(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0x9df2
movq -0x90(%rbp), %rax
movl 0x1(%rax), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jbe 0x9ddc
movq -0x78(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x58(%rbp), %edi
movq -0x68(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0x75e0
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x5b90
cmpl $0x0, -0x58(%rbp)
jle 0x9e27
movl -0x5c(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x30(%rax)
movl -0x58(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x68(%rbp), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0x9e39
cmpq $0x0, -0x68(%rbp)
je 0x9e37
movq -0x68(%rbp), %rdi
callq 0x2040
jmp 0x9e39
jmp 0x9e44
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9e4b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)