// File: /workspace/github_cpp_makefile_star2_O3/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 0x26d58c(%rip), %rax    # 0x295758
movslq 0x7c(%rax), %rbx
leaq 0x10(%rsp), %r14
movl $0xd0, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x20e0
pushq $0x8
popq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, %r13
movq %rax, 0x80(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2120
movq %rax, %rbp
movq %rax, 0x78(%r14)
pushq $0x68
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x88(%r14)
movl $0xc0, %esi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x90(%r14)
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x60(%r14)
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rbx, %rdx
movq %rax, 0x68(%r14)
testq %rbx, %rbx
je 0x28299
xorl %r14d, %r14d
movq %rdx, %rbx
xorl %edi, %edi
xorl %esi, %esi
pushq $0x1
popq %rdx
callq 0x387f4
movq %rax, (%r13,%r14,8)
pushq $0x1
popq %rdi
pushq $0x10
popq %rsi
callq 0x2120
movq %rax, %r12
callq 0x1edff7
movq %rbx, %rdx
movq %rax, (%r12)
movq %r12, (%rbp,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x2825e
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rbx
movups %xmm0, 0x38(%rbx)
movups %xmm0, 0x48(%rbx)
movups %xmm0, 0x28(%rbx)
movups %xmm0, 0x18(%rbx)
movups %xmm0, 0x8(%rbx)
leaq 0x10(%rsp), %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %r12
movq %r12, 0x38(%rbx)
movq 0x18(%r12), %rcx
leaq 0x1bf7f0(%rip), %r14    # 0x1e7ac5
movq %rdx, %rbp
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x108f2c
movq $0x1, 0x40(%rbx)
movq 0x18(%r12), %rcx
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x108f2c
testl %ebp, %ebp
je 0x283a1
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %rbp, %r13
movq 0x90(%rsp), %rax
movq (%rax,%rbx), %rdi
movl 0xf0(%rdi), %eax
addl %eax, 0x50(%rsp)
movl 0xf8(%rdi), %eax
addl %eax, 0x48(%rsp)
callq 0x38b4b
movq 0x88(%rsp), %rax
movq (%rax,%rbx), %rdi
callq 0x19fca1
movq 0x98(%rsp), %rdi
addq %r14, %rdi
callq 0x1a1e15
movq 0xa0(%rsp), %rdi
addq %r12, %rdi
callq 0x1a1e43
movq 0x70(%rsp), %rax
movq 0x8(%rax,%rbx,2), %rdi
callq 0x2220
movq 0x78(%rsp), %rax
movq (%rax,%r15,2), %rdi
callq 0x2220
addq $0xc0, %r12
addq $0x68, %r14
addq $0x8, %rbx
addq $0xc, %r15
decq %r13
jne 0x28312
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 0x26cbf0(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
movl 0x48(%rsp), %r8d
movl 0x50(%rsp), %ecx
leaq 0x21b75d(%rip), %rsi    # 0x243b60
leaq 0x21c658(%rip), %rdx    # 0x244a62
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %r14
movq (%r14), %rdx
testq %rdx, %rdx
je 0x28464
xorl %eax, %eax
xorl %ebx, %ebx
xorl %ecx, %ecx
movq 0x10(%r14), %rsi
cmpb $0x0, 0x28(%rsi,%rax)
js 0x28458
leaq (%rsi,%rax), %rdx
imulq $0x30, %rbx, %rdi
incq %rbx
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups 0x20(%rdx), %xmm2
movups %xmm2, 0x20(%rsi,%rdi)
movups %xmm1, 0x10(%rsi,%rdi)
movups %xmm0, (%rsi,%rdi)
movq (%r14), %rdx
incq %rcx
addq $0x30, %rax
cmpq %rdx, %rcx
jb 0x28426
movq %rbx, (%r14)
movl 0x18(%r14), %esi
movq %r14, %rdi
callq 0xc4edd
leaq 0xe0(%rsp), %rdx
movq $0x2, 0x40(%rdx)
movq 0x18(%r14), %rcx
leaq 0x1bf637(%rip), %rsi    # 0x1e7ac5
movl %ebp, %edi
callq 0x108f2c
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq