// File: /workspace/github_cpp_makefile_star2_O2/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 0xabe4a
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)
imulq $0x18, %r15, %rdx
addq $-0x18, %rdx
movq %r15, %rsi
testq %rsi, %rsi
jle 0xac01a
movq (%rax), %r9
movq 0x8(%r14), %rdi
movq (%rdi,%rdx), %r8
cmpq %r8, %r9
ja 0xac01a
cmpl $0x0, 0xc(%rdi,%rdx)
js 0xabfd3
xorq %r9, %r8
shrq $0x20, %r8
jne 0xabfd3
movl 0x8(%rax), %r8d
cmpl %r8d, 0x8(%rdi,%rdx)
je 0xac016
addq %rdx, %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)
movq %rdx, %rax
addq $-0x18, %rdx
addq 0x8(%r14), %rax
decq %rsi
jmp 0xabfa3
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
incl %ebx
movabsq $0x100000000, %rdx      # imm = 0x100000000
cmpl %ecx, %ebx
jae 0xac063
movq (%rax,%rbx,8), %rsi
testl %esi, %esi
je 0xac05e
addq %rdx, %rsi
movq %rsi, (%rax,%rbx,8)
incq %rbx
jmp 0xac04b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq