// File: chhylp123[P]hifiasm/Correct.cpp
// Function: non_trim_error_rate(overlap_region*, All_reads*, ul_idx_t const*, kvec_t_u64_warp const*, Correct_dumy*, UC_Read*, double, long)
inline double non_trim_error_rate(overlap_region *z, All_reads* rref, const ul_idx_t *uref, const kvec_t_u64_warp* v_idx, Correct_dumy* dumy, UC_Read* g_read, double e_rate, int64_t block_s)
{
    int64_t nw, aw = z->w_list.n, k, m, w_id, wn_id, w_s, w_e, idx_e, tErr = 0, tLen = 0, y_s, ex_beg, ex_end, err_thre, p_err_thre;
    int64_t x_len, Window_Len, y_beg_left, y_beg_right;
    unsigned int r_error_left, r_error_right; int32_t r_x_end_left, r_y_end_left, aligned_xLen_left, r_x_end_right, r_y_end_right, aligned_xLen_right;
    nw = get_num_wins(z->x_pos_s, z->x_pos_e+1, block_s);
    assert(nw >= aw && aw > 0);

    for (k = aw-1, idx_e = nw; k >= 0; k--) {
        w_id = get_win_id_by_e(z, z->w_list.a[k].x_end, block_s, &w_s);
        assert(w_s == z->w_list.a[k].x_start && w_id < idx_e && k <= w_id);
        tLen += z->w_list.a[k].x_end + 1 - z->w_list.a[k].x_start;
        tErr += z->w_list.a[k].error;///matched window
        // if(z->y_id == 1) {
        //     fprintf(stderr, "+[M::%s] ws->%d, we->%d, tot_l->%ld, tot_e->%ld\n", 
        //                         __func__, z->w_list.a[k].x_start, z->w_list.a[k].x_end, tLen, tErr);
        // }
        // if(k != w_id) z->w_list.a[w_id] = z->w_list.a[k];
        ///from mapped window w_list.a[k] to the following unmapped windows
        for (m = w_id+1, w_e = z->w_list.a[k].x_end; m < idx_e; m++) {
            w_s = w_e + 1;
            wn_id = get_win_id_by_s(z, w_s, block_s, &w_e);
            assert(wn_id == m); x_len = w_e + 1 - w_s; tLen += x_len;
            ///check if there are some windows that cannot be algined by any overlaps/unitigs
            ///if no, it is likely that the UL read itself has issues
            if(uref && v_idx && z->is_match == 4) {
                if(check_coverage_gap(v_idx->a.a, w_s, w_e, block_s)) {
                    tErr += THRESHOLD_MAX_SIZE;
                    // if(z->y_id == 1) {
                    //     fprintf(stderr, "-[M::%s] ws->%ld, we->%ld, tot_l->%ld, tot_e->%ld\n", __func__, w_s, w_e, tLen, tErr);
                    // }
                    continue;
                } 
            }
            if(!get_init_paras(rref, uref, z, w_s, w_e, e_rate, block_s, &y_s, &ex_beg, &ex_end, &err_thre)) {
                tErr += x_len;
                // if(z->y_id == 1) {
                //     fprintf(stderr, "-[M::%s] ws->%ld, we->%ld, tot_l->%ld, tot_e->%ld\n", __func__, w_s, w_e, tLen, tErr);
                // }
                continue;
            }
            p_err_thre = err_thre;

            if(rref) {
                err_thre = double_error_threshold(err_thre, x_len);
            } else {
                err_thre = double_ul_error_threshold(err_thre, x_len);
            }
            Window_Len = x_len + (err_thre << 1); 
            r_error_left = r_error_right = 0;
            aligned_xLen_left = aligned_xLen_right = 0;
            y_beg_left = y_beg_right = -1;

            if(m == w_id+1) { ///if the previous window is mapped
                y_beg_left = z->w_list.a[k].y_end + 1;///incorrect
            }

            if(m+1 == idx_e && k+1 < aw) { ///if the next window is mapped
                y_beg_right = z->w_list.a[k+1].y_start-x_len;///incorrect
            }

            if(y_beg_left == -1 && y_beg_right == -1) {
                y_beg_left = y_s;
                if(ex_beg >= 0) y_beg_left = y_beg_left + p_err_thre - ex_beg;
                y_beg_right = y_beg_left;
            }

            if(y_beg_left == -1 && y_beg_right != -1) y_beg_left = y_beg_right;
            if(y_beg_right == -1 && y_beg_left != -1) y_beg_right = y_beg_left;

            if(y_beg_left != -1) {///note: this function will change tstr/qstr
                if(rref) {
                    verify_sub_window(rref, dumy, g_read, w_s, x_len, y_beg_left, Window_Len, 
                    z->y_id, z->y_pos_strand, err_thre, 0, &r_error_left, &r_y_end_left, &r_x_end_left, &aligned_xLen_left);
                } else {
                    verify_ul_sub_window(uref, dumy, g_read, w_s, x_len, y_beg_left, Window_Len, 
                    z->y_id, z->y_pos_strand, err_thre, 0, &r_error_left, &r_y_end_left, &r_x_end_left, &aligned_xLen_left);
                }
            }

            if(y_beg_right != -1) {
                if(rref) {
                    verify_sub_window(rref, dumy, g_read, w_s, x_len, y_beg_right, Window_Len, z->y_id, z->y_pos_strand,
                    err_thre, 1, &r_error_right, &r_y_end_right, &r_x_end_right, &aligned_xLen_right);
                } else {
                    verify_ul_sub_window(uref, dumy, g_read, w_s, x_len, y_beg_right, Window_Len, z->y_id, z->y_pos_strand,
                    err_thre, 1, &r_error_right, &r_y_end_right, &r_x_end_right, &aligned_xLen_right);
                }
            }

            ///aligned in both directions
            if(aligned_xLen_left != 0 && aligned_xLen_right != 0) {
                if(aligned_xLen_left + aligned_xLen_right <= x_len) {
                    tErr += r_error_left + r_error_right + (x_len - aligned_xLen_left - aligned_xLen_right);
                } else {
                    float E_rate = (float)(x_len)/(float)(aligned_xLen_left + aligned_xLen_right);
                    tErr += (r_error_left + r_error_right)*E_rate;
                }
            }///not aligned in both directions
            else if(aligned_xLen_left == 0 && aligned_xLen_right == 0) {
                tErr += x_len;
            }///only aligned in left
            else if(aligned_xLen_left != 0) {
                tErr += r_error_left + (x_len - aligned_xLen_left);
            }///only aligned in right
            else if(aligned_xLen_right != 0) {
                tErr += r_error_right + (x_len - aligned_xLen_right);
            }
            // if(z->y_id == 1) {
            //     fprintf(stderr, "*[M::%s] qs->%ld, ts->%ld, tb[0]->%ld, tb[1]->%ld, di[0]->%u, di[1]->%u, al[0]->%d, al[1]->%d, err_thre->%ld\n", __func__, 
            //     w_s, y_s, y_beg_left, y_beg_right, r_error_left, r_error_right, aligned_xLen_left, aligned_xLen_right, err_thre);
            // }
            // if(z->y_id == 1) {
            //     fprintf(stderr, "-[M::%s] ws->%ld, we->%ld, tot_l->%ld, tot_e->%ld\n", __func__, w_s, w_e, tLen, tErr);
            // }
        }
        idx_e = w_id;
    }

    if(idx_e > 0) {
        for (m = 0, w_e = (int64_t)z->x_pos_s-1; m < idx_e; m++) {
            w_s = w_e + 1;
            wn_id = get_win_id_by_s(z, w_s, block_s, &w_e);
            assert(wn_id == m); x_len = w_e + 1 - w_s; tLen += x_len;
            ///check if there are some windows that cannot be algined by any overlaps/unitigs
            ///if no, it is likely that the UL read itself has issues
            if(uref && v_idx && z->is_match == 4) {
                if(check_coverage_gap(v_idx->a.a, w_s, w_e, block_s)) {
                    tErr += THRESHOLD_MAX_SIZE;
                    // if(z->y_id == 1) {
                    //     fprintf(stderr, "-[M::%s] ws->%ld, we->%ld, tot_l->%ld, tot_e->%ld\n", __func__, w_s, w_e, tLen, tErr);
                    // }
                    continue;
                } 
                // else {
                //     if(z->y_id == 575) {
                //         fprintf(stderr, "---[M::%s::] z::y_id->%u, w_s->%ld, w_e->%ld\n", __func__, z->y_id, w_s, w_e);
                //     } 
                // }
            }
            if(!get_init_paras(rref, uref, z, w_s, w_e, e_rate, block_s, &y_s, &ex_beg, &ex_end, &err_thre)) {
                tErr += x_len;
                // if(z->y_id == 1) {
                //     fprintf(stderr, "-[M::%s] ws->%ld, we->%ld, tot_l->%ld, tot_e->%ld\n", __func__, w_s, w_e, tLen, tErr);
                // }
                continue;
            }
            p_err_thre = err_thre;
            if(rref) {
                err_thre = double_error_threshold(err_thre, x_len);
            } else {
                err_thre = double_ul_error_threshold(err_thre, x_len);
            }
            Window_Len = x_len + (err_thre << 1); 
            r_error_left = r_error_right = 0;
            aligned_xLen_left = aligned_xLen_right = 0;
            y_beg_left = y_beg_right = -1;

            ///impossible that the previous window is mapped
            // if(m == w_id+1) { ///if the previous window is mapped
            //     y_beg_left = z->w_list.a[k].y_end + 1;
            // }

            if(m+1 == idx_e && k+1 < aw) { ///if the next window is mapped
                y_beg_right = z->w_list.a[k+1].y_start-x_len;
            }

            if(y_beg_left == -1 && y_beg_right == -1) {
                y_beg_left = y_s;
                if(ex_beg >= 0) y_beg_left = y_beg_left + p_err_thre - ex_beg;
                y_beg_right = y_beg_left;
            }

            if(y_beg_left == -1 && y_beg_right != -1) y_beg_left = y_beg_right;
            if(y_beg_right == -1 && y_beg_left != -1) y_beg_right = y_beg_left;

            if(y_beg_left != -1) {
                if(rref) {
                    verify_sub_window(rref, dumy, g_read, w_s, x_len, y_beg_left, Window_Len, 
                    z->y_id, z->y_pos_strand, err_thre, 0, &r_error_left, &r_y_end_left, &r_x_end_left, &aligned_xLen_left);
                } else {
                    verify_ul_sub_window(uref, dumy, g_read, w_s, x_len, y_beg_left, Window_Len, 
                    z->y_id, z->y_pos_strand, err_thre, 0, &r_error_left, &r_y_end_left, &r_x_end_left, &aligned_xLen_left);
                }
            }

            if(y_beg_right != -1) {
                if(rref) {
                    verify_sub_window(rref, dumy, g_read, w_s, x_len, y_beg_right, Window_Len, z->y_id, z->y_pos_strand,
                    err_thre, 1, &r_error_right, &r_y_end_right, &r_x_end_right, &aligned_xLen_right);
                } else {
                    verify_ul_sub_window(uref, dumy, g_read, w_s, x_len, y_beg_right, Window_Len, z->y_id, z->y_pos_strand,
                    err_thre, 1, &r_error_right, &r_y_end_right, &r_x_end_right, &aligned_xLen_right);
                }
            }

            ///aligned in both directions
            if(aligned_xLen_left != 0 && aligned_xLen_right != 0) {
                if(aligned_xLen_left + aligned_xLen_right <= x_len) {
                    tErr += r_error_left + r_error_right + (x_len - aligned_xLen_left - aligned_xLen_right);
                } else {
                    float E_rate = (float)(x_len)/(float)(aligned_xLen_left + aligned_xLen_right);
                    tErr += (r_error_left + r_error_right)*E_rate;
                }
            }///not aligned in both directions
            else if(aligned_xLen_left == 0 && aligned_xLen_right == 0) {
                tErr += x_len;
            }///only aligned in left
            else if(aligned_xLen_left != 0) {
                tErr += r_error_left + (x_len - aligned_xLen_left);
            }///only aligned in right
            else if(aligned_xLen_right != 0) {
                tErr += r_error_right + (x_len - aligned_xLen_right);
            }
            // if(z->y_id == 1) {
            //     fprintf(stderr, "-[M::%s] ws->%ld, we->%ld, tot_l->%ld, tot_e->%ld\n", __func__, w_s, w_e, tLen, tErr);
            // }
        }
    }
    
    assert(tLen == z->x_pos_e + 1 - z->x_pos_s);
    return (double)(tErr)/(double)(tLen);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
movq 0x10(%rbp), %rdx
callq 0x340c0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rcx
xorl %eax, %eax
cmpq -0x70(%rbp), %rcx
movb %al, -0x129(%rbp)
jl 0xc3f2b
cmpq $0x0, -0x70(%rbp)
setg %al
movb %al, -0x129(%rbp)
movb -0x129(%rbp), %al
testb $0x1, %al
jne 0xc3f37
jmp 0xc3f39
jmp 0xc3f58
leaq 0x2be455(%rip), %rdi    # 0x382395
leaq 0x2be3d4(%rip), %rsi    # 0x38231b
movl $0x43c, %edx            # imm = 0x43C
leaq 0x2c267a(%rip), %rcx    # 0x3865cd
callq 0x2130
movq -0x70(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0x78(%rbp)
jl 0xc482a
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rsi
movq 0x10(%rbp), %rdx
leaq -0x98(%rbp), %rcx
callq 0x9e250
movq %rax, -0x88(%rbp)
movq -0x98(%rbp), %rcx
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movslq (%rax), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x12a(%rbp)
jne 0xc4002
movq -0x88(%rbp), %rcx
xorl %eax, %eax
cmpq -0xa8(%rbp), %rcx
movb %al, -0x12a(%rbp)
jge 0xc4002
movq -0x78(%rbp), %rax
cmpq -0x88(%rbp), %rax
setle %al
movb %al, -0x12a(%rbp)
movb -0x12a(%rbp), %al
testb $0x1, %al
jne 0xc400e
jmp 0xc4010
jmp 0xc402f
leaq 0x2be3c7(%rip), %rdi    # 0x3823de
leaq 0x2be2fd(%rip), %rsi    # 0x38231b
movl $0x440, %edx            # imm = 0x440
leaq 0x2c25a3(%rip), %rcx    # 0x3865cd
callq 0x2130
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movq -0x30(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x78(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
subl (%rcx), %eax
cltq
addq -0xb8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswq 0x14(%rax), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x80(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jge 0xc480b
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq 0x10(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x9e2e0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x80(%rbp), %rax
jne 0xc4114
jmp 0xc4133
leaq 0x2be2fe(%rip), %rdi    # 0x382419
leaq 0x2be1f9(%rip), %rsi    # 0x38231b
movl $0x44c, %edx            # imm = 0x44C
leaq 0x2c249f(%rip), %rcx    # 0x3865cd
callq 0x2130
movq -0xa0(%rbp), %rax
addq $0x1, %rax
subq -0x98(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
addq -0xb8(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xc41ba
cmpq $0x0, -0x48(%rbp)
je 0xc41ba
movq -0x30(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x4, %eax
jne 0xc41ba
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq 0x349f0
cmpq $0x0, %rax
je 0xc41b8
movq -0xb0(%rbp), %rax
addq $0x1f, %rax
movq %rax, -0xb0(%rbp)
jmp 0xc47fa
jmp 0xc41ba
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r8
movsd -0x60(%rbp), %xmm0
movq 0x10(%rbp), %r9
leaq -0xc0(%rbp), %rbx
leaq -0xc8(%rbp), %r11
leaq -0xd0(%rbp), %r10
leaq -0xd8(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x34830
cmpl $0x0, %eax
jne 0xc4230
movq -0xe8(%rbp), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc47fa
movq -0xd8(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xc4267
movq -0xd8(%rbp), %rax
movl %eax, %edi
movq -0xe8(%rbp), %rax
movl %eax, %esi
callq 0x9e370
cltq
movq %rax, -0xd8(%rbp)
jmp 0xc4287
movq -0xd8(%rbp), %rax
movl %eax, %edi
movq -0xe8(%rbp), %rax
movl %eax, %esi
callq 0x9f400
cltq
movq %rax, -0xd8(%rbp)
movq -0xe8(%rbp), %rax
movq -0xd8(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movl $0x0, -0x108(%rbp)
movl $0x0, -0x104(%rbp)
movl $0x0, -0x120(%rbp)
movl $0x0, -0x114(%rbp)
movq $-0x1, -0x100(%rbp)
movq $-0x1, -0xf8(%rbp)
movq -0x80(%rbp), %rax
movq -0x88(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0xc4316
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0xf8(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
cmpq -0xa8(%rbp), %rax
jne 0xc435e
movq -0x78(%rbp), %rax
addq $0x1, %rax
cmpq -0x70(%rbp), %rax
jge 0xc435e
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
subq -0xe8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $-0x1, -0xf8(%rbp)
jne 0xc43b4
cmpq $-0x1, -0x100(%rbp)
jne 0xc43b4
movq -0xc0(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xc8(%rbp)
jl 0xc43a6
movq -0xf8(%rbp), %rax
addq -0xe0(%rbp), %rax
subq -0xc8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $-0x1, -0xf8(%rbp)
jne 0xc43d6
cmpq $-0x1, -0x100(%rbp)
je 0xc43d6
movq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $-0x1, -0x100(%rbp)
jne 0xc43f8
cmpq $-0x1, -0xf8(%rbp)
je 0xc43f8
movq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $-0x1, -0xf8(%rbp)
je 0xc4548
cmpq $0x0, -0x38(%rbp)
je 0xc44ae
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0xf8(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
xorl %eax, %eax
leaq -0x104(%rbp), %rbx
leaq -0x110(%rbp), %r11
leaq -0x10c(%rbp), %r10
leaq -0x114(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc4fe0
jmp 0xc4546
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0xf8(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
xorl %eax, %eax
leaq -0x104(%rbp), %rbx
leaq -0x110(%rbp), %r11
leaq -0x10c(%rbp), %r10
leaq -0x114(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc5190
jmp 0xc4548
cmpq $-0x1, -0x100(%rbp)
je 0xc4694
cmpq $0x0, -0x38(%rbp)
je 0xc45fc
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0x100(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
leaq -0x108(%rbp), %rbx
leaq -0x11c(%rbp), %r11
leaq -0x118(%rbp), %r10
leaq -0x120(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc4fe0
jmp 0xc4692
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0x100(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
leaq -0x108(%rbp), %rbx
leaq -0x11c(%rbp), %r11
leaq -0x118(%rbp), %r10
leaq -0x120(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc5190
jmp 0xc4694
cmpl $0x0, -0x114(%rbp)
je 0xc4765
cmpl $0x0, -0x120(%rbp)
je 0xc4765
movl -0x114(%rbp), %eax
addl -0x120(%rbp), %eax
cltq
cmpq -0xe8(%rbp), %rax
jg 0xc4701
movl -0x104(%rbp), %eax
addl -0x108(%rbp), %eax
movl %eax, %eax
movq -0xe8(%rbp), %rcx
movslq -0x114(%rbp), %rdx
subq %rdx, %rcx
movslq -0x120(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4760
cvtsi2ssq -0xe8(%rbp), %xmm0
movl -0x114(%rbp), %eax
movl -0x120(%rbp), %ecx
addl %ecx, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x124(%rbp)
movl -0x104(%rbp), %eax
movl -0x108(%rbp), %ecx
addl %ecx, %eax
cvtsi2ss %rax, %xmm0
movss -0x124(%rbp), %xmm2
cvtsi2ssq -0xb0(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movq %rax, -0xb0(%rbp)
jmp 0xc47f8
cmpl $0x0, -0x114(%rbp)
jne 0xc478e
cmpl $0x0, -0x120(%rbp)
jne 0xc478e
movq -0xe8(%rbp), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc47f6
cmpl $0x0, -0x114(%rbp)
je 0xc47c1
movl -0x104(%rbp), %eax
movq -0xe8(%rbp), %rcx
movslq -0x114(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc47f4
cmpl $0x0, -0x120(%rbp)
je 0xc47f2
movl -0x108(%rbp), %eax
movq -0xe8(%rbp), %rcx
movslq -0x120(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc47f4
jmp 0xc47f6
jmp 0xc47f8
jmp 0xc47fa
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0xc40c0
movq -0x88(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0xc3f6f
cmpq $0x0, -0xa8(%rbp)
jle 0xc4f69
movq $0x0, -0x80(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
subq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0x80(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jge 0xc4f67
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq 0x10(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x9e2e0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x80(%rbp), %rax
jne 0xc48a6
jmp 0xc48c5
leaq 0x2bdb6c(%rip), %rdi    # 0x382419
leaq 0x2bda67(%rip), %rsi    # 0x38231b
movl $0x4b1, %edx            # imm = 0x4B1
leaq 0x2c1d0d(%rip), %rcx    # 0x3865cd
callq 0x2130
movq -0xa0(%rbp), %rax
addq $0x1, %rax
subq -0x98(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
addq -0xb8(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xc494c
cmpq $0x0, -0x48(%rbp)
je 0xc494c
movq -0x30(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x4, %eax
jne 0xc494c
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq 0x349f0
cmpq $0x0, %rax
je 0xc494a
movq -0xb0(%rbp), %rax
addq $0x1f, %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4f56
jmp 0xc494c
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r8
movsd -0x60(%rbp), %xmm0
movq 0x10(%rbp), %r9
leaq -0xc0(%rbp), %rbx
leaq -0xc8(%rbp), %r11
leaq -0xd0(%rbp), %r10
leaq -0xd8(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x34830
cmpl $0x0, %eax
jne 0xc49c2
movq -0xe8(%rbp), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4f56
movq -0xd8(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xc49f9
movq -0xd8(%rbp), %rax
movl %eax, %edi
movq -0xe8(%rbp), %rax
movl %eax, %esi
callq 0x9e370
cltq
movq %rax, -0xd8(%rbp)
jmp 0xc4a19
movq -0xd8(%rbp), %rax
movl %eax, %edi
movq -0xe8(%rbp), %rax
movl %eax, %esi
callq 0x9f400
cltq
movq %rax, -0xd8(%rbp)
movq -0xe8(%rbp), %rax
movq -0xd8(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movl $0x0, -0x108(%rbp)
movl $0x0, -0x104(%rbp)
movl $0x0, -0x120(%rbp)
movl $0x0, -0x114(%rbp)
movq $-0x1, -0x100(%rbp)
movq $-0x1, -0xf8(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
cmpq -0xa8(%rbp), %rax
jne 0xc4aba
movq -0x78(%rbp), %rax
addq $0x1, %rax
cmpq -0x70(%rbp), %rax
jge 0xc4aba
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
subq -0xe8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $-0x1, -0xf8(%rbp)
jne 0xc4b10
cmpq $-0x1, -0x100(%rbp)
jne 0xc4b10
movq -0xc0(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xc8(%rbp)
jl 0xc4b02
movq -0xf8(%rbp), %rax
addq -0xe0(%rbp), %rax
subq -0xc8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $-0x1, -0xf8(%rbp)
jne 0xc4b32
cmpq $-0x1, -0x100(%rbp)
je 0xc4b32
movq -0x100(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $-0x1, -0x100(%rbp)
jne 0xc4b54
cmpq $-0x1, -0xf8(%rbp)
je 0xc4b54
movq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpq $-0x1, -0xf8(%rbp)
je 0xc4ca4
cmpq $0x0, -0x38(%rbp)
je 0xc4c0a
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0xf8(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
xorl %eax, %eax
leaq -0x104(%rbp), %rbx
leaq -0x110(%rbp), %r11
leaq -0x10c(%rbp), %r10
leaq -0x114(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc4fe0
jmp 0xc4ca2
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0xf8(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
xorl %eax, %eax
leaq -0x104(%rbp), %rbx
leaq -0x110(%rbp), %r11
leaq -0x10c(%rbp), %r10
leaq -0x114(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc5190
jmp 0xc4ca4
cmpq $-0x1, -0x100(%rbp)
je 0xc4df0
cmpq $0x0, -0x38(%rbp)
je 0xc4d58
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0x100(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
leaq -0x108(%rbp), %rbx
leaq -0x11c(%rbp), %r11
leaq -0x118(%rbp), %r10
leaq -0x120(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc4fe0
jmp 0xc4dee
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xe8(%rbp), %r8
movq -0x100(%rbp), %r9
movq -0xf0(%rbp), %r13
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %r15d
movq -0xd8(%rbp), %rax
movl %eax, %r14d
leaq -0x108(%rbp), %rbx
leaq -0x11c(%rbp), %r11
leaq -0x118(%rbp), %r10
leaq -0x120(%rbp), %rax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0xc5190
jmp 0xc4df0
cmpl $0x0, -0x114(%rbp)
je 0xc4ec1
cmpl $0x0, -0x120(%rbp)
je 0xc4ec1
movl -0x114(%rbp), %eax
addl -0x120(%rbp), %eax
cltq
cmpq -0xe8(%rbp), %rax
jg 0xc4e5d
movl -0x104(%rbp), %eax
addl -0x108(%rbp), %eax
movl %eax, %eax
movq -0xe8(%rbp), %rcx
movslq -0x114(%rbp), %rdx
subq %rdx, %rcx
movslq -0x120(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4ebc
cvtsi2ssq -0xe8(%rbp), %xmm0
movl -0x114(%rbp), %eax
movl -0x120(%rbp), %ecx
addl %ecx, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x128(%rbp)
movl -0x104(%rbp), %eax
movl -0x108(%rbp), %ecx
addl %ecx, %eax
cvtsi2ss %rax, %xmm0
movss -0x128(%rbp), %xmm2
cvtsi2ssq -0xb0(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4f54
cmpl $0x0, -0x114(%rbp)
jne 0xc4eea
cmpl $0x0, -0x120(%rbp)
jne 0xc4eea
movq -0xe8(%rbp), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4f52
cmpl $0x0, -0x114(%rbp)
je 0xc4f1d
movl -0x104(%rbp), %eax
movq -0xe8(%rbp), %rcx
movslq -0x114(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4f50
cmpl $0x0, -0x120(%rbp)
je 0xc4f4e
movl -0x108(%rbp), %eax
movq -0xe8(%rbp), %rcx
movslq -0x120(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0xc4f50
jmp 0xc4f52
jmp 0xc4f54
jmp 0xc4f56
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0xc4852
jmp 0xc4f69
movq -0xb8(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl $0x1, %ecx
movq -0x30(%rbp), %rdx
subl 0x4(%rdx), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0xc4f8a
jmp 0xc4fa9
leaq 0x2c16cd(%rip), %rdi    # 0x38665e
leaq 0x2bd383(%rip), %rsi    # 0x38231b
movl $0x512, %edx            # imm = 0x512
leaq 0x2c1629(%rip), %rcx    # 0x3865cd
callq 0x2130
cvtsi2sdq -0xb0(%rbp), %xmm0
cvtsi2sdq -0xb8(%rbp), %xmm1
divsd %xmm1, %xmm0
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)