// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: save_all_edges(kvec_t_u64_warp*, asg_t*, unsigned long*, unsigned long, unsigned int, unsigned int, unsigned int*, unsigned int*)
void save_all_edges(kvec_t_u64_warp* u_vecs, asg_t* nsg, uint64_t* nodes, uint64_t n,
uint32_t beg, uint32_t end, uint32_t* beg_c, uint32_t* end_c)
{
    uint32_t i, v, nv, k;
    uint64_t tmp;
    asg_arc_t *av = NULL;
    u_vecs->a.n = 0;

    (*beg_c) = nsg->seq[beg>>1].c;
    (*end_c) = nsg->seq[end>>1].c;
    for (i = 0; i < n; i++)
    {
        v = (uint32_t)nodes[i];
        tmp = nsg->seq[v].c; tmp = tmp<<32; tmp = (tmp)|((uint64_t)v);
        nodes[i] = tmp;

        if(nsg->seq[v].del) continue;
        if(nsg->seq[v].c == ALTER_LABLE) continue;

        v = v<<1;
        av = asg_arc_a(nsg, v);
        nv = asg_arc_n(nsg, v);
        for (k = 0; k < nv; k++)
        {
            if(av[k].del) continue;
            kv_push(uint64_t, u_vecs->a, (uint64_t)((uint64_t)av[k].ol << 32 | (av - nsg->arc + k)));   
        }
        

        v = v^1;
        av = asg_arc_a(nsg, v);
        nv = asg_arc_n(nsg, v);
        for (k = 0; k < nv; k++)
        {
            if(av[k].del) continue;
            kv_push(uint64_t, u_vecs->a, (uint64_t)((uint64_t)av[k].ol << 32 | (av - nsg->arc + k)));   
        }
    }

    v = beg;
    if((!nsg->seq[v>>1].del)&&(nsg->seq[v>>1].c!=ALTER_LABLE))
    {
        av = asg_arc_a(nsg, v);
        nv = asg_arc_n(nsg, v);
        for (k = 0; k < nv; k++)
        {
            if(av[k].del) continue;
            for (i = 0; i < n; i++)
            {
                if((av[k].v>>1)==((uint32_t)nodes[i])) break;
            }
            if(i==n) continue;
            kv_push(uint64_t, u_vecs->a, (uint64_t)((uint64_t)av[k].ol << 32 | (av - nsg->arc + k)));   
        }
    }
    



    v = end^1;
    if((!nsg->seq[v>>1].del)&&(nsg->seq[v>>1].c!=ALTER_LABLE))
    {
        av = asg_arc_a(nsg, v);
        nv = asg_arc_n(nsg, v);
        for (k = 0; k < nv; k++)
        {
            if(av[k].del) continue;
            for (i = 0; i < n; i++)
            {
                if((av[k].v>>1)==((uint32_t)nodes[i])) break;
            }
            if(i==n) continue;
            kv_push(uint64_t, u_vecs->a, (uint64_t)((uint64_t)av[k].ol << 32 | (av - nsg->arc + k)));   
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, %r10
movq %rdi, %r12
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rdi
movq $0x0, (%r12)
movq 0x20(%rsi), %rdx
movl %r8d, 0x18(%rsp)
movl %r8d, %esi
shrl %esi
movq %rsi, 0x20(%rsp)
movzbl 0x4(%rdx,%rsi,8), %esi
movl %esi, (%rdi)
movl %r9d, 0x1c(%rsp)
movl %r9d, %esi
shrl %esi
movq %rsi, 0x28(%rsp)
movzbl 0x4(%rdx,%rsi,8), %edx
movl %edx, (%rax)
movq %rcx, (%rsp)
testq %rcx, %rcx
movq %r10, 0x8(%rsp)
je 0xec59f
xorl %ebp, %ebp
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x10(%rsp), %rsi
movq (%rsi,%rbp,8), %r9
movl %r9d, %eax
movq 0x20(%r10), %rcx
movzbl 0x4(%rcx,%rax,8), %edx
movl %edx, 0x4(%rsi,%rbp,8)
cmpl $0x0, (%rcx,%rax,8)
js 0xec593
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xec593
addl %r9d, %r9d
movq 0x28(%r10), %rax
movq %r9, 0x30(%rsp)
movq (%rax,%r9,8), %rax
testl %eax, %eax
je 0xec4ce
movq 0x8(%r10), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r13
movl %eax, %ebx
leaq (%rcx,%rdx,8), %r15
addq $0xc, %r15
xorl %r14d, %r14d
cmpl $0x0, (%r15)
js 0xec4be
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0xec48b
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq 0x8(%rsp), %r10
movq %rax, 0x10(%r12)
movl (%r15), %eax
andl %edi, %eax
shlq $0x20, %rax
movq %r13, %rcx
subq 0x8(%r10), %rcx
sarq $0x3, %rcx
imulq %r8, %rcx
addq %r14, %rcx
orq %rax, %rcx
movq (%r12), %rax
movq 0x10(%r12), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, (%r12)
movq %rcx, (%rdx,%rax,8)
incq %r14
addq $0x18, %r15
cmpq %r14, %rbx
jne 0xec43e
movq 0x28(%r10), %rax
movl 0x30(%rsp), %ecx
movq 0x8(%rax,%rcx,8), %rax
testl %eax, %eax
je 0xec593
movq 0x8(%r10), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r14
movl %eax, %ebx
leaq (%rcx,%rdx,8), %r15
addq $0xc, %r15
xorl %r13d, %r13d
cmpl $0x0, (%r15)
js 0xec583
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0xec550
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq 0x8(%rsp), %r10
movq %rax, 0x10(%r12)
movl (%r15), %eax
andl %edi, %eax
shlq $0x20, %rax
movq %r14, %rcx
subq 0x8(%r10), %rcx
sarq $0x3, %rcx
imulq %r8, %rcx
addq %r13, %rcx
orq %rax, %rcx
movq (%r12), %rax
movq 0x10(%r12), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, (%r12)
movq %rcx, (%rdx,%rax,8)
incq %r13
addq $0x18, %r15
cmpq %r13, %rbx
jne 0xec503
incl %ebp
cmpq (%rsp), %rbp
jb 0xec3d8
movq 0x20(%r10), %rax
movq 0x20(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,8)
js 0xec6c1
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xec6c1
movq 0x28(%r10), %rax
movl 0x18(%rsp), %ecx
movq (%rax,%rcx,8), %rax
testl %eax, %eax
je 0xec6c1
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rbx
shlq $0x3, %rbx
addq 0x8(%r10), %rbx
movl %eax, %r13d
xorl %ebp, %ebp
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpl $0x0, 0xc(%rbx,%rax,8)
js 0xec6b5
leaq (%rbx,%rax,8), %r15
cmpq $0x0, (%rsp)
je 0xec63c
movl 0x8(%r15), %eax
shrl %eax
movl $0x1, %ecx
xorl %edx, %edx
movq 0x10(%rsp), %rsi
cmpl (%rsi,%rdx,8), %eax
je 0xec63e
movl %ecx, %edx
incl %ecx
cmpq (%rsp), %rdx
jb 0xec626
jmp 0xec63e
xorl %edx, %edx
cmpq (%rsp), %rdx
je 0xec6b5
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0xec681
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq 0x8(%rsp), %r10
movq %rax, 0x10(%r12)
movl 0xc(%r15), %eax
andl %edi, %eax
shlq $0x20, %rax
movq %rbx, %rcx
subq 0x8(%r10), %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
addq %rbp, %rcx
orq %rax, %rcx
movq (%r12), %rax
movq 0x10(%r12), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, (%r12)
movq %rcx, (%rdx,%rax,8)
incq %rbp
cmpq %r13, %rbp
jne 0xec5f8
movq 0x20(%r10), %rax
movq 0x28(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,8)
js 0xec7e8
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0xec7e8
movl 0x1c(%rsp), %ecx
xorl $0x1, %ecx
movq 0x28(%r10), %rax
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
testl %eax, %eax
je 0xec7e8
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rbx
shlq $0x3, %rbx
addq 0x8(%r10), %rbx
movl %eax, %r13d
xorl %ebp, %ebp
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpl $0x0, 0xc(%rbx,%rax,8)
js 0xec7dc
leaq (%rbx,%rax,8), %r15
cmpq $0x0, (%rsp)
je 0xec763
movl 0x8(%r15), %eax
shrl %eax
movl $0x1, %ecx
xorl %edx, %edx
movq 0x10(%rsp), %rsi
cmpl (%rsi,%rdx,8), %eax
je 0xec765
movl %ecx, %edx
incl %ecx
cmpq (%rsp), %rdx
jb 0xec74d
jmp 0xec765
xorl %edx, %edx
cmpq (%rsp), %rdx
je 0xec7dc
movq 0x8(%r12), %rax
cmpq %rax, (%r12)
jne 0xec7a8
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq 0x8(%rsp), %r10
movq %rax, 0x10(%r12)
movl 0xc(%r15), %eax
andl %edi, %eax
shlq $0x20, %rax
movq %rbx, %rcx
subq 0x8(%r10), %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
addq %rbp, %rcx
orq %rax, %rcx
movq (%r12), %rax
movq 0x10(%r12), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, (%r12)
movq %rcx, (%rdx,%rax,8)
incq %rbp
cmpq %r13, %rbp
jne 0xec71f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq