// File: /workspace/github_cpp_makefile_star2_O1/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 %ecx, %ecx
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 %rcx, 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 %rcx, 0xc0(%rsp)
addl %eax, %eax
je 0xd327f
movq %rsi, %r13
movl %eax, %eax
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
movq 0x28(%r13), %rax
movq (%rax,%r12,8), %rcx
movq %rcx, %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rdx
je 0xd3271
movq 0x8(%r13), %rsi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rsi,%rcx,8), %rcx
addq $0xc, %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rcx,%rsi), %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %edi
addq $0x18, %rsi
cmpq %rsi, %rdx
jne 0xd2ff7
testl %edi, %edi
je 0xd3271
movl %r12d, %ebx
xorl $0x1, %ebx
movq (%rax,%rbx,8), %rax
movq %rax, %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rcx
je 0xd3271
movq 0x8(%r13), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,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 0xd3051
testl %esi, %esi
je 0xd3271
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 0x10109f
addq $0x20, %rsp
cmpl $0x3, %eax
jne 0xd3271
movl (%rsp), %ecx
movq 0x28(%r13), %rax
movq (%rax,%rcx,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0xd30f1
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 0xd30e8
movl -0x4(%rdx,%rsi), %edi
movl %edi, (%rsp)
addq $0x18, %rsi
cmpq %rsi, %rcx
jne 0xd30db
movq (%rax,%r12,8), %rax
testl %eax, %eax
je 0xd3271
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %r15
shlq $0x3, %r15
addq 0x8(%r13), %r15
movl %eax, %eax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpl $0x0, 0xc(%r15,%rax,8)
js 0xd3263
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 0x10109f
addq $0x20, %rsp
cmpl $0x3, %eax
jne 0xd3263
movl 0x4(%rsp), %eax
movq 0x28(%r13), %rcx
movq (%rcx,%rax,8), %rcx
movq %rcx, %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
andq %rdx, %rax
je 0xd31bf
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 $0x0, (%rcx,%rdx)
js 0xd31b6
movl -0x4(%rcx,%rdx), %esi
movl %esi, 0x4(%rsp)
addq $0x18, %rdx
cmpq %rdx, %rax
jne 0xd31a8
movl 0x4(%rsp), %eax
cmpl (%rsp), %eax
jne 0xd3263
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 0x1015d1
addq $0x30, %rsp
testl %eax, %eax
jne 0xd3263
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 0xd3263
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 0xd325a
orb $-0x80, 0x3(%rcx,%rdx)
addq $0x18, %rdx
cmpq %rdx, %rax
jne 0xd324f
incq %rbp
cmpq 0x38(%rsp), %rbp
jne 0xd3119
incq %r12
cmpq 0x30(%rsp), %r12
jne 0xd2fbe
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