// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: chain_trans_ovlp(hap_cov_t*, utg_trans_t*, ma_ug_t*, asg_t*, buf_t*, unsigned int, unsigned int*)
void chain_trans_ovlp(hap_cov_t *cover, utg_trans_t *o, ma_ug_t *ug, asg_t *read_sg, buf_t* xReads, uint32_t targetBaseLen, uint32_t* xEnd)
{
    ma_hit_t_alloc* reverse_sources = (o? o->reverse_sources:cover->reverse_sources);
    ma_sub_t *coverage_cut = (o? o->coverage_cut:cover->coverage_cut);
    int max_hang = (o? o->max_hang:cover->max_hang);
    int min_ovlp = (o? o->min_ovlp:cover->min_ovlp);
    kvec_asg_arc_t_offset* u_buffer = (o? &(o->u_buffer):&(cover->u_buffer));
    kvec_t_i32_warp* tailIndex = (o? &(o->tailIndex):&(cover->tailIndex));
    kvec_t_i32_warp* prevIndex = (o? &(o->prevIndex):&(cover->prevIndex));
    uint64_t *pos_idx = (o? o->pos_idx:cover->pos_idx);
    ma_hit_t_alloc *xR = NULL;
    ma_hit_t *h = NULL;
    ma_sub_t *sq = NULL, *st = NULL;
    int32_t r;
    asg_arc_t t;
    uint32_t rId, v, w;
    uint64_t tmp;
    asg_arc_t_offset t_offset;
    u_buffer->a.n = 0;
    ///(*xEnd) = (uint32_t)-1;
    (*xEnd) = 0;
    uint32_t u_i, r_i, k, j, len, p_v, *a = xReads->b.a, uid, ori, l, m, aOcc, nv, xOcc = (uint32_t)-1;
    ma_utg_t* u = NULL;
    asg_arc_t *av  = NULL;


    for (u_i = r_i = len = aOcc = 0, xOcc = (uint32_t)-1, p_v = (uint32_t)-1; u_i < xReads->b.n; u_i++)
    {
        uid = a[u_i] >> 1;
        ori = a[u_i] & 1;
        u = &(ug->u.a[uid]);
        if(u->n == 0) continue;

        for (r_i = 0; r_i < u->n; r_i++, aOcc++)
        {
            l = 0;
            v = (ori == 1?((uint64_t)((u->a[u->n - r_i - 1])^(uint64_t)(0x100000000)))>>32:((uint64_t)(u->a[r_i]))>>32);

            if(p_v != (uint32_t)-1)
            {
                av = asg_arc_a(read_sg, p_v);
                nv = asg_arc_n(read_sg, p_v);
                
                for (k = 0; k < nv; k++)
                {
                    if(av[k].del) continue;
                    if(av[k].v == v) 
                    {
                        l = asg_arc_len(av[k]);
                        break;
                    }
                }
                if(k == nv) fprintf(stderr, "ERROR\n");
            }

            p_v = v; len += l;
            if(len >= targetBaseLen)///might be not right for centromeres 
            {
                xOcc = aOcc;
                break;
            }
        }

        if(xOcc != (uint32_t)-1) break;
    }
    if(xOcc == (uint32_t)-1) xOcc = aOcc;
    if(xOcc == 0) xOcc = 1;



    for (u_i = r_i = len = aOcc = 0, p_v = (uint32_t)-1; u_i < xReads->b.n; u_i++)
    {
        uid = a[u_i] >> 1;
        ori = a[u_i] & 1;
        u = &(ug->u.a[uid]);
        if(u->n == 0) continue;

        for (r_i = 0; r_i < u->n; r_i++, aOcc++)
        {
            if(aOcc >= xOcc) break;
            l = 0;
            v = (ori == 1?((uint64_t)((u->a[u->n - r_i - 1])^(uint64_t)(0x100000000)))>>32:((uint64_t)(u->a[r_i]))>>32);

            if(p_v != (uint32_t)-1)
            {
                av = asg_arc_a(read_sg, p_v);
                nv = asg_arc_n(read_sg, p_v);
                
                for (k = 0; k < nv; k++)
                {
                    if(av[k].del) continue;
                    if(av[k].v == v) 
                    {
                        l = asg_arc_len(av[k]);
                        break;
                    }
                }
                if(k == nv) fprintf(stderr, "ERROR\n");
            }

            p_v = v; len += l;

            xR = &(reverse_sources[v>>1]);
            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_sg->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_sg->seq[rId].del == 1) continue;
                if(pos_idx[rId] == (uint64_t)-1) continue;
                w = (uint32_t)(pos_idx[rId]);
                if(rId != (w>>1)) continue;

                tmp = get_xy_pos_by_pos(read_sg, &t, v, w, len, pos_idx[w>>1]>>32,
                                                    (uint32_t)-1, targetBaseLen, &(t.el));
                if(((tmp>>32) == (uint32_t)-1) || (((uint32_t)tmp) == (uint32_t)-1)) continue;
                if(t.el) continue; ///must

                t_offset.Off = tmp;
                t_offset.x = t;
                t_offset.weight = 1;
                kv_push(asg_arc_t_offset, u_buffer->a, t_offset); 
            }
        }

        if(aOcc >= xOcc) break;
    }

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

    qsort(u_buffer->a.a, u_buffer->a.n, sizeof(asg_arc_t_offset), cmp_hap_alignment_chaining);

    ///print_asg_arc_t_offset(u_buffer->a.a, u_buffer->a.n, "before");


    for (k = 1, l = 0, m = 0; k <= u_buffer->a.n; ++k)
    {
        if (k == u_buffer->a.n || u_buffer->a.a[k].x.el != u_buffer->a.a[l].x.el || 
                                            u_buffer->a.a[k].Off != u_buffer->a.a[l].Off) 
        {
            u_buffer->a.a[m] = u_buffer->a.a[l];
            for (l += 1; l < k; l++)
            {
                u_buffer->a.a[m].weight += u_buffer->a.a[l].weight;
                if(u_buffer->a.a[l].x.ol > u_buffer->a.a[m].x.ol)
                {
                    u_buffer->a.a[m].x = u_buffer->a.a[l].x;
                }
            }
            l = k;
            m++;
        }
    } 
    u_buffer->a.n = m;

    ///print_asg_arc_t_offset(u_buffer->a.a, u_buffer->a.n, "after");
    quick_LIS(u_buffer->a.a, u_buffer->a.n, tailIndex, prevIndex);
    if(tailIndex->a.n == 0) return;


    uint32_t xLen_thres = (uint32_t)-1;
    asg_arc_t_offset* best = &(u_buffer->a.a[tailIndex->a.a[tailIndex->a.n-1]]);
    for (u_i = r_i = len = aOcc = 0, p_v = (uint32_t)-1; u_i < xReads->b.n; u_i++)
    {
        uid = a[u_i] >> 1;
        ori = a[u_i] & 1;
        u = &(ug->u.a[uid]);
        if(u->n == 0) continue;

        for (r_i = 0; r_i < u->n; r_i++, aOcc++)
        {
            l = 0;
            v = (ori == 1?((uint64_t)((u->a[u->n - r_i - 1])^(uint64_t)(0x100000000)))>>32:((uint64_t)(u->a[r_i]))>>32);

            if(p_v != (uint32_t)-1)
            {
                av = asg_arc_a(read_sg, p_v);
                nv = asg_arc_n(read_sg, p_v);
                
                for (k = 0; k < nv; k++)
                {
                    if(av[k].del) continue;
                    if(av[k].v == v) 
                    {
                        l = asg_arc_len(av[k]);
                        break;
                    }
                }
                if(k == nv) fprintf(stderr, "ERROR\n");
            }

            p_v = v; len += l;

            if((v>>1) == (best->x.ul>>33) && xLen_thres == (uint32_t)-1)
            {
                ///cov->pos_idx[v>>1] = len; 
                xR = &(reverse_sources[v>>1]);
                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_sg->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_sg->seq[rId].del == 1) continue;
                    if(pos_idx[rId] == (uint64_t)-1) continue;
                    w = (uint32_t)(pos_idx[rId]);
                    if(rId != (w>>1)) continue;

                    tmp = get_xy_pos_by_pos(read_sg, &t, v, w, len, pos_idx[w>>1]>>32,
                                                        (uint32_t)-1, targetBaseLen, &(t.el));
                    if(((tmp>>32) == (uint32_t)-1) || (((uint32_t)tmp) == (uint32_t)-1)) continue;
                    if(t.el) continue; ///must

                    t_offset.Off = tmp;
                    t_offset.x = t;
                    t_offset.weight = 1;
                    if(t_offset.Off == best->Off && t_offset.x.v == best->x.v && t_offset.x.ul == best->x.ul)
                    {
                        xLen_thres = Get_xOff(best->Off) + targetBaseLen - Get_yOff(best->Off);
                    }
                }
            }

            if(len >= xLen_thres)
            {
                (*xEnd) = aOcc;
                return;
            }
        }
    }

    (*xEnd) = aOcc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1738ee
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x150(%rbp)
jmp 0x1738fd
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x173920
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x158(%rbp)
jmp 0x17392f
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x173953
movq -0x10(%rbp), %rax
movl 0x110(%rax), %eax
movl %eax, -0x15c(%rbp)
jmp 0x173960
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x15c(%rbp)
movl -0x15c(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x173982
movq -0x10(%rbp), %rax
movl 0x114(%rax), %eax
movl %eax, -0x160(%rbp)
jmp 0x17398f
movq -0x8(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x160(%rbp)
movl -0x160(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1739b0
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x168(%rbp)
jmp 0x1739bf
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1739e2
movq -0x10(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x170(%rbp)
jmp 0x1739f1
movq -0x8(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x173a14
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x178(%rbp)
jmp 0x173a25
movq -0x8(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x173a4b
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
movq %rax, -0x180(%rbp)
jmp 0x173a5a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x180(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x108(%rbp)
movl $0xffffffff, -0x124(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x130(%rbp)
movq $0x0, -0x138(%rbp)
movl $0x0, -0x11c(%rbp)
movl $0x0, -0xfc(%rbp)
movl $0x0, -0xf0(%rbp)
movl $0x0, -0xec(%rbp)
movl $0xffffffff, -0x124(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x100(%rbp) # imm = 0xFFFFFFFF
movl -0xec(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x173d98
movq -0x108(%rbp), %rax
movl -0xec(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x10c(%rbp)
movq -0x108(%rbp), %rax
movl -0xec(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x1, %eax
movl %eax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x10c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x173b7b
jmp 0x173d84
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
movq -0x130(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x173d77
movl $0x0, -0x114(%rbp)
cmpl $0x1, -0x110(%rbp)
jne 0x173beb
movq -0x130(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x130(%rbp), %rax
movl 0x10(%rax), %eax
subl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movabsq $0x100000000, %rax      # imm = 0x100000000
xorq (%rcx,%rdx,8), %rax
shrq $0x20, %rax
movq %rax, -0x188(%rbp)
jmp 0x173c0b
movq -0x130(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xf0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
movl %eax, -0xb0(%rbp)
cmpl $-0x1, -0x100(%rbp)
je 0x173d1b
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x100(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x138(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x100(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x120(%rbp)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0x120(%rbp), %eax
jae 0x173cf3
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x173ca2
jmp 0x173ce2
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0xb0(%rbp), %eax
jne 0x173ce0
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x114(%rbp)
jmp 0x173cf3
jmp 0x173ce2
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x173c73
movl -0xf4(%rbp), %eax
cmpl -0x120(%rbp), %eax
jne 0x173d19
movq 0x2502d8(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x215d9d(%rip), %rsi    # 0x389aaf
movb $0x0, %al
callq 0x22a0
jmp 0x173d1b
movl -0xb0(%rbp), %eax
movl %eax, -0x100(%rbp)
movl -0x114(%rbp), %eax
addl -0xfc(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x173d52
movl -0x11c(%rbp), %eax
movl %eax, -0x124(%rbp)
jmp 0x173d77
jmp 0x173d54
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x173b85
cmpl $-0x1, -0x124(%rbp)
je 0x173d82
jmp 0x173d98
jmp 0x173d84
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x173b08
cmpl $-0x1, -0x124(%rbp)
jne 0x173dad
movl -0x11c(%rbp), %eax
movl %eax, -0x124(%rbp)
cmpl $0x0, -0x124(%rbp)
jne 0x173dc0
movl $0x1, -0x124(%rbp)
movl $0x0, -0x11c(%rbp)
movl $0x0, -0xfc(%rbp)
movl $0x0, -0xf0(%rbp)
movl $0x0, -0xec(%rbp)
movl $0xffffffff, -0x100(%rbp) # imm = 0xFFFFFFFF
movl -0xec(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x174398
movq -0x108(%rbp), %rax
movl -0xec(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x10c(%rbp)
movq -0x108(%rbp), %rax
movl -0xec(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x1, %eax
movl %eax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x10c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x173e65
jmp 0x174384
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
movq -0x130(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x174372
movl -0x11c(%rbp), %eax
cmpl -0x124(%rbp), %eax
jb 0x173e98
jmp 0x174372
movl $0x0, -0x114(%rbp)
cmpl $0x1, -0x110(%rbp)
jne 0x173ee8
movq -0x130(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x130(%rbp), %rax
movl 0x10(%rax), %eax
subl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movabsq $0x100000000, %rax      # imm = 0x100000000
xorq (%rcx,%rdx,8), %rax
shrq $0x20, %rax
movq %rax, -0x190(%rbp)
jmp 0x173f08
movq -0x130(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xf0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x190(%rbp)
movq -0x190(%rbp), %rax
movl %eax, -0xb0(%rbp)
cmpl $-0x1, -0x100(%rbp)
je 0x174018
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x100(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x138(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x100(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x120(%rbp)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0x120(%rbp), %eax
jae 0x173ff0
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x173f9f
jmp 0x173fdf
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0xb0(%rbp), %eax
jne 0x173fdd
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x114(%rbp)
jmp 0x173ff0
jmp 0x173fdf
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x173f70
movl -0xf4(%rbp), %eax
cmpl -0x120(%rbp), %eax
jne 0x174016
movq 0x24ffdb(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x215aa0(%rip), %rsi    # 0x389aaf
movb $0x0, %al
callq 0x22a0
jmp 0x174018
movl -0xb0(%rbp), %eax
movl %eax, -0x100(%rbp)
movl -0x114(%rbp), %eax
addl -0xfc(%rbp), %eax
movl %eax, -0xfc(%rbp)
movq -0x38(%rbp), %rax
movl -0xb0(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
movq -0x70(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x17434d
movq -0x70(%rbp), %rax
movq (%rax), %rax
movl -0xf8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq -0x78(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1740e4
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1740e9
jmp 0x174339
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x80(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %esi
movq -0x88(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x88(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %edx
movl -0x44(%rbp), %ecx
leaq 0x2506d3(%rip), %rax    # 0x3c47f8
movss 0x158(%rax), %xmm0
movl -0x48(%rbp), %r8d
leaq -0xa8(%rbp), %r9
callq 0x172eb0
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
jge 0x174151
jmp 0x174339
movl -0xa0(%rbp), %eax
shrl %eax
movl %eax, -0xac(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl -0xac(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x17417d
jmp 0x174339
movq -0x68(%rbp), %rax
movl -0xac(%rbp), %ecx
cmpq $-0x1, (%rax,%rcx,8)
jne 0x174193
jmp 0x174339
movq -0x68(%rbp), %rax
movl -0xac(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0xb4(%rbp)
movl -0xac(%rbp), %eax
movl -0xb4(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
je 0x1741be
jmp 0x174339
movq -0x20(%rbp), %rdi
movl -0xb0(%rbp), %edx
movl -0xb4(%rbp), %ecx
movl -0xfc(%rbp), %r8d
movq -0x68(%rbp), %rax
movl -0xb4(%rbp), %esi
shrl %esi
movl %esi, %esi
movq (%rax,%rsi,8), %rax
shrq $0x20, %rax
movl %eax, %r9d
movl -0x2c(%rbp), %r10d
leaq -0xa8(%rbp), %rax
addq $0x12, %rax
leaq -0xa8(%rbp), %rsi
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x1736d0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
shrq $0x20, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x174242
movq -0xc0(%rbp), %rax
cmpl $-0x1, %eax
jne 0x174247
jmp 0x174339
cmpb $0x0, -0x96(%rbp)
je 0x174255
jmp 0x174339
movq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq $0x1, -0xc8(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x174306
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1742c8
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x198(%rbp)
jmp 0x1742d6
movl $0x2, %eax
movq %rax, -0x198(%rbp)
jmp 0x1742d6
movq -0x198(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
imulq $0x28, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq -0xe8(%rbp), %rsi
movl $0x28, %edx
callq 0x2180
jmp 0x174339
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x174059
jmp 0x17434f
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x173e6f
movl -0x11c(%rbp), %eax
cmpl -0x124(%rbp), %eax
jb 0x174382
jmp 0x174398
jmp 0x174384
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x173df2
movq -0x50(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1743a7
jmp 0x174c0d
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rsi
movl $0x28, %edx
leaq -0x3d22(%rip), %rcx     # 0x1706a0
callq 0x23e0
movl $0x1, -0xf4(%rbp)
movl $0x0, -0x114(%rbp)
movl $0x0, -0x118(%rbp)
movl -0xf4(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
ja 0x1745c6
movl -0xf4(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
je 0x174475
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xf4(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movzbl 0x12(%rax), %eax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x114(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movzbl 0x12(%rcx), %ecx
cmpl %ecx, %eax
jne 0x174475
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xf4(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x114(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x18(%rcx), %rax
je 0x1745b0
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x114(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x118(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
movl -0x114(%rbp), %eax
cmpl -0xf4(%rbp), %eax
jae 0x174595
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x114(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rcx
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x118(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x114(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x118(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jle 0x17457f
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x114(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rcx
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x118(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
jmp 0x174581
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x1744b8
movl -0xf4(%rbp), %eax
movl %eax, -0x114(%rbp)
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x1745b2
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x1743e5
movl -0x118(%rbp), %eax
movl %eax, %ecx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
movq (%rax), %rax
movl %eax, %esi
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
callq 0x1732b0
movq -0x58(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x174602
jmp 0x174c0d
movl $0xffffffff, -0x13c(%rbp) # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x58(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x148(%rbp)
movl $0x0, -0x11c(%rbp)
movl $0x0, -0xfc(%rbp)
movl $0x0, -0xf0(%rbp)
movl $0x0, -0xec(%rbp)
movl $0xffffffff, -0x100(%rbp) # imm = 0xFFFFFFFF
movl -0xec(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x174c01
movq -0x108(%rbp), %rax
movl -0xec(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x10c(%rbp)
movq -0x108(%rbp), %rax
movl -0xec(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x1, %eax
movl %eax, -0x110(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x10c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1746de
jmp 0x174bed
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
movq -0x130(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x174beb
movl $0x0, -0x114(%rbp)
cmpl $0x1, -0x110(%rbp)
jne 0x17474e
movq -0x130(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x130(%rbp), %rax
movl 0x10(%rax), %eax
subl -0xf0(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movabsq $0x100000000, %rax      # imm = 0x100000000
xorq (%rcx,%rdx,8), %rax
shrq $0x20, %rax
movq %rax, -0x1a0(%rbp)
jmp 0x17476e
movq -0x130(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xf0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rax
movl %eax, -0xb0(%rbp)
cmpl $-0x1, -0x100(%rbp)
je 0x17487e
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x100(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x138(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x100(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x120(%rbp)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
cmpl -0x120(%rbp), %eax
jae 0x174856
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x174805
jmp 0x174845
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0xb0(%rbp), %eax
jne 0x174843
movq -0x138(%rbp), %rax
movl -0xf4(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x114(%rbp)
jmp 0x174856
jmp 0x174845
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x1747d6
movl -0xf4(%rbp), %eax
cmpl -0x120(%rbp), %eax
jne 0x17487c
movq 0x24f775(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x21523a(%rip), %rsi    # 0x389aaf
movb $0x0, %al
callq 0x22a0
jmp 0x17487e
movl -0xb0(%rbp), %eax
movl %eax, -0x100(%rbp)
movl -0x114(%rbp), %eax
addl -0xfc(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0xb0(%rbp), %eax
shrl %eax
movl %eax, %eax
movq -0x148(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x21, %rcx
cmpq %rcx, %rax
jne 0x174baa
cmpl $-0x1, -0x13c(%rbp)
jne 0x174baa
movq -0x38(%rbp), %rax
movl -0xb0(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
movq -0x70(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x174ba8
movq -0x70(%rbp), %rax
movq (%rax), %rax
movl -0xf8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq -0x78(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x174978
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x17497d
jmp 0x174b94
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x80(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %esi
movq -0x88(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x88(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %edx
movl -0x44(%rbp), %ecx
leaq 0x24fe3f(%rip), %rax    # 0x3c47f8
movss 0x158(%rax), %xmm0
movl -0x48(%rbp), %r8d
leaq -0xa8(%rbp), %r9
callq 0x172eb0
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
jge 0x1749e5
jmp 0x174b94
movl -0xa0(%rbp), %eax
shrl %eax
movl %eax, -0xac(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl -0xac(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x1, %eax
jne 0x174a11
jmp 0x174b94
movq -0x68(%rbp), %rax
movl -0xac(%rbp), %ecx
cmpq $-0x1, (%rax,%rcx,8)
jne 0x174a27
jmp 0x174b94
movq -0x68(%rbp), %rax
movl -0xac(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0xb4(%rbp)
movl -0xac(%rbp), %eax
movl -0xb4(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
je 0x174a52
jmp 0x174b94
movq -0x20(%rbp), %rdi
movl -0xb0(%rbp), %edx
movl -0xb4(%rbp), %ecx
movl -0xfc(%rbp), %r8d
movq -0x68(%rbp), %rax
movl -0xb4(%rbp), %esi
shrl %esi
movl %esi, %esi
movq (%rax,%rsi,8), %rax
shrq $0x20, %rax
movl %eax, %r9d
movl -0x2c(%rbp), %r10d
leaq -0xa8(%rbp), %rax
addq $0x12, %rax
leaq -0xa8(%rbp), %rsi
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x1736d0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
shrq $0x20, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x174ad6
movq -0xc0(%rbp), %rax
cmpl $-0x1, %eax
jne 0x174adb
jmp 0x174b94
cmpb $0x0, -0x96(%rbp)
je 0x174ae9
jmp 0x174b94
movq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq $0x1, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
movq -0x148(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x174b92
movl -0xe0(%rbp), %eax
movq -0x148(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x174b92
movq -0xe8(%rbp), %rax
movq -0x148(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x174b92
movq -0x148(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movl -0x2c(%rbp), %ecx
addq %rcx, %rax
movq -0x148(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
subq %rcx, %rax
movl %eax, -0x13c(%rbp)
jmp 0x174b94
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x1748ed
jmp 0x174baa
movl -0xfc(%rbp), %eax
cmpl -0x13c(%rbp), %eax
jb 0x174bc6
movl -0x11c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
jmp 0x174c0d
jmp 0x174bc8
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x1746e8
jmp 0x174bed
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x17466b
movl -0x11c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopw %cs:(%rax,%rax)