// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/anchor.cpp
// Function: h_ec_lchain_re_gen3(ha_abuf_s*, unsigned int, char*, unsigned long, unsigned long, unsigned long, ha_pt_s*, All_reads*, overlap_region_alloc*, Candidates_list*, double, int, kvec_t_u8_warp*, kvec_t_u64_warp*, st_mt_t*, unsigned int*, unsigned int*, unsigned int, long, double, unsigned int, long, long, long, long, double, double, UC_Read*, asg64_v*, asg16_v*)
void h_ec_lchain_re_gen3(ha_abuf_t *ab, uint32_t rid, char* rs, uint64_t rl, uint64_t mz_w, uint64_t mz_k, ha_pt_t *ha_idx, All_reads *rref, overlap_region_alloc *olst, Candidates_list *cl, double bw_thres, 
								 int apend_be, kvec_t_u8_warp* k_flag, kvec_t_u64_warp* dbg_ct, st_mt_t *sp, uint32_t *high_occ, uint32_t *low_occ, uint32_t gen_off, int64_t enable_mcopy, double mcopy_rate, uint32_t mcopy_khit_cut, 
								 int64_t max_skip, int64_t max_iter, int64_t max_dis, int64_t quick_check, double chn_pen_gap, double chn_pen_skip, UC_Read *tu, asg64_v *oidx, asg16_v *scc)
{
	uint64_t i, k, l, m, max_cnt = UINT32_MAX, min_cnt = 0; int n, n0, j; ha_mz1_t *z; seed1_t *s; tiny_queue_t tq; memset(&tq, 0, sizeof(tiny_queue_t));
    if(high_occ) {
        max_cnt = (*high_occ);
        if(max_cnt < 2) max_cnt = 2;
    }
    if(low_occ) {
        min_cnt = (*low_occ);
        if(min_cnt < 2) min_cnt = 2;
    }
    clear_Candidates_list(cl); ab->n_a = 0;

	// minimizer of queried read
    if (ab->mz.m > ab->old_mz_m) {
        ab->old_mz_m = ab->mz.m;
        REALLOC(ab->seed, ab->old_mz_m);
    }

    for (i = 0, ab->n_a = 0; i < ab->mz.n; ++i) {
        ab->seed[i].a = ha_pt_get(ha_idx, ab->mz.a[i].x, &n);
        ab->seed[i].n = n;
        ab->n_a += n;
    }

	if (ab->n_a > ab->m_a) {
        ab->m_a = ab->n_a;
        REALLOC(ab->a, ab->m_a);
    }

	for (i = 0, k = 0; i < ab->mz.n; ++i) {
        ///z is one of the minimizer
        z = &ab->mz.a[i]; s = &ab->seed[i];

		// uint64_t rpos, rspan;
		// if(!recalu_minimizer0(rs + (z->pos+1-z->span), z->span, !(asm_opt.flag & HA_F_NO_HPC), mz_k, z->x, &tq, &rpos, &rspan)) {
		// 	fprintf(stderr, "-1-[M::%s]\t%c\trg0::[%u,%u)\trid::%u\n", __func__, "+-"[z->rev], z->pos+1-z->span, z->pos+1, rid);
		// } 
		// else {
		// 	fprintf(stderr, "-0-[M::%s]\t%c\trg0::[%u,%u)\trid::%u\n", __func__, "+-"[z->rev], z->pos+1-z->span, z->pos+1, rid);
		// }

        for (j = 0; j < s->n; ++j) {
            const ha_idxpos_t *y = &s->a[j];
            anchor1_t *an = &ab->a[k++];
            uint8_t rev = z->rev == y->rev? 0 : 1;

            // an->other_off = rev?((uint32_t)-1)-1-(y->pos+1-y->span):y->pos;
			an->other_off = y->span;

            // an->self_off = z->pos;
			an->self_off = i;
			
            ///an->cnt: cnt<<8|span
            an->cnt = s->n; if(an->cnt > ((uint32_t)(0xffffffu))) an->cnt = 0xffffffu;
            an->cnt <<= 8; an->cnt |= ((z->span <= ((uint32_t)(0xffu)))?z->span:((uint32_t)(0xffu)));

            // an->srt = (uint64_t)y->rid<<33 | (uint64_t)rev<<32 | an->self_off;
			an->srt = (uint64_t)y->rid<<33 | (uint64_t)rev<<32 | y->pos;
        }
    }

	// copy over to _cl_
    if (ab->m_a >= (uint64_t)cl->size) {
        cl->size = ab->m_a;
        REALLOC(cl->list, cl->size);
    }
	clear_overlap_region_alloc(olst);

	// char dbg[256]; uint64_t rpos, rspan, thash;
	// char dbg[768]; uint64_t rpos, rspan, thash;
	k_mer_hit *p; uint64_t tid = (uint64_t)-1, tl = (uint64_t)-1, trev, tspan, ol, zn, olst_n, sk, sv; int64_t ok, nk, ck, str_s, str_e;
    radix_sort_ha_an1(ab->a, ab->a + ab->n_a);
    for (k = 1, l = ol = n = zn = 0; k <= ab->n_a; ++k) {
        if (k == ab->n_a || (ab->a[k].srt>>32) != (ab->a[l].srt>>32)) {
			
			for (sk = sv = 0; (ol < oidx->n) && ((oidx->a[ol]>>33) < (ab->a[l].srt>>33)); ol++);
			if((ol < oidx->n) && ((ab->a[l].srt>>33) == (oidx->a[ol]>>33))) {
				for (; (ol < oidx->n) && ((oidx->a[ol]>>32) < (ab->a[l].srt>>32)); ol++);
				if((ol < oidx->n) && ((ab->a[l].srt>>32) == (oidx->a[ol]>>32))) {
					if(((uint32_t)oidx->a[ol]) == ((uint32_t)-1)) sk = 1;///exact match
					else sv = 1;
				} else {///match in rev
					sk = 1;
				}
			}

			if(!sk) {
				tl = Get_READ_LENGTH((*rref), ab->a[l].srt>>33); tid = ab->a[l].srt>>33; trev = (ab->a[l].srt>>32) & 1; olst_n = olst->length;
				if(tid != rid) {
					for (i = l, m = 0, ok = nk = ck = str_s = str_e = 0; i < k; i++) {
						if(!recalu_minimizer_bd(rid, &(ab->a[i]), &(scc[tid]), &ok, &nk, &ck, &str_s, &str_e, mz_k, ab->mz.a[ab->a[i].self_off].x, &tq, rref, tu, rs, ab->mz.a[ab->a[i].self_off].pos+1-ab->mz.a[ab->a[i].self_off].span, ab->mz.a[ab->a[i].self_off].pos+1)) continue;
						///debug
						// recover_UC_Read_sub_region(dbg, ((uint32_t)ab->a[i].srt) + 1 - ab->a[i].other_off, ab->a[i].other_off, 0, rref, tid);
						// if(recalu_minimizer0(dbg, ab->a[i].other_off, !(asm_opt.flag & HA_F_NO_HPC), mz_k, ab->mz.a[ab->a[i].self_off].x, &tq, &rpos, &rspan) && (rpos + 1 == ab->a[i].other_off) && (ab->a[i].other_off == rspan)) {
						// 	// fprintf(stderr, "-0-[M::%s]\n", __func__);
						// } else {
						// 	fprintf(stderr, "-1-[M::%s]\n", __func__);
						// }
						// thash = ab->mz.a[ab->a[i].self_off].x;
						ab->a[m] = ab->a[i]; tspan = ab->a[m].other_off;
						ab->a[m].other_off = (uint32_t)ab->a[m].srt;
						if(trev) ab->a[m].other_off = tl - (ab->a[m].other_off+1-tspan) - 1;///looks like a bug
						ab->a[m].self_off = ab->mz.a[ab->a[m].self_off].pos;
						ab->a[m].srt = ab->a[m].self_off; ab->a[m].srt <<= 32; ab->a[m].srt |= ab->a[m].other_off;
						///debug
						/**
						recover_UC_Read_sub_region(dbg, ab->a[m].other_off + 1 - tspan, tspan, trev, rref, tid);
						if(recalu_minimizer0(dbg, tspan, !(asm_opt.flag & HA_F_NO_HPC), mz_k, thash, &tq, &rpos, &rspan) && (rpos + 1 == tspan) && (tspan == rspan)) {
							// fprintf(stderr, "-0-[M::%s]\n", __func__);
						} else {
							fprintf(stderr, "-1-[M::%s]\ttrev::%lu\n", __func__, trev);
						}
						///debug
						hpc_ext_check(rref, tid, ab->a[m].other_off + 1 - tspan, ab->a[m].other_off + 1, tl, trev, dbg);
						**/

						m++;
					}
					if(m > 1) radix_sort_ha_an1(ab->a, ab->a + m);
					for (i = 0, n0 = n; i < m; i++) {
						p = &cl->list[n++];
						p->readID = tid;
						p->strand = trev;
						p->offset = ab->a[i].other_off;
						p->self_offset = ab->a[i].self_off;
						if(((ab->a[i].cnt>>8) < max_cnt) && ((ab->a[i].cnt>>8) > min_cnt)){
							p->cnt = 1;
						} else if((ab->a[i].cnt>>8) <= min_cnt) {
							p->cnt = 2;
						} else{
							p->cnt = 1 + (((ab->a[i].cnt>>8) + (max_cnt<<1) - 1)/(max_cnt<<1));
							p->cnt = pow(p->cnt, 1.1);
						}
						if(p->cnt > ((uint32_t)(0xffffffu))) p->cnt = 0xffffffu;
						p->cnt <<= 8; p->cnt |= (((uint32_t)(0xffu))&(ab->a[i].cnt));
					}

					if(m > 0) {
						zn += lchain_qdp_mcopy_fast(cl, n0, n-n0, zn, &(cl->chainDP), olst, max_skip, max_iter, max_dis, chn_pen_gap, chn_pen_skip, bw_thres, 
																		rid, rl, tl, quick_check, apend_be, gen_off, enable_mcopy, mcopy_rate, mcopy_khit_cut, 1);
					}

					if(sv && olst->length > olst_n) {
						oidx->a[ol] >>= 32; oidx->a[ol] <<= 32; oidx->a[ol] |= ((uint64_t)((uint32_t)-1));
					}
				}
			}

            l = k;
        }
    }
    cl->length = zn;

	for (k = m = 0; k < oidx->n; k++) {
		if(((uint32_t)oidx->a[k]) == ((uint32_t)-1)) continue;
		oidx->a[m++] = oidx->a[k];
	}
	// fprintf(stderr, "[M::%s]\ttot::%lu\tremain::%lu\n", __func__, (uint64_t)oidx->n, m);
	oidx->n = m;

	for (i = 0; i < olst->length; ++i) olst->list[i].align_length = 0;

	// minimizers_qgen0(ab, rs, rl, mz_w, mz_k, cl, k_flag, ha_flt_tab, ha_idx, rref, dbg_ct, sp, high_occ, low_occ);
	
	// lchain_qgen_mcopy_fast(cl, overlap_list, rid, rl, rref, apend_be, max_n_chain, max_skip, max_iter, max_dis, chn_pen_gap, chn_pen_skip, bw_thres, quick_check, gen_off, enable_mcopy, mcopy_rate, chain_cutoff, mcopy_khit_cut, sp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movsd %xmm3, 0x70(%rsp)
movsd %xmm2, 0x68(%rsp)
movsd %xmm1, 0x60(%rsp)
movsd %xmm0, 0x58(%rsp)
movq %r9, 0xa0(%rsp)
movq %rcx, 0x50(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r12
movq 0x258(%rsp), %rbx
movq 0x250(%rsp), %r14
leaq 0xd0(%rsp), %rdi
movl $0x108, %edx            # imm = 0x108
xorl %esi, %esi
callq 0x20e0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x12d305
movl (%r14), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x18(%rsp)
movq 0x228(%rsp), %rdi
testq %rbx, %rbx
je 0x12d32b
movl (%rbx), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x20(%rsp)
jmp 0x12d334
movq $0x0, 0x20(%rsp)
callq 0x3fd1c
movq $0x0, (%r12)
movl 0x1c(%r12), %esi
cmpl 0x10(%r12), %esi
jbe 0x12d365
movl %esi, 0x10(%r12)
movq 0x28(%r12), %rdi
shlq $0x4, %rsi
callq 0x2370
movq %rax, 0x28(%r12)
movq $0x0, (%r12)
cmpl $0x0, 0x18(%r12)
je 0x12d3c2
movq 0x210(%rsp), %r14
xorl %ebx, %ebx
movq %rsp, %r15
xorl %r13d, %r13d
movq 0x20(%r12), %rax
movq (%rax,%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x1139ee
movq 0x28(%r12), %rcx
movq %rax, 0x8(%rcx,%rbx)
movl (%rsp), %eax
movl %eax, (%rcx,%rbx)
movslq (%rsp), %rax
addq %rax, (%r12)
incq %r13
movl 0x18(%r12), %eax
addq $0x10, %rbx
cmpq %rax, %r13
jb 0x12d385
movq (%r12), %rax
cmpq 0x8(%r12), %rax
jbe 0x12d3e9
movq %rax, 0x8(%r12)
movq 0x30(%r12), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq %rax, 0x30(%r12)
movl 0x18(%r12), %eax
testq %rax, %rax
je 0x12d4cc
movq 0x20(%r12), %rcx
movq %rcx, 0x8(%rsp)
movq 0x28(%r12), %rdx
xorl %esi, %esi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x1(%rcx), %r8
xorl %r9d, %r9d
movq %rsi, %rbx
shlq $0x4, %rbx
movslq (%rdx,%rbx), %r10
testq %r10, %r10
jle 0x12d4c0
leaq (%rdx,%rbx), %r11
movq 0x8(%r11), %r11
movq 0x30(%r12), %r14
movq 0x8(%rsp), %rcx
addq %rcx, %rbx
addq $0x8, %rbx
movl $0xffffff, %ecx         # imm = 0xFFFFFF
cmpl %ecx, %r10d
movl $0xffffff, %ebp         # imm = 0xFFFFFF
cmovbl %r10d, %ebp
shll $0x8, %ebp
leaq (%r9,%r9,2), %r15
leaq (%r14,%r15,8), %r14
addq $0x10, %r14
xorl %r15d, %r15d
movq (%r11,%r15,8), %rdi
movq (%rbx), %r13
xorq %rdi, %r13
shrq $0x38, %rdi
movl %edi, -0x4(%r14)
movl %esi, -0x8(%r14)
movl %ebp, (%r14)
movzbl 0x7(%rbx), %edi
orl %ebp, %edi
movl %edi, (%r14)
movq (%r11,%r15,8), %rdi
movl %edi, %ecx
andl $0xfffffff, %ecx        # imm = 0xFFFFFFF
shlq $0x21, %rcx
shrq $0x17, %r13
andq %r8, %r13
orq %rcx, %r13
shrq $0x1c, %rdi
andl $0x7ffffff, %edi        # imm = 0x7FFFFFF
orq %r13, %rdi
movq %rdi, -0x10(%r14)
incq %r15
addq $0x18, %r14
cmpq %r15, %r10
jne 0x12d464
addq %r15, %r9
incq %rsi
cmpq %rax, %rsi
jne 0x12d414
movq 0x220(%rsp), %r13
movq 0x8(%r12), %rsi
movq 0x228(%rsp), %rax
cmpq 0x10(%rax), %rsi
jb 0x12d502
movq %rsi, 0x10(%rax)
movq (%rax), %rdi
shlq $0x4, %rsi
callq 0x2370
movq 0x228(%rsp), %rcx
movq %rax, (%rcx)
movq 0x2a0(%rsp), %rbp
movq %r13, %rdi
callq 0x3db37
movq (%r12), %rax
movq 0x30(%r12), %rdi
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x11fe18
movl $0x0, (%rsp)
movq (%r12), %rax
testq %rax, %rax
je 0x12dae0
movl 0x30(%rsp), %r10d
movq 0x18(%rsp), %rcx
leaq (%rcx,%rcx), %rdx
movq %rdx, 0x90(%rsp)
leaq -0x1(,%rcx,2), %rcx
movq %rcx, 0x88(%rsp)
movq 0x228(%rsp), %r9
leaq 0x18(%r9), %rcx
movq %rcx, 0x48(%rsp)
movl $0x1, %r11d
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %r10, 0x78(%rsp)
cmpq %rax, %r11
je 0x12d5b1
movq 0x30(%r12), %rax
leaq (%r11,%r11,2), %rcx
leaq (%r14,%r14,2), %rdx
movq (%rax,%rdx,8), %rdx
xorq (%rax,%rcx,8), %rdx
shrq $0x20, %rdx
je 0x12d6b5
movq (%rbp), %rax
movb $0x1, %bl
cmpq %rax, %r15
setb %dil
jae 0x12d68f
movq 0x10(%rbp), %rdx
movq 0x30(%r12), %rsi
leaq (%r14,%r14,2), %rcx
movq (%rsi,%rcx,8), %rsi
shrq $0x21, %rsi
movq (%rdx,%r15,8), %r8
shrq $0x21, %r8
cmpl %esi, %r8d
jae 0x12d60b
leaq -0x1(%rax), %rdi
cmpq %r15, %rdi
je 0x12d68c
movq 0x8(%rdx,%r15,8), %r8
shrq $0x21, %r8
incq %r15
cmpl %esi, %r8d
jb 0x12d5ea
cmpq %rax, %r15
setb %dil
testb %dil, %dil
je 0x12d68f
movq 0x30(%r12), %rdx
movq (%rdx,%rcx,8), %rcx
movq 0x10(%rbp), %rdx
movq (%rdx,%r15,8), %rsi
xorq %rcx, %rsi
shrq $0x21, %rsi
jne 0x12d68f
cmpq %rax, %r15
setb %sil
jae 0x12dacf
movq %rcx, %rdi
shrq $0x20, %rdi
cmpl %edi, 0x4(%rdx,%r15,8)
jae 0x12d660
leaq 0x1(%r15), %r8
cmpq %rax, %r8
setb %sil
jae 0x12dad6
cmpl %edi, 0xc(%rdx,%r15,8)
movq %r8, %r15
jb 0x12d645
testb %sil, %sil
je 0x12dacf
movq (%rdx,%r15,8), %rax
xorq %rax, %rcx
shrq $0x20, %rcx
jne 0x12dacf
movl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
sete %bl
setne %cl
jmp 0x12d691
movq %rax, %r15
movb $0x1, %cl
testb %cl, %cl
je 0x12d6b2
movb %bl, 0x7(%rsp)
movq 0x30(%r12), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rbx
movq %rbx, %rcx
shrq $0x21, %rcx
cmpq %r10, %rcx
jne 0x12d6ca
movq %r11, %r14
incq %r11
movq (%r12), %rax
cmpq %rax, %r11
jbe 0x12d58d
jmp 0x12daf1
movq 0x218(%rsp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x38(%rsp)
movq (%rax,%rcx,8), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%r13), %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
movq %rax, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
movl $0x0, %r13d
cmpq %r11, %r14
movq %r11, 0x8(%rsp)
jae 0x12d8a2
movq 0x38(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq 0x2a8(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x28(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incq %rax
movq %rax, 0x98(%rsp)
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %rbp
xorl %r13d, %r13d
movq 0x20(%r12), %rax
movq 0x30(%r12), %rsi
movl 0x8(%rsi,%rbp), %edi
addq %rbp, %rsi
shlq $0x4, %rdi
subq $0x18, %rsp
movq 0x40(%rsp), %rdx
leaq 0xe0(%rsp), %rcx
leaq 0xd8(%rsp), %r8
leaq 0xd0(%rsp), %r9
pushq 0x2b0(%rsp)
pushq 0x238(%rsp)
leaq 0xf8(%rsp), %r10
pushq %r10
pushq (%rax,%rdi)
pushq 0xd8(%rsp)
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0xf8(%rsp), %rax
pushq %rax
callq 0x12b7f9
addq $0x50, %rsp
testq %rax, %rax
je 0x12d88d
movq 0x30(%r12), %rcx
leaq (,%r13,8), %rax
leaq (%rax,%rax,2), %rax
movq 0x10(%rcx,%rbp), %rdx
movq %rdx, 0x10(%rcx,%rax)
movupd (%rcx,%rbp), %xmm0
movupd %xmm0, (%rcx,%rax)
movq 0x30(%r12), %rcx
movl (%rcx,%rax), %esi
movl 0xc(%rcx,%rax), %edx
movl %esi, 0xc(%rcx,%rax)
testq %rbx, 0x98(%rsp)
je 0x12d83f
leaq (,%r13,2), %rsi
addq %r13, %rsi
movl 0xc(%rcx,%rsi,8), %edi
notl %edi
addl 0x40(%rsp), %edx
addl %edi, %edx
decl %edx
movl %edx, 0xc(%rcx,%rsi,8)
addq %rcx, %rax
movq 0x20(%r12), %rdx
leaq (,%r13,2), %rsi
addq %r13, %rsi
movl 0x8(%rcx,%rsi,8), %edi
shlq $0x4, %rdi
movq 0x8(%rdx,%rdi), %rdx
movq %rdx, %rdi
shrq $0x1c, %rdi
andl $0x7ffffff, %edi        # imm = 0x7FFFFFF
movl %edi, 0x8(%rcx,%rsi,8)
shlq $0x4, %rdx
movabsq $0x7ffffff00000000, %rcx # imm = 0x7FFFFFF00000000
andq %rcx, %rdx
movl 0xc(%rax), %ecx
orq %rdx, %rcx
movq %rcx, (%rax)
incq %r13
movq 0x8(%rsp), %r11
incq %r14
addq $0x18, %rbp
cmpq %r14, %r11
jne 0x12d767
cmpq $0x2, %r13
jb 0x12d8c6
movq 0x30(%r12), %rdi
leaq (,%r13,2), %rax
addq %r13, %rax
leaq (%rdi,%rax,8), %rsi
callq 0x11fe18
movq 0x8(%rsp), %r11
testq %r13, %r13
movq 0x20(%rsp), %r9
je 0x12da77
movslq (%rsp), %rax
movq %rax, 0x28(%rsp)
shrq %rbx
andl $0x80000000, %ebx       # imm = 0x80000000
addl 0x38(%rsp), %ebx
movl $0x10, %r14d
movq 0x18(%rsp), %r8
movq 0x228(%rsp), %rdi
movq (%rdi), %rax
movslq (%rsp), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rsp)
shlq $0x4, %rcx
leaq (%rax,%rcx), %rbp
movl %ebx, (%rax,%rcx)
movq 0x30(%r12), %rdx
movl -0x4(%rdx,%r14), %esi
movl %esi, 0x4(%rax,%rcx)
movl -0x8(%rdx,%r14), %esi
movl %esi, 0x8(%rax,%rcx)
movl (%rdx,%r14), %ecx
shrl $0x8, %ecx
movl %ecx, %eax
cmpl %ecx, %r8d
seta %cl
cmpq %rax, %r9
setb %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x12d951
movl $0x1, 0xc(%rbp)
jmp 0x12d9a2
cmpl %eax, %r9d
jae 0x12d99b
addq 0x88(%rsp), %rax
xorl %edx, %edx
divq 0x90(%rsp)
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0xfc1f6(%rip), %xmm1    # 0x229b70
callq 0x23a0
movq 0x20(%rsp), %r9
movq 0x228(%rsp), %rdi
movq 0x18(%rsp), %r8
cvttsd2si %xmm0, %rax
movl %eax, 0xc(%rbp)
jmp 0x12d9a2
movl $0x2, 0xc(%rbp)
cmpl $0x1000000, 0xc(%rbp)   # imm = 0x1000000
jb 0x12d9b2
movl $0xffffff, 0xc(%rbp)    # imm = 0xFFFFFF
movl 0xc(%rbp), %eax
shll $0x8, %eax
movl %eax, 0xc(%rbp)
movq 0x30(%r12), %rcx
movzbl (%rcx,%r14), %ecx
orl %eax, %ecx
movl %ecx, 0xc(%rbp)
addq $0x18, %r14
decq %r13
jne 0x12d8fd
movslq (%rsp), %rdx
movq 0x28(%rsp), %rsi
subq %rsi, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
movq 0x48(%rsp), %r8
movq 0x220(%rsp), %r13
movq %r13, %r9
movsd 0x68(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0x60(%rsp), %xmm3
pushq $0x1
movl 0x278(%rsp), %eax
pushq %rax
pushq 0x278(%rsp)
movl 0x278(%rsp), %eax
pushq %rax
movl 0x250(%rsp), %eax
pushq %rax
pushq 0x2b8(%rsp)
pushq 0x70(%rsp)
pushq 0x88(%rsp)
pushq 0x70(%rsp)
pushq 0x2d0(%rsp)
pushq 0x2d0(%rsp)
pushq 0x2d0(%rsp)
callq 0x4287f
addq $0x60, %rsp
addq %rax, %rbx
movq %rbx, 0x10(%rsp)
movq 0x8(%rsp), %r11
jmp 0x12da7f
movq 0x220(%rsp), %r13
cmpb $0x0, 0x7(%rsp)
movq 0x2a0(%rsp), %rbp
movq 0x78(%rsp), %r10
je 0x12daa3
movq %r11, %r14
movq 0x228(%rsp), %r9
jmp 0x12d6b5
movq 0x80(%rsp), %rax
cmpq %rax, 0x10(%r13)
movq 0x228(%rsp), %r9
jbe 0x12d6b2
movq 0x10(%rbp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
orq %rcx, (%rax,%r15,8)
jmp 0x12d6b2
xorl %ecx, %ecx
jmp 0x12d691
xorl %ecx, %ecx
movq %rax, %r15
jmp 0x12d691
movq $0x0, 0x10(%rsp)
movq 0x228(%rsp), %r9
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r9)
cmpq $0x0, (%rbp)
je 0x12db24
movq 0x10(%rbp), %rcx
xorl %edx, %edx
xorl %eax, %eax
movq (%rcx,%rdx,8), %rsi
cmpl $-0x1, %esi
je 0x12db19
movq %rsi, (%rcx,%rax,8)
incq %rax
incq %rdx
cmpq (%rbp), %rdx
jb 0x12db09
jmp 0x12db26
xorl %eax, %eax
movq %rax, (%rbp)
movq 0x10(%r13), %rax
testq %rax, %rax
je 0x12db4d
movq (%r13), %rcx
addq $0x28, %rcx
movl $0x0, (%rcx)
addq $0xa8, %rcx
decq %rax
jne 0x12db3b
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq