// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: rphase_hc_back(overlap_region_alloc*, All_reads*, haplotype_evdience_alloc*, UC_Read*, UC_Read*, kv_ul_ov_t*, asg64_v*, asg64_v*, long, long, long, unsigned char, unsigned long, unsigned long, unsigned long)
void rphase_hc_back(overlap_region_alloc* ol, All_reads *rref, haplotype_evdience_alloc* hp, UC_Read* qu, UC_Read* tu, kv_ul_ov_t *c_idx, asg64_v* idx, asg64_v* buf, int64_t bd, int64_t wl, int64_t ql, uint8_t occ_thres/**, uint8_t is_dbg**/, uint64_t rid, uint64_t hpc_len, uint64_t std_bs)
{   
    int64_t on = ol->length, k, i, zwn, q[2]; 
    uint64_t m, l0, wi, wl0, si, ei, fi; overlap_region *z; ul_ov_t *cp;
    kv_resize(uint64_t, *idx, (ol->length)); 
    kv_resize(ul_ov_t, *c_idx, ol->length);

    for (k = idx->n = c_idx->n = 0; k < on; k++) {
        z = &(ol->list[k]); zwn = z->w_list.n; 
        // z->align_length = 0; z->overlapLen = (uint32_t)-1; z->non_homopolymer_errors = 0;
        if(!zwn) continue;
        for (i = 0; i < zwn; i++) {
            if(is_ualn_win(z->w_list.a[i])) continue;
            q[0] = z->w_list.a[i].x_start; q[1] = z->w_list.a[i].x_end;
            q[0] += bd; q[1] -= bd;
            if(q[1] >= q[0]) {
                m = ((uint64_t)q[0]); m <<= 32; 
                m += c_idx->n; kv_push(uint64_t, *idx, m);

                kv_pushp(ul_ov_t, *c_idx, &cp);
                ovlp_id(*cp) = k; ///ovlp id
                // ovlp_min_wid(*cp) = i; ///beg id of windows
                // ovlp_max_wid(*cp) = i; ///end id of windows
                ovlp_cur_wid(*cp) = i; ///cur id of windows
                ovlp_cur_xoff(*cp) = z->w_list.a[i].x_start; ///cur xpos
                ovlp_cur_yoff(*cp) = z->w_list.a[i].y_start; ///cur xpos
                ovlp_cur_ylen(*cp) = 0;
                ovlp_cur_coff(*cp) = 0; ///cur cigar off in cur window
                ovlp_bd(*cp) = bd;
            }
            // if(rid == 19350) {
            //     fprintf(stderr, "#########[M::%s] tid::%u\t%.*s\twid::%ld\tq::[%u, %u)\terr::%d\toerr::%u#########\n", __func__, z->y_id, (int)Get_NAME_LENGTH(R_INF, z->y_id), Get_NAME(R_INF, z->y_id),
            //             i, z->w_list.a[i].x_start, z->w_list.a[i].x_end+1, z->w_list.a[i].error, z->non_homopolymer_errors);
            // }
        }
    }

    int64_t srt_n = idx->n, s, e, t, os, oe, rm_n, rr; i = 0;
    radix_sort_bc64(idx->a, idx->a+idx->n);
    for (k = 1, i = 0; k < srt_n; k++) {
        if (k == srt_n || (idx->a[k]>>32) != (idx->a[i]>>32)) {
            if(k - i > 1) {
                for (t = i; t < k; t++) {
                    cp = &(c_idx->a[(uint32_t)idx->a[t]]);
                    // s = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_start+ovlp_bd(*cp);
                    // assert(s == (int64_t)(idx->a[i]>>32));
                    m = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_end+1-ovlp_bd(*cp);
                    m <<= 32; m += ((uint32_t)idx->a[t]); idx->a[t] = m;
                    // fprintf(stderr, "[M::%s] s::%ld\tsi::%lu\n", __func__, s, (idx->a[i]>>32));
                }
                radix_sort_bc64(idx->a + i, idx->a + k);
            }
            i = k;
        }
    }
    
    ResizeInitHaplotypeEvdience(hp);
    // if(is_dbg) fprintf(stderr, "[M::%s] ******\n", __func__);
    // fprintf(stderr, "[M::%s] ig_hpc::%lu\n", __func__, ig_hpc);
    i = 0; s = 0; e = wl; e = ((e<=ql)?e:ql); rr = 0;
    for (; s < ql; ) {
        // if(is_dbg) fprintf(stderr, "-0-[M::%s]\ts::%ld\te::%ld\n", __func__, s, e);
        if(rr) {
            // rr = 0;
            for (m = rm_n = srt_n; m < idx->n; m++) {
                cp = &(c_idx->a[idx->a[m]]);
                q[0] = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_start+ovlp_bd(*cp);
                q[1] = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_end+1-ovlp_bd(*cp);
                os = MAX(q[0], s); oe = MIN(q[1], e);
                if(oe > os) {
                    idx->a[rm_n++] = idx->a[m];
                    // if(q[1] <= e) rr = 1;
                }
            }
            idx->n = rm_n;
        }

        for (; i < srt_n; ++i) {
            cp = &(c_idx->a[(uint32_t)idx->a[i]]);
            q[0] = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_start+ovlp_bd(*cp);
            q[1] = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_end+1-ovlp_bd(*cp);
            if(q[0] >= e) break;
            os = MAX(q[0], s); oe = MIN(q[1], e);
            if(oe > os) {
                kv_push(uint64_t, *idx, ((uint32_t)idx->a[i]));
                // if(q[1] <= e) rr = 1;
            }
        }

        // fprintf(stderr, "[M::%s] s::%ld, e::%ld, srt_n::%ld, idx->n::%ld\n", __func__, s, e, srt_n, (int64_t)idx->n);
        // debug_inter(ol, c_idx, idx->a, srt_n, idx->a + srt_n, idx->n - srt_n, s, e);
        l0 = hp->length;
        // if(is_dbg) fprintf(stderr, "-1-[M::%s]\ts::%ld\te::%ld\n", __func__, s, e);
        rr = hc_phase_robust_rr(ol->list, rref, hp, qu->seq, qu->length, tu, idx->a + srt_n, idx->n - srt_n, s, e, c_idx->a, 1, occ_thres, hpc_len/**, is_dbg**/);
        /**
        for (wi = fi = ei = 0, si = ((uint64_t)-1), wl0 = e - s; wi < wl0; wi++) {
            if(hp->flag[wi] > 0) {
                if((hp->flag[wi] > occ_thres) && ((!hpc_len) || (!hpc_mask_ff(qu->seq, qu->length, wi + s, hpc_len, HPC_RR, hp->flag, e - s, s, HPC_CC)))) {
                    fi = 1; hp->nn_snp++;
                }
                ei = wi + 1; if(si == ((uint64_t)-1)) si = wi;
            }
        }
        **/
       for (wi = fi = ei = 0, si = ((uint64_t)-1), wl0 = e - s; wi < wl0; wi++) {
            if(hp->flag[wi] > 0) {
                if(hp->flag[wi] > occ_thres) {
                    fi = 1; hp->nn_snp++; hp->flag[wi] = 1;
                    if((hpc_len) && (hpc_mask_ff(qu->seq, qu->length, wi + s, hpc_len, HPC_RR, NULL, 0, 0, HPC_CC))) hp->flag[wi] = 3;
                    ei = wi + 1; if(si == ((uint64_t)-1)) si = wi;
                } else {
                    hp->flag[wi] = 0;
                }
            } 
        }

        if(fi) {
            // if(is_dbg) fprintf(stderr, "-2-[M::%s]\ts::%ld\te::%ld\n", __func__, s, e);
            rr = hc_phase_robust_rr(ol->list, rref, hp, qu->seq, qu->length, tu, idx->a + srt_n, idx->n - srt_n, s, e, c_idx->a, 0, occ_thres, hpc_len/**, is_dbg**/);
            if(hp->length > l0) radix_sort_haplotype_evdience_srt(hp->list + l0, hp->list + hp->length);
        }

        if(ei > si) memset(hp->flag + si, 0, (ei-si)*sizeof((*(hp->flag))));
        // if(is_dbg) fprintf(stderr, "-3-[M::%s]\ts::%ld\te::%ld\n", __func__, s, e);

        s += wl; e += wl; e = ((e<=ql)?e:ql);
    }

    // debug_snp_site(ol->list, rref, qu, hp->list, hp->length);


    SetSnpMatrix(hp, &(hp->nn_snp), &(ol->length), 0, NULL); 
    srt_n = hp->length; z = ((std_bs)?(ol->list):(NULL));
    for (k = 1, i = t = 0; k <= srt_n; ++k) {  
        if (k == srt_n || hp->list[k].site != hp->list[i].site) {
            t += push_info(hp, hp->list+i, k-i, hp->list+t, z, NULL, sc_wn);
            i = k;
        }
    }
    hp->length = t;

    // generate_haplotypes_naive_advance(hap, overlap_list, NULL);
    generate_haplotypes_naive_HiFi(hp, ol, 0.04, qu, ((std_bs)?(0):(1)), ((std_bs)?(0.05):(0)), ((std_bs)?(2):((uint64_t)-1)));
    // generate_haplotypes_DP(hap, overlap_list, R_INF, g_read->length, force_repeat);
    // generate_haplotypes_naive(hap, overlap_list, R_INF, g_read->length, force_repeat);

    // lable_large_indels(overlap_list, g_read->length, dumy, asm_opt.max_ov_diff_ec);
    

    // for (i = k = 0, dp = old_dp = 0, beg = 0, end = -1; i < srt_n; ++i) {///[beg, end) but coordinates in idx is [, ]
    //     ///if idx->a.a[] is qe
    //     old_dp = dp;
    //     if ((idx->a[i]>>32)&1) {
    //         --dp; end = (idx->a[i]>>33)+1;
    //     }else {
    //         //meet a new overlap; the overlaps are pushed by the x_pos_s
    //         ++dp; end = (idx->a[i]>>33);
    //         kv_push(uint64_t, *idx, ((uint32_t)idx->a[i]));
    //     }
    //     if((end > beg) && (old_dp >= 2)) {
    //         idx->n = srt_n + gen_region_phase_robust_rr(ol->list, idx->a+srt_n, idx->n-srt_n, beg, end, old_dp, c_idx->a, buf, mk);
    //     }
    //     beg = end;
    // }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, 0x88(%rsp)
movq %rcx, 0x68(%rsp)
movq %rdx, %r15
movq %rsi, 0x80(%rsp)
movq %rdi, %r13
movq 0x120(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x58(%rsp)
movb 0x108(%rsp), %al
movb %al, 0xf(%rsp)
movq 0x100(%rsp), %r12
movq 0xf8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xf0(%rsp), %rbx
movq 0xe0(%rsp), %r8
movq 0x10(%rdi), %rcx
movq %rcx, %rax
movq %rcx, 0x30(%rsp)
cmpq %rcx, 0x8(%r8)
movq %r9, 0x18(%rsp)
movq %r8, 0x20(%rsp)
jae 0x70421
movq 0x30(%rsp), %rax
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r8)
movq 0x10(%r8), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %r9
movq %rax, 0x10(%r8)
movq 0x10(%r13), %rax
cmpq %rax, 0x10(%r9)
jae 0x70487
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x10(%r9)
movq (%r9), %rdi
leaq (%rax,%rax,8), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax), %rsi
incq %rsi
callq 0x2370
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %r9
movq %rax, (%r9)
xorl %eax, %eax
movq %rax, 0x8(%r9)
movq %rax, (%r8)
cmpq $0x0, 0x30(%rsp)
movq %r15, 0x28(%rsp)
movq %r13, 0x38(%rsp)
movq %r12, 0x60(%rsp)
jle 0x7071d
movl %ebx, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, 0x40(%rsp)
xorl %edi, %edi
movq (%r13), %rax
imulq $0xa8, %rdi, %rcx
movq 0x48(%rax,%rcx), %r12
testq %r12, %r12
jle 0x70617
leaq (%rax,%rcx), %rbp
addq $0x48, %rbp
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rdi, 0x10(%rsp)
movq 0x10(%rbp), %rax
cmpw $0x7fff, 0x14(%rax,%r15) # imm = 0x7FFF
jne 0x70507
cmpl $0x0, 0x1c(%rax,%r15)
jne 0x70507
cmpw $0x0, 0x12(%rax,%r15)
js 0x70607
movslq (%rax,%r15), %r14
movslq 0x4(%rax,%r15), %rax
addq %rbx, %r14
subq %rbx, %rax
cmpq %r14, %rax
jl 0x70607
shlq $0x20, %r14
addq 0x8(%r9), %r14
movq (%r8), %rcx
movq 0x10(%r8), %rax
cmpq 0x8(%r8), %rcx
jne 0x70565
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 0x20(%rsp), %r8
movq 0x18(%rsp), %r9
movq %rax, 0x10(%r8)
movq (%r8), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r8)
movq %r14, (%rax,%rcx,8)
movq (%r9), %rax
movq 0x8(%r9), %rcx
cmpq 0x10(%r9), %rcx
jne 0x705b5
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%r9)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %r9
movq %rax, (%r9)
movq 0x8(%r9), %rcx
movq 0x10(%rsp), %rdi
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r9)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl %edi, 0xc(%rax,%rdx)
movl %r13d, (%rax,%rdx)
movq 0x10(%rbp), %rcx
movl (%rcx,%r15), %esi
movl %esi, 0x4(%rax,%rdx)
movl 0x8(%rcx,%r15), %ecx
movl %ecx, 0x10(%rax,%rdx)
xorl %ecx, %ecx
movl %ecx, 0x14(%rax,%rdx)
movl %ecx, 0x8(%rax,%rdx)
movl 0x18(%rax,%rdx), %ecx
movl $0xc0000000, %esi       # imm = 0xC0000000
andl %esi, %ecx
addl 0x40(%rsp), %ecx
movl %ecx, 0x18(%rax,%rdx)
incq %r13
addq $0x20, %r15
cmpq %r13, %r12
jne 0x704e4
incq %rdi
cmpq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r13
jne 0x704b8
movq (%r8), %rbx
movq 0x10(%r8), %rdi
leaq 0x10(%r8), %rax
movq %rax, 0x40(%rsp)
leaq (%rdi,%rbx,8), %rsi
callq 0x45373
cmpq $0x2, %rbx
movq %rbx, 0x10(%rsp)
jl 0x7073c
movq %rbx, %rdi
movl $0x1, %ebx
xorl %eax, %eax
movl $0x3fffffff, %ebp       # imm = 0x3FFFFFFF
movq 0x28(%rsp), %r15
movq 0x60(%rsp), %r12
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdx
xorq (%rcx,%rbx,8), %rdx
shrq $0x20, %rdx
jne 0x70689
movq %rax, %rdx
jmp 0x7070c
movq %rbx, %rsi
subq %rax, %rsi
movq %rbx, %rdx
cmpq $0x2, %rsi
jl 0x7070c
cmpq %rax, %rbx
jle 0x706f7
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
movq (%r13), %rsi
movq %rax, %rdi
movl (%rcx,%rdi,8), %r8d
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r8, %r9
movl (%rdx,%r9), %r8d
movl 0xc(%rdx,%r9), %r10d
imulq $0xa8, %r10, %r10
movq 0x58(%rsi,%r10), %r10
shlq $0x5, %r8
movl 0x4(%r10,%r8), %r8d
movl 0x18(%rdx,%r9), %r9d
andl %ebp, %r9d
negl %r9d
addl %r9d, %r8d
incl %r8d
movl %r8d, 0x4(%rcx,%rdi,8)
incq %rdi
cmpq %rdi, %rbx
jne 0x706ac
leaq (%rcx,%rbx,8), %rsi
leaq (%rcx,%rax,8), %rdi
callq 0x45373
movq %rbx, %rdx
movq 0x10(%rsp), %rdi
incq %rbx
movq %rdx, %rax
cmpq %rdi, %rbx
jne 0x7066b
jmp 0x70746
leaq 0x10(%r8), %rax
movq %rax, 0x40(%rsp)
movq (%rax), %rdi
movq %rdi, %rsi
callq 0x45373
movq $0x0, 0x10(%rsp)
jmp 0x70746
movq 0x28(%rsp), %r15
movq 0x60(%rsp), %r12
xorl %eax, %eax
movl %eax, 0x230(%r15)
movq %rax, 0x220(%r15)
movl %eax, 0x10(%r15)
movq %rax, 0x8(%r15)
leaq 0x18(%r15), %rbp
movl $0x1ac, %edx            # imm = 0x1AC
movq %rbp, %rdi
xorl %esi, %esi
callq 0x20e0
testq %r12, %r12
jle 0x70c48
movq 0x78(%rsp), %rax
cmpq %r12, %rax
cmovlq %rax, %r12
movq $0x0, 0x30(%rsp)
xorl %esi, %esi
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r11
testq %rsi, %rsi
je 0x7086e
movq (%r9), %rax
movq %r11, %rcx
cmpq %rax, %r11
jae 0x70857
movq 0x18(%rsp), %rcx
movq (%rcx), %rdx
movq 0x40(%rsp), %rcx
movq (%rcx), %rsi
movq 0x38(%rsp), %rcx
movq (%rcx), %rdi
movq 0x10(%rsp), %r8
movq %r8, %rcx
movq (%rsi,%r8,8), %r9
leaq (%r9,%r9,8), %r10
leaq (%r10,%r10,2), %r10
addq %r9, %r10
movl (%rdx,%r10), %r11d
movl 0xc(%rdx,%r10), %r15d
imulq $0xa8, %r15, %r15
movq 0x58(%rdi,%r15), %r15
shlq $0x5, %r11
movslq (%r15,%r11), %r13
movl 0x18(%rdx,%r10), %r10d
andl $0x3fffffff, %r10d      # imm = 0x3FFFFFFF
addq %r10, %r13
movl 0x4(%r15,%r11), %r11d
subl %r10d, %r11d
incl %r11d
movslq %r11d, %r10
cmpq %r13, %r14
cmovgq %r14, %r13
cmpq %r10, %r12
cmovlq %r12, %r10
cmpq %r13, %r10
jle 0x7084a
movq %r9, (%rsi,%rcx,8)
incq %rcx
movq 0x20(%rsp), %r9
movq (%r9), %rax
jmp 0x7084f
movq 0x20(%rsp), %r9
incq %r8
cmpq %rax, %r8
jb 0x707dd
movq %rcx, (%r9)
movq 0x28(%rsp), %r15
movq 0x38(%rsp), %r13
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r11
movq 0x40(%rsp), %rax
movq (%rax), %rax
cmpq %r11, %rbx
jge 0x70940
movq (%r10), %rdi
movl (%rax,%rbx,8), %ecx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %r8
addq %rcx, %r8
movq (%r13), %rcx
movl (%rdi,%r8), %edx
movl 0xc(%rdi,%r8), %esi
imulq $0xa8, %rsi, %rsi
movq 0x58(%rcx,%rsi), %rsi
shlq $0x5, %rdx
movslq (%rsi,%rdx), %rcx
movl 0x18(%rdi,%r8), %edi
andl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
addq %rdi, %rcx
cmpq %rcx, %r12
jle 0x70940
addq %rdx, %rsi
movl 0x4(%rsi), %edx
subl %edi, %edx
incl %edx
movslq %edx, %rdx
cmpq %rcx, %r14
cmovgq %r14, %rcx
cmpq %rdx, %r12
cmovlq %r12, %rdx
cmpq %rcx, %rdx
jle 0x70931
movq (%r9), %rcx
cmpq 0x8(%r9), %rcx
jne 0x70923
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r9)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x10(%rsp), %r11
movq 0x20(%rsp), %r9
movq 0x18(%rsp), %r10
movq %rax, 0x10(%r9)
movq (%r9), %rcx
movl (%rax,%rbx,8), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%r9)
movq %rdx, (%rax,%rcx,8)
incq %rbx
cmpq %rbx, %r11
jne 0x7087f
movq %r11, %rbx
movl 0x10(%r15), %ecx
movq %rcx, 0xa0(%rsp)
movq (%r13), %rdi
movq 0x68(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%r11,8), %rax
movq (%r9), %r8
subq %r11, %r8
movq 0x80(%rsp), %rsi
movq %r15, %rdx
movq 0x88(%rsp), %r9
pushq 0x58(%rsp)
pushq $0x0
pushq $0x1
pushq (%r10)
pushq %r12
pushq %r14
pushq %r8
pushq %rax
callq 0x6e8bf
addq $0x40, %rsp
movq %rax, %rsi
cmpq %r14, %r12
jne 0x709ac
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r11
jmp 0x70bb5
movq 0x30(%rsp), %rcx
leaq (%r12,%rcx), %rax
cmpq $0x1, %rax
movq %r12, %r15
adcq %rcx, %r15
leaq -0x1(%r15), %rax
movq %rax, 0x48(%rsp)
negq %rcx
movq %rcx, 0x98(%rsp)
movq $-0x1, %rdi
movb $0x1, %al
xorl %edx, %edx
movq 0x18(%rsp), %r10
movb 0xf(%rsp), %r8b
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r11
movq %rdx, %r13
movb (%rbp,%r13), %cl
testb %cl, %cl
je 0x70a09
cmpb %r8b, %cl
ja 0x70a16
movb $0x0, (%rbp,%r13)
incq %r13
cmpq %r13, %r15
jne 0x709f5
jmp 0x70ad5
movq 0x28(%rsp), %rax
incl 0x230(%rax)
movb $0x1, 0x18(%rax,%r13)
cmpq $0x0, 0x58(%rsp)
je 0x70aaa
movq 0x68(%rsp), %rax
movq %rdi, 0x50(%rsp)
movq (%rax), %rdi
movq %rsi, 0x90(%rsp)
movq 0x8(%rax), %rsi
movq 0x98(%rsp), %rax
leaq (%rax,%r13), %rdx
subq $0x20, %rsp
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x2, 0x10(%rsp)
movl $0x4, %r8d
movq 0x78(%rsp), %rcx
xorl %r9d, %r9d
callq 0x56a35
movq 0x70(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0x30(%rsp), %r11
movq 0x40(%rsp), %r9
movb 0x2f(%rsp), %r8b
movq 0x38(%rsp), %r10
addq $0x20, %rsp
testb %al, %al
je 0x70aaa
movb $0x3, (%rbp,%r13)
leaq 0x1(%r13), %rdx
cmpq $-0x1, %rdi
cmoveq %r13, %rdi
xorl %eax, %eax
cmpq %r13, 0x48(%rsp)
jne 0x709f2
incq %r13
movq %r13, %rdx
movq 0x28(%rsp), %r15
movq 0x38(%rsp), %r13
jmp 0x70ae7
testb $0x1, %al
movq 0x28(%rsp), %r15
movq 0x38(%rsp), %r13
jne 0x70b8c
movq %rdx, 0x48(%rsp)
movq %rdi, 0x50(%rsp)
movq (%r13), %rdi
movq 0x68(%rsp), %rax
movq (%rax), %rcx
leaq (,%r11,8), %rax
addq 0x10(%r9), %rax
movq (%r9), %r8
subq %r11, %r8
movq 0x80(%rsp), %rsi
movq %r15, %rdx
movq 0x88(%rsp), %r9
pushq 0x58(%rsp)
pushq $0x0
pushq $0x0
pushq (%r10)
pushq %r12
pushq %r14
pushq %r8
pushq %rax
callq 0x6e8bf
addq $0x40, %rsp
movq %rax, %rsi
movl 0x10(%r15), %eax
movq 0xa0(%rsp), %rdx
cmpl %edx, %eax
jbe 0x70b73
movq (%r15), %rcx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rdi
leaq (%rax,%rax,2), %rax
movq %rsi, %r15
leaq (%rcx,%rax,8), %rsi
callq 0x45630
movq %r15, %rsi
movq 0x28(%rsp), %r15
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r9
movq 0x10(%rsp), %r11
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rdx
subq %rdi, %rdx
jbe 0x70bb5
addq %rbp, %rdi
movq %rsi, %r15
xorl %esi, %esi
callq 0x20e0
movq %r15, %rsi
movq 0x28(%rsp), %r15
movq 0x10(%rsp), %r11
movq 0x20(%rsp), %r9
movq 0x18(%rsp), %r10
movq 0x78(%rsp), %rcx
addq %rcx, %r14
addq %rcx, %r12
movq 0x60(%rsp), %rax
cmpq %rax, %r12
cmovgeq %rax, %r12
subq %rcx, 0x30(%rsp)
cmpq %rax, %r14
jl 0x707a5
movl 0x230(%r15), %eax
cmpq %rax, 0x228(%r15)
jae 0x70c48
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x228(%r15)
movq 0x218(%r15), %rdi
leaq 0x8(,%rcx,8), %rax
leaq (%rax,%rax,4), %rsi
callq 0x2370
movq %rax, 0x218(%r15)
movq $0x0, 0x220(%r15)
movl 0x10(%r13), %eax
movl %eax, 0x1c8(%r15)
movl $0x0, 0x1c4(%r15)
movl 0x10(%r15), %eax
xorl %r14d, %r14d
cmpq $0x0, 0x70(%rsp)
je 0x70c7e
movq (%r13), %rbx
jmp 0x70c80
xorl %ebx, %ebx
testq %rax, %rax
je 0x70d0e
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
leaq (%rax,%rax,2), %r12
addq $-0x18, %r12
movl $0x1, %r13d
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
cmpq %rbp, %r12
je 0x70cc0
movl 0x18(%rcx,%rbp), %edx
leaq (%rax,%rax,2), %rsi
cmpl (%rcx,%rsi,8), %edx
je 0x70cf8
leaq (%rax,%rax,2), %rdx
leaq (%rcx,%rdx,8), %rsi
movq %r13, %rdx
subq %rax, %rdx
leaq (%r14,%r14,2), %rax
leaq (%rcx,%rax,8), %rcx
subq $0x8, %rsp
movq 0x30(%rsp), %rdi
movq %rbx, %r8
xorl %r9d, %r9d
pushq $0x5
callq 0x5716a
addq $0x10, %rsp
cltq
addq %rax, %r14
movq %r13, %rax
incq %r13
addq $0x18, %rbp
cmpq %rbp, %r15
jne 0x70ca6
movq 0x28(%rsp), %r15
movq 0x38(%rsp), %r13
xorl %ecx, %ecx
movl %r14d, 0x10(%r15)
xorps %xmm1, %xmm1
cmpq $0x0, 0x70(%rsp)
sete %cl
je 0x70d2a
movsd 0x1c089e(%rip), %xmm1   # 0x2315c8
movq %rcx, %r8
negq %r8
orq $0x2, %r8
movsd 0x1c08ac(%rip), %xmm0   # 0x2315e8
movq %r15, %rdi
movq %r13, %rsi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51d63