// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: insert_arc(asg_t*, long long, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned char, unsigned char, unsigned char)
void insert_arc(asg_t *g, long long index, uint32_t m_distance, uint32_t src, uint32_t srcLen, uint32_t dest, 
uint32_t oLen, uint8_t strong, uint8_t el, uint8_t no_l_indel)
{
    asg_arc_t* p;
    uint32_t l;
    long long i;
    p = insert_index_p(g, index, m_distance);
    p->del = !!(0);p->el = el; p->no_l_indel = no_l_indel; p->strong = strong; p->ol = oLen;
    p->v = dest;
    p->ul = src; p->ul = p->ul << 32; l = srcLen - oLen; p->ul = p->ul | l;
    for (i = index - 1; i >= 0 && p->ul <= g->arc[i].ul; i--)
    {
        if((!g->arc[i].del)&&(g->arc[i].v==p->v) && ((g->arc[i].ul>>32)==(p->ul>>32)))
        {
            p->del = !!(1);
            break;
        }
        exchange_arcs(p, &(g->arc[i]));p = &(g->arc[i]);
    }
    

    if(asg_arc_n(g, src) == 0)
    {
        g->idx[src] = index; g->idx[src] = g->idx[src]<<32; g->idx[src] = g->idx[src] | 1;
    }
    else
    {
        g->idx[src] = g->idx[src] + 1;
    }
      
    uint32_t v, v_tx = g->n_seq*2;
    uint64_t add = 1; add = add << 32;
    for (v = src+1; v < v_tx; v++)
    {
        if(asg_arc_n(g, v) == 0) continue;
        g->idx[v] += add;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, 0xc(%rsp)
movl %r8d, %r12d
movl %ecx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movl 0x60(%rsp), %r13d
movb 0x68(%rsp), %bpl
callq 0xe8e2f
movb 0x70(%rsp), %cl
movb %cl, 0x12(%rax)
movzwl 0x10(%rax), %ecx
movl 0x78(%rsp), %edx
shll $0xf, %edx
andl $0x3fff, %ecx           # imm = 0x3FFF
orl %edx, %ecx
andb $0x1, %bpl
movzbl %bpl, %edx
shll $0xe, %edx
orl %ecx, %edx
movw %dx, 0x10(%rax)
subl %r13d, %r12d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movl %r13d, 0xc(%rax)
movl 0xc(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl %ebx, %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rdx, %r12
movq %r12, (%rax)
testq %r15, %r15
jle 0xe9014
leaq 0x1(%r15), %rdx
leaq (%r15,%r15,2), %rsi
leaq -0x18(,%rsi,8), %rsi
movq (%rax), %r9
movq 0x8(%r14), %rdi
movq (%rdi,%rsi), %r8
cmpq %r8, %r9
ja 0xe9014
cmpl $0x0, 0xc(%rdi,%rsi)
js 0xe8fc7
xorq %r9, %r8
shrq $0x20, %r8
jne 0xe8fc7
movl 0x8(%rax), %r8d
cmpl %r8d, 0x8(%rdi,%rsi)
je 0xe9010
addq %rsi, %rdi
movq 0x10(%rax), %r8
movq %r8, 0x20(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rdi), %r8
movq %r8, 0x10(%rax)
movups (%rdi), %xmm0
movups %xmm0, (%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rdi)
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rdi)
decq %rdx
movq %rsi, %rax
addq $-0x18, %rsi
addq 0x8(%r14), %rax
cmpq $0x1, %rdx
jg 0xe8f9c
jmp 0xe9014
orb $-0x80, 0xf(%rax)
movq 0x28(%r14), %rax
movq (%rax,%rcx,8), %rdx
movq %rdx, %rsi
incq %rsi
shlq $0x20, %r15
incq %r15
testl %edx, %edx
cmovneq %rsi, %r15
movq %r15, (%rax,%rcx,8)
movl 0x14(%r14), %ecx
addl %ecx, %ecx
leal 0x1(%rbx), %edx
cmpl %ecx, %edx
jae 0xe906c
movl %edx, %edx
leaq (%rax,%rdx,8), %rax
notl %ebx
addl %ecx, %ebx
xorl %ecx, %ecx
movabsq $0x100000000, %rdx      # imm = 0x100000000
movq (%rax,%rcx,8), %rsi
testl %esi, %esi
je 0xe9065
addq %rdx, %rsi
movq %rsi, (%rax,%rcx,8)
incq %rcx
cmpl %ecx, %ebx
jne 0xe9056
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq