// File: /workspace/github_cpp_makefile_star2_O2/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 %rcx, %r15
movq %rdx, %r13
movq %rdi, %r12
movq 0x78(%rsp), %rax
movq 0x70(%rsp), %rcx
andq $0x0, (%rdi)
movq %rsi, (%rsp)
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, (%rcx)
movl %r9d, 0x1c(%rsp)
movl %r9d, %ecx
shrl %ecx
movq %rcx, 0x10(%rsp)
movzbl 0x4(%rdx,%rcx,8), %ecx
movl %ecx, (%rax)
xorl %ebp, %ebp
pushq $0x18
popq %r9
movq %r15, 0x30(%rsp)
movq %r13, 0x28(%rsp)
movl %ebp, %ebp
cmpq %r15, %rbp
jae 0xaf045
movl (%r13,%rbp,8), %edx
movq (%rsp), %rax
movq 0x20(%rax), %rax
movb 0x4(%rax,%rdx,8), %cl
movzbl %cl, %ecx
movl %ecx, 0x4(%r13,%rbp,8)
cmpl $0x0, (%rax,%rdx,8)
sets %al
cmpb $0x1, %cl
sete %cl
orb %al, %cl
je 0xaeed7
incl %ebp
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
jmp 0xaee94
addl %edx, %edx
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rax
movq %rdx, 0x8(%rsp)
movq (%rax,%rdx,8), %rax
movl %eax, %r14d
shrq $0x20, %rax
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %r13
leaq (%rcx,%rax), %r15
addq $0xc, %r15
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0xaef91
movl (%r15), %esi
testl %esi, %esi
js 0xaef85
movq (%r12), %r8
movq 0x10(%r12), %rdi
cmpq 0x8(%r12), %r8
jne 0xaef5e
leaq (%r8,%r8), %rsi
testq %r8, %r8
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
callq 0x2370
pushq $0x18
popq %r9
movq %rax, %rdi
movq %rax, 0x10(%r12)
movl (%r15), %esi
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq (%r12), %r8
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x20, %rsi
movq %r13, %rax
subq %rcx, %rax
cqto
idivq %r9
addq %rbx, %rax
orq %rsi, %rax
leaq 0x1(%r8), %rdx
movq %rdx, (%r12)
movq %rax, (%rdi,%r8,8)
incq %rbx
addq $0x18, %r15
jmp 0xaef07
movq (%rsp), %rax
movq 0x28(%rax), %rax
movl 0x8(%rsp), %edx
movq 0x8(%rax,%rdx,8), %rax
movl %eax, %ebx
shrq $0x20, %rax
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %r14
leaq (%rcx,%rax), %r15
addq $0xc, %r15
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0xaeec9
movl (%r15), %esi
testl %esi, %esi
js 0xaf039
movq (%r12), %r8
movq 0x10(%r12), %rdi
cmpq 0x8(%r12), %r8
jne 0xaf012
leaq (%r8,%r8), %rsi
testq %r8, %r8
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
callq 0x2370
pushq $0x18
popq %r9
movq %rax, %rdi
movq %rax, 0x10(%r12)
movl (%r15), %esi
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq (%r12), %r8
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x20, %rsi
movq %r14, %rax
subq %rcx, %rax
cqto
idivq %r9
addq %r13, %rax
orq %rsi, %rax
leaq 0x1(%r8), %rdx
movq %rdx, (%r12)
movq %rax, (%rdi,%r8,8)
incq %r13
addq $0x18, %r15
jmp 0xaefbb
movq (%rsp), %rax
movq 0x20(%rax), %rax
movq 0x20(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,8)
js 0xaf156
cmpb $0x1, 0x4(%rax,%rcx,8)
movq 0x10(%rsp), %rcx
je 0xaf15b
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rax
movl 0x18(%rsp), %edx
movq (%rax,%rdx,8), %rax
movl %eax, %r10d
shrq $0x20, %rax
imulq $0x18, %rax, %rbp
addq %rcx, %rbp
xorl %ebx, %ebx
movq %r10, 0x8(%rsp)
cmpq %r10, %rbx
je 0xaf14e
imulq $0x18, %rbx, %r14
movl 0xc(%rbp,%r14), %esi
testl %esi, %esi
js 0xaf146
addq %rbp, %r14
xorl %edx, %edx
movq %rdx, %rax
cmpl %r15d, %eax
jae 0xaf0cd
movl 0x8(%r14), %edi
shrl %edi
leaq 0x1(%rax), %rdx
cmpl (%r13,%rax,8), %edi
jne 0xaf0b4
cmpq %rax, %r15
je 0xaf146
movq (%r12), %r8
movq 0x10(%r12), %rdi
cmpq 0x8(%r12), %r8
jne 0xaf11f
leaq (%r8,%r8), %rsi
testq %r8, %r8
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %r10
pushq $0x18
popq %r9
movq %rax, %rdi
movq %rax, 0x10(%r12)
movl 0xc(%r14), %esi
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq (%r12), %r8
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x20, %rsi
movq %rbp, %rax
subq %rcx, %rax
cqto
idivq %r9
addq %rbx, %rax
orq %rsi, %rax
leaq 0x1(%r8), %rdx
movq %rdx, (%r12)
movq %rax, (%rdi,%r8,8)
incq %rbx
jmp 0xaf095
movq (%rsp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,8)
js 0xaf168
cmpb $0x1, 0x4(%rax,%rcx,8)
jne 0xaf177
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x1c(%rsp), %edx
xorl $0x1, %edx
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rax
movl %edx, %edx
movq (%rax,%rdx,8), %rax
movl %eax, %r10d
shrq $0x20, %rax
imulq $0x18, %rax, %rbp
addq %rcx, %rbp
xorl %ebx, %ebx
movq %r10, 0x8(%rsp)
cmpq %r10, %rbx
je 0xaf168
imulq $0x18, %rbx, %r14
movl 0xc(%rbp,%r14), %esi
testl %esi, %esi
js 0xaf250
addq %rbp, %r14
xorl %edx, %edx
movl %edx, %eax
cmpq %r15, %rax
jae 0xaf1d7
movl 0x8(%r14), %edi
shrl %edi
leal 0x1(%rax), %edx
cmpl (%r13,%rax,8), %edi
jne 0xaf1c0
cmpq %r15, %rax
je 0xaf250
movq (%r12), %r8
movq 0x10(%r12), %rdi
cmpq 0x8(%r12), %r8
jne 0xaf229
leaq (%r8,%r8), %rsi
testq %r8, %r8
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
callq 0x2370
movq 0x8(%rsp), %r10
pushq $0x18
popq %r9
movq %rax, %rdi
movq %rax, 0x10(%r12)
movl 0xc(%r14), %esi
movq (%rsp), %rax
movq 0x8(%rax), %rcx
movq (%r12), %r8
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x20, %rsi
movq %rbp, %rax
subq %rcx, %rax
cqto
idivq %r9
addq %rbx, %rax
orq %rsi, %rax
leaq 0x1(%r8), %rdx
movq %rdx, (%r12)
movq %rax, (%rdi,%r8,8)
incq %rbx
jmp 0xaf1a5