// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: drop_semi_circle(ma_ug_t*, asg_t*, asg_t*, ma_hit_t_alloc*, R_to_U*, unsigned char*)
void drop_semi_circle(ma_ug_t *ug, asg_t* nsg, asg_t* read_g, ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex, uint8_t* is_r_het)
{
    uint32_t v, n_vtx = nsg->n_seq*2, convex_f, convex_b, i, nv;
    long long ll, tmp, max_stop_nodeLen, max_stop_baseLen;
    asg_arc_t *av = NULL;
    buf_t b_0, b_1;
    memset(&b_0, 0, sizeof(buf_t));
    memset(&b_1, 0, sizeof(buf_t));

    for (v = 0; v < n_vtx; ++v) 
    {
        if(get_real_length(nsg, v, NULL) == 0) continue;
        if(get_real_length(nsg, v^1, NULL) == 0) continue;

        if(get_unitig(nsg, ug, v^1, &convex_b, &ll, &tmp, &max_stop_nodeLen, &max_stop_baseLen, 
                    1, NULL)!=MUL_INPUT)
        {
            continue;
        }

        get_real_length(nsg, convex_b, &convex_b);

        av = asg_arc_a(nsg, v);
        nv = asg_arc_n(nsg, v);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;

            if(get_unitig(nsg, ug, av[i].v, &convex_f, &ll, &tmp, &max_stop_nodeLen, &max_stop_baseLen, 
                    1, NULL)!=MUL_INPUT)
            {
                continue;
            }
            get_real_length(nsg, convex_f, &convex_f);
            if(convex_f != convex_b) continue;
            if(check_different_haps(nsg, ug, read_g, v^1, av[i].v, 
            reverse_sources, &b_0, &b_1, ruIndex, is_r_het, 2, 1) == PLOID)
            {
                av[i].del = 1;
		        asg_arc_del(nsg, av[i].v^1, v^1, 1);
            }
        }
        
    }

    free(b_0.b.a);
    free(b_1.b.a);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r9, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movl 0x14(%rsi), %eax
xorl %edi, %edi
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x120(%rsp)
movq %rdi, 0x130(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movq %rdi, 0xc0(%rsp)
addl %eax, %eax
je 0xd4692
movq %rsi, %r13
movl %eax, %eax
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
movq 0x28(%r13), %rcx
movq (%rcx,%r12,8), %rdx
movq %rdx, %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rsi
je 0xd467c
movq 0x8(%r13), %rax
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rdx
addq $0xc, %rdx
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rdx,%rdi), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %r8d
addq $0x18, %rdi
cmpq %rdi, %rsi
jne 0xd440b
testl %r8d, %r8d
je 0xd467c
movl %r12d, %ebx
xorl $0x1, %ebx
movq (%rcx,%rbx,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0xd467c
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xd4462
testl %esi, %esi
je 0xd467c
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movl %ebx, %edx
movq %rsp, %rcx
leaq 0x58(%rsp), %r8
leaq 0x50(%rsp), %r9
pushq $0x0
pushq $0x1
leaq 0x50(%rsp), %rax
pushq %rax
leaq 0x60(%rsp), %rax
pushq %rax
callq 0x1053a7
addq $0x20, %rsp
cmpl $0x3, %eax
jne 0xd467c
movl (%rsp), %edx
movq 0x8(%r13), %rax
movq 0x28(%r13), %rcx
movq (%rcx,%rdx,8), %rsi
movq %rsi, %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
andq %rdi, %rdx
je 0xd4504
shrq $0x20, %rsi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rsi,%rsi,2), %rsi
leaq (%rax,%rsi,8), %rsi
addq $0xc, %rsi
xorl %edi, %edi
cmpl $0x0, (%rsi,%rdi)
js 0xd44fb
movl -0x4(%rsi,%rdi), %r8d
movl %r8d, (%rsp)
addq $0x18, %rdi
cmpq %rdi, %rdx
jne 0xd44ec
movq (%rcx,%r12,8), %rcx
testl %ecx, %ecx
je 0xd467c
movq %rcx, %rdx
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %r15
movl %ecx, %eax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpl $0x0, 0xc(%r15,%rax,8)
js 0xd466e
leaq (%r15,%rax,8), %r14
movl 0x8(%r14), %edx
movq %r13, %rdi
movq 0x8(%rsp), %rsi
leaq 0x4(%rsp), %rcx
leaq 0x58(%rsp), %r8
leaq 0x50(%rsp), %r9
pushq $0x0
pushq $0x1
leaq 0x50(%rsp), %rax
pushq %rax
leaq 0x60(%rsp), %rax
pushq %rax
callq 0x1053a7
addq $0x20, %rsp
cmpl $0x3, %eax
jne 0xd466e
movl 0x4(%rsp), %eax
movq 0x28(%r13), %rcx
movq (%rcx,%rax,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0xd45ce
movq 0x8(%r13), %rsi
shrq $0x20, %rdx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rdx,2), %rdx
leaq (%rsi,%rdx,8), %rdx
addq $0xc, %rdx
xorl %esi, %esi
cmpl $0x0, (%rdx,%rsi)
js 0xd45c5
movl -0x4(%rdx,%rsi), %eax
movl %eax, 0x4(%rsp)
addq $0x18, %rsi
cmpq %rsi, %rcx
jne 0xd45b7
cmpl (%rsp), %eax
jne 0xd466e
movl 0x8(%r14), %r8d
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movl %ebx, %ecx
movq 0x18(%rsp), %r9
pushq $0x1
pushq $0x2
pushq 0x38(%rsp)
pushq 0x38(%rsp)
leaq 0x80(%rsp), %rax
pushq %rax
leaq 0xf8(%rsp), %rax
pushq %rax
callq 0x105913
addq $0x30, %rsp
testl %eax, %eax
jne 0xd466e
orb $-0x80, 0xf(%r14)
movl 0x8(%r14), %eax
xorq $0x1, %rax
movq 0x28(%r13), %rcx
movq (%rcx,%rax,8), %rcx
movq %rcx, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rax
je 0xd466e
movq 0x8(%r13), %rdx
shrq $0x20, %rcx
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rcx
addq $0xc, %rcx
xorl %edx, %edx
cmpl %ebx, -0x4(%rcx,%rdx)
jne 0xd4665
orb $-0x80, 0x3(%rcx,%rdx)
addq $0x18, %rdx
cmpq %rdx, %rax
jne 0xd465a
incq %rbp
cmpq 0x38(%rsp), %rbp
jne 0xd4528
incq %r12
cmpq 0x30(%rsp), %r12
jne 0xd43d1
movq 0x118(%rsp), %rdi
callq 0x2220
movq 0xa8(%rsp), %rdi
callq 0x2220
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq