// File: 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
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq 0x48(%rbp), %rax
cmpq $0x0, (%rax)
jge 0x2b5d1b
jmp 0x2b5f78
movq 0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jge 0x2b5f76
movq -0x40(%rbp), %rdx
subq $0x1, %rdx
movq 0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jge 0x2b5d6b
jmp 0x2b5f65
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
sarl $0x2, %eax
cltq
cmpq 0x10(%rbp), %rax
je 0x2b5e23
movq 0x10(%rbp), %rax
shlq $0x2, %rax
movl %eax, %edx
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x3, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movsd -0x28(%rbp), %xmm0
movq -0x30(%rbp), %r8
imulq $0x1c, 0x10(%rbp), %rax
addq %rax, %r8
movq -0x30(%rbp), %r9
imulq $0x1c, -0x48(%rbp), %rax
addq %rax, %r9
leaq -0x58(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x2b2f20
cmpl $0x0, %eax
je 0x2b5e21
movq 0x10(%rbp), %rax
shlq $0x2, %rax
movl %eax, %edx
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x58(%rbp), %rsi
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
addq %rsi, %rdx
movl %edx, (%rax,%rcx,4)
jmp 0x2b5e23
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
sarl $0x2, %eax
cltq
cmpq 0x10(%rbp), %rax
jne 0x2b5e4c
movq 0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0x3, %eax
cmpl $0x3, %eax
jne 0x2b5e51
jmp 0x2b5f65
movq 0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x50(%rbp)
movb %al, -0x61(%rbp)
jl 0x2b5e7b
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
setg %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x2b5e84
jmp 0x2b5eac
movq 0x38(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x40(%rbp), %rax
jne 0x2b5ea0
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x2b5eac
movq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x2b5ebb
jmp 0x2b5f65
movq -0x40(%rbp), %rdx
movq 0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x50(%rbp), %rax
je 0x2b5f2c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movsd -0x28(%rbp), %xmm0
movq -0x30(%rbp), %r8
imulq $0x1c, -0x48(%rbp), %rax
addq %rax, %r8
movq -0x30(%rbp), %r9
imulq $0x1c, -0x50(%rbp), %rax
addq %rax, %r9
leaq -0x58(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x2b2f20
cmpl $0x0, %eax
jne 0x2b5f2a
jmp 0x2b5f65
jmp 0x2b5f2c
movq 0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq 0x50(%rbp), %rcx
cmpq (%rcx), %rax
jl 0x2b5f63
movq -0x60(%rbp), %rcx
movq 0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq 0x48(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2b5f65
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2b5d32
jmp 0x2b5f78
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)