// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/ecovlp.cpp
// Function: h_ec_lchain_fast(ha_abuf_s*, unsigned int, UC_Read*, UC_Read*, unsigned long, unsigned long, All_reads*, overlap_region_alloc*, Candidates_list*, bit_extz_t*, asg16_v*, asg64_v*, double, int, kvec_t_u8_warp*, kvec_t_u64_warp*, st_mt_t*, unsigned int*, unsigned int*, unsigned int, unsigned int, long, double, unsigned int, ma_hit_t_alloc*, ma_hit_t_alloc*, double)
overlap_region* h_ec_lchain_fast(ha_abuf_t *ab, uint32_t rid, UC_Read *qu, UC_Read *tu, uint64_t mz_w, uint64_t mz_k, All_reads *rref, overlap_region_alloc *ol, Candidates_list *cl, bit_extz_t *exz, asg16_v *buf, asg64_v *srt_i, 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 is_accurate, uint32_t gen_off, int64_t enable_mcopy, double mcopy_rate, uint32_t mcopy_khit_cut, ma_hit_t_alloc *in0, ma_hit_t_alloc *in1, double sh)
{
    // fprintf(stderr, "-0-[M::%s]\tnew_n::%lu\told_n::%u\n", __func__, ol->length, in0->length + in1->length);
    // fprintf(stderr, "-mm-[M::%s]\tchain_cutoff::%u\n", __func__, chain_cutoff);
    uint64_t on = 0, k, l, i, one = 0, ol0, wl = (asm_opt.is_ont)?(WINDOW_OHC):(WINDOW_HC), m, m0, tid, trev, max_cnt = UINT32_MAX, min_cnt = 0, is_match; ma_hit_t *oa = NULL, *p = NULL; overlap_region *aux_o = NULL, *z = NULL; Window_Pool w; double err = asm_opt.max_ov_diff_ec; tiny_queue_t tq; memset(&tq, 0, sizeof(tiny_queue_t));
    char* rs = qu->seq; uint64_t rl = qu->length; int64_t n, zn, om; uint64_t aq[2], at[2], bq[2], bt[2], ovlp, os, oe;
    int64_t max_skip, max_iter, max_dis, quick_check; double chn_pen_gap, chn_pen_skip; 
	set_lchain_dp_op(is_accurate, mz_k, &max_skip, &max_iter, &max_dis, &chn_pen_gap, &chn_pen_skip, &quick_check);
    init_Window_Pool(&w, rl, wl, (int)(1.0/err));
    
    ///cutoff
    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;
    }
    
    ///memory
    ol->length = 0; on = in0->length + in1->length + 1;
    if(on > ol->size) {
        REALLOC(ol->list, on);
        memset(ol->list+ol->size, 0, sizeof(overlap_region)*(on-ol->size));
        ol->size = on;   
    }
    aux_o = &(ol->list[on-1]); ol->mapped_overlaps_length = 0; on = in0->length + in1->length;
    
    ///overlap idx
    srt_i->n = 0;
    oa = in0->buffer; on = in0->length; m0 = 0;
    for (k = 0; k < on; k++) {
        if(oa[k].el) {
            one++; continue;
        }
        m = oa[k].tn; m <<= 1; m |= ((uint64_t)oa[k].rev); m <<= 32; m |= (k<<1); m |= m0;
        kv_push(uint64_t, *srt_i, m);
    }
    oa = in1->buffer; on = in1->length; m0 = 1;
    for (k = 0; k < on; k++) {
        // if(oa[k].el) continue;
        m = oa[k].tn; m <<= 1; m |= ((uint64_t)oa[k].rev); m <<= 32; m |= (k<<1); m |= m0;
        kv_push(uint64_t, *srt_i, m);
    }
    radix_sort_ec64(srt_i->a, srt_i->a + srt_i->n);

    // get the list of anchors
    get_mz1(rs, rl, mz_w, mz_k, 0, !(asm_opt.flag & HA_F_NO_HPC), ab, ha_flt_tab, NULL/**ha_idx**/, asm_opt.mz_sample_dist, k_flag, dbg_ct, NULL, -1, asm_opt.dp_min_len, -1, sp, asm_opt.mz_rewin, 0, NULL, 0);

    h_ec_lchain_re_gen_srt(ab, ha_idx, ol, cl);

    k = 1; l = 0; i = 0; n = zn = 0;
    while(h_ec_lchain_re_gen_qry(ab, &k, &l, &i, srt_i->a, srt_i->n, &tid, &trev)) {
        
        if(trev) recover_UC_Read_RC(tu, rref, tid);
        else recover_UC_Read(tu, rref, tid);

        ol0 = ol->length; om = 0;
        if(h_ec_lchain_re_chn(ab, l, k, rid, rs, rl, tid, tu->seq, tu->length, trev, mz_w, mz_k, ol, cl, bw_thres, apend_be, max_cnt, min_cnt, gen_off, enable_mcopy, mcopy_rate, mcopy_khit_cut, max_skip, max_iter, max_dis, quick_check, chn_pen_gap, chn_pen_skip, &tq, scb.a, &n, &zn)) {
            assert(ol->length - ol0 == 1);
            ol->list[ol0].y_pos_strand = trev; om = 1; ol->list[ol0].shared_seed = 0; ol->list[ol0].is_match = 0;
            
            assert(((srt_i->a[i]>>33) == ol->list[ol0].y_id) && (((srt_i->a[i]>>32)&1) == ol->list[ol0].y_pos_strand));
            if(srt_i->a[i]&1) {
                p = &(in1->buffer[((uint32_t)srt_i->a[i])>>1]); is_match = 2;
            } else {
                p = &(in0->buffer[((uint32_t)srt_i->a[i])>>1]); is_match = 1;
            }
            ol->list[ol0].strong = p->ml; ol->list[ol0].without_large_indel = p->no_l_indel;

            aq[0] = (uint32_t)p->qns; aq[1] = p->qe; 
            at[0] = p->ts; at[1] = p->te;

            bq[0] = ol->list[ol0].x_pos_s; bq[1] = ol->list[ol0].x_pos_e + 1;
            bt[0] = ol->list[ol0].y_pos_s; bt[1] = ol->list[ol0].y_pos_e + 1;
            
            os = MAX(aq[0], bq[0]); oe = MIN(aq[1], bq[1]);
            ovlp = ((oe>os)? (oe-os):0);
            if(!((ovlp) && (ovlp >= ((aq[1] - aq[0])*sh)) && ((ovlp >= ((bq[1] - bq[0])*sh))))) om = 0;

            os = MAX(at[0], bt[0]); oe = MIN(at[1], bt[1]);
            ovlp = ((oe>os)? (oe-os):0);
            if(!((ovlp) && (ovlp >= ((at[1] - at[0])*sh)) && ((ovlp >= ((bt[1] - bt[0])*sh))))) om = 0;

            if(om) {
                if(exact_ec_check(rs, rl, tu->seq, tu->length, bq[0], bq[1], bt[0], bt[1])) {
                    if(is_match == 2) {
                        ol->list[ol0].strong = 0; ol->list[ol0].without_large_indel = 1;
                    }
                    is_match = 1; ol->list[ol0].shared_seed = 1;
                }
                ol->list[ol0].is_match = is_match;
            } else {///unmatch
                clear_fake_cigar(&(ol->list[ol0].f_cigar));
                clear_window_list_alloc(&(ol->list[ol0].w_list));
                clear_window_list_alloc(&(ol->list[ol0].boundary_cigars));
                ol->length--;
            }
        }

        if(om) {
            srt_i->a[i] >>= 32; srt_i->a[i] <<= 32; srt_i->a[i] |= ((uint64_t)((uint32_t)-1));
        }

        l = k; k++; 
    }

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


    oa = in0->buffer; on = in0->length;
    for (k = 0; k < on; k++) {
        if(oa[k].el) {
            z = &(ol->list[ol->length++]);
            z->x_id = rid; z->y_id = oa[k].tn;
            z->x_pos_strand = 0; z->y_pos_strand = oa[k].rev;
            z->x_pos_s = (uint32_t)oa[k].qns;
            z->x_pos_e = oa[k].qe - 1;
            z->y_pos_s = oa[k].ts;
            z->y_pos_e = oa[k].te - 1;

            z->align_length = z->overlapLen = z->x_pos_e + 1 - z->x_pos_s;
            z->non_homopolymer_errors = 0;

            z->is_match = 1; z->shared_seed = 1;
            z->strong = oa[k].ml; z->without_large_indel = oa[k].no_l_indel;

            set_exact_exz(exz, z->x_pos_s, z->x_pos_e + 1, z->y_pos_s, z->y_pos_e + 1); push_alnw(z, exz);

            // if(oa[k].tn == 1945) fprintf(stderr, "-em-[M::%s]\tqn::%u\ttn::%u\terr::%u\n", __func__, rid, oa[k].tn, ol->list[ol->length-1].non_homopolymer_errors);
        }
    }
    /**
    m = ol->length;


    clear_Candidates_list(cl);
    for (k = 0; k < srt_i->n; k++) {
        ol0 = ol->length;
        if(srt_i->a[k]&1) {
            p = &(in1->buffer[((uint32_t)srt_i->a[k])>>1]);
        } else {
            p = &(in0->buffer[((uint32_t)srt_i->a[k])>>1]);
        }
        
        if(p->rev) recover_UC_Read_RC(tu, rref, p->tn);
        else recover_UC_Read(tu, rref, p->tn);

        get_pi_ec_chain(ab, rid, rl, p->tn, tu->seq, tu->length, mz_w, mz_k, ol, cl, bw_thres, apend_be, k_flag, dbg_ct, sp, high_occ, low_occ, gen_off, enable_mcopy, mcopy_rate, mcopy_khit_cut, max_skip, max_iter, max_dis, quick_check, chn_pen_gap, chn_pen_skip);
        assert(ol->length - ol0 <= 1);
        if((ol->length > ol0) && (gen_hc_r_alin_re(&(ol->list[ol0]), cl, rs, rl, tu->seq, tu->length, exz, aux_o, asm_opt.max_ov_diff_ec, w.window_length, rid, E_KHIT, 1, buf))) {
            ol->list[ol0].y_pos_strand = p->rev;
            // if(oa[k].tn == 15382) fprintf(stderr, "-mm-[M::%s]\tqn::%u\ttn::%u\terr::%u\n", __func__, rid, oa[k].tn, ol->list[ol->length-1].non_homopolymer_errors);
        } 

        if((ol->length <= ol0) || (ol->list[ol0].is_match != 1)) continue;

        if(m != ol0) {
            t = ol->list[m];
            ol->list[m] = ol->list[ol0];
            ol->list[ol0] = t;
        }

        m++;
    }
    
    ol->length = m;
    **/
    
    // fprintf(stderr, "[M::%s]\tnew_n::%lu\told_n::%lu\n", __func__, ol->length, m0);
    // fprintf(stderr, "-1-[M::%s]\tnew_n::%lu\told_n::%u\n", __func__, ol->length, in0->length + in1->length);
    assert(ol->length <= (in0->length + in1->length));


    // dbg_overlap_region_cigar(ol->list, ol->length, rs, rref, tu);

    return aux_o;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movsd %xmm2, 0xc8(%rsp)
movsd %xmm1, 0x148(%rsp)
movsd %xmm0, 0x140(%rsp)
movq %r9, %r12
movq %r8, 0x118(%rsp)
movq %rcx, %r13
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, 0xe0(%rsp)
movq 0x328(%rsp), %rbx
movq 0x320(%rsp), %r15
leaq 0x190(%rsp), %rdi
movl $0x108, %edx            # imm = 0x108
xorl %esi, %esi
callq 0x20e0
movq (%r14), %rax
movq %rax, 0xe8(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x110(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x150(%rsp), %rax
movq %rax, (%rsp)
leaq 0x178(%rsp), %rdx
leaq 0x170(%rsp), %rcx
leaq 0x168(%rsp), %r8
leaq 0x158(%rsp), %r9
movl 0x330(%rsp), %edi
movq %r12, 0x120(%rsp)
movl %r12d, %esi
callq 0x129a8a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x108(%rsp)
testq %r15, %r15
je 0x1860ea
movl (%r15), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x108(%rsp)
movq 0x2d8(%rsp), %r14
testq %rbx, %rbx
je 0x18610e
movl (%rbx), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x100(%rsp)
jmp 0x18611a
movq $0x0, 0x100(%rsp)
movl %ebp, 0xbc(%rsp)
movq 0x2f8(%rsp), %rdi
movq $0x0, 0x10(%r14)
movq 0x350(%rsp), %rax
movl 0xc(%rax), %eax
movq 0x358(%rsp), %rcx
movl 0xc(%rcx), %ecx
leal (%rax,%rcx), %ebx
incl %ebx
cmpq %rbx, 0x8(%r14)
jae 0x186192
movq (%r14), %rdi
imulq $0xa8, %rbx, %rsi
callq 0x2370
movq %rax, (%r14)
movq 0x8(%r14), %rcx
imulq $0xa8, %rcx, %rdi
addq %rax, %rdi
movq %rbx, %rax
subq %rcx, %rax
imulq $0xa8, %rax, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x2f8(%rsp), %rdi
movq %rbx, 0x8(%r14)
movq %r13, 0xc0(%rsp)
movq %rbx, 0x130(%rsp)
movq (%r14), %rax
movq %rax, 0x128(%rsp)
xorl %eax, %eax
movq %rax, 0x18(%r14)
movq %rax, (%rdi)
movq 0x350(%rsp), %rcx
movq (%rcx), %rbx
movl 0xc(%rcx), %r14d
movq %rax, 0xb0(%rsp)
testq %r14, %r14
je 0x186278
xorl %r12d, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1(%rax), %r15
leaq (%r12,%r12,4), %rax
cmpb $0x0, 0x20(%rbx,%rax,8)
jne 0x18625c
leaq (%rbx,%rax,8), %rax
movl 0xc(%rax), %r13d
movq 0x18(%rax), %rbp
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0x186237
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rdi)
movq 0x2f8(%rsp), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x2f8(%rsp), %rdi
movq %rax, 0x10(%rdi)
shlq $0x21, %r13
addq %rbp, %rbp
andq %r15, %rbp
orq %r13, %rbp
addq %r12, %r12
orq %rbp, %r12
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rdi)
movq %r12, (%rcx,%rax,8)
movq 0xb0(%rsp), %r12
incq %r12
movq %r12, 0xb0(%rsp)
cmpq %r14, %r12
jb 0x1861e2
movq 0x358(%rsp), %rax
movq (%rax), %r12
movl 0xc(%rax), %r13d
movq $0x0, 0xb0(%rsp)
testq %r13, %r13
je 0x18633e
xorl %ebp, %ebp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1(%rax), %rbx
leaq (,%rbp,4), %rax
addq %rbp, %rax
movl 0xc(%r12,%rax,8), %r14d
movq 0x18(%r12,%rax,8), %r15
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0x1862fa
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rdi)
movq 0x2f8(%rsp), %rax
movq 0x10(%rax), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x2f8(%rsp), %rdi
movq %rax, 0x10(%rdi)
shlq $0x21, %r14
addq %r15, %r15
andq %rbx, %r15
orq %r14, %r15
addq %rbp, %rbp
orq %r15, %rbp
incq %rbp
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rdi)
movq %rbp, (%rcx,%rax,8)
movq 0xb0(%rsp), %rbp
incq %rbp
movq %rbp, 0xb0(%rsp)
cmpq %r13, %rbp
jb 0x1862a7
movq (%rdi), %rax
movq %rdi, %r14
movq 0x10(%rdi), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x178fc2
leaq 0x104400(%rip), %rax    # 0x28a758
movl (%rax), %r9d
movl 0xa0(%rax), %ecx
notl %r9d
andl $0x1, %r9d
leaq 0x1050c1(%rip), %rdx    # 0x28b430
movq (%rdx), %rdx
movl 0xa8(%rax), %esi
movl 0x1f8(%rax), %eax
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rsp)
movl %ecx, 0x50(%rsp)
movq 0x318(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movl %eax, 0x40(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x30(%rsp)
movq 0x310(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x308(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %esi, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq 0xe0(%rsp), %r12
movq %r12, (%rsp)
movl $0x0, 0x58(%rsp)
movl $0xffffffff, 0x38(%rsp) # imm = 0xFFFFFFFF
movss 0xa85b2(%rip), %xmm0    # 0x22e9a0
movq 0xe8(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x118(%rsp), %rdx
movq 0x120(%rsp), %rcx
xorl %r8d, %r8d
callq 0x12e247
leaq 0x10501b(%rip), %rax    # 0x28b438
movq (%rax), %rsi
movq %r12, %rdi
movq 0x2d8(%rsp), %r15
movq %r15, %rdx
movq 0x2e0(%rsp), %rcx
callq 0x12db5f
leaq 0xb0(%rsp), %rsi
movq $0x1, (%rsi)
leaq 0xf8(%rsp), %rdx
movq %rbx, (%rdx)
leaq 0xd8(%rsp), %rcx
movq %rbx, (%rcx)
movq %rbx, 0x180(%rsp)
movq %rbx, 0x188(%rsp)
movq (%r14), %r9
movq 0x10(%r14), %r8
leaq 0xd0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
callq 0x12dd51
testq %rax, %rax
movl 0xbc(%rsp), %ebp
movq 0xc0(%rsp), %rbx
je 0x1869d5
cmpq $0x0, 0xd0(%rsp)
movq 0xf0(%rsp), %rdx
movq %rbx, %rdi
movq 0x2d0(%rsp), %rsi
je 0x1864d5
callq 0x33dc3
jmp 0x1864da
callq 0x33cf8
movq 0x10(%r15), %r14
movq 0xf8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0xf0(%rsp), %rax
movups (%rbx), %xmm0
movq 0xd0(%rsp), %rcx
movq 0x178(%rsp), %rdi
movq 0x170(%rsp), %r8
movq 0x168(%rsp), %r9
movq 0x160(%rsp), %r10
movsd 0x158(%rsp), %xmm2
movsd 0x150(%rsp), %xmm3
movq 0x10502e(%rip), %r11    # 0x28b568
movq %r11, 0x98(%rsp)
movq %r10, 0x88(%rsp)
movq %r9, 0x80(%rsp)
movq %r8, 0x78(%rsp)
movq %rdi, 0x70(%rsp)
leaq 0x180(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
leaq 0x188(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
leaq 0x190(%rsp), %rdi
movq %rdi, 0x90(%rsp)
movl 0x348(%rsp), %edi
movl %edi, 0x68(%rsp)
movq 0x340(%rsp), %rdi
movq %rdi, 0x60(%rsp)
movl 0x338(%rsp), %edi
movl %edi, 0x58(%rsp)
movq 0x100(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movq 0x108(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movl 0x300(%rsp), %edi
movl %edi, 0x40(%rsp)
movq 0x2e0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movq %r15, 0x30(%rsp)
movq 0x120(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq 0x118(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movups %xmm0, 0x8(%rsp)
movq %rax, (%rsp)
movq %r12, %rdi
movl %ebp, %ecx
movq 0xe8(%rsp), %r8
movq 0x110(%rsp), %r9
movsd 0x140(%rsp), %xmm0
movsd 0x148(%rsp), %xmm1
callq 0x12de4f
testq %rax, %rax
movq 0x2f8(%rsp), %rdx
je 0x186971
movq 0x10(%r15), %rax
subq %r14, %rax
cmpq $0x1, %rax
jne 0x186bb5
movl 0xd0(%rsp), %eax
movq (%r15), %rbx
imulq $0xa8, %r14, %r12
movl %eax, 0x1c(%rbx,%r12)
movl $0x0, 0x24(%rbx,%r12)
movb $0x0, 0x2c(%rbx,%r12)
movq 0x10(%rdx), %rbp
movq 0xd8(%rsp), %rax
movq %rax, 0x138(%rsp)
movq (%rbp,%rax,8), %r15
movq %r15, %rax
shrq $0x21, %rax
cmpl 0x10(%rbx,%r12), %eax
jne 0x186b96
leaq (%rbx,%r12), %rax
movq %r15, %r14
shrq $0x20, %r14
movl %r14d, %ecx
andl $0x1, %ecx
cmpl 0x1c(%rax), %ecx
jne 0x186b96
movl %r15d, %r13d
andl $0x1, %r13d
movl %r15d, %edx
shrl %edx
testq %r13, %r13
movq 0x358(%rsp), %rcx
cmoveq 0x350(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rdx,%rdx,4), %rsi
movl 0x18(%rcx,%rsi,8), %edx
shrl $0x1e, %edx
andb $0x1, %dl
movb %dl, 0x2e(%rbx,%r12)
movb 0x21(%rcx,%rsi,8), %dl
movb %dl, 0x2d(%rbx,%r12)
movl (%rcx,%rsi,8), %r8d
movl 0x8(%rcx,%rsi,8), %r9d
movl 0x4(%rax), %edi
movl 0x8(%rax), %edx
incl %edx
cmpq %rdi, %r8
movq %rdi, %r11
cmovaq %r8, %r11
cmpq %rdx, %r9
movq %rdx, %r10
cmovbq %r9, %r10
subq %r11, %r10
jbe 0x1867ab
jae 0x186734
xorl %r10d, %r10d
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
subq %r8, %r9
movq %r9, %xmm1
punpckldq 0x9eaf4(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x9eafc(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
jb 0x1867ab
movq %rdx, %r8
subq %rdi, %r8
movq %r8, %xmm1
punpckldq 0x9eabe(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x9eac6(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
movl $0x1, %r8d
ucomisd %xmm2, %xmm0
jae 0x1867ae
xorl %r8d, %r8d
movl 0x10(%rcx,%rsi,8), %r9d
movl 0x14(%rcx,%rsi,8), %ecx
movl 0x14(%rax), %esi
movl 0x18(%rax), %eax
incl %eax
cmpq %rsi, %r9
movq %rsi, %r11
cmovaq %r9, %r11
cmpq %rax, %rcx
movq %rax, %r10
cmovbq %rcx, %r10
subq %r11, %r10
jbe 0x18684e
jae 0x1867dd
xorl %r10d, %r10d
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
subq %r9, %rcx
movq %rcx, %xmm1
punpckldq 0x9ea4b(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x9ea53(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
jb 0x18684e
movq %rax, %rcx
subq %rsi, %rcx
movq %rcx, %xmm1
punpckldq 0x9ea15(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x9ea1d(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
jae 0x186851
xorl %r8d, %r8d
testq %r8, %r8
je 0x1868b8
incb %r13b
subq %rdi, %rdx
subq %rsi, %rax
cmpq %rax, %rdx
jne 0x186912
addq 0xe8(%rsp), %rdi
movq 0xc0(%rsp), %rax
addq (%rax), %rsi
callq 0x21a0
testl %eax, %eax
movq 0x2f8(%rsp), %rdx
jne 0x18691a
testb $0x1, %r15b
je 0x1868a5
leaq (%rbx,%r12), %rax
addq $0x2e, %rax
movb $0x0, (%rax)
movb $0x1, -0x1(%rax)
leaq (%rbx,%r12), %rax
addq $0x24, %rax
movl $0x1, (%rax)
movb $0x1, %r13b
jmp 0x18691a
leaq (%rbx,%r12), %rdi
addq $0x38, %rdi
callq 0x3db73
movq 0x2d8(%rsp), %r15
movq (%r15), %rax
leaq (%rax,%r12), %rdi
addq $0x48, %rdi
callq 0x3db7b
movq (%r15), %rax
leaq (%rax,%r12), %rdi
addq $0x78, %rdi
callq 0x3db7b
decq 0x10(%r15)
movl 0xbc(%rsp), %ebp
movq 0xc0(%rsp), %rbx
movq 0xe0(%rsp), %r12
movq 0x2f8(%rsp), %rdx
jmp 0x186971
movq 0x2f8(%rsp), %rdx
leaq (%rbx,%r12), %rax
addq $0x2c, %rax
movb %r13b, (%rax)
movq 0x138(%rsp), %rax
movq %r14, (%rbp,%rax,8)
movq 0xd8(%rsp), %rax
shlq $0x20, (%rbp,%rax,8)
movq 0xd8(%rsp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
orq %rcx, (%rbp,%rax,8)
movl 0xbc(%rsp), %ebp
movq 0x2d8(%rsp), %r15
movq 0xc0(%rsp), %rbx
movq 0xe0(%rsp), %r12
movq 0xb0(%rsp), %rax
movq %rax, 0xf8(%rsp)
incq %rax
movq %rax, 0xb0(%rsp)
movq (%rdx), %r9
movq 0x10(%rdx), %r8
leaq 0xd0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
leaq 0xb0(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
callq 0x12dd51
testq %rax, %rax
jne 0x1864b0
movq $0x0, 0xb0(%rsp)
movq 0x2f8(%rsp), %rsi
cmpq $0x0, (%rsi)
je 0x186a21
movq 0x10(%rsi), %rcx
xorl %eax, %eax
xorl %edx, %edx
movq (%rcx,%rdx,8), %rdx
cmpl $-0x1, %edx
je 0x186a07
movq %rdx, (%rcx,%rax,8)
incq %rax
movq 0xb0(%rsp), %rdx
incq %rdx
movq %rdx, 0xb0(%rsp)
cmpq (%rsi), %rdx
jb 0x1869f7
jmp 0x186a23
xorl %eax, %eax
movq %rax, (%rsi)
movq 0x350(%rsp), %rax
movq (%rax), %rbx
movl 0xc(%rax), %r14d
movq $0x0, 0xb0(%rsp)
testq %r14, %r14
je 0x186b43
movq 0x2e8(%rsp), %r15
xorl %r13d, %r13d
xorl %eax, %eax
leaq (%rax,%rax,4), %rax
cmpb $0x0, 0x20(%rbx,%rax,8)
je 0x186b27
movq 0x2d8(%rsp), %rsi
movq (%rsi), %rdi
movq 0x10(%rsi), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rsi)
imulq $0xa8, %rcx, %r9
leaq (%rdi,%r9), %r12
movl %ebp, (%rdi,%r9)
movl 0xc(%rbx,%rax,8), %ecx
movl %ecx, 0x10(%rdi,%r9)
movl %r13d, 0xc(%rdi,%r9)
movl 0x18(%rbx,%rax,8), %ecx
shrl $0x1f, %ecx
movl %ecx, 0x1c(%rdi,%r9)
movq (%rbx,%rax,8), %r10
movl %r10d, %esi
movl %r10d, 0x4(%rdi,%r9)
movl 0x8(%rbx,%rax,8), %edx
leal -0x1(%rdx), %ecx
movl %ecx, 0x8(%rdi,%r9)
movl 0x10(%rbx,%rax,8), %ecx
movl %ecx, 0x14(%rdi,%r9)
movl 0x14(%rbx,%rax,8), %r8d
leal -0x1(%r8), %r11d
movl %r11d, 0x18(%rdi,%r9)
movl %edx, %r11d
subl %r10d, %r11d
movl %r11d, 0x20(%rdi,%r9)
movl %r11d, 0x28(%rdi,%r9)
movl %r13d, 0x30(%rdi,%r9)
movb $0x1, 0x2c(%rdi,%r9)
movl $0x1, 0x24(%rdi,%r9)
movl 0x18(%rbx,%rax,8), %r10d
shrl $0x1e, %r10d
andb $0x1, %r10b
movb %r10b, 0x2e(%rdi,%r9)
movb 0x21(%rbx,%rax,8), %al
movb %al, 0x2d(%rdi,%r9)
movq %r15, %rdi
callq 0x666da
movq %r12, %rdi
movq %r15, %rsi
callq 0x65d35
movq 0xb0(%rsp), %rax
incq %rax
movq %rax, 0xb0(%rsp)
cmpq %r14, %rax
jb 0x186a57
movq 0x358(%rsp), %rax
movl 0xc(%rax), %eax
movq 0x350(%rsp), %rcx
addl 0xc(%rcx), %eax
movq 0x2d8(%rsp), %rcx
cmpq %rax, 0x10(%rcx)
ja 0x186bd4
imulq $0xa8, 0x130(%rsp), %rax
movq 0x128(%rsp), %rcx
addq %rcx, %rax
addq $-0xa8, %rax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xac370(%rip), %rdi     # 0x232f0d
leaq 0xab247(%rip), %rsi     # 0x231deb
leaq 0xac1f4(%rip), %rcx     # 0x232d9f
movl $0x133c, %edx           # imm = 0x133C
callq 0x2110
leaq 0xac068(%rip), %rdi     # 0x232c24
leaq 0xab228(%rip), %rsi     # 0x231deb
leaq 0xac1d5(%rip), %rcx     # 0x232d9f
movl $0x1339, %edx           # imm = 0x1339
callq 0x2110
leaq 0xabcea(%rip), %rdi     # 0x2328c5
leaq 0xab209(%rip), %rsi     # 0x231deb
leaq 0xac1b6(%rip), %rcx     # 0x232d9f
movl $0x13af, %edx           # imm = 0x13AF
callq 0x2110