// File: /workspace/github_cpp_makefile_star2_O1/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
movl (%rdi), %ebp
movl 0x4(%rdi), %eax
movl %eax, 0x14(%rsp)
movq 0x10(%rdi), %r14
movq %rdi, 0x18(%rsp)
movl 0x8(%rdi), %eax
movl %eax, 0x10(%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 0xa6c77
movb $0x1, %bl
movq 0x20(%r14), %rax
movl %ebp, %r15d
shrl %r15d
cmpl $0x0, (%rax,%r15,8)
js 0xa6c6a
movq $0x0, 0x58(%rsp)
movq 0x30(%r14), %rax
movl %ebp, %r12d
cmpb $0x1, (%rax,%r12)
je 0xa6c4c
movq %r14, %rdi
movl %ebp, %esi
leaq 0xc(%rsp), %rdx
leaq 0x90(%rsp), %rcx
leaq 0x20(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xa401f
testl %eax, %eax
je 0xa6c4c
cmpq $0x0, 0x58(%rsp)
jle 0xa6c35
movl 0xc(%rsp), %eax
shrl %eax
xorl %ecx, %ecx
movq 0x68(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
cmpl %r15d, %edx
je 0xa6c2b
cmpl %eax, %edx
je 0xa6c2b
movq 0x30(%r14), %rsi
addl %edx, %edx
movb %bl, (%rsi,%rdx)
movq 0x30(%r14), %rdx
movq 0x68(%rsp), %rsi
movl (%rsi,%rcx,4), %esi
addl %esi, %esi
movb %bl, 0x1(%rdx,%rsi)
incq %rcx
cmpq 0x58(%rsp), %rcx
jl 0xa6bff
movq 0x30(%r14), %rax
movb %bl, (%rax,%r12)
movq 0x30(%r14), %rax
movl 0xc(%rsp), %ecx
xorq $0x1, %rcx
movb %bl, (%rax,%rcx)
cmpl $0x1, 0x10(%rsp)
jne 0xa6c6a
movq %r14, %rdi
movl %ebp, %esi
callq 0xa688c
testl %eax, %eax
je 0xa6c6a
movq 0x30(%r14), %rax
movb $0x2, (%rax,%r12)
addl 0x14(%rsp), %ebp
cmpl %r13d, %ebp
jb 0xa6b99
movq 0x68(%rsp), %rdi
callq 0x2220
movq 0x18(%rsp), %rdi
callq 0x2220
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq