// File: /workspace/github_cpp_makefile_star2_O1/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 0x261aeb(%rip), %rax    # 0x28a758
movslq 0x7c(%rax), %rbp
leaq 0x10(%rsp), %r14
movl $0xd0, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20e0
pushq $0x8
popq %r15
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, 0x80(%r14)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, 0x78(%r14)
pushq $0x68
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x88(%r14)
movl $0xc0, %esi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x90(%r14)
pushq $0x10
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x60(%r14)
pushq $0x18
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x68(%r14)
testq %rbp, %rbp
je 0x28d3f
xorl %ebx, %ebx
pushq $0x1
popq %r13
pushq $0x10
popq %r12
xorl %edi, %edi
xorl %esi, %esi
pushq $0x1
popq %rdx
callq 0x39240
movq 0x90(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
movq %r13, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, %r14
callq 0x1e35d3
movq %rax, (%r14)
movq 0x88(%rsp), %rax
movq %r14, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %rbp
jne 0x28cfd
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %r14
movaps %xmm0, (%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x40(%r14)
andq $0x0, 0x50(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
leaq 0x10(%rsp), %rax
movq %rax, (%r14)
movq 0x8(%rsp), %rbx
movq %rbx, 0x38(%r14)
andq $0x0, 0x40(%r14)
movq 0x18(%rbx), %rcx
leaq 0x1b42b5(%rip), %r12    # 0x1dd03d
movl %ebp, %edi
movq %r12, %rsi
movq %r14, %rdx
callq 0x1047b4
movq $0x1, 0x40(%r14)
movq 0x18(%rbx), %rcx
movl %ebp, %edi
movq %r12, %rsi
movq %r14, %rdx
callq 0x1047b4
testl %ebp, %ebp
movq %rbp, %rbx
je 0x28e54
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %rbx, %rbp
movq 0x90(%rsp), %rax
movq (%rax,%r14), %rdi
movl 0xf0(%rdi), %eax
addl %eax, 0x50(%rsp)
movl 0xf8(%rdi), %eax
addl %eax, 0x48(%rsp)
callq 0x395cd
movq 0x88(%rsp), %rax
movq (%rax,%r14), %rdi
callq 0x196f11
movq 0x98(%rsp), %rdi
addq %r12, %rdi
callq 0x19912e
movq 0xa0(%rsp), %rdi
addq %r13, %rdi
callq 0x19915c
movq 0x70(%rsp), %rax
movq 0x8(%rax,%r14,2), %rdi
callq 0x2220
movq 0x78(%rsp), %rax
movq (%rax,%r15,2), %rdi
callq 0x2220
addq $0xc0, %r13
addq $0x68, %r12
addq $0x8, %r14
addq $0xc, %r15
decq %rbp
jne 0x28dc5
movq 0x90(%rsp), %rdi
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 0x26113d(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movl 0x48(%rsp), %r8d
movl 0x50(%rsp), %ecx
leaq 0x20e9da(%rip), %rsi    # 0x237890
leaq 0x20f8d5(%rip), %rdx    # 0x238792
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %r15
cmpq $0x0, (%r15)
je 0x28f14
xorl %eax, %eax
xorl %r14d, %r14d
xorl %ecx, %ecx
movq 0x10(%r15), %rdx
cmpb $0x0, 0x28(%rdx,%rax)
js 0x28f08
leaq (%rdx,%rax), %rsi
imulq $0x30, %r14, %rdi
incq %r14
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, %rax
cmpq (%r15), %rcx
jb 0x28ed9
movq %r14, (%r15)
movl 0x18(%r15), %esi
movq %r15, %rdi
callq 0xc405a
leaq 0xe0(%rsp), %rdx
movq $0x2, 0x40(%rdx)
movq 0x18(%r15), %rcx
leaq 0x1b40ff(%rip), %rsi    # 0x1dd03d
movl %ebx, %edi
callq 0x1047b4
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq