// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movb 0x28(%rbp), %al
movb 0x20(%rbp), %al
movb 0x18(%rbp), %al
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x141750
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movb 0x20(%rbp), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x12(%rax)
movzbl 0x28(%rbp), %eax
movw %ax, %dx
movq -0x28(%rbp), %rax
movw 0x10(%rax), %cx
andw $0x1, %dx
shlw $0xf, %dx
andw $0x7fff, %cx            # imm = 0x7FFF
orw %dx, %cx
movw %cx, 0x10(%rax)
movzbl 0x18(%rbp), %eax
movw %ax, %dx
movq -0x28(%rbp), %rax
movw 0x10(%rax), %cx
andw $0x1, %dx
shlw $0xe, %dx
andw $0xbfff, %cx            # imm = 0xBFFF
orw %dx, %cx
movw %cx, 0x10(%rax)
movl 0x10(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0xc(%rax)
movl -0x20(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x18(%rbp), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
subl 0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movl -0x2c(%rbp), %eax
orq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x38(%rbp)
movb %al, -0x49(%rbp)
jl 0x141a19
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
imulq $0x18, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
setbe %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x141a25
jmp 0x141ad9
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x141a9b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x141a9b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
jne 0x141a9b
movq -0x28(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
jmp 0x141ad9
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
imulq $0x18, -0x38(%rbp), %rax
addq %rax, %rsi
callq 0x141870
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1419ed
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, %eax
jne 0x141b46
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
orq $0x1, %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x141b68
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x40(%rbp)
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x48(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x141bd6
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x3c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, %eax
jne 0x141bb4
jmp 0x141bcb
movq -0x48(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x3c(%rbp), %ecx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x141b96
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)