// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: asg_arc_identify_simple_bubbles_multi_back(asg_t*, int)
int asg_arc_identify_simple_bubbles_multi_back(asg_t *g, int check_cross)
{
    double startTime = Get_T();
    memset(g->seq_vis, 0, g->n_seq*2*sizeof(uint8_t));

    pthread_t *_r_threads;

	_r_threads = (pthread_t *)malloc(sizeof(pthread_t)*asm_opt.thread_num);

    int i = 0;

	for (i = 0; i < asm_opt.thread_num; i++)
	{
        para_for_simple_bub* arg = (para_for_simple_bub*)malloc(sizeof(*arg));
        arg->g = g;
        arg->thread_num = asm_opt.thread_num;
        arg->threadID = i;
        arg->check_cross = check_cross;

        pthread_create(_r_threads + i, NULL, asg_arc_identify_simple_bubbles_pthread, (void*)arg);
	}
    

    for (i = 0; i<asm_opt.thread_num; i++)
		pthread_join(_r_threads[i], NULL);


    free(_r_threads);

    uint32_t v, n_vtx = g->n_seq * 2;
    long long nodes, bub_nodes, cross_nodes;
    bub_nodes = nodes = cross_nodes = 0;
    for (v = 0; v < n_vtx; ++v) 
    {
        if (g->seq[v>>1].del) continue;
        nodes++;
        if(g->seq_vis[v] == 1) bub_nodes++;
        if(g->seq_vis[v] == 2) cross_nodes++;
    }


    if(VERBOSE >= 1)
    {
        fprintf(stderr, "[M::%s] takes %0.2f s\n\n", __func__, Get_T()-startTime);
    }
    return bub_nodes+cross_nodes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
callq 0x2510
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movslq %eax, %rdx
shlq $0x0, %rdx
xorl %esi, %esi
callq 0x2100
leaq 0x2ec444(%rip), %rax    # 0x3c47f8
movslq 0x7c(%rax), %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0x2ec41b(%rip), %rcx    # 0x3c47f8
cmpl 0x7c(%rcx), %eax
jge 0xd844e
movl $0x18, %edi
callq 0x2270
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0x2ec3f5(%rip), %rax    # 0x3c47f8
movl 0x7c(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x24(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0xc(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rdi
movslq -0x24(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x2ce(%rip), %rdx      # 0xd8170
callq 0x23b0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd83d3
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0x2ec399(%rip), %rcx    # 0x3c47f8
cmpl 0x7c(%rcx), %eax
jge 0xd8484
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2190
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xd8455
movq -0x20(%rbp), %rdi
callq 0x2210
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x38(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0xd853a
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x34(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0xd84e1
jmp 0xd852f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x34(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0xd850d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x34(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0xd852d
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xd852f
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xd84bd
movq -0x48(%rbp), %rax
addq -0x50(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)