// File: 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
movq %rsp, %rbp
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x40(%rbp)
movq $0x0, -0x78(%rbp)
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x11d9be
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x0, %eax
jne 0x11d790
jmp 0x11d9b0
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x0, %eax
jne 0x11d7ad
jmp 0x11d9b0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x3c(%rbp), %edx
xorl $0x1, %edx
leaq -0x48(%rbp), %rcx
leaq -0x58(%rbp), %r8
leaq -0x60(%rbp), %r9
leaq -0x68(%rbp), %r10
leaq -0x70(%rbp), %rax
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0x166c30
cmpl $0x3, %eax
je 0x11d7fb
jmp 0x11d9b0
movq -0x18(%rbp), %rdi
movl -0x48(%rbp), %esi
leaq -0x48(%rbp), %rdx
callq 0x166b50
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x3c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x3c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jae 0x11d9ae
movq -0x78(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x11d874
jmp 0x11d9a0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
leaq -0x44(%rbp), %rcx
leaq -0x58(%rbp), %r8
leaq -0x60(%rbp), %r9
leaq -0x68(%rbp), %r10
leaq -0x70(%rbp), %rax
xorl %r11d, %r11d
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0x166c30
cmpl $0x3, %eax
je 0x11d8cd
jmp 0x11d9a0
movq -0x18(%rbp), %rdi
movl -0x44(%rbp), %esi
leaq -0x44(%rbp), %rdx
callq 0x166b50
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x11d8ea
jmp 0x11d9a0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x3c(%rbp), %ecx
xorl $0x1, %ecx
movq -0x78(%rbp), %rax
movl -0x4c(%rbp), %r8d
imulq $0x18, %r8, %r8
addq %r8, %rax
movl 0x8(%rax), %r8d
movq -0x28(%rbp), %r9
movq -0x30(%rbp), %r10
movq -0x38(%rbp), %rax
leaq -0xe0(%rbp), %rbx
leaq -0x148(%rbp), %r11
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movl $0x2, 0x20(%rsp)
movl $0x1, 0x28(%rsp)
callq 0x1674d0
cmpl $0x0, %eax
jne 0x11d99e
movq -0x78(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
xorl $0x1, %esi
movl -0x3c(%rbp), %edx
xorl $0x1, %edx
movl $0x1, %ecx
callq 0xd6530
jmp 0x11d9a0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x11d84a
jmp 0x11d9b0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x11d76a
movq -0x98(%rbp), %rdi
callq 0x2210
movq -0x100(%rbp), %rdi
callq 0x2210
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %rbp
retq