// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: gfa_parse_S
static inline int gfa_parse_S(asg_t *g, char *s)
{
    if (*s != 'S') return PARSE_S_ERR;

    int i, c, is_ok;
    char *p, *q, *seg, *seq, *rest;
    uint32_t sid, len;
    
    seg = seq = rest = 0;
    len = 0;
    for (i = 0, p = q = s + 2;; ++p) {
        if (*p == 0 || *p == '\t') {
            c = *p;
            *p = 0;
            if (i == 0) seg = q;
            else if (i == 1) {
                seq = q[0] == '*'? 0 : 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
        // parse sequence coverage if presented
        int l_aux, m_aux = 0;
        uint32_t LN = 0;
        uint8_t *aux = 0, *s_LN = 0;
        asg_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 = *(int64_t*)(s_LN + 1);
        if (seq == 0) {
            if (LN > 0) len = LN;
        } else {
            len = strlen(seq);
        }
        if (LN > 0 && len != LN)
            fprintf(stderr, "[W::%s] for segment '%s', LN:i:%u tag is different from sequence length %d\n", __func__, seg, LN, len);
        sid = asg_add_seg(g, seg, 0);
        s = &g->seg[sid];
        s->len = len, s->seq = seq;
        if (l_aux > 0) {
            uint8_t *s_SBP_COV = 0, *s_SEQ_COV = 0;
            double dv = 0;
            char tag[2];
            if (TAG_SBP_COV[0] != 0) {
                memcpy(tag, TAG_SBP_COV, 2);
                s_SBP_COV = gfa_aux_get(l_aux, aux, tag);
                if (s_SBP_COV && *s_SBP_COV == TAG_SBP_COV[3]) {
                    dv = gfa_aux_decimal_value(s_SBP_COV);
                    s->cov = len > 0? dv/len : dv;
                } else {
                    fprintf(stderr, "[W::%s] for segment '%s', %s tag is absent\n", __func__, seg, tag);
                }
            } else if (TAG_SEQ_COV[0] != 0) {
                memcpy(tag, TAG_SEQ_COV, 2);
                s_SEQ_COV = gfa_aux_get(l_aux, aux, tag);
                if (s_SEQ_COV && *s_SEQ_COV == TAG_SEQ_COV[3]) {
                    s->cov = gfa_aux_decimal_value(s_SEQ_COV);
                } else {
                    fprintf(stderr, "[W::%s] for segment '%s', %s tag is absent\n", __func__, seg, tag);
                }
            } else {
                // check KC and FC
                s_SBP_COV = gfa_aux_get(l_aux, aux, "KC");
                if (s_SBP_COV && *s_SBP_COV == 'i') {
                    dv = *(int64_t*)(s_SBP_COV + 1);
                } else {
                    s_SBP_COV = gfa_aux_get(l_aux, aux, "FC");
                    if (s_SBP_COV && *s_SBP_COV == 'i')
                        dv = *(int64_t*)(s_SBP_COV + 1);
                }
                s->cov = len > 0? dv/len : dv;
            }
        }
        if (s->cov == 0) {
            fprintf(stderr, "[W::%s] the coverage of segment '%s' is zero\n", __func__, seg);
            s->cov = 1;
        }
        free(aux);
    } else return PARSE_S_ERR;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x53, %eax
je 0xca8b
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0xcfb2
movq $0x0, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xcadd
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
jne 0xcb8d
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0xcafe
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xcb6e
cmpl $0x1, -0x1c(%rbp)
jne 0xcb6c
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0xcb1b
xorl %eax, %eax
movq %rax, -0xa8(%rbp)
jmp 0xcb2b
movq -0x38(%rbp), %rdi
callq 0x2470
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1, -0x24(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0xcb54
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0xcb5f
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0xcb5f
movq -0xb0(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0xcba0
jmp 0xcb6e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x20(%rbp)
jne 0xcb8b
jmp 0xcba0
jmp 0xcb8d
jmp 0xcb8f
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xcac1
cmpl $0x0, -0x24(%rbp)
je 0xcfa2
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x16c50
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0xcbfe
movl -0x5c(%rbp), %edi
movq -0x70(%rbp), %rsi
leaq 0x17753(%rip), %rdx     # 0x24343
callq 0x171c0
movq %rax, -0xb8(%rbp)
jmp 0xcc09
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
jmp 0xcc09
movq -0xb8(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xcc32
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0xcc32
movq -0x78(%rbp), %rax
movq 0x1(%rax), %rax
movl %eax, -0x64(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xcc47
cmpl $0x0, -0x64(%rbp)
jbe 0xcc45
movl -0x64(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0xcc53
movq -0x48(%rbp), %rdi
callq 0x2130
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x64(%rbp)
jbe 0xcc8c
movl -0x58(%rbp), %eax
cmpl -0x64(%rbp), %eax
je 0xcc8c
movq 0x1d390(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movq -0x40(%rbp), %rcx
movl -0x64(%rbp), %r8d
movl -0x58(%rbp), %r9d
leaq 0x176c8(%rip), %rsi     # 0x24346
leaq 0x1770d(%rip), %rdx     # 0x24392
movb $0x0, %al
callq 0x2290
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0xb300
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x54(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl -0x58(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x48(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x5c(%rbp)
jle 0xcf5f
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x98(%rbp)
movsbl 0x1d694(%rip), %eax     # 0x2a390
cmpl $0x0, %eax
je 0xcddb
movw 0x1d684(%rip), %ax      # 0x2a390
movw %ax, -0x9a(%rbp)
movl -0x5c(%rbp), %edi
movq -0x70(%rbp), %rsi
leaq -0x9a(%rbp), %rdx
callq 0x171c0
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0xcdac
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
movsbl 0x1d64b(%rip), %ecx     # 0x2a393
cmpl %ecx, %eax
jne 0xcdac
movq -0x88(%rbp), %rdi
callq 0x172f0
movsd %xmm0, -0x98(%rbp)
cmpl $0x0, -0x58(%rbp)
jbe 0xcd84
movsd -0x98(%rbp), %xmm0
movl -0x58(%rbp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
jmp 0xcd94
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0xc0(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0xcdd6
movq 0x1d245(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movq -0x40(%rbp), %rcx
leaq -0x9a(%rbp), %r8
leaq 0x175d6(%rip), %rsi     # 0x2439e
leaq 0x175c3(%rip), %rdx     # 0x24392
movb $0x0, %al
callq 0x2290
jmp 0xcf5d
movsbl 0x1d5aa(%rip), %eax     # 0x2a38c
cmpl $0x0, %eax
je 0xce7d
movw 0x1d59a(%rip), %ax      # 0x2a38c
movw %ax, -0x9a(%rbp)
movl -0x5c(%rbp), %edi
movq -0x70(%rbp), %rsi
leaq -0x9a(%rbp), %rdx
callq 0x171c0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0xce4e
movq -0x90(%rbp), %rax
movzbl (%rax), %eax
movsbl 0x1d561(%rip), %ecx     # 0x2a38f
cmpl %ecx, %eax
jne 0xce4e
movq -0x90(%rbp), %rdi
callq 0x172f0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0xce78
movq 0x1d1a3(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movq -0x40(%rbp), %rcx
leaq -0x9a(%rbp), %r8
leaq 0x17534(%rip), %rsi     # 0x2439e
leaq 0x17521(%rip), %rdx     # 0x24392
movb $0x0, %al
callq 0x2290
jmp 0xcf5b
movl -0x5c(%rbp), %edi
movq -0x70(%rbp), %rsi
leaq 0x1753f(%rip), %rdx     # 0x243ca
callq 0x171c0
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0xcec7
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0xcec7
movq -0x88(%rbp), %rax
cvtsi2sdq 0x1(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0xcf11
movl -0x5c(%rbp), %edi
movq -0x70(%rbp), %rsi
leaq 0x174f8(%rip), %rdx     # 0x243cd
callq 0x171c0
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0xcf0f
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0xcf0f
movq -0x88(%rbp), %rax
cvtsi2sdq 0x1(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0xcf11
cmpl $0x0, -0x58(%rbp)
jbe 0xcf35
movsd -0x98(%rbp), %xmm0
movl -0x58(%rbp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
jmp 0xcf45
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xc8(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0xcf5d
jmp 0xcf5f
movq -0x80(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0xcf97
movq 0x1d088(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movq -0x40(%rbp), %rcx
leaq 0x17452(%rip), %rsi     # 0x243d0
leaq 0x1740d(%rip), %rdx     # 0x24392
movb $0x0, %al
callq 0x2290
movq -0x80(%rbp), %rax
movl $0x1, 0x14(%rax)
movq -0x70(%rbp), %rdi
callq 0x2060
jmp 0xcfab
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0xcfb2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nop