// File: /workspace/github_cpp_makefile_star2_O2/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, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movl 0x14(%rsi), %eax
addl %eax, %eax
movq %rax, 0x38(%rsp)
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rax
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
andq $0x0, 0x60(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x50(%rax)
leaq 0x60(%rsp), %rax
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x50(%rax)
andq $0x0, 0x60(%rax)
xorl %ebx, %ebx
cmpq 0x38(%rsp), %rbx
je 0x97cc9
movq %r13, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
je 0x97cc1
movl %ebx, %r14d
xorl $0x1, %r14d
movq %r13, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
je 0x97cc1
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl %r14d, %edx
leaq 0x8(%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 0xc2ebf
addq $0x20, %rsp
cmpl $0x3, %eax
jne 0x97cc1
movl 0x8(%rsp), %esi
movq %r13, %rdi
leaq 0x8(%rsp), %rdx
callq 0xc2e7a
movq 0x8(%r13), %rax
movq 0x28(%r13), %rcx
movq (%rcx,%rbx,8), %rcx
movl %ecx, %edx
shrq $0x20, %rcx
imulq $0x18, %rdx, %r15
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %r12
addq $0xc, %r12
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x97cc1
cmpl $0x0, (%r12,%rbp)
js 0x97cb8
movl -0x4(%r12,%rbp), %edx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
leaq 0xc(%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 0xc2ebf
addq $0x20, %rsp
cmpl $0x3, %eax
jne 0x97cb8
movl 0xc(%rsp), %esi
movq %r13, %rdi
leaq 0xc(%rsp), %rdx
callq 0xc2e7a
movl 0xc(%rsp), %eax
cmpl 0x8(%rsp), %eax
jne 0x97cb8
movl -0x4(%r12,%rbp), %r8d
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl %r14d, %ecx
movq 0x20(%rsp), %r9
pushq $0x1
pushq $0x2
pushq 0x40(%rsp)
pushq 0x40(%rsp)
leaq 0x80(%rsp), %rax
pushq %rax
leaq 0xf8(%rsp), %rax
pushq %rax
callq 0xc3307
addq $0x30, %rsp
testl %eax, %eax
jne 0x97cb8
orb $-0x80, 0x3(%r12,%rbp)
movl -0x4(%r12,%rbp), %esi
xorl $0x1, %esi
movq %r13, %rdi
movl %r14d, %edx
pushq $0x1
popq %rcx
callq 0x6db50
addq $0x18, %rbp
jmp 0x97bee
incq %rbx
jmp 0x97b42
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