// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_hap_alignment(ma_ug_t*, asg_t*, ma_hit_t_alloc*, buf_t*, R_to_U*, unsigned int*, unsigned long*, unsigned char*, kvec_t_u64_warp*, Hap_Align_warp*, kvec_t_u32_warp*, kvec_t_u32_warp*, unsigned int, unsigned int, unsigned long*, float, asg_t*, unsigned int)
void get_hap_alignment(ma_ug_t *ug, asg_t *read_g, ma_hit_t_alloc* reverse_sources, 
buf_t* b_0, R_to_U* ruIndex, uint32_t* position_index, uint64_t* vote_counting, uint8_t* visit, 
kvec_t_u64_warp* u_vecs, Hap_Align_warp* u_buffer, kvec_t_u32_warp* x_vecs, kvec_t_u32_warp* y_vecs,
uint32_t cId, uint32_t contigNum, uint64_t* cBeg, float Hap_rate, asg_t *bi_g, uint32_t is_bi_edge)
{
    ma_utg_t* reads = NULL;
    uint32_t beg, end, i, j, k, rId, Hap_cId, y_cId, y_offset, qn, self_offset, uId, uOri, is_Unitig, xLen, seedOcc;
    uint64_t tmp;
    long long nodeLen, baseLen, max_stop_nodeLen, max_stop_baseLen;
    memset(vote_counting, 0, sizeof(uint64_t)*contigNum);
    memset(visit, 0, contigNum);
    u_vecs->a.n = x_vecs->a.n = y_vecs->a.n = 0;

    beg = (uint32_t)(cBeg[cId]);
    b_0->b.n = 0;
    get_unitig(ug->g, ug, beg, &end, &nodeLen, &baseLen, &max_stop_nodeLen, &max_stop_baseLen, 1, b_0);
    xLen = cBeg[cId]>>33;
    kv_resize(uint32_t, x_vecs->a, xLen);

    for (i = 0, self_offset = 0; i < b_0->b.n; i++)
    {
        uId = b_0->b.a[i]>>1;
        uOri = b_0->b.a[i]&(uint32_t)1;
        reads = &(ug->u.a[uId]);
        for (j = 0; j < reads->n; j++, self_offset++)
        {
            if(uOri == 1)
            {
                rId = reads->a[reads->n - j - 1]>>33;
            }
            else
            {
                rId = reads->a[j]>>33;
            }


            tmp = rId<<1;
            if(read_g->seq[rId].c == HAP_LABLE)
            {
                tmp = tmp | 1;
                kv_push(uint32_t, x_vecs->a, tmp);
                continue;
            }
            kv_push(uint32_t, x_vecs->a, tmp); 


            /**********************for debug*************************/
            ///debug_visit_flag(visit, contigNum);
            /**********************for debug*************************/

            qn = rId;
            for (k = 0; k < reverse_sources[qn].length; k++)
            {
                rId = Get_tn(reverse_sources[qn].buffer[k]);
            
                if(read_g->seq[rId].del == 1)
                {
                    ///get the id of read that contains it 
                    get_R_to_U(ruIndex, rId, &rId, &is_Unitig);
                    if(rId == (uint32_t)-1 || is_Unitig == 1 || read_g->seq[rId].del == 1) continue;
                }

                ///there are two cases: 
                ///1. read at primary contigs, get_R_to_U() return its corresponding contig Id  
                ///2. read at alternative contigs, get_R_to_U() return (uint32_t)-1
                get_R_to_U(ruIndex, rId, &Hap_cId, &is_Unitig);
                if(is_Unitig == 0 || Hap_cId == (uint32_t)-1) continue;
                ///here rId is the id of the read coming from the different haplotype
                ///Hap_cId is the id of the corresponding contig (note here is the contig, instead of untig)
                if(visit[Hap_cId]!=0) continue;
                visit[Hap_cId] = 1;
                if(vote_counting[Hap_cId] < UINT64_MAX) vote_counting[Hap_cId]++;
            }

            reset_visit_flag(visit, read_g, ruIndex, contigNum, &(reverse_sources[qn]));
        }
    }


    u_vecs->a.n = 0;
    for (i = 0; i < contigNum; i++)
    {
        if(i == cId) continue;
        if(vote_counting[i] == 0) continue;
        tmp = vote_counting[i]; tmp = tmp << 32; tmp = tmp | (uint64_t)i;
        kv_push(uint64_t, u_vecs->a, tmp);
    }

    if(u_vecs->a.n == 0) return;

    sort_kvec_t_u64_warp(u_vecs, 1);


    ma_hit_t_alloc *x = NULL, *pre_x = NULL;
    Hap_Align* p = NULL;
    asg_arc_t *e = NULL;
    ///scan from the weightest candidate 
    for (i = 0; i < u_vecs->a.n; i++)
    {
        Hap_cId = (uint32_t)u_vecs->a.a[i];
        get_readSeq(ug, read_g, y_vecs, cBeg, b_0, Hap_cId);
        y_cId = Hap_cId;
        seedOcc = u_vecs->a.a[i]>>32;

        if(debug_purge_dup)
        {
            if(cId == 53)
            {
                fprintf(stderr, "cId: %u, y_cId: %u, seedOcc: %u\n", cId, y_cId, seedOcc);
            }
        }

        u_buffer->x.n = 0;
        for (k = 0; k < x_vecs->a.n; k++)
        {
            x = pre_x = NULL;
            rId = x_vecs->a.a[k]>>1;
            if(read_g->seq[rId].c == HAP_LABLE) continue;
            x = &(reverse_sources[rId]);

            if(k >= 1)
            {
                rId = x_vecs->a.a[k-1]>>1;
                if(read_g->seq[rId].c != HAP_LABLE)
                {
                    pre_x = &(reverse_sources[rId]);
                }
            }




            for (j = 0; j < x->length; j++)
            {
                rId = Get_tn(x->buffer[j]);
                if(read_g->seq[rId].del == 1)
                {
                    ///get the id of read that contains it 
                    get_R_to_U(ruIndex, rId, &rId, &is_Unitig);
                    if(rId == (uint32_t)-1 || is_Unitig == 1 || read_g->seq[rId].del == 1) continue;
                }

                ///there are two cases: 
                ///1. read at primary contigs, get_R_to_U() return its corresponding contig Id  
                ///2. read at alternative contigs, get_R_to_U() return (uint32_t)-1
                get_R_to_U(ruIndex, rId, &Hap_cId, &is_Unitig);
                if(is_Unitig == 0 || Hap_cId == (uint32_t)-1) continue;
                if(Hap_cId != y_cId) continue;

                y_offset = position_index[rId];
                ///if(retrieve_skip_overlaps(pre_x, rId) != (uint32_t)-1)
                if(retrieve_skip_overlaps(pre_x, Get_tn(x->buffer[j])) != (uint32_t)-1)
                {
                    check_duplicate(u_buffer, (uint32_t)-1, y_offset);
                    continue;
                } 
                if(check_duplicate(u_buffer, k, y_offset)) continue;

                kv_pushp(Hap_Align, u_buffer->x, &p);
                p->q_pos = k;
                p->t_pos = y_offset;
                p->t_id = y_cId;
                p->is_color = 1;
            }
        }

        merge_hap_hits(u_buffer);
        if(u_buffer->x.n == 0) continue;

        ///for (k = 0; k < u_buffer->x.n; k++)
        for (k = u_buffer->x.n-1; k >= 0; k--)
        {
            if(calculate_hap_similarity(&(u_buffer->x.a[k]), 0, cId, y_cId, x_vecs, y_vecs, 
            reverse_sources, read_g, ruIndex, Hap_rate, seedOcc)==PLOID)
            {
                break;
            }
            else if(calculate_hap_similarity(&(u_buffer->x.a[k]), 1, cId, y_cId, x_vecs, y_vecs, 
            reverse_sources, read_g, ruIndex, Hap_rate, seedOcc)==PLOID)
            {
                break;
            }
            if(k == 0)
            {
                k = (uint32_t)-1;
                break;
            }
        }

        ///if(k < u_buffer->x.n)
        if(k != (uint32_t)-1)
        {
            e = asg_arc_pushp(bi_g);
            e->del = 0;
            e->ol = 0;
            e->ul = cId; e->ul = e->ul << 32; e->ul = e->ul | (uint64_t)(0);
            e->v = y_cId;

            if(is_bi_edge)
            {
                e = asg_arc_pushp(bi_g);
                e->del = 0;
                e->ol = 0;
                e->ul = y_cId; e->ul = e->ul << 32; e->ul = e->ul | (uint64_t)(0);
                e->v = cId;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl 0x60(%rbp), %eax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movl 0x48(%rbp), %eax
movl 0x40(%rbp), %eax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movss %xmm0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movq 0x10(%rbp), %rdi
movl 0x48(%rbp), %eax
movl %eax, %edx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2100
movq 0x18(%rbp), %rdi
movl 0x48(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movq 0x38(%rbp), %rax
movq $0x0, (%rax)
movq 0x30(%rbp), %rax
movq $0x0, (%rax)
movq 0x20(%rbp), %rax
movq $0x0, (%rax)
movq 0x50(%rbp), %rax
movl 0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x4c(%rbp), %edx
movq -0x28(%rbp), %rax
leaq -0x50(%rbp), %rcx
leaq -0x98(%rbp), %r8
leaq -0xa0(%rbp), %r9
leaq -0xa8(%rbp), %r11
leaq -0xb0(%rbp), %r10
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x166c30
movq 0x50(%rbp), %rax
movl 0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x84(%rbp)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x84(%rbp), %ecx
cmpq %rcx, %rax
jae 0x144abe
movl -0x84(%rbp), %eax
movl %eax, %ecx
movq 0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
shrq %rcx
movq 0x30(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x2, %rcx
movq 0x30(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x4, %rcx
movq 0x30(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x8, %rcx
movq 0x30(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x10, %rcx
movq 0x30(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x144ac0
movl $0x0, -0x54(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x54(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x144e30
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x1, %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x78(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x144e20
cmpl $0x1, -0x7c(%rbp)
jne 0x144b5d
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl -0x58(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x60(%rbp)
jmp 0x144b73
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x58(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
shll %eax
movl %eax, %eax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x2, %eax
jne 0x144c47
movq -0x90(%rbp), %rax
orq $0x1, %rax
movq %rax, -0x90(%rbp)
movq 0x30(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x144c1d
movq 0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x144bdc
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xd8(%rbp)
jmp 0x144bea
movl $0x2, %eax
movq %rax, -0xd8(%rbp)
jmp 0x144bea
movq -0xd8(%rbp), %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x90(%rbp), %rax
movl %eax, %edx
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x144e09
jmp 0x144c49
movq 0x30(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x144cba
movq 0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x144c79
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xe0(%rbp)
jmp 0x144c87
movl $0x2, %eax
movq %rax, -0xe0(%rbp)
jmp 0x144c87
movq -0xe0(%rbp), %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x90(%rbp), %rax
movl %eax, %edx
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movl %edx, (%rax,%rcx,4)
movl -0x60(%rbp), %eax
movl %eax, -0x70(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
movl -0x70(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x144de7
movq -0x20(%rbp), %rax
movl -0x70(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x5c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x144d77
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq -0x60(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x60(%rbp)
je 0x144d73
cmpl $0x1, -0x80(%rbp)
je 0x144d73
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x144d75
jmp 0x144dd9
jmp 0x144d77
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq -0x64(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0xd3d50
cmpl $0x0, -0x80(%rbp)
je 0x144d97
cmpl $-0x1, -0x64(%rbp)
jne 0x144d99
jmp 0x144dd9
movq 0x18(%rbp), %rax
movl -0x64(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x144dab
jmp 0x144dd9
movq 0x18(%rbp), %rax
movl -0x64(%rbp), %ecx
movb $0x1, (%rax,%rcx)
movq 0x10(%rbp), %rax
movl -0x64(%rbp), %ecx
cmpq $-0x1, (%rax,%rcx,8)
jae 0x144dd7
movq 0x10(%rbp), %rax
movl -0x64(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x144dd9
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x144cec
movq 0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl 0x48(%rbp), %ecx
movq -0x20(%rbp), %r8
movl -0x70(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %r8
callq 0x168570
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x144b23
jmp 0x144e22
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x144ace
movq 0x20(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x48(%rbp), %eax
jae 0x144f4b
movl -0x54(%rbp), %eax
cmpl 0x40(%rbp), %eax
jne 0x144e5b
jmp 0x144f3d
movq 0x10(%rbp), %rax
movl -0x54(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x144e6e
jmp 0x144f3d
movq 0x10(%rbp), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl -0x54(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x90(%rbp)
movq 0x20(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x144f17
movq 0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x144ed6
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xe8(%rbp)
jmp 0x144ee4
movl $0x2, %eax
movq %rax, -0xe8(%rbp)
jmp 0x144ee4
movq -0xe8(%rbp), %rcx
movq 0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x90(%rbp), %rdx
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x144f3d
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x144e42
movq 0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x144f5a
jmp 0x145534
movq 0x20(%rbp), %rdi
movl $0x1, %esi
callq 0xcd080
movq $0x0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq 0x20(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x145534
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x38(%rbp), %rdx
movq 0x50(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x64(%rbp), %r9d
callq 0x1435a0
movl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
movq 0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, -0x88(%rbp)
cmpl $0x0, 0x2804b8(%rip)    # 0x3c54b8
je 0x14502f
cmpl $0x35, 0x40(%rbp)
jne 0x14502d
movq 0x27efd1(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl 0x40(%rbp), %edx
movl -0x68(%rbp), %ecx
movl -0x88(%rbp), %r8d
leaq 0x243fe7(%rip), %rsi    # 0x38900d
movb $0x0, %al
callq 0x22a0
jmp 0x14502f
movq 0x28(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq 0x30(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1452fc
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xb8(%rbp)
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x5c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x2, %eax
jne 0x145094
jmp 0x1452ee
movq -0x20(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
cmpl $0x1, -0x5c(%rbp)
jb 0x1450f3
movq 0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x5c(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x2, %eax
je 0x1450f1
movq -0x20(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
jmp 0x1450f3
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0xb8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x1452ec
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0x58(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x14517a
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq -0x60(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0xd3d50
cmpl $-0x1, -0x60(%rbp)
je 0x145173
cmpl $0x1, -0x80(%rbp)
je 0x145173
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x145178
jmp 0x1452de
jmp 0x14517a
movq -0x30(%rbp), %rdi
movl -0x60(%rbp), %esi
leaq -0x64(%rbp), %rdx
leaq -0x80(%rbp), %rcx
callq 0xd3d50
cmpl $0x0, -0x80(%rbp)
je 0x14519a
cmpl $-0x1, -0x64(%rbp)
jne 0x14519f
jmp 0x1452de
movl -0x64(%rbp), %eax
cmpl -0x68(%rbp), %eax
je 0x1451ac
jmp 0x1452de
movq -0x38(%rbp), %rax
movl -0x60(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x6c(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0x58(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %esi
callq 0x168670
cmpl $-0x1, %eax
je 0x1451f7
movq 0x28(%rbp), %rdi
movl -0x6c(%rbp), %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1686e0
jmp 0x1452de
movq 0x28(%rbp), %rdi
movl -0x5c(%rbp), %esi
movl -0x6c(%rbp), %edx
callq 0x1686e0
cmpl $0x0, %eax
je 0x145210
jmp 0x1452de
jmp 0x145212
movq 0x28(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x145283
movq 0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x145242
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0xf0(%rbp)
jmp 0x145250
movl $0x2, %eax
movq %rax, -0xf0(%rbp)
jmp 0x145250
movq -0xf0(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x4, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movl -0x5c(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, (%rax)
movl -0x6c(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x68(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xc8(%rbp), %rax
movl $0x1, 0xc(%rax)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1450fa
jmp 0x1452ee
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x145041
movq 0x28(%rbp), %rdi
callq 0x1687d0
movq 0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x145314
jmp 0x145526
movq 0x28(%rbp), %rax
movq (%rax), %rax
subq $0x1, %rax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jb 0x1453fe
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x5c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdi
movl 0x40(%rbp), %edx
movl -0x68(%rbp), %ecx
movq 0x30(%rbp), %r8
movq 0x38(%rbp), %r9
movq -0x20(%rbp), %rbx
movq -0x18(%rbp), %r11
movq -0x30(%rbp), %r10
movss -0x3c(%rbp), %xmm0
movl -0x88(%rbp), %eax
xorl %esi, %esi
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x143b40
cmpl $0x0, %eax
jne 0x145383
jmp 0x1453fe
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x5c(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdi
movl 0x40(%rbp), %edx
movl -0x68(%rbp), %ecx
movq 0x30(%rbp), %r8
movq 0x38(%rbp), %r9
movq -0x20(%rbp), %rbx
movq -0x18(%rbp), %r11
movq -0x30(%rbp), %r10
movss -0x3c(%rbp), %xmm0
movl -0x88(%rbp), %eax
movl $0x1, %esi
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x143b40
cmpl $0x0, %eax
jne 0x1453dd
jmp 0x1453fe
jmp 0x1453df
cmpl $0x0, -0x5c(%rbp)
jne 0x1453ee
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
jmp 0x1453fe
jmp 0x1453f0
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x145322
cmpl $-0x1, -0x5c(%rbp)
je 0x145524
movq 0x58(%rbp), %rdi
callq 0xd4050
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movq -0xd0(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movl 0x40(%rbp), %eax
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
movq (%rax), %rcx
orq $0x0, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movl -0x68(%rbp), %ecx
movq -0xd0(%rbp), %rax
movl %ecx, 0x8(%rax)
cmpl $0x0, 0x60(%rbp)
je 0x145522
movq 0x58(%rbp), %rdi
callq 0xd4050
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movq -0xd0(%rbp), %rax
movl 0xc(%rax), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movl -0x68(%rbp), %eax
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movq -0xd0(%rbp), %rax
movq (%rax), %rcx
orq $0x0, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, (%rax)
movl 0x40(%rbp), %ecx
movq -0xd0(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0x145524
jmp 0x145526
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x144f9b
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %rbp
retq
nop