// File: /workspace/github_cpp_makefile_star2_O3/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, 0x128(%rsp)
movq %rcx, 0xc0(%rsp)
movq %rdx, %r14
movl %esi, 0xbc(%rsp)
movq %rdi, 0xe0(%rsp)
movq 0x328(%rsp), %rbx
movq 0x320(%rsp), %r15
movl 0x330(%rsp), %ebp
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, 0x120(%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 %ebp, %edi
movq %r12, 0x130(%rsp)
movl %r12d, %esi
callq 0x12fb4d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x118(%rsp)
testq %r15, %r15
je 0x18d73d
movl (%r15), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x118(%rsp)
movq 0x350(%rsp), %rcx
movq 0x2d8(%rsp), %r14
testq %rbx, %rbx
je 0x18d769
movl (%rbx), %eax
cmpl $0x3, %eax
movl $0x2, %edx
cmovael %eax, %edx
movq %rdx, 0x110(%rsp)
jmp 0x18d775
movq $0x0, 0x110(%rsp)
movq 0x2f8(%rsp), %r8
movq $0x0, 0x10(%r14)
movl 0xc(%rcx), %eax
movq %rcx, %rbx
movq 0x358(%rsp), %rcx
movl 0xc(%rcx), %ecx
leal (%rax,%rcx), %r15d
incl %r15d
movq (%r14), %rdi
cmpq %r15, 0x8(%r14)
movq %r15, 0x138(%rsp)
jae 0x18d7f8
imulq $0xa8, %r15, %rsi
callq 0x2370
movq %rax, (%r14)
movq 0x8(%r14), %rdx
imulq $0xa8, %rdx, %rdi
movq %rax, 0x100(%rsp)
addq %rax, %rdi
movq %r15, %rcx
subq %rdx, %rcx
imulq $0xa8, %rcx, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x2f8(%rsp), %r8
movq %r15, 0x8(%r14)
movl 0xc(%rbx), %eax
jmp 0x18d800
movq %rdi, 0x100(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x18(%r14)
movq %rcx, (%r8)
movq (%rbx), %rbx
movq %rcx, 0xb0(%rsp)
testl %eax, %eax
je 0x18d8b8
movl %eax, %r14d
xorl %r15d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1(%rax), %r12
leaq (%r15,%r15,4), %rax
cmpb $0x0, 0x20(%rbx,%rax,8)
jne 0x18d8a4
leaq (%rbx,%rax,8), %rax
movl 0xc(%rax), %r13d
movq 0x18(%rax), %rbp
movq (%r8), %rcx
movq 0x10(%r8), %rax
cmpq 0x8(%r8), %rcx
jne 0x18d87e
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r8)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x2f8(%rsp), %r8
movq %rax, 0x10(%r8)
movq (%r8), %rcx
shlq $0x21, %r13
addq %rbp, %rbp
andq %r12, %rbp
orq %r13, %rbp
addq %r15, %r15
orq %rbp, %r15
leaq 0x1(%rcx), %rdx
movq %rdx, (%r8)
movq %r15, (%rax,%rcx,8)
movq 0xb0(%rsp), %r15
incq %r15
movq %r15, 0xb0(%rsp)
cmpq %r14, %r15
jb 0x18d82b
movq 0x358(%rsp), %rax
movq (%rax), %r12
movl 0xc(%rax), %r13d
movq $0x0, 0xb0(%rsp)
testq %r13, %r13
je 0x18d977
movq 0x10(%r8), %rdi
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 (%r8), %rax
cmpq 0x8(%r8), %rax
jne 0x18d938
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r8)
shlq $0x3, %rsi
callq 0x2370
movq 0x2f8(%rsp), %r8
movq %rax, %rdi
movq %rax, 0x10(%r8)
movq (%r8), %rax
shlq $0x21, %r14
addq %r15, %r15
andq %rbx, %r15
orq %r14, %r15
addq %rbp, %rbp
orq %r15, %rbp
incq %rbp
leaq 0x1(%rax), %rcx
movq %rcx, (%r8)
movq %rbp, (%rdi,%rax,8)
movq 0xb0(%rsp), %rbp
incq %rbp
movq %rbp, 0xb0(%rsp)
cmpq %r13, %rbp
jb 0x18d8eb
jmp 0x18d97b
movq 0x10(%r8), %rdi
movq (%r8), %rax
leaq (%rdi,%rax,8), %rsi
movq %r8, %r14
callq 0x17fc92
leaq 0x107dc7(%rip), %rax    # 0x295758
movl (%rax), %r9d
movl 0xa0(%rax), %ecx
notl %r9d
andl $0x1, %r9d
leaq 0x108a88(%rip), %rdx    # 0x296430
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), %r15
movq %r15, (%rsp)
movl $0x0, 0x58(%rsp)
movl $0xffffffff, 0x38(%rsp) # imm = 0xFFFFFFFF
movss 0xad189(%rip), %xmm0    # 0x23abb0
movq 0xe8(%rsp), %rdi
movq 0x120(%rsp), %rsi
movq 0x128(%rsp), %rdx
movq 0x130(%rsp), %rcx
xorl %r8d, %r8d
callq 0x13444e
leaq 0x1089e2(%rip), %rax    # 0x296438
movq (%rax), %rsi
movq %r15, %rdi
movq 0x2d8(%rsp), %rbp
movq %rbp, %rdx
movq 0x2e0(%rsp), %rcx
callq 0x133d50
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 %r15, %rdi
callq 0x133f5a
testq %rax, %rax
movq 0xc0(%rsp), %rbx
je 0x18e00d
cmpq $0x0, 0xd0(%rsp)
movq 0xf0(%rsp), %rdx
movq %rbx, %rdi
movq 0x2d0(%rsp), %rsi
je 0x18db07
callq 0x334a6
jmp 0x18db0c
callq 0x333e0
movq 0x10(%rbp), %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 0x1089fc(%rip), %r11    # 0x296568
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 0x110(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movq 0x118(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movl 0x300(%rsp), %edi
movl %edi, 0x40(%rsp)
movq 0x2e0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movq %rbp, 0x30(%rsp)
movq 0x130(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq 0x128(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movups %xmm0, 0x8(%rsp)
movq %rax, (%rsp)
movq %r15, %rdi
movl 0xbc(%rsp), %ecx
movq 0xe8(%rsp), %r8
movq 0x120(%rsp), %r9
movsd 0x140(%rsp), %xmm0
movsd 0x148(%rsp), %xmm1
callq 0x134041
testq %rax, %rax
movq 0x2f8(%rsp), %rdx
je 0x18dee3
movq 0x10(%rbp), %rax
subq %r14, %rax
cmpq $0x1, %rax
jne 0x18e1ed
movq 0xd0(%rsp), %rax
movq (%rbp), %rbx
imulq $0xa8, %r14, %r13
movl %eax, 0x1c(%rbx,%r13)
movl $0x0, 0x24(%rbx,%r13)
movb $0x0, 0x2c(%rbx,%r13)
movq 0x10(%rdx), %rbp
movq 0xd8(%rsp), %rcx
movq %rcx, 0x108(%rsp)
movq (%rbp,%rcx,8), %r12
movq %r12, %rcx
shrq $0x21, %rcx
cmpl 0x10(%rbx,%r13), %ecx
jne 0x18e1ce
movl %eax, %eax
movq %r12, %r14
shrq $0x20, %r14
movl %r14d, %ecx
andl $0x1, %ecx
cmpl %eax, %ecx
jne 0x18e1ce
movl %r12d, %r15d
andl $0x1, %r15d
movl %r12d, %edx
shrl %edx
testq %r15, %r15
movq 0x358(%rsp), %rcx
cmoveq 0x350(%rsp), %rcx
leaq (%rbx,%r13), %rax
movq (%rcx), %rcx
leaq (%rdx,%rdx,4), %rsi
movl 0x18(%rcx,%rsi,8), %edx
shrl $0x1e, %edx
andb $0x1, %dl
movb %dl, 0x2e(%rbx,%r13)
movb 0x21(%rcx,%rsi,8), %dl
movb %dl, 0x2d(%rbx,%r13)
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 0x18dde3
jae 0x18dd6e
xorl %r10d, %r10d
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
subq %r8, %r9
movq %r9, %xmm1
punpckldq 0xa34fa(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa3502(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
jb 0x18dde3
movq %rdx, %r8
subq %rdi, %r8
movq %r8, %xmm1
punpckldq 0xa34c4(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa34cc(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
jae 0x18df4c
movb $0x1, %r8b
incb %r15b
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 0x18de90
jae 0x18de18
xorl %r10d, %r10d
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
subq %r9, %rcx
movq %rcx, %xmm1
punpckldq 0xa3450(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa3458(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
jb 0x18de90
subq %rsi, %rax
movq %rax, %xmm1
punpckldq 0xa341d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa3425(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd 0xc8(%rsp), %xmm2
ucomisd %xmm2, %xmm0
setb %cl
orb %r8b, %cl
je 0x18df54
leaq (%rbx,%r13), %rdi
addq $0x38, %rdi
callq 0x3d054
movq 0x2d8(%rsp), %rbp
movq (%rbp), %rax
leaq (%rax,%r13), %rdi
addq $0x48, %rdi
callq 0x3d05c
movq (%rbp), %rax
leaq (%rax,%r13), %rdi
addq $0x78, %rdi
callq 0x3d05c
decq 0x10(%rbp)
movq 0xc0(%rsp), %rbx
movq 0xe0(%rsp), %r15
movq 0x2f8(%rsp), %rdx
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 %r15, %rdi
leaq 0xb0(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
callq 0x133f5a
testq %rax, %rax
jne 0x18dae2
jmp 0x18e00d
xorl %r8d, %r8d
jmp 0x18dde6
subq %rdi, %rdx
cmpq %rax, %rdx
jne 0x18dfb0
addq 0xe8(%rsp), %rdi
movq 0xc0(%rsp), %rax
addq (%rax), %rsi
callq 0x21a0
testl %eax, %eax
movq 0x2f8(%rsp), %rdx
movq 0x108(%rsp), %rcx
jne 0x18dfc0
testb $0x1, %r12b
je 0x18df9d
leaq (%rbx,%r13), %rax
addq $0x2e, %rax
movb $0x0, (%rax)
movb $0x1, -0x1(%rax)
leaq (%rbx,%r13), %rax
addq $0x24, %rax
movl $0x1, (%rax)
movb $0x1, %r15b
jmp 0x18dfc0
movq 0x2f8(%rsp), %rdx
movq 0x108(%rsp), %rcx
leaq (%rbx,%r13), %rax
addq $0x2c, %rax
movb %r15b, (%rax)
movq %r14, (%rbp,%rcx,8)
movq 0xd8(%rsp), %rax
shlq $0x20, (%rbp,%rax,8)
movq 0xd8(%rsp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
orq %rcx, (%rbp,%rax,8)
movq 0x2d8(%rsp), %rbp
movq 0xc0(%rsp), %rbx
movq 0xe0(%rsp), %r15
jmp 0x18dee3
movq $0x0, 0xb0(%rsp)
movq 0x2f8(%rsp), %r9
movq (%r9), %rsi
xorl %eax, %eax
testq %rsi, %rsi
je 0x18e061
movq 0x10(%r9), %rdx
xorl %ecx, %ecx
xorl %edi, %edi
movq (%rdx,%rdi,8), %r8
cmpl $-0x1, %r8d
je 0x18e04f
movq %r8, (%rdx,%rcx,8)
incq %rcx
movq 0xb0(%rsp), %rdi
movq (%r9), %rsi
incq %rdi
movq %rdi, 0xb0(%rsp)
cmpq %rsi, %rdi
jb 0x18e033
jmp 0x18e063
xorl %ecx, %ecx
movq %rcx, (%r9)
movq 0x350(%rsp), %rcx
movq (%rcx), %rbx
movl 0xc(%rcx), %r14d
movq $0x0, 0xb0(%rsp)
testq %r14, %r14
je 0x18e18e
movq 0x2e8(%rsp), %r15
xorl %r13d, %r13d
xorl %ecx, %ecx
leaq (%rcx,%rcx,4), %rax
cmpb $0x0, 0x20(%rbx,%rax,8)
je 0x18e16f
movq (%rbp), %rdi
movq 0x10(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rbp)
imulq $0xa8, %rcx, %r9
leaq (%rdi,%r9), %r12
movl 0xbc(%rsp), %ecx
movl %ecx, (%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 0x663fa
movq %r12, %rdi
movq %r15, %rsi
callq 0x65a71
movq 0xb0(%rsp), %rcx
incq %rcx
movq %rcx, 0xb0(%rsp)
cmpq %r14, %rcx
jb 0x18e097
movq 0x350(%rsp), %rax
movl 0xc(%rax), %eax
movq 0x358(%rsp), %rcx
addl 0xc(%rcx), %eax
cmpq %rax, 0x10(%rbp)
ja 0x18e20c
imulq $0xa8, 0x138(%rsp), %rax
movq 0x100(%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 0xb0f88(%rip), %rdi     # 0x23f15d
leaq 0xafe5f(%rip), %rsi     # 0x23e03b
leaq 0xb0e0c(%rip), %rcx     # 0x23efef
movl $0x133c, %edx           # imm = 0x133C
callq 0x2110
leaq 0xb0c80(%rip), %rdi     # 0x23ee74
leaq 0xafe40(%rip), %rsi     # 0x23e03b
leaq 0xb0ded(%rip), %rcx     # 0x23efef
movl $0x1339, %edx           # imm = 0x1339
callq 0x2110
leaq 0xb0902(%rip), %rdi     # 0x23eb15
leaq 0xafe21(%rip), %rsi     # 0x23e03b
leaq 0xb0dce(%rip), %rcx     # 0x23efef
movl $0x13af, %edx           # imm = 0x13AF
callq 0x2110