// File: chhylp123[P]hifiasm/inter.cpp
// Function: quick_rechain_sc(ul_ov_t*, overlap_region_alloc*, ul_idx_t const*, ug_opt_t const*, long, double, All_reads*, kv_rtrace_t*, char*, UC_Read*, rtrace_iter*, double, bit_extz_t*, long, int*, long, long)
int64_t quick_rechain_sc(ul_ov_t *a, overlap_region_alloc* ol, const ul_idx_t *uref, const ug_opt_t *uopt, 
int64_t bw, double diff, All_reads *ridx, kv_rtrace_t *trace, char* qstr, UC_Read *tu, rtrace_iter *tc,
double e_rate, bit_extz_t *exz, int64_t trans_sc, int32_t *f, int64_t ai, int64_t aj)
{
	ul_ov_t *li = &(a[ai]), *lj = &(a[aj]);
	uint32_t li_v, lj_v; int64_t qo, is_c, err, sc = INT32_MIN;
	li_v = (li->tn<<1)|li->rev; lj_v = (lj->tn<<1)|lj->rev;
	if(li_v == lj_v) return INT32_MIN;
	if(lj->qe <= li->qs) return INT32_MIN;
	if(lj->qs > li->qs) return INT32_MIN;
	qo = infer_rovlp(li, lj, NULL, NULL, ridx, NULL);
	if(get_ecov_contain_adv(uref, uopt, li_v^1, lj_v^1, bw, diff, qo, &is_c)) {
		if(is_c == 0) {
			err = get_rid_backward_cigar_err(tc, li, trace, NULL, uref, qstr, tu, ol, NULL, exz, e_rate, lj->qe);
			sc = f[aj] + (li->qe - lj->qe) - (err*trans_sc);
		}
	}
	return sc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xa8, %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, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movsd %xmm0, -0x40(%rbp)
movq %r9, -0x48(%rbp)
movsd %xmm1, -0x50(%rbp)
movq -0x18(%rbp), %rax
imulq $0x1c, 0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
imulq $0x1c, 0x50(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq $-0x80000000, -0x88(%rbp) # imm = 0x80000000
movq -0x58(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0x58(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x64(%rbp)
movq -0x60(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0x60(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x68(%rbp), %eax
jne 0x2b2b02
movq $-0x80000000, -0x10(%rbp) # imm = 0x80000000
jmp 0x2b2c2f
movq -0x60(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x58(%rbp), %rcx
cmpl 0x4(%rcx), %eax
ja 0x2b2b1f
movq $-0x80000000, -0x10(%rbp) # imm = 0x80000000
jmp 0x2b2c2f
movq -0x60(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x58(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2b2b3c
movq $-0x80000000, -0x10(%rbp) # imm = 0x80000000
jmp 0x2b2c2f
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x48(%rbp), %r8
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rdx
movq %r9, %rcx
callq 0x71a90
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x64(%rbp), %edx
xorl $0x1, %edx
movl -0x68(%rbp), %ecx
xorl $0x1, %ecx
movq -0x38(%rbp), %r8
movsd -0x40(%rbp), %xmm0
movq -0x70(%rbp), %r9
leaq -0x78(%rbp), %rax
movq %rax, (%rsp)
callq 0x2b0c90
cmpq $0x0, %rax
je 0x2b2c24
cmpq $0x0, -0x78(%rbp)
jne 0x2b2c22
movq 0x28(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x28(%rbp), %r8
movq 0x18(%rbp), %r9
movq 0x20(%rbp), %rbx
movq -0x20(%rbp), %r11
movq 0x30(%rbp), %r10
movsd -0x50(%rbp), %xmm0
movq -0x60(%rbp), %rax
movl 0x8(%rax), %eax
xorl %ecx, %ecx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x93360
movq %rax, -0x80(%rbp)
movq 0x40(%rbp), %rax
movq 0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x58(%rbp), %rcx
movl 0x8(%rcx), %ecx
movq -0x60(%rbp), %rdx
subl 0x8(%rdx), %ecx
addl %ecx, %eax
movl %eax, %eax
movq -0x80(%rbp), %rcx
imulq 0x38(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x88(%rbp)
jmp 0x2b2c24
movq -0x88(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0xa8, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)