// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movq %rdi, %rbx
movl (%rdi), %ebp
movl 0x4(%rdi), %eax
movl %eax, 0x10(%rsp)
movq 0x10(%rdi), %r14
movl 0x8(%rdi), %eax
movl %eax, 0xc(%rsp)
movl 0x14(%r14), %r13d
addl %r13d, %r13d
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x80(%rsp)
cmpl %r13d, %ebp
jae 0xa7cc3
movq %rbx, 0x18(%rsp)
movb $0x1, %bl
movq 0x20(%r14), %rax
movl %ebp, %r15d
shrl %r15d
cmpl $0x0, (%rax,%r15,8)
js 0xa7caa
movq $0x0, 0x58(%rsp)
movq 0x30(%r14), %rax
movl %ebp, %r12d
cmpb $0x1, (%rax,%r12)
je 0xa7c8c
movq %r14, %rdi
movl %ebp, %esi
leaq 0x14(%rsp), %rdx
leaq 0x90(%rsp), %rcx
leaq 0x20(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xa50af
testl %eax, %eax
je 0xa7c8c
movq 0x58(%rsp), %rsi
movl 0x14(%rsp), %eax
testq %rsi, %rsi
jle 0xa7c79
movl %eax, %ecx
shrl %ecx
xorl %edx, %edx
movq 0x68(%rsp), %rdi
movl (%rdi,%rdx,4), %edi
cmpl %r15d, %edi
je 0xa7c71
cmpl %ecx, %edi
je 0xa7c71
movq 0x30(%r14), %rsi
addl %edi, %edi
movb %bl, (%rsi,%rdi)
movq 0x30(%r14), %rsi
movq 0x68(%rsp), %rdi
movl (%rdi,%rdx,4), %edi
addl %edi, %edi
movb %bl, 0x1(%rsi,%rdi)
movq 0x58(%rsp), %rsi
incq %rdx
cmpq %rsi, %rdx
jl 0xa7c40
movq 0x30(%r14), %rcx
movb %bl, (%rcx,%r12)
movq 0x30(%r14), %rcx
xorq $0x1, %rax
movb %bl, (%rcx,%rax)
cmpl $0x1, 0xc(%rsp)
jne 0xa7caa
movq %r14, %rdi
movl %ebp, %esi
callq 0xa78a4
testl %eax, %eax
je 0xa7caa
movq 0x30(%r14), %rax
movb $0x2, (%rax,%r12)
addl 0x10(%rsp), %ebp
cmpl %r13d, %ebp
jb 0xa7bd6
movq 0x68(%rsp), %rdi
movq 0x18(%rsp), %rbx
jmp 0xa7cc5
xorl %edi, %edi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq