// File: /workspace/github_c_makefile_star2_O0/lh3[P]partig/pdist.c
// Function: pt_cal_sim
static pt_match1_t *pt_cal_sim(int64_t n_an, const pt128_t *an, const pt_uinfo_t *info, int32_t k, int32_t min_cnt, double min_sim, uint32_t *n_ma_)
{
	int64_t st, i, j, max = 0;
	uint64_t *a;
	int32_t *b;
	uint32_t n_ma = 0, m_ma = 0;
	pt_match1_t *ma = 0;
	for (st = 0, i = 1; i <= n_an; ++i) // pre-calculate the max size
		if (i == n_an || an[i].x != an[st].x) {
			max = max > i - st? max : i - st;
			st = i;
		}
	PT_MALLOC(a, max);
	PT_MALLOC(b, max);
	for (st = 0, i = 1; i <= n_an; ++i) {
		if (i == n_an || an[i].x != an[st].x) {
			int32_t l, n = 0;
			uint32_t nn[2];
			pt_match1_t m;
			if (i - st < min_cnt) goto end_chain;
			for (j = st; j < i; ++j)
				a[n++] = an[j].y;
			radix_sort_gfa64(a, a + n);
			for (l = 0; l < n; ++l) a[l] = (uint32_t)a[l];
			m.m = pt_lis_64(n, a, b);
			if (m.m < min_cnt) goto end_chain;
			m.sid[0] = an[st].x >> 33;
			m.sid[1] = ((uint32_t)an[st].x) >> 1;
			if (m.sid[0] == m.sid[1]) goto end_chain;
			nn[0] = info[m.sid[0]].cnt2;
			nn[1] = info[m.sid[1]].cnt2;
			m.rev = (an[st].x>>32&1) ^ (an[st].x&1);
			m.sim = pow(2.0 * m.m / (nn[0] + nn[1]), 1.0 / k);
			if (m.sim >= min_sim) {
				if (n_ma == m_ma) PT_EXPAND(ma, m_ma);
				ma[n_ma++] = m;
			}
end_chain:	st = i;
		}
	}
	free(b);
	free(a);
	*n_ma_ = n_ma;
	if (pt_verbose >= 3)
		fprintf(stderr, "[%s::%.3f] calculated similarity for %d pairs of unitigs\n", __func__, pt_realtime(), n_ma);
	return ma;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x8(%rbp), %rax
jg 0xaf96
movq -0x40(%rbp), %rax
cmpq -0x8(%rbp), %rax
je 0xaf43
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
je 0xaf83
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
subq -0x38(%rbp), %rcx
cmpq %rcx, %rax
jle 0xaf61
movq -0x50(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0xaf70
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xaf85
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xaf05
movq -0x50(%rbp), %rdi
shlq $0x3, %rdi
callq 0x11a0
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
shlq $0x2, %rdi
callq 0x11a0
movq %rax, -0x60(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x8(%rbp), %rax
jg 0xb263
movq -0x40(%rbp), %rax
cmpq -0x8(%rbp), %rax
je 0xb00a
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
je 0xb250
movl $0x0, -0x78(%rbp)
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
cmpq %rcx, %rax
jge 0xb027
jmp 0xb248
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0xb070
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq -0x58(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x78(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xb02f
movq -0x58(%rbp), %rdi
movq -0x58(%rbp), %rsi
movslq -0x78(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2590
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x78(%rbp), %eax
jge 0xb0be
movq -0x58(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movl %eax, %edx
movq -0x58(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xb08f
movl -0x78(%rbp), %edi
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0xa220
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0xb0e4
jmp 0xb248
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x21, %rax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrl %eax
movl %eax, -0x94(%rbp)
movl -0x98(%rbp), %eax
cmpl -0x94(%rbp), %eax
jne 0xb12d
jmp 0xb248
movq -0x18(%rbp), %rax
movl -0x98(%rbp), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movl -0x94(%rbp), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rcx
movq %rcx, %rax
shrq $0x20, %rax
xorl %ecx, %eax
andl $0x1, %eax
movl %eax, -0x8c(%rbp)
movl -0x90(%rbp), %eax
cvtsi2sd %rax, %xmm0
addsd %xmm0, %xmm0
movl -0x80(%rbp), %eax
movl -0x7c(%rbp), %ecx
addl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm2
movsd 0x24d4(%rip), %xmm1     # 0xd670
divsd %xmm2, %xmm1
callq 0x10c0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
ucomisd -0x28(%rbp), %xmm0
jb 0xb246
movl -0x64(%rbp), %eax
cmpl -0x68(%rbp), %eax
jne 0xb20e
jmp 0xb1ca
cmpl $0x0, -0x68(%rbp)
je 0xb1e2
movl -0x68(%rbp), %eax
movl -0x68(%rbp), %ecx
shrl %ecx
addl %ecx, %eax
movl %eax, -0xa4(%rbp)
jmp 0xb1ef
movl $0x10, %eax
movl %eax, -0xa4(%rbp)
jmp 0xb1ef
movl -0xa4(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x70(%rbp), %rdi
movl -0x68(%rbp), %eax
imulq $0x18, %rax, %rsi
callq 0x11b0
movq %rax, -0x70(%rbp)
jmp 0xb20e
movq -0x70(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x64(%rbp)
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0xb248
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xb252
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xafc8
movq -0x60(%rbp), %rdi
callq 0x1040
movq -0x58(%rbp), %rdi
callq 0x1040
movl -0x64(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
leaq 0x4fb3(%rip), %rax      # 0x10238
cmpl $0x3, (%rax)
jb 0xb2bf
movq 0x4d67(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
callq 0x8c60
movq -0xb0(%rbp), %rdi
movl -0x64(%rbp), %ecx
leaq 0x251f(%rip), %rsi      # 0xd7d0
leaq 0x2552(%rip), %rdx      # 0xd80a
movb $0x1, %al
callq 0x1170
movq -0x70(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)