// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: worker_for_ctg_trans_order(void*, long, int)
static void worker_for_ctg_trans_order(void *data, long i, int tid)
{
	ctdat_t *c = (ctdat_t*)data; utepdat_t *s = c->s; asg64_v b;
	u_trans_t *a = NULL, *r_a = NULL, t; uint64_t n, r_n, k, z, m;

	if(c->mm == 0) {
		copy_asg_arr(b, (s->sps[tid]));
		rm_dup_aln(u_trans_a(*(c->ta), i), u_trans_n(*(c->ta), i), &b, 0.25);
		copy_asg_arr((s->sps[tid]), b); 
	} else if(c->mm == 1) {
			a = u_trans_a(*(c->ta), i); n = u_trans_n(*(c->ta), i);
			for (k = 0; k < n; k++) {
				if(a[k].tn < a[k].qn) continue;
				r_a = u_trans_a(*(c->ta), a[k].tn); r_n = u_trans_n(*(c->ta), a[k].tn);
				for(z = 0; (z < r_n) && (r_a[z].tn != a[k].qn); z++);
				assert(z < r_n);
				// if(a[k].del || r_a[z].del) {
				// 	a[k].del = r_a[z].del = 1;
				// }
				///discard too short overlaps
				if((!a[k].f) || (!r_a[z].f)) {
					if((a[k].qe - a[k].qs <= asm_opt.self_scaf_min) || (a[k].te - a[k].ts <= asm_opt.self_scaf_min)) {
						a[k].del = r_a[z].del = 1;
					} else if((r_a[z].qe - r_a[z].qs <= asm_opt.self_scaf_min) || (r_a[z].te - r_a[z].ts <= asm_opt.self_scaf_min)) {
						a[k].del = r_a[z].del = 1;
					}
				}

				if(a[k].del != r_a[z].del) {
					a[k].del = r_a[z].del = 0;
					a[k].occ = r_a[z].occ = (uint32_t)-1;
				}
			}
	} else {
		a = u_trans_a(*(c->ta), i); n = u_trans_n(*(c->ta), i);
		for (k = m = 0; k < n; k++) {
			if((a[k].occ != (uint32_t)-1)) {
				if(m != k) {t = a[k]; a[k] = a[m]; a[m] = t;}
				m++;
			}
		}
		radix_sort_u_trans_qs0(a, a + m);
		radix_sort_u_trans_qs0(a + m, a + n);
		a = a + m; n = n - m;
		if(n) {//sort and merge unreliable regions
			for (k = 0; k < n; k++) a[k].del = 1; 
			for (k = m = 0; k < n; k++) {
				if((m > 0) && (a[m-1].qe >= a[k].qs)) {
					if(a[k].qe > a[m-1].qe) a[m-1].qe = a[k].qe;
				} else {
					a[m++] = a[k];
				}
			}

			for(k = m; k < n; k++) {///not useful anymore
				a[k].qn = a[k].qs = a[k].qe = (uint32_t)-1;
				a[k].tn = a[k].ts = a[k].te = (uint32_t)-1;
			}
		}
	}
	
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq 0x40(%rdi), %rax
cmpq $0x1, %rax
je 0x1e7b58
testq %rax, %rax
jne 0x1e7c7a
movq (%rdi), %r14
movq 0x68(%r14), %rax
movslq %edx, %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r15
movq 0x10(%rax,%r15), %rcx
leaq 0x10(%rsp), %rbx
movq %rcx, 0x10(%rbx)
movups (%rax,%r15), %xmm0
movaps %xmm0, (%rbx)
movq 0x38(%rdi), %rax
movq 0x28(%rax), %rcx
movq (%rcx,%rsi,8), %rcx
movl %ecx, %esi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x4, %rdi
addq 0x10(%rax), %rdi
movsd 0x49a9c(%rip), %xmm0    # 0x2315d0
movq %rbx, %rdx
callq 0x1d9f19
movq 0x10(%rbx), %rax
movq 0x68(%r14), %rcx
movq %rax, 0x10(%rcx,%r15)
movdqa (%rbx), %xmm0
movdqu %xmm0, (%rcx,%r15)
jmp 0x1e7e18
movq 0x38(%rdi), %r8
movq 0x28(%r8), %rax
movq (%rax,%rsi,8), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rdx, %rcx
andq %rax, %rcx
je 0x1e7e18
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
addq 0x10(%r8), %rdx
xorl %esi, %esi
leaq 0xadbca(%rip), %r8      # 0x295758
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
leaq (%rsi,%rsi,2), %r10
shlq $0x4, %r10
movl 0x8(%rdx,%r10), %ebx
movl 0x14(%rdx,%r10), %r11d
cmpl %ebx, %r11d
jb 0x1e7c69
movq 0x38(%rdi), %r15
movq 0x28(%r15), %r14
movq (%r14,%r11,8), %r11
movq %r11, %r14
andq %rax, %r14
je 0x1e7e27
addq %rdx, %r10
movq 0x10(%r15), %r15
shrq $0x20, %r11
leaq (%r11,%r11,2), %r11
shlq $0x4, %r11
addq %r15, %r11
addq $0x28, %r11
cmpl %ebx, -0x14(%r11)
je 0x1e7bf5
addq $0x30, %r11
decq %r14
jne 0x1e7be1
jmp 0x1e7e27
movb 0x28(%r10), %bl
testb $0x3f, %bl
je 0x1e7c04
testb $0x3f, (%r11)
jne 0x1e7c4d
movl 0x4(%r10), %r15d
subl (%r10), %r15d
movq 0x268(%r8), %r14
cmpq %r15, %r14
jae 0x1e7c3e
movl 0x10(%r10), %r15d
subl 0xc(%r10), %r15d
cmpq %r15, %r14
jae 0x1e7c3e
movl -0x24(%r11), %r15d
subl -0x28(%r11), %r15d
cmpq %r15, %r14
jae 0x1e7c3e
movl -0x18(%r11), %r15d
subl -0x1c(%r11), %r15d
cmpq %r15, %r14
jb 0x1e7c4d
orb $-0x80, (%r11)
movb 0x28(%r10), %bl
orb $-0x80, %bl
movb %bl, 0x28(%r10)
movb (%r11), %bpl
xorb %bpl, %bl
jns 0x1e7c69
andb $0x7f, %bpl
movb %bpl, (%r11)
andb $0x7f, 0x28(%r10)
movl %r9d, -0x10(%r11)
movl %r9d, 0x18(%r10)
incq %rsi
cmpq %rcx, %rsi
jne 0x1e7b94
jmp 0x1e7e18
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rdx
movq 0x28(%rax), %rax
movq (%rax,%rsi,8), %rax
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rbp
shlq $0x4, %rbp
movq %rdx, 0x8(%rsp)
leaq (%rdx,%rbp), %r14
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %r12d, %r12d
andq %rax, %r15
je 0x1e7d2f
movq %r14, %rax
xorl %ecx, %ecx
cmpl $-0x1, 0x18(%rax)
je 0x1e7d23
cmpq %r12, %rcx
je 0x1e7d20
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movaps %xmm2, 0x30(%rsp)
movaps %xmm1, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq (%r12,%r12,2), %rdx
shlq $0x4, %rdx
movups (%r14,%rdx), %xmm0
movups 0x10(%r14,%rdx), %xmm1
movups 0x20(%r14,%rdx), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movdqa 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
movaps 0x30(%rsp), %xmm2
movups %xmm2, 0x20(%r14,%rdx)
movups %xmm1, 0x10(%r14,%rdx)
movdqu %xmm0, (%r14,%rdx)
incq %r12
incq %rcx
addq $0x30, %rax
cmpq %rcx, %r15
jne 0x1e7cb5
leaq (%r12,%r12,2), %r13
shlq $0x4, %r13
leaq (%r14,%r13), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x19db6d
leaq (%r15,%r15,2), %rsi
shlq $0x4, %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x19db6d
subq %r12, %r15
je 0x1e7e18
addq %rbp, %r13
movq 0x8(%rsp), %rax
addq %r13, %rax
addq $0x28, %rax
movq %r15, %rcx
orb $-0x80, (%rax)
addq $0x30, %rax
decq %rcx
jne 0x1e7d74
leaq -0x2c(%rbx), %rcx
xorl %eax, %eax
movq %rbx, %rdx
movq %r15, %rsi
testq %rax, %rax
je 0x1e7da2
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
movl (%rcx,%rdi), %r8d
cmpl (%rdx), %r8d
jae 0x1e7dd3
leaq (%rax,%rax,2), %rdi
incq %rax
shlq $0x4, %rdi
movdqu (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups 0x20(%rdx), %xmm2
movups %xmm2, 0x20(%rbx,%rdi)
movups %xmm1, 0x10(%rbx,%rdi)
movdqu %xmm0, (%rbx,%rdi)
addq $0x30, %rdx
decq %rsi
jne 0x1e7d8c
jmp 0x1e7de4
movl 0x4(%rdx), %r9d
cmpl %r8d, %r9d
jbe 0x1e7dc8
addq %rcx, %rdi
movl %r9d, (%rdi)
jmp 0x1e7dc8
cmpq %r15, %rax
jae 0x1e7e18
movq 0x8(%rsp), %rdx
addq %r13, %rdx
leaq (%rax,%rax,2), %rcx
shlq $0x4, %rcx
addq %rdx, %rcx
pcmpeqd %xmm0, %xmm0
incq %rax
movdqu %xmm0, (%rcx)
movq $-0x1, 0x10(%rcx)
addq $0x30, %rcx
cmpq %r15, %rax
jb 0x1e7e00
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d425(%rip), %rdi     # 0x245253
leaq 0x57e26(%rip), %rsi     # 0x23fc5b
leaq 0x5d41f(%rip), %rcx     # 0x24525b
movl $0x44ae, %edx           # imm = 0x44AE
callq 0x2110