// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: refine_ed_aln(overlap_region_alloc*, All_reads*, ul_idx_t const*, UC_Read*, Correct_dumy*, UC_Read*, kvec_t_u64_warp*, long, double, double)
inline void refine_ed_aln(overlap_region_alloc* overlap_list, All_reads *rref, const ul_idx_t *uref, 
                        UC_Read* g_read, Correct_dumy* dumy, UC_Read* overlap_read, kvec_t_u64_warp* v_idx, int64_t block_s, double e_rate, double e_rate_final)
{
    int64_t j, k, i, on, y_id, y_readLen, x_start, x_end, x_len, total_y_start, total_y_end;
    int32_t y_strand, real_y_start;
    int64_t nw, a_nw, w_id, w_s, w_e, is_srt, mm_we, mm_ws, mm_aln, ovl;
    double error_rate; uint64_t *w_idx; overlap_region *z; window_list *p = NULL;

    overlap_list->mapped_overlaps_length = 0; on = overlap_list->length;
    for (j = 0; j < on; ++j) {
        // z = &(overlap_list->list[j]); ovl = z->x_pos_e+1-z->x_pos_s;
        // if(!realign_ed(z, uref, NULL, rref, g_read->seq, 
        //         dumy->overlap_region, dumy->overlap_region_fix, dumy, v_idx, block_s, e_rate, NULL, 1, &is_srt)) {
        //     continue;
        // }
        z = &(overlap_list->list[j]); z->is_match = 0; is_srt = 1;
        if(z->w_list.n == 0) continue;///no alignment
        nw = get_num_wins(z->x_pos_s, z->x_pos_e+1, block_s); a_nw = z->w_list.n;
        kv_resize(uint64_t, v_idx->a, (uint64_t)nw); 
        memset(v_idx->a.a, -1, sizeof((*v_idx->a.a))*nw); w_idx = v_idx->a.a;
        for (i = 0; i < a_nw; i++) { ///w_idx[] == (uint64_t) if unmatched
            assert(z->w_list.a[i].y_end != -1);
            w_id = get_win_id_by_s(z, z->w_list.a[i].x_start, block_s, NULL);
            w_idx[w_id] = i;
        }

        y_id = z->y_id; y_strand = z->y_pos_strand; 
        ovl = z->x_pos_e+1-z->x_pos_s; mm_we = z->x_pos_s; mm_aln = 0; 
        y_readLen = (rref?(Get_READ_LENGTH((*rref), y_id)):(uref->ug->u.a[y_id].len));
        for (i = a_nw-1; i >= 0; i--) { //utilize the the end pos of pre-window in forward
            w_id = get_win_id_by_s(z, z->w_list.a[i].x_start, block_s, &w_e);
            assert(z->w_list.a[i].x_end == w_e);
            if(w_e > mm_we) mm_we = w_e;
            ///in most cases, extra_begin = 0
            total_y_start = z->w_list.a[i].y_end + 1 - z->w_list.a[i].extra_begin;
            for (k = w_id + 1; k < nw && total_y_start < y_readLen; k++) {
                if(w_idx[k] != (uint64_t)-1) break;
                w_s = w_e + 1;
                w_id = get_win_id_by_s(z, w_s, block_s, &w_e);
                assert(w_id == k);
                x_start = w_s; x_end = w_e;
                if(aln_wlst(z, rref, uref, g_read, dumy, y_strand, y_id, x_start, x_end, 
                                                            total_y_start, block_s, e_rate, 0)) {
                    p = &(z->w_list.a[z->w_list.n-1]);
                    w_idx[k] = z->w_list.n - 1;
                    if(x_end > mm_we) mm_we = x_end;
                    if(is_srt && z->w_list.n > 1 && p->x_start < z->w_list.a[z->w_list.n-2].x_start) is_srt = 0;
                } else {
                    break;
                }
                total_y_start = p->y_end + 1 - p->extra_begin;
            }
        }
        mm_ws = z->x_pos_s; mm_aln = mm_we+1-mm_ws; 
        if(!simi_pass(ovl, mm_aln, uref?1:0, OVERLAP_THRESHOLD_NOSI_FILTER, NULL)) continue;
        if(nw > 0 && w_idx[0] != (uint64_t)-1) mm_ws = z->w_list.a[w_idx[0]].x_end+1;
        
        for (i = 1; i < nw; i++) { //utilize the the start pos of next window in backward
            ///find the first matched window, which should not be the first window
            ///the pre-window of this matched window must be unmatched
            if(w_idx[i] != (uint64_t)-1 && w_idx[i-1] == (uint64_t)-1) {
                w_s = z->w_list.a[w_idx[i]].x_start; mm_aln -= (w_s-mm_ws);
                ///check if the start pos of this matched window has been calculated
                if(z->w_list.a[w_idx[i]].clen == 0) {
                    p = &(z->w_list.a[w_idx[i]]);
                    gen_backtrace(p, z, rref, uref, g_read, dumy, y_strand, y_id);
                    assert(p->error != -1);
                    p->y_end += p->extra_begin;
                } 
                real_y_start = p->y_start;

                ///the end pos for pre window is real_y_start - 1
                total_y_end = real_y_start - 1;
                ///find the unmatched window on the left of current matched window
                ///k starts from i - 1
                for (k = i - 1; k >= 0 && w_idx[k] == (uint64_t)-1 && total_y_end > 0; k--) {  
                    w_e = w_s - 1;
                    w_id = get_win_id_by_e(z, w_e, block_s, &w_s);
                    assert(w_id == k);
                    x_start = w_s; x_end = w_e; x_len = x_end + 1 - x_start;
                    if(aln_wlst(z, rref, uref, g_read, dumy, y_strand, y_id, x_start, x_end, total_y_end+1-x_len, block_s, e_rate, 1)) {
                        p = &(z->w_list.a[z->w_list.n-1]);
                        p->y_start -= p->extra_begin; ///y_start has no shift, but y_end has shift  
                        w_idx[k] = z->w_list.n - 1;
                        mm_aln += x_len;
                        if(is_srt && z->w_list.n > 1 && p->x_start < z->w_list.a[z->w_list.n-2].x_start) is_srt = 0;
                    } else {
                        break;
                    }
                    total_y_end = p->y_start - 1;
                }
                if(!simi_pass(ovl, mm_aln, uref?1:0, OVERLAP_THRESHOLD_NOSI_FILTER, NULL)) break;
            }
            if(w_idx[i] != (uint64_t)-1) mm_ws = z->w_list.a[w_idx[i]].x_end+1;
        }

        if(i < nw) continue;
        if(uref && simi_pass(ovl, z->align_length, uref?1:0, OVERLAP_THRESHOLD_NOSI_FILTER, NULL)) {
            z->is_match = 3; overlap_list->mapped_overlaps_length += z->align_length;
            ///sort for set_herror_win
            if(!is_srt) radix_sort_window_list_xs_srt(z->w_list.a, z->w_list.a + z->w_list.n);
        }
    }

    if(uref && overlap_list->mapped_overlaps_length > 0) {
        set_herror_win(overlap_list, dumy, v_idx, e_rate, g_read->length, block_s);
    }

    overlap_list->mapped_overlaps_length = 0;
    for (j = 0; j < (long long)overlap_list->length; j++) {
        z = &(overlap_list->list[j]);
        y_id = z->y_id; y_strand = z->y_pos_strand; 
        y_readLen = (rref?(Get_READ_LENGTH((*rref), y_id)):(uref->ug->u.a[y_id].len));
        ovl = z->x_pos_e + 1 - z->x_pos_s; //z->is_match = 0;
        // if(y_id == 4) {
        //     fprintf(stderr, "[M::%s::idx->%ld::] z::x_pos_s->%u, z::x_pos_e->%u, ovl->%ld, aln->%u\n", 
        //     __func__, j, z->x_pos_s, z->x_pos_e, ovl, z->align_length);
        // }
        ///debug_scan_cigar(&(overlap_list->list[j]));
        ///only calculate cigar for high quality overlaps
        // int64_t tt = 0;
        if(simi_pass(ovl, z->align_length, 0, OVERLAP_THRESHOLD_NOSI_FILTER, &e_rate)) {
            a_nw = z->w_list.n;
            for (i = 0, is_srt = 1; i < a_nw; i++) {
                p = &(z->w_list.a[i]);
                ///check if the cigar of this window has been got 
                if(p->clen == 0) {
                    gen_backtrace(p, z, rref, uref, g_read, dumy, y_strand, y_id);
                    assert(p->error != -1);
                    // if(y_id == 4) {
                    //     fprintf(stderr, "+[M::idx->%ld::] y_start->%d, y_end->%d, error->%d\n", 
                    //     j, p->y_start, p->y_end, p->error);
                    // }
                }
                else {
                    p->y_end -= p->extra_begin;
                    // if(y_id == 4) {
                    //     fprintf(stderr, "-[M::idx->%ld::] y_start->%d, y_end->%d, error->%d\n", 
                    //     j, p->y_start, p->y_end, p->error);
                    // }
                }
                // tt += p->error;
                if(is_srt && i > 0 && p->x_start < z->w_list.a[i-1].x_start) is_srt = 0;
            }
            if(!is_srt) radix_sort_window_list_xs_srt(z->w_list.a, z->w_list.a + z->w_list.n);
            error_rate = non_trim_error_rate(z, rref, uref, v_idx, dumy, g_read, e_rate, block_s);
            z->is_match = 0;///must be here;
            // if(y_id == 4) {
            //     fprintf(stderr, "[M::%s::idx->%ld::] block_s->%ld, z::x_pos_s->%u, z::x_pos_e->%u, ovl->%ld, aln->%u, error_rate->%f, e_rate_final->%f\n", 
            //     __func__, j, block_s, z->x_pos_s, z->x_pos_e, ovl, z->align_length, error_rate, e_rate_final);
            //     exit(1);
            // }
            if (error_rate <= e_rate_final) {
                overlap_list->mapped_overlaps_length += ovl;
                z->is_match = 1; append_unmatched_wins(z, block_s);
                if(rref) {
                    calculate_boundary_cigars(z, rref, dumy, g_read, e_rate);
                } else {
                    calculate_ul_boundary_cigars(z, uref, dumy, g_read, e_rate, block_s);
                }
                // assert(get_num_wins(z->x_pos_s, z->x_pos_e+1, block_s)==(int64_t)z->w_list.n);
                // assert((int64_t)z->x_pos_s==z->w_list.a[0].x_start && 
                //                             (int64_t)z->x_pos_e==z->w_list.a[z->w_list.n-1].x_end);
            } else if (error_rate <= e_rate_final * 1.5) {
                z->is_match = 3;
            }
        } else {///it impossible to be matched
            z->is_match = 0;
            // fprintf(stderr, "[M::%s::idx->%ld::is_match->%u] z::x_pos_s->%u, z::x_pos_e->%u, error_rate->-1, e_threshold->%f\n", 
            // __func__, j, z->is_match, z->x_pos_s, z->x_pos_e, e_rate);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movsd %xmm1, 0x90(%rsp)
movsd %xmm0, 0x58(%rsp)
movq %r8, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r12
movq %rdi, %r14
movq 0xe8(%rsp), %r9
movq 0xe0(%rsp), %rbx
movq $0x0, 0x18(%rdi)
movq 0x10(%rdi), %rax
movq %rax, 0x98(%rsp)
testq %rax, %rax
movq %rsi, 0x48(%rsp)
movq %rdi, 0x68(%rsp)
jle 0x89380
xorl %r15d, %r15d
xorl %ebp, %ebp
movq (%r14), %rdx
imulq $0xa8, %rbp, %rax
movb $0x0, 0x2c(%rdx,%rax)
movq 0x48(%rdx,%rax), %r13
testq %r13, %r13
movq %rbp, 0xa0(%rsp)
je 0x89349
addq %rax, %rdx
movl 0x4(%rdx), %ecx
movq %rdx, 0x20(%rsp)
movl 0x8(%rdx), %esi
incl %esi
movq %rcx, %rax
xorl %edx, %edx
idivq %r9
subq %rcx, %rdx
addq %rdx, %rsi
movq %rsi, %rax
cqto
idivq %r9
xorl %ecx, %ecx
testq %rdx, %rdx
setg %cl
addq %rax, %rcx
movq 0x10(%rbx), %rdi
cmpq %rcx, 0x8(%rbx)
movq %rcx, 0x28(%rsp)
jae 0x88c27
leaq -0x1(%rcx), %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(%rbx)
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x28(%rsp), %rcx
movq %rax, %rdi
movq %rax, 0x10(%rbx)
leaq (,%rcx,8), %rdx
movl $0xff, %esi
callq 0x20e0
movq 0x10(%rbx), %rdi
testq %r13, %r13
movq %rdi, 0x10(%rsp)
jle 0x88cb0
movq 0x20(%rsp), %rax
movq 0x58(%rax), %rdi
xorl %r8d, %r8d
movq 0xe8(%rsp), %r9
movq 0x28(%rsp), %r11
cmpl $-0x1, 0xc(%rdi)
je 0x89612
movslq (%rdi), %rcx
movq 0x20(%rsp), %rax
movl 0x4(%rax), %r10d
movl %r10d, %esi
movq %rsi, %rax
xorl %edx, %edx
idivq %r9
addq %rdx, %rcx
subq %rsi, %rcx
movq %rcx, %rax
cqto
idivq %r9
movq 0x10(%rsp), %rcx
movq %r8, (%rcx,%rax,8)
incq %r8
addq $0x20, %rdi
cmpq %r8, %r13
jne 0x88c60
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %r8
jmp 0x88cc6
movq 0x20(%rsp), %r8
movl 0x4(%r8), %r10d
movq 0xe8(%rsp), %r9
movq 0x28(%rsp), %r11
movl 0x10(%r8), %edx
testq %r12, %r12
je 0x88cda
movq 0x18(%r12), %rax
movq (%rax,%rdx,8), %rax
jmp 0x88cf2
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
leaq (%rdx,%rdx,4), %rcx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x8(%rsp)
movq %rdx, %rax
movl 0x8(%r8), %ecx
movl %ecx, 0x70(%rsp)
movl 0x1c(%r8), %ecx
movq %rcx, 0x60(%rsp)
movl %r10d, 0x88(%rsp)
movl %r10d, %ecx
testq %r13, %r13
jle 0x88f5b
movq %rax, 0x40(%rsp)
movl $0x1, %ebp
movq %rcx, 0x80(%rsp)
movq %rcx, %r10
leaq -0x1(%r13), %rbx
movq 0x58(%r8), %rdi
movq %r8, %rax
movq %rbx, %r8
shlq $0x5, %r8
movslq (%rdi,%r8), %rcx
movl 0x8(%rax), %r12d
movl 0x4(%rax), %esi
movq %rsi, %rax
xorl %edx, %edx
idivq %r9
subq %rdx, %rsi
subq %rsi, %rcx
movq %rcx, %rax
cqto
idivq %r9
movq %rax, %r14
incq %rax
movq %rax, %rcx
imulq %r9, %rcx
addq %rsi, %rcx
decq %rcx
cmpq %r12, %rcx
cmovlq %rcx, %r12
movslq 0x4(%rdi,%r8), %rcx
cmpq %rcx, %r12
jne 0x89631
movq %r13, 0x78(%rsp)
movq %rbx, 0x50(%rsp)
cmpq %r10, %r12
cmovgq %r12, %r10
movq %r10, %r13
cmpq %r11, %rax
jge 0x88eff
addq %r8, %rdi
movl 0xc(%rdi), %eax
movswl 0x10(%rdi), %ecx
subl %ecx, %eax
incl %eax
movslq %eax, %r10
cmpq %r10, 0x8(%rsp)
jle 0x88eff
movq 0x10(%rsp), %rdi
cmpq $-0x1, 0x8(%rdi,%r14,8)
movq 0x20(%rsp), %r8
jne 0x88f09
addq $0x2, %r14
leaq -0x1(%r14), %rsi
movq %r12, %r11
incq %r11
movl 0x8(%r8), %r12d
movl 0x4(%r8), %ecx
movq %rcx, %rax
xorl %edx, %edx
idivq %r9
subq %rdx, %rcx
movq %r11, %rax
subq %rcx, %rax
cqto
idivq %r9
leaq 0x1(%rax), %rdx
imulq %r9, %rdx
addq %rdx, %rcx
decq %rcx
cmpq %r12, %rcx
cmovlq %rcx, %r12
cmpq %rax, %rsi
jne 0x895f3
movq %r8, %rdi
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r8, %rbx
movq 0x38(%rsp), %r8
movq %r9, %rax
movq 0x60(%rsp), %r9
movsd 0x58(%rsp), %xmm0
pushq $0x0
pushq %rax
pushq %r10
pushq %r12
pushq %r11
pushq 0x68(%rsp)
callq 0x9b7e9
addq $0x30, %rsp
testl %eax, %eax
je 0x88f1f
movq 0x48(%rbx), %r15
movq 0x58(%rbx), %rax
decq %r15
movq 0x10(%rsp), %rdi
movq %r15, -0x8(%rdi,%r14,8)
shlq $0x5, %r15
addq %rax, %r15
cmpq %r13, %r12
cmovgq %r12, %r13
testq %rbp, %rbp
movq 0x28(%rsp), %r11
movq %rbx, %r8
je 0x88ec8
movq 0x48(%r8), %rcx
movl $0x1, %ebp
cmpq $0x2, %rcx
movq 0xe8(%rsp), %r9
jb 0x88ed2
movl (%r15), %edx
shlq $0x5, %rcx
xorl %ebp, %ebp
cmpl -0x40(%rax,%rcx), %edx
setge %bpl
jmp 0x88ed2
xorl %ebp, %ebp
movq 0xe8(%rsp), %r9
cmpq %r11, %r14
jge 0x88f09
movl 0xc(%r15), %eax
movswl 0x10(%r15), %ecx
subl %ecx, %eax
incl %eax
movslq %eax, %r10
cmpq %r10, 0x8(%rsp)
jle 0x88f09
cmpq $-0x1, (%rdi,%r14,8)
leaq 0x1(%r14), %r14
je 0x88de2
jmp 0x88f09
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %r8
cmpq $0x1, 0x78(%rsp)
movq %r13, %r10
movq 0x50(%rsp), %r13
jg 0x88d34
jmp 0x88f36
movq 0xe8(%rsp), %r9
movq 0x28(%rsp), %r11
movq 0x10(%rsp), %rdi
movq %rbx, %r8
jmp 0x88f09
movl 0x4(%r8), %esi
movq 0x48(%rsp), %r12
movq 0x68(%rsp), %r14
movq 0xe0(%rsp), %rbx
movq 0x40(%rsp), %rax
movq 0x80(%rsp), %rdx
jmp 0x88f69
movl $0x1, %ebp
movq %rcx, %rsi
movq %rcx, %r10
movq %rcx, %rdx
movl 0x70(%rsp), %ecx
incl %ecx
cmpl %edx, %ecx
je 0x89349
subq %rsi, %r10
incq %r10
je 0x89349
subl 0x88(%rsp), %ecx
movl %ecx, %ecx
movq %rcx, 0x70(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
cvtsi2sd %r10, %xmm1
cmpq $0x0, 0x18(%rsp)
je 0x88fbc
mulsd 0x1a8642(%rip), %xmm0   # 0x2315f0
cmpq $0x1c2, %r10            # imm = 0x1C2
jge 0x88fc4
jmp 0x89349
mulsd 0x1a85dc(%rip), %xmm0   # 0x2315a0
ucomisd %xmm0, %xmm1
jb 0x89349
movl $0x1, %edx
testq %r11, %r11
jle 0x892e2
movq %rax, 0x40(%rsp)
movq (%rdi), %rax
cmpq $-0x1, %rax
je 0x88ffa
movq 0x58(%r8), %rcx
shlq $0x5, %rax
movslq 0x4(%rcx,%rax), %rsi
incq %rsi
cmpq $0x1, %r11
je 0x892e2
xorps %xmm0, %xmm0
cvtsi2sdq 0x70(%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x1a8586(%rip), %xmm1   # 0x2315a0
movsd %xmm1, 0x80(%rsp)
mulsd 0x1a85c5(%rip), %xmm0   # 0x2315f0
movsd %xmm0, 0x88(%rsp)
movq (%rdi,%rdx,8), %rax
cmpq $-0x1, %rax
je 0x892d3
cmpq $-0x1, -0x8(%rdi,%rdx,8)
jne 0x892b9
movq 0x58(%r8), %r14
shlq $0x5, %rax
movslq (%r14,%rax), %rbx
cmpl $0x0, 0x1c(%r14,%rax)
movq %rdx, 0x50(%rsp)
jne 0x890d3
movq %r12, %rdx
movq %rsi, %r12
movq %r10, %r13
addq %rax, %r14
movq %r14, %rdi
movq %r8, %rsi
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
pushq 0x40(%rsp)
pushq 0x68(%rsp)
callq 0x9bdd2
addq $0x10, %rsp
cmpw $-0x1, 0x14(%r14)
je 0x8968e
movswl 0x10(%r14), %eax
addl %eax, 0xc(%r14)
movq %r14, %r15
movq 0xe8(%rsp), %r9
movq 0x28(%rsp), %r11
movq 0x10(%rsp), %rdi
movq %r13, %r10
movq 0x20(%rsp), %r8
movq %r12, %rsi
movq 0x50(%rsp), %rdx
movq %rbp, 0x8(%rsp)
movq %rsi, 0x78(%rsp)
addq %rsi, %r10
subq %rbx, %r10
cmpq $-0x1, -0x8(%rdi,%rdx,8)
jne 0x8925a
movl 0x8(%r15), %esi
cmpl $0x2, %esi
jl 0x8925a
leaq -0x1(%rdx), %r14
movq %r10, %rbp
leaq -0x1(%rbx), %r10
movl 0x4(%r8), %ecx
movq %rcx, %rax
xorl %edx, %edx
idivq %r9
movq %rcx, %rdi
subq %rdx, %rdi
movq %r10, %rax
subq %rdi, %rax
cqto
idivq %r9
movq %rax, %r12
imulq %r9, %r12
addq %rdi, %r12
cmpq %rcx, %r12
cmovleq %rcx, %r12
cmpq %rax, %r14
jne 0x8966f
movq %r9, %r11
subq %r12, %rbx
movl %esi, %eax
subq %rbx, %rax
movq %r8, %rdi
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq %r8, %r13
movq 0x38(%rsp), %r8
movq 0x60(%rsp), %r9
movsd 0x58(%rsp), %xmm0
pushq $0x1
pushq %r11
pushq %rax
pushq %r10
pushq %r12
pushq 0x68(%rsp)
callq 0x9b7e9
addq $0x30, %rsp
testl %eax, %eax
je 0x8923d
movq 0x48(%r13), %rcx
movq 0x58(%r13), %rax
movq %rcx, %rdx
shlq $0x5, %rdx
leaq (%rax,%rdx), %r15
addq $-0x20, %r15
movswl 0x10(%r15), %edx
movl 0x8(%r15), %esi
subl %edx, %esi
movl %esi, 0x8(%r15)
decq %rcx
movq 0x10(%rsp), %rdi
movq %rcx, (%rdi,%r14,8)
cmpq $0x0, 0x8(%rsp)
movq 0x28(%rsp), %r11
movq %rbp, %r10
movq %r13, %r8
je 0x89206
movq 0x48(%r8), %rcx
movl $0x1, %edx
movq %rdx, 0x8(%rsp)
cmpq $0x2, %rcx
movq 0xe8(%rsp), %r9
jb 0x89217
movl (%r15), %edx
shlq $0x5, %rcx
xorl %r13d, %r13d
cmpl -0x40(%rax,%rcx), %edx
setge %r13b
movq %r13, 0x8(%rsp)
jmp 0x89217
movq $0x0, 0x8(%rsp)
movq 0xe8(%rsp), %r9
addq %rbx, %r10
testq %r14, %r14
jle 0x89255
cmpq $-0x1, -0x8(%rdi,%r14,8)
movq 0x50(%rsp), %rdx
jne 0x8925a
decq %r14
movq %r12, %rbx
cmpl $0x2, %esi
jge 0x89100
jmp 0x8925a
movq 0xe8(%rsp), %r9
movq 0x28(%rsp), %r11
movq 0x10(%rsp), %rdi
movq %rbp, %r10
movq %r13, %r8
movq 0x50(%rsp), %rdx
testq %r10, %r10
je 0x89364
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
cmpq $0x0, 0x18(%rsp)
movq 0x48(%rsp), %r12
movq 0x68(%rsp), %r14
movq 0xe0(%rsp), %rbx
movq 0x8(%rsp), %rbp
je 0x892a5
cmpq $0x1c2, %r10            # imm = 0x1C2
jl 0x892e2
ucomisd 0x88(%rsp), %xmm0
movq 0x78(%rsp), %rsi
jae 0x892b9
jmp 0x892e2
ucomisd 0x80(%rsp), %xmm0
movq 0x78(%rsp), %rsi
jb 0x89349
movq (%rdi,%rdx,8), %rax
cmpq $-0x1, %rax
je 0x892d3
movq 0x58(%r8), %rcx
shlq $0x5, %rax
movslq 0x4(%rcx,%rax), %rsi
incq %rsi
incq %rdx
cmpq %r11, %rdx
jne 0x89034
movq %r11, %rdx
cmpq $0x0, 0x18(%rsp)
je 0x89349
cmpq %r11, %rdx
jl 0x89349
movl 0x28(%r8), %eax
testq %rax, %rax
je 0x89349
xorps %xmm0, %xmm0
cvtsi2sdq 0x70(%rsp), %xmm0
mulsd 0x1a82e6(%rip), %xmm0   # 0x2315f0
cmpl $0x1c2, %eax            # imm = 0x1C2
jb 0x89349
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
ucomisd %xmm0, %xmm1
jb 0x89349
movb $0x3, 0x2c(%r8)
addq %rax, 0x18(%r14)
testq %rbp, %rbp
jne 0x89349
movq 0x48(%r8), %rsi
movq 0x58(%r8), %rdi
shlq $0x5, %rsi
addq %rdi, %rsi
callq 0x46146
movq 0xe8(%rsp), %r9
movq 0xa0(%rsp), %rbp
incq %rbp
cmpq 0x98(%rsp), %rbp
jne 0x88b6c
jmp 0x89380
movq 0x48(%rsp), %r12
movq 0x68(%rsp), %r14
movq 0xe0(%rsp), %rbx
movq 0x8(%rsp), %rbp
jmp 0x892e2
cmpq $0x0, 0x18(%rsp)
je 0x893ab
cmpq $0x0, 0x18(%r14)
jle 0x893ab
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rcx
movq %r14, %rdi
movq 0x38(%rsp), %rsi
movq %rbx, %rdx
movq %r9, %r8
callq 0x4ad19
movq $0x0, 0x18(%r14)
cmpq $0x0, 0x10(%r14)
jle 0x895e1
movsd 0x1a7f4a(%rip), %xmm0   # 0x231310
subsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x1a8196(%rip), %xmm0   # 0x231570
mulsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
xorl %ebp, %ebp
movq (%r14), %rax
imulq $0xa8, %rbp, %rcx
leaq (%rax,%rcx), %rbx
movl 0x8(%rax,%rcx), %r8d
incl %r8d
movl 0x28(%rax,%rcx), %edx
testl %edx, %edx
sete %sil
subl 0x4(%rax,%rcx), %r8d
sete %dil
orb %sil, %dil
jne 0x89437
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
mulsd 0x28(%rsp), %xmm0
movl %edx, %edx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
ucomisd %xmm0, %xmm1
jae 0x89449
movb $0x0, 0x2c(%rbx)
incq %rbp
cmpq 0x10(%r14), %rbp
jl 0x893eb
jmp 0x895e1
movq %r8, 0x40(%rsp)
movq 0x48(%rbx), %r13
testq %r13, %r13
jle 0x8951c
movq %rbp, 0x60(%rsp)
movl 0x10(%rax,%rcx), %edx
movq %rdx, 0x10(%rsp)
movl 0x1c(%rax,%rcx), %eax
movq %rax, 0x8(%rsp)
movl $0x1, %r12d
xorl %ebp, %ebp
movq 0x58(%rbx), %r15
leaq (%r15,%rbp), %r14
cmpl $0x0, 0x1c(%r15,%rbp)
je 0x89497
movswl 0x10(%r15,%rbp), %eax
subl %eax, 0xc(%r15,%rbp)
jmp 0x894cf
movq %r14, %rdi
movq %rbx, %rsi
movq 0x48(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
pushq 0x10(%rsp)
pushq 0x10(%rsp)
callq 0x9bdd2
addq $0x10, %rsp
cmpw $-0x1, 0x14(%r15,%rbp)
je 0x89650
testq %rbp, %rbp
je 0x894eb
testq %r12, %r12
je 0x894eb
movl (%r14), %eax
movq 0x58(%rbx), %rcx
xorl %r12d, %r12d
cmpl -0x20(%rcx,%rbp), %eax
setge %r12b
addq $0x20, %rbp
decq %r13
jne 0x8947a
testq %r12, %r12
movq 0x48(%rsp), %r12
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %rbp
jne 0x8951c
movq 0x48(%rbx), %rsi
movq 0x58(%rbx), %rdi
shlq $0x5, %rsi
addq %rdi, %rsi
callq 0x46146
subq $0x8, %rsp
movq %rbx, %rdi
movq %r12, %rsi
movq 0x20(%rsp), %rdx
movq 0xe8(%rsp), %rcx
movq 0x40(%rsp), %r8
movq 0x38(%rsp), %r9
movsd 0x60(%rsp), %xmm0
movq 0xf0(%rsp), %r15
pushq %r15
callq 0x99c0c
addq $0x10, %rsp
movb $0x0, 0x2c(%rbx)
movsd 0x90(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x89582
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x8943b
movb $0x3, 0x2c(%rbx)
jmp 0x8943b
movq 0x40(%rsp), %rax
addq %rax, 0x18(%r14)
movb $0x1, 0x2c(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x49760
movq %rbx, %rdi
testq %r12, %r12
je 0x895bf
movq %r12, %rsi
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
movsd 0x58(%rsp), %xmm0
callq 0x49e91
jmp 0x8943b
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
movsd 0x58(%rsp), %xmm0
movq %r15, %r8
callq 0x4a52c
jmp 0x8943b
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a9138(%rip), %rdi    # 0x232732
leaq 0x1a8152(%rip), %rsi    # 0x231753
leaq 0x1ac4b2(%rip), %rcx    # 0x235aba
movl $0x10dc, %edx           # imm = 0x10DC
callq 0x2110
leaq 0x1a902e(%rip), %rdi    # 0x232647
leaq 0x1a8133(%rip), %rsi    # 0x231753
leaq 0x1ac493(%rip), %rcx    # 0x235aba
movl $0x10ca, %edx           # imm = 0x10CA
callq 0x2110
leaq 0x1ac397(%rip), %rdi    # 0x2359cf
leaq 0x1a8114(%rip), %rsi    # 0x231753
leaq 0x1ac474(%rip), %rcx    # 0x235aba
movl $0x10d4, %edx           # imm = 0x10D4
callq 0x2110
leaq 0x1a90cc(%rip), %rdi    # 0x232723
leaq 0x1a80f5(%rip), %rsi    # 0x231753
leaq 0x1ac455(%rip), %rcx    # 0x235aba
movl $0x1135, %edx           # imm = 0x1135
callq 0x2110
leaq 0x1a90bc(%rip), %rdi    # 0x232732
leaq 0x1a80d6(%rip), %rsi    # 0x231753
leaq 0x1ac436(%rip), %rcx    # 0x235aba
movl $0x1103, %edx           # imm = 0x1103
callq 0x2110
leaq 0x1a908e(%rip), %rdi    # 0x232723
leaq 0x1a80b7(%rip), %rsi    # 0x231753
leaq 0x1ac417(%rip), %rcx    # 0x235aba
movl $0x10f7, %edx           # imm = 0x10F7
callq 0x2110