// File: chhylp123[P]hifiasm/Correct.cpp
// Function: calculate_boundary_cigars(overlap_region*, All_reads*, Correct_dumy*, UC_Read*, double)
void calculate_boundary_cigars(overlap_region* z, All_reads* R_INF, Correct_dumy* dumy, UC_Read* g_read, double e_rate)
{
    assert(z->w_list.n > 0);
    int64_t nw = z->w_list.n;
    resize_window_list_alloc(&(z->boundary_cigars), nw - 1);
    int64_t y_id = z->y_id, y_strand = z->y_pos_strand;
    int64_t y_readLen = Get_READ_LENGTH((*R_INF), y_id);
    int64_t i, y_distance, f_err = -1, b_err = -1, m_error;
    int64_t scanLen = 10, boundaryLen = 200;
    int64_t single_sideLen = boundaryLen/2;
    int64_t force_useless_side = single_sideLen/2;
    int64_t L_useless_side, R_useless_side, alpha = 1;
    long long y_start, x_start, x_end, yLen, xLen, leftLen, rightLen, threshold, o_len;
    char *x_string = NULL, *y_string = NULL;
    int end_site, real_y_start, extra_begin, extra_end;
    unsigned int error;
    z->boundary_cigars.n = nw - 1;
    ///the (i)-th boundary between the (i)-th window and the (i+1)-th window
    ///that means it includes (the tail of (i)-th window) and (the header of (i+1)-th window)
    ///note the (i)-th boundary is calculated at the (i)-th window
    for (i = 0; i + 1 < nw; i++) {
        ///if both of the two windows are not aligned
        ///it is not necessary to calculate the boundary
        if(z->w_list.a[i].y_end == -1 || z->w_list.a[i+1].y_end == -1) {
            z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
            continue;
        }
        ///y_distance can be less than 0, or larger than 0
        y_distance = (int64_t)z->w_list.a[i+1].y_start - (int64_t)z->w_list.a[i].y_end - 1;

        ///if two windows are aligned
        if(z->w_list.a[i].y_end != -1 && z->w_list.a[i+1].y_end != -1 && y_distance == 0) {
            ///scan backward
            scan_cigar(&(z->w_list.a[i]), &(z->w_list), &b_err, scanLen, 1);
            ///scan forward
            scan_cigar(&(z->w_list.a[i+1]), &(z->w_list), &f_err, scanLen, 0);
            if(b_err == 0 && f_err == 0) {
                z->boundary_cigars.a[i].error = -2; z->boundary_cigars.a[i].y_end = -1;
                continue;
            }
        }

        
        if(z->w_list.a[i].y_end != -1) {
            y_start = z->w_list.a[i].y_end; x_start = z->w_list.a[i].x_end;
        }///if the (i)-th window is not matched, have a look at the (i+1)-th window
        else if(z->w_list.a[i+1].y_end != -1) {
            y_start = z->w_list.a[i+1].y_start; x_start = z->w_list.a[i+1].x_start;
        }///if both of these two windows are not matched, directly skip
        else {
            z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
            continue;
        }

        ///it seems we don't need to record x_start and y_start
        z->boundary_cigars.a[i].extra_begin = x_start;
        z->boundary_cigars.a[i].extra_end = y_start;

        ///leftLen and rightLen are used for x        
        ///x should be at [sub_list->w_list[i].x_start, sub_list->w_list[i+1].x_end]
        ///y shouldn't have limitation
        ///note that the x_start and x_end should not be -1 in any case
        ///up to now, x_start and y_start are not -1
        ///leftLen does not include x_start itself, rightLen does
        ///gnerally speaking, rightLen should be always larger than leftLen
        leftLen = MIN(MIN((x_start - (int64_t)z->w_list.a[i].x_start), y_start), single_sideLen);
        rightLen = MIN(MIN(((int64_t)z->w_list.a[i+1].x_end + 1 - x_start), y_readLen - y_start), single_sideLen);

        ///xLen should be the sum length of two windows
        xLen = leftLen + rightLen;
        x_start = x_start - leftLen;
        x_end = x_start + xLen - 1;
        y_start = y_start - leftLen;

        ///if we don't have enough leftLen and rightLen
        // if(leftLen <= useless_side || rightLen <= useless_side)
        // {
        //     sub_list->boundary_cigars.buffer[i].error = -1;
        //     sub_list->boundary_cigars.buffer[i].y_end = -1;
        //     continue;
        // }


        threshold = xLen * e_rate/**asm_opt.max_ov_diff_ec**/;
        threshold = Adjust_Threshold(threshold, xLen);
        threshold = double_error_threshold(threshold, xLen);

        yLen = xLen + (threshold << 1);
        if(!determine_overlap_region(threshold, y_start, y_id, yLen, Get_READ_LENGTH((*R_INF), y_id), 
                    &extra_begin, &extra_end, &y_start, &o_len)) {
            z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
            continue;
        }

        if(o_len < xLen) {
            z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
            continue;
        }

        fill_subregion(dumy->overlap_region, y_start, o_len, y_strand, R_INF, y_id, extra_begin, extra_end);
        
        x_string = g_read->seq + x_start;
        y_string = dumy->overlap_region;

        end_site = Reserve_Banded_BPM_PATH(y_string, yLen, x_string, xLen, threshold, &error, 
        &real_y_start, &(dumy->path_length), dumy->matrix_bit, dumy->path, -1, -1);

        ///means this window is matched
        if (error!=(unsigned int)-1) {
            z->boundary_cigars.a[i].x_start = x_start;
            z->boundary_cigars.a[i].x_end = x_end;

            generate_cigar(dumy->path, dumy->path_length, &(z->boundary_cigars.a[i]), &(z->boundary_cigars),
                        &real_y_start, &end_site, &error, x_string, xLen, y_string);
            ///should not adjust cigar here, adjust cigar may cause problem
            ///that is not what we want

            ///y_distance can be less than 0, or larger than 0
            ///please if one of the two windows is not matched, 
            ///y_distance may have potential problems 
            if(y_distance < 0) y_distance = y_distance * (-1);
            ///leftLen, rightLen
            // if(leftLen <= useless_side || rightLen <= useless_side)
            // {
            //     sub_list->boundary_cigars.buffer[i].error = -1;
            //     sub_list->boundary_cigars.buffer[i].y_end = -1;
            //     continue;
            // }
            L_useless_side = R_useless_side = force_useless_side;

            ///first window
            if((i == 0) && (x_start == (int64_t)z->w_list.a[0].x_start)) {
                L_useless_side = 0;
            }
            ///last window
            if((i == (int64_t)(z->w_list.n) - 2) && 
                    (x_end == (long long)(z->w_list.a[(int64_t)(z->w_list.n)-1].x_end))) {
                R_useless_side = 0;
            }

            if(leftLen <= L_useless_side || rightLen <= R_useless_side) {
                z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
                z->boundary_cigars.c.n = z->boundary_cigars.a[i].cidx;
                continue;
            }



            ///up to now, if we require (i)-th window and (i+1)-th window are matched
            ///boundary_cigars.buffer[i].cigar, w_list[i].cigar and w_list[i+1].cigar are avaiable
            ///get the error excluding the first and the last useless_side bases
            scan_cigar_interval(&(z->boundary_cigars.a[i]), &(z->boundary_cigars), &m_error, L_useless_side, xLen-R_useless_side-1);
            scan_cigar(&(z->w_list.a[i]), &(z->w_list), &b_err, leftLen-L_useless_side, 1);
            scan_cigar(&(z->w_list.a[i+1]), &(z->w_list), &f_err, rightLen-R_useless_side, 0);

            if(f_err + b_err + y_distance + alpha < m_error) {
                z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
                z->boundary_cigars.c.n = z->boundary_cigars.a[i].cidx;
                continue;
            }

            z->boundary_cigars.a[i].error = error;
            z->boundary_cigars.a[i].y_start = y_start + real_y_start - extra_begin;
            z->boundary_cigars.a[i].y_end = y_start + end_site - extra_begin;

            z->boundary_cigars.a[i].x_start = x_start;
            z->boundary_cigars.a[i].x_end = x_end;
            ///sub_list->boundary_cigars.buffer[i].error_threshold = useless_side;
            z->boundary_cigars.a[i].extra_begin = L_useless_side;
            z->boundary_cigars.a[i].extra_end = R_useless_side;
        }
        else {
            z->boundary_cigars.a[i].error = -1; z->boundary_cigars.a[i].y_end = -1;
            continue;
        }     
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x359be
jmp 0x359dd
leaq 0x34ca5f(%rip), %rdi    # 0x382424
leaq 0x34c94f(%rip), %rsi    # 0x38231b
movl $0xa31, %edx            # imm = 0xA31
leaq 0x34ca5c(%rip), %rcx    # 0x382434
callq 0x2130
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
addq $0x78, %rdi
movq -0x38(%rbp), %rsi
subq $0x1, %rsi
callq 0x231a0
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq $-0x1, -0x68(%rbp)
movq $-0x1, -0x70(%rbp)
movq $0xa, -0x80(%rbp)
movq $0xc8, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0x98(%rbp)
movq $0x1, -0xb0(%rbp)
movq $0x0, -0x100(%rbp)
movq $0x0, -0x108(%rbp)
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
cmpq -0x38(%rbp), %rax
jge 0x36720
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x35afc
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
jne 0x35b3a
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x3670f
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0xc(%rcx), %rcx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x35c6d
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x35c6d
cmpq $0x0, -0x60(%rbp)
jne 0x35c6d
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x58(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0x80(%rbp), %rcx
leaq -0x70(%rbp), %rdx
movl $0x1, %r8d
callq 0x350a0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x58(%rbp), %rax
addq $0x1, %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0x80(%rbp), %rcx
leaq -0x68(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
callq 0x350a0
cmpq $0x0, -0x70(%rbp)
jne 0x35c6b
cmpq $0x0, -0x68(%rbp)
jne 0x35c6b
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xfffe, 0x14(%rax)     # imm = 0xFFFE
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x3670f
jmp 0x35c6d
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x35cc7
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0xc(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x35d69
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x35d29
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0xc0(%rbp)
jmp 0x35d67
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x3670f
jmp 0x35d69
movq -0xc0(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x10(%rax)
movq -0xb8(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x12(%rax)
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
cmpq -0xb8(%rbp), %rax
jg 0x35e03
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x128(%rbp)
jmp 0x35e11
movq -0xb8(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
cmpq -0x90(%rbp), %rax
jg 0x35e91
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
cmpq -0xb8(%rbp), %rax
jg 0x35e73
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x130(%rbp)
jmp 0x35e81
movq -0xb8(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x35e9f
movq -0x90(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc0(%rbp), %rax
movq -0x50(%rbp), %rcx
subq -0xb8(%rbp), %rcx
cmpq %rcx, %rax
jg 0x35f12
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc0(%rbp), %rax
movq %rax, -0x140(%rbp)
jmp 0x35f24
movq -0x50(%rbp), %rax
subq -0xb8(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
cmpq -0x90(%rbp), %rax
jg 0x35fbf
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc0(%rbp), %rax
movq -0x50(%rbp), %rcx
subq -0xb8(%rbp), %rcx
cmpq %rcx, %rax
jg 0x35f9d
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc0(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x35faf
movq -0x50(%rbp), %rax
subq -0xb8(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x150(%rbp)
jmp 0x35fcd
movq -0x90(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
addq -0xe8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xc0(%rbp), %rax
subq -0xe0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
addq -0xd8(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0xb8(%rbp), %rax
subq -0xe0(%rbp), %rax
movq %rax, -0xb8(%rbp)
cvtsi2sdq -0xd8(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xf0(%rbp)
jne 0x3606f
cmpq $0x4, -0xd8(%rbp)
jl 0x3606f
movl $0x1, %eax
movq %rax, -0x158(%rbp)
jmp 0x3607d
movq -0xf0(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movl %eax, %edi
movq -0xd8(%rbp), %rax
movl %eax, %esi
callq 0x9e370
cltq
movq %rax, -0xf0(%rbp)
movq -0xd8(%rbp), %rax
movq -0xf0(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xf0(%rbp), %rax
movl %eax, %edi
movq -0xb8(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0xd0(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %r8
movq (%rax,%r8,8), %r8
leaq -0x114(%rbp), %r9
leaq -0x118(%rbp), %r11
leaq -0xb8(%rbp), %r10
leaq -0xf8(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x32290
cmpl $0x0, %eax
jne 0x36163
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x3670f
movq -0xf8(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jge 0x361b1
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x3670f
movq -0x20(%rbp), %rdi
addq $0x50, %rdi
movq -0xb8(%rbp), %rsi
movq -0xf8(%rbp), %rdx
movq -0x48(%rbp), %rax
movb %al, %cl
movq -0x18(%rbp), %r8
movq -0x40(%rbp), %r9
movl -0x114(%rbp), %r10d
movl -0x118(%rbp), %eax
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x32160
movq -0x28(%rbp), %rax
movq (%rax), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rdi
movq -0xd0(%rbp), %rax
movl %eax, %esi
movq -0x100(%rbp), %rdx
movq -0xd8(%rbp), %rax
movl %eax, %ecx
movq -0xf0(%rbp), %rax
movw %ax, %r8w
movq -0x20(%rbp), %r11
addq $0x7d70, %r11           # imm = 0x7D70
movq -0x20(%rbp), %r10
addq $0xff0, %r10            # imm = 0xFF0
movq -0x20(%rbp), %rax
addq $0xa14, %rax            # imm = 0xA14
leaq -0x11c(%rbp), %r9
leaq -0x110(%rbp), %rbx
movzwl %r8w, %r8d
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movl $0xffffffff, 0x20(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
callq 0x9e3d0
movl %eax, -0x10c(%rbp)
cmpl $-0x1, -0x11c(%rbp)
je 0x366d2
movq -0xc0(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rdi
addq $0xa14, %rdi            # imm = 0xA14
movq -0x20(%rbp), %rax
movl 0x7d70(%rax), %esi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdx
movq -0x58(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rcx
addq $0x78, %rcx
movq -0x100(%rbp), %r11
movq -0xd8(%rbp), %rax
movl %eax, %r10d
movq -0x108(%rbp), %rax
leaq -0x110(%rbp), %r8
leaq -0x10c(%rbp), %r9
leaq -0x11c(%rbp), %rbx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x9f0f0
cmpq $0x0, -0x60(%rbp)
jge 0x36379
imulq $-0x1, -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x363b7
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jne 0x363b7
movq $0x0, -0xa0(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jne 0x36402
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x10(%rbp), %rdx
movq 0x48(%rdx), %rdx
subq $0x1, %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x4(%rcx), %rcx
cmpq %rcx, %rax
jne 0x36402
movq $0x0, -0xa8(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jle 0x36422
movq -0xe8(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jg 0x36486
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
jmp 0x3670f
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x58(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x78, %rsi
movq -0xa0(%rbp), %rcx
movq -0xd8(%rbp), %r8
subq -0xa8(%rbp), %r8
subq $0x1, %r8
leaq -0x78(%rbp), %rdx
callq 0x35420
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x58(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0xe0(%rbp), %rcx
subq -0xa0(%rbp), %rcx
leaq -0x70(%rbp), %rdx
movl $0x1, %r8d
callq 0x350a0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x58(%rbp), %rax
addq $0x1, %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0xe8(%rbp), %rcx
subq -0xa8(%rbp), %rcx
leaq -0x68(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
callq 0x350a0
movq -0x68(%rbp), %rax
addq -0x70(%rbp), %rax
addq -0x60(%rbp), %rax
addq -0xb0(%rbp), %rax
cmpq -0x78(%rbp), %rax
jge 0x365b6
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
jmp 0x3670f
movl -0x11c(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x14(%rax)
movq -0xb8(%rbp), %rax
movslq -0x110(%rbp), %rcx
addq %rcx, %rax
movslq -0x114(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0xb8(%rbp), %rax
movslq -0x10c(%rbp), %rcx
addq %rcx, %rax
movslq -0x114(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0xc0(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0xa0(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x10(%rax)
movq -0xa8(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x12(%rax)
jmp 0x3670d
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x58(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x3670f
jmp 0x3670f
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x35ab4
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %rbp
retq
nopw (%rax,%rax)