// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/shortk.c
// Function: mg_shortest_k
mg_pathv_t *mg_shortest_k(void *km0, const gfa_t *g, uint32_t src, int32_t n_dst, mg_path_dst_t *dst, int32_t max_dist, int32_t max_k, int32_t *n_pathv)
{
	sp_node_t *p, *root = 0, **out;
	sp_topk_t *q;
	kh_sp_t *h;
	kh_sp2_t *h2;
	void *km;
	khint_t k;
	int absent;
	int32_t i, j, n_done, n_found;
	uint32_t id, n_out, m_out;
	int8_t *dst_done;
	mg_pathv_t *ret = 0;
	uint64_t *dst_group, *seeds = 0;
	void *h_seeds = 0;
	mg128_v mini = {0,0,0};

	if (n_pathv) *n_pathv = 0;
	if (n_dst <= 0) return 0;
	for (i = 0; i < n_dst; ++i) { // initialize
		mg_path_dst_t *t = &dst[i];
		if (t->inner)
			t->dist = 0, t->n_path = 1, t->path_end = -1;
		else
			t->dist = -1, t->n_path = 0, t->path_end = -1;
	}
	if (max_k > MG_MAX_SHORT_K) max_k = MG_MAX_SHORT_K;
	km = (mg_dbg_flag&MG_DBG_NO_KALLOC) && (mg_dbg_flag&MG_DBG_SHORTK)? 0 : km_init2(km0, 0x4000);

	KCALLOC(km, dst_done, n_dst);
	KMALLOC(km, dst_group, n_dst);
	for (i = 0; i < n_dst; ++i) // multiple dst[] may have the same dst[].v. We need to group them first.
		dst_group[i] = (uint64_t)dst[i].v<<32 | i;
	radix_sort_gfa64(dst_group, dst_group + n_dst);

	h2 = sp2_init2(km); // this hash table keeps all destinations
	sp2_resize(h2, n_dst * 2);
	for (i = 1, j = 0; i <= n_dst; ++i) {
		if (i == n_dst || dst_group[i]>>32 != dst_group[j]>>32) {
			k = sp2_put(h2, dst_group[j]>>32, &absent);
			kh_val(h2, k) = (uint64_t)j << 32 | (i - j);
			assert(absent);
			j = i;
		}
	}

	h = sp_init2(km); // this hash table keeps visited vertices
	sp_resize(h, 16);
	m_out = 16, n_out = 0;
	KMALLOC(km, out, m_out);

	id = 0;
	p = gen_sp_node(km, g, src, 0, id++);
	p->hash = kh_hash_uint32(src);
	kavl_insert(sp, &root, p, 0);
	k = sp_put(h, src, &absent);
	q = &kh_val(h, k);
	q->k = 1, q->p[0] = p, q->qs = q->qe = -1;

	n_done = 0;
	while (kavl_size(head, root) > 0) {
		int32_t i, nv;
		gfa_arc_t *av;
		sp_node_t *r;

		r = kavl_erase_first(sp, &root); // take out the closest vertex in the heap (as a binary tree)
		//fprintf(stderr, "XX\t%d\t%d\t%d\t%c%s[%d]\t%d\n", n_out, kavl_size(head, root), n_finished, "><"[(r->v&1)^1], g->seg[r->v>>1].name, r->v, (int32_t)(r->di>>32));
		if (n_out == m_out) KEXPAND(km, out, m_out);
		r->di = r->di>>32<<32 | n_out; // lower 32 bits now for position in the out[] array
		out[n_out++] = r;

		k = sp2_get(h2, r->v);
		if (k != kh_end(h2)) { // we have reached one dst vertex
			int32_t j, dist = r->di>>32, off = kh_val(h2, k) >> 32, cnt = (int32_t)kh_val(h2, k);
			for (j = 0; j < cnt; ++j) {
				mg_path_dst_t *t = &dst[(int32_t)dst_group[off + j]];
				int32_t done = 0;
				if (t->inner) {
					done = 1;
				} else {
					int32_t copy = 0;
					//if (mg_dbg_flag & MG_DBG_GC1) fprintf(stderr, "  src=%c%s[%d],qlen=%d\tdst=%c%s[%d]\ttarget_distx=%d,target_hash=%x\tdistx=%d,hash=%x\n", "><"[src&1], g->seg[src>>1].name, src, ql, "><"[t->v&1], g->seg[t->v>>1].name, t->v, t->target_dist - g->seg[src>>1].len, t->target_hash, dist - g->seg[src>>1].len, r->hash);
					if (t->n_path == 0) { // keep the shortest path
						copy = 1;
					} else if (t->target_dist >= 0) { // we have a target distance; choose the closest
						if (dist == t->target_dist && t->check_hash && r->hash == t->target_hash) { // we found the target path
							copy = 1, done = 1;
						} else {
							int32_t d0 = t->dist, d1 = dist;
							d0 = d0 > t->target_dist? d0 - t->target_dist : t->target_dist - d0;
							d1 = d1 > t->target_dist? d1 - t->target_dist : t->target_dist - d1;
							if (d1 < d0) copy = 1;
						}
					}
					if (copy) {
						t->path_end = n_out - 1, t->dist = dist, t->hash = r->hash, t->is_0 = r->is_0;
						if (t->target_dist >= 0) {
							if (dist == t->target_dist && t->check_hash && r->hash == t->target_hash) done = 1;
							else if (dist > t->target_dist + MG_SHORT_K_EXT) done = 1;
						}
					}
					++t->n_path;
					if (t->n_path >= max_k) done = 1;
				}
				if (dst_done[off + j] == 0 && done)
					dst_done[off + j] = 1, ++n_done;
			}
			if (n_done == n_dst) break;
		}

		nv = gfa_arc_n(g, r->v);
		av = gfa_arc_a(g, r->v);
		for (i = 0; i < nv; ++i) { // visit all neighbors
			gfa_arc_t *ai = &av[i];
			int32_t d = (r->di>>32) + (uint32_t)ai->v_lv;
			if (d > max_dist) continue; // don't probe vertices too far away
			k = sp_put(h, ai->w, &absent);
			q = &kh_val(h, k);
			if (absent) { // a new vertex visited
				q->k = 0, q->qs = q->qe = -1;
				//if (ql && qs) fprintf(stderr, "ql=%d,src=%d\tv=%c%s[%d]\n", ql, src, "><"[ai->w&1], g->seg[ai->w>>1].name, ai->w);
			}
			if (q->k < max_k) { // enough room: add to the heap
				p = gen_sp_node(km, g, ai->w, d, id++);
				p->pre = n_out - 1;
				p->hash = r->hash + kh_hash_uint32(ai->w);
				p->is_0 = r->is_0;
				if (ai->rank > 0) p->is_0 = 0;
				kavl_insert(sp, &root, p, 0);
				q->p[q->k++] = p;
				ks_heapup_sp(q->k, q->p);
			} else if (q->p[0]->di>>32 > d) { // shorter than the longest path so far: replace the longest
				p = kavl_erase(sp, &root, q->p[0], 0);
				if (p) {
					p->di = (uint64_t)d<<32 | (id++);
					p->pre = n_out - 1;
					p->hash = r->hash + kh_hash_uint32(ai->w);
					p->is_0 = r->is_0;
					if (ai->rank > 0) p->is_0 = 0;
					kavl_insert(sp, &root, p, 0);
					ks_heapdown_sp(0, q->k, q->p);
				} else {
					fprintf(stderr, "Warning: logical bug in gfa_shortest_k(): q->k=%d,q->p[0]->{d,i}={%d,%d},d=%d,src=%u,max_dist=%d,n_dst=%d\n", q->k, (int32_t)(q->p[0]->di>>32), (int32_t)q->p[0]->di, d, src, max_dist, n_dst);
					km_destroy(km);
					return 0;
				}
			} // else: the path is longer than all the existing paths ended at ai->w
		}
	}

	kfree(km, dst_group);
	kfree(km, dst_done);
	sp_destroy(h);
	mg_idx_hfree(h_seeds);
	kfree(km, seeds);
	kfree(km, mini.a);
	// NB: AVL nodes are not deallocated. When km==0, they are memory leaks.

	for (i = 0, n_found = 0; i < n_dst; ++i)
		if (dst[i].n_path > 0) ++n_found;

	if (n_found > 0 && n_pathv) { // then generate the backtrack array
		int32_t n, *trans;
		KCALLOC(km, trans, n_out); // used to squeeze unused elements in out[]
		for (i = 0; i < n_dst; ++i) { // mark dst vertices with a target distance
			mg_path_dst_t *t = &dst[i];
			if (t->n_path > 0 && t->target_dist >= 0 && t->path_end >= 0)
				trans[(int32_t)out[t->path_end]->di] = 1;
		}
		for (i = 0; i < n_out; ++i) { // mark dst vertices without a target distance
			k = sp2_get(h2, out[i]->v);
			if (k != kh_end(h2)) { // TODO: check if this is correct!
				int32_t off = kh_val(h2, k)>>32, cnt = (int32_t)kh_val(h2, k);
				for (j = off; j < off + cnt; ++j)
					if (dst[j].target_dist < 0)
						trans[i] = 1;
			}
		}
		for (i = n_out - 1; i >= 0; --i) // mark all predecessors
			if (trans[i] && out[i]->pre >= 0)
				trans[out[i]->pre] = 1;
		for (i = n = 0; i < n_out; ++i) // generate coordinate translations
			if (trans[i]) trans[i] = n++;
			else trans[i] = -1;

		*n_pathv = n;
		KMALLOC(km0, ret, n);
		for (i = 0; i < n_out; ++i) { // generate the backtrack array
			mg_pathv_t *p;
			if (trans[i] < 0) continue;
			p = &ret[trans[i]];
			p->v = out[i]->v, p->d = out[i]->di >> 32;
			p->pre = out[i]->pre < 0? out[i]->pre : trans[out[i]->pre];
		}
		for (i = 0; i < n_dst; ++i) // translate "path_end"
			if (dst[i].path_end >= 0)
				dst[i].path_end = trans[dst[i].path_end];
	}

	km_destroy(km);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %r9d, %r15d
movq %r8, %r13
movq %rcx, 0x60(%rsp)
movq %rdx, 0x80(%rsp)
movq %rsi, 0xa0(%rsp)
movq 0xe8(%rsp), %rax
andq $0x0, 0x38(%rsp)
testq %rax, %rax
je 0xe5a9
andl $0x0, (%rax)
movq 0x60(%rsp), %rax
testl %eax, %eax
jle 0xe631
movq %rax, %rcx
movl 0xe0(%rsp), %eax
movl %ecx, %r14d
imulq $0x24, %r14, %rcx
xorl %edx, %edx
movl $0x80000000, %esi       # imm = 0x80000000
cmpq %rdx, %rcx
je 0xe609
cmpl $0x0, 0xc(%r13,%rdx)
js 0xe5e7
orl $-0x1, 0x1c(%r13,%rdx)
movl 0x14(%r13,%rdx), %r8d
andl %esi, %r8d
jmp 0xe5f8
andl $0x0, 0x1c(%r13,%rdx)
movl 0x14(%r13,%rdx), %r8d
andl %esi, %r8d
incl %r8d
movl %r8d, 0x14(%r13,%rdx)
orl $-0x1, 0x18(%r13,%rdx)
addq $0x24, %rdx
jmp 0xe5ca
cmpl $0xf, %eax
pushq $0xf
popq %rcx
cmovll %eax, %ecx
movl %ecx, 0x58(%rsp)
leaq 0x2005b(%rip), %rax     # 0x2e678
movl (%rax), %eax
notl %eax
testb $0x21, %al
movq %rdi, 0x98(%rsp)
jne 0xe639
xorl %ebx, %ebx
jmp 0xe646
xorl %r13d, %r13d
jmp 0xf09a
movl $0x4000, %esi           # imm = 0x4000
callq 0x24ac
movq %rax, %rbx
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x24f0
movq %rax, 0x88(%rsp)
leaq (,%r14,8), %rsi
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
callq 0x266c
movq %rax, 0x30(%rsp)
xorl %eax, %eax
movq %r13, %rcx
movq 0x30(%rsp), %rsi
cmpq %rax, %r14
je 0xe69e
movl (%rcx), %edx
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, (%rsi,%rax,8)
incq %rax
addq $0x24, %rcx
jmp 0xe683
movq 0x30(%rsp), %rdi
leaq (%rdi,%r14,8), %rsi
callq 0x3d53
pushq $0x20
popq %rdx
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x24f0
movq %rbx, 0x18(%rax)
movq 0x60(%rsp), %rbx
leal (%rbx,%rbx), %esi
movq %rax, 0x48(%rsp)
movq %rax, %rdi
callq 0xf331
leal 0x1(%rbx), %eax
movq %rax, 0x78(%rsp)
xorl %edx, %edx
pushq $0x1
popq %r9
movq %r13, 0x68(%rsp)
movq %r14, 0x90(%rsp)
movq %r15, 0x70(%rsp)
movq 0x48(%rsp), %r12
cmpq 0x78(%rsp), %rbp
je 0xe894
movslq %edx, %rsi
cmpq %r14, %rbp
jne 0xe71b
movq 0x30(%rsp), %rax
movq (%rax,%rsi,8), %r15
jmp 0xe735
movq 0x30(%rsp), %rcx
movq (%rcx,%rsi,8), %r15
movq (%rcx,%rbp,8), %rcx
xorq %r15, %rcx
shrq $0x20, %rcx
je 0xe873
movq 0x10(%r12), %rbx
testq %rbx, %rbx
je 0xe74b
movb (%r12), %cl
movl %r9d, %r13d
shll %cl, %r13d
jmp 0xe74e
xorl %r13d, %r13d
movl %r13d, %eax
shrl %eax
movl %r13d, %ecx
shrl $0x2, %ecx
addl %eax, %ecx
cmpl %ecx, 0x4(%r12)
movl %edx, 0x8(%rsp)
movq %rsi, 0x20(%rsp)
jae 0xe776
movq %rbp, 0x10(%rsp)
movl (%r12), %ebp
jmp 0xe7a3
leal 0x1(%r13), %esi
movq %r12, %rdi
callq 0xf331
testl %eax, %eax
js 0xe87b
movq %rbp, 0x10(%rsp)
movl (%r12), %ebp
pushq $0x1
popq %rax
movl %eax, %r13d
movl %ebp, %ecx
shll %cl, %r13d
movq 0x10(%r12), %rbx
shrq $0x20, %r15
movl %r13d, %r14d
decl %r14d
movl %r15d, %edi
callq 0xf0ff
imull $0x9e3779b9, %eax, %r13d # imm = 0x9E3779B9
negb %bpl
movl %ebp, %ecx
shrl %cl, %r13d
movq 0x8(%r12), %rax
movl %r13d, %ecx
movq 0x10(%rsp), %rbp
pushq $0x1
popq %r9
movq 0x20(%rsp), %r10
movl %ecx, %edx
shrl $0x5, %edx
movl (%rax,%rdx,4), %edi
movl %r9d, %esi
shll %cl, %esi
btl %ecx, %edi
jae 0xe816
movl %ecx, %r8d
imulq $0xc, %r8, %r8
cmpl %r15d, (%rbx,%r8)
je 0xe816
incl %ecx
andl %r14d, %ecx
cmpl %r13d, %ecx
jne 0xe7da
movl %r13d, %edx
shrl $0x5, %edx
movl %r9d, %esi
movl %r13d, %ecx
shll %cl, %esi
movl (%rax,%rdx,4), %edi
jmp 0xe819
movl %ecx, %r13d
testl %edi, %esi
movq 0x90(%rsp), %r14
je 0xe82b
xorl %eax, %eax
movb $0x1, %cl
jmp 0xe846
movl %r13d, %ecx
imulq $0xc, %rcx, %rcx
movl %r15d, (%rbx,%rcx)
orl %esi, (%rax,%rdx,4)
movq 0x48(%rsp), %rax
incl 0x4(%rax)
xorl %ecx, %ecx
movl %r9d, %eax
movl 0x8(%rsp), %esi
shlq $0x20, %r10
movl %ebp, %edx
subl %esi, %edx
movslq %edx, %rdx
orq %r10, %rdx
movl %r13d, %esi
imulq $0xc, %rsi, %rsi
movq %rdx, 0x4(%rbx,%rsi)
movl %ebp, %edx
testb %cl, %cl
movq 0x68(%rsp), %r13
jne 0xf0af
incq %rbp
jmp 0xe6fd
movq 0x10(%r12), %rbx
xorl %ecx, %ecx
pushq $-0x1
popq %rax
pushq $0x1
popq %r9
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %r10
jmp 0xe84a
leaq 0x5c(%rsp), %r12
movl %eax, (%r12)
pushq $0x1
popq %rsi
pushq $0x20
popq %rdx
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x24f0
movq %rax, %r15
movq %rbx, 0x18(%rax)
pushq $0x10
popq %rbp
movq %rax, %rdi
movl %ebp, %esi
callq 0xf570
movl $0x80, %esi
movq %rbx, %rdi
callq 0x266c
movq %rax, 0x28(%rsp)
movq $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq 0x80(%rsp), %rbx
movl %ebx, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf0cc
movq %rax, %r14
movl %ebx, %edi
callq 0xf0ff
movl %eax, 0x10(%r14)
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xdd42
movq %r15, %rdi
movl %ebx, %esi
movq %r15, 0x78(%rsp)
movq %r12, %rdx
callq 0xf12a
movq 0x10(%r15), %rcx
movl %eax, %eax
imulq $0x8c, %rax, %rax
movabsq $-0xffffffff, %rdx      # imm = 0xFFFFFFFF00000001
movq %rdx, 0x4(%rcx,%rax)
movq %r14, 0x14(%rcx,%rax)
orl $-0x1, 0xc(%rcx,%rax)
pushq $0x1
popq %rax
movl %eax, 0x20(%rsp)
xorl %r12d, %r12d
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0xedc8
cmpl $0x0, 0x2c(%rax)
je 0xedc8
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xdfc1
movq %rax, 0x8(%rsp)
cmpl %ebp, 0x10(%rsp)
jne 0xe9b6
movl %ebp, %ebx
shrl %ebx
addl %ebp, %ebx
cmpl $0x4, %ebp
pushq $0x10
popq %rax
cmovbl %eax, %ebx
leaq (,%rbx,8), %rdx
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x2774
movl %ebx, 0x50(%rsp)
movq 0x48(%rsp), %rdi
jmp 0xe9c4
movl %ebp, 0x50(%rsp)
movq 0x48(%rsp), %rdi
movq 0x28(%rsp), %rax
movq 0x8(%rsp), %rsi
movq (%rsi), %rbx
movq 0x10(%rsp), %rdx
movl %edx, %ecx
movl %edx, (%rsi)
movq %rax, 0x28(%rsp)
movq %rsi, (%rax,%rcx,8)
movl 0x8(%rsi), %ebp
movl %ebp, %esi
movq %rdi, %r14
callq 0xf23e
movq 0x10(%r14), %rdx
testq %rdx, %rdx
je 0xe9fe
movb (%r14), %cl
pushq $0x1
popq %rsi
shll %cl, %esi
jmp 0xea00
xorl %esi, %esi
movq 0x10(%rsp), %rcx
incl %ecx
movl %ecx, 0x54(%rsp)
cmpl %esi, %eax
jne 0xea19
movl %r12d, 0x40(%rsp)
jmp 0xebc6
shrq $0x20, %rbx
movl %eax, %eax
imulq $0xc, %rax, %rax
movq 0x4(%rdx,%rax), %rdx
movq %rdx, %rax
sarq $0x20, %rax
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
movq 0x30(%rsp), %rdx
leaq (%rdx,%rax,8), %r15
addq 0x88(%rsp), %rax
xorl %esi, %esi
movq %r15, 0x40(%rsp)
cmpq %rsi, %rcx
je 0xebae
movslq (%r15,%rsi,8), %rdi
imulq $0x24, %rdi, %rdi
movl 0xc(%r13,%rdi), %r10d
testl %r10d, %r10d
js 0xeaf7
addq %r13, %rdi
movl 0x4(%rdi), %r14d
movl 0x14(%rdi), %r8d
movl %r8d, %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
je 0xeaff
testl %r14d, %r14d
js 0xeb65
cmpl $0x40000000, %r10d      # imm = 0x40000000
jb 0xeab8
cmpl %ebx, %r14d
jne 0xeab8
movq 0x8(%rsp), %rdx
movl 0x10(%rdx), %r15d
movl %ebx, %ebp
pushq $0x1
popq %r9
cmpl 0x8(%rdi), %r15d
movq 0x40(%rsp), %r15
je 0xeb05
movl 0x1c(%rdi), %r9d
subl %r14d, %r9d
movl %r9d, %r15d
negl %r15d
cmovsl %r9d, %r15d
movl %r14d, %r9d
subl %ebx, %r9d
movq %r13, %rdx
movl %r12d, %r13d
movl %r9d, %r12d
negl %r12d
cmovsl %r9d, %r12d
xorl %r9d, %r9d
movl %r14d, %ebp
cmpl %r15d, %r12d
movq 0x40(%rsp), %r15
movl %r13d, %r12d
movq %rdx, %r13
jb 0xeb05
jmp 0xeb68
movb $0x1, %dil
jmp 0xeb94
xorl %r9d, %r9d
movl %r14d, %ebp
movq 0x10(%rsp), %r8
movl %r8d, 0x18(%rdi)
movl %ebx, 0x1c(%rdi)
movq 0x8(%rsp), %rdx
movl 0x10(%rdx), %r8d
movl %r8d, 0x20(%rdi)
movl 0x14(%rdx), %r8d
shll $0x1f, %r8d
orl %r11d, %r8d
movl %r8d, 0x14(%rdi)
testl %ebp, %ebp
js 0xeb68
cmpl $0x40000000, %r10d      # imm = 0x40000000
jb 0xeb53
cmpl %ebx, %ebp
jne 0xeb53
movq 0x8(%rsp), %rdx
movl 0x10(%rdx), %r10d
cmpl 0x8(%rdi), %r10d
jne 0xeb53
pushq $0x1
popq %r9
jmp 0xeb68
addl $0x3e8, %ebp            # imm = 0x3E8
cmpl %ebx, %ebp
pushq $0x1
popq %r10
cmovll %r10d, %r9d
jmp 0xeb68
xorl %r9d, %r9d
leal 0x1(%r8), %r10d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
andl $0x80000000, %r8d       # imm = 0x80000000
orl %r10d, %r8d
movl %r8d, 0x14(%rdi)
cmpl 0x58(%rsp), %r10d
setge %r8b
testl %r9d, %r9d
setne %dil
orb %r8b, %dil
testb %dil, %dil
je 0xeba6
cmpb $0x0, (%rax,%rsi)
jne 0xeba6
movb $0x1, (%rax,%rsi)
incl %r12d
incq %rsi
jmp 0xea51
cmpl 0x60(%rsp), %r12d
je 0xedbf
movl %r12d, 0x40(%rsp)
movq 0x8(%rsp), %rax
movl 0x8(%rax), %ebp
movq 0xa0(%rsp), %rcx
movq 0x48(%rcx), %rax
movq 0x58(%rcx), %rcx
movl %ebp, %edx
movq (%rcx,%rdx,8), %rcx
testl %ecx, %ecx
movl $0x0, %ebx
cmovgl %ecx, %ebx
shlq $0x5, %rbx
shrq $0x1b, %rcx
andq $-0x20, %rcx
leaq (%rax,%rcx), %r13
addq $0xc, %r13
xorl %r14d, %r14d
movq 0x70(%rsp), %rbp
cmpq %r14, %rbx
je 0xeda3
movq 0x8(%rsp), %rax
movl 0x4(%rax), %r12d
addq -0xc(%r13,%r14), %r12
cmpl %ebp, %r12d
jg 0xed9a
movl -0x4(%r13,%r14), %esi
movq 0x78(%rsp), %r15
movq %r15, %rdi
leaq 0x5c(%rsp), %rdx
callq 0xf12a
movq 0x10(%r15), %rcx
movl %eax, %eax
imulq $0x8c, %rax, %rax
leaq (%rcx,%rax), %r15
addq $0x4, %r15
cmpl $0x0, 0x5c(%rsp)
je 0xec6b
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, (%r15)
orl $-0x1, 0x8(%r15)
xorl %eax, %eax
jmp 0xec6e
movl (%r15), %eax
cmpl 0x58(%rsp), %eax
jge 0xecfe
movl -0x4(%r13,%r14), %esi
movq 0x18(%rsp), %rdi
movl %r12d, %edx
movl 0x20(%rsp), %ecx
callq 0xf0cc
movq %rax, %r12
movq 0x10(%rsp), %rax
movl %eax, 0xc(%r12)
movq 0x8(%rsp), %rax
movl 0x10(%rax), %ebp
movl -0x4(%r13,%r14), %edi
callq 0xf0ff
addl %ebp, %eax
movl %eax, 0x10(%r12)
cmpl $0x0, (%r13,%r14)
movl $0x0, %eax
jg 0xecc9
movq 0x8(%rsp), %rax
movl 0x14(%rax), %eax
incl 0x20(%rsp)
movl %eax, 0x14(%r12)
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xdd42
leaq 0x10(%r15), %rsi
movslq (%r15), %rax
leaq 0x1(%rax), %rdi
movl %edi, (%r15)
movq %r12, 0x10(%r15,%rax,8)
callq 0xe415
jmp 0xed95
movq 0x10(%r15), %rsi
movl 0x4(%rsi), %eax
movslq %r12d, %rcx
cmpq %rcx, %rax
jbe 0xed9a
leaq 0x38(%rsp), %rdi
xorl %edx, %edx
callq 0xdfc1
testq %rax, %rax
je 0xf047
movq %rax, %rbp
shlq $0x20, %r12
movl 0x20(%rsp), %eax
orq %r12, %rax
movq %rax, (%rbp)
movq 0x10(%rsp), %rax
movl %eax, 0xc(%rbp)
movq 0x8(%rsp), %rax
movl 0x10(%rax), %r12d
movl -0x4(%r13,%r14), %edi
callq 0xf0ff
addl %r12d, %eax
movl %eax, 0x10(%rbp)
cmpl $0x0, (%r13,%r14)
movl $0x0, %eax
jg 0xed6e
movq 0x8(%rsp), %rax
movl 0x14(%rax), %eax
leaq 0x10(%r15), %r12
incl 0x20(%rsp)
movl %eax, 0x14(%rbp)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0xdd42
movslq (%r15), %rsi
xorl %edi, %edi
movq %r12, %rdx
callq 0xe3c5
movq 0x70(%rsp), %rbp
addq $0x20, %r14
jmp 0xec02
movl 0x54(%rsp), %eax
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %r13
movl 0x40(%rsp), %r12d
movl 0x50(%rsp), %ebp
jmp 0xe954
movl 0x54(%rsp), %eax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0x2577
movq %rbx, %rdi
movq 0x88(%rsp), %rsi
callq 0x2577
movq 0x78(%rsp), %rbx
testq %rbx, %rbx
je 0xee1b
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %r14
movq %r14, %rdi
callq 0x2577
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x2577
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2577
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x12880
movq 0x18(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2577
movq %r14, %rdi
xorl %esi, %esi
callq 0x2577
imulq $0x24, 0x90(%rsp), %r12
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %eax, %eax
cmpq %rbx, %r12
je 0xee65
movl 0x14(%r13,%rbx), %edx
andl %ecx, %edx
cmpl $0x1, %edx
sbbl $-0x1, %eax
addq $0x24, %rbx
jmp 0xee4d
xorl %r13d, %r13d
cmpq $0x0, 0xe8(%rsp)
je 0xf090
testl %eax, %eax
je 0xf090
movl 0x10(%rsp), %r15d
pushq $0x4
popq %rdx
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x24f0
movq %rax, %r14
xorl %eax, %eax
movq 0x68(%rsp), %rdx
movq 0x28(%rsp), %rsi
cmpq %rax, %r12
je 0xeed8
testl $0x7fffffff, 0x14(%rdx,%rax) # imm = 0x7FFFFFFF
je 0xeed2
cmpl $0x0, 0x4(%rdx,%rax)
js 0xeed2
movslq 0x18(%rdx,%rax), %rcx
testq %rcx, %rcx
js 0xeed2
movq (%rsi,%rcx,8), %rcx
movslq (%rcx), %rcx
movl $0x1, (%r14,%rcx,4)
addq $0x24, %rax
jmp 0xeea3
leaq 0x4(%rdx), %rbx
xorl %r13d, %r13d
movq 0x48(%rsp), %rbp
cmpq %r15, %r13
je 0xef61
movq (%rsi,%r13,8), %rax
movl 0x8(%rax), %esi
movq %rbp, %rdi
callq 0xf23e
movq 0x10(%rbp), %rdx
testq %rdx, %rdx
je 0xef0b
movb (%rbp), %cl
pushq $0x1
popq %rsi
shll %cl, %esi
jmp 0xef0d
xorl %esi, %esi
cmpl %esi, %eax
movq 0x28(%rsp), %rsi
jne 0xef1b
incq %r13
jmp 0xeee4
movl %eax, %eax
imulq $0xc, %rax, %rax
movq 0x4(%rdx,%rax), %rax
movq %rax, %rcx
sarq $0x20, %rcx
movabsq $0x100000001, %rdx      # imm = 0x100000001
imulq %rdx, %rax
sarq $0x20, %rax
imulq $0x24, %rcx, %rdx
addq %rbx, %rdx
cmpq %rax, %rcx
jge 0xef16
cmpl $0x0, (%rdx)
jns 0xef58
movl $0x1, (%r14,%r13,4)
incq %rcx
addq $0x24, %rdx
jmp 0xef46
leaq -0x1(%r15), %rax
movq 0x98(%rsp), %rdi
testl %eax, %eax
js 0xef9a
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl $0x0, (%r14,%rcx,4)
je 0xef95
movq (%rsi,%rcx,8), %rcx
movslq 0xc(%rcx), %rcx
testq %rcx, %rcx
js 0xef95
movl $0x1, (%r14,%rcx,4)
decq %rax
jmp 0xef6d
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %rax, %r15
je 0xefc6
movl (%r14,%rax,4), %edx
cmpl $0x1, %edx
movl $0x0, %esi
sbbl %esi, %esi
cmpl $0x1, %edx
movl %ecx, %edx
sbbl $-0x1, %edx
orl %ecx, %esi
movl %esi, (%r14,%rax,4)
incq %rax
movl %edx, %ecx
jmp 0xef9e
movq 0xe8(%rsp), %rax
movl %ecx, (%rax)
movl %ecx, %eax
imulq $0xc, %rax, %rsi
callq 0x266c
movq 0x28(%rsp), %rdi
movq %rax, %r13
xorl %eax, %eax
cmpq %rax, %r15
je 0xf023
movslq (%r14,%rax,4), %rcx
testq %rcx, %rcx
js 0xf01e
imulq $0xc, %rcx, %rcx
movq (%rdi,%rax,8), %rdx
movl 0x8(%rdx), %esi
movl %esi, (%r13,%rcx)
movl 0x4(%rdx), %esi
movl %esi, 0x4(%r13,%rcx)
movslq 0xc(%rdx), %rdx
testq %rdx, %rdx
js 0xf018
movl (%r14,%rdx,4), %edx
addq %r13, %rcx
movl %edx, 0x8(%rcx)
incq %rax
jmp 0xefe5
xorl %eax, %eax
movq 0x68(%rsp), %rdx
cmpq %rax, %r12
je 0xf090
movslq 0x18(%rdx,%rax), %rcx
testq %rcx, %rcx
js 0xf041
movl (%r14,%rcx,4), %ecx
movl %ecx, 0x18(%rdx,%rax)
addq $0x24, %rax
jmp 0xf02a
movq 0x1efaa(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
movl (%r15), %edx
movq 0x10(%r15), %rax
movq (%rax), %r8
movq %r8, %rcx
shrq $0x20, %rcx
subq $0x8, %rsp
leaq 0x14c4d(%rip), %rsi     # 0x23cba
xorl %r13d, %r13d
movl %r12d, %r9d
xorl %eax, %eax
pushq 0x68(%rsp)
pushq 0x80(%rsp)
pushq 0x98(%rsp)
callq 0x2210
addq $0x20, %rsp
movq 0x18(%rsp), %rdi
callq 0x253c
movq %r13, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14b82(%rip), %rdi     # 0x23c38
leaq 0x14b82(%rip), %rsi     # 0x23c3f
leaq 0x14b84(%rip), %rcx     # 0x23c48
pushq $0x52
popq %rdx
callq 0x2160