// File: chhylp123[P]hifiasm/Correct.cpp
// Function: generate_haplotypes_DP(haplotype_evdience_alloc*, overlap_region_alloc*, All_reads*, long long, int)
int generate_haplotypes_DP(haplotype_evdience_alloc* hap, overlap_region_alloc* overlap_list, All_reads* R_INF, long long rLen, 
int force_repeat)
{
    int j, i;
    int vectorID, vectorID2;
    int8_t *vector, *vector2;

    
    // if(hap->available_snp == 0)
    if(hap->snp_stat.n == 0)
    {
        return 0;
    }

    ///debug_print_snp_stat("m64013_190324_024932/23660629/ccs", hap, overlap_list, R_INF);

    
    ///if hap->available_snp == 1, the following codes would have bugs
    ///filter snps that are highly likly false 
    // if(hap->available_snp > 1)
    if(hap->snp_stat.n > 1)
    {
        i = 0;
        ///if a snp is very close to others, it should not be a real snp
        for (j = 0; j < (int)hap->snp_stat.n/**hap->available_snp**/; j++)
        {
            if(j > 0 && j + 1 < (int)hap->snp_stat.n)
            {
                if(hap->snp_stat.a[j].site != hap->snp_stat.a[j - 1].site + 1
                    &&
                hap->snp_stat.a[j].site + 1 != hap->snp_stat.a[j + 1].site)
                {
                    hap->snp_stat.a[i] = hap->snp_stat.a[j];
                    i++;
                }

            }
            else if(j == 0)
            {
                if(hap->snp_stat.a[j].site + 1 != hap->snp_stat.a[j + 1].site)
                {
                    hap->snp_stat.a[i] = hap->snp_stat.a[j];
                    i++;
                }
            }
            else
            {
                if(hap->snp_stat.a[j].site != hap->snp_stat.a[j - 1].site + 1)
                {
                    hap->snp_stat.a[i] = hap->snp_stat.a[j];
                    i++;
                }
            }
        }
        // hap->available_snp = i;
        hap->snp_stat.n = i;
    }


    
    


    int flag;
    long long overlap_length, total_read, unuseful_read;
    total_read = unuseful_read = 0;
    ///check if any read may be conflict with others
    for (i = 0; i < (long long)overlap_list->length; i++)
    {
        overlap_length = overlap_list->list[i].x_pos_e - overlap_list->list[i].x_pos_s + 1;
        if (overlap_list->list[i].is_match == 1)
        {
            total_read++;
            flag = -1;
            for (j = 0; j < (int)hap->snp_stat.n; j++)
            {
                vectorID = hap->snp_stat.a[j].id;
                vector = Get_SNP_Vector((*hap), vectorID);

                ///flag == -1 means there are no useful signals yet
                if (flag == -1)
                {
                    if((vector[i] == 0 || vector[i] == 1 ))
                    {
                        flag = 0;
                    }
                }///flag == 0 means there is at least one useful signal yet
                else if (flag == 0) 
                {
                    if(vector[i] != 0 && vector[i] != 1)
                    {
                        flag = 2;
                    }
                }///flag == 0 means there is at least one useful signal first, and another unuseful signal after that
                else if(flag == 2) 
                {
                    if((vector[i] == 0 || vector[i] == 1 ))
                    {
                        flag = 3;
                        break;
                    }
                }
            }


            if(flag == 3) ///Fix-attention: definitely wrong
            {
                unuseful_read++;
                for (j = 0; j < (int)hap->snp_stat.n; j++)
                {
                    vectorID = hap->snp_stat.a[j].id;
                    vector = Get_SNP_Vector((*hap), vectorID);
                    

                    
                    if(vector[i] == 0)
                    {
                        hap->snp_stat.a[j].occ_0--;
                        hap->snp_stat.a[j].occ_2++;
                    }
                    else if(vector[i] == 1)
                    {
                        hap->snp_stat.a[j].occ_1--;
                        hap->snp_stat.a[j].occ_2++;
                    }
                    else if(vector[i] != 2)
                    {
                        hap->snp_stat.a[j].occ_2++;
                    }
                    

                    vector[i] = 2;
                }
                
                ///this read may be unuseful
                ///overlap_list->list[i].is_match = 0;
                ///overlap_list->list[i].is_match = 2;
                overlap_list->list[i].is_match = 4;
                ///overlap_list->mapped_overlaps--;
                overlap_list->mapped_overlaps_length -= overlap_length;
            }
        }
    }
    

    /*******************************DP********************************/
    init_DP_matrix(&(hap->dp), hap->snp_stat.n);

    long long equal_best = 0;
    uint32_t* column;

    

    for (i = 0; i < (int)hap->snp_stat.n; i++)
    {
        ///vector of snp i
        vectorID = hap->snp_stat.a[i].id;
        vector = Get_SNP_Vector((*hap), vectorID);
        hap->dp.visit[i] = 0;
        hap->dp.max[i] = 1;
        hap->dp.backtrack_length[i] = 0;
        equal_best = 0;
        column = Get_DP_Backtrack_Column(hap->dp, i);

        for (j = 0; j < i; j++)
        {
            ///vector of snp j
            vectorID2 = hap->snp_stat.a[j].id;
            vector2 = Get_SNP_Vector((*hap), vectorID2);

            ///vector is compatible with vector2
            if(calculate_distance_snp_vector(vector, vector2, Get_SNP_Vector_Length((*hap))) == 0)
            {
                
                if(hap->dp.max[i] < hap->dp.max[j] + 1)
                {
                    hap->dp.max[i] = hap->dp.max[j] + 1;

                    column[0] = j;
                    equal_best = 1;
                }
                else if(hap->dp.max[i] == hap->dp.max[j] + 1)
                {
                    column[equal_best] = j;
                    equal_best++;   
                }
                
                
            }
        }

        hap->dp.backtrack_length[i] = equal_best;
    }

    /*******************************DP********************************/

    uint64_t tmp_mode = 0;

    for (i = 0; i < (int)hap->snp_stat.n; i++)
    {
        tmp_mode = hap->dp.max[i];
        tmp_mode = tmp_mode << 32;
        tmp_mode = tmp_mode | (uint64_t)(i);
        hap->dp.max_for_sort[i] = tmp_mode;
    }
    
    qsort(hap->dp.max_for_sort, hap->snp_stat.n, sizeof(uint64_t), cmp_max_DP);


    int snpID;
    ///the minmum snp_num is 1
    hap->dp.max_snp_num = 0;
    hap->dp.max_score = -2;
    

    for (i = 0; i < (int)hap->snp_stat.n; i++)
    {
        snpID = Get_Max_DP_ID(hap->dp.max_for_sort[i]);
        if(hap->dp.visit[snpID] == 0)
        {
            hap->dp.current_snp_num = Get_Max_DP_Value(hap->dp.max_for_sort[i]);
            Preorder_Merge_Advance_Repeat(snpID, hap, 0);
        }
    }

    ///debug_print_snp_stat("m64013_190324_024932/23660629/ccs", hap, overlap_list, R_INF);


    //if(hap->dp.max_snp_num > 0)
    if(hap->snp_stat.n > 0)
    {
        process_repeat_snps(hap, overlap_list);
        return 1;
    }
    else
    {
        return 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x220(%rax)
jne 0x3fc59
movl $0x0, -0x4(%rbp)
jmp 0x405a4
movq -0x10(%rbp), %rax
cmpq $0x1, 0x220(%rax)
jbe 0x3fe93
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x3fe84
cmpl $0x0, -0x30(%rbp)
jle 0x3fd70
movl -0x30(%rbp), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x3fd70
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x218(%rcx), %rcx
movl -0x30(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x3fd6b
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
movq 0x218(%rcx), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
je 0x3fd6b
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rsi
movslq -0x30(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rdi
movslq -0x34(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3fe74
cmpl $0x0, -0x30(%rbp)
jne 0x3fdf3
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
movq 0x218(%rcx), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
je 0x3fdf1
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rsi
movslq -0x30(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rdi
movslq -0x34(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3fe72
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x218(%rcx), %rcx
movl -0x30(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x3fe70
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rsi
movslq -0x30(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rdi
movslq -0x34(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3fe72
jmp 0x3fe74
jmp 0x3fe76
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3fc79
movslq -0x34(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x220(%rax)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x401ce
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x34(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
subl 0x4(%rcx), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
jne 0x401be
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x4002d
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x1d0(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x1c8(%rcx), %ecx
imull -0x38(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
cmpl $-0x1, -0x54(%rbp)
jne 0x3ffb5
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x3ffac
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x3ffb3
movl $0x0, -0x54(%rbp)
jmp 0x4001d
cmpl $0x0, -0x54(%rbp)
jne 0x3ffe6
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x3ffe4
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
je 0x3ffe4
movl $0x2, -0x54(%rbp)
jmp 0x4001b
cmpl $0x2, -0x54(%rbp)
jne 0x40019
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x4000e
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x40017
movl $0x3, -0x54(%rbp)
jmp 0x4002d
jmp 0x40019
jmp 0x4001b
jmp 0x4001d
jmp 0x4001f
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3ff31
cmpl $0x3, -0x54(%rbp)
jne 0x401bc
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x40190
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x1d0(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x1c8(%rcx), %ecx
imull -0x38(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x400f1
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x40176
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x40142
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x40174
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
je 0x40172
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0x40174
jmp 0x40176
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x2, (%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4004a
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movb $0x4, 0x2c(%rax)
movq -0x60(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x18(%rax)
jmp 0x401be
jmp 0x401c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3feaa
movq -0x10(%rbp), %rdi
addq $0x250, %rdi            # imm = 0x250
movq -0x10(%rbp), %rax
movq 0x220(%rax), %rax
movl %eax, %esi
callq 0xa1c60
movq $0x0, -0x78(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x4040e
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x1d0(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x1c8(%rcx), %ecx
imull -0x38(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x258(%rax), %rax
movslq -0x34(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movslq -0x34(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x278(%rax), %rax
movslq -0x34(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x280(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x250(%rcx), %ecx
imull -0x34(%rbp), %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x403e8
movq -0x10(%rbp), %rax
movq 0x218(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x1d0(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x1c8(%rcx), %ecx
imull -0x3c(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x1c8(%rax), %edx
callq 0x3dea0
cmpl $0x0, %eax
jne 0x403d8
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x260(%rcx), %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jae 0x4038f
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
movq $0x1, -0x78(%rbp)
jmp 0x403d6
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x260(%rcx), %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x403d4
movl -0x30(%rbp), %edx
movq -0x80(%rbp), %rax
movq -0x78(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x403d6
jmp 0x403d8
jmp 0x403da
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x402c1
movq -0x78(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x278(%rax), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x401fa
movq $0x0, -0x88(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x40497
movq -0x10(%rbp), %rax
movq 0x260(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movslq -0x34(%rbp), %rcx
orq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x268(%rax), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x40420
movq -0x10(%rbp), %rax
movq 0x268(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x220(%rax), %rsi
movl $0x8, %edx
leaq -0x29c9(%rip), %rcx     # 0x3daf0
callq 0x23e0
movq -0x10(%rbp), %rax
movl $0x0, 0x2a0(%rax)
movq -0x10(%rbp), %rax
movl $0xfffffffe, 0x2a4(%rax) # imm = 0xFFFFFFFE
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x220(%rcx), %rcx
cmpl %ecx, %eax
jge 0x40579
movq -0x10(%rbp), %rax
movq 0x268(%rax), %rcx
movslq -0x34(%rbp), %rdx
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq (%rcx,%rdx,8), %rax
movl %eax, -0x8c(%rbp)
movq -0x10(%rbp), %rax
movq 0x258(%rax), %rax
movslq -0x8c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x40569
movq -0x10(%rbp), %rax
movq 0x268(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2a8(%rax)
movl -0x8c(%rbp), %edi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x3e9e0
jmp 0x4056b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x404e1
movq -0x10(%rbp), %rax
cmpq $0x0, 0x220(%rax)
jbe 0x4059d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3f500
movl $0x1, -0x4(%rbp)
jmp 0x405a4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq