// File: /workspace/github_cpp_makefile_star2_O3/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 0x1c092a
movslq %r9d, %r12
leaq 0x1(%r13), %rbx
cmpq %r12, %rbx
jge 0x1c092a
movq 0xb8(%rsp), %rdx
movq 0xa8(%rsp), %rdi
movq 0x98(%rsp), %r15
movq 0x90(%rsp), %r9
leaq -0x1(%r13), %r14
leal (,%r9,4), %eax
movl %eax, 0x18(%rsp)
leal 0x3(,%r9,4), %eax
movl %eax, 0x1c(%rsp)
leaq (%r9,%r9,8), %rax
leaq (%rax,%rax,2), %rcx
addq %r8, %rcx
addq %r9, %rcx
movq %rcx, 0x50(%rsp)
leaq (,%r13,8), %rax
addq %r13, %rax
leaq (%rax,%rax,2), %rax
addq %r13, %rax
leaq (%r8,%rax), %rcx
movq %rcx, 0x48(%rsp)
leaq (%r8,%rax), %rbp
addq $0x1c, %rbp
movq %r14, (%rdx,%rbx,8)
cmpq $0x0, (%rdi,%rbx,8)
js 0x1c091a
movl (%r15,%rbx,4), %eax
movl %eax, %ecx
sarl $0x2, %ecx
movslq %ecx, %rcx
cmpq %r9, %rcx
je 0x1c086a
movl 0x1c(%rsp), %eax
movl %eax, (%r15,%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 0x1be65f
testl %eax, %eax
je 0x1c084e
movl 0x40(%rsp), %eax
addl 0x18(%rsp), %eax
movl %eax, (%r15,%rbx,4)
jmp 0x1c0852
movl (%r15,%rbx,4), %eax
movq 0xb8(%rsp), %rdx
movq 0xa8(%rsp), %rdi
movq 0x90(%rsp), %r9
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
je 0x1c091a
sarl $0x2, %eax
cltq
cmpq %r9, %rax
jne 0x1c091a
movq (%rdi,%rbx,8), %rax
cmpq %r13, %rax
jle 0x1c089a
cmpq %r13, (%rdx,%rax,8)
movq %r13, %rax
je 0x1c089a
movq %r14, %rax
cmpq %r13, %rax
jne 0x1c091a
movq %r13, (%rdx,%rbx,8)
cmpq %r13, (%rdi,%rbx,8)
je 0x1c08f0
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 0x1be65f
movq 0x90(%rsp), %r9
movq 0xa8(%rsp), %rdi
movq 0xb8(%rsp), %rdx
testl %eax, %eax
je 0x1c091a
movq 0xb0(%rsp), %rax
movslq (%rax,%rbx,4), %rax
incq %rax
movq 0xd0(%rsp), %rcx
cmpq %rax, (%rcx)
jg 0x1c091a
movq %rax, (%rcx)
movq 0xc8(%rsp), %rax
movq %rbx, (%rax)
incq %rbx
addq $0x1c, %rbp
cmpq %rbx, %r12
jne 0x1c07e9
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq