// File: chhylp123[P]hifiasm/Correct.cpp
// Function: calculate_ul_boundary_cigars(overlap_region*, ul_idx_t const*, Correct_dumy*, UC_Read*, double, long long)
void calculate_ul_boundary_cigars(overlap_region* z, const ul_idx_t *uref, Correct_dumy* dumy, 
UC_Read* g_read, double max_ov_diff_ec, long long blockLen)
{
    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;
    int64_t y_strand = z->y_pos_strand;
    int64_t y_readLen = uref->ug->u.a[y_id].len;
    int64_t i, y_distance;
    int64_t f_err, b_err, m_error, scanLen = 10;
    int64_t boundaryLen = WINDOW_UL_BOUND_RATE*blockLen;
    boundaryLen >>= 2; boundaryLen <<= 2;
    if(boundaryLen < WINDOW_UL_BOUND) boundaryLen = WINDOW_UL_BOUND;
    int64_t single_sideLen = boundaryLen/2;
    int64_t force_useless_side = single_sideLen/2;
    int64_t L_useless_side, R_useless_side;
    int64_t alpha = 1;
    long long y_start, x_start, x_end, yLen, xLen, leftLen, rightLen, threshold, o_len;
    int extra_begin, extra_end, end_site, real_y_start;
    char* x_string;
    char* y_string;
    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(sub_list->w_list[i].y_end == -1 && sub_list->w_list[i+1].y_end == -1)
        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;
        }

        ///note if w_list[i+1].y_start or sub_list->w_list[i].y_end is -1
        ///y_distance might have some problems at the last of this function
        ///we need to deal with it carefully
        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;
            }
        }


        ///y_distance can be less than 0, or larger than 0
        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 - (long long)z->w_list.a[i].x_start), y_start), single_sideLen);
        rightLen = MIN(MIN(((long long)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 * max_ov_diff_ec;
        threshold = Adjust_Threshold(threshold, xLen);
        threshold = double_ul_error_threshold(threshold, xLen);

        yLen = xLen + (threshold << 1);
        if(!determine_overlap_region(threshold, y_start, y_id, yLen, uref->ug->u.a[y_id].len, 
                    &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_ul(dumy->overlap_region, y_start, o_len, y_strand, 
                    uref, 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 == (long long)z->w_list.a[0].x_start)) {
                L_useless_side = 0;
            }
            ///last window
            if((i == (int64_t)(z->w_list.n) - 2) && (x_end == (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 %r8, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x36762
jmp 0x36781
leaq 0x34bcbb(%rip), %rdi    # 0x382424
leaq 0x34bbab(%rip), %rsi    # 0x38231b
movl $0xae6, %edx            # imm = 0xAE6
leaq 0x34bd19(%rip), %rcx    # 0x382495
callq 0x2130
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
addq $0x78, %rdi
movq -0x40(%rbp), %rsi
subq $0x1, %rsi
callq 0x231a0
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x48(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x58(%rbp)
movq $0xa, -0x88(%rbp)
cvtsi2sdq -0x38(%rbp), %xmm1
movsd 0x34ba17(%rip), %xmm0   # 0x382208
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
sarq $0x2, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x90(%rbp)
cmpq $0x30, -0x90(%rbp)
jge 0x3683a
movq $0x30, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0xa0(%rbp)
movq $0x1, -0xb8(%rbp)
movq -0x40(%rbp), %rcx
subq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
cmpq -0x40(%rbp), %rax
jge 0x3750e
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x368d5
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
jne 0x36913
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x374fd
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0xc(%rcx), %rcx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x36a4c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x36a4c
cmpq $0x0, -0x68(%rbp)
jne 0x36a4c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x60(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0x88(%rbp), %rcx
leaq -0x78(%rbp), %rdx
movl $0x1, %r8d
callq 0x350a0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x60(%rbp), %rax
addq $0x1, %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0x88(%rbp), %rcx
leaq -0x70(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
callq 0x350a0
cmpq $0x0, -0x78(%rbp)
jne 0x36a4a
cmpq $0x0, -0x70(%rbp)
jne 0x36a4a
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xfffe, 0x14(%rax)     # imm = 0xFFFE
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x374fd
jmp 0x36a4c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x36aa6
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0xc(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0xc8(%rbp)
jmp 0x36b48
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $-0x1, 0xc(%rax)
je 0x36b08
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0xc8(%rbp)
jmp 0x36b46
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x374fd
jmp 0x36b48
movq -0xc8(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x10(%rax)
movq -0xc0(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x12(%rax)
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
cmpq -0xc0(%rbp), %rax
jg 0x36be2
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x130(%rbp)
jmp 0x36bf0
movq -0xc0(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
cmpq -0x98(%rbp), %rax
jg 0x36c70
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
cmpq -0xc0(%rbp), %rax
jg 0x36c52
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x138(%rbp)
jmp 0x36c60
movq -0xc0(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0x140(%rbp)
jmp 0x36c7e
movq -0x98(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc8(%rbp), %rax
movq -0x58(%rbp), %rcx
subq -0xc0(%rbp), %rcx
cmpq %rcx, %rax
jg 0x36cf1
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc8(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x36d03
movq -0x58(%rbp), %rax
subq -0xc0(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
cmpq -0x98(%rbp), %rax
jg 0x36d9e
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc8(%rbp), %rax
movq -0x58(%rbp), %rcx
subq -0xc0(%rbp), %rcx
cmpq %rcx, %rax
jg 0x36d7c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x60(%rbp), %rcx
addq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0xc8(%rbp), %rax
movq %rax, -0x150(%rbp)
jmp 0x36d8e
movq -0x58(%rbp), %rax
subq -0xc0(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x36dac
movq -0x98(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rax
addq -0xf0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xc8(%rbp), %rax
subq -0xe8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
addq -0xe0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xd0(%rbp)
movq -0xc0(%rbp), %rax
subq -0xe8(%rbp), %rax
movq %rax, -0xc0(%rbp)
cvtsi2sdq -0xe0(%rbp), %xmm0
mulsd -0x30(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
jne 0x36e4e
cmpq $0x4, -0xe0(%rbp)
jl 0x36e4e
movl $0x1, %eax
movq %rax, -0x160(%rbp)
jmp 0x36e5c
movq -0xf8(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movl %eax, %edi
movq -0xe0(%rbp), %rax
movl %eax, %esi
callq 0x9f400
cltq
movq %rax, -0xf8(%rbp)
movq -0xe0(%rbp), %rax
movq -0xf8(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0xf8(%rbp), %rax
movl %eax, %edi
movq -0xc0(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0xd8(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x48(%rbp), %r8
addq %r8, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r8d
leaq -0x104(%rbp), %r9
leaq -0x108(%rbp), %r11
leaq -0xc0(%rbp), %r10
leaq -0x100(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x32290
cmpl $0x0, %eax
jne 0x36f51
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x374fd
movq -0x100(%rbp), %rax
cmpq -0xe0(%rbp), %rax
jge 0x36f9f
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x374fd
movq -0x20(%rbp), %rdi
addq $0x50, %rdi
movq -0xc0(%rbp), %rsi
movq -0x100(%rbp), %rdx
movq -0x50(%rbp), %rax
movb %al, %cl
movq -0x18(%rbp), %r8
movq -0x48(%rbp), %r9
movl -0x104(%rbp), %r10d
movl -0x108(%rbp), %eax
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x321f0
movq -0x28(%rbp), %rax
movq (%rax), %rax
addq -0xc8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x20(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
movq -0xd8(%rbp), %rax
movl %eax, %esi
movq -0x118(%rbp), %rdx
movq -0xe0(%rbp), %rax
movl %eax, %ecx
movq -0xf8(%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 -0x124(%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, -0x124(%rbp)
je 0x374c0
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0xd0(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%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 -0x60(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rcx
addq $0x78, %rcx
movq -0x118(%rbp), %r11
movq -0xe0(%rbp), %rax
movl %eax, %r10d
movq -0x120(%rbp), %rax
leaq -0x110(%rbp), %r8
leaq -0x10c(%rbp), %r9
leaq -0x124(%rbp), %rbx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x9f0f0
cmpq $0x0, -0x68(%rbp)
jge 0x37167
imulq $-0x1, -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x371a5
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movslq (%rcx), %rcx
cmpq %rcx, %rax
jne 0x371a5
movq $0x0, -0xa8(%rbp)
movq -0x60(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jne 0x371f0
movq -0xd0(%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 0x371f0
movq $0x0, -0xb0(%rbp)
movq -0xe8(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jle 0x37210
movq -0xf0(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jg 0x37274
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
jmp 0x374fd
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x60(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x78, %rsi
movq -0xa8(%rbp), %rcx
movq -0xe0(%rbp), %r8
subq -0xb0(%rbp), %r8
subq $0x1, %r8
leaq -0x80(%rbp), %rdx
callq 0x35420
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x60(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0xe8(%rbp), %rcx
subq -0xa8(%rbp), %rcx
leaq -0x78(%rbp), %rdx
movl $0x1, %r8d
callq 0x350a0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x60(%rbp), %rax
addq $0x1, %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
movq -0xf0(%rbp), %rcx
subq -0xb0(%rbp), %rcx
leaq -0x70(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
callq 0x350a0
movq -0x70(%rbp), %rax
addq -0x78(%rbp), %rax
addq -0x68(%rbp), %rax
addq -0xb8(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0x373a4
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
jmp 0x374fd
movl -0x124(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x14(%rax)
movq -0xc0(%rbp), %rax
movslq -0x110(%rbp), %rcx
addq %rcx, %rax
movslq -0x104(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0xc0(%rbp), %rax
movslq -0x10c(%rbp), %rcx
addq %rcx, %rax
movslq -0x104(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0xd0(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0xa8(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x10(%rax)
movq -0xb0(%rbp), %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movw %cx, 0x12(%rax)
jmp 0x374fb
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
jmp 0x374fd
jmp 0x374fd
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x3688d
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %rbp
retq
nopl (%rax,%rax)