// File: /workspace/github_c_makefile_star2_O3/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_chain
mem_chain_v mem_chain(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, int len, const uint8_t *seq, void *buf)
{
	int i, b, e, l_rep;
	int64_t l_pac = bns->l_pac;
	mem_chain_v chain;
	kbtree_t(chn) *tree;
	smem_aux_t *aux;

	kv_init(chain);
	if (len < opt->min_seed_len) return chain; // if the query is shorter than the seed length, no match
	tree = kb_init(chn, KB_DEFAULT_SIZE);

	aux = buf? (smem_aux_t*)buf : smem_aux_init();

	mem_collect_intv(opt, bwt, len, seq, aux);

	for (i = 0, b = e = l_rep = 0; i < aux->mem.n; ++i) { // compute frac_rep
		bwtintv_t *p = &aux->mem.a[i];
		int sb = (p->info>>32), se = (uint32_t)p->info;
		if (p->x[2] <= opt->max_occ) continue;
		if (sb > e) l_rep += e - b, b = sb, e = se;
		else e = e > se? e : se;
	}
	l_rep += e - b;
	for (i = 0; i < aux->mem.n; ++i) {
		bwtintv_t *p = &aux->mem.a[i];
		int step, count, slen = (uint32_t)p->info - (p->info>>32); // seed length
		int64_t k;
		step = p->x[2] > opt->max_occ? p->x[2] / opt->max_occ : 1;
		for (k = count = 0; k < p->x[2] && count < opt->max_occ; k += step, ++count) {
			mem_chain_t tmp, *lower, *upper;
			mem_seed_t s;
			int rid, to_add = 0;
			s.rbeg = tmp.pos = bwt_sa(bwt, p->x[0] + k); // this is the base coordinate in the forward-reverse reference
			s.qbeg = p->info>>32;
			s.score= s.len = slen;
			rid = bns_intv2rid(bns, s.rbeg, s.rbeg + s.len);
			if (rid < 0) continue; // bridging multiple reference sequences or the forward-reverse boundary; TODO: split the seed; don't discard it!!!
			if (kb_size(tree)) {
				kb_intervalp(chn, tree, &tmp, &lower, &upper); // find the closest chain
				if (!lower || !test_and_merge(opt, l_pac, lower, &s, rid)) to_add = 1;
			} else to_add = 1;
			if (to_add) { // add the seed as a new chain
				tmp.n = 1; tmp.m = 4;
				tmp.seeds = calloc(tmp.m, sizeof(mem_seed_t));
				tmp.seeds[0] = s;
				tmp.rid = rid;
				tmp.is_alt = !!bns->anns[rid].is_alt;
				kb_putp(chn, tree, &tmp);
			}
		}
	}
	if (buf == 0) smem_aux_destroy(aux);

	kv_resize(mem_chain_t, chain, kb_size(tree));

	#define traverse_func(p_) (chain.a[chain.n++] = *(p_))
	__kb_traverse(mem_chain_t, tree, traverse_func);
	#undef traverse_func

	for (i = 0; i < chain.n; ++i) chain.a[i].frac_rep = (float)l_rep / len;
	logMessage(__func__, LOG_LEVEL_DEBUG, "* fraction of repetitive seeds: %.3f\n", (float)l_rep / len);

	kb_destroy(chn, tree);
	return chain;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, 0x48(%rsp)
movq %rcx, 0x80(%rsp)
movq (%rcx), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, 0x40(%rsp)
movq $0x0, 0x10(%rdi)
movq %rsi, 0x20(%rsp)
cmpl %r8d, 0x78(%rsi)
jg 0x1567e
movq %r9, %r12
movq %rax, 0x70(%rsp)
movl %r8d, 0x1c(%rsp)
movq 0xf0(%rsp), %rbx
movl $0x200, %edi            # imm = 0x200
callq 0x14581
movq %rax, %r14
movq %rbx, %r9
testq %rbx, %rbx
jne 0x14893
callq 0x1f7c9
movq %rax, %r9
movq 0x20(%rsp), %rcx
movl 0x48(%rcx), %eax
andl $0x40, %eax
cmpl $0x1, %eax
movl $0x2, %eax
sbbl $0x0, %eax
movl %eax, 0x68(%rsp)
xorps %xmm0, %xmm0
cvtsi2ssl 0x78(%rcx), %xmm0
mulss 0x84(%rcx), %xmm0
movq $0x0, (%r9)
movl 0x1c(%rsp), %esi
testl %esi, %esi
movq %r9, 0x10(%rsp)
jle 0x14c41
cvtss2sd %xmm0, %xmm0
addsd 0x10ebf(%rip), %xmm0    # 0x257a0
cvttsd2si %xmm0, %eax
movl %eax, 0x34(%rsp)
leaq 0x18(%r9), %rax
movq %rax, 0x38(%rsp)
leaq 0x30(%r9), %rax
movq %rax, 0x28(%rsp)
xorl %r15d, %r15d
leaq 0x1488d(%rip), %rbp     # 0x29192
movq %r12, 0x60(%rsp)
movslq %r15d, %rax
cmpb $0x15, (%r12,%rax)
ja 0x149fd
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rdi
movq %r12, %rdx
movl %r15d, %ecx
movl 0x68(%rsp), %r8d
movq 0x38(%rsp), %rbx
movq %rbx, %r9
callq 0xfe31
movl %eax, %r15d
movq (%rbx), %rax
testq %rax, %rax
je 0x14a02
xorl %r12d, %r12d
xorl %ebx, %ebx
movq 0x10(%rsp), %r9
movq 0x28(%r9), %r13
movq 0x18(%r13,%r12), %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
subl %edx, %ecx
movq 0x20(%rsp), %rdx
cmpl %ecx, 0x78(%rdx)
jg 0x149e2
movq (%r9), %rcx
movq 0x10(%r9), %rax
cmpq 0x8(%r9), %rcx
jne 0x149bb
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r9)
shlq $0x5, %rsi
movq %rax, %rdi
leaq 0x13f1e(%rip), %rdx     # 0x288c0
movl $0xc9, %ecx
movq %rbp, %r8
callq 0x2324c
movq 0x10(%rsp), %r9
movq %rax, 0x10(%r9)
movq (%r9), %rcx
addq %r12, %r13
leaq 0x1(%rcx), %rdx
movq %rdx, (%r9)
shlq $0x5, %rcx
movupd (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
movq 0x18(%r9), %rax
incq %rbx
addq $0x20, %r12
cmpq %rbx, %rax
ja 0x14957
movl 0x1c(%rsp), %esi
movq 0x60(%rsp), %r12
jmp 0x14a0b
incl %r15d
jmp 0x14a0b
movl 0x1c(%rsp), %esi
movq 0x10(%rsp), %r9
cmpl %esi, %r15d
jl 0x1490a
movq (%r9), %r15
testl %r15d, %r15d
jle 0x14b5b
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %ebx, %ebx
movq 0x10(%r9), %rdx
movq %rbx, %rsi
shlq $0x5, %rsi
movq 0x18(%rdx,%rsi), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movl %eax, %edi
subl %ecx, %edi
cmpl 0x34(%rsp), %edi
jl 0x14b4f
addq %rsi, %rdx
movq 0x10(%rdx), %r8
movq 0x20(%rsp), %rdx
movslq 0x88(%rdx), %rdx
cmpq %rdx, %r8
ja 0x14b4f
addl %eax, %ecx
sarl %ecx
incl %r8d
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rdi
movl 0x1c(%rsp), %esi
movq %r12, %rdx
movq 0x38(%rsp), %r13
movq %r13, %r9
callq 0xfe31
movq 0x10(%rsp), %r9
movq (%r13), %rax
testq %rax, %rax
je 0x14b4f
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x28(%r9), %rcx
movq 0x18(%rcx,%r13), %rdx
movl %edx, %esi
shrq $0x20, %rdx
subq %rdx, %rsi
movq 0x20(%rsp), %rdx
movslq 0x78(%rdx), %rdx
cmpq %rdx, %rsi
jb 0x14b3f
movq (%r9), %rdx
movq 0x10(%r9), %rax
cmpq 0x8(%r9), %rdx
jne 0x14b1a
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r9)
shlq $0x5, %rsi
movq %rax, %rdi
leaq 0x13dc7(%rip), %rdx     # 0x288c0
movl $0xd8, %ecx
leaq 0x1468d(%rip), %r8      # 0x29192
callq 0x2324c
movq 0x10(%rsp), %r9
movq %rax, 0x10(%r9)
movq (%r9), %rdx
movq 0x28(%r9), %rcx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r9)
shlq $0x5, %rdx
movupd (%rcx,%r13), %xmm0
movups 0x10(%rcx,%r13), %xmm1
movups %xmm1, 0x10(%rax,%rdx)
movupd %xmm0, (%rax,%rdx)
movq 0x18(%r9), %rax
incq %rbp
addq $0x20, %r13
cmpq %rbp, %rax
ja 0x14aaa
incq %rbx
cmpq %r15, %rbx
jne 0x14a29
movq 0x20(%rsp), %rax
cmpq $0x0, 0x30(%rax)
movl 0x1c(%rsp), %esi
je 0x14c41
xorl %ebp, %ebp
leaq 0x98(%rsp), %rbx
leaq 0x13d40(%rip), %r15     # 0x288c0
leaq 0x1460b(%rip), %r13     # 0x29192
movslq %ebp, %rax
cmpb $0x15, (%r12,%rax)
ja 0x14c37
movq 0x20(%rsp), %rax
movl 0x30(%rax), %r9d
movl 0x78(%rax), %r8d
movq %rbx, (%rsp)
movq 0x48(%rsp), %rdi
movq %r12, %rdx
movl %ebp, %ecx
callq 0xfe48
movq 0x10(%rsp), %r9
movl %eax, %ebp
cmpq $0x0, 0xa8(%rsp)
je 0x14c31
movq (%r9), %rcx
movq 0x10(%r9), %rax
cmpq 0x8(%r9), %rcx
jne 0x14c0b
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r9)
shlq $0x5, %rsi
movq %rax, %rdi
movq %r15, %rdx
movl $0xe3, %ecx
movq %r13, %r8
callq 0x2324c
movq 0x10(%rsp), %r9
movq %rax, 0x10(%r9)
movq (%r9), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r9)
shlq $0x5, %rcx
movupd 0x98(%rsp), %xmm0
movups 0xa8(%rsp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
movl 0x1c(%rsp), %esi
jmp 0x14c39
incl %ebp
cmpl %esi, %ebp
jl 0x14b87
movq (%r9), %rdi
movq 0x10(%r9), %rsi
callq 0x1407c
movq 0x10(%rsp), %rdi
movq (%rdi), %rcx
testq %rcx, %rcx
je 0x15271
movq 0x10(%rdi), %rax
movq 0x20(%rsp), %rdx
movslq 0x8c(%rdx), %rdx
addq $0x18, %rax
xorl %esi, %esi
movq %rcx, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %rdx, -0x8(%rax)
jbe 0x14cad
movq (%rax), %r10
movq %r10, %r11
shrq $0x20, %r11
cmpl %r11d, %r8d
jge 0x14ca3
addl %r9d, %r8d
subl %esi, %r8d
movl %r8d, %r9d
movl %r10d, %r8d
movl %r11d, %esi
jmp 0x14cad
cmpl %r10d, %r8d
cmovgl %r8d, %r10d
movl %r10d, %r8d
addq $0x20, %rax
decq %rdi
jne 0x14c7d
subl %esi, %r8d
addl %r9d, %r8d
xorps %xmm0, %xmm0
cvtsi2ss %r8d, %xmm0
movss %xmm0, 0xc(%rsp)
xorl %r9d, %r9d
movq 0x10(%rsp), %rdi
movq 0x10(%rdi), %r13
movq %r9, %rsi
shlq $0x5, %rsi
movq 0x10(%r13,%rsi), %rax
movq 0x18(%r13,%rsi), %r10
movq 0x20(%rsp), %rdx
movslq 0x8c(%rdx), %r8
cmpq %r8, %rax
jbe 0x14d06
xorl %edx, %edx
divq %r8
cltq
movq %rax, 0x78(%rsp)
jmp 0x14d19
movl $0x1, %edx
movq %rdx, 0x78(%rsp)
testq %rax, %rax
je 0x15263
movq %r9, 0x88(%rsp)
addq %rsi, %r13
movq %r10, %rcx
movq %r10, %rax
shrq $0x20, %rax
subq %rax, %rcx
movq %rcx, 0x58(%rsp)
movslq %ecx, %rax
movq %rax, 0x90(%rsp)
xorl %r12d, %r12d
xorl %esi, %esi
movq %r13, 0x50(%rsp)
movq 0x20(%rsp), %rax
cmpl 0x8c(%rax), %esi
jge 0x15258
movl %esi, 0x28(%rsp)
movq (%r13), %rsi
addq %r12, %rsi
movq 0x48(%rsp), %rdi
callq 0xef5e
movq %rax, %rbp
movl 0x1c(%r13), %ebx
movq 0x90(%rsp), %rax
leaq (%rax,%rbp), %r15
movq 0x80(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x114e7
movl %eax, 0x38(%rsp)
testl %eax, %eax
js 0x14e6d
cmpl $0x0, 0x20(%r14)
je 0x14fce
movq (%r14), %rax
testq %rax, %rax
je 0x14fce
xorl %r13d, %r13d
movl (%rax), %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x2, %edx
jb 0x14e46
movl %edx, %ecx
sarl %ecx
testl %ecx, %ecx
jle 0x14e07
leaq 0x4(%rax), %rdi
xorl %esi, %esi
movl %ecx, %r8d
leal (%rsi,%r8), %r9d
sarl %r9d
movslq %r9d, %r10
leaq (%r10,%r10,4), %r10
cmpq %rbp, 0x18(%rdi,%r10,8)
jl 0x14df4
movl %r9d, %r8d
jmp 0x14dfa
incl %r9d
movl %r9d, %esi
cmpl %r8d, %esi
jl 0x14dda
cmpl %ecx, %esi
jne 0x14e09
decl %ecx
jmp 0x14e38
xorl %esi, %esi
movslq %esi, %rcx
leaq (%rcx,%rcx,4), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
cmpq %rbp, 0x1c(%rax,%rsi,8)
setl %dil
setg %r8b
subl %r8d, %edi
movl %edi, %esi
sarl $0x1f, %esi
addl %esi, %ecx
testl %edi, %edi
jne 0x14e34
testl %ecx, %ecx
jns 0x14e7b
testl %ecx, %ecx
js 0x14e46
movl %ecx, %esi
leaq (%rsi,%rsi,4), %rsi
leaq (%rax,%rsi,8), %r13
addq $0x4, %r13
testb $0x1, %dl
je 0x14e63
movslq 0xc(%r14), %rdx
addq %rdx, %rax
movslq %ecx, %rcx
movq 0x8(%rax,%rcx,8), %rax
testq %rax, %rax
jne 0x14dbd
testq %r13, %r13
jne 0x14e89
jmp 0x14fce
movq 0x10(%rsp), %rdi
movl 0x28(%rsp), %esi
jmp 0x15247
addq $0x4, %rax
movl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %r13
movl 0x38(%rsp), %eax
cmpl %eax, 0xc(%r13)
jne 0x14fce
movq 0x20(%r13), %rax
movl (%r13), %ecx
movslq %ecx, %rdx
leaq (%rdx,%rdx,2), %r8
movl -0x10(%rax,%r8,8), %edi
movslq -0xc(%rax,%r8,8), %rsi
movq -0x18(%rax,%r8,8), %r8
cmpl %ebx, 0x8(%rax)
jg 0x14ee5
leal (%rsi,%rdi), %r9d
movq 0x58(%rsp), %r10
addl %ebx, %r10d
cmpl %r9d, %r10d
jg 0x14ee5
cmpq (%rax), %rbp
jl 0x14ee5
leaq (%r8,%rsi), %r9
cmpq %r9, %r15
jg 0x14ee5
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %r13
jmp 0x14e72
movq 0x70(%rsp), %r9
cmpq %r9, %r8
jge 0x14ef9
cmpq %r9, %rbp
jl 0x14f0c
jmp 0x14fce
cmpq %r9, %rbp
jl 0x14f0c
movq 0x70(%rsp), %r9
cmpq %r9, (%rax)
jl 0x14fce
movq %rbp, %r9
subq %r8, %r9
js 0x14fce
movl %ebx, %r8d
subl %edi, %r8d
movslq %r8d, %rdi
movq %rdi, %r10
subq %r9, %r10
movq 0x20(%rsp), %r8
movslq 0x24(%r8), %r8
cmpq %r8, %r10
jg 0x14fce
movq %r9, %r10
subq %rdi, %r10
cmpq %r8, %r10
jg 0x14fce
subq %rsi, %rdi
movq 0x20(%rsp), %r8
movslq 0x90(%r8), %r8
cmpq %r8, %rdi
jge 0x14fce
subq %rsi, %r9
cmpq %r8, %r9
jge 0x14fce
cmpl 0x4(%r13), %ecx
jne 0x14fa1
addl %ecx, %ecx
movl %ecx, 0x4(%r13)
movslq %ecx, %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
leaq 0x1393b(%rip), %rdx     # 0x288c0
movl $0x11a, %ecx            # imm = 0x11A
leaq 0x14212(%rip), %r8      # 0x291a3
callq 0x2324c
movq %rax, 0x20(%r13)
movl (%r13), %ecx
movslq %ecx, %rdx
movq 0x10(%rsp), %rdi
movl 0x28(%rsp), %esi
incl %ecx
movl %ecx, (%r13)
leaq (%rdx,%rdx,2), %rcx
movq %rbp, (%rax,%rcx,8)
movl %ebx, 0x8(%rax,%rcx,8)
movq 0x58(%rsp), %rdx
movl %edx, 0xc(%rax,%rcx,8)
movl %edx, 0x10(%rax,%rcx,8)
jmp 0x15242
movl $0x4, %edi
movl $0x18, %esi
leaq 0x138e1(%rip), %r15     # 0x288c0
movq %r15, %rdx
movl $0x174, %ecx            # imm = 0x174
leaq 0x13962(%rip), %r8      # 0x28950
callq 0x2319c
movq %rax, %rcx
movq %rbp, (%rax)
movl %ebx, 0x8(%rax)
movq 0x58(%rsp), %rax
movl %eax, 0xc(%rcx)
movq %rcx, 0x68(%rsp)
movl %eax, 0x10(%rcx)
movq 0x80(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x38(%rsp), %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0x14(%rax,%rcx,8)
setne 0x60(%rsp)
incl 0x20(%r14)
movq (%r14), %r13
movl (%r13), %eax
movl %eax, %ecx
sarl %ecx
movl 0x1c(%r14), %edx
leal -0x1(,%rdx,2), %edx
cmpl %edx, %ecx
jne 0x1514c
incl 0x24(%r14)
movslq 0x10(%r14), %rsi
movl $0x1, %edi
movq %r15, %rdx
movl $0x108, %ecx            # imm = 0x108
leaq 0x1414a(%rip), %r8      # 0x291b2
callq 0x2319c
movq %rax, %rbx
movq %rax, (%r14)
movl $0x1, (%rax)
movslq 0xc(%r14), %rax
movq %r13, (%rbx,%rax)
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x1f83e
movl (%rbx), %eax
movq %rbx, %r13
jmp 0x1514c
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x2, %eax
jb 0x150f3
sarl %eax
testl %eax, %eax
jle 0x150d4
leaq 0x4(%r13), %rdx
xorl %ecx, %ecx
movl %eax, %esi
leal (%rcx,%rsi), %edi
sarl %edi
movslq %edi, %r8
leaq (%r8,%r8,4), %r8
cmpq %rbp, 0x18(%rdx,%r8,8)
jl 0x150ca
movl %edi, %esi
jmp 0x150ce
incl %edi
movl %edi, %ecx
cmpl %esi, %ecx
jl 0x150b3
jmp 0x150d6
xorl %ecx, %ecx
cmpl %eax, %ecx
jne 0x150e0
decl %eax
movl %eax, %ecx
jmp 0x150f3
movslq %ecx, %rax
leaq (%rax,%rax,4), %rax
xorl %edx, %edx
cmpq 0x1c(%r13,%rax,8), %rbp
setl %dl
subl %edx, %ecx
movslq %ecx, %r15
movslq 0xc(%r14), %rax
addq %r13, %rax
movq 0x8(%rax,%r15,8), %rcx
movl (%rcx), %eax
movl %eax, %edx
sarl %edx
movl 0x1c(%r14), %esi
leal -0x1(,%rsi,2), %esi
cmpl %esi, %edx
jne 0x15149
leaq 0x1(%r15), %rbx
movq %r14, %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0x1f83e
leaq (%rbx,%rbx,4), %rax
addl $0x2, %r15d
cmpq %rbp, 0x1c(%r13,%rax,8)
cmovgel %ebx, %r15d
movslq 0xc(%r14), %rax
movslq %r15d, %rcx
addq %r13, %rax
movq (%rax,%rcx,8), %rcx
movl (%rcx), %eax
movq %rcx, %r13
testb $0x1, %al
jne 0x1509b
cmpl $0x2, %eax
jae 0x15162
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
jmp 0x151b0
sarl %eax
testl %eax, %eax
jle 0x15191
leaq 0x4(%r13), %rdx
xorl %ecx, %ecx
movl %eax, %esi
leal (%rcx,%rsi), %edi
sarl %edi
movslq %edi, %r8
leaq (%r8,%r8,4), %r8
cmpq %rbp, 0x18(%rdx,%r8,8)
jl 0x15187
movl %edi, %esi
jmp 0x1518b
incl %edi
movl %edi, %ecx
cmpl %esi, %ecx
jl 0x15170
jmp 0x15193
xorl %ecx, %ecx
cmpl %eax, %ecx
jne 0x1519c
leal -0x1(%rax), %ecx
jmp 0x151b0
movslq %ecx, %rdx
leaq (%rdx,%rdx,4), %rdx
xorl %esi, %esi
cmpq 0x1c(%r13,%rdx,8), %rbp
setl %sil
subl %esi, %ecx
leal -0x1(%rax), %edx
movslq %ecx, %rbx
cmpl %edx, %ecx
je 0x151e9
leaq (%rbx,%rbx,4), %rcx
leaq 0x54(,%rcx,8), %rdi
addq %r13, %rdi
leaq 0x2c(,%rcx,8), %rsi
addq %r13, %rsi
movl %ebx, %ecx
notl %ecx
addl %ecx, %eax
cltq
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdx
callq 0x3600
movq 0x10(%rsp), %rdi
movl 0x28(%rsp), %esi
xorl %eax, %eax
movb 0x60(%rsp), %cl
movb %cl, %al
shll $0x1f, %eax
movl 0x34(%rsp), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
orl %eax, %edx
leaq (%rbx,%rbx,4), %rax
movabsq $0x400000001, %rcx      # imm = 0x400000001
movq %rcx, 0x2c(%r13,%rax,8)
movl 0x38(%rsp), %ecx
movl %ecx, 0x38(%r13,%rax,8)
movl %edx, 0x34(%rsp)
movl %edx, 0x3c(%r13,%rax,8)
movq %rbp, 0x44(%r13,%rax,8)
movq 0x68(%rsp), %rcx
movq %rcx, 0x4c(%r13,%rax,8)
addl $0x2, (%r13)
movq 0x50(%rsp), %r13
addq 0x78(%rsp), %r12
incl %esi
cmpq 0x10(%r13), %r12
jb 0x14d4b
movq (%rdi), %rcx
movq 0x88(%rsp), %r9
incq %r9
cmpq %r9, %rcx
ja 0x14cd2
jmp 0x1527a
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
cmpq $0x0, 0xf0(%rsp)
jne 0x1528a
callq 0x15695
movslq 0x20(%r14), %rax
movq 0x40(%rsp), %r12
movq %rax, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
leaq 0x13614(%rip), %rbx     # 0x288c0
leaq 0x1369d(%rip), %r15     # 0x28950
movq %rbx, %rdx
movl $0x17e, %ecx            # imm = 0x17E
movq %r15, %r8
callq 0x2324c
movq %rax, 0x10(%r12)
movl $0x8, %edi
movl $0x10, %esi
movq %rbx, %rdx
movl $0x181, %ecx            # imm = 0x181
movq %r15, %r8
callq 0x2319c
movq (%r14), %rcx
movq %rcx, (%rax)
movl $0x0, 0x8(%rax)
movl $0x8, %r12d
movq %rax, %rsi
movq %rsi, %rdx
testq %rcx, %rcx
je 0x15394
movl (%rcx), %esi
sarl %esi
cmpl %esi, 0x8(%rdx)
jg 0x15394
movq %rdx, %rsi
subq %rax, %rsi
sarq $0x4, %rsi
leal -0x1(%r12), %edi
movslq %edi, %rdi
cmpq %rdi, %rsi
jne 0x15362
leal (%r12,%r12), %ebp
movslq %ebp, %rsi
shlq $0x4, %rsi
movq %rax, %rdi
movq %rbx, %rdx
movl $0x181, %ecx            # imm = 0x181
movq %r15, %r8
callq 0x2324c
shlq $0x21, %r12
sarq $0x21, %r12
shlq $0x4, %r12
leaq (%rax,%r12), %rsi
addq $-0x10, %rsi
movq (%rsi), %rcx
movl %ebp, %r12d
jmp 0x15365
movq %rdx, %rsi
leaq 0x10(%rsi), %rdx
movl $0x0, 0x18(%rsi)
testb $0x1, (%rcx)
je 0x1538d
movslq 0xc(%r14), %rdi
addq %rdi, %rcx
movslq 0x8(%rsi), %rdi
movq (%rcx,%rdi,8), %rcx
movq %rcx, 0x10(%rsi)
jmp 0x152fb
movq $0x0, (%rdx)
leaq -0x10(%rdx), %rsi
cmpq %rax, %rsi
jb 0x153fd
movq (%rsi), %rcx
testq %rcx, %rcx
je 0x153f3
movslq -0x8(%rdx), %rdi
movl (%rcx), %r8d
sarl %r8d
cmpl %r8d, %edi
jge 0x153f5
movq 0x40(%rsp), %r11
movq (%r11), %r8
movq 0x10(%r11), %r9
leaq 0x1(%r8), %r10
movq %r10, (%r11)
leaq (%r8,%r8,4), %r8
leaq (%rdi,%rdi,4), %rdi
movq 0x24(%rcx,%rdi,8), %r10
movq %r10, 0x20(%r9,%r8,8)
movups 0x4(%rcx,%rdi,8), %xmm0
movups 0x14(%rcx,%rdi,8), %xmm1
movups %xmm1, 0x10(%r9,%r8,8)
movups %xmm0, (%r9,%r8,8)
movq (%rsi), %rcx
jmp 0x153f5
xorl %ecx, %ecx
incl -0x8(%rdx)
jmp 0x152f8
movq %rax, %rdi
callq 0x3390
xorps %xmm0, %xmm0
cvtsi2ssl 0x1c(%rsp), %xmm0
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movss 0xc(%rsp), %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
testq %rcx, %rcx
je 0x15541
leaq 0x3(%rcx), %rax
andq $-0x4, %rax
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movl $0x8c, %ecx
movq 0x40(%rsp), %rdx
addq 0x10(%rdx), %rcx
movdqa 0x10366(%rip), %xmm1    # 0x257c0
movdqa 0x1036e(%rip), %xmm2    # 0x257d0
movdqa 0x10376(%rip), %xmm3    # 0x257e0
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x10376(%rip), %xmm5    # 0x257f0
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x154b9
movd 0xc(%rsp), %xmm7
movd %xmm7, -0x78(%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x154d2
movd 0xc(%rsp), %xmm6
movd %xmm6, -0x50(%rcx)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x15514
movd 0xc(%rsp), %xmm7
movd %xmm7, -0x28(%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x15528
movd 0xc(%rsp), %xmm6
movd %xmm6, (%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0xa0, %rcx
addq $-0x4, %rax
jne 0x1547a
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
leaq 0x133ff(%rip), %rbx     # 0x28950
leaq 0x13402(%rip), %rdx     # 0x2895a
movq %rbx, %rdi
movl $0x4, %esi
movb $0x1, %al
callq 0xde80
leaq 0x13352(%rip), %rdx     # 0x288c0
movl $0x8, %edi
movl $0x8, %esi
movl $0x187, %ecx            # imm = 0x187
movq %rbx, %r8
callq 0x2319c
movq %rax, %r15
movq (%r14), %rax
movq %rax, (%r15)
movq %r15, %r12
addq $0x8, %r12
movl $0x8, %ebp
addq $-0x8, %r12
movq (%r12), %r13
testq %r13, %r13
je 0x155b0
movl (%r13), %ecx
testb $0x1, %cl
jne 0x155ca
movq %r13, %rdi
callq 0x3390
leaq -0x8(%r12), %rax
cmpq %r15, %r12
movq %rax, %r12
jne 0x1559e
jmp 0x1566e
testl %ecx, %ecx
js 0x1565d
movl 0xc(%r14), %eax
movq $-0x1, %rbx
movslq %eax, %rdx
addq %r13, %rdx
cmpq $0x0, 0x8(%rdx,%rbx,8)
je 0x1564e
movq %r12, %rcx
subq %r15, %rcx
sarq $0x3, %rcx
movslq %ebp, %rdx
cmpq %rdx, %rcx
jne 0x15637
movq %rbp, %r12
addl %ebp, %ebp
movslq %ebp, %rsi
shlq $0x3, %rsi
movq %r15, %rdi
leaq 0x132ad(%rip), %rdx     # 0x288c0
movl $0x187, %ecx            # imm = 0x187
leaq 0x13331(%rip), %r8      # 0x28950
callq 0x2324c
movq %rax, %r15
shlq $0x21, %r12
sarq $0x21, %r12
leaq (%rax,%r12,8), %r12
movl 0xc(%r14), %eax
movslq %eax, %rcx
addq %r13, %rcx
movq 0x8(%rcx,%rbx,8), %rcx
movq %rcx, (%r12)
addq $0x8, %r12
movl (%r13), %ecx
movl %ecx, %edx
sarl %edx
movslq %edx, %rdx
incq %rbx
cmpq %rdx, %rbx
jl 0x155dd
movq %r13, %rdi
callq 0x3390
cmpq %r15, %r12
jne 0x1559a
movq %r14, %rdi
callq 0x3390
movq %r15, %rdi
callq 0x3390
movq 0x40(%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq