// File: /workspace/github_cpp_makefile_star2_O1/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, 0x90(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, %r14
movq %rsi, 0x88(%rsp)
movq %rdi, %r15
movq 0x120(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x118(%rsp), %rax
movq %rax, 0x30(%rsp)
movb 0x108(%rsp), %al
movb %al, 0xf(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xf0(%rsp), %rbx
movq 0xe0(%rsp), %rdi
movq 0x10(%r15), %rax
movq %rax, 0x18(%rsp)
cmpq %rax, 0x8(%rdi)
movq %r9, 0x10(%rsp)
movq %rdi, (%rsp)
jae 0x70b10
movq 0x18(%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(%rdi)
movq 0x10(%rdi), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq (%rsp), %rdi
movq 0x10(%rsp), %r9
movq %rax, 0x10(%rdi)
movq %r14, 0x28(%rsp)
movq 0x10(%r15), %rax
cmpq %rax, 0x10(%r9)
jae 0x70b7e
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 (%rsp), %rdi
movq 0x10(%rsp), %r9
movq %rax, (%r9)
xorl %eax, %eax
movq %rax, 0x8(%r9)
movq %rax, (%rdi)
cmpq $0x0, 0x18(%rsp)
movq %r15, 0x48(%rsp)
jle 0x70d1c
movl %ebx, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, 0x58(%rsp)
xorl %r8d, %r8d
movq (%r15), %rax
imulq $0xa8, %r8, %rcx
movq 0x48(%rax,%rcx), %r12
testq %r12, %r12
jle 0x70d09
leaq (%rax,%rcx), %rbp
addq $0x48, %rbp
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %r8, 0x20(%rsp)
movq 0x10(%rbp), %rax
cmpw $0x7fff, 0x14(%rax,%r15) # imm = 0x7FFF
jne 0x70bf4
cmpl $0x0, 0x1c(%rax,%r15)
jne 0x70bf4
cmpw $0x0, 0x12(%rax,%r15)
js 0x70cf9
movslq (%rax,%r15), %r13
movslq 0x4(%rax,%r15), %rax
addq %rbx, %r13
subq %rbx, %rax
cmpq %r13, %rax
jl 0x70cf9
shlq $0x20, %r13
addq 0x8(%r9), %r13
movq 0x8(%rdi), %rax
cmpq %rax, (%rdi)
jne 0x70c50
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rdi)
movq 0x10(%rdi), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x20(%rsp), %r8
movq (%rsp), %rdi
movq 0x10(%rsp), %r9
movq %rax, 0x10(%rdi)
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rdi)
movq %r13, (%rcx,%rax,8)
movq 0x10(%r9), %rax
cmpq %rax, 0x8(%r9)
jne 0x70ca4
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%r9)
movq (%r9), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq 0x20(%rsp), %r8
movq (%rsp), %rdi
movq 0x10(%rsp), %r9
movq %rax, (%r9)
movq (%r9), %rax
movq 0x8(%r9), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%r9)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl %r8d, 0xc(%rax,%rdx)
movl %r14d, (%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 0x58(%rsp), %ecx
movl %ecx, 0x18(%rax,%rdx)
incq %r14
addq $0x20, %r15
cmpq %r14, %r12
jne 0x70bd1
incq %r8
cmpq 0x18(%rsp), %r8
movq 0x48(%rsp), %r15
jne 0x70ba6
movq (%rdi), %r14
movq 0x10(%rdi), %rdi
leaq (%rdi,%r14,8), %rsi
callq 0x45d47
movq (%rsp), %rdi
cmpq $0x2, %r14
movq 0x28(%rsp), %r13
jl 0x70df5
movl $0x1, %ebx
xorl %eax, %eax
movl $0x3fffffff, %ebp       # imm = 0x3FFFFFFF
movq 0x10(%rdi), %rcx
movq (%rcx,%rax,8), %rdx
xorq (%rcx,%rbx,8), %rdx
shrq $0x20, %rdx
jne 0x70d65
movq %rax, %rdx
jmp 0x70de6
movq %rbx, %rsi
subq %rax, %rsi
movq %rbx, %rdx
cmpq $0x2, %rsi
jl 0x70de6
cmpq %rax, %rbx
jle 0x70dd2
movq 0x10(%rsp), %rdx
movq (%rdx), %rdx
movq (%r15), %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 0x70d87
leaq (%rcx,%rbx,8), %rsi
leaq (%rcx,%rax,8), %rdi
callq 0x45d47
movq %rbx, %rdx
movq (%rsp), %rdi
incq %rbx
movq %rdx, %rax
cmpq %r14, %rbx
jne 0x70d4b
xorl %eax, %eax
movl %eax, 0x230(%r13)
movq %rax, 0x220(%r13)
movl %eax, 0x10(%r13)
movq %rax, 0x8(%r13)
leaq 0x18(%r13), %rdi
movl $0x1ac, %edx            # imm = 0x1AC
movq %rdi, 0x20(%rsp)
xorl %esi, %esi
callq 0x20e0
movq (%rsp), %r9
cmpq $0x0, 0x38(%rsp)
jle 0x7122a
movq 0x38(%rsp), %rbx
movq 0x78(%rsp), %rax
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq $0x0, 0x80(%rsp)
xorl %eax, %eax
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r14, 0x40(%rsp)
testq %rax, %rax
je 0x70efe
movq %r14, %rax
cmpq (%r9), %r14
jae 0x70ef6
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%r9), %rdx
movq (%r15), %rsi
movq 0x40(%rsp), %rdi
movq %rdi, %rax
movq (%rdx,%rdi,8), %r8
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r8, %r9
movl (%rcx,%r9), %r10d
movl 0xc(%rcx,%r9), %r11d
imulq $0xa8, %r11, %r11
movq 0x58(%rsi,%r11), %r11
shlq $0x5, %r10
movslq (%r11,%r10), %r14
movl 0x18(%rcx,%r9), %r9d
andl $0x3fffffff, %r9d       # imm = 0x3FFFFFFF
addq %r9, %r14
movl 0x4(%r11,%r10), %r10d
subl %r9d, %r10d
incl %r10d
movslq %r10d, %r9
cmpq %r14, %rbp
cmovgq %rbp, %r14
cmpq %r9, %rbx
cmovlq %rbx, %r9
cmpq %r14, %r9
jle 0x70eea
movq %r8, (%rdx,%rax,8)
incq %rax
movq (%rsp), %r9
incq %rdi
cmpq (%r9), %rdi
jb 0x70e87
movq %rax, (%r9)
movq 0x40(%rsp), %r14
cmpq %r14, %r12
jge 0x70fcf
movq 0x10(%rsp), %r10
movq (%r10), %rsi
movq 0x10(%r9), %rdi
movl (%rdi,%r12,8), %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %r8
addq %rax, %r8
movq (%r15), %rax
movl (%rsi,%r8), %ecx
movl 0xc(%rsi,%r8), %edx
imulq $0xa8, %rdx, %rdx
movq 0x58(%rax,%rdx), %rdx
shlq $0x5, %rcx
movslq (%rdx,%rcx), %rax
movl 0x18(%rsi,%r8), %esi
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
addq %rsi, %rax
cmpq %rax, %rbx
jle 0x70fd4
addq %rcx, %rdx
movl 0x4(%rdx), %ecx
subl %esi, %ecx
incl %ecx
movslq %ecx, %rcx
cmpq %rax, %rbp
cmovgq %rbp, %rax
cmpq %rcx, %rbx
cmovlq %rbx, %rcx
cmpq %rax, %rcx
jle 0x70fbe
movq 0x8(%r9), %rax
cmpq %rax, (%r9)
jne 0x70fa8
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r9)
shlq $0x3, %rsi
callq 0x2370
movq (%rsp), %r9
movq 0x10(%rsp), %r10
movq %rax, 0x10(%r9)
movq (%r9), %rax
movq 0x10(%r9), %rcx
movl (%rcx,%r12,8), %edx
leaq 0x1(%rax), %rsi
movq %rsi, (%r9)
movq %rdx, (%rcx,%rax,8)
incq %r12
cmpq %r12, %r14
jne 0x70f0c
movq %r14, %r12
jmp 0x70fd4
movq 0x10(%rsp), %r10
movl 0x10(%r13), %eax
movq %rax, 0xa0(%rsp)
movq (%r15), %rdi
movq 0x50(%rsp), %rax
movq (%rax), %rcx
leaq (,%r14,8), %rdx
movq 0x10(%r9), %rax
movq %rdx, 0x98(%rsp)
addq %rdx, %rax
movq (%r9), %r8
subq %r14, %r8
movq 0x88(%rsp), %rsi
movq %r13, %rdx
movq 0x90(%rsp), %r9
pushq 0x30(%rsp)
pushq $0x0
pushq $0x1
pushq (%r10)
pushq %rbx
pushq %rbp
pushq %r8
pushq %rax
callq 0x6eeed
addq $0x40, %rsp
movq %rax, 0x18(%rsp)
cmpq %rbp, %rbx
jne 0x71057
movb $0x1, %al
movq $-0x1, %rdi
xorl %edx, %edx
movq 0x10(%rsp), %r8
movq (%rsp), %r9
jmp 0x71151
movq 0x80(%rsp), %rcx
leaq (%rbx,%rcx), %rax
cmpq $0x1, %rax
movq %rbx, %r15
adcq %rcx, %r15
movq $-0x1, %rdi
xorl %eax, %eax
xorl %edx, %edx
xorl %r14d, %r14d
movq 0x10(%rsp), %r8
movq (%rsp), %r9
movq 0x20(%rsp), %rsi
movq %rbx, 0x58(%rsp)
movb (%rsi,%r14), %cl
testb %cl, %cl
je 0x71135
cmpb 0xf(%rsp), %cl
jbe 0x71130
incl 0x230(%r13)
movb $0x1, 0x18(%r13,%r14)
cmpq $0x0, 0x30(%rsp)
je 0x7111d
movq 0x50(%rsp), %rax
movq %r13, %rbx
movq %rdi, %r13
movq (%rax), %rdi
movq 0x8(%rax), %rsi
leaq (%r14,%rbp), %rdx
subq $0x20, %rsp
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x2, 0x10(%rsp)
movl $0x4, %r8d
movq 0x50(%rsp), %rcx
xorl %r9d, %r9d
callq 0x575c6
movq %r13, %rdi
movq %rbx, %r13
movq 0x78(%rsp), %rbx
movq 0x40(%rsp), %rsi
movq 0x20(%rsp), %r9
movq 0x30(%rsp), %r8
addq $0x20, %rsp
testb %al, %al
je 0x7111d
movb $0x3, (%rsi,%r14)
leaq 0x1(%r14), %rdx
cmpq $-0x1, %rdi
cmoveq %r14, %rdi
movl $0x1, %eax
jmp 0x71135
movb $0x0, (%rsi,%r14)
incq %r14
cmpq %r14, %r15
jne 0x7108e
testq %rax, %rax
sete %al
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %r14
testb %al, %al
jne 0x711e8
movq %rdx, 0x68(%rsp)
movq %rdi, 0x70(%rsp)
movq (%r15), %rdi
movq 0x50(%rsp), %rax
movq (%rax), %rcx
movq 0x98(%rsp), %r10
addq 0x10(%r9), %r10
movq (%r9), %rax
subq %r14, %rax
movq 0x88(%rsp), %rsi
movq %r13, %rdx
movq 0x90(%rsp), %r9
pushq 0x30(%rsp)
pushq $0x0
pushq $0x0
pushq (%r8)
pushq %rbx
pushq %rbp
pushq %rax
pushq %r10
callq 0x6eeed
addq $0x40, %rsp
movq %rax, 0x18(%rsp)
movl 0x10(%r13), %eax
movq 0xa0(%rsp), %rdx
cmpl %edx, %eax
jbe 0x711da
movq (%r13), %rcx
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rdi
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rsi
callq 0x46007
movq (%rsp), %r9
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rdx
subq %rdi, %rdx
jbe 0x711fd
addq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
movq (%rsp), %r9
movq 0x78(%rsp), %rcx
addq %rcx, %rbp
addq %rcx, %rbx
movq 0x38(%rsp), %rax
cmpq %rax, %rbx
cmovgeq %rax, %rbx
subq %rcx, 0x80(%rsp)
cmpq %rax, %rbp
movq 0x18(%rsp), %rax
jl 0x70e5b
movl 0x230(%r13), %eax
cmpq %rax, 0x228(%r13)
jae 0x71298
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(%r13)
movq 0x218(%r13), %rdi
leaq 0x8(,%rcx,8), %rax
leaq (%rax,%rax,4), %rsi
callq 0x2370
movq %rax, 0x218(%r13)
movq $0x0, 0x220(%r13)
movl 0x10(%r15), %eax
movl %eax, 0x1c8(%r13)
movl $0x0, 0x1c4(%r13)
movl 0x10(%r13), %eax
xorl %ebx, %ebx
cmpq $0x0, 0x60(%rsp)
je 0x712cc
movq (%r15), %r14
jmp 0x712cf
xorl %r14d, %r14d
testq %rax, %rax
je 0x7135f
shlq $0x3, %rax
leaq (%rax,%rax,2), %r15
leaq (%rax,%rax,2), %r12
addq $-0x18, %r12
movl $0x1, %r13d
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %eax, %eax
cmpq %rbp, %r12
je 0x7130e
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
movl 0x18(%rcx,%rbp), %edx
leaq (%rax,%rax,2), %rsi
cmpl (%rcx,%rsi,8), %edx
je 0x71349
movq 0x28(%rsp), %rdi
movq (%rdi), %rcx
leaq (%rax,%rax,2), %rdx
leaq (%rcx,%rdx,8), %rsi
movq %r13, %rdx
subq %rax, %rdx
leaq (%rbx,%rbx,2), %rax
leaq (%rcx,%rax,8), %rcx
subq $0x8, %rsp
movq %r14, %r8
xorl %r9d, %r9d
pushq $0x5
callq 0x57d10
addq $0x10, %rsp
cltq
addq %rax, %rbx
movq %r13, %rax
incq %r13
addq $0x18, %rbp
cmpq %rbp, %r15
jne 0x712f4
movq 0x28(%rsp), %r13
movq 0x48(%rsp), %r15
xorl %ecx, %ecx
movl %ebx, 0x10(%r13)
xorps %xmm1, %xmm1
cmpq $0x0, 0x60(%rsp)
sete %cl
je 0x7137b
movsd 0x1b414d(%rip), %xmm1   # 0x2254c8
movq %rcx, %r8
negq %r8
orq $0x2, %r8
movsd 0x1b415b(%rip), %xmm0   # 0x2254e8
movq %r13, %rdi
movq %r15, %rsi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52bf1