// File: 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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2c8, %rsp            # imm = 0x2C8
movq 0xa8(%rbp), %rax
movq 0xa0(%rbp), %rax
movq 0x98(%rbp), %rax
movq 0x90(%rbp), %rax
movq 0x88(%rbp), %rax
movq 0x80(%rbp), %rax
movq 0x78(%rbp), %rax
movl 0x70(%rbp), %eax
movq 0x68(%rbp), %rax
movl 0x60(%rbp), %eax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movl %esi, -0x34(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm1, -0x68(%rbp)
movsd %xmm2, -0x70(%rbp)
movsd %xmm3, -0x78(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
leaq -0x1d0(%rbp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x2100
cmpq $0x0, 0x50(%rbp)
je 0x1b0d53
movq 0x50(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xa0(%rbp)
cmpq $0x2, -0xa0(%rbp)
jae 0x1b0d51
movq $0x2, -0xa0(%rbp)
jmp 0x1b0d53
cmpq $0x0, 0x58(%rbp)
je 0x1b0d7e
movq 0x58(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xa8(%rbp)
cmpq $0x2, -0xa8(%rbp)
jae 0x1b0d7c
movq $0x2, -0xa8(%rbp)
jmp 0x1b0d7e
movq 0x28(%rbp), %rdi
callq 0x23090
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jbe 0x1b0dd5
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %esi
shlq $0x4, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq $0x0, -0x80(%rbp)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x80(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
jae 0x1b0e75
movq 0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
leaq -0xac(%rbp), %rdx
callq 0x1877b0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x80(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0xac(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x80(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movslq -0xac(%rbp), %rcx
movq -0x30(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x1b0de8
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x1b0eb6
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x30(%rbp), %rax
imulq $0x18, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x80(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0x18(%rcx), %ecx
cmpq %rcx, %rax
jae 0x1b10d9
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movq -0xc8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1b10c6
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xb4(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x1d8(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x1e0(%rbp)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x37, %rax
andq $0x1, %rax
movl %eax, %edx
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
shrq $0x37, %rax
andq $0x1, %rax
movl %eax, %esi
movl $0x1, %eax
xorl %ecx, %ecx
cmpl %esi, %edx
cmovel %ecx, %eax
movb %al, -0x1e1(%rbp)
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
shrq $0x38, %rax
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x80(%rbp), %rax
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xc8(%rbp), %rax
movl (%rax), %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x1e0(%rbp), %rax
cmpl $0xffffff, 0x10(%rax)   # imm = 0xFFFFFF
jbe 0x1b1011
movq -0x1e0(%rbp), %rax
movl $0xffffff, 0x10(%rax)   # imm = 0xFFFFFF
movq -0x1e0(%rbp), %rax
movl 0x10(%rax), %ecx
shll $0x8, %ecx
movl %ecx, 0x10(%rax)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x38, %rax
cmpl $0xff, %eax
ja 0x1b104e
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x38, %rax
movl %eax, -0x254(%rbp)
jmp 0x1b105b
movl $0xff, %eax
movl %eax, -0x254(%rbp)
jmp 0x1b105b
movl -0x254(%rbp), %ecx
movq -0x1e0(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x1d8(%rbp), %rax
movq (%rax), %rcx
andq $0xfffffff, %rcx        # imm = 0xFFFFFFF
shlq $0x21, %rcx
movzbl -0x1e1(%rbp), %eax
shlq $0x20, %rax
orq %rax, %rcx
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
orq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq %rcx, (%rax)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x1b0f1b
jmp 0x1b10c8
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x1b0ec9
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jb 0x1b111d
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x28(%rbp), %rax
movq (%rax), %rdi
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rsi
shlq $0x4, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
movq 0x20(%rbp), %rdi
callq 0x1e120
movq $-0x1, -0x1f8(%rbp)
movq $-0x1, -0x200(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x30(%rbp), %rax
imulq $0x18, (%rax), %rax
addq %rax, %rsi
callq 0x19c150
movq $0x1, -0x88(%rbp)
movq $0x0, -0x220(%rbp)
movl $0x0, -0xac(%rbp)
movq $0x0, -0x218(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
ja 0x1b1ae8
movq -0x88(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
je 0x1b11f3
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x88(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x90(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x1b1acf
jmp 0x1b11f5
movq -0x218(%rbp), %rcx
movq 0xa0(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x255(%rbp)
jae 0x1b1250
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x218(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x90(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
setb %al
movb %al, -0x255(%rbp)
movb -0x255(%rbp), %al
testb $0x1, %al
jne 0x1b125c
jmp 0x1b1272
jmp 0x1b125e
movq -0x218(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x218(%rbp)
jmp 0x1b11f5
movq -0x218(%rbp), %rax
movq 0xa0(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1b1ac1
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x90(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movq 0xa0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x218(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
jne 0x1b1ac1
movq 0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x90(%rbp), %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x21, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x200(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x90(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x21, %rax
movq %rax, -0x1f8(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x90(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
andq $0x1, %rax
movq %rax, -0x208(%rbp)
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x228(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0x250(%rbp)
movq $0x0, -0x248(%rbp)
movq $0x0, -0x240(%rbp)
movq $0x0, -0x238(%rbp)
movq $0x0, -0x230(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x88(%rbp), %rax
jae 0x1b16e4
movl -0x34(%rbp), %eax
movl %eax, %edi
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rsi
imulq $0x18, -0x80(%rbp), %rax
addq %rax, %rsi
movq 0xa8(%rbp), %rdx
imulq $0x18, -0x1f8(%rbp), %rax
addq %rax, %rdx
movq -0x58(%rbp), %r13
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x80(%rbp), %r8
addq %r8, %rcx
movl 0x8(%rcx), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %r12
movq 0x18(%rbp), %r14
movq 0x98(%rbp), %rbx
movq -0x40(%rbp), %r11
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x80(%rbp), %r8
addq %r8, %rcx
movl 0x8(%rcx), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
addl $0x1, %eax
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq -0x30(%rbp), %r8
movq 0x30(%r8), %r8
imulq $0x18, -0x80(%rbp), %r9
addq %r9, %r8
movl 0x8(%r8), %r8d
shlq $0x4, %r8
addq %r8, %rcx
movq 0x8(%rcx), %rcx
shrq $0x38, %rcx
subl %ecx, %eax
movslq %eax, %r10
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x80(%rbp), %r8
addq %r8, %rcx
movl 0x8(%rcx), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
addl $0x1, %eax
cltq
movq %rax, -0x260(%rbp)
leaq -0x230(%rbp), %rcx
leaq -0x238(%rbp), %r8
leaq -0x240(%rbp), %r9
leaq -0x248(%rbp), %rax
leaq -0x250(%rbp), %r15
movq %r15, -0x268(%rbp)
leaq -0x1d0(%rbp), %r15
movq %rax, (%rsp)
movq -0x268(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x260(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1ae300
cmpq $0x0, %rax
jne 0x1b1524
jmp 0x1b16d3
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rcx
imulq $0x18, -0x80(%rbp), %rax
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq %rax, -0x210(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
cmpq $0x0, -0x208(%rbp)
je 0x1b15fa
movq -0x200(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
subq -0x210(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrq $0x1c, %rax
andq $0x7ffffff, %rax        # imm = 0x7FFFFFF
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x98(%rbp), %rdx
addq %rdx, %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x1b1395
cmpq $0x1, -0x98(%rbp)
jbe 0x1b170e
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rsi
imulq $0x18, -0x98(%rbp), %rax
addq %rax, %rsi
callq 0x19c150
movq $0x0, -0x80(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0xb0(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x98(%rbp), %rax
jae 0x1b192b
movq 0x28(%rbp), %rax
movq (%rax), %rax
movl -0xac(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0xac(%rbp)
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f8(%rbp), %rax
movl %eax, %edx
movq -0x1f0(%rbp), %rax
movl (%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x208(%rbp), %rax
movl %eax, %edx
movq -0x1f0(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq -0x1f0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x1f0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
shrl $0x8, %eax
movl %eax, %eax
cmpq -0xa0(%rbp), %rax
jae 0x1b182f
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
shrl $0x8, %eax
movl %eax, %eax
cmpq -0xa8(%rbp), %rax
jbe 0x1b182f
movq -0x1f0(%rbp), %rax
movl $0x1, 0xc(%rax)
jmp 0x1b18c6
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
shrl $0x8, %eax
movl %eax, %eax
cmpq -0xa8(%rbp), %rax
ja 0x1b1860
movq -0x1f0(%rbp), %rax
movl $0x2, 0xc(%rax)
jmp 0x1b18c4
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x80(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
movl 0x10(%rax,%rcx,8), %eax
shrl $0x8, %eax
movq -0xa0(%rbp), %rdx
movq %rdx, %rcx
addq %rcx, %rcx
leaq -0x1(%rax,%rdx,2), %rax
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
incl %ecx
movq -0x1f0(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x1f0(%rbp), %rax
movl 0xc(%rax), %edi
movsd 0x1d4f9a(%rip), %xmm0   # 0x386848
callq 0x1b4690
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x1f0(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x1b18c6
movq -0x1f0(%rbp), %rax
cmpl $0xffffff, 0xc(%rax)    # imm = 0xFFFFFF
jbe 0x1b18e4
movq -0x1f0(%rbp), %rax
movl $0xffffff, 0xc(%rax)    # imm = 0xFFFFFF
movq -0x1f0(%rbp), %rax
movl 0xc(%rax), %ecx
shll $0x8, %ecx
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x18, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
andl $0xff, %ecx
movq -0x1f0(%rbp), %rax
orl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x1b1722
cmpq $0x0, -0x98(%rbp)
jbe 0x1b1a4e
movq -0x1f8(%rbp), %rax
movl -0x34(%rbp), %ecx
cmpq %rcx, %rax
je 0x1b1a4e
movq 0x28(%rbp), %rdi
movslq -0xb0(%rbp), %rsi
movl -0xac(%rbp), %eax
subl -0xb0(%rbp), %eax
movslq %eax, %rdx
movq -0x220(%rbp), %rcx
movq 0x28(%rbp), %r8
addq $0x18, %r8
movq 0x20(%rbp), %r9
movq 0x78(%rbp), %rax
movq %rax, -0x288(%rbp)
movq 0x80(%rbp), %rax
movq %rax, -0x280(%rbp)
movq 0x88(%rbp), %rax
movq %rax, -0x278(%rbp)
movsd -0x70(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
movl -0x34(%rbp), %r13d
movq -0x48(%rbp), %r12
movq -0x200(%rbp), %r15
movq 0x90(%rbp), %r14
movl 0x30(%rbp), %ebx
movl 0x60(%rbp), %eax
movl %eax, %r11d
movq 0x68(%rbp), %r10
movsd -0x68(%rbp), %xmm3
movl 0x70(%rbp), %eax
movq %rax, -0x270(%rbp)
movq -0x288(%rbp), %rax
movq %rax, (%rsp)
movq -0x280(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x278(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0x270(%rbp), %rax
movl %r13d, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movl %ebx, 0x38(%rsp)
movq %r11, 0x40(%rsp)
movq %r10, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movq $0x1, 0x58(%rsp)
callq 0x275f0
addq -0x220(%rbp), %rax
movq %rax, -0x220(%rbp)
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x228(%rbp), %rax
jbe 0x1b1abf
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x218(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
shrq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x218(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x218(%rbp), %rcx
movabsq $0xffffffff, %rdx       # imm = 0xFFFFFFFF
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1b1ac1
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0x1b1ad1
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x1b1192
movq -0x220(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq $0x0, -0x98(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0xa0(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1b1b8b
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $-0x1, %eax
jne 0x1b1b3d
jmp 0x1b1b77
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x98(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x1b1b0d
movq -0x98(%rbp), %rcx
movq 0xa0(%rbp), %rax
movq %rcx, (%rax)
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq 0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x1b1bd9
movq 0x20(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x80(%rbp), %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x1b1ba4
addq $0x2c8, %rsp            # imm = 0x2C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)