// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/ecovlp.cpp
// Function: gen_mm_cns_arc(cns_gfa*, unsigned int, unsigned int, unsigned int, unsigned int)
inline void gen_mm_cns_arc(cns_gfa *cns, uint32_t src, uint32_t des, uint32_t sc, uint32_t f)
{
    cns_t *av = &((*cns).a[src]), *aw;
    uint32_t vk, wk;
    for (vk = 0; vk < av->arc.nou; vk++) {///out-edge of src
        if((av->arc.a[vk].v != des) || (del_cns_arc((*av), vk))) continue;
        // av->arc.a[vk].f = 1; ///not sure if we should set these edges as visited
        av->arc.a[vk].f = f;
        av->arc.a[vk].sc += sc;

        aw = &((*cns).a[des]);
        for (wk = aw->arc.nou; wk < aw->arc.n; wk++) {///in-edge of des
            if((aw->arc.a[wk].v != src) || (del_cns_arc((*aw), wk))) continue;
            // aw->arc.a[wk].f = 1; ///not sure if we should set these edges as visited
            aw->arc.a[wk].f = f;
            aw->arc.a[wk].sc += sc; 
            break;
        }

        assert(wk < aw->arc.n);
        return;
    }

    cns_arc *p, t;
    ///src -> des
    kv_pushp(cns_arc, (*cns).a[src].arc, &p);
    p->sc = sc; p->v = des;
    // p->f = 1; ///not sure if we should set these edges as visited
    p->f = f; 
    ///ou-edge
    (*cns).a[src].arc.nou++;
    if((*cns).a[src].arc.nou < (*cns).a[src].arc.n) {
        t = (*cns).a[src].arc.a[(*cns).a[src].arc.nou-1]; 
        (*cns).a[src].arc.a[(*cns).a[src].arc.nou-1] = *p;
        *p = t;
    }

    ///src <- des; in-edge
    kv_pushp(cns_arc, (*cns).a[des].arc, &p);
    p->sc = sc; p->v = src;
    // p->f = 1; ///not sure if we should set these edges as visited
    p->f = f; 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %r12d
movl %esi, %r14d
movq %rdi, %r15
movq 0x10(%rdi), %rcx
movl %esi, %eax
imulq $0x28, %rax, %r13
leaq (%rcx,%r13), %rax
addq $0x8, %rax
movq 0x10(%rax), %rsi
xorl %r9d, %r9d
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movl %r9d, %edx
cmpq %rdx, %rsi
jbe 0x14f2ee
movq 0x18(%rax), %r8
movl (%r8,%rdx,8), %r9d
andl %edi, %r9d
cmpl %r12d, %r9d
setne %r10b
cmpl %edi, %r9d
sete %r11b
orb %r10b, %r11b
leal 0x1(%rdx), %r9d
testb %r11b, %r11b
jne 0x14f225
shll $0x1f, %ebx
movl %ebx, %ecx
orl %r12d, %ecx
movl %ecx, (%r8,%rdx,8)
movq 0x18(%rax), %rax
addl %ebp, 0x4(%rax,%rdx,8)
movq 0x10(%r15), %rax
movl %r12d, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
addq $0x8, %rax
movl 0x10(%rax), %r8d
movq (%rax), %rdx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl %r8d, %ecx
cmpq %rcx, %rdx
jbe 0x14f2c6
movq 0x18(%rax), %rdi
movl (%rdi,%rcx,8), %r8d
andl %esi, %r8d
cmpl %r14d, %r8d
setne %r9b
cmpl %esi, %r8d
sete %r10b
orb %r9b, %r10b
leal 0x1(%rcx), %r8d
testb %r10b, %r10b
jne 0x14f288
orl %r14d, %ebx
movl %ebx, (%rdi,%rcx,8)
movq 0x18(%rax), %rdx
addl %ebp, 0x4(%rdx,%rcx,8)
movq (%rax), %rdx
cmpq %rcx, %rdx
ja 0x14f3e9
leaq 0xa0d98(%rip), %rdi     # 0x1f006e
leaq 0xa0c1e(%rip), %rsi     # 0x1efefb
leaq 0xa24b1(%rip), %rcx     # 0x1f1795
movl $0x4d7, %edx            # imm = 0x4D7
callq 0x2110
movq (%rax), %rdx
pushq $0x2
popq %r9
cmpq 0x8(%rax), %rdx
jne 0x14f32a
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
cmoveq %r9, %rsi
movq %rsi, 0x10(%rcx,%r13)
movq 0x18(%rax), %rdi
shlq $0x3, %rsi
callq 0x2370
pushq $0x2
popq %r9
movq 0x10(%r15), %rcx
movq %rax, 0x20(%rcx,%r13)
movq 0x8(%rcx,%r13), %rdx
movq 0x20(%rcx,%r13), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, 0x8(%rcx,%r13)
movl %ebp, 0x4(%rax,%rdx,8)
movl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll $0x1f, %ebx
orl %ebx, %ecx
movl %ecx, (%rax,%rdx,8)
movq 0x10(%r15), %rcx
movq 0x18(%rcx,%r13), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, 0x18(%rcx,%r13)
cmpq 0x8(%rcx,%r13), %rdi
jae 0x14f385
addq %r13, %rcx
addq $0x8, %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rsi,8), %rdi
movq (%rax,%rdx,8), %r8
movq %r8, (%rcx,%rsi,8)
movq %rdi, (%rax,%rdx,8)
movq 0x10(%r15), %rcx
movl %r12d, %eax
imulq $0x28, %rax, %r12
movq 0x8(%rcx,%r12), %rax
cmpq 0x10(%rcx,%r12), %rax
jne 0x14f3ca
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r9, %rsi
leaq (%rcx,%r12), %rax
addq $0x8, %rax
movq %rsi, 0x8(%rax)
movq 0x18(%rax), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x10(%r15), %rcx
movq %rax, 0x20(%rcx,%r12)
movq 0x8(%rcx,%r12), %rax
movq 0x20(%rcx,%r12), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x8(%rcx,%r12)
movl %ebp, 0x4(%rdx,%rax,8)
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
orl %r14d, %ebx
movl %ebx, (%rdx,%rax,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq