// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: push_cns_c0(cns_gfa*, unsigned long, unsigned long, unsigned long, unsigned int, unsigned int)
uint32_t push_cns_c0(cns_gfa *cns, uint64_t s0, uint64_t s, uint64_t e, uint32_t plus0, uint32_t rid)
{
    if(s > e) return s0;///it is possible that s == e
    uint32_t rr, k, re; 
    
    // rr = add_cns_arc(cns, s0, s, 1, plus0); assert(rr);
    // rr = add_cns_arc(cns, s, s0, 0, plus0); assert(rr);
    if(!add_cns_arc(cns, s0, s, 1, plus0)) {
        insert_cns_arc(cns, s0, s, 1, plus0, rid);
        insert_cns_arc(cns, s, s0, 0, plus0, rid);
    } else {
        rr = add_cns_arc(cns, s, s0, 0, plus0); assert(rr);
    }
    (*cns).a[s].sc++; re = s;

    for (k = s + 1; k < e; k++) {
        rr = add_cns_arc(cns, k-1, k, 1, 1); 
        // if(!rr) {
        //     fprintf(stderr, "[M::%s] s0::%u, s::%u\n", __func__, k-1, k);
        //     prt_cns_arc(cns, k-1, __func__); prt_cns_arc(cns, k, __func__);
        // }
        assert(rr);



        rr = add_cns_arc(cns, k, k-1, 0, 1); assert(rr);
        (*cns).a[k].sc++; re = k;
    }
    
    return re;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jbe 0x24cc96
movq -0x18(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x24ce5b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
movq -0x20(%rbp), %rax
movl %eax, %edx
movl -0x2c(%rbp), %r8d
movl $0x1, %ecx
callq 0x26cd20
cmpl $0x0, %eax
jne 0x24ccfc
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %esi
movq -0x20(%rbp), %rax
movl %eax, %edx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r9d
movl $0x1, %ecx
callq 0x26ca80
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
movq -0x18(%rbp), %rax
movl %eax, %edx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r9d
xorl %ecx, %ecx
callq 0x26ca80
jmp 0x24cd43
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
movq -0x18(%rbp), %rax
movl %eax, %edx
movl -0x2c(%rbp), %r8d
xorl %ecx, %ecx
callq 0x26cd20
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x24cd22
jmp 0x24cd41
leaq 0x137dbd(%rip), %rdi    # 0x384ae6
leaq 0x141edb(%rip), %rsi    # 0x38ec0b
movl $0x2aa, %edx            # imm = 0x2AA
leaq 0x141eda(%rip), %rcx    # 0x38ec16
callq 0x2130
jmp 0x24cd43
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x20(%rbp), %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)
movq -0x20(%rbp), %rax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpq -0x28(%rbp), %rax
jae 0x24ce55
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
subl $0x1, %esi
movl -0x38(%rbp), %edx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x26cd20
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x24cdb2
jmp 0x24cdd1
leaq 0x137d2d(%rip), %rdi    # 0x384ae6
leaq 0x141e4b(%rip), %rsi    # 0x38ec0b
movl $0x2b4, %edx            # imm = 0x2B4
leaq 0x141e4a(%rip), %rcx    # 0x38ec16
callq 0x2130
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x38(%rbp), %edx
subl $0x1, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x26cd20
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x24cdf6
jmp 0x24ce15
leaq 0x137ce9(%rip), %rdi    # 0x384ae6
leaq 0x141e07(%rip), %rsi    # 0x38ec0b
movl $0x2b8, %edx            # imm = 0x2B8
leaq 0x141e06(%rip), %rcx    # 0x38ec16
callq 0x2130
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x38(%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 -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x24cd7f
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)