// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: order_contig_trans(kv_u_trans_t*)
void order_contig_trans(kv_u_trans_t *in)
{
	utepdat_t s; uint64_t i, n_th = asm_opt.thread_num; memset(&s, 0, sizeof(s)); 
    CALLOC(s.hab, n_th); CALLOC(s.buf, n_th); CALLOC(s.ll, n_th); 
    CALLOC(s.gdp, n_th); CALLOC(s.mzs, n_th); CALLOC(s.sps, n_th); 

    for (i = 0; i < n_th; ++i) {
        s.hab[i] = ha_ovec_init(0, 0, 1); s.buf[i] = mg_tbuf_init();
    }

    ctdat_t c; memset(&c, 0, sizeof(c)); c.s = &(s); c.ta = in; 

    c.mm = 0; kt_for(n_th, worker_for_ctg_trans_order, &c, in->idx.n);
	c.mm = 1; kt_for(n_th, worker_for_ctg_trans_order, &c, in->idx.n);

    for (i = 0; i < n_th; ++i) {
        s.sum_len += s.hab[i]->num_read_base; s.n += s.hab[i]->num_correct_base;
        ha_ovec_destroy(s.hab[i]); mg_tbuf_destroy(s.buf[i]); hc_glchain_destroy(&(s.ll[i]));
        hc_gdpchain_destroy(&(s.gdp[i])); kv_destroy(s.mzs[i]); kv_destroy(s.sps[i]);
    }

    free(s.hab); free(s.buf); free(s.ll); free(s.gdp); free(s.mzs); free(s.sps);
    fprintf(stderr, "[M::%s::] # try:%d, # done:%d\n", __func__, s.sum_len, s.n); 

	uint64_t m;
	for (i = m = 0; i < in->n; i++) {
		if(in->a[i].del) continue;
		in->a[m++] = in->a[i];
	}
	in->n = m;
	kt_u_trans_t_idx(in, in->idx.n);
	c.mm = 2; kt_for(n_th, worker_for_ctg_trans_order, &c, in->idx.n);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x8(%rsp)
leaq 0xb7415(%rip), %rax     # 0x253758
movslq 0x7c(%rax), %rbx
leaq 0x10(%rsp), %r12
xorl %r14d, %r14d
movl $0xd0, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x20e0
pushq $0x8
popq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, %r13
movq %rax, 0x80(%r12)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, %rbp
movq %rax, 0x78(%r12)
pushq $0x68
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x88(%r12)
movl $0xc0, %esi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x90(%r12)
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x60(%r12)
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x68(%r12)
pushq $0x1
popq %r12
cmpq %r14, %rbx
je 0x19c3fc
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %edx
callq 0xc44b
movq %rax, (%r13,%r14,8)
callq 0x1588bc
movq %rax, (%rbp,%r14,8)
incq %r14
jmp 0x19c3d7
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %r12
movups %xmm0, 0x38(%r12)
movups %xmm0, 0x48(%r12)
movups %xmm0, 0x28(%r12)
movups %xmm0, 0x18(%r12)
movups %xmm0, 0x8(%r12)
leaq 0x10(%rsp), %rax
movq %rax, (%r12)
movq 0x8(%rsp), %r14
movq %r14, 0x38(%r12)
movq 0x18(%r14), %rcx
leaq 0x1bd(%rip), %r13       # 0x19c600
movl %ebx, %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0xc67c0
movq $0x1, 0x40(%r12)
movq 0x18(%r14), %rcx
movl %ebx, %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0xc67c0
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %rbx, %rbp
movq 0x90(%rsp), %rdi
subq $0x1, %rbp
jb 0x19c50b
movq (%rdi,%r13), %rdi
movl 0xf0(%rdi), %eax
addl %eax, 0x50(%rsp)
movl 0xf8(%rdi), %eax
addl %eax, 0x48(%rsp)
callq 0xc5d1
movq 0x88(%rsp), %rax
movq (%rax,%r13), %rdi
callq 0x1588d8
movq 0x98(%rsp), %rdi
addq %r12, %rdi
callq 0x15a8d7
movq 0xa0(%rsp), %rdi
addq %r14, %rdi
callq 0x15a905
movq 0x70(%rsp), %rax
movq 0x8(%rax,%r13,2), %rdi
callq 0x2220
movq 0x78(%rsp), %rax
movq (%rax,%r15,2), %rdi
callq 0x2220
addq $0xc, %r15
addq $0x8, %r13
addq $0x68, %r12
addq $0xc0, %r14
jmp 0x19c476
callq 0x2220
movq 0x88(%rsp), %rdi
callq 0x2220
movq 0x98(%rsp), %rdi
callq 0x2220
movq 0xa0(%rsp), %rdi
callq 0x2220
movq 0x70(%rsp), %rdi
callq 0x2220
movq 0x78(%rsp), %rdi
callq 0x2220
movq 0xb6a8e(%rip), %rax     # 0x252fe0
movq (%rax), %rdi
movl 0x48(%rsp), %r8d
movl 0x50(%rsp), %ecx
leaq 0x594c3(%rip), %rsi     # 0x1f5a28
leaq 0x5a3be(%rip), %rdx     # 0x1f692a
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x22b0
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x8(%rsp), %r15
cmpq (%r15), %rcx
jae 0x19c5bd
movq 0x10(%r15), %rdx
cmpb $0x0, 0x28(%rdx,%r14)
js 0x19c5b4
leaq (%rdx,%r14), %rsi
imulq $0x30, %rax, %rdi
incq %rax
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movups 0x20(%rsi), %xmm2
movups %xmm2, 0x20(%rdx,%rdi)
movups %xmm1, 0x10(%rdx,%rdi)
movups %xmm0, (%rdx,%rdi)
incq %rcx
addq $0x30, %r14
jmp 0x19c57f
movq %rax, (%r15)
movl 0x18(%r15), %esi
movq %r15, %rdi
callq 0x88a31
leaq 0xe0(%rsp), %rdx
movq $0x2, 0x40(%rdx)
movq 0x18(%r15), %rcx
leaq 0x19(%rip), %rsi        # 0x19c600
movl %ebx, %edi
callq 0xc67c0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq