// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: hap_alignment_advance_worker(void*, long, int)
static void hap_alignment_advance_worker(void *_data, long eid, int tid)
{
    hap_alignment_struct_pip* hap_buf = (hap_alignment_struct_pip*)_data;
    ma_ug_t *ug = hap_buf->ug;
    asg_t *read_g = hap_buf->read_g;
    ma_hit_t_alloc* sources = hap_buf->sources;
    ma_hit_t_alloc* reverse_sources = hap_buf->reverse_sources;
    R_to_U* ruIndex = hap_buf->ruIndex;
    ma_sub_t *coverage_cut = hap_buf->coverage_cut;
    uint64_t* position_index = hap_buf->position_index;
    float Hap_rate = hap_buf->Hap_rate/**MIN(hap_buf->Hap_rate, 0.2)**/, sim;
    int max_hang = hap_buf->max_hang;
    int min_ovlp = hap_buf->min_ovlp;
    float chain_rate = hap_buf->chain_rate;
    hap_overlaps_list* all_ovlp = hap_buf->all_ovlp;
    uint32_t Input_uId = eid;
    uint64_t* vote_counting = hap_buf->buf[tid].vote_counting;
    uint8_t* visit = hap_buf->buf[tid].visit;
    kvec_t_u64_warp* u_vecs = &(hap_buf->buf[tid].u_vecs);
    kvec_asg_arc_t_offset* u_buffer = &(hap_buf->buf[tid].u_buffer);
    kvec_hap_candidates* u_can = &(hap_buf->buf[tid].u_can);
    kvec_t_i32_warp* score_vc = &(hap_buf->buf[tid].u_buffer_tailIndex);
    kvec_t_i32_warp* prevIndex_vec = &(hap_buf->buf[tid].u_buffer_prevIndex);
    kvec_t_i32_warp* begIndex_vec = &(hap_buf->buf[tid].u_buffer_beg);
    kvec_t_u8_warp* flag_vec = &(hap_buf->buf[tid].u_buffer_flag);
    uint64_t cov_threshold = hap_buf->cov_threshold;
    hap_cov_t *cov = hap_buf->cov;
    uint8_t *hh = hap_buf->hh, hhc;
    if(hap_buf->cov_threshold < 0) cov_threshold = (uint64_t)-1;
    ma_utg_t *xReads = NULL, *yReads = NULL;
    ma_hit_t_alloc *xR = NULL;
    ma_hit_t *h = NULL;
    ma_sub_t *sq = NULL, *st = NULL;
    asg_t* nsg = ug->g;
    uint32_t i, j, v, rId, k, is_Unitig, Hap_uId, xUid, yUid, seedOcc;
    uint64_t tmp, max_weight, m;
    long long r_x_pos_beg, r_x_pos_end, r_y_pos_beg, r_y_pos_end, max_score;
    int32_t r;
    asg_arc_t t;
    asg_arc_t_offset t_offset;
    hap_overlaps hap_align;
    hap_overlaps *hap_align_x = NULL;
    xUid = Input_uId;
    if(nsg->seq[xUid].del || nsg->seq[xUid].c == ALTER_LABLE) return;
    memset(vote_counting, 0, sizeof(uint64_t)*nsg->n_seq);
    memset(visit, 0, nsg->n_seq);
    u_vecs->a.n = 0;
    u_can->a.n = 0;

    xReads = &(ug->u.a[xUid]);
    for (i = 0; i < xReads->n; i++)
    {
        xR = &(reverse_sources[xReads->a[i]>>33]);
        
        for (k = 0; k < xR->length; k++)
        {
            rId = Get_tn(xR->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_uId, &is_Unitig);
            if(is_Unitig == 0 || Hap_uId == (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_uId]!=0) continue; ///one read only has one vote for one hap unitig
            visit[Hap_uId] = 1;
            if(vote_counting[Hap_uId] < UINT64_MAX) vote_counting[Hap_uId]++;
        }

        clean_visit_flag(visit, read_g, ruIndex, nsg->n_seq, xR);
    }



    u_vecs->a.n = 0;
    for (i = 0; i < nsg->n_seq; i++)
    {
        if(i == xUid) 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);


    ///scan each candidate unitig
    for (i = 0; i < u_vecs->a.n; i++)
    {
        yUid = (uint32_t)u_vecs->a.a[i];
        seedOcc = u_vecs->a.a[i]>>32;
        xReads = &(ug->u.a[xUid]);
        yReads = &(ug->u.a[yUid]);
        u_buffer->a.n = 0;

        for (k = 0; k < xReads->n; k++)
        {
            xR = &(reverse_sources[xReads->a[k]>>33]);
            hhc = hh[xReads->a[k]>>33];
            for (j = 0; j < xR->length; j++)
            {
                h = &(xR->buffer[j]);
                sq = &(coverage_cut[Get_qn(*h)]);
                st = &(coverage_cut[Get_tn(*h)]);
                if(st->del || read_g->seq[Get_tn(*h)].del) continue;

                r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, 
                                asm_opt.max_hang_rate, min_ovlp, &t);
                ///if it is a contained overlap, skip
                if(r < 0) continue;

                rId = t.v>>1;
                if(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_uId, &is_Unitig);
                if(is_Unitig == 0 || Hap_uId == (uint32_t)-1) continue;
                if(Hap_uId != yUid) continue;

                v = xReads->a[k]>>32;
                get_R_to_U(ruIndex, v>>1, &Hap_uId, &is_Unitig);
                if(is_Unitig == 0 || Hap_uId == (uint32_t)-1) continue;
                if(Hap_uId != xUid) continue;
                if((uint32_t)(position_index[v>>1]) != k) continue;

                if(asm_opt.purge_level_primary <= 2 &&
                    (prefilter((uint32_t)(position_index[v>>1]), (uint32_t)(position_index[rId]), 
                    xReads->n, yReads->n, 0, Hap_rate, seedOcc)==NON_PLOID) && 
                   (prefilter((uint32_t)(position_index[v>>1]), (uint32_t)(position_index[rId]), 
                    xReads->n, yReads->n, 1, Hap_rate, seedOcc)==NON_PLOID))
                {
                    continue;
                }
            
                t_offset.Off = get_xy_pos(read_g, &t, v, (yReads->a[(uint32_t)(position_index[rId])])>>32, 
                xReads->len, yReads->len, position_index, &(t.el));
                if(((t_offset.Off>>32) == (uint32_t)-1) || (((uint32_t)t_offset.Off) == (uint32_t)-1)) continue;

                t_offset.x = t;
                t_offset.weight = hhc;

                kv_push(asg_arc_t_offset, u_buffer->a, t_offset);
            }

            deduplicate_edge(u_buffer);
        }

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

        
        get_candidate_hap_alignment(u_can, u_buffer, score_vc, prevIndex_vec, begIndex_vec,
        flag_vec, chain_rate, 50, xReads->len, yReads->len);

        if(u_can->a.n == 0) continue;
        
        qsort(u_can->a.a, u_can->a.n, sizeof(hap_candidates), cmp_hap_candidates);

        memset(&hap_align, 0, sizeof(hap_overlaps));    
        m = all_ovlp->x[xUid].a.n;     
        max_weight = 0; max_score = 0;
        for (k = 0; k < u_can->a.n; k++)
        {
            if(u_can->a.a[k].weight < max_weight*0.33) continue;
            if(calculate_pair_hap_similarity_advance(&(u_can->a.a[k]), position_index, xUid, yUid, 
            xReads, yReads, sources, reverse_sources, read_g, ruIndex, coverage_cut, Hap_rate,
            (asm_opt.purge_level_primary<=2? 0:1), max_hang, min_ovlp, cov_threshold, u_buffer, 
            score_vc, prevIndex_vec, cov, &r_x_pos_beg, &r_x_pos_end, &r_y_pos_beg, &r_y_pos_end, &sim)!=PLOID)
            {
                continue;
            }
            ///max_weight == 0 means the first matched chain
            if(max_weight == 0 || max_score < u_can->a.a[k].score) max_score = u_can->a.a[k].score;
            if(max_weight < u_can->a.a[k].weight) max_weight = u_can->a.a[k].weight;
            ///if one is positive and another one is negative, it is wrong
            if(!filter_secondary_chain(max_score, u_can->a.a[k].score, CHAIN_FILTER_RATE)) continue;
                            
            hap_align.rev = Get_rev(u_can->a.a[k]);
            hap_align.type = Get_type(u_can->a.a[k]);
            hap_align.x_beg_id = Get_x_beg(u_can->a.a[k]);
            hap_align.x_end_id = Get_x_end(u_can->a.a[k]) + 1;
            hap_align.y_beg_id = Get_y_beg(u_can->a.a[k]);
            hap_align.y_end_id = Get_y_end(u_can->a.a[k]) + 1;
            hap_align.weight = Get_match(u_can->a.a[k]);
            hap_align.score = u_can->a.a[k].score;
            hap_align.x_beg_pos = r_x_pos_beg;
            hap_align.x_end_pos = r_x_pos_end + 1;
            if(hap_align.rev == 0)
            {
                hap_align.y_beg_pos = r_y_pos_beg;
                hap_align.y_end_pos = r_y_pos_end + 1;
            }
            else
            {
                hap_align.y_beg_pos = yReads->len - r_y_pos_end - 1;
                hap_align.y_end_pos = yReads->len - r_y_pos_beg - 1 + 1;
            }
            hap_align.xUid = xUid;
            hap_align.yUid = yUid;
            hap_align.status = SELF_EXIST;
            hap_align.s = sim;
            kv_push(hap_overlaps, all_ovlp->x[hap_align.xUid].a, hap_align);
        }
        /**
        ///chains with same xUid && yUid
        for (k = m; k < all_ovlp->x[xUid].a.n; k++)
        {
            if(!filter_secondary_chain(max_score, 
                        all_ovlp->x[xUid].a.a[k].score, CHAIN_FILTER_RATE))
            {
                continue;
            } 
            all_ovlp->x[xUid].a.a[m] = all_ovlp->x[xUid].a.a[k];
            m++;
        }
        all_ovlp->x[xUid].a.n = m;
        **/

        hap_align_x = NULL;
        for (k = m; k < all_ovlp->x[xUid].a.n; k++)
        {
            if(all_ovlp->x[xUid].a.a[k].score != max_score) continue;
            if(hap_align_x == NULL || all_ovlp->x[xUid].a.a[k].weight > hap_align_x->weight)
            {
                hap_align_x = &(all_ovlp->x[xUid].a.a[k]);
            }
            else if(all_ovlp->x[xUid].a.a[k].weight == hap_align_x->weight)
            {
                if((all_ovlp->x[xUid].a.a[k].x_end_pos 
                            - all_ovlp->x[xUid].a.a[k].x_beg_pos) < 
                    (hap_align_x->x_end_pos - hap_align_x->x_beg_pos))
                {
                    hap_align_x = &(all_ovlp->x[xUid].a.a[k]);
                }
            }
        }
        if(hap_align_x)
        {
            all_ovlp->x[xUid].a.a[m] = (*hap_align_x);
            all_ovlp->x[xUid].a.n = m + 1;
        }
    }
    // filter_secondary_ovlp(&all_ovlp->x[xUid], u_vecs, hap_buf->Hap_rate, 0.7);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq 0x18(%rdi), %rcx
movq 0x68(%rdi), %rax
testq %rax, %rax
movq $-0x1, %r8
cmovnsq %rax, %r8
movq %r8, 0x1f0(%rsp)
movq %rcx, 0x180(%rsp)
movq 0x18(%rcx), %rbp
movq 0x20(%rbp), %rax
movq %rsi, 0x158(%rsp)
movl %esi, %ecx
movq %rcx, 0xe8(%rsp)
cmpl $0x0, (%rax,%rcx,8)
js 0x111b6c
movq 0xe8(%rsp), %rcx
cmpb $0x1, 0x4(%rax,%rcx,8)
je 0x111b6c
movq 0x20(%rdi), %rax
movq %rax, 0xc8(%rsp)
movq 0x30(%rdi), %rax
movq %rax, 0x140(%rsp)
movq 0x38(%rdi), %rax
movq %rax, 0xd8(%rsp)
movq 0x40(%rdi), %rax
movq %rax, 0xa8(%rsp)
movq 0x48(%rdi), %rax
movq %rax, 0xf0(%rsp)
movss 0x50(%rdi), %xmm0
movss %xmm0, 0xe4(%rsp)
movl 0x54(%rdi), %eax
movl %eax, 0x124(%rsp)
movl 0x58(%rdi), %eax
movl %eax, 0x120(%rsp)
movss 0x5c(%rdi), %xmm0
movss %xmm0, 0x160(%rsp)
movq 0x60(%rdi), %rax
movq %rax, 0x130(%rsp)
movslq %edx, %rax
imulq $0xf0, %rax, %rcx
movq (%rdi), %rsi
movq 0x10(%rdi), %rax
movq %rax, 0x1f8(%rsp)
leaq (%rsi,%rcx), %r15
addq $0x10, %r15
movq 0x70(%rdi), %rax
movq %rax, 0x188(%rsp)
movl 0x14(%rbp), %edx
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %rdx
shlq $0x3, %rdx
movq -0x10(%r15), %rdi
movq -0x8(%r15), %r13
movq %rcx, 0x108(%rsp)
movq %rsi, 0xc0(%rsp)
leaq (%rsi,%rcx), %r12
addq $0xd0, %r12
xorl %r14d, %r14d
movq %rdi, 0x98(%rsp)
xorl %esi, %esi
callq 0x20e0
movq %rbp, 0xb0(%rsp)
movl 0x14(%rbp), %edx
andq %rbx, %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x20e0
movq %r15, 0x128(%rsp)
movq %r14, (%r15)
movq %r12, 0x190(%rsp)
movq %r14, (%r12)
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xe8(%rsp), %rcx
leaq (%rcx,%rcx,4), %rcx
movq %rcx, 0x178(%rsp)
cmpl $0x0, 0x10(%rax,%rcx,8)
je 0x110e40
movq 0x178(%rsp), %rcx
leaq (%rax,%rcx,8), %rcx
xorl %r14d, %r14d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq %rcx, 0xf8(%rsp)
movq 0x18(%rcx), %rax
movq (%rax,%r14,8), %rax
shrq $0x21, %rax
leaq (%rax,%rax,2), %rax
movq 0x140(%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
cmpl $0x0, 0xc(%rbx)
je 0x110d29
movl $0xc, %r15d
xorl %ebp, %ebp
movq (%rbx), %rax
movl (%rax,%r15), %esi
movl %esi, 0xa4(%rsp)
movq 0xc8(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
js 0x110ccd
movl 0xa4(%rsp), %esi
movq 0xd8(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xa306f
cmpl $0x0, 0x90(%rsp)
sete %cl
movl 0xa0(%rsp), %eax
cmpl $-0x1, %eax
sete %dl
orb %cl, %dl
jne 0x110d16
movl %eax, %eax
cmpb $0x0, (%r13,%rax)
jne 0x110d16
movb $0x1, (%r13,%rax)
movl 0xa0(%rsp), %eax
movq 0x98(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
cmpq $-0x1, %rcx
je 0x110d16
incq %rcx
movq 0x98(%rsp), %rdx
movq %rcx, (%rdx,%rax,8)
jmp 0x110d16
movq 0xd8(%rsp), %rdi
leaq 0xa4(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xa306f
movl 0xa4(%rsp), %eax
cmpq %r12, %rax
je 0x110d16
cmpl $0x1, 0x90(%rsp)
je 0x110d16
movq 0xc8(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpl $0x0, (%rcx,%rax,8)
jns 0x110c4f
incq %rbp
movl 0xc(%rbx), %eax
addq $0x28, %r15
cmpq %rax, %rbp
jb 0x110c2f
movq 0xb0(%rsp), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl 0xc(%rbx), %eax
leal (%rax,%rax), %ecx
cmpl %edx, %ecx
jbe 0x110d53
movq %r13, %rdi
xorl %esi, %esi
callq 0x20e0
jmp 0x110e29
testl %eax, %eax
je 0x110e29
movl $0xc, %r15d
xorl %ebp, %ebp
movq (%rbx), %rax
movl (%rax,%r15), %esi
movl %esi, 0x118(%rsp)
movq 0xc8(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rsi,8)
js 0x110dcd
movl 0x118(%rsp), %esi
movq 0xd8(%rsp), %rdi
leaq 0x148(%rsp), %rdx
leaq 0x110(%rsp), %rcx
callq 0xa306f
cmpl $0x0, 0x110(%rsp)
sete %cl
movl 0x148(%rsp), %eax
cmpl $-0x1, %eax
sete %dl
orb %cl, %dl
jne 0x110e16
movl %eax, %eax
movb $0x0, (%r13,%rax)
jmp 0x110e16
movq 0xd8(%rsp), %rdi
leaq 0x118(%rsp), %rdx
leaq 0x110(%rsp), %rcx
callq 0xa306f
movl 0x118(%rsp), %eax
cmpq %r12, %rax
je 0x110e16
cmpl $0x1, 0x110(%rsp)
je 0x110e16
movq 0xc8(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpl $0x0, (%rcx,%rax,8)
jns 0x110d83
incq %rbp
movl 0xc(%rbx), %eax
addq $0x28, %r15
cmpq %rax, %rbp
jb 0x110d63
incq %r14
movq 0xf8(%rsp), %rcx
movl 0x10(%rcx), %eax
cmpq %rax, %r14
jb 0x110c01
movq 0x108(%rsp), %rbp
movq 0xc0(%rsp), %rax
leaq (%rax,%rbp), %r13
movq 0x128(%rsp), %rax
movq $0x0, (%rax)
movq 0xb0(%rsp), %r12
testl $0x7fffffff, 0x14(%r12) # imm = 0x7FFFFFFF
movq 0xe8(%rsp), %rsi
je 0x110efb
xorl %ebx, %ebx
movl $0x2, %r14d
cmpq %rbx, %rsi
je 0x110ee9
movq 0x98(%rsp), %rax
movq (%rax,%rbx,8), %r15
testq %r15, %r15
je 0x110ee9
movq 0x18(%r13), %rax
cmpq %rax, 0x10(%r13)
jne 0x110ece
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x18(%r13)
movq 0x20(%r13), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0xe8(%rsp), %rsi
movq %rax, 0x20(%r13)
shlq $0x20, %r15
addq %rbx, %r15
movq 0x10(%r13), %rax
movq 0x20(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%r13)
movq %r15, (%rcx,%rax,8)
incq %rbx
movl 0x14(%r12), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %rbx
jb 0x110e86
movq 0x128(%rsp), %rax
cmpq $0x0, (%rax)
je 0x111b6c
movq 0x128(%rsp), %rbx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x9fc63
cmpq $0x0, (%rbx)
je 0x111b6c
movq 0xc0(%rsp), %rcx
leaq (%rcx,%rbp), %rax
addq $0x30, %rax
movq %rax, 0x138(%rsp)
leaq 0x50(%rcx,%rbp), %rax
movq %rax, 0x1a0(%rsp)
leaq 0x70(%rcx,%rbp), %rax
movq %rax, 0x198(%rsp)
leaq 0xb0(%rcx,%rbp), %rax
movq %rax, 0x1c8(%rsp)
leaq (%rcx,%rbp), %rax
addq $0x90, %rax
movq %rax, 0x1c0(%rsp)
xorl %ecx, %ecx
movq 0xe8(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq %rax, 0xd0(%rsp)
movq %r13, 0x150(%rsp)
movq 0x20(%r13), %rax
movq %rcx, 0x1e8(%rsp)
movq (%rax,%rcx,8), %rdx
movq 0x180(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x178(%rsp), %rcx
leaq (%rax,%rcx,8), %rbx
movq %rdx, 0xf8(%rsp)
movl %edx, %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0xc0(%rsp)
movq $0x0, 0x30(%r13)
cmpl $0x0, 0x10(%rbx)
je 0x11150f
movq 0xf8(%rsp), %rax
shrq $0x20, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movss %xmm0, 0xbc(%rsp)
xorl %ecx, %ecx
movq %rbx, 0xb0(%rsp)
movq 0x18(%rbx), %rax
movq %rcx, 0x98(%rsp)
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
leaq (%rax,%rax,2), %rcx
movq 0x140(%rsp), %rdx
cmpl $0x0, 0xc(%rdx,%rcx,8)
movq 0xa8(%rsp), %r8
je 0x1114e3
movq 0x140(%rsp), %rdx
leaq (%rdx,%rcx,8), %rbp
movq 0x1f8(%rsp), %rcx
movzbl (%rcx,%rax), %eax
movq %rax, 0x108(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%rbp), %rdi
movl 0xc(%rdi,%r12), %edx
leaq (%rdx,%rdx,2), %rcx
movl (%r8,%rcx,4), %eax
testl %eax, %eax
js 0x111464
movq 0xc8(%rsp), %rsi
movq 0x20(%rsi), %r15
cmpl $0x0, (%r15,%rdx,8)
js 0x111464
movl 0x4(%rdi,%r12), %edx
addq %r12, %rdi
leaq (%rdx,%rdx,2), %rdx
leaq (%r8,%rdx,4), %rdx
leaq (%r8,%rcx,4), %rcx
movl 0x4(%rdx), %esi
movl (%rdx), %edx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %edx
subl %edx, %esi
movl 0x4(%rcx), %edx
subl %eax, %edx
leaq 0x179687(%rip), %rax    # 0x28a758
movss 0x158(%rax), %xmm0
movl 0x124(%rsp), %ecx
movl 0x120(%rsp), %r8d
leaq 0x1a8(%rsp), %r9
callq 0x107fb9
movq 0xa8(%rsp), %r8
testl %eax, %eax
js 0x111464
movl 0x1b0(%rsp), %r14d
movl %r14d, %esi
shrl %esi
movl %esi, 0xa4(%rsp)
cmpl $0x0, (%r15,%rsi,8)
js 0x111464
movq 0xd8(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xa306f
movq 0xa8(%rsp), %r8
cmpl $0x0, 0x90(%rsp)
je 0x111464
movl 0xa0(%rsp), %eax
cmpl $-0x1, %eax
je 0x111464
cmpl 0xf8(%rsp), %eax
jne 0x111464
movq 0xb0(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x98(%rsp), %rcx
movq (%rax,%rcx,8), %r15
movq %r15, %r13
shrq $0x21, %r13
movq 0xd8(%rsp), %rdi
movl %r13d, %esi
leaq 0xa0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xa306f
movq 0xa8(%rsp), %r8
cmpl $0x0, 0x90(%rsp)
je 0x111464
movl 0xa0(%rsp), %eax
cmpl $-0x1, %eax
je 0x111464
cmpl 0x158(%rsp), %eax
jne 0x111464
movq 0xf0(%rsp), %rax
movq (%rax,%r13,8), %r9
movl %r9d, %eax
cmpq %rax, 0x98(%rsp)
jne 0x111464
leaq 0x17954e(%rip), %rax    # 0x28a758
cmpl $0x2, 0x130(%rax)
jg 0x1112a7
movl 0xa4(%rsp), %eax
movq 0xf0(%rsp), %rcx
movl (%rcx,%rax,8), %eax
movq 0xb0(%rsp), %rcx
movl 0x10(%rcx), %edx
movq 0xc0(%rsp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, %esi
subl %eax, %esi
subl %r9d, %edx
cmpl %r9d, %eax
movl %r9d, %edi
cmovbl %eax, %edi
cmpl %esi, %edx
cmovbl %edx, %esi
addl %edi, %esi
je 0x111270
cvtsi2ss %rsi, %xmm0
mulss 0xe4(%rsp), %xmm0
ucomiss 0xbc(%rsp), %xmm0
jb 0x1112a7
incl %eax
subl %eax, %ecx
cmpl %r9d, %ecx
cmovael %r9d, %ecx
cmpl %eax, %edx
cmovbl %edx, %eax
addl %ecx, %eax
je 0x111464
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
mulss 0xe4(%rsp), %xmm0
ucomiss 0xbc(%rsp), %xmm0
jae 0x111464
shrq $0x20, %r15
movq 0xc0(%rsp), %rsi
movq 0x18(%rsi), %rax
movl 0xa4(%rsp), %ecx
movq 0xf0(%rsp), %rdx
movl (%rdx,%rcx,8), %ecx
movq (%rax,%rcx,8), %r10
movq 0xb0(%rsp), %rax
movl (%rax), %edi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %edi
movl (%rsi), %esi
andl %edx, %esi
movq 0x1a8(%rsp), %rax
shrq $0x20, %rax
cmpq %r15, %rax
jne 0x111314
shrq $0x20, %r9
movq 0xc8(%rsp), %rax
movq 0x20(%rax), %rax
movl (%rax,%r13,8), %eax
andl %edx, %eax
addl %eax, %r9d
decl %r9d
xorl %r15d, %r15d
jmp 0x111327
xorl %r15d, %eax
cmpl $0x1, %eax
jne 0x111479
shrq $0x20, %r9
movb $0x1, %r15b
movq %r10, %rax
shrq $0x20, %rax
cmpl %eax, %r14d
jne 0x111355
shrq $0x21, %r10
movq 0xf0(%rsp), %rax
movl 0x4(%rax,%r10,8), %eax
movl 0x1b4(%rsp), %ecx
andl %edx, %ecx
addl %ecx, %eax
decl %eax
xorl %ecx, %ecx
jmp 0x111392
xorl %eax, %r14d
cmpl $0x1, %r14d
jne 0x1114b2
shrq $0x21, %r10
movq 0xc8(%rsp), %rax
movq 0x20(%rax), %rax
movl (%rax,%r10,8), %eax
andl %edx, %eax
movl 0x1b4(%rsp), %ecx
andl %edx, %ecx
movq 0xf0(%rsp), %rdx
addl 0x4(%rdx,%r10,8), %eax
subl %ecx, %eax
movb $0x1, %cl
movl %ecx, %edx
xorb %r15b, %dl
movb %dl, 0x1ba(%rsp)
cmpb %cl, %r15b
je 0x1113b0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %esi, %eax
jae 0x1113b2
notl %eax
addl %esi, %eax
movl %eax, %ecx
cmpl %edi, %r9d
movl %r9d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovael %eax, %r15d
cmpl %esi, %ecx
movl %ecx, %r14d
cmovael %eax, %r14d
cmpl %edi, %r9d
jae 0x111464
cmpl %esi, %ecx
jae 0x111464
movq 0x150(%rsp), %r13
movq 0x38(%r13), %rax
cmpq %rax, 0x30(%r13)
jne 0x11141e
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x38(%r13)
movq 0x40(%r13), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movq 0xa8(%rsp), %r8
movq %rax, 0x40(%r13)
shlq $0x20, %r15
orq %r15, %r14
movq 0x30(%r13), %rax
movq 0x40(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%r13)
leaq (%rax,%rax,4), %rax
movq 0x1b8(%rsp), %rdx
movq %rdx, 0x10(%rcx,%rax,8)
movups 0x1a8(%rsp), %xmm0
movups %xmm0, (%rcx,%rax,8)
movq %r14, 0x18(%rcx,%rax,8)
movq 0x108(%rsp), %rdx
movq %rdx, 0x20(%rcx,%rax,8)
incq %rbx
movl 0xc(%rbp), %eax
addq $0x28, %r12
cmpq %rax, %rbx
jb 0x111071
jmp 0x1114e3
movl %esi, %r15d
movl %edi, %r13d
movq %r10, 0x100(%rsp)
callq 0x13d86
movq 0x100(%rsp), %r10
movl %r13d, %edi
movl %r15d, %esi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq 0xa8(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
jmp 0x11130f
movq %r9, %r14
movl %esi, %r13d
movl %edi, 0x100(%rsp)
callq 0x13da8
movl 0x100(%rsp), %edi
movl %r13d, %esi
movq %r14, %r9
movq 0xa8(%rsp), %r8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x111351
movq 0x138(%rsp), %rdi
callq 0x105d2a
movq 0x98(%rsp), %rcx
incq %rcx
movq 0xb0(%rsp), %rbx
movl 0x10(%rbx), %eax
cmpq %rax, %rcx
jb 0x111019
movq 0x138(%rsp), %rax
cmpq $0x0, (%rax)
movq 0x190(%rsp), %r14
movq 0x150(%rsp), %r13
je 0x111b51
movl (%rbx), %eax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rax
movq 0xc0(%rsp), %rcx
movl (%rcx), %ecx
andq %rdx, %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq $0x32, (%rsp)
movq %r14, %rdi
movq 0x138(%rsp), %rsi
movq 0x1a0(%rsp), %rdx
movq 0x198(%rsp), %rcx
movq 0x1c8(%rsp), %r8
movq 0x1c0(%rsp), %r9
movss 0x160(%rsp), %xmm0
callq 0x10bc08
movq (%r14), %rsi
testq %rsi, %rsi
je 0x111b51
movq 0xe0(%r13), %rdi
movl $0x48, %edx
leaq -0xb698(%rip), %rcx     # 0x105f1a
callq 0x23f0
movq 0x130(%rsp), %rax
movq (%rax), %rax
movq 0xd0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x1d0(%rsp)
cmpq $0x0, 0xd0(%r13)
je 0x111a5d
movq %rbx, 0xb0(%rsp)
movl $0x1, %ebp
xorl %ecx, %ecx
movq $0x0, 0x98(%rsp)
xorl %r12d, %r12d
movq 0xa8(%rsp), %r8
movq 0x188(%rsp), %rbx
movq 0xe0(%r13), %rax
leaq (%rcx,%rcx,8), %r15
movsd (%rax,%r15,8), %xmm0
movsd 0x113c15(%rip), %xmm2   # 0x225240
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x113c1a(%rip), %xmm3   # 0x225250
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movq %r12, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd 0x11be51(%rip), %xmm2   # 0x22d4b8
ucomisd %xmm1, %xmm2
ja 0x111a4e
leaq (%rax,%r15,8), %rdi
xorl %eax, %eax
leaq 0x1790da(%rip), %rcx    # 0x28a758
cmpl $0x3, 0x130(%rcx)
setge %al
leaq 0x174(%rsp), %rcx
movq %rcx, 0x88(%rsp)
leaq 0x200(%rsp), %rcx
movq %rcx, 0x80(%rsp)
leaq 0x148(%rsp), %rcx
movq %rcx, 0x78(%rsp)
leaq 0x110(%rsp), %rcx
movq %rcx, 0x70(%rsp)
leaq 0x118(%rsp), %rcx
movq %rcx, 0x68(%rsp)
movq %rbx, 0x60(%rsp)
movq 0x198(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movq 0x1a0(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movq 0x138(%rsp), %rcx
movq %rcx, 0x48(%rsp)
movq 0x1f0(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movl 0x120(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movl 0x124(%rsp), %ecx
movl %ecx, 0x30(%rsp)
movq %r8, 0x20(%rsp)
movq 0xd8(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq 0xc8(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq 0x140(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movl %eax, 0x28(%rsp)
movq 0xf0(%rsp), %rsi
movq 0x158(%rsp), %rdx
movq 0xf8(%rsp), %rcx
movq 0xb0(%rsp), %r8
movq 0xc0(%rsp), %r9
movss 0xe4(%rsp), %xmm0
callq 0x10ae7b
testl %eax, %eax
je 0x111795
movq 0xa8(%rsp), %r8
jmp 0x111a4e
testq %r12, %r12
movq 0x98(%rsp), %rcx
je 0x1117b0
movq 0xe0(%r13), %rax
cmpq 0x20(%rax,%r15,8), %rcx
jge 0x1117bc
movq 0xe0(%r13), %rax
movq 0x20(%rax,%r15,8), %rcx
movq 0xe0(%r13), %rax
movq (%rax,%r15,8), %r9
cmpq %r9, %r12
cmovbeq %r9, %r12
movq %rcx, 0x98(%rsp)
subq 0x20(%rax,%r15,8), %rcx
movq 0xa8(%rsp), %r8
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
jle 0x11181b
movq 0x98(%rsp), %rdi
movq %rdi, %rdx
negq %rdx
cmovsq %rdi, %rdx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
cvtsi2sd %rdx, %xmm1
mulsd 0x11bcaf(%rip), %xmm1   # 0x22d4c0
ucomisd %xmm1, %xmm0
jae 0x111a4e
leaq (%rax,%r15,8), %rax
movb 0x28(%rax), %r10b
movl 0x200(%rsp), %r15d
testb %r10b, %r10b
je 0x111851
movq 0xc0(%rsp), %rcx
movl (%rcx), %ecx
andl %esi, %ecx
notl %r15d
addl %ecx, %r15d
subl 0x148(%rsp), %ecx
movl %r15d, %r11d
movl %ecx, %r15d
jmp 0x11185c
movl 0x148(%rsp), %r11d
incl %r15d
movq 0xd0(%rsp), %rdx
movb 0x1c(%rax), %cl
movb %cl, 0x97(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x170(%rsp)
movl 0xc(%rax), %r14d
movl 0x10(%rax), %ecx
movl %ecx, 0x100(%rsp)
movl 0x14(%rax), %ecx
movl %ecx, 0xbc(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x108(%rsp)
movl 0x118(%rsp), %eax
movl %eax, 0x16c(%rsp)
movl 0x110(%rsp), %r13d
movss 0x174(%rsp), %xmm0
movq 0x130(%rsp), %rbx
movq (%rbx), %rax
movq 0x8(%rax,%rdx,8), %rcx
cmpq %rcx, (%rax,%rdx,8)
jne 0x111985
movq 0xd0(%rsp), %rdx
leaq (%rax,%rdx,8), %rdx
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq 0xe8(%rsp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x1d8(%rsp)
movq %rsi, 0x8(%rax,%rcx)
movq 0x8(%rdx), %rsi
movq 0x10(%rdx), %rdi
shlq $0x6, %rsi
movq %r9, 0x1e0(%rsp)
movb %r10b, 0x96(%rsp)
movl %r11d, 0x168(%rsp)
movss %xmm0, 0x164(%rsp)
callq 0x2370
movss 0x164(%rsp), %xmm0
movl 0x168(%rsp), %r11d
movb 0x96(%rsp), %r10b
movq 0x1e0(%rsp), %r9
movq 0xd0(%rsp), %rdx
movq 0xa8(%rsp), %r8
movq (%rbx), %rcx
movq 0x1d8(%rsp), %rsi
movq %rax, 0x10(%rcx,%rsi)
movq (%rbx), %rax
movq (%rax,%rdx,8), %rcx
movq %rdx, %rdi
movq 0x10(%rax,%rdx,8), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rax,%rdi,8)
shlq $0x6, %rcx
movb %r10b, (%rdx,%rcx)
movb 0x97(%rsp), %al
movb %al, 0x1(%rdx,%rcx)
movw $0x0, 0x2(%rdx,%rcx)
movl 0x16c(%rsp), %eax
movl %eax, 0x4(%rdx,%rcx)
incl %r13d
movl %r13d, 0x8(%rdx,%rcx)
movl %r11d, 0xc(%rdx,%rcx)
movl %r15d, 0x10(%rdx,%rcx)
movl 0x170(%rsp), %eax
movl %eax, 0x14(%rdx,%rcx)
incl %r14d
movl %r14d, 0x18(%rdx,%rcx)
movl 0x100(%rsp), %eax
movl %eax, 0x1c(%rdx,%rcx)
movl 0xbc(%rsp), %eax
incl %eax
movl %eax, 0x20(%rdx,%rcx)
movq 0x158(%rsp), %rax
movl %eax, 0x24(%rdx,%rcx)
movq 0xf8(%rsp), %rax
movl %eax, 0x28(%rdx,%rcx)
movl %r9d, 0x2c(%rdx,%rcx)
movq 0x108(%rsp), %rax
movq %rax, 0x30(%rdx,%rcx)
movss %xmm0, 0x38(%rdx,%rcx)
movl $0x0, 0x3c(%rdx,%rcx)
movq 0x188(%rsp), %rbx
movq 0x190(%rsp), %r14
movq 0x150(%rsp), %r13
movl %ebp, %ecx
incl %ebp
cmpq %rcx, (%r14)
ja 0x111612
jmp 0x111a69
movq $0x0, 0x98(%rsp)
movq 0x130(%rsp), %rax
movq (%rax), %rdx
movq 0xd0(%rsp), %rdi
leaq (%rdx,%rdi,8), %rax
movq (%rax), %rcx
movq 0x1d0(%rsp), %rbx
movl %ebx, %r9d
cmpq %r9, %rcx
jbe 0x111afd
movq 0x10(%rax), %rsi
leaq (%rdx,%rdi,8), %rdi
addq $0x10, %rdi
leal 0x1(%rbx), %r8d
xorl %edx, %edx
movq 0x98(%rsp), %r14
shlq $0x6, %r9
cmpq %r14, 0x30(%rsi,%r9)
jne 0x111ad1
testq %rdx, %rdx
je 0x111acb
leaq (%rsi,%r9), %r10
movl 0x2c(%rdx), %r11d
cmpl %r11d, 0x2c(%r10)
jbe 0x111ade
addq (%rdi), %r9
movq %r9, %rdx
movl %r8d, %r9d
incl %r8d
cmpq %r9, %rcx
ja 0x111aad
jmp 0x111aff
jne 0x111ad1
movl 0x8(%r10), %r9d
subl 0x4(%r10), %r9d
movl 0x8(%rdx), %r11d
subl 0x4(%rdx), %r11d
cmpl %r11d, %r9d
jb 0x111af8
movq %rdx, %r10
movq %r10, %rdx
jmp 0x111ad1
xorl %edx, %edx
testq %rdx, %rdx
je 0x111b51
movq 0x10(%rax), %rax
movq %rbx, %rcx
shlq $0x6, %rcx
movups (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movupd 0x20(%rdx), %xmm2
movupd 0x30(%rdx), %xmm3
movupd %xmm3, 0x30(%rax,%rcx)
movupd %xmm2, 0x20(%rax,%rcx)
movupd %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
incq %rbx
movq 0x130(%rsp), %rax
movq (%rax), %rax
movq 0xd0(%rsp), %rcx
movq %rbx, (%rax,%rcx,8)
movq 0x1e8(%rsp), %rcx
incl %ecx
movq 0x128(%rsp), %rax
cmpq %rcx, (%rax)
ja 0x110f9e
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq