// File: chhylp123[P]hifiasm/Correct.cpp
// Function: verify_ul_window(long long, long long, overlap_region_alloc*, Correct_dumy*, ul_idx_t const*, char*, double, long long, long long, void*)
void verify_ul_window(long long window_start, long long window_end, overlap_region_alloc* overlap_list,Correct_dumy* dumy, const ul_idx_t *uref,
char* r_string, double max_ov_diff_ec, long long blockLen, long long max_error, void *km)
{
    long long i;
    long long currentID;
    long long x_start, y_start, o_len;
    long long Window_Len = blockLen + (max_error << 1);
    char* x_string = NULL;
    char* y_string = NULL;
    long long x_end, x_len;
    int end_site;
    unsigned int error;
    int groupLen = 0;
    int return_sites[GROUP_SIZE];
    unsigned int return_sites_error[GROUP_SIZE];
    uint64_t overlapID[GROUP_SIZE];
    uint64_t y_startGroup[GROUP_SIZE];
    int y_extra_begin[GROUP_SIZE];
    int y_extra_end[GROUP_SIZE];
    int error_threshold[GROUP_SIZE];
    int extra_begin;
    int extra_end;

    ///here are overlaps fully covered by blockLen
    for (i = 0; i < (long long)dumy->length; i++)
    {
        extra_begin = extra_end = 0;
        ///if the window has been fully covered, the interval at x is [window_start, window_end]
        x_len = blockLen;
        currentID = dumy->overlapID[i];
        x_start = window_start;
        ///offset of y
        y_start = (x_start - overlap_list->list[currentID].x_pos_s) + overlap_list->list[currentID].y_pos_s;
        /****************************may have bugs********************************/
        y_start += y_start_offset(x_start, &(overlap_list->list[currentID].f_cigar));
        /****************************may have bugs********************************/
        
  
        if(!determine_overlap_region(max_error, y_start, overlap_list->list[currentID].y_id, Window_Len, uref->ug->u.a[overlap_list->list[currentID].y_id].len,
        &extra_begin, &extra_end, &y_start, &o_len)) {
            continue;
        }

        // if(overlap_list->list[currentID].y_id == 4) {
        //     fprintf(stderr, "[M::%s] q_s::%lld, t_s::%lld, t_pri_l::%lld, aux_beg::%d, aux_end::%d, aln_l::%lld\n", __func__, 
        //         x_start, y_start, o_len, extra_begin, extra_end, Window_Len);
        // }

        fill_subregion_ul(dumy->overlap_region_group[groupLen], y_start, o_len, overlap_list->list[currentID].y_pos_strand, 
        uref, overlap_list->list[currentID].y_id, extra_begin, extra_end);

        y_extra_begin[groupLen] = extra_begin;
        y_extra_end[groupLen] = extra_end;
        overlapID[groupLen] = currentID;
        y_startGroup[groupLen] = y_start;
        error_threshold[groupLen] = max_error;
        x_string = r_string + x_start;
        groupLen++;
        

        if (groupLen == GROUP_SIZE)
        {
            // Reserve_Banded_BPM_4_SSE_only(dumy->overlap_region_group[0], dumy->overlap_region_group[1], 
            // dumy->overlap_region_group[2], dumy->overlap_region_group[3], Window_Len, x_string, blockLen,
            //     return_sites, return_sites_error, max_error, dumy->Peq_SSE);
            return_sites[0] = 
                    Reserve_Banded_BPM(dumy->overlap_region_group[0], Window_Len, x_string, blockLen, max_error, &return_sites_error[0]);
            return_sites[1] = 
                    Reserve_Banded_BPM(dumy->overlap_region_group[1], Window_Len, x_string, blockLen, max_error, &return_sites_error[1]);
            return_sites[2] = 
                    Reserve_Banded_BPM(dumy->overlap_region_group[2], Window_Len, x_string, blockLen, max_error, &return_sites_error[2]);
            return_sites[3] = 
                    Reserve_Banded_BPM(dumy->overlap_region_group[3], Window_Len, x_string, blockLen, max_error, &return_sites_error[3]);
            




            groupLen = 0;
            
            if (return_sites_error[0]!=(unsigned int)-1) {
                overlap_list->list[overlapID[0]].align_length += x_len;

                append_window_list(&overlap_list->list[overlapID[0]], window_start, window_end, 
                            y_startGroup[0], y_startGroup[0] + return_sites[0], (int)return_sites_error[0],
                            y_extra_begin[0], y_extra_end[0], error_threshold[0], blockLen, km);
            }
            

            if (return_sites_error[1]!=(unsigned int)-1) {
                overlap_list->list[overlapID[1]].align_length += x_len;
                append_window_list(&overlap_list->list[overlapID[1]], window_start, window_end, 
                            y_startGroup[1], y_startGroup[1] + return_sites[1], (int)return_sites_error[1],
                            y_extra_begin[1], y_extra_end[1], error_threshold[1], blockLen, km);
            }
            

            if (return_sites_error[2]!=(unsigned int)-1) {
                overlap_list->list[overlapID[2]].align_length += x_len;

                append_window_list(&overlap_list->list[overlapID[2]], window_start, window_end, 
                            y_startGroup[2], y_startGroup[2] + return_sites[2], (int)return_sites_error[2],
                            y_extra_begin[2], y_extra_end[2], error_threshold[2], blockLen, km);
            }
            

            if (return_sites_error[3]!=(unsigned int)-1) {
                overlap_list->list[overlapID[3]].align_length += x_len;

                append_window_list(&overlap_list->list[overlapID[3]], window_start, window_end, 
                            y_startGroup[3], y_startGroup[3] + return_sites[3], (int)return_sites_error[3],
                            y_extra_begin[3], y_extra_end[3], error_threshold[3], blockLen, km);
            } 
        }
    }

    if (groupLen == 1)
    {
        end_site = Reserve_Banded_BPM(dumy->overlap_region_group[0], Window_Len, x_string, blockLen, max_error, &error);

        if (error!=(unsigned int)-1) {
            overlap_list->list[overlapID[0]].align_length += x_len;

            append_window_list(&overlap_list->list[overlapID[0]], window_start, window_end, 
                                y_startGroup[0], y_startGroup[0] + end_site, (int)error,
                                y_extra_begin[0], y_extra_end[0], error_threshold[0], blockLen, km);
        }
    }
    else if (groupLen > 1)
    {
        // Reserve_Banded_BPM_4_SSE_only(dumy->overlap_region_group[0], dumy->overlap_region_group[1], 
        //         dumy->overlap_region_group[2], dumy->overlap_region_group[3], Window_Len, x_string, blockLen,
        //             return_sites, return_sites_error, max_error, dumy->Peq_SSE);

        for (i = 0; i < groupLen; i++)
        {
            return_sites[i] = Reserve_Banded_BPM(dumy->overlap_region_group[i], Window_Len, x_string, blockLen, max_error, &return_sites_error[i]);

            if (return_sites_error[i]!=(unsigned int)-1) {
                overlap_list->list[overlapID[i]].align_length += x_len;
                append_window_list(&overlap_list->list[overlapID[i]], window_start, window_end, 
                                y_startGroup[i], y_startGroup[i] + return_sites[i], (int)return_sites_error[i],
                                y_extra_begin[i], y_extra_end[i], error_threshold[i], blockLen, km);
            }
        }

        groupLen = 0;
    }

    long long reverse_i = dumy->size - 1;
    int threshold;
    
    ///here are overlaps partially covered by blockLen
    for (i = 0; i < (long long)dumy->lengthNT; i++)
    {
        extra_begin = extra_end = 0;
        currentID = dumy->overlapID[reverse_i--];
        x_start = MAX(window_start, (long long)overlap_list->list[currentID].x_pos_s);
        x_end = MIN(window_end, (long long)overlap_list->list[currentID].x_pos_e);

        ///overlap length between [window_start, window_end]
        x_len = x_end - x_start + 1;
        threshold = x_len * max_ov_diff_ec;
        /****************************may have bugs********************************/
        threshold = Adjust_Threshold(threshold, x_len);
        if(threshold > THRESHOLD_MAX_SIZE) threshold = THRESHOLD_MAX_SIZE;
        /****************************may have bugs********************************/
        
        ///offset of y
        y_start = (x_start - overlap_list->list[currentID].x_pos_s) + overlap_list->list[currentID].y_pos_s;
        /****************************may have bugs********************************/
        y_start += y_start_offset(x_start, &(overlap_list->list[currentID].f_cigar));
        /****************************may have bugs********************************/

        Window_Len = x_len + (threshold << 1);

        if(!determine_overlap_region(threshold, y_start, overlap_list->list[currentID].y_id, Window_Len, uref->ug->u.a[overlap_list->list[currentID].y_id].len,
        &extra_begin, &extra_end, &y_start, &o_len)) {
            continue;
        }

        // if(overlap_list->list[currentID].y_id == 4) {
        //     fprintf(stderr, "[M::%s] q_s::%lld, t_s::%lld, t_pri_l::%lld, aux_beg::%d, aux_end::%d, aln_l::%lld\n", __func__, 
        //         x_start, y_start, o_len, extra_begin, extra_end, Window_Len);
        // }
        
        fill_subregion_ul(dumy->overlap_region, y_start, o_len, overlap_list->list[currentID].y_pos_strand, 
        uref, overlap_list->list[currentID].y_id, extra_begin, extra_end);        

        x_string = r_string + x_start;
        y_string = dumy->overlap_region;

        end_site = Reserve_Banded_BPM(y_string, Window_Len, x_string, x_len, threshold, &error);

        if (error!=(unsigned int)-1) {
            overlap_list->list[currentID].align_length += x_len;
            append_window_list(&overlap_list->list[currentID], x_start, x_end, y_start, y_start + end_site, (int)error,
            extra_begin, extra_end, threshold, blockLen, km);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movsd %xmm0, -0x48(%rbp)
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movl $0x0, -0xa4(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jge 0x33920
movl $0x0, -0x148(%rbp)
movl $0x0, -0x144(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x58(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
subq %rcx, %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x58(%rbp), %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
imulq $0xa8, -0x58(%rbp), %rax
addq %rax, %rsi
addq $0x38, %rsi
callq 0x331a0
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x18(%rbp), %rax
movl %eax, %edi
movq -0x68(%rbp), %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, %edx
movq -0x78(%rbp), %rcx
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %r8
movq (%r8), %r8
imulq $0xa8, -0x58(%rbp), %r9
addq %r9, %r8
movl 0x10(%r8), %r8d
imulq $0x28, %r8, %r8
addq %r8, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r8d
leaq -0x144(%rbp), %r9
leaq -0x148(%rbp), %r11
leaq -0x68(%rbp), %r10
leaq -0x70(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x32290
cmpl $0x0, %eax
jne 0x33456
jmp 0x3390f
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
movslq -0xa4(%rbp), %rax
imulq $0x1f4, %rax, %rax      # imm = 0x1F4
addq %rax, %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movb %al, %cl
movq -0x38(%rbp), %r8
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %r9
addq %r9, %rax
movl 0x10(%rax), %eax
movl %eax, %r9d
movl -0x144(%rbp), %r10d
movl -0x148(%rbp), %eax
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x321f0
movl -0x144(%rbp), %ecx
movslq -0xa4(%rbp), %rax
movl %ecx, -0x120(%rbp,%rax,4)
movl -0x148(%rbp), %ecx
movslq -0xa4(%rbp), %rax
movl %ecx, -0x130(%rbp,%rax,4)
movq -0x58(%rbp), %rcx
movslq -0xa4(%rbp), %rax
movq %rcx, -0xf0(%rbp,%rax,8)
movq -0x68(%rbp), %rcx
movslq -0xa4(%rbp), %rax
movq %rcx, -0x110(%rbp,%rax,8)
movq 0x18(%rbp), %rax
movl %eax, %ecx
movslq -0xa4(%rbp), %rax
movl %ecx, -0x140(%rbp,%rax,4)
movq -0x40(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
cmpl $0x4, -0xa4(%rbp)
jne 0x3390d
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
leaq -0xd0(%rbp), %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
addq $0x1f4, %rdi            # imm = 0x1F4
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
leaq -0xd0(%rbp), %r9
addq $0x4, %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, -0xbc(%rbp)
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
addq $0x3e8, %rdi            # imm = 0x3E8
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
leaq -0xd0(%rbp), %r9
addq $0x8, %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, -0xb8(%rbp)
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
addq $0x5dc, %rdi            # imm = 0x5DC
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
leaq -0xd0(%rbp), %r9
addq $0xc, %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, -0xb4(%rbp)
movl $0x0, -0xa4(%rbp)
cmpl $-0x1, -0xd0(%rbp)
je 0x33701
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0xf0(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0xf0(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x110(%rbp), %rax
movl %eax, %ecx
movq -0x110(%rbp), %rax
movslq -0xc0(%rbp), %r8
addq %r8, %rax
movl %eax, %r8d
movl -0xd0(%rbp), %r9d
movl -0x120(%rbp), %r14d
movl -0x130(%rbp), %ebx
movl -0x140(%rbp), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
cmpl $-0x1, -0xcc(%rbp)
je 0x337af
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0xe8(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0xe8(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x108(%rbp), %rax
movl %eax, %ecx
movq -0x108(%rbp), %rax
movslq -0xbc(%rbp), %r8
addq %r8, %rax
movl %eax, %r8d
movl -0xcc(%rbp), %r9d
movl -0x11c(%rbp), %r14d
movl -0x12c(%rbp), %ebx
movl -0x13c(%rbp), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
cmpl $-0x1, -0xc8(%rbp)
je 0x3385d
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0xe0(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0xe0(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x100(%rbp), %rax
movl %eax, %ecx
movq -0x100(%rbp), %rax
movslq -0xb8(%rbp), %r8
addq %r8, %rax
movl %eax, %r8d
movl -0xc8(%rbp), %r9d
movl -0x118(%rbp), %r14d
movl -0x128(%rbp), %ebx
movl -0x138(%rbp), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
cmpl $-0x1, -0xc4(%rbp)
je 0x3390b
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0xd8(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0xd8(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0xf8(%rbp), %rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movslq -0xb4(%rbp), %r8
addq %r8, %rax
movl %eax, %r8d
movl -0xc4(%rbp), %r9d
movl -0x114(%rbp), %r14d
movl -0x124(%rbp), %ebx
movl -0x134(%rbp), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
jmp 0x3390d
jmp 0x3390f
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x3331e
cmpl $0x1, -0xa4(%rbp)
jne 0x33a15
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
leaq -0xa0(%rbp), %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, -0x9c(%rbp)
cmpl $-0x1, -0xa0(%rbp)
je 0x33a10
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0xf0(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0xf0(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x110(%rbp), %rax
movl %eax, %ecx
movq -0x110(%rbp), %rax
movslq -0x9c(%rbp), %r8
addq %r8, %rax
movl %eax, %r8d
movl -0xa0(%rbp), %r9d
movl -0x120(%rbp), %r14d
movl -0x130(%rbp), %ebx
movl -0x140(%rbp), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
jmp 0x33b8f
cmpl $0x1, -0xa4(%rbp)
jle 0x33b8d
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0xa4(%rbp), %rcx
cmpq %rcx, %rax
jge 0x33b83
movq -0x30(%rbp), %rdi
addq $0x244, %rdi            # imm = 0x244
imulq $0x1f4, -0x50(%rbp), %rax # imm = 0x1F4
addq %rax, %rdi
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq 0x18(%rbp), %rax
movq -0x50(%rbp), %r8
leaq -0xd0(%rbp), %r9
shlq $0x2, %r8
addq %r8, %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, -0xc0(%rbp,%rax,4)
movq -0x50(%rbp), %rax
cmpl $-0x1, -0xd0(%rbp,%rax,4)
je 0x33b70
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
imulq $0xa8, -0xf0(%rbp,%rcx,8), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x50(%rbp), %rax
imulq $0xa8, -0xf0(%rbp,%rax,8), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x50(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movq -0x110(%rbp,%rax,8), %rax
movq -0x50(%rbp), %r8
movslq -0xc0(%rbp,%r8,4), %r8
addq %r8, %rax
movl %eax, %r8d
movq -0x50(%rbp), %rax
movl -0xd0(%rbp,%rax,4), %r9d
movq -0x50(%rbp), %rax
movl -0x120(%rbp,%rax,4), %r14d
movq -0x50(%rbp), %rax
movl -0x130(%rbp,%rax,4), %ebx
movq -0x50(%rbp), %rax
movl -0x140(%rbp,%rax,4), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
jmp 0x33b72
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x33a2a
movl $0x0, -0xa4(%rbp)
jmp 0x33b8f
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
subq $0x1, %rax
movq %rax, -0x150(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jge 0x33f82
movl $0x0, -0x148(%rbp)
movl $0x0, -0x144(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x150(%rbp), %rcx
movq %rcx, %rdx
addq $-0x1, %rdx
movq %rdx, -0x150(%rbp)
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x58(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
cmpq %rcx, %rax
jl 0x33c20
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
jmp 0x33c3c
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x58(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
cmpq %rcx, %rax
jg 0x33c72
movq -0x20(%rbp), %rax
movq %rax, -0x168(%rbp)
jmp 0x33c8e
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
subq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
cvtsi2sdq -0x98(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x154(%rbp)
cmpl $0x0, -0x154(%rbp)
jne 0x33cea
cmpq $0x4, -0x98(%rbp)
jl 0x33cea
movl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x33cf6
movl -0x154(%rbp), %eax
movl %eax, -0x16c(%rbp)
movl -0x16c(%rbp), %eax
movl %eax, -0x154(%rbp)
cmpl $0x1f, -0x154(%rbp)
jle 0x33d15
movl $0x1f, -0x154(%rbp)
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x58(%rbp), %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
subq %rcx, %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
imulq $0xa8, -0x58(%rbp), %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
imulq $0xa8, -0x58(%rbp), %rax
addq %rax, %rsi
addq $0x38, %rsi
callq 0x331a0
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x98(%rbp), %rax
movl -0x154(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x154(%rbp), %edi
movq -0x68(%rbp), %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, %edx
movq -0x78(%rbp), %rcx
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %r8
movq (%r8), %r8
imulq $0xa8, -0x58(%rbp), %r9
addq %r9, %r8
movl 0x10(%r8), %r8d
imulq $0x28, %r8, %r8
addq %r8, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %r8d
leaq -0x144(%rbp), %r9
leaq -0x148(%rbp), %r11
leaq -0x68(%rbp), %r10
leaq -0x70(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x32290
cmpl $0x0, %eax
jne 0x33e19
jmp 0x33f71
movq -0x30(%rbp), %rdi
addq $0x50, %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movb %al, %cl
movq -0x38(%rbp), %r8
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %r9
addq %r9, %rax
movl 0x10(%rax), %eax
movl %eax, %r9d
movl -0x144(%rbp), %r10d
movl -0x148(%rbp), %eax
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x321f0
movq -0x40(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x30(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movq -0x78(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq -0x98(%rbp), %rax
movl %eax, %ecx
movl -0x154(%rbp), %eax
leaq -0xa0(%rbp), %r9
movzwl %ax, %r8d
callq 0x9c2b0
movl %eax, -0x9c(%rbp)
cmpl $-0x1, -0xa0(%rbp)
je 0x33f6f
movq -0x98(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x58(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
imulq $0xa8, -0x58(%rbp), %rax
addq %rax, %rdi
movq -0x60(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x68(%rbp), %rax
movslq -0x9c(%rbp), %r8
addq %r8, %rax
movl %eax, %r8d
movl -0xa0(%rbp), %r9d
movl -0x144(%rbp), %r14d
movl -0x148(%rbp), %ebx
movl -0x154(%rbp), %r11d
movq 0x10(%rbp), %rax
movl %eax, %r10d
movq 0x20(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x22d00
jmp 0x33f71
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x33baa
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %rbp
retq
nop