// File: /workspace/github_c_makefile_star2_O1/lh3[P]minimap2/map.c
// Function: mm_map_frag_core
void mm_map_frag_core(const mm_idx_t *mi, int n_segs, const int *qlens, const char **seqs, int *n_regs, mm_reg1_t **regs, mm_tbuf_t *b, const mm_mapopt_t *opt, const char *qname)
{
	int i, j, rep_len, qlen_sum, n_regs0, n_mini_pos;
	int max_chain_gap_qry, max_chain_gap_ref, is_splice = !!(opt->flag & MM_F_SPLICE), is_sr = !!(opt->flag & MM_F_SR), is_sr_rna = !!(opt->flag & MM_F_SR_RNA);
	uint32_t hash;
	int64_t n_a;
	uint64_t *u, *mini_pos;
	mm128_t *a;
	mm128_v mv = {0,0,0};
	mm_reg1_t *regs0;
	km_stat_t kmst;
	float chn_pen_gap, chn_pen_skip;

	for (i = 0, qlen_sum = 0; i < n_segs; ++i)
		qlen_sum += qlens[i], n_regs[i] = 0, regs[i] = 0;

	if (qlen_sum == 0 || n_segs <= 0 || n_segs > MM_MAX_SEG) return;
	if (opt->max_qlen > 0 && qlen_sum > opt->max_qlen) return;

	hash  = qname && !(opt->flag & MM_F_NO_HASH_NAME)? __ac_X31_hash_string(qname) : 0;
	hash ^= __ac_Wang_hash(qlen_sum) + __ac_Wang_hash(opt->seed);
	hash  = __ac_Wang_hash(hash);

	collect_minimizers(b->km, opt, mi, n_segs, qlens, seqs, &mv);
	if (opt->q_occ_frac > 0.0f) mm_seed_mz_flt(b->km, &mv, opt->mid_occ, opt->q_occ_frac);
	if (opt->flag & MM_F_HEAP_SORT) a = collect_seed_hits_heap(b->km, opt, opt->mid_occ, mi, qname, &mv, qlen_sum, &n_a, &rep_len, &n_mini_pos, &mini_pos);
	else a = collect_seed_hits(b->km, opt, opt->mid_occ, mi, qname, &mv, qlen_sum, &n_a, &rep_len, &n_mini_pos, &mini_pos);

	if (mm_dbg_flag & MM_DBG_PRINT_SEED) {
		fprintf(stderr, "RS\t%d\n", rep_len);
		for (i = 0; i < n_a; ++i)
			fprintf(stderr, "SD\t%s\t%d\t%c\t%d\t%d\t%d\n", mi->seq[a[i].x<<1>>33].name, (int32_t)a[i].x, "+-"[a[i].x>>63], (int32_t)a[i].y, (int32_t)(a[i].y>>32&0xff),
					i == 0? 0 : ((int32_t)a[i].y - (int32_t)a[i-1].y) - ((int32_t)a[i].x - (int32_t)a[i-1].x));
	}

	// set max chaining gap on the query and the reference sequence
	if (is_sr)
		max_chain_gap_qry = qlen_sum > opt->max_gap? qlen_sum : opt->max_gap;
	else max_chain_gap_qry = opt->max_gap;
	if (opt->max_gap_ref > 0) {
		max_chain_gap_ref = opt->max_gap_ref; // always honor mm_mapopt_t::max_gap_ref if set
	} else if (opt->max_frag_len > 0) {
		max_chain_gap_ref = opt->max_frag_len - qlen_sum;
		if (max_chain_gap_ref < opt->max_gap) max_chain_gap_ref = opt->max_gap;
	} else max_chain_gap_ref = opt->max_gap;

	chn_pen_gap  = opt->chain_gap_scale * 0.01 * mi->k;
	chn_pen_skip = opt->chain_skip_scale * 0.01 * mi->k;
	if (opt->flag & MM_F_RMQ) {
		a = mg_lchain_rmq(opt->max_gap, opt->rmq_inner_dist, opt->bw, opt->max_chain_skip, opt->rmq_size_cap, opt->min_cnt, opt->min_chain_score,
						  chn_pen_gap, chn_pen_skip, n_a, a, &n_regs0, &u, b->km);
	} else {
		a = mg_lchain_dp(max_chain_gap_ref, max_chain_gap_qry, opt->bw, opt->max_chain_skip, opt->max_chain_iter, opt->min_cnt, opt->min_chain_score,
						 chn_pen_gap, chn_pen_skip, is_splice, n_segs, n_a, a, &n_regs0, &u, b->km);
	}

	if (opt->bw_long > opt->bw && (opt->flag & (MM_F_SPLICE|MM_F_SR|MM_F_NO_LJOIN)) == 0 && n_segs == 1 && n_regs0 > 1) { // re-chain/long-join for long sequences
		int32_t st = (int32_t)a[0].y, en = (int32_t)a[(int32_t)u[0] - 1].y;
		if (qlen_sum - (en - st) > opt->rmq_rescue_size || en - st > qlen_sum * opt->rmq_rescue_ratio) {
			int32_t i;
			for (i = 0, n_a = 0; i < n_regs0; ++i) n_a += (int32_t)u[i];
			kfree(b->km, u);
			radix_sort_128x(a, a + n_a);
			a = mg_lchain_rmq(opt->max_gap, opt->rmq_inner_dist, opt->bw_long, opt->max_chain_skip, opt->rmq_size_cap, opt->min_cnt, opt->min_chain_score,
							  chn_pen_gap, chn_pen_skip, n_a, a, &n_regs0, &u, b->km);
		}
	} else if (opt->max_occ > opt->mid_occ && rep_len > 0 && !(opt->flag & MM_F_RMQ)) { // re-chain, mostly for short reads
		int rechain = 0;
		if (n_regs0 > 0) { // test if the best chain has all the segments
			int n_chained_segs = 1, max = 0, max_i = -1, max_off = -1, off = 0;
			for (i = 0; i < n_regs0; ++i) { // find the best chain
				if (max < (int)(u[i]>>32)) max = u[i]>>32, max_i = i, max_off = off;
				off += (uint32_t)u[i];
			}
			for (i = 1; i < (int32_t)u[max_i]; ++i) // count the number of segments in the best chain
				if ((a[max_off+i].y&MM_SEED_SEG_MASK) != (a[max_off+i-1].y&MM_SEED_SEG_MASK))
					++n_chained_segs;
			if (n_chained_segs < n_segs)
				rechain = 1;
		} else rechain = 1;
		if (rechain) { // redo chaining with a higher max_occ threshold
			kfree(b->km, a);
			kfree(b->km, u);
			kfree(b->km, mini_pos);
			if (opt->flag & MM_F_HEAP_SORT) a = collect_seed_hits_heap(b->km, opt, opt->max_occ, mi, qname, &mv, qlen_sum, &n_a, &rep_len, &n_mini_pos, &mini_pos);
			else a = collect_seed_hits(b->km, opt, opt->max_occ, mi, qname, &mv, qlen_sum, &n_a, &rep_len, &n_mini_pos, &mini_pos);
			a = mg_lchain_dp(max_chain_gap_ref, max_chain_gap_qry, opt->bw, opt->max_chain_skip, opt->max_chain_iter, opt->min_cnt, opt->min_chain_score,
							 chn_pen_gap, chn_pen_skip, is_splice, n_segs, n_a, a, &n_regs0, &u, b->km);
		}
	}
	b->frag_gap = max_chain_gap_ref;
	b->rep_len = rep_len;

	regs0 = mm_gen_regs(b->km, hash, qlen_sum, n_regs0, u, a, !!(opt->flag&MM_F_QSTRAND));
	if (mi->n_alt) {
		mm_mark_alt(mi, n_regs0, regs0);
		mm_hit_sort(b->km, &n_regs0, regs0, opt->alt_drop); // this step can be merged into mm_gen_regs(); will do if this shows up in profile
	}

	if (mm_dbg_flag & (MM_DBG_PRINT_SEED|MM_DBG_PRINT_CHAIN))
		for (j = 0; j < n_regs0; ++j)
			for (i = regs0[j].as; i < regs0[j].as + regs0[j].cnt; ++i)
				fprintf(stderr, "CN\t%d\t%s\t%d\t%c\t%d\t%d\t%d\n", j, mi->seq[a[i].x<<1>>33].name, (int32_t)a[i].x, "+-"[a[i].x>>63], (int32_t)a[i].y, (int32_t)(a[i].y>>32&0xff),
						i == regs0[j].as? 0 : ((int32_t)a[i].y - (int32_t)a[i-1].y) - ((int32_t)a[i].x - (int32_t)a[i-1].x));

	chain_post(opt, max_chain_gap_ref, mi, b->km, qlen_sum, n_segs, qlens, &n_regs0, regs0, a);
	if (!is_sr && !(opt->flag&MM_F_QSTRAND)) {
		mm_est_err(mi, qlen_sum, n_regs0, regs0, a, n_mini_pos, mini_pos);
		n_regs0 = mm_filter_strand_retained(n_regs0, regs0);
	}

	if (n_segs == 1) { // uni-segment
		regs0 = align_regs(opt, mi, b->km, qlens[0], seqs[0], &n_regs0, regs0, a);
		regs0 = (mm_reg1_t*)realloc(regs0, sizeof(*regs0) * n_regs0);
		mm_set_mapq2(b->km, n_regs0, regs0, opt->min_chain_score, opt->a, rep_len, is_sr || is_sr_rna, is_splice);
		n_regs[0] = n_regs0, regs[0] = regs0;
	} else { // multi-segment
		mm_seg_t *seg;
		seg = mm_seg_gen(b->km, hash, n_segs, qlens, n_regs0, regs0, n_regs, regs, a); // split fragment chain to separate segment chains
		free(regs0);
		for (i = 0; i < n_segs; ++i) {
			mm_set_parent(b->km, opt->mask_level, opt->mask_len, n_regs[i], regs[i], opt->a * 2 + opt->b, opt->flag&MM_F_HARD_MLEVEL, opt->alt_drop); // update mm_reg1_t::parent
			regs[i] = align_regs(opt, mi, b->km, qlens[i], seqs[i], &n_regs[i], regs[i], seg[i].a);
			mm_set_mapq2(b->km, n_regs[i], regs[i], opt->min_chain_score, opt->a, rep_len, is_sr || is_sr_rna, is_splice);
		}
		mm_seg_free(b->km, n_segs, seg);
		if (n_segs == 2 && opt->pe_ori >= 0 && (opt->flag&MM_F_CIGAR))
			mm_pair(b->km, max_chain_gap_ref, opt->pe_bonus, opt->a * 2 + opt->b, opt->a, qlens, n_regs, regs); // pairing
	}

	kfree(b->km, mv.a);
	kfree(b->km, a);
	kfree(b->km, u);
	kfree(b->km, mini_pos);

	if (mi->J && n_segs == 1 && is_splice)
		for (i = 0; i < n_regs0; ++i)
			mm_jump_split(b->km, mi, opt, qlens[0], (const uint8_t*)seqs[0], &regs0[i], 0);

	if (b->km) {
		km_stat(b->km, &kmst);
		if (mm_dbg_flag & MM_DBG_PRINT_QNAME)
			fprintf(stderr, "QM\t%s\t%d\tcap=%ld,nCore=%ld,largest=%ld\n", qname, qlen_sum, kmst.capacity, kmst.n_cores, kmst.largest);
		assert(kmst.n_blocks == kmst.n_cores); // otherwise, there is a memory leak
		if (kmst.largest > 1U<<28 || (opt->cap_kalloc > 0 && kmst.capacity > opt->cap_kalloc)) {
			if (mm_dbg_flag & MM_DBG_PRINT_QNAME)
				fprintf(stderr, "[W::%s] reset thread-local memory after read %s\n", __func__, qname);
			km_destroy(b->km);
			b->km = km_init();
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, %rbx
movq 0x148(%rsp), %r13
movq (%r13), %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
testl %esi, %esi
jle 0xb098
movl %esi, %eax
xorl %ecx, %ecx
xorl %r14d, %r14d
addl (%rdx,%rcx,4), %r14d
movl $0x0, (%r8,%rcx,4)
movq $0x0, (%r9,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xb07a
jmp 0xb09b
xorl %r14d, %r14d
leal -0x100(%rsi), %eax
cmpl $0xffffff01, %eax       # imm = 0xFFFFFF01
jb 0xc0a5
testl %r14d, %r14d
je 0xc0a5
movl 0x10(%r13), %eax
testl %eax, %eax
jle 0xb0c6
cmpl %eax, %r14d
jg 0xc0a5
movq 0x150(%rsp), %r15
movq 0x140(%rsp), %r10
testq %r15, %r15
setne %al
btq $0x22, %r12
setae %cl
andb %al, %cl
xorl %eax, %eax
cmpb $0x1, %cl
jne 0xb124
movsbl (%r15), %r11d
testl %r11d, %r11d
je 0xb124
movb 0x1(%r15), %cl
testb %cl, %cl
je 0xb121
addq $0x2, %r15
movl %r11d, %eax
movl %eax, %r11d
shll $0x5, %r11d
subl %eax, %r11d
movsbl %cl, %eax
addl %r11d, %eax
movb (%r15), %cl
incq %r15
testb %cl, %cl
jne 0xb105
jmp 0xb124
movl %r11d, %eax
movq %r12, 0x80(%rsp)
movq %r9, 0xc0(%rsp)
movq %r8, 0xc8(%rsp)
movl %r14d, %ecx
shll $0xf, %ecx
notl %ecx
movq %r14, 0xd0(%rsp)
addl %r14d, %ecx
movl %ecx, %r8d
shrl $0xa, %r8d
xorl %ecx, %r8d
leal (%r8,%r8,8), %ecx
movl %ecx, %r8d
shrl $0x6, %r8d
xorl %ecx, %r8d
movl %r8d, %r9d
shll $0xb, %r9d
notl %r9d
addl %r8d, %r9d
movl %r9d, %ecx
shrl $0x10, %ecx
xorl %r9d, %ecx
movl 0x8(%r13), %r8d
movl %r8d, %r9d
shll $0xf, %r9d
notl %r9d
addl %r8d, %r9d
movl %r9d, %r8d
shrl $0xa, %r8d
xorl %r9d, %r8d
leal (%r8,%r8,8), %r8d
movl %r8d, %r9d
shrl $0x6, %r9d
xorl %r8d, %r9d
movl %r9d, %r8d
shll $0xb, %r8d
notl %r8d
addl %r9d, %r8d
movl %r8d, %r9d
shrl $0x10, %r9d
xorl %r8d, %r9d
addl %ecx, %r9d
xorl %eax, %r9d
movl %r9d, %eax
shll $0xf, %eax
notl %eax
addl %r9d, %eax
movl %eax, %ecx
shrl $0xa, %ecx
xorl %eax, %ecx
leal (%rcx,%rcx,8), %eax
movl %eax, 0xdc(%rsp)
shrl $0x6, %eax
movl %eax, 0xb0(%rsp)
movq (%r10), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x90(%rsp)
movq %rsi, 0x28(%rsp)
testl %esi, %esi
movq %rbx, 0x88(%rsp)
movq %rdx, 0x68(%rsp)
movq %rdi, 0x10(%rsp)
jle 0xb458
movl 0x28(%rsp), %eax
movq %rax, 0x60(%rsp)
xorl %r9d, %r9d
xorl %r14d, %r14d
xorl %ebp, %ebp
movq (%rbx,%r9,8), %rsi
movl (%rdx,%r9,4), %edx
movl 0x4(%rdi), %ecx
movl 0x8(%rdi), %r8d
movl 0xc(%rdi), %eax
andl $0x1, %eax
movq 0x50(%rsp), %rdi
movq %r9, 0x70(%rsp)
leaq 0x90(%rsp), %r10
pushq %r10
pushq %rax
callq 0x1376c
addq $0x10, %rsp
movl %ebp, 0xb8(%rsp)
movslq %ebp, %r15
movq 0x90(%rsp), %r12
movq %r12, %rax
subq %r15, %rax
jbe 0xb2a3
leal (%r14,%r14), %ecx
movslq %ecx, %rcx
movq 0xa0(%rsp), %rdx
movq %r15, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
addq $0x8, %rdx
addq %rcx, (%rdx)
addq $0x10, %rdx
decq %rax
jne 0xb297
movq %r14, 0x58(%rsp)
movl 0xc(%r13), %ebp
testl %ebp, %ebp
jle 0xb423
subl %r15d, %r12d
shlq $0x4, %r15
addq 0xa0(%rsp), %r15
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movl (%rax,%rcx,4), %r13d
movq (%rbx,%rcx,8), %rbx
movq 0x50(%rsp), %rdi
callq 0x1409c
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
movl $0x40, %ecx
leaq 0xe0(%rsp), %r8
movq %rax, 0x38(%rsp)
movq %rax, %r9
callq 0x142b4
testl %r12d, %r12d
jle 0xb3fd
movl 0xe0(%rsp), %ecx
movslq %ecx, %rdx
movq %rdx, 0x20(%rsp)
movl %r12d, %esi
xorl %edi, %edi
xorl %ebx, %ebx
xorl %r8d, %r8d
movq %rdi, %r9
shlq $0x4, %r9
cmpl %ecx, %r8d
jge 0xb3da
movl 0x8(%r15,%r9), %r11d
shrl %r11d
movzbl (%r15,%r9), %r10d
incl %r11d
movl %r11d, %ebp
subl %r10d, %ebp
movslq %r8d, %r14
movb $0x1, %dl
cmpl (%rax,%r14,8), %ebp
jge 0xb359
movq %r14, %r8
jmp 0xb37d
incl %r8d
movl %r8d, %r12d
cmpl %r12d, %ecx
je 0xb3ca
incl %r12d
leaq 0x1(%r14), %r8
cmpl 0x8(%rax,%r14,8), %ebp
movq %r8, %r14
jge 0xb35f
cmpq 0x20(%rsp), %r8
setl %dl
testb %dl, %dl
je 0xb3da
movslq %r8d, %rdx
cmpl 0x4(%rax,%rdx,8), %r11d
jle 0xb3da
xorl %r12d, %r12d
cmpl %r8d, %ecx
jle 0xb3d2
xorl %r14d, %r14d
movq %r8, %r13
movq (%rax,%r13,8), %r12
movq %r12, %rdx
shrq $0x20, %rdx
cmpl %edx, %r11d
jle 0xb3cf
cmpl %edx, %ebp
cmovgl %ebp, %edx
cmpl %r12d, %r11d
cmovll %r11d, %r12d
addl %r14d, %r12d
subl %edx, %r12d
incq %r13
movl %r12d, %r14d
cmpq 0x20(%rsp), %r13
jl 0xb399
jmp 0xb3d2
movl %ecx, %r8d
jmp 0xb3da
movl %r14d, %r12d
shrl %r10d
cmpl %r10d, %r12d
jg 0xb3ef
addq %r15, %r9
movslq %ebx, %rdx
incl %ebx
shlq $0x4, %rdx
movups (%r9), %xmm0
movups %xmm0, (%r15,%rdx)
incq %rdi
cmpq %rsi, %rdi
jne 0xb323
jmp 0xb3ff
xorl %ebx, %ebx
movq 0x38(%rsp), %rdi
callq 0x14259
addl 0xb8(%rsp), %ebx
movslq %ebx, %rax
movq %rax, 0x90(%rsp)
movq 0x88(%rsp), %rbx
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %r9
movq 0x58(%rsp), %r14
addl (%rdx,%r9,4), %r14d
movl 0x90(%rsp), %ebp
incq %r9
cmpq 0x60(%rsp), %r9
movq 0x148(%rsp), %r13
movq 0x10(%rsp), %rdi
jne 0xb22d
movl 0xb0(%rsp), %ebx
xorl 0xdc(%rsp), %ebx
movss 0xc8(%r13), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
movq 0x140(%rsp), %r14
jbe 0xb496
movq (%r14), %rdi
movl 0xd4(%r13), %edx
leaq 0x90(%rsp), %rsi
callq 0x1d574
movl %ebx, %r15d
shll $0xb, %ebx
movq 0x80(%rsp), %rax
andl $0x80, %eax
movq %rax, 0xb8(%rsp)
testb $0x40, 0x2(%r13)
movq (%r14), %rdi
movl 0xd4(%r13), %edx
movq 0x150(%rsp), %r12
movq 0xd0(%rsp), %rbp
jne 0xb50f
subq $0x8, %rsp
leaq 0x80(%rsp), %rax
leaq 0x54(%rsp), %r10
leaq 0x24(%rsp), %r11
leaq 0x38(%rsp), %r14
leaq 0x98(%rsp), %r9
movq %r13, %rsi
movq 0x18(%rsp), %rcx
movq %r12, %r8
pushq %rax
pushq %r10
pushq %r11
pushq %r14
pushq %rbp
callq 0xc61b
jmp 0xb54a
subq $0x8, %rsp
leaq 0x80(%rsp), %rax
leaq 0x54(%rsp), %r10
leaq 0x24(%rsp), %r11
leaq 0x38(%rsp), %r14
leaq 0x98(%rsp), %r9
movq %r13, %rsi
movq 0x18(%rsp), %rcx
movq %r12, %r8
pushq %rax
pushq %r10
pushq %r11
pushq %r14
pushq %rbp
callq 0xc14e
addq $0x30, %rsp
movq %rax, %r14
notl %ebx
leaq 0x2a3ce(%rip), %rax     # 0x35928
testb $0x4, (%rax)
jne 0xba00
addl %ebx, %r15d
movq 0xb8(%rsp), %rax
movl %eax, %r12d
movl 0x1c(%r13), %eax
movl 0x20(%r13), %edi
cmpl %eax, %ebp
movl %eax, %esi
cmovgl %ebp, %esi
btl $0xc, 0x80(%rsp)
cmovael %eax, %esi
testl %edi, %edi
jg 0xb5a9
movl 0x24(%r13), %edi
testl %edi, %edi
jle 0xb5a5
subl %ebp, %edi
movl 0x1c(%r13), %eax
cmpl %eax, %edi
cmovlel %eax, %edi
jmp 0xb5a9
movl 0x1c(%r13), %edi
movl %r15d, %ebx
shrl $0x10, %r15d
xorps %xmm0, %xmm0
cvtss2sd 0x38(%r13), %xmm0
shrl $0x7, %r12d
movsd 0x21193(%rip), %xmm1    # 0x2c758
movq 0x10(%rsp), %rax
cvtsi2sdl 0x8(%rax), %xmm2
mulsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd 0x3c(%r13), %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
xorps %xmm1, %xmm1
cvtsd2ss %xmm3, %xmm1
testb $-0x80, 0x3(%r13)
movl %edi, 0x38(%rsp)
movq %r12, 0x70(%rsp)
movss %xmm0, 0x20(%rsp)
movss %xmm1, 0x50(%rsp)
movl %esi, 0x60(%rsp)
jne 0xb65b
movl 0x14(%r13), %edx
movl 0x28(%r13), %ecx
movl 0x2c(%r13), %r8d
movl 0x30(%r13), %r9d
movl 0x34(%r13), %eax
leaq 0x40(%rsp), %r10
movq %rbp, %r11
movq 0x140(%rsp), %rbp
pushq (%rbp)
movq %r11, %rbp
pushq %r10
leaq 0x1c(%rsp), %r10
pushq %r10
pushq %r14
pushq 0x50(%rsp)
pushq 0x50(%rsp)
pushq %r12
pushq %rax
callq 0x14e7f
addq $0x40, %rsp
jmp 0xb6a1
movl 0x14(%r13), %edx
movl 0x1c(%r13), %edi
movl 0x44(%r13), %esi
movl 0x28(%r13), %ecx
movl 0x40(%r13), %r8d
movl 0x30(%r13), %r9d
movl 0x34(%r13), %eax
leaq 0x40(%rsp), %r10
leaq 0xc(%rsp), %r11
movq 0x140(%rsp), %r12
pushq (%r12)
pushq %r10
pushq %r11
pushq %r14
pushq 0x50(%rsp)
pushq %rax
callq 0x165ed
addq $0x30, %rsp
movq %rax, %r9
movl %r15d, %r10d
xorl %ebx, %r10d
movl 0x18(%r13), %eax
cmpl 0x14(%r13), %eax
movl %r10d, 0x58(%rsp)
jle 0xb7e2
movzwl (%r13), %eax
testl $0x1480, %eax           # imm = 0x1480
sete %al
cmpl $0x1, 0x28(%rsp)
sete %cl
andb %al, %cl
movl 0xc(%rsp), %eax
cmpl $0x2, %eax
setge %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xb7e2
movq 0x40(%rsp), %rsi
movq (%rsi), %rcx
shlq $0x20, %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
addq %rcx, %rdx
sarq $0x1c, %rdx
movl 0x8(%r9,%rdx), %ecx
subl 0x8(%r9), %ecx
movl %ebp, %edx
subl %ecx, %edx
cmpl 0x48(%r13), %edx
movq 0x10(%rsp), %r12
movq 0x140(%rsp), %r15
jg 0xb73d
cvtsi2ss %ecx, %xmm0
cvtsi2ss %ebp, %xmm1
mulss 0x4c(%r13), %xmm1
ucomiss %xmm1, %xmm0
jbe 0xb94e
movl %r10d, %r14d
movq %r9, %rbx
movq $0x0, 0x30(%rsp)
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
xorl %eax, %eax
xorl %edx, %edx
movslq (%rsi,%rax,8), %rdi
addq %rdi, %rdx
movq %rdx, 0x30(%rsp)
incq %rax
cmpq %rax, %rcx
jne 0xb75b
movq (%r15), %rdi
callq 0x1261e
movq 0x30(%rsp), %rsi
shlq $0x4, %rsi
addq %rbx, %rsi
movq %rbx, %rdi
callq 0x5ae1
movl 0x18(%r13), %edx
movl 0x1c(%r13), %edi
movl 0x44(%r13), %esi
movl 0x28(%r13), %ecx
movl 0x40(%r13), %r8d
movl 0x30(%r13), %r9d
movl 0x34(%r13), %eax
leaq 0x40(%rsp), %r10
leaq 0xc(%rsp), %r11
movss 0x20(%rsp), %xmm0
movss 0x50(%rsp), %xmm1
pushq (%r15)
pushq %r10
pushq %r11
pushq %rbx
pushq 0x50(%rsp)
pushq %rax
callq 0x165ed
addq $0x30, %rsp
movq %rax, %r9
movl 0x38(%rsp), %ecx
movl %r14d, %r10d
jmp 0xba2a
movl 0xd8(%r13), %eax
cmpl 0xd4(%r13), %eax
movq 0x140(%rsp), %r15
jle 0xb949
cmpl $0x0, 0x1c(%rsp)
movl 0x38(%rsp), %ecx
jle 0xb93f
testb $-0x80, 0x3(%r13)
jne 0xb93f
movslq 0xc(%rsp), %rcx
testq %rcx, %rcx
jle 0xb8c7
movq %r9, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edx, %edx
movq 0x40(%rsp), %rsi
xorl %r8d, %r8d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
movq (%rsi,%rdx,8), %r10
movq %r10, %r11
shrq $0x20, %r11
cmpl %r11d, %r9d
cmovgl %r9d, %r11d
cmovll %edx, %edi
cmovll %r8d, %eax
addl %r8d, %r10d
incq %rdx
movl %r10d, %r8d
movl %r11d, %r9d
cmpq %rdx, %rcx
jne 0xb840
movq 0x40(%rsp), %rcx
movslq %edi, %rdx
movq (%rcx,%rdx,8), %rcx
movl $0x1, %edx
cmpl $0x2, %ecx
movq %r14, %r9
jl 0xb8bd
cltq
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shlq $0x4, %rax
addq %r9, %rax
addq $0x18, %rax
decq %rcx
movabsq $0xff000000000000, %rsi # imm = 0xFF000000000000
movq -0x10(%rax), %rdi
xorq (%rax), %rdi
andq %rsi, %rdi
cmpq $0x1, %rdi
sbbl $-0x1, %edx
addq $0x10, %rax
decq %rcx
jne 0xb8a3
cmpl 0x28(%rsp), %edx
jge 0xba1c
movq (%r15), %rdi
movq %r9, %rsi
callq 0x1261e
movq (%r15), %rdi
movq 0x40(%rsp), %rsi
callq 0x1261e
movq (%r15), %rdi
movq 0x78(%rsp), %rsi
callq 0x1261e
testb $0x40, 0x2(%r13)
movq (%r15), %rdi
movl 0xd8(%r13), %edx
jne 0xb957
subq $0x8, %rsp
leaq 0x80(%rsp), %rax
leaq 0x54(%rsp), %r10
leaq 0x24(%rsp), %r11
leaq 0x38(%rsp), %r14
leaq 0x98(%rsp), %r9
movq %r13, %rsi
movq 0x18(%rsp), %rcx
movq 0x158(%rsp), %r8
pushq %rax
pushq %r10
pushq %r11
pushq %r14
pushq %rbp
callq 0xc61b
jmp 0xb997
movq 0x10(%rsp), %r12
jmp 0xba2a
movq 0x10(%rsp), %r12
movl 0x38(%rsp), %ecx
jmp 0xba2a
subq $0x8, %rsp
leaq 0x80(%rsp), %rax
leaq 0x54(%rsp), %r10
leaq 0x24(%rsp), %r11
leaq 0x38(%rsp), %r14
leaq 0x98(%rsp), %r9
movq %r13, %rsi
movq 0x18(%rsp), %rcx
movq 0x158(%rsp), %r8
pushq %rax
pushq %r10
pushq %r11
pushq %r14
pushq %rbp
callq 0xc14e
addq $0x30, %rsp
movl 0x14(%r13), %edx
movl 0x28(%r13), %ecx
movl 0x2c(%r13), %r8d
movl 0x30(%r13), %r9d
movl 0x34(%r13), %r10d
leaq 0x40(%rsp), %r11
leaq 0xc(%rsp), %r14
movl 0x38(%rsp), %r12d
movl %r12d, %edi
movl 0x60(%rsp), %esi
movss 0x20(%rsp), %xmm0
movss 0x50(%rsp), %xmm1
pushq (%r15)
pushq %r11
pushq %r14
pushq %rax
pushq 0x50(%rsp)
pushq 0x50(%rsp)
pushq 0xa0(%rsp)
pushq %r10
callq 0x14e7f
movl %r12d, %ecx
addq $0x40, %rsp
movq %rax, %r9
movq 0x10(%rsp), %r12
jmp 0xba25
leaq 0x1c(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
callq 0x2ec1
jmp 0xb563
movq 0x10(%rsp), %r12
movl 0x38(%rsp), %ecx
movl 0x58(%rsp), %r10d
movl %ecx, 0xc(%r15)
movl 0x1c(%rsp), %eax
movl %eax, 0x8(%r15)
movq (%r15), %rdi
movl 0xc(%rsp), %ecx
movq 0x40(%rsp), %r8
movl 0x4(%r13), %eax
andl $0x1, %eax
subq $0x8, %rsp
movl %r10d, %esi
movl %ebp, %edx
movq %r9, 0x28(%rsp)
pushq %rax
callq 0x1bb24
addq $0x10, %rsp
movq %rax, %rbx
cmpl $0x0, 0x18(%r12)
je 0xba93
leaq 0xc(%rsp), %r14
movl (%r14), %esi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x1beed
movq (%r15), %rdi
movss 0x60(%r13), %xmm0
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1c47b
leaq 0x29e8e(%rip), %rax     # 0x35928
testb $0x14, (%rax)
je 0xbb8a
cmpl $0x0, 0xc(%rsp)
jle 0xbb8a
xorl %r12d, %r12d
leaq (%r12,%r12,4), %rbp
shlq $0x4, %rbp
cmpl $0x0, 0x4(%rbx,%rbp)
jle 0xbb79
addq %rbx, %rbp
movl 0x28(%rbp), %eax
movslq %eax, %r13
movq %r13, %r15
shlq $0x4, %r15
addq 0x20(%rsp), %r15
movq (%r15), %r8
movq 0x8(%r15), %r10
xorl %r11d, %r11d
cmpl %eax, %r13d
je 0xbaf9
movl -0x8(%r15), %eax
addl %r8d, %eax
movl %r10d, %r11d
subl %eax, %r11d
addl -0x10(%r15), %r11d
movq 0x294f8(%rip), %rax     # 0x34ff8
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
movq %r8, %rcx
shrq $0x20, %rcx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rcx
movq %r8, %rax
shrq $0x3f, %rax
leaq 0x20c5a(%rip), %rdx     # 0x2c789
movsbl (%rax,%rdx), %r9d
movq %r10, %rax
shrq $0x20, %rax
movzbl %al, %r14d
subq $0x8, %rsp
leaq 0x20c42(%rip), %rsi     # 0x2c78c
movl %r12d, %edx
xorl %eax, %eax
pushq %r11
pushq %r14
pushq %r10
callq 0x2260
addq $0x20, %rsp
incq %r13
movslq 0x28(%rbp), %rax
movslq 0x4(%rbp), %rcx
addq %rax, %rcx
addq $0x10, %r15
cmpq %rcx, %r13
jl 0xbad9
incq %r12
movslq 0xc(%rsp), %rax
cmpq %rax, %r12
jl 0xbab1
movq 0x148(%rsp), %r13
movq (%r13), %r9
btl $0x17, %r9d
movq 0x140(%rsp), %r12
movq 0x68(%rsp), %rbp
movq 0x28(%rsp), %r15
jb 0xbc62
movq (%r12), %r14
movss 0x50(%r13), %xmm0
movl 0x54(%r13), %esi
movl 0xc(%rsp), %edx
movl 0x64(%r13), %r8d
addl %r8d, %r8d
addl 0x68(%r13), %r8d
andl $0x20000000, %r9d       # imm = 0x20000000
movss 0x60(%r13), %xmm1
movq %r14, %rdi
movq %rbx, %rcx
callq 0x1c006
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edx
addl %edx, %edx
movss 0x58(%r13), %xmm0
movl 0x5c(%r13), %ecx
cmpl $0x1, %r15d
jg 0xbc35
xorps %xmm1, %xmm1
cvtsi2sdl 0x1c(%r13), %xmm1
mulsd 0x20b4d(%rip), %xmm1    # 0x2c760
cvttsd2si %xmm1, %r8d
subq $0x8, %rsp
leaq 0x14(%rsp), %r9
movq %r14, %rdi
movl %edx, %esi
movl %ecx, %edx
movl $0x1, %ecx
pushq %rbx
callq 0x1c812
jmp 0xbc5e
leaq 0xc(%rsp), %rax
movss 0x20b26(%rip), %xmm1    # 0x2c768
movss 0x1e3ba(%rip), %xmm2    # 0x2a004
movq %r14, %rdi
movl 0x38(%rsp), %esi
movl %r15d, %r8d
movq %rbp, %r9
pushq %rbx
pushq %rax
callq 0x10e60
addq $0x10, %rsp
movq %r12, %r14
btl $0xc, 0x80(%rsp)
movq 0x20(%rsp), %r13
jb 0xbcc8
movq 0x148(%rsp), %rax
testb $0x1, 0x4(%rax)
jne 0xbcc8
movl 0xc(%rsp), %edx
movl 0x4c(%rsp), %r9d
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
movq 0xd8(%rsp), %rsi
movq %rbx, %rcx
movq %r13, %r8
pushq 0x80(%rsp)
callq 0x11a70
addq $0x10, %rsp
movl 0xc(%rsp), %edi
movq %rbx, %rsi
callq 0x1ca23
movq 0x20(%rsp), %r13
movl %eax, 0xc(%rsp)
movq (%r14), %rdx
cmpl $0x1, %r15d
jne 0xbd8b
movl (%rbp), %ecx
movq 0x88(%rsp), %rax
movq (%rax), %r8
movq %rbx, %rax
leaq 0xc(%rsp), %rbx
movq 0x148(%rsp), %rbp
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %r9
pushq %r13
pushq %rax
callq 0xc9dd
addq $0x10, %rsp
movslq (%rbx), %rcx
shlq $0x4, %rcx
leaq (%rcx,%rcx,4), %rsi
movq %rax, %rdi
callq 0x2320
movq %rax, %r14
movq 0x140(%rsp), %rax
movq (%rax), %rdi
movl (%rbx), %esi
movl 0x34(%rbp), %ecx
movl 0x64(%rbp), %r8d
movl 0x1c(%rsp), %r9d
movabsq $0x8000001000, %rax     # imm = 0x8000001000
xorl %r10d, %r10d
testq %rax, 0x80(%rsp)
setne %r10b
movq %r14, %rdx
pushq 0x70(%rsp)
pushq %r10
callq 0x1d098
addq $0x10, %rsp
movl (%rbx), %eax
movq 0x140(%rsp), %rbx
movq 0xc8(%rsp), %rcx
movl %eax, (%rcx)
movq 0xc0(%rsp), %rax
movq %r14, %rbp
movq %r14, (%rax)
jmp 0xbf70
movl 0xc(%rsp), %r8d
subq $0x8, %rsp
movq %rdx, %rdi
movl 0x60(%rsp), %esi
movl %r15d, %edx
movq %rbp, %rcx
movq %rbx, %r9
pushq %r13
movq %rbx, %rbp
movq 0xd0(%rsp), %rbx
pushq %rbx
movq 0xe0(%rsp), %r13
pushq %r13
callq 0x1cc92
addq $0x20, %rsp
movq %rax, 0x60(%rsp)
movq %rbp, 0xb0(%rsp)
movq %rbp, %rdi
callq 0x2040
testl %r15d, %r15d
movq 0x148(%rsp), %r15
movq %r14, %r12
jle 0xbee3
movabsq $0x8000001000, %rax     # imm = 0x8000001000
xorl %ecx, %ecx
testq %rax, 0x80(%rsp)
setne %cl
movq %rcx, 0x58(%rsp)
movl 0x28(%rsp), %eax
movq 0x60(%rsp), %rbp
addq $0x10, %rbp
shlq $0x2, %rax
movq %rax, 0x50(%rsp)
xorl %r14d, %r14d
movq (%r12), %rdi
movss 0x50(%r15), %xmm0
movl 0x54(%r15), %esi
leaq (%r14,%r13), %r12
movl (%r13,%r14), %edx
movl 0x64(%r15), %r8d
addl %r8d, %r8d
addl 0x68(%r15), %r8d
movq (%rbx,%r14,2), %rcx
movl (%r15), %r9d
movl $0x20000000, %eax       # imm = 0x20000000
andl %eax, %r9d
movss 0x60(%r15), %xmm1
callq 0x1c006
movq 0x140(%rsp), %rax
movq (%rax), %rdx
movq 0x68(%rsp), %rax
movl (%rax,%r14), %ecx
movq 0x88(%rsp), %rax
movq (%rax,%r14,2), %r8
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq %r12, %r9
movq 0x140(%rsp), %r12
pushq (%rbp)
pushq (%rbx,%r14,2)
callq 0xc9dd
addq $0x10, %rsp
movq %rax, (%rbx,%r14,2)
movq (%r12), %rdi
movl (%r13,%r14), %esi
movl 0x34(%r15), %ecx
movl 0x64(%r15), %r8d
movl 0x1c(%rsp), %r9d
movq %rax, %rdx
pushq 0x70(%rsp)
pushq 0x60(%rsp)
callq 0x1d098
addq $0x10, %rsp
addq $0x4, %r14
addq $0x18, %rbp
cmpq %r14, 0x50(%rsp)
jne 0xbe23
movq (%r12), %rdi
movq 0x28(%rsp), %r14
movl %r14d, %esi
movq 0x60(%rsp), %rdx
callq 0x1d01b
cmpl $0x2, %r14d
jne 0xbf5b
movq 0x148(%rsp), %r15
cmpl $0x0, 0xb8(%r15)
movq 0x68(%rsp), %r9
movq 0xb0(%rsp), %rbp
js 0xbf63
testb $0x4, (%r15)
je 0xbf63
movq (%r12), %rdi
movl 0x64(%r15), %r8d
movl 0xbc(%r15), %edx
leal (%r8,%r8), %ecx
movq %r12, %rbx
addl 0x68(%r15), %ecx
movl 0x38(%rsp), %esi
pushq 0xc0(%rsp)
pushq 0xd0(%rsp)
callq 0x113db
addq $0x10, %rsp
jmp 0xbf66
movq 0xb0(%rsp), %rbp
movq %r12, %rbx
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r13
movq (%rbx), %rdi
movq 0xa0(%rsp), %rsi
callq 0x1261e
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x1261e
movq (%rbx), %rdi
movq 0x40(%rsp), %rsi
callq 0x1261e
movq (%rbx), %rdi
movq 0x78(%rsp), %rsi
callq 0x1261e
cmpl $0x1, %r15d
movq 0x88(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq 0x148(%rsp), %r15
movq %rbx, %r13
jne 0xc02a
cmpq $0x0, 0x48(%rdx)
je 0xc02a
cmpq $0x0, 0xb8(%rsp)
je 0xc02a
cmpl $0x0, 0xc(%rsp)
jle 0xc02a
xorl %r14d, %r14d
movq (%r13), %rdi
movq %rcx, %r12
movl (%rcx), %ecx
movq (%rax), %r8
subq $0x8, %rsp
movq %rdx, %rbx
movq %rdx, %rsi
movq %r15, %rdx
movq %rbp, %r9
pushq $0x0
callq 0x1dcf0
movq %rbx, %rdx
movq %r12, %rcx
addq $0x10, %rsp
incq %r14
movslq 0xc(%rsp), %rax
addq $0x50, %rbp
cmpq %rax, %r14
movq 0x88(%rsp), %rax
jl 0xbfe4
movq (%r13), %rdi
testq %rdi, %rdi
je 0xc0a5
movq %r13, %r14
leaq 0xe0(%rsp), %rsi
callq 0x128e5
leaq 0x298de(%rip), %rax     # 0x35928
testb $0x2, (%rax)
jne 0xc0b7
movq 0xf0(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jne 0xc12f
cmpq $0x10000000, 0x100(%rsp) # imm = 0x10000000
ja 0xc089
movq 0xf8(%r15), %rax
testq %rax, %rax
jle 0xc0a5
cmpq %rax, 0xe0(%rsp)
jbe 0xc0a5
leaq 0x29898(%rip), %rax     # 0x35928
testb $0x2, (%rax)
jne 0xc103
movq (%r14), %rdi
callq 0x125e0
callq 0x125bf
movq %rax, (%r14)
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28f3a(%rip), %rax     # 0x34ff8
movq (%rax), %rdi
movq 0xe0(%rsp), %r8
movq 0xf8(%rsp), %r9
subq $0x8, %rsp
leaq 0x206c9(%rip), %rsi     # 0x2c7a5
movq 0x158(%rsp), %rdx
movq 0xd8(%rsp), %rcx
xorl %eax, %eax
pushq 0x108(%rsp)
callq 0x2260
addq $0x10, %rsp
jmp 0xc04f
movq 0x28eee(%rip), %rax     # 0x34ff8
movq (%rax), %rdi
leaq 0x2076b(%rip), %rsi     # 0x2c87f
leaq 0x20795(%rip), %rdx     # 0x2c8b0
movq 0x150(%rsp), %rcx
xorl %eax, %eax
callq 0x2260
jmp 0xc095
leaq 0x20697(%rip), %rdi     # 0x2c7cd
leaq 0x206ae(%rip), %rsi     # 0x2c7eb
leaq 0x206ad(%rip), %rcx     # 0x2c7f1
movl $0x172, %edx            # imm = 0x172
callq 0x21a0