// File: /workspace/github_cpp_makefile_star2_O1/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, 0x88(%rsp)
movsd %xmm0, 0x50(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movq 0xe8(%rsp), %r9
movq 0xe0(%rsp), %rbp
movq $0x0, 0x18(%rdi)
movq 0x10(%rdi), %rax
movq %rax, 0xa0(%rsp)
testq %rax, %rax
movq %rsi, 0x8(%rsp)
movq %rdi, 0x30(%rsp)
jle 0x89fd6
xorl %r15d, %r15d
xorl %ebx, %ebx
movq (%r12), %r13
imulq $0xa8, %rbx, %rax
movb $0x0, 0x2c(%r13,%rax)
movq 0x48(%r13,%rax), %rcx
testq %rcx, %rcx
je 0x89fb4
movq %rcx, %r12
addq %rax, %r13
movl 0x4(%r13), %ecx
movl 0x8(%r13), %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
cmpq %rcx, 0x8(%rbp)
movq %rcx, 0x10(%rsp)
jae 0x898e7
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(%rbp)
movq 0x10(%rbp), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x10(%rsp), %rcx
movq %rax, 0x10(%rbp)
movq 0x10(%rbp), %rdi
leaq (,%rcx,8), %rdx
movl $0xff, %esi
callq 0x20e0
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
movq %r12, %r10
testq %r12, %r12
movq 0xe8(%rsp), %r9
jle 0x89957
movq 0x58(%r13), %rdi
xorl %r8d, %r8d
cmpl $-0x1, 0xc(%rdi)
je 0x8a276
movslq (%rdi), %rcx
movl 0x4(%r13), %esi
movq %rsi, %rax
xorl %edx, %edx
idivq %r9
addq %rdx, %rcx
subq %rsi, %rcx
movq %rcx, %rax
cqto
idivq %r9
movq (%rsp), %rcx
movq %r8, (%rcx,%rax,8)
incq %r8
addq $0x20, %rdi
cmpq %r8, %r10
jne 0x8991c
movl 0x10(%r13), %edx
testq %r14, %r14
je 0x8996a
movq 0x18(%r14), %rax
movq (%rax,%rdx,8), %rax
jmp 0x89982
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, 0x20(%rsp)
movq 0x10(%rsp), %r11
movq (%rsp), %rdi
movq %rbx, 0x68(%rsp)
movl 0x4(%r13), %ebp
movl 0x8(%r13), %eax
movl %eax, 0x2c(%rsp)
movl 0x1c(%r13), %eax
movq %rax, 0x58(%rsp)
testq %r10, %r10
movq %rbp, 0x70(%rsp)
movq %rdx, 0x60(%rsp)
movl $0x1, %eax
jle 0x89baa
movq %rax, 0x48(%rsp)
movq %r10, %rbx
decq %r10
movq 0x58(%r13), %rdi
movq %r10, %r8
shlq $0x5, %r8
movslq (%rdi,%r8), %rcx
movl 0x8(%r13), %r12d
movl 0x4(%r13), %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 0x8a295
movq %r10, 0x78(%rsp)
cmpq %rbp, %r12
cmovgq %r12, %rbp
cmpq %r11, %rax
jge 0x89b95
addq %r8, %rdi
movl 0xc(%rdi), %eax
movswl 0x10(%rdi), %ecx
subl %ecx, %eax
incl %eax
movslq %eax, %r10
cmpq %r10, 0x20(%rsp)
jle 0x89b95
movq (%rsp), %rdi
cmpq $-0x1, 0x8(%rdi,%r14,8)
jne 0x89b99
addq $0x2, %r14
leaq -0x1(%r14), %rsi
movq %r12, %r11
incq %r11
movl 0x8(%r13), %r12d
movl 0x4(%r13), %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 0x8a257
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq 0x40(%rsp), %r8
movq %r9, %rax
movq 0x58(%rsp), %r9
movsd 0x50(%rsp), %xmm0
pushq $0x0
pushq %rax
pushq %r10
pushq %r12
pushq %r11
pushq 0x88(%rsp)
callq 0x9b0b2
addq $0x30, %rsp
testl %eax, %eax
je 0x89b88
movq 0x48(%r13), %r15
movq 0x58(%r13), %rax
decq %r15
movq (%rsp), %rdi
movq %r15, -0x8(%rdi,%r14,8)
shlq $0x5, %r15
addq %rax, %r15
cmpq %rbp, %r12
cmovgq %r12, %rbp
cmpq $0x0, 0x48(%rsp)
movq 0x10(%rsp), %r11
je 0x89b4c
movq 0x48(%r13), %rcx
movl $0x1, %esi
cmpq $0x2, %rcx
movq 0xe8(%rsp), %r9
jb 0x89b56
movl (%r15), %edx
shlq $0x5, %rcx
xorl %esi, %esi
cmpl -0x40(%rax,%rcx), %edx
setge %sil
jmp 0x89b56
xorl %esi, %esi
movq 0xe8(%rsp), %r9
cmpq %r11, %r14
movq %rsi, 0x48(%rsp)
jge 0x89b99
movl 0xc(%r15), %eax
movswl 0x10(%r15), %ecx
subl %ecx, %eax
incl %eax
movslq %eax, %r10
cmpq %r10, 0x20(%rsp)
jle 0x89b99
cmpq $-0x1, (%rdi,%r14,8)
leaq 0x1(%r14), %r14
je 0x89a67
jmp 0x89b99
movq 0xe8(%rsp), %r9
movq 0x10(%rsp), %r11
movq (%rsp), %rdi
cmpq $0x1, %rbx
movq 0x78(%rsp), %r10
jg 0x899c7
jmp 0x89baf
movq %rax, 0x48(%rsp)
movl 0x2c(%rsp), %edx
incl %edx
movq 0x70(%rsp), %rcx
cmpl %ecx, %edx
je 0x89c04
movl 0x4(%r13), %r12d
subq %r12, %rbp
incq %rbp
movq 0x68(%rsp), %rbx
je 0x89fa2
movl %edx, %eax
subl %ecx, %eax
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
cvtsi2sd %rbp, %xmm1
cmpq $0x0, 0x18(%rsp)
je 0x89c20
mulsd 0x19b8fa(%rip), %xmm0   # 0x2254f0
cmpq $0x1c2, %rbp            # imm = 0x1C2
jge 0x89c28
jmp 0x89fa2
movq 0x8(%rsp), %r14
movq 0x30(%rsp), %r12
movq 0xe0(%rsp), %rbp
movq 0x68(%rsp), %rbx
jmp 0x89fb4
mulsd 0x19b878(%rip), %xmm0   # 0x2254a0
ucomisd %xmm0, %xmm1
jb 0x89fa2
movq %rax, 0x80(%rsp)
testq %r11, %r11
jle 0x89c58
movq (%rdi), %rax
cmpq $-0x1, %rax
je 0x89c58
movq 0x58(%r13), %rcx
shlq $0x5, %rax
movslq 0x4(%rcx,%rax), %r12
incq %r12
movl $0x1, %esi
cmpq $0x2, %r11
movl %edx, 0x2c(%rsp)
jl 0x89f08
xorps %xmm0, %xmm0
cvtsi2sdq 0x80(%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x19b81c(%rip), %xmm1   # 0x2254a0
movsd %xmm1, 0x90(%rsp)
mulsd 0x19b85b(%rip), %xmm0   # 0x2254f0
movsd %xmm0, 0x98(%rsp)
movq (%rdi,%rsi,8), %rax
cmpq $-0x1, %rax
je 0x89ee2
cmpq $-0x1, -0x8(%rdi,%rsi,8)
jne 0x89ee2
movq 0x58(%r13), %r14
shlq $0x5, %rax
movslq (%r14,%rax), %rbx
cmpl $0x0, 0x1c(%r14,%rax)
movq %rsi, 0x20(%rsp)
jne 0x89d2d
addq %rax, %r14
movq %r14, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
pushq 0x60(%rsp)
pushq 0x60(%rsp)
callq 0x9b652
addq $0x10, %rsp
cmpw $-0x1, 0x14(%r14)
je 0x8a2f2
movswl 0x10(%r14), %eax
addl %eax, 0xc(%r14)
movq %r14, %r15
movq 0xe8(%rsp), %r9
movq 0x10(%rsp), %r11
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %r12, %rbp
subq %rbx, %rbp
cmpq $-0x1, -0x8(%rdi,%rsi,8)
movq %r12, 0x78(%rsp)
jne 0x89e8f
movl 0x8(%r15), %esi
cmpl $0x2, %esi
jl 0x89e8f
movq 0x20(%rsp), %rax
leaq -0x1(%rax), %r14
leaq -0x1(%rbx), %r10
movl 0x4(%r13), %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 0x8a2b4
movq %r9, %r11
subq %r12, %rbx
movl %esi, %eax
subq %rbx, %rax
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq 0x40(%rsp), %r8
movq 0x58(%rsp), %r9
movsd 0x50(%rsp), %xmm0
pushq $0x1
pushq %r11
pushq %rax
pushq %r10
pushq %r12
pushq 0x88(%rsp)
callq 0x9b0b2
addq $0x30, %rsp
testl %eax, %eax
je 0x89e7e
movq 0x48(%r13), %rdx
movq 0x58(%r13), %rax
movq %rdx, %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %r15
addq $-0x20, %r15
movswl 0x10(%r15), %esi
subl %esi, 0x8(%r15)
decq %rdx
movq (%rsp), %rdi
movq %rdx, (%rdi,%r14,8)
cmpq $0x0, 0x48(%rsp)
movq 0x10(%rsp), %r11
je 0x89e48
movq 0x48(%r13), %rdx
movl $0x1, %esi
cmpq $0x2, %rdx
movq 0xe8(%rsp), %r9
jb 0x89e52
movl (%r15), %esi
shlq $0x5, %rdx
cmpl -0x40(%rax,%rdx), %esi
movl $0x0, %esi
setge %sil
jmp 0x89e52
xorl %esi, %esi
movq 0xe8(%rsp), %r9
addq %rbx, %rbp
testq %r14, %r14
movq %rsi, 0x48(%rsp)
jle 0x89e8f
cmpq $-0x1, -0x8(%rdi,%r14,8)
jne 0x89e8f
addq %rcx, %rax
decq %r14
movl -0x18(%rax), %esi
movq %r12, %rbx
cmpl $0x2, %esi
jge 0x89d5a
jmp 0x89e8f
movq 0xe8(%rsp), %r9
movq 0x10(%rsp), %r11
movq (%rsp), %rdi
movl 0x2c(%rsp), %eax
cmpl 0x70(%rsp), %eax
je 0x89fc7
testq %rbp, %rbp
movq 0x68(%rsp), %rbx
movq 0x20(%rsp), %rsi
je 0x89f08
xorps %xmm0, %xmm0
cvtsi2sd %rbp, %xmm0
cmpq $0x0, 0x18(%rsp)
movq 0x78(%rsp), %r12
je 0x89ed7
cmpq $0x1c2, %rbp            # imm = 0x1C2
jl 0x89f08
ucomisd 0x98(%rsp), %xmm0
jae 0x89ee2
jmp 0x89f08
ucomisd 0x90(%rsp), %xmm0
jb 0x89f08
movq (%rdi,%rsi,8), %rax
cmpq $-0x1, %rax
je 0x89efc
movq 0x58(%r13), %rcx
shlq $0x5, %rax
movslq 0x4(%rcx,%rax), %r12
incq %r12
incq %rsi
cmpq %r11, %rsi
jne 0x89c9e
cmpq $0x0, 0x18(%rsp)
je 0x89fa2
cmpq %r11, %rsi
movq 0x8(%rsp), %r14
movq 0x30(%rsp), %r12
movq 0xe0(%rsp), %rbp
jl 0x89fb4
movl 0x2c(%rsp), %eax
cmpl 0x70(%rsp), %eax
sete %cl
movl 0x28(%r13), %eax
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x89fb4
xorps %xmm0, %xmm0
cvtsi2sdq 0x80(%rsp), %xmm0
mulsd 0x19b593(%rip), %xmm0   # 0x2254f0
cmpl $0x1c2, %eax            # imm = 0x1C2
jb 0x89fb4
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
ucomisd %xmm0, %xmm1
jb 0x89fb4
movb $0x3, 0x2c(%r13)
addq %rax, 0x18(%r12)
cmpq $0x0, 0x48(%rsp)
jne 0x89fb4
movq 0x48(%r13), %rsi
movq 0x58(%r13), %rdi
shlq $0x5, %rsi
addq %rdi, %rsi
callq 0x46b34
movq 0xe8(%rsp), %r9
jmp 0x89fb4
movq 0x8(%rsp), %r14
movq 0x30(%rsp), %r12
movq 0xe0(%rsp), %rbp
incq %rbx
cmpq 0xa0(%rsp), %rbx
jne 0x89835
jmp 0x89fd6
movq 0x68(%rsp), %rbx
movq 0x20(%rsp), %rsi
jmp 0x89f08
cmpq $0x0, 0x18(%rsp)
je 0x8a002
cmpq $0x0, 0x18(%r12)
jle 0x8a002
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rcx
movq %r12, %rdi
movq 0x40(%rsp), %rsi
movq %rbp, %rdx
movq %r9, %r8
callq 0x4b691
movq $0x0, 0x18(%r12)
cmpq $0x0, 0x10(%r12)
jle 0x8a245
movsd 0x19b251(%rip), %xmm0   # 0x225270
subsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x19b43d(%rip), %xmm0   # 0x225470
mulsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
xorl %r13d, %r13d
movq (%r12), %rax
imulq $0xa8, %r13, %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 0x8a092
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
mulsd 0x20(%rsp), %xmm0
movl %edx, %edx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
ucomisd %xmm0, %xmm1
jae 0x8a0a5
movb $0x0, 0x2c(%rbx)
incq %r13
cmpq 0x10(%r12), %r13
jl 0x8a045
jmp 0x8a245
movq %r8, 0x60(%rsp)
movq %r13, 0x10(%rsp)
movq 0x48(%rbx), %r13
testq %r13, %r13
jle 0x8a17a
movl 0x10(%rax,%rcx), %edx
movq %rdx, 0x48(%rsp)
movl 0x1c(%rax,%rcx), %eax
movq %rax, (%rsp)
movl $0x1, %r12d
xorl %ebp, %ebp
movq 0x58(%rbx), %r15
leaq (%r15,%rbp), %r14
cmpl $0x0, 0x1c(%r15,%rbp)
je 0x8a0f2
movswl 0x10(%r15,%rbp), %eax
subl %eax, 0xc(%r15,%rbp)
jmp 0x8a12a
movq %r14, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
pushq 0x48(%rsp)
pushq 0x8(%rsp)
callq 0x9b652
addq $0x10, %rsp
cmpw $-0x1, 0x14(%r15,%rbp)
je 0x8a2d3
testq %rbp, %rbp
je 0x8a146
testq %r12, %r12
je 0x8a146
movl (%r14), %eax
movq 0x58(%rbx), %rcx
xorl %r12d, %r12d
cmpl -0x20(%rcx,%rbp), %eax
setge %r12b
addq $0x20, %rbp
decq %r13
jne 0x8a0d5
testq %r12, %r12
movq 0x8(%rsp), %r14
movq 0x30(%rsp), %r12
movq 0xe0(%rsp), %rbp
jne 0x8a17a
movq 0x48(%rbx), %rsi
movq 0x58(%rbx), %rdi
shlq $0x5, %rsi
addq %rdi, %rsi
callq 0x46b34
subq $0x8, %rsp
movq %rbx, %rdi
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movq %rbp, %rcx
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %r9
movsd 0x58(%rsp), %xmm0
movq 0xf0(%rsp), %r15
pushq %r15
callq 0x99413
addq $0x10, %rsp
movb $0x0, 0x2c(%rbx)
movsd 0x88(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0x8a1e0
movsd 0x58(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movq 0x10(%rsp), %r13
jb 0x8a096
movb $0x3, 0x2c(%rbx)
jmp 0x8a096
movq 0x60(%rsp), %rax
addq %rax, 0x18(%r12)
movb $0x1, 0x2c(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4a082
testq %r14, %r14
movq 0x10(%rsp), %r13
movq %rbx, %rdi
je 0x8a223
movq %r14, %rsi
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rcx
movsd 0x50(%rsp), %xmm0
callq 0x4a7c5
jmp 0x8a096
movq 0x18(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rcx
movsd 0x50(%rsp), %xmm0
movq %r15, %r8
callq 0x4aed4
jmp 0x8a096
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19c3c4(%rip), %rdi    # 0x226622
leaq 0x19b3de(%rip), %rsi    # 0x225643
leaq 0x19f73e(%rip), %rcx    # 0x2299aa
movl $0x10dc, %edx           # imm = 0x10DC
callq 0x2110
leaq 0x19c2ba(%rip), %rdi    # 0x226537
leaq 0x19b3bf(%rip), %rsi    # 0x225643
leaq 0x19f71f(%rip), %rcx    # 0x2299aa
movl $0x10ca, %edx           # imm = 0x10CA
callq 0x2110
leaq 0x19f623(%rip), %rdi    # 0x2298bf
leaq 0x19b3a0(%rip), %rsi    # 0x225643
leaq 0x19f700(%rip), %rcx    # 0x2299aa
movl $0x10d4, %edx           # imm = 0x10D4
callq 0x2110
leaq 0x19c367(%rip), %rdi    # 0x226622
leaq 0x19b381(%rip), %rsi    # 0x225643
leaq 0x19f6e1(%rip), %rcx    # 0x2299aa
movl $0x1103, %edx           # imm = 0x1103
callq 0x2110
leaq 0x19c339(%rip), %rdi    # 0x226613
leaq 0x19b362(%rip), %rsi    # 0x225643
leaq 0x19f6c2(%rip), %rcx    # 0x2299aa
movl $0x1135, %edx           # imm = 0x1135
callq 0x2110
leaq 0x19c31a(%rip), %rdi    # 0x226613
leaq 0x19b343(%rip), %rsi    # 0x225643
leaq 0x19f6a3(%rip), %rcx    # 0x2299aa
movl $0x10f7, %edx           # imm = 0x10F7
callq 0x2110