// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: asg_arc_identify_simple_bubbles_pthread(void*)
void* asg_arc_identify_simple_bubbles_pthread(void* arg)
{
    int thr_ID = ((para_for_simple_bub*)arg)->threadID;
    int thr_num = ((para_for_simple_bub*)arg)->thread_num;
    asg_t *g = ((para_for_simple_bub*)arg)->g;
    int check_cross = ((para_for_simple_bub*)arg)->check_cross;
    ///the reason is that each read has two direction (query->target, target->query)    

	uint32_t v, w, n_vtx = g->n_seq * 2;
    buf_t b;
    memset(&b, 0, sizeof(buf_t));
    long long l, i;
    ///for (v = 0; v < n_vtx; ++v)
    for (v = thr_ID; v < n_vtx; v = v + thr_num) 
    {
        if (g->seq[v>>1].del) continue;

        b.b.n = 0;

        if(g->seq_vis[v] != 1)
        {
            ///if(detect_bubble_with_bubbles(g, v, &w, &l, &b, (uint32_t)-1))
            if(detect_bubble_with_bubbles(g, v, &w, &l, &b, SMALL_BUBBLE_SIZE))
            {
                for (i = 0; i < (long long)b.b.n; i++)
                {
                    if(b.b.a[i] != (v>>1) && b.b.a[i] != (w>>1))
                    {
                        g->seq_vis[b.b.a[i]<<1] = 1;
                        g->seq_vis[(b.b.a[i]<<1) + 1] = 1;
                    }
                }
                g->seq_vis[v] = 1;
                g->seq_vis[w^1] = 1;
            }
        }

        if(check_cross == 1 && check_if_cross(g, v))
        {
            g->seq_vis[v] = 2;
        }
    }
    free(b.b.a);

    free(arg);

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl (%rdi), %ebp
movl 0x4(%rdi), %eax
movl %eax, 0x8(%rsp)
movq 0x10(%rdi), %r14
movq %rdi, 0x10(%rsp)
movl 0x8(%rdi), %eax
movl %eax, 0x4(%rsp)
movl 0x14(%r14), %ebx
addl %ebx, %ebx
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rax
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
andq $0x0, 0x60(%rax)
movb $0x1, %r15b
cmpl %ebx, %ebp
jae 0x6ee36
movq 0x20(%r14), %rax
movl %ebp, %r12d
shrl %r12d
cmpl $0x0, (%rax,%r12,8)
js 0x6ee2d
andq $0x0, 0x58(%rsp)
movq 0x30(%r14), %rax
movl %ebp, %r13d
cmpb $0x1, (%rax,%r13)
je 0x6ee0f
movq %r14, %rdi
movl %ebp, %esi
leaq 0xc(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x20(%rsp), %r8
pushq $-0x1
popq %r9
callq 0x6d021
testl %eax, %eax
je 0x6ee0f
movl 0xc(%rsp), %eax
movl %eax, %ecx
shrl %ecx
xorl %edx, %edx
cmpq 0x58(%rsp), %rdx
jge 0x6edfb
movq 0x68(%rsp), %rsi
movl (%rsi,%rdx,4), %esi
cmpl %r12d, %esi
sete %dil
cmpl %ecx, %esi
sete %r8b
orb %dil, %r8b
jne 0x6edf6
movq 0x30(%r14), %rdi
addl %esi, %esi
movb %r15b, (%rdi,%rsi)
movq 0x30(%r14), %rsi
movq 0x68(%rsp), %rdi
movl (%rdi,%rdx,4), %edi
addl %edi, %edi
movb %r15b, 0x1(%rsi,%rdi)
incq %rdx
jmp 0x6edb8
movq 0x30(%r14), %rcx
movb %r15b, (%rcx,%r13)
movq 0x30(%r14), %rcx
xorq $0x1, %rax
movb %r15b, (%rcx,%rax)
cmpl $0x1, 0x4(%rsp)
jne 0x6ee2d
movq %r14, %rdi
movl %ebp, %esi
callq 0x6eb1d
testl %eax, %eax
je 0x6ee2d
movq 0x30(%r14), %rax
movb $0x2, (%rax,%r13)
addl 0x8(%rsp), %ebp
jmp 0x6ed58
movq 0x68(%rsp), %rdi
callq 0x2220
movq 0x10(%rsp), %rdi
callq 0x2220
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq