// File: /workspace/github_cpp_makefile_star2_O3/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, 0x18(%rsp)
movq %rdi, %r12
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rdx
movq $0x0, (%r12)
movq %rsi, (%rsp)
movq 0x20(%rsi), %rax
movl %r8d, %r10d
shrl %r10d
movzbl 0x4(%rax,%r10,8), %esi
movl %esi, (%rdx)
movl %r9d, 0x24(%rsp)
movl %r9d, %esi
shrl %esi
movzbl 0x4(%rax,%rsi,8), %edx
movl %edx, (%rdi)
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
je 0xedebb
movq %r10, 0x28(%rsp)
movl %r8d, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
xorl %ebp, %ebp
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x18(%rsp), %rdx
movl (%rdx,%rbp,8), %esi
movq (%rsp), %rax
movq 0x20(%rax), %rax
movb 0x4(%rax,%rsi,8), %cl
movzbl %cl, %ecx
movl %ecx, 0x4(%rdx,%rbp,8)
cmpl $0x0, (%rax,%rsi,8)
sets %al
cmpb $0x1, %cl
sete %cl
orb %al, %cl
jne 0xede97
addl %esi, %esi
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rax
movq (%rax,%rsi,8), %rdx
testl %edx, %edx
je 0xedddd
movq %rsi, 0x30(%rsp)
movq %rdx, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %r13
movl %edx, %r15d
leaq (%rcx,%rax,8), %rbx
addq $0xc, %rbx
xorl %r14d, %r14d
movl (%rbx), %edx
testl %edx, %edx
js 0xeddc0
movq (%r12), %rdi
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdi
jne 0xedd96
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %rax, 0x10(%r12)
movl (%rbx), %edx
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%r12), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movq %r13, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %r8, %rsi
addq %r14, %rsi
orq %rdx, %rsi
leaq 0x1(%rdi), %rdx
movq %rdx, (%r12)
movq %rsi, (%rax,%rdi,8)
incq %r14
addq $0x18, %rbx
cmpq %r14, %r15
jne 0xedd42
movq (%rsp), %rax
movq 0x28(%rax), %rax
movq 0x30(%rsp), %rsi
movl %esi, %edx
movq 0x8(%rax,%rdx,8), %rax
testl %eax, %eax
je 0xede97
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %r14
movl %eax, %r15d
leaq (%rcx,%rdx,8), %rbx
addq $0xc, %rbx
xorl %r13d, %r13d
movl (%rbx), %edx
testl %edx, %edx
js 0xede87
movq (%r12), %rdi
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdi
jne 0xede5d
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %rax, 0x10(%r12)
movl (%rbx), %edx
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%r12), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movq %r14, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %r8, %rsi
addq %r13, %rsi
orq %rdx, %rsi
leaq 0x1(%rdi), %rdx
movq %rdx, (%r12)
movq %rsi, (%rax,%rdi,8)
incq %r13
addq $0x18, %rbx
cmpq %r13, %r15
jne 0xede09
incl %ebp
cmpq 0x8(%rsp), %rbp
jb 0xedcd6
movq (%rsp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rsp), %rsi
movl 0x20(%rsp), %r8d
movq 0x28(%rsp), %r10
cmpl $0x0, (%rax,%r10,8)
js 0xedfef
cmpb $0x1, 0x4(%rax,%r10,8)
je 0xedfef
movq (%rsp), %rcx
movq 0x28(%rcx), %rcx
movl %r8d, %edx
movq (%rcx,%rdx,8), %rdx
testl %edx, %edx
je 0xedfef
movq %rsi, 0x10(%rsp)
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq %rdx, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rbx
movl %edx, %r14d
xorl %r13d, %r13d
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
leaq (,%r13,2), %rax
addq %r13, %rax
movl 0xc(%rbx,%rax,8), %edx
testl %edx, %edx
js 0xedfd6
leaq (%rbx,%rax,8), %r15
cmpq $0x0, 0x8(%rsp)
je 0xedf5d
movl 0x8(%r15), %eax
shrl %eax
movl $0x1, %esi
xorl %edi, %edi
movq 0x18(%rsp), %r8
cmpl (%r8,%rdi,8), %eax
je 0xedf5f
movl %esi, %edi
incl %esi
cmpq 0x8(%rsp), %rdi
jb 0xedf45
jmp 0xedf5f
xorl %edi, %edi
cmpq 0x8(%rsp), %rdi
je 0xedfd6
movq (%r12), %rdi
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdi
jne 0xedfac
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r12)
movl 0xc(%r15), %edx
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%r12), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movq %rbx, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %rbp, %rsi
addq %r13, %rsi
orq %rdx, %rsi
leaq 0x1(%rdi), %rdx
movq %rdx, (%r12)
movq %rsi, (%rax,%rdi,8)
incq %r13
cmpq %r14, %r13
jne 0xedf15
movq (%rsp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rsp), %rsi
cmpl $0x0, (%rax,%rsi,8)
js 0xee115
cmpb $0x1, 0x4(%rax,%rsi,8)
je 0xee115
movl 0x24(%rsp), %ecx
xorl $0x1, %ecx
movq (%rsp), %rax
movq 0x28(%rax), %rax
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
testl %eax, %eax
je 0xee115
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbx
movl %eax, %r14d
xorl %r13d, %r13d
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
leaq (,%r13,2), %rax
addq %r13, %rax
movl 0xc(%rbx,%rax,8), %edx
testl %edx, %edx
js 0xee109
leaq (%rbx,%rax,8), %r15
cmpq $0x0, 0x8(%rsp)
je 0xee090
movl 0x8(%r15), %eax
shrl %eax
movl $0x1, %esi
xorl %edi, %edi
movq 0x18(%rsp), %r8
cmpl (%r8,%rdi,8), %eax
je 0xee092
movl %esi, %edi
incl %esi
cmpq 0x8(%rsp), %rdi
jb 0xee078
jmp 0xee092
xorl %edi, %edi
cmpq 0x8(%rsp), %rdi
je 0xee109
movq (%r12), %rdi
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdi
jne 0xee0df
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r12)
movl 0xc(%r15), %edx
movq (%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%r12), %rdi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movq %rbx, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %rbp, %rsi
addq %r13, %rsi
orq %rdx, %rsi
leaq 0x1(%rdi), %rdx
movq %rdx, (%r12)
movq %rsi, (%rax,%rdi,8)
incq %r13
cmpq %r14, %r13
jne 0xee048
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq