// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/anchor.cpp
// Function: h_ec_lchain_re_gen(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_gen(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];
	k_mer_hit *p; uint64_t tid = (uint64_t)-1, tl = (uint64_t)-1, trev, tspan, ol, zn, olst_n; 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 (; (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))) {
				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;
				for (i = l, m = 0, ok = nk = ck = str_s = str_e = 0; i < k; i++) {
					if(!recalu_minimizer(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
					// if(rid == 3196 && tid == 3199) 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(rid == 3196 && tid == 3199) fprintf(stderr, "[M::%s]\ttid::%lu\ttrev::%lu\told::%lu\tnew::%lu\n", __func__, tid, trev, k - l, m);

				if(m > 0 && tid != rid) {
					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(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 $0x1e8, %rsp            # imm = 0x1E8
movq %xmm3, 0x88(%rsp)
movq %xmm2, 0x80(%rsp)
movq %xmm1, 0x78(%rsp)
movq %xmm0, 0x70(%rsp)
movq %r9, 0xb0(%rsp)
movq %rcx, 0x68(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x268(%rsp), %rbx
movq 0x260(%rsp), %r14
leaq 0xe0(%rsp), %rdi
movl $0x108, %edx            # imm = 0x108
xorl %esi, %esi
callq 0x20e0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x132aef
movl (%r14), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x20(%rsp)
testq %rbx, %rbx
je 0x132b0d
movl (%rbx), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x18(%rsp)
jmp 0x132b16
movq $0x0, 0x18(%rsp)
movq 0x238(%rsp), %rdi
callq 0x3f1bd
movq 0x8(%rsp), %rdi
movq $0x0, (%rdi)
movl 0x1c(%rdi), %esi
cmpl 0x10(%rdi), %esi
jbe 0x132b50
movl %esi, 0x10(%rdi)
movq 0x28(%rdi), %rdi
shlq $0x4, %rsi
callq 0x2370
movq 0x8(%rsp), %rdi
movq %rax, 0x28(%rdi)
movq $0x0, (%rdi)
cmpl $0x0, 0x18(%rdi)
je 0x132cc1
movq 0x220(%rsp), %r14
xorl %ebx, %ebx
leaq 0x4(%rsp), %r15
xorl %r12d, %r12d
movq 0x20(%rdi), %rax
movq (%rax,%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x1194bb
movq 0x8(%rsp), %rdi
movq 0x28(%rdi), %rcx
movq %rax, 0x8(%rcx,%rbx)
movslq 0x4(%rsp), %rax
movl %eax, (%rcx,%rbx)
addq (%rdi), %rax
movq %rax, (%rdi)
incq %r12
movl 0x18(%rdi), %ecx
addq $0x10, %rbx
cmpq %rcx, %r12
jb 0x132b73
cmpq 0x8(%rdi), %rax
jbe 0x132bd8
movq %rax, 0x8(%rdi)
movq 0x30(%rdi), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq 0x8(%rsp), %rdi
movq %rax, 0x30(%rdi)
movl 0x18(%rdi), %ecx
leaq 0x8(%rdi), %rax
testl %ecx, %ecx
je 0x132cc5
movq %rax, 0x10(%rsp)
movl %ecx, %ecx
movq 0x20(%rdi), %rdx
movq 0x28(%rdi), %rsi
xorl %edi, %edi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1(%rax), %r9
xorl %r10d, %r10d
movq %rdi, %r14
shlq $0x4, %r14
movslq (%rsi,%r14), %r11
testq %r11, %r11
jle 0x132cae
leaq (%rsi,%r14), %rbx
movq 0x8(%rbx), %rbx
movq 0x8(%rsp), %rax
movq 0x30(%rax), %r15
addq %rdx, %r14
addq $0x8, %r14
movl $0xffffff, %eax         # imm = 0xFFFFFF
cmpl %eax, %r11d
movl $0xffffff, %ebp         # imm = 0xFFFFFF
cmovbl %r11d, %ebp
shll $0x8, %ebp
leaq (%r10,%r10,2), %r12
leaq (%r15,%r12,8), %r15
addq $0x10, %r15
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rax
movq (%r14), %r13
xorq %rax, %r13
shrq $0x38, %rax
movl %eax, -0x4(%r15)
movl %edi, -0x8(%r15)
movl %ebp, (%r15)
movzbl 0x7(%r14), %eax
orl %ebp, %eax
movl %eax, (%r15)
movq (%rbx,%r12,8), %rax
movl %eax, %r8d
andl $0xfffffff, %r8d        # imm = 0xFFFFFFF
shlq $0x21, %r8
shrq $0x17, %r13
andq %r9, %r13
orq %r8, %r13
shrq $0x1c, %rax
andl $0x7ffffff, %eax        # imm = 0x7FFFFFF
orq %r13, %rax
movq %rax, -0x10(%r15)
incq %r12
addq $0x18, %r15
cmpq %r12, %r11
jne 0x132c50
addq %r12, %r10
incq %rdi
cmpq %rcx, %rdi
jne 0x132c01
movq 0x10(%rsp), %rax
jmp 0x132cc5
leaq 0x8(%rdi), %rax
movq 0x230(%rsp), %r12
movq (%rax), %rsi
movq 0x238(%rsp), %rax
cmpq 0x10(%rax), %rsi
jb 0x132cf9
movq 0x238(%rsp), %rbx
movq %rsi, 0x10(%rbx)
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x2370
movq %rax, (%rbx)
movq 0x2b0(%rsp), %r13
movq %r12, %rdi
callq 0x3d018
movq 0x8(%rsp), %rbx
movq (%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x125ce1
movl $0x0, 0x4(%rsp)
movq (%rbx), %rax
testq %rax, %rax
je 0x13323d
movq %rbx, %r9
movl 0x40(%rsp), %ecx
movq %rcx, 0x90(%rsp)
movq 0x20(%rsp), %rcx
leaq (%rcx,%rcx), %rdx
movq %rdx, 0xa0(%rsp)
leaq -0x1(%rcx,%rcx), %rcx
movq %rcx, 0x98(%rsp)
movq 0x238(%rsp), %rcx
addq $0x18, %rcx
movq %rcx, 0x60(%rsp)
movl $0x1, %edi
xorl %r8d, %r8d
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq %rax, %rdi
je 0x132da7
movq 0x30(%r9), %rax
leaq (%rdi,%rdi,2), %rcx
leaq (%r15,%r15,2), %rdx
movq (%rax,%rdx,8), %rdx
xorq (%rax,%rcx,8), %rdx
shrq $0x20, %rdx
je 0x13322c
movq (%r13), %rax
cmpq %rax, %r14
jae 0x133229
movq 0x10(%r13), %rcx
movq 0x30(%r9), %rdx
leaq (%r15,%r15,2), %rsi
movq (%rdx,%rsi,8), %rbx
movq %rbx, 0x58(%rsp)
shrq $0x20, %rbx
movq (%rcx,%r14,8), %rdx
shrq $0x20, %rdx
cmpq %rbx, %rdx
jae 0x132ded
incq %r14
cmpq %r14, %rax
jne 0x132dcd
movq %rdi, %r15
movq %rax, %r14
jmp 0x13322c
cmpl %edx, %ebx
jne 0x133229
movq 0x228(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x58(%rsp), %rcx
shrq $0x21, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x50(%rsp)
movq 0x10(%r12), %rax
movq %r8, 0xb8(%rsp)
movq %r8, 0xc0(%rsp)
movq %r8, 0xc8(%rsp)
movq %r8, 0xd0(%rsp)
movq %r8, 0xd8(%rsp)
cmpq %rdi, %r15
jae 0x133215
movq %rax, 0x28(%rsp)
movq %rbp, 0x30(%rsp)
movq %rcx, 0x48(%rsp)
leaq (%rcx,%rcx,2), %rax
movq 0x2b8(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x38(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incq %rax
movq %rax, 0xa8(%rsp)
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %r12
xorl %ebp, %ebp
movq %rdi, 0x10(%rsp)
movq 0x20(%r9), %rax
movq 0x30(%r9), %rsi
movl 0x8(%rsi,%r12), %edi
addq %r12, %rsi
shlq $0x4, %rdi
subq $0x18, %rsp
movq 0x50(%rsp), %rdx
leaq 0xf0(%rsp), %rcx
leaq 0xe8(%rsp), %r8
movq %r9, %r13
leaq 0xe0(%rsp), %r9
pushq 0x2c0(%rsp)
pushq 0x248(%rsp)
leaq 0x108(%rsp), %r10
pushq %r10
pushq (%rax,%rdi)
pushq 0xe8(%rsp)
leaq 0xf8(%rsp), %rax
pushq %rax
leaq 0x108(%rsp), %rax
pushq %rax
callq 0x130d0f
addq $0x50, %rsp
testq %rax, %rax
je 0x132fbe
movq 0x30(%r13), %rcx
leaq (,%rbp,8), %rax
leaq (%rax,%rax,2), %rax
movq 0x10(%rcx,%r12), %rdx
movq %rdx, 0x10(%rcx,%rax)
movdqu (%rcx,%r12), %xmm0
movdqu %xmm0, (%rcx,%rax)
movq 0x30(%r13), %rdx
movl (%rdx,%rax), %ecx
movl 0xc(%rdx,%rax), %esi
movl %ecx, 0xc(%rdx,%rax)
movq 0xa8(%rsp), %rdi
testq %rdi, 0x58(%rsp)
movq %r13, %r9
je 0x132f6d
leaq (,%rbp,2), %rdi
addq %rbp, %rdi
notl %ecx
addl 0x50(%rsp), %esi
addl %esi, %ecx
decl %ecx
movl %ecx, 0xc(%rdx,%rdi,8)
addq %rdx, %rax
movq 0x20(%r9), %rsi
leaq (,%rbp,2), %rdi
addq %rbp, %rdi
movl 0x8(%rdx,%rdi,8), %r8d
shlq $0x4, %r8
movq 0x8(%rsi,%r8), %rsi
movq %rsi, %r8
shrq $0x1c, %r8
andl $0x7ffffff, %r8d        # imm = 0x7FFFFFF
movl %r8d, 0x8(%rdx,%rdi,8)
shlq $0x4, %rsi
movabsq $0x7ffffff00000000, %rdx # imm = 0x7FFFFFF00000000
andq %rdx, %rsi
movl %ecx, %ecx
orq %rsi, %rcx
movq %rcx, (%rax)
incq %rbp
jmp 0x132fc1
movq %r13, %r9
incq %r15
addq $0x18, %r12
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
jne 0x132e90
cmpq $0x2, %rbp
jb 0x132ffb
movq 0x30(%r9), %rdi
leaq (,%rbp,2), %rax
addq %rbp, %rax
leaq (%rdi,%rax,8), %rsi
callq 0x125ce1
movq 0x8(%rsp), %r9
jmp 0x133009
testq %rbp, %rbp
movl $0x1, %ebp
je 0x1331f3
movslq 0x4(%rsp), %rax
movq %rax, 0x38(%rsp)
shll $0x1f, %ebx
addl 0x48(%rsp), %ebx
movl $0x10, %r15d
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
movq 0x238(%rsp), %rax
movq (%rax), %rax
movslq 0x4(%rsp), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rsp)
shlq $0x4, %rcx
leaq (%rax,%rcx), %r12
movl %ebx, (%rax,%rcx)
movq 0x30(%r9), %rdx
movq -0x8(%rdx,%r15), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x4(%rax,%rcx)
movl (%rdx,%r15), %edx
shrl $0x8, %edx
cmpl %edx, %edi
ja 0x1330d2
cmpl %edx, %r8d
jae 0x1330d2
movq 0x98(%rsp), %rax
addq %rdx, %rax
xorl %edx, %edx
divq 0xa0(%rsp)
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movq 0x102ccf(%rip), %xmm1   # 0x235d68
callq 0x23a0
cvttsd2si %xmm0, %rdx
movl %edx, 0xc(%r12)
addq $0xc, %r12
cmpl $0x1000000, %edx        # imm = 0x1000000
jb 0x1330c1
movl $0xffffff, (%r12)       # imm = 0xFFFFFF
movl $0xffffff, %edx         # imm = 0xFFFFFF
movq 0x8(%rsp), %r9
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r8
jmp 0x1330f9
cmpq %rdx, %r8
setb %sil
cmpq %rdx, %rdi
seta %dl
andb %sil, %dl
movzbl %dl, %esi
movl $0x2, %edx
subl %esi, %edx
movl %edx, 0xc(%r12)
leaq (%rax,%rcx), %r12
addq $0xc, %r12
shll $0x8, %edx
movq 0x30(%r9), %rax
movzbl (%rax,%r15), %eax
orl %edx, %eax
movl %eax, (%r12)
addq $0x18, %r15
decq %rbp
jne 0x13302a
movq 0x48(%rsp), %rax
cmpl 0x90(%rsp), %eax
movq 0x2b0(%rsp), %r13
jne 0x13313b
movq 0x230(%rsp), %r12
jmp 0x133203
movslq 0x4(%rsp), %rdx
movq 0x38(%rsp), %rsi
subq %rsi, %rdx
movq 0x238(%rsp), %rdi
movq 0x30(%rsp), %rbp
movq %rbp, %rcx
movq 0x60(%rsp), %r8
movq 0x230(%rsp), %r12
movq %r12, %r9
movq 0x80(%rsp), %xmm0
movq 0x88(%rsp), %xmm1
movq 0x70(%rsp), %xmm2
movq 0x78(%rsp), %xmm3
pushq $0x1
movl 0x288(%rsp), %eax
pushq %rax
pushq 0x288(%rsp)
movl 0x288(%rsp), %eax
pushq %rax
movl 0x260(%rsp), %eax
pushq %rax
pushq 0x2c8(%rsp)
pushq 0x80(%rsp)
pushq 0xa0(%rsp)
pushq 0x80(%rsp)
pushq 0x2e0(%rsp)
pushq 0x2e0(%rsp)
pushq 0x2e0(%rsp)
callq 0x42094
movq 0x68(%rsp), %r9
addq $0x60, %rsp
addq %rax, %rbp
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
jmp 0x133210
movq 0x230(%rsp), %r12
movq 0x2b0(%rsp), %r13
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
movq 0x30(%rsp), %rbp
movq 0x28(%rsp), %rax
cmpq %rax, 0x10(%r12)
jbe 0x133229
movq 0x10(%r13), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
orq %rcx, (%rax,%r14,8)
movq %rdi, %r15
incq %rdi
movq (%r9), %rax
cmpq %rax, %rdi
jbe 0x132d84
jmp 0x13323f
xorl %ebp, %ebp
movq 0x238(%rsp), %rax
movq %rbp, 0x8(%rax)
movq (%r13), %rdx
testq %rdx, %rdx
je 0x13327a
movq 0x10(%r13), %rcx
xorl %esi, %esi
xorl %eax, %eax
movq (%rcx,%rsi,8), %rdi
cmpl $-0x1, %edi
je 0x133270
movq %rdi, (%rcx,%rax,8)
incq %rax
movq (%r13), %rdx
incq %rsi
cmpq %rdx, %rsi
jb 0x13325c
jmp 0x13327c
xorl %eax, %eax
movq %rax, (%r13)
movq 0x10(%r12), %rcx
testq %rcx, %rcx
je 0x133394
leaq 0x3(%rcx), %rax
andq $-0x4, %rax
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movl $0x220, %ecx            # imm = 0x220
addq (%r12), %rcx
movdqa 0xfe00c(%rip), %xmm1    # 0x2312c0
movdqa 0xfe014(%rip), %xmm2    # 0x2312d0
movdqa 0xfe01c(%rip), %xmm3    # 0x2312e0
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0xfe25c(%rip), %xmm5    # 0x231530
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 0x133312
movl $0x0, -0x1f8(%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x13332a
movl $0x0, -0x150(%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 0x13336b
movl $0x0, -0xa8(%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x13337b
movl $0x0, (%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x2a0, %rcx            # imm = 0x2A0
addq $-0x4, %rax
jne 0x1332d4
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq