// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movq %r9, %rbx
movq %r8, 0x78(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, 0x70(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x38(%rsp)
movb 0xf8(%rsp), %al
movb %al, 0x7(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xd0(%rsp), %r12
leaq 0x10(%rdi), %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x10(%rdi), %rcx
movq %rcx, %rax
movq %rcx, %r14
cmpq %rcx, 0x8(%r12)
jae 0x3ed4f
leaq -0x1(%r14), %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(%r12)
movq 0x10(%r12), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0x10(%r12)
movq 0x50(%rsp), %rax
movq (%rax), %rax
cmpq %rax, 0x10(%rbx)
jae 0x3ed9f
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
incq %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
imulq $0x1c, %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq %rbx, 0x30(%rsp)
andq $0x0, 0x8(%rbx)
andq $0x0, (%r12)
movq 0x20(%rsp), %rdi
movl %edi, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, 0x48(%rsp)
xorl %eax, %eax
testq %r14, %r14
cmovleq %rax, %r14
movq %r14, 0x18(%rsp)
xorl %r8d, %r8d
cmpq 0x18(%rsp), %r8
je 0x3ef41
movq 0x10(%rsp), %rax
movq (%rax), %rax
imulq $0xa8, %r8, %rcx
movq 0x48(%rax,%rcx), %r13
testq %r13, %r13
je 0x3ef39
leaq 0x48(%rax,%rcx), %rbp
movl $0x0, %eax
cmovleq %rax, %r13
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r8, 0x28(%rsp)
cmpq %r15, %r13
je 0x3ef39
movq 0x10(%rbp), %rax
cmpw $0x7fff, 0x14(%rax,%r14) # imm = 0x7FFF
jne 0x3ee3c
cmpl $0x0, 0x1c(%rax,%r14)
jne 0x3ee3c
cmpw $0x0, 0x12(%rax,%r14)
js 0x3ef2d
movslq (%rax,%r14), %rbx
movslq 0x4(%rax,%r14), %rax
addq %rdi, %rbx
subq %rdi, %rax
cmpq %rbx, %rax
jl 0x3ef2d
shlq $0x20, %rbx
movq 0x30(%rsp), %rax
addq 0x8(%rax), %rbx
movq (%r12), %rcx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rcx
jne 0x3ee99
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%r12)
movq (%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
movq %rbx, (%rax,%rcx,8)
movq 0x30(%rsp), %rbx
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x3eedc
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbx)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %r8
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
imulq $0x1c, %rcx, %rcx
movl %r8d, 0xc(%rax,%rcx)
movl %r15d, (%rax,%rcx)
movq 0x10(%rbp), %rdx
movl (%rdx,%r14), %esi
movl %esi, 0x4(%rax,%rcx)
movl 0x8(%rdx,%r14), %edx
movl %edx, 0x10(%rax,%rcx)
andl $0x0, 0x14(%rax,%rcx)
andl $0x0, 0x8(%rax,%rcx)
movl 0x18(%rax,%rcx), %edx
movl $0xc0000000, %esi       # imm = 0xC0000000
andl %esi, %edx
addl 0x48(%rsp), %edx
movl %edx, 0x18(%rax,%rcx)
incq %r15
addq $0x20, %r14
jmp 0x3ee10
incq %r8
jmp 0x3edcf
movq (%r12), %rax
movq 0x10(%r12), %rdi
movq %rax, 0x28(%rsp)
leaq (%rdi,%rax,8), %rsi
callq 0x1905d
pushq $0x1
popq %rbx
xorl %eax, %eax
movl $0x3fffffff, %ebp       # imm = 0x3FFFFFFF
movq 0x8(%rsp), %rdi
cmpq 0x28(%rsp), %rbx
jge 0x3f00b
movq 0x10(%r12), %rcx
movq (%rcx,%rax,8), %rdx
xorq (%rcx,%rbx,8), %rdx
shrq $0x20, %rdx
jne 0x3ef8a
movq %rax, %rdx
jmp 0x3f000
movq %rbx, %rsi
subq %rax, %rsi
movq %rbx, %rdx
cmpq $0x2, %rsi
jl 0x3f000
leaq (%rcx,%rbx,8), %rsi
leaq (%rcx,%rax,8), %rdi
cmpq %rbx, %rax
jge 0x3eff3
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
movl (%rcx,%rax,8), %r8d
imulq $0x1c, %r8, %r8
movq 0x10(%rsp), %r9
movq (%r9), %r9
movl (%rdx,%r8), %r10d
movl 0xc(%rdx,%r8), %r11d
imulq $0xa8, %r11, %r11
movq 0x58(%r9,%r11), %r9
shlq $0x5, %r10
movl 0x4(%r9,%r10), %r9d
movl 0x18(%rdx,%r8), %edx
andl %ebp, %edx
negl %edx
addl %r9d, %edx
incl %edx
movl %edx, 0x4(%rcx,%rax,8)
incq %rax
jmp 0x3efa1
callq 0x1905d
movq %rbx, %rdx
movq 0x8(%rsp), %rdi
incq %rbx
movq %rdx, %rax
jmp 0x3ef67
andl $0x0, 0x230(%rdi)
andq $0x0, 0x220(%rdi)
leaq 0x230(%rdi), %rax
movq %rax, 0x80(%rsp)
andl $0x0, 0x10(%rdi)
andq $0x0, 0x8(%rdi)
addq $0x18, %rdi
movq $0x0, 0x20(%rsp)
movl $0x1ac, %edx            # imm = 0x1AC
movq %rdi, 0x88(%rsp)
xorl %esi, %esi
callq 0x20e0
movq 0x68(%rsp), %rax
movq 0x60(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, %r14
cmovlq %rcx, %r14
xorl %r11d, %r11d
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq %rax, %r13
movq 0x30(%rsp), %rbx
movq 0x28(%rsp), %rbp
jge 0x3f3a6
testq %r15, %r15
je 0x3f112
movq %rbp, %rcx
movq %rbp, %rax
cmpq (%r12), %rcx
jae 0x3f10e
movq %r11, %r15
movq (%rbx), %rdi
movq 0x10(%r12), %rdx
movq (%rdx,%rcx,8), %rsi
imulq $0x1c, %rsi, %r8
movq 0x10(%rsp), %r9
movq (%r9), %r9
movl (%rdi,%r8), %r10d
movl 0xc(%rdi,%r8), %r11d
imulq $0xa8, %r11, %r11
movq 0x58(%r9,%r11), %r9
shlq $0x5, %r10
movslq (%r9,%r10), %r11
movl 0x18(%rdi,%r8), %edi
andl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
addq %rdi, %r11
movl 0x4(%r9,%r10), %r8d
subl %edi, %r8d
incl %r8d
movslq %r8d, %rdi
cmpq %r11, %r13
cmovgq %r13, %r11
cmpq %rdi, %r14
cmovlq %r14, %rdi
cmpq %r11, %rdi
jle 0x3f106
movq %rsi, (%rdx,%rax,8)
incq %rax
incq %rcx
movq %r15, %r11
jmp 0x3f092
movq %rax, (%r12)
movq 0x10(%r12), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rdi
movq (%rbx), %r8
cmpq %rbp, %r11
jge 0x3f1d7
movl (%rax,%r11,8), %ecx
imulq $0x1c, %rcx, %r10
movl (%r8,%r10), %esi
movl 0xc(%r8,%r10), %edx
imulq $0xa8, %rdx, %rdx
movq 0x58(%rdi,%rdx), %r9
shlq $0x5, %rsi
movslq (%r9,%rsi), %rdx
movl 0x18(%r8,%r10), %r10d
andl $0x3fffffff, %r10d      # imm = 0x3FFFFFFF
addq %r10, %rdx
cmpq %rdx, %r14
jle 0x3f1d7
addq %rsi, %r9
movl 0x4(%r9), %esi
subl %r10d, %esi
incl %esi
movslq %esi, %rsi
cmpq %rdx, %r13
cmovgq %r13, %rdx
cmpq %rsi, %r14
cmovlq %r14, %rsi
cmpq %rdx, %rsi
jle 0x3f1cf
movq (%r12), %rdx
cmpq 0x8(%r12), %rdx
jne 0x3f1c3
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
movq %r11, %r15
callq 0x2370
movq %r15, %r11
movq %rax, 0x10(%r12)
movl (%rax,%r15,8), %ecx
movq (%r12), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%r12)
movq %rcx, (%rax,%rdx,8)
incq %r11
jmp 0x3f117
movq %r11, 0x48(%rsp)
movq 0x8(%rsp), %rdx
movl 0x10(%rdx), %ecx
movq %rcx, 0x90(%rsp)
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rbp,8), %rax
movq (%r12), %r10
subq %rbp, %r10
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %r9
pushq 0x38(%rsp)
pushq $0x0
pushq $0x1
pushq %r8
pushq %r14
pushq %r13
pushq %r10
pushq %rax
callq 0x3d11d
addq $0x40, %rsp
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
leaq (%r14,%rax), %r15
xorl %ebx, %ebx
pushq $-0x1
popq %rbp
xorl %edx, %edx
xorl %eax, %eax
cmpq %rbx, %r15
je 0x3f2ce
movq 0x8(%rsp), %rsi
movb 0x18(%rsi,%rbx), %cl
testb %cl, %cl
je 0x3f2c6
cmpb 0x7(%rsp), %cl
jbe 0x3f2c1
incl 0x230(%rsi)
movb $0x1, 0x18(%rsi,%rbx)
cmpq $0x0, 0x38(%rsp)
je 0x3f2b0
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
leaq (%rbx,%r13), %rdx
subq $0x20, %rsp
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x2, 0x10(%rsp)
movq 0x58(%rsp), %rcx
pushq $0x4
popq %r8
xorl %r9d, %r9d
callq 0x27ce8
movq 0x28(%rsp), %rcx
addq $0x20, %rsp
testb %al, %al
je 0x3f2b0
movb $0x3, 0x18(%rcx,%rbx)
leaq 0x1(%rbx), %rdx
cmpq $-0x1, %rbp
cmoveq %rbx, %rbp
pushq $0x1
popq %rax
jmp 0x3f2c6
movb $0x0, 0x18(%rsi,%rbx)
incq %rbx
jmp 0x3f23a
testq %rax, %rax
movq 0x18(%rsp), %r15
je 0x3f369
movq %rdx, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movq 0x28(%rsp), %rdx
leaq (,%rdx,8), %rax
addq 0x10(%r12), %rax
movq (%r12), %r8
subq %rdx, %r8
movq 0x70(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
movq 0x78(%rsp), %r9
pushq 0x38(%rsp)
pushq $0x0
pushq $0x0
movq 0x48(%rsp), %r10
pushq (%r10)
pushq %r14
pushq %r13
pushq %r8
pushq %rax
callq 0x3d11d
addq $0x40, %rsp
movq %rax, %r15
movl 0x10(%rbx), %eax
movq 0x90(%rsp), %rdx
cmpl %edx, %eax
jbe 0x3f364
movq (%rbx), %rcx
imulq $0x18, %rdx, %rdi
addq %rcx, %rdi
imulq $0x18, %rax, %rsi
addq %rcx, %rsi
callq 0x192d4
movq 0x18(%rsp), %rdx
subq %rbp, %rdx
jbe 0x3f380
addq 0x88(%rsp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x60(%rsp), %rcx
addq %rcx, %r13
addq %rcx, %r14
movq 0x68(%rsp), %rax
cmpq %rax, %r14
cmovgeq %rax, %r14
subq %rcx, 0x20(%rsp)
movq 0x48(%rsp), %r11
jmp 0x3f070
xorl %r15d, %r15d
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq 0x80(%rsp), %rsi
movq 0x50(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x53d01
movq %rbx, %rdi
movl 0x10(%rbx), %eax
cmpq $0x0, 0x58(%rsp)
je 0x3f3de
movq 0x10(%rsp), %rcx
movq (%rcx), %r15
imulq $0x18, %rax, %rbx
leaq -0x18(%rbx), %r14
pushq $0x1
popq %r12
xorl %ebp, %ebp
xorl %eax, %eax
xorl %r13d, %r13d
cmpq %rbp, %rbx
je 0x3f44d
movq (%rdi), %rdi
cmpq %rbp, %r14
je 0x3f40b
movl 0x18(%rdi,%rbp), %ecx
imulq $0x18, %rax, %rdx
cmpl (%rdi,%rdx), %ecx
je 0x3f43f
imulq $0x18, %rax, %rsi
addq %rdi, %rsi
movq %r12, %rdx
subq %rax, %rdx
imulq $0x18, %r13, %rcx
addq %rdi, %rcx
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
movq %r15, %r8
xorl %r9d, %r9d
pushq $0x5
callq 0x283d2
popq %rcx
popq %rdx
cltq
addq %rax, %r13
movq %r12, %rax
incq %r12
addq $0x18, %rbp
movq 0x8(%rsp), %rdi
jmp 0x3f3f1
xorl %ecx, %ecx
movl %r13d, 0x10(%rdi)
xorps %xmm1, %xmm1
cmpq $0x0, 0x58(%rsp)
sete %cl
je 0x3f469
movsd 0x1a40af(%rip), %xmm1   # 0x1e3518
movq %rcx, %r8
negq %r8
orq $0x2, %r8
movsd 0x1a40bd(%rip), %xmm0   # 0x1e3538
movq 0x10(%rsp), %rsi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x23d9f