// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/ecovlp.cpp
// Function: h_ec_lchain_re2(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*)
overlap_region* h_ec_lchain_re2(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)
{
    // 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; ma_hit_t *oa = NULL, *p = NULL; overlap_region *aux_o = NULL, *z = NULL, t; 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;
    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 = 0;
            if(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 = trev; om = 1;
            } 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->is_match = 1;
            z->align_length = z->overlapLen = z->shared_seed = z->x_pos_e + 1 - z->x_pos_s;
            z->non_homopolymer_errors = z->strong = 0;

            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 $0x288, %rsp            # imm = 0x288
movsd %xmm1, 0x88(%rsp)
movsd %xmm0, 0x80(%rsp)
movq %r9, %r15
movq %r8, 0x70(%rsp)
movq %rcx, %r12
movq %rdx, %rbx
movl %esi, 0x8(%rsp)
movq %rdi, 0x38(%rsp)
movq 0x318(%rsp), %r13
movq 0x310(%rsp), %rbp
movl 0x320(%rsp), %r14d
leaq 0x108ce2(%rip), %rax    # 0x295758
cmpq $0x0, 0x2a8(%rax)
movl $0x307, %eax            # imm = 0x307
movl $0x177, %ecx            # imm = 0x177
cmoveq %rax, %rcx
movq %rcx, 0x78(%rsp)
leaq 0xd8(%rsp), %rdi
movl $0x108, %edx            # imm = 0x108
xorl %esi, %esi
callq 0x20e0
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0xa0(%rsp), %rax
leaq 0x90(%rsp), %r10
leaq 0xb8(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0xa8(%rsp), %r8
leaq 0x98(%rsp), %r9
movl %r14d, %edi
movl %r15d, %esi
pushq %rax
pushq %r10
callq 0x12fb4d
addq $0x10, %rsp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x68(%rsp)
testq %rbp, %rbp
je 0x18cb1a
movl (%rbp), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x68(%rsp)
movq 0x2c8(%rsp), %r14
testq %r13, %r13
je 0x18cb3d
movl (%r13), %eax
cmpl $0x3, %eax
movl $0x2, %ecx
cmovael %eax, %ecx
movq %rcx, 0x60(%rsp)
jmp 0x18cb46
movq $0x0, 0x60(%rsp)
movq 0x2e8(%rsp), %r8
movq $0x0, 0x10(%r14)
movq 0x340(%rsp), %rbx
movl 0xc(%rbx), %eax
movq 0x348(%rsp), %rcx
movl 0xc(%rcx), %ecx
leal (%rax,%rcx), %r13d
incl %r13d
movq (%r14), %rdi
cmpq %r13, 0x8(%r14)
movq %r12, 0x10(%rsp)
movq %r13, 0x18(%rsp)
jae 0x18cbcd
imulq $0xa8, %r13, %rsi
callq 0x2370
movq %rax, (%r14)
movq 0x8(%r14), %rdx
imulq $0xa8, %rdx, %rdi
movq %rax, 0x20(%rsp)
addq %rax, %rdi
movq %r13, %rcx
subq %rdx, %rcx
imulq $0xa8, %rcx, %rdx
xorl %esi, %esi
callq 0x20e0
movq 0x2e8(%rsp), %r8
movq %r13, 0x8(%r14)
movl 0xc(%rbx), %eax
jmp 0x18cbd2
movq %rdi, 0x20(%rsp)
movq %r15, 0xc0(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x18(%r14)
movq %rcx, (%r8)
movq (%rbx), %rbp
movq %rcx, (%rsp)
testl %eax, %eax
je 0x18cc8d
movl %eax, %r13d
xorl %r12d, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1(%rax), %r15
leaq (%r12,%r12,4), %rax
cmpb $0x0, 0x20(%rbp,%rax,8)
jne 0x18cc7d
leaq (,%rax,8), %rax
addq %rbp, %rax
movl 0xc(%rax), %r14d
movq 0x18(%rax), %rbx
movq (%r8), %rcx
movq 0x10(%r8), %rax
cmpq 0x8(%r8), %rcx
jne 0x18cc5b
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 0x2e8(%rsp), %r8
movq %rax, 0x10(%r8)
movq (%r8), %rcx
shlq $0x21, %r14
addq %rbx, %rbx
andq %r15, %rbx
orq %r14, %rbx
addq %r12, %r12
orq %rbx, %r12
leaq 0x1(%rcx), %rdx
movq %rdx, (%r8)
movq %r12, (%rax,%rcx,8)
movq (%rsp), %r12
incq %r12
movq %r12, (%rsp)
cmpq %r13, %r12
jb 0x18cc01
imulq $0xa8, 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x348(%rsp), %rax
movq (%rax), %rbp
movl 0xc(%rax), %r12d
movq $0x0, (%rsp)
testq %r12, %r12
je 0x18cd4b
movq 0x10(%r8), %rdi
xorl %r13d, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x1(%rax), %rbx
leaq (,%r13,4), %rax
addq %r13, %rax
movl 0xc(%rbp,%rax,8), %r15d
movq 0x18(%rbp,%rax,8), %r14
movq (%r8), %rax
cmpq 0x8(%r8), %rax
jne 0x18cd18
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r8)
shlq $0x3, %rsi
callq 0x2370
movq 0x2e8(%rsp), %r8
movq %rax, %rdi
movq %rax, 0x10(%r8)
movq (%r8), %rax
shlq $0x21, %r15
addq %r14, %r14
andq %rbx, %r14
orq %r15, %r14
addq %r13, %r13
orq %r14, %r13
incq %r13
leaq 0x1(%rax), %rcx
movq %rcx, (%r8)
movq %r13, (%rdi,%rax,8)
movq (%rsp), %r13
incq %r13
movq %r13, (%rsp)
cmpq %r12, %r13
jb 0x18cccb
jmp 0x18cd4f
movq 0x10(%r8), %rdi
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
addq %rcx, %rax
addq $-0xa8, %rax
movq %rax, 0x18(%rsp)
movq (%r8), %rax
leaq (%rdi,%rax,8), %rsi
movq %r8, %r13
callq 0x17fc92
leaq 0x1089db(%rip), %rsi    # 0x295758
movl (%rsi), %r9d
movl 0xa0(%rsi), %eax
notl %r9d
andl $0x1, %r9d
leaq 0x10969c(%rip), %rcx    # 0x296430
movq (%rcx), %rcx
movl 0xa8(%rsi), %edx
movl 0x1f8(%rsi), %esi
subq $0x70, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rsp)
movl %eax, 0x50(%rsp)
movq 0x378(%rsp), %rax
movq %rax, 0x48(%rsp)
movl %esi, 0x40(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x30(%rsp)
movq 0x370(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x368(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %edx, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movq 0xa8(%rsp), %r12
movq %r12, (%rsp)
movl $0x0, 0x58(%rsp)
movl $0xffffffff, 0x38(%rsp) # imm = 0xFFFFFFFF
movss 0xadd99(%rip), %xmm0    # 0x23abb0
movq 0xa0(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0xe0(%rsp), %r14
movl %r14d, %edx
movq 0x130(%rsp), %r15
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x13444e
addq $0x70, %rsp
leaq 0x1095e8(%rip), %rax    # 0x296438
movq (%rax), %rsi
movq %r12, %rdi
movq 0x2c8(%rsp), %rdx
movq 0x2d0(%rsp), %rcx
callq 0x133d50
movq %rsp, %rsi
movq $0x1, (%rsi)
leaq 0x58(%rsp), %rdx
movq %rbx, (%rdx)
leaq 0x48(%rsp), %rcx
movq %rbx, (%rcx)
movq %rbx, 0xc8(%rsp)
movq %rbx, 0xd0(%rsp)
movq (%r13), %r9
movq 0x10(%r13), %r8
leaq 0x40(%rsp), %rax
leaq 0x50(%rsp), %r10
movq %r12, %rdi
pushq %rax
pushq %r10
callq 0x133f5a
addq $0x10, %rsp
movl 0x8(%rsp), %ecx
movq %rcx, 0x20(%rsp)
testq %rax, %rax
je 0x18d1c8
leaq 0x48(%rsp), %r13
cmpq $0x0, 0x40(%rsp)
movq 0x50(%rsp), %rdx
je 0x18cef1
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x2c0(%rsp), %rsi
callq 0x334a6
jmp 0x18cf06
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x2c0(%rsp), %rsi
callq 0x333e0
movq 0x2c8(%rsp), %r12
movq 0x10(%r12), %rbx
movq 0x58(%rsp), %rsi
movq (%rsp), %rdx
movq 0x50(%rsp), %rax
movups (%rbp), %xmm0
movq 0x40(%rsp), %rcx
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %r8
movq 0xa8(%rsp), %r9
movq 0xa0(%rsp), %r10
movsd 0x98(%rsp), %xmm2
movsd 0x90(%rsp), %xmm3
movq 0x109605(%rip), %r11    # 0x296568
subq $0xb0, %rsp
movq %r11, 0x98(%rsp)
movq %r10, 0x88(%rsp)
movq %r9, 0x80(%rsp)
movq %r8, 0x78(%rsp)
movq %rdi, 0x70(%rsp)
leaq 0x178(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
leaq 0x180(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
leaq 0x188(%rsp), %rdi
movq %rdi, 0x90(%rsp)
movl 0x3e8(%rsp), %edi
movl %edi, 0x68(%rsp)
movq 0x3e0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
movl 0x3d8(%rsp), %edi
movl %edi, 0x58(%rsp)
movq 0x110(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movq 0x118(%rsp), %rdi
movq %rdi, 0x48(%rsp)
movl 0x3a0(%rsp), %edi
movl %edi, 0x40(%rsp)
movq 0x380(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movq %r12, 0x30(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movups %xmm0, 0x8(%rsp)
movq %rax, (%rsp)
movq 0xe8(%rsp), %rdi
movl 0xb8(%rsp), %ecx
movq 0xe0(%rsp), %r8
movq 0xd8(%rsp), %r9
movsd 0x130(%rsp), %xmm0
movsd 0x138(%rsp), %xmm1
callq 0x134041
addq $0xb0, %rsp
testq %rax, %rax
movq 0x2e8(%rsp), %rsi
je 0x18d183
movq 0x10(%r12), %rax
subq %rbx, %rax
cmpq $0x1, %rax
jne 0x18d5f9
movq (%r12), %rdi
imulq $0xa8, %rbx, %rbx
movl $0x0, 0x1c(%rdi,%rbx)
addq %rbx, %rdi
movq 0x10(%rsp), %rax
movq (%rax), %r8
movq 0x8(%rax), %r9
leaq 0x1086a1(%rip), %rax    # 0x295758
movsd 0xc0(%rax), %xmm0
subq $0x8, %rsp
movq 0x2d8(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
pushq 0x2e8(%rsp)
pushq $0x1
pushq $0x1f
pushq 0x40(%rsp)
pushq 0xa0(%rsp)
pushq 0x48(%rsp)
pushq 0x310(%rsp)
callq 0x84832
addq $0x40, %rsp
testq %rax, %rax
je 0x18d143
movl 0x40(%rsp), %eax
movq (%r12), %rcx
movl %eax, 0x1c(%rcx,%rbx)
movq 0x2e8(%rsp), %rsi
movq 0x10(%rsi), %rax
movq 0x48(%rsp), %rcx
movl 0x4(%rax,%rcx,8), %edx
movq %rdx, (%rax,%rcx,8)
movq 0x48(%rsp), %rcx
shlq $0x20, (%rax,%rcx,8)
movq 0x48(%rsp), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
orq %rdx, (%rax,%rcx,8)
jmp 0x18d183
movq (%r12), %rax
leaq (%rax,%rbx), %rdi
addq $0x38, %rdi
callq 0x3d054
movq (%r12), %rax
leaq (%rax,%rbx), %rdi
addq $0x48, %rdi
callq 0x3d05c
movq (%r12), %rax
leaq (%rax,%rbx), %rdi
addq $0x78, %rdi
callq 0x3d05c
decq 0x10(%r12)
movq 0x2e8(%rsp), %rsi
movq (%rsp), %rax
movq %rax, 0x58(%rsp)
incq %rax
movq %rax, (%rsp)
movq (%rsi), %r9
movq 0x10(%rsi), %r8
movq 0x38(%rsp), %rdi
movq %rsp, %rsi
leaq 0x58(%rsp), %rdx
movq %r13, %rcx
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x58(%rsp), %rax
pushq %rax
callq 0x133f5a
addq $0x10, %rsp
testq %rax, %rax
jne 0x18cecd
movq $0x0, (%rsp)
movq 0x2e8(%rsp), %r8
movq (%r8), %rdx
testq %rdx, %rdx
je 0x18d21a
movq 0x10(%r8), %rcx
xorl %eax, %eax
xorl %esi, %esi
movq 0x10(%rsp), %r13
movq 0x2c8(%rsp), %r14
movq (%rcx,%rsi,8), %rdi
cmpl $-0x1, %edi
je 0x18d20c
movq %rdi, (%rcx,%rax,8)
incq %rax
movq (%rsp), %rsi
movq (%r8), %rdx
incq %rsi
movq %rsi, (%rsp)
cmpq %rdx, %rsi
jb 0x18d1f5
jmp 0x18d229
xorl %eax, %eax
movq 0x10(%rsp), %r13
movq 0x2c8(%rsp), %r14
movq %rax, (%r8)
movq 0x340(%rsp), %rax
movq (%rax), %r12
movl 0xc(%rax), %ebp
movq $0x0, (%rsp)
testq %rbp, %rbp
je 0x18d322
xorl %eax, %eax
leaq (%rax,%rax,4), %r8
cmpb $0x0, 0x20(%r12,%r8,8)
je 0x18d312
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%r14)
imulq $0xa8, %rcx, %rdi
leaq (%rax,%rdi), %r13
movl 0x8(%rsp), %ecx
movl %ecx, (%rax,%rdi)
movl 0xc(%r12,%r8,8), %ecx
movl %ecx, 0x10(%rax,%rdi)
xorl %r11d, %r11d
movl %r11d, 0xc(%rax,%rdi)
movl 0x18(%r12,%r8,8), %ecx
shrl $0x1f, %ecx
movl %ecx, 0x1c(%rax,%rdi)
movq (%r12,%r8,8), %r9
movl %r9d, %esi
movl %r9d, 0x4(%rax,%rdi)
movl 0x8(%r12,%r8,8), %edx
leal -0x1(%rdx), %ecx
movl %ecx, 0x8(%rax,%rdi)
movl 0x10(%r12,%r8,8), %ecx
movl %ecx, 0x14(%rax,%rdi)
movl 0x14(%r12,%r8,8), %r8d
leal -0x1(%r8), %r10d
movl %r10d, 0x18(%rax,%rdi)
movb $0x1, 0x2c(%rax,%rdi)
movl %edx, %r10d
subl %r9d, %r10d
movl %r10d, 0x24(%rax,%rdi)
movl %r10d, 0x20(%rax,%rdi)
movl %r10d, 0x28(%rax,%rdi)
movb $0x0, 0x2e(%rax,%rdi)
movl %r11d, 0x30(%rax,%rdi)
movq 0x2d8(%rsp), %rbx
movq %rbx, %rdi
callq 0x663fa
movq %r13, %rdi
movq 0x10(%rsp), %r13
movq %rbx, %rsi
callq 0x65a71
movq (%rsp), %rax
incq %rax
movq %rax, (%rsp)
cmpq %rbp, %rax
jb 0x18d24d
movq 0x10(%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x2d0(%rsp), %rdi
callq 0x3f1bd
movq $0x0, (%rsp)
movq 0x2e8(%rsp), %rcx
cmpq $0x0, (%rcx)
je 0x18d59f
xorl %eax, %eax
movq 0x10(%r14), %rbp
movq 0x10(%rcx), %rcx
movq (%rcx,%rax,8), %rax
movl %eax, %ecx
shrl %ecx
testb $0x1, %al
movq 0x348(%rsp), %rax
cmoveq 0x340(%rsp), %rax
movq (%rax), %rbx
leaq (%rcx,%rcx,4), %r14
testb $-0x80, 0x1b(%rbx,%r14,8)
movl 0xc(%rbx,%r14,8), %edx
movq %r13, %rdi
movq 0x2c0(%rsp), %rsi
jne 0x18d39d
callq 0x333e0
jmp 0x18d3a2
callq 0x334a6
leaq (%rbx,%r14,8), %r12
movl 0xc(%r12), %ecx
movq (%r13), %r8
movq 0x8(%r13), %r9
movsd 0x98(%rsp), %xmm2
movsd 0x90(%rsp), %xmm3
subq $0x8, %rsp
movq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movsd 0x88(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
pushq 0xa8(%rsp)
pushq 0xb8(%rsp)
pushq 0xc8(%rsp)
pushq 0xd8(%rsp)
movl 0x360(%rsp), %eax
pushq %rax
pushq 0x360(%rsp)
movl 0x360(%rsp), %eax
pushq %rax
pushq 0x358(%rsp)
pushq 0x358(%rsp)
pushq 0x358(%rsp)
pushq 0x358(%rsp)
pushq 0x358(%rsp)
movl 0x358(%rsp), %eax
pushq %rax
pushq 0x340(%rsp)
movq 0x340(%rsp), %r14
pushq %r14
pushq %r15
pushq 0xf8(%rsp)
callq 0x1345a7
addq $0x90, %rsp
movq 0x10(%r14), %rax
movq %rax, %rcx
subq %rbp, %rcx
cmpq $0x2, %rcx
jae 0x18d5da
cmpq %rbp, %rax
jbe 0x18d4ff
imulq $0xa8, %rbp, %rbx
movq (%r14), %rdi
addq %rbx, %rdi
movq (%r13), %r8
movq 0x8(%r13), %r9
leaq 0x1082b5(%rip), %rax    # 0x295758
movsd 0xc0(%rax), %xmm0
subq $0x8, %rsp
movq 0x2d8(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
pushq 0x2e8(%rsp)
pushq $0x1
pushq $0x1f
pushq 0x40(%rsp)
pushq 0xa0(%rsp)
pushq 0x48(%rsp)
pushq 0x310(%rsp)
callq 0x84832
addq $0x40, %rsp
testq %rax, %rax
je 0x18d4ff
movl 0x18(%r12), %eax
shrl $0x1f, %eax
movq (%r14), %rcx
movl %eax, 0x1c(%rcx,%rbx)
cmpq %rbp, 0x10(%r14)
movq 0x2e8(%rsp), %rcx
jbe 0x18d58b
movq (%r14), %r12
imulq $0xa8, %rbp, %r13
cmpb $0x1, 0x2c(%r12,%r13)
jne 0x18d586
movq 0x8(%rsp), %rax
cmpq %rbp, %rax
je 0x18d57e
imulq $0xa8, %rax, %rbp
addq %r12, %rbp
movl $0xa8, %edx
leaq 0x1e0(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2160
addq %r13, %r12
movl $0xa8, %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2160
addq (%r14), %r13
movl $0xa8, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2160
movq 0x8(%rsp), %rax
movq 0x2e8(%rsp), %rcx
incq %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %r13
movq (%rsp), %rax
incq %rax
movq %rax, (%rsp)
cmpq (%rcx), %rax
jb 0x18d354
movq 0x8(%rsp), %rdx
movq %rdx, 0x10(%r14)
movq 0x348(%rsp), %rax
movl 0xc(%rax), %eax
movq 0x340(%rsp), %rcx
addl 0xc(%rcx), %eax
cmpq %rax, %rdx
ja 0x18d618
movq 0x18(%rsp), %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb13be(%rip), %rdi     # 0x23e99f
leaq 0xb0a53(%rip), %rsi     # 0x23e03b
leaq 0xb189b(%rip), %rcx     # 0x23ee8a
movl $0x12de, %edx           # imm = 0x12DE
callq 0x2110
leaq 0xb1874(%rip), %rdi     # 0x23ee74
leaq 0xb0a34(%rip), %rsi     # 0x23e03b
leaq 0xb187c(%rip), %rcx     # 0x23ee8a
movl $0x129e, %edx           # imm = 0x129E
callq 0x2110
leaq 0xb14f6(%rip), %rdi     # 0x23eb15
leaq 0xb0a15(%rip), %rsi     # 0x23e03b
leaq 0xb185d(%rip), %rcx     # 0x23ee8a
movl $0x12f3, %edx           # imm = 0x12F3
callq 0x2110