// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/lchain.c
// Function: mg_chain_backtrack
uint64_t *mg_chain_backtrack(void *km, int64_t n, const int32_t *f, const int64_t *p, int32_t *v, int32_t *t, int32_t min_cnt, int32_t min_sc, int32_t max_drop, int32_t *n_u_, int32_t *n_v_)
{
	mm128_t *z;
	uint64_t *u;
	int64_t i, k, n_z, n_v;
	int32_t n_u;

	*n_u_ = *n_v_ = 0;
	for (i = 0, n_z = 0; i < n; ++i) // precompute n_z
		if (f[i] >= min_sc) ++n_z;
	if (n_z == 0) return 0;
	z = Kmalloc(km, mm128_t, n_z);
	for (i = 0, k = 0; i < n; ++i) // populate z[]
		if (f[i] >= min_sc) z[k].x = f[i], z[k++].y = i;
	radix_sort_128x(z, z + n_z);

	memset(t, 0, n * 4);
	for (k = n_z - 1, n_v = n_u = 0; k >= 0; --k) { // precompute n_u
		if (t[z[k].y] == 0) {
			int64_t n_v0 = n_v, end_i;
			int32_t sc;
			end_i = mg_chain_bk_end(max_drop, z, f, p, t, k);
			for (i = z[k].y; i != end_i; i = p[i])
				++n_v, t[i] = 1;
			sc = i < 0? z[k].x : (int32_t)z[k].x - f[i];
			if (sc >= min_sc && n_v > n_v0 && n_v - n_v0 >= min_cnt)
				++n_u;
			else n_v = n_v0;
		}
	}
	u = Kmalloc(km, uint64_t, n_u);
	memset(t, 0, n * 4);
	for (k = n_z - 1, n_v = n_u = 0; k >= 0; --k) { // populate u[]
		if (t[z[k].y] == 0) {
			int64_t n_v0 = n_v, end_i;
			int32_t sc;
			end_i = mg_chain_bk_end(max_drop, z, f, p, t, k);
			for (i = z[k].y; i != end_i; i = p[i])
				v[n_v++] = i, t[i] = 1;
			sc = i < 0? z[k].x : (int32_t)z[k].x - f[i];
			if (sc >= min_sc && n_v > n_v0 && n_v - n_v0 >= min_cnt)
				u[n_u++] = (uint64_t)sc << 32 | (n_v - n_v0);
			else n_v = n_v0;
		}
	}
	kfree(km, z);
	assert(n_v < INT32_MAX);
	*n_u_ = n_u, *n_v_ = n_v;
	return u;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq 0x30(%rbp), %rax
movl $0x0, (%rax)
movq 0x28(%rbp), %rax
movl $0x0, (%rax)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x1e7be
movq -0x20(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x18(%rbp), %eax
jl 0x1e7ae
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x1e7b0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1e788
cmpq $0x0, -0x60(%rbp)
jne 0x1e7d2
movq $0x0, -0x8(%rbp)
jmp 0x1ec11
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
shlq $0x4, %rsi
callq 0x1aae0
movq %rax, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x1e861
movq -0x20(%rbp), %rax
movq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x18(%rbp), %eax
jl 0x1e851
movq -0x20(%rbp), %rax
movq -0x50(%rbp), %rcx
movslq (%rax,%rcx,4), %rcx
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rdx
movq %rdx, %rsi
addq $0x1, %rsi
movq %rsi, -0x58(%rbp)
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x1e853
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1e7f7
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x60(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x5ad0
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x21b0
movq -0x60(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x6c(%rbp)
movq $0x0, -0x68(%rbp)
cmpq $0x0, -0x58(%rbp)
jl 0x1e9ec
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq -0x58(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x1e9d9
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movl 0x20(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x58(%rbp), %r9
callq 0x1ec20
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x80(%rbp), %rax
je 0x1e949
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movq -0x50(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
jmp 0x1e912
cmpq $0x0, -0x50(%rbp)
jge 0x1e96b
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
jmp 0x1e991
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x50(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
cltq
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl 0x18(%rbp), %eax
jl 0x1e9cf
movq -0x68(%rbp), %rax
cmpq -0x78(%rbp), %rax
jle 0x1e9cf
movq -0x68(%rbp), %rax
subq -0x78(%rbp), %rax
movslq 0x10(%rbp), %rcx
cmpq %rcx, %rax
jl 0x1e9cf
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1e9d7
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x1e9d9
jmp 0x1e9db
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x1e8a7
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x1aae0
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x21b0
movq -0x60(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x6c(%rbp)
movq $0x0, -0x68(%rbp)
cmpq $0x0, -0x58(%rbp)
jl 0x1ebbc
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq -0x58(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x1eba9
movq -0x68(%rbp), %rax
movq %rax, -0x90(%rbp)
movl 0x20(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x58(%rbp), %r9
callq 0x1ec20
movq %rax, -0x98(%rbp)
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x98(%rbp), %rax
je 0x1eaea
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x30(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x68(%rbp)
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
movq -0x50(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
jmp 0x1eaa0
cmpq $0x0, -0x50(%rbp)
jge 0x1eb0c
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x1eb32
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq -0x50(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
cltq
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl 0x18(%rbp), %eax
jl 0x1eb9c
movq -0x68(%rbp), %rax
cmpq -0x90(%rbp), %rax
jle 0x1eb9c
movq -0x68(%rbp), %rax
subq -0x90(%rbp), %rax
movslq 0x10(%rbp), %rcx
cmpq %rcx, %rax
jl 0x1eb9c
movslq -0x9c(%rbp), %rdx
shlq $0x20, %rdx
movq -0x68(%rbp), %rax
subq -0x90(%rbp), %rax
orq %rax, %rdx
movq -0x48(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x6c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1eba7
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x1eba9
jmp 0x1ebab
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x1ea2f
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1a8c0
cmpq $0x7fffffff, -0x68(%rbp) # imm = 0x7FFFFFFF
jge 0x1ebd5
jmp 0x1ebf4
leaq 0x3940c(%rip), %rdi     # 0x57fe8
leaq 0x39415(%rip), %rsi     # 0x57ff8
movl $0x49, %edx
leaq 0x39412(%rip), %rcx     # 0x58001
callq 0x21a0
movl -0x6c(%rbp), %ecx
movq 0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq 0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nop