// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: propagate_transitive_reduction(ul_idx_t const*, ug_opt_t const*, All_reads*, long, double, ul_ov_t*, int, long, int*, int*, long*, int*, long*, long*, long*, long*)
void propagate_transitive_reduction(const ul_idx_t *uref, const ug_opt_t *uopt, All_reads *ridx, int64_t bw, double diff, 
ul_ov_t *a, int32_t a_n, int64_t ai, int32_t *rch, int32_t *f, int64_t *p, int32_t *c_n, int64_t *t, int64_t *mm_sc, 
int64_t *mm_idx, int64_t *mm_n)
{
	if((*mm_idx) < 0) return;
	int64_t mm_idx0 = (*mm_idx), j, k, is_c, sn;
	for (j = mm_idx0 + 1; j < a_n; j++) {
		t[j] = mm_idx0 - 1;
		if(p[j] < 0) continue;
		if((rch[j]>>2) != ai) {
			rch[j] = (ai<<2); rch[j] += 3;
			if(if_qchain_cnn(uref, uopt, ridx, bw, diff, &(a[ai]), &(a[j]), &is_c, NULL)) {
				rch[j] = (ai<<2); rch[j] += is_c;
			}
		}
		if(!rch_connect(rch[j], ai)) continue;
		for (k = p[j]; k >= 0 && k > mm_idx0; k = p[k]) {
			if(t[k] == mm_idx0) {
				k = mm_idx0; break;
			} else {
				k = mm_idx0-1; break;
			}
		}
		if (k != mm_idx0) continue;
		t[j] = mm_idx0;//a[j] could reach mm_idx0;
		if(p[j] != k) {
			if(!(if_qchain_cnn(uref, uopt, ridx, bw, diff, &(a[j]), &(a[k]), &is_c, NULL))) continue;
		}
		sn = c_n[j] + 1;
		if(sn >= (*mm_n)) {//must >=
			(*mm_n) = sn; (*mm_idx) = j;
		}
	}
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movsd %xmm0, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq 0xc8(%rsp), %rax
movq (%rax), %r13
testq %r13, %r13
js 0x175b64
movq 0xb8(%rsp), %rdx
movq 0xa8(%rsp), %rdi
movq 0x98(%rsp), %r14
movq 0x90(%rsp), %r10
movslq %r9d, %r12
leaq -0x1(%r13), %r15
leal (,%r10,4), %eax
movl %eax, 0x18(%rsp)
leal 0x3(,%r10,4), %eax
movl %eax, 0x1c(%rsp)
imulq $0x1c, %r10, %rax
addq %r8, %rax
movq %rax, 0x50(%rsp)
imulq $0x1c, %r13, %rax
leaq (%r8,%rax), %rcx
movq %rcx, 0x48(%rsp)
leaq 0x1(%r13), %rbx
leaq (%r8,%rax), %rbp
addq $0x1c, %rbp
cmpq %r12, %rbx
jge 0x175b64
movq %r15, (%rdx,%rbx,8)
cmpq $0x0, (%rdi,%rbx,8)
js 0x175b58
movl (%r14,%rbx,4), %eax
movl %eax, %ecx
sarl $0x2, %ecx
movslq %ecx, %rcx
cmpq %r10, %rcx
je 0x175aa8
movl 0x1c(%rsp), %eax
movl %eax, (%r14,%rbx,4)
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movsd 0x38(%rsp), %xmm0
movq 0x50(%rsp), %r8
movq %rbp, %r9
callq 0x173c90
testl %eax, %eax
je 0x175a8c
movl 0x40(%rsp), %eax
addl 0x18(%rsp), %eax
movl %eax, (%r14,%rbx,4)
jmp 0x175a90
movl (%r14,%rbx,4), %eax
movq 0xb8(%rsp), %rdx
movq 0xa8(%rsp), %rdi
movq 0x90(%rsp), %r10
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
je 0x175b58
sarl $0x2, %eax
cltq
cmpq %r10, %rax
jne 0x175b58
movq (%rdi,%rbx,8), %rax
cmpq %r13, %rax
jle 0x175ad8
cmpq %r13, (%rdx,%rax,8)
movq %r13, %rax
je 0x175ad8
movq %r15, %rax
cmpq %r13, %rax
jne 0x175b58
movq %r13, (%rdx,%rbx,8)
cmpq %r13, (%rdi,%rbx,8)
je 0x175b2e
leaq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movsd 0x38(%rsp), %xmm0
movq %rbp, %r8
movq 0x48(%rsp), %r9
callq 0x173c90
movq 0x90(%rsp), %r10
movq 0xa8(%rsp), %rdi
movq 0xb8(%rsp), %rdx
testl %eax, %eax
je 0x175b58
movq 0xb0(%rsp), %rax
movslq (%rax,%rbx,4), %rax
incq %rax
movq 0xd0(%rsp), %rcx
cmpq %rax, (%rcx)
jg 0x175b58
movq %rax, (%rcx)
movq 0xc8(%rsp), %rax
movq %rbx, (%rax)
incq %rbx
addq $0x1c, %rbp
jmp 0x175a1e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq