// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: worker_for_ctg_trans_cc(void*, long, int)
static void worker_for_ctg_trans_cc(void *data, long i, int tid) // callback for kt_for()
{
    kv_u_trans_t *ta = (kv_u_trans_t*)data;
    u_trans_t *a = NULL, *r_a = NULL, *mz, *cz;
    uint32_t n, r_n, id = i, k, l, z;

    a = u_trans_a(*ta, id); n = u_trans_n(*ta, id);
    for (k = 1, l = 0; k <= n; k++) {
        if(k == n || a[l].tn != a[k].tn) {
            if(k > l) {
                get_u_trans_spec(ta, a[l].tn, a[l].qn, &r_a, &r_n);
                assert(r_n > 0);
                if(id > a[l].tn) {
                    l = k; continue;
                }

                mz = cz = NULL; 
                for (z = l; z < k; z++) {
                    cz = &(a[z]); cz->del = 1;
                    if((mz) && (mz->f == 1) && (cz->f != 1)) continue;
                    if((!mz) || ((cz->f == 1) && (mz->f != 1)) || ((cz->f == mz->f) && ((mz->nw < cz->nw) || ((mz->nw == cz->nw) && ((mz->qe - mz->qs) < (cz->qe - cz->qs)))))) {
                        mz = cz; 
                    }
                }
                for (z = 0; z < r_n; z++) {
                    cz = &(r_a[z]); cz->del = 1;
                    if((mz) && (mz->f == 1) && (cz->f != 1)) continue;
                    if((!mz) || ((cz->f == 1) && (mz->f != 1)) || ((cz->f == mz->f) && ((mz->nw < cz->nw) || ((mz->nw == cz->nw) && ((mz->qe - mz->qs) < (cz->qe - cz->qs)))))) {
                        mz = cz; 
                    }
                }

                assert(mz);
                mz->del = 0;
            }
            l = k;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x4c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x44(%rbp)
movl $0x1, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x44(%rbp), %eax
ja 0x12800a
movl -0x50(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x127d04
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x28(%rbp), %rcx
movl -0x50(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
je 0x127ffa
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jbe 0x127ff4
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %esi
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x110ee0
cmpl $0x0, -0x48(%rbp)
jbe 0x127d4b
jmp 0x127d6a
leaq 0x2620ef(%rip), %rdi    # 0x389e41
leaq 0x25eb64(%rip), %rsi    # 0x3868bd
movl $0x550a, %edx           # imm = 0x550A
leaq 0x2620e4(%rip), %rcx    # 0x389e49
callq 0x2130
movl -0x4c(%rbp), %eax
movq -0x28(%rbp), %rcx
movl -0x54(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
jbe 0x127d8b
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x127ffc
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x50(%rbp), %eax
jae 0x127eab
movq -0x28(%rbp), %rax
movl -0x58(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb 0x28(%rax), %cl
andb $0x7f, %cl
orb $-0x80, %cl
movb %cl, 0x28(%rax)
cmpq $0x0, -0x38(%rbp)
je 0x127dfd
movq -0x38(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x127dfd
movq -0x40(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0x127dfd
jmp 0x127e9d
cmpq $0x0, -0x38(%rbp)
je 0x127e93
movq -0x40(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x127e2a
movq -0x38(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x127e93
movq -0x40(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
movq -0x38(%rbp), %rcx
movb 0x28(%rcx), %cl
andb $0x3f, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x127e9b
movq -0x38(%rbp), %rax
movsd 0x20(%rax), %xmm1
movq -0x40(%rbp), %rax
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0x127e93
movq -0x38(%rbp), %rax
movsd 0x20(%rax), %xmm0
movq -0x40(%rbp), %rax
ucomisd 0x20(%rax), %xmm0
jne 0x127e9b
jp 0x127e9b
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
subl (%rcx), %eax
movq -0x40(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq -0x40(%rbp), %rdx
subl (%rdx), %ecx
cmpl %ecx, %eax
jae 0x127e9b
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x127e9d
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x127da1
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0x127fbc
movq -0x30(%rbp), %rax
movl -0x58(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb 0x28(%rax), %cl
andb $0x7f, %cl
orb $-0x80, %cl
movb %cl, 0x28(%rax)
cmpq $0x0, -0x38(%rbp)
je 0x127f0e
movq -0x38(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x127f0e
movq -0x40(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0x127f0e
jmp 0x127fae
cmpq $0x0, -0x38(%rbp)
je 0x127fa4
movq -0x40(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x127f3b
movq -0x38(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x127fa4
movq -0x40(%rbp), %rax
movb 0x28(%rax), %al
andb $0x3f, %al
movzbl %al, %eax
movq -0x38(%rbp), %rcx
movb 0x28(%rcx), %cl
andb $0x3f, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x127fac
movq -0x38(%rbp), %rax
movsd 0x20(%rax), %xmm1
movq -0x40(%rbp), %rax
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0x127fa4
movq -0x38(%rbp), %rax
movsd 0x20(%rax), %xmm0
movq -0x40(%rbp), %rax
ucomisd 0x20(%rax), %xmm0
jne 0x127fac
jp 0x127fac
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
subl (%rcx), %eax
movq -0x40(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq -0x40(%rbp), %rdx
subl (%rdx), %ecx
cmpl %ecx, %eax
jae 0x127fac
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x127fae
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x127eb2
cmpq $0x0, -0x38(%rbp)
je 0x127fc5
jmp 0x127fe4
leaq 0x261ead(%rip), %rdi    # 0x389e79
leaq 0x25e8ea(%rip), %rsi    # 0x3868bd
movl $0x551f, %edx           # imm = 0x551F
leaq 0x261e6a(%rip), %rcx    # 0x389e49
callq 0x2130
movq -0x38(%rbp), %rax
movb 0x28(%rax), %cl
andb $0x7f, %cl
orb $0x0, %cl
movb %cl, 0x28(%rax)
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x127ffc
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x127cc8
addq $0x60, %rsp
popq %rbp
retq