// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: add_cns_arc_bp(cns_gfa*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
inline uint32_t add_cns_arc_bp(cns_gfa *cns, uint32_t src, uint32_t bp, uint32_t plus0, uint32_t rid, uint32_t av_bp)
{
    uint32_t rr, des;
    rr = get_cns_arc_bp(cns, src, bp, 1, av_bp);
    if(rr != ((uint32_t)-1)) {///find an existing node
        des = (*cns).a[src].arc.a[rr].v;
        (*cns).a[des].sc++;
        (*cns).a[src].arc.a[rr].sc += plus0;

        rr = add_cns_arc(cns, des, src, 0, plus0); 
        // if(rr == 0) {
        //     fprintf(stderr, "[M::%s] src::%u -> des::%u\n", __func__, src, des);
        //     prt_cns_arc(cns, src);
        //     prt_cns_arc(cns, des);
        // }
        assert(rr);

        return des;
    } else {///create a new node
        des = insert_cns_node(cns);
        (*cns).a[des].sc++; (*cns).a[des].c = bp;
        insert_cns_arc(cns, src, des, 1, plus0, rid); 
        insert_cns_arc(cns, des, src, 0, plus0, rid);
    }

    return des;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x24(%rbp), %r8d
movl $0x1, %ecx
callq 0x26e000
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
je 0x26cf10
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
shrl $0x3, %edx
addl $0x1, %edx
movl (%rax), %ecx
andl $0x1fffffff, %edx       # imm = 0x1FFFFFFF
shll $0x3, %edx
andl $0x7, %ecx
orl %edx, %ecx
movl %ecx, (%rax)
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movl -0x28(%rbp), %ecx
addl 0x4(%rax,%rcx,8), %edx
movl %edx, 0x4(%rax,%rcx,8)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x1c(%rbp), %r8d
xorl %ecx, %ecx
callq 0x26cd20
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x26cee6
jmp 0x26cf05
leaq 0x117bf9(%rip), %rdi    # 0x384ae6
leaq 0x121d17(%rip), %rsi    # 0x38ec0b
movl $0x269, %edx            # imm = 0x269
leaq 0x12355f(%rip), %rcx    # 0x39045f
callq 0x2130
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x26cfa4
movq -0x10(%rbp), %rdi
callq 0x26e190
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
shrl $0x3, %edx
addl $0x1, %edx
movl (%rax), %ecx
andl $0x1fffffff, %edx       # imm = 0x1FFFFFFF
shll $0x3, %edx
andl $0x7, %ecx
orl %edx, %ecx
movl %ecx, (%rax)
movl -0x18(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
andl $0x3, %edx
andl $-0x4, %ecx
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x2c(%rbp), %edx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl $0x1, %ecx
callq 0x26ca80
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %ecx, %ecx
callq 0x26ca80
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)