// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
leaq 0x18(%rdi), %rax
leaq 0x8(%rsi), %r14
leaq 0x20(%rdi), %r10
leaq 0x110(%rsi), %r15
leaq 0x38(%rdi), %r11
leaq 0x3c(%rdi), %rbx
leaq 0x40(%rdi), %r12
leaq 0x60(%rdi), %r13
leaq 0x80(%rdi), %rbp
addq $0x10, %rdi
testq %rsi, %rsi
cmovneq %r14, %r10
cmovneq %r15, %r11
movq %r9, 0x48(%rsp)
leaq 0x114(%rsi), %r9
cmovneq %r9, %rbx
leaq 0x20(%rsi), %r9
cmovneq %r9, %r12
movq %rcx, 0x8(%rsp)
leaq 0x40(%rsi), %rcx
cmovneq %rcx, %r13
movq %r13, 0xa8(%rsp)
movq %rdx, 0x78(%rsp)
leaq 0x60(%rsi), %rcx
cmovneq %rcx, %rbp
movq %rbp, 0xb0(%rsp)
movq 0x100(%rsp), %rdx
cmovneq %rsi, %rax
leaq 0xe0(%rsi), %rcx
movq (%rax), %rax
movq %rax, 0x98(%rsp)
movq (%r10), %r13
movl (%r11), %eax
movl %eax, 0x3c(%rsp)
movl (%rbx), %eax
movl %eax, 0x38(%rsp)
cmovneq %rcx, %rdi
movq (%rdi), %rax
movq %rax, 0x50(%rsp)
movq %r12, 0x20(%rsp)
movq $0x0, (%r12)
movl $0x0, (%rdx)
movq 0x48(%r8), %rax
movq %rax, 0x70(%rsp)
movq %r8, 0x30(%rsp)
cmpq $0x0, 0x38(%r8)
je 0x108652
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
xorl %edi, %edi
xorl %ebp, %ebp
movq 0x8(%rsp), %r8
movq 0x70(%rsp), %rcx
movl (%rcx,%r9,4), %r11d
movl %r11d, %edx
shrl %edx
movq 0x78(%rsp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rdx,%rdx,4), %rdx
cmpl $0x0, 0x10(%rcx,%rdx,8)
je 0x108638
leaq (%rcx,%rdx,8), %r12
movl 0x10(%r12), %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
testl %ecx, %ecx
je 0x108632
xorl %r14d, %r14d
testb $0x1, %r11b
jne 0x10856b
movq 0x18(%r12), %rcx
movl 0x4(%rcx,%r14,8), %ebx
jmp 0x10857f
movq 0x18(%r12), %rdx
movl %r14d, %esi
notl %esi
addl %esi, %ecx
movl 0x4(%rdx,%rcx,8), %ebx
xorq $0x1, %rbx
cmpl $-0x1, %eax
je 0x1085ca
movq 0x28(%r8), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
xorl %r15d, %r15d
testl %eax, %eax
je 0x1085cf
movq 0x8(%r8), %rcx
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %edx
leaq (%rsi,%rsi,2), %rsi
leaq (%rcx,%rsi,8), %rsi
addq $0xc, %rsi
xorl %ecx, %ecx
cmpl $0x0, (%rsi)
js 0x1085ba
cmpl %ebx, -0x4(%rsi)
je 0x1085d3
incq %rcx
addq $0x18, %rsi
cmpq %rcx, %rdx
jne 0x1085b0
movl %eax, %ecx
jmp 0x1085d7
xorl %r15d, %r15d
jmp 0x1085db
xorl %ecx, %ecx
jmp 0x1085d7
movl -0xc(%rsi), %r15d
cmpl %eax, %ecx
je 0x1085fb
addl %r15d, %ebp
cmpl 0x48(%rsp), %ebp
jae 0x108629
incq %r14
incl %edi
movl 0x10(%r12), %ecx
movl %ebx, %eax
cmpq %rcx, %r14
jb 0x108559
jmp 0x108630
movl %edi, 0x10(%rsp)
movq %r9, 0x28(%rsp)
movl %r11d, 0x18(%rsp)
callq 0x13953
movl 0x18(%rsp), %r11d
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movq 0x28(%rsp), %r9
movl 0x10(%rsp), %edi
movq 0x8(%rsp), %r8
jmp 0x1085db
movl %ebx, %eax
movl %edi, %r10d
jmp 0x108632
movl %ebx, %eax
cmpl $-0x1, %r10d
jne 0x10865f
incl %r9d
movq 0x30(%rsp), %rcx
cmpq %r9, 0x38(%rcx)
ja 0x108519
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
jmp 0x10865f
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
xorl %edi, %edi
movq 0x8(%rsp), %r8
cmpl $-0x1, %r10d
cmovnel %r10d, %edi
cmpl $0x1, %edi
movl %edi, %esi
adcl $0x0, %esi
movq 0x30(%rsp), %rax
cmpq $0x0, 0x38(%rax)
movq 0x20(%rsp), %r14
je 0x108a18
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
xorl %r10d, %r10d
movl $0x0, 0x14(%rsp)
movl %edi, 0x10(%rsp)
movl %esi, 0xa4(%rsp)
movq %r13, 0xc0(%rsp)
movq 0x70(%rsp), %rcx
movl (%rcx,%r9,4), %ecx
movl %ecx, 0x40(%rsp)
movl %ecx, %edx
shrl %edx
movq 0x78(%rsp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rdx,%rdx,4), %rdx
cmpl $0x0, 0x10(%rcx,%rdx,8)
je 0x108a06
leaq (%rcx,%rdx,8), %rdi
movl 0x10(%rdi), %ecx
cmpl %esi, %r10d
setb %dl
testl %ecx, %ecx
movq %r9, 0xb8(%rsp)
je 0x1089e8
cmpl %esi, %r10d
jae 0x1089e8
xorl %r9d, %r9d
movq %rdi, 0x90(%rsp)
testb $0x1, 0x40(%rsp)
jne 0x108716
movq 0x18(%rdi), %rcx
movl 0x4(%rcx,%r9,8), %ebx
jmp 0x108729
movq 0x18(%rdi), %rdx
movl %r9d, %esi
notl %esi
addl %esi, %ecx
movl 0x4(%rdx,%rcx,8), %ebx
xorq $0x1, %rbx
movl %r10d, 0x28(%rsp)
cmpl $-0x1, %eax
movq %r9, 0x18(%rsp)
je 0x10877d
movq 0x28(%r8), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
xorl %ebp, %ebp
testl %eax, %eax
je 0x108781
movq 0x8(%r8), %rcx
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %edx
leaq (%rsi,%rsi,2), %rsi
leaq (%rcx,%rsi,8), %rsi
addq $0xc, %rsi
xorl %ecx, %ecx
cmpl $0x0, (%rsi)
js 0x10876d
cmpl %ebx, -0x4(%rsi)
je 0x108785
incq %rcx
addq $0x18, %rsi
cmpq %rcx, %rdx
jne 0x108763
movl %eax, %ecx
jmp 0x108788
xorl %ebp, %ebp
jmp 0x108790
xorl %ecx, %ecx
jmp 0x108788
movl -0xc(%rsi), %ebp
cmpl %eax, %ecx
je 0x1089d9
addl %ebp, 0x14(%rsp)
movl %ebx, %eax
shrl %eax
leaq (%rax,%rax,2), %rax
movq 0x98(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0x10899d
movq 0x98(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
xorl %r12d, %r12d
xorl %r14d, %r14d
movq (%r15), %rdi
movl 0xc(%rdi,%r12), %edx
leaq (%rdx,%rdx,2), %rcx
movl (%r13,%rcx,4), %eax
testl %eax, %eax
js 0x108989
movq 0x20(%r8), %rbp
cmpl $0x0, (%rbp,%rdx,8)
js 0x108989
movl 0x4(%rdi,%r12), %edx
addq %r12, %rdi
leaq (%rdx,%rdx,2), %rdx
leaq (,%rdx,4), %rdx
addq %r13, %rdx
leaq (%r13,%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 0x181f37(%rip), %rax    # 0x28a758
movss 0x158(%rax), %xmm0
movl 0x3c(%rsp), %ecx
movl 0x38(%rsp), %r8d
leaq 0x58(%rsp), %r9
callq 0x107fb9
movq 0x8(%rsp), %r8
testl %eax, %eax
js 0x108989
movl 0x60(%rsp), %eax
shrl %eax
cmpl $0x0, (%rbp,%rax,8)
js 0x108989
movq 0x50(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
cmpq $-0x1, %rcx
je 0x108989
movl %ecx, %edx
shrl %edx
cmpl %edx, %eax
jne 0x108989
movl %edx, %eax
movq 0x50(%rsp), %rdx
movl 0x4(%rdx,%rax,8), %r9d
subq $0x8, %rsp
movq %r8, %rdi
leaq 0x60(%rsp), %rsi
movl %ebx, %edx
movl 0x1c(%rsp), %r8d
leaq 0x72(%rsp), %rax
pushq %rax
pushq 0x58(%rsp)
pushq $-0x1
callq 0x108317
movq 0x28(%rsp), %r8
addq $0x20, %rsp
movq %rax, %rbp
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rax, %rbp
ja 0x108989
movl %ebp, %eax
cmpl $-0x1, %eax
je 0x108989
cmpb $0x0, 0x6a(%rsp)
jne 0x108989
movq 0x58(%rsp), %rsi
movl 0x60(%rsp), %edi
movq 0x20(%rsp), %r13
movq 0x8(%r13), %rax
cmpq %rax, (%r13)
jne 0x108942
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%r13)
movl %edi, 0x80(%rsp)
movq 0x10(%r13), %rdi
shlq $0x3, %rcx
movq %rsi, 0x88(%rsp)
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movl 0x80(%rsp), %edi
movq 0x88(%rsp), %rsi
movq 0x8(%rsp), %r8
movq %rax, 0x10(%r13)
movq (%r13), %rax
movq 0x10(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r13)
leaq (%rax,%rax,4), %rax
movq %rsi, (%rcx,%rax,8)
movl %edi, 0x8(%rcx,%rax,8)
leaq 0x6a(%rsp), %rsi
movq -0x6(%rsi), %rdx
movq %rdx, 0xc(%rcx,%rax,8)
movl 0x2(%rsi), %edx
movl %edx, 0x14(%rcx,%rax,8)
movq %rbp, 0x18(%rcx,%rax,8)
movq $0x1, 0x20(%rcx,%rax,8)
movq 0xc0(%rsp), %r13
incq %r14
movl 0xc(%r15), %eax
addq $0x28, %r12
cmpq %rax, %r14
jb 0x1087c1
movq 0x18(%rsp), %r9
incq %r9
movl 0x28(%rsp), %r10d
incl %r10d
movq 0x90(%rsp), %rdi
movl 0x10(%rdi), %ecx
movl 0x10(%rsp), %esi
cmpl %r10d, %esi
seta %dl
cmpq %rcx, %r9
jae 0x1089ec
movl %ebx, %eax
cmpl %r10d, %esi
movq 0x20(%rsp), %r14
ja 0x108704
jmp 0x1089f1
callq 0x1396f
movq 0x8(%rsp), %r8
jmp 0x108790
movl %eax, %ebx
jmp 0x1089f1
movq 0x20(%rsp), %r14
movl %ebx, %eax
testb %dl, %dl
movl 0xa4(%rsp), %esi
movq 0xb8(%rsp), %r9
je 0x108a18
incl %r9d
movq 0x30(%rsp), %rcx
cmpq %r9, 0x38(%rcx)
ja 0x1086aa
movq (%r14), %rsi
testq %rsi, %rsi
je 0x108ec4
movq 0x10(%r14), %rdi
leaq -0x2b5a(%rip), %rcx     # 0x105ed5
movl $0x28, %edx
callq 0x23f0
movq (%r14), %r8
testq %r8, %r8
je 0x108b30
movl $0x1, %eax
movl $0x1, %r9d
xorl %ecx, %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %esi, %esi
xorl %edi, %edi
movl %edi, %r10d
cmpq %r9, %r8
je 0x108a91
movq 0x10(%r14), %r8
leaq (%r9,%r9,4), %r9
movb 0x12(%r8,%r9,8), %bl
leaq (%r10,%r10,4), %r11
cmpb 0x12(%r8,%r11,8), %bl
jne 0x108a91
leaq (%r8,%r9,8), %r9
leaq (%r8,%r11,8), %r8
movq 0x18(%r9), %r9
cmpq 0x18(%r8), %r9
je 0x108b1b
movq 0x10(%r14), %r9
leaq (%r10,%r10,4), %r10
movl %esi, %r8d
leaq (%r8,%r8,4), %r8
movq 0x20(%r9,%r10,8), %r11
movq %r11, 0x20(%r9,%r8,8)
movups (%r9,%r10,8), %xmm0
movups 0x10(%r9,%r10,8), %xmm1
movups %xmm1, 0x10(%r9,%r8,8)
movups %xmm0, (%r9,%r8,8)
leal 0x1(%rdi), %r9d
cmpl %eax, %r9d
jae 0x108b17
movl %r9d, %r9d
shlq $0x3, %r9
leaq (%r9,%r9,4), %r9
addl %ecx, %edi
movq 0x10(%r14), %r10
movq 0x20(%r10,%r9), %r11
addq %r11, 0x20(%r10,%r8,8)
movl 0xc(%r10,%r9), %r11d
andl %edx, %r11d
movl 0xc(%r10,%r8,8), %ebx
andl %edx, %ebx
cmpl %ebx, %r11d
jbe 0x108b0f
leaq (%r10,%r8,8), %r11
addq %r9, %r10
movq 0x10(%r10), %rbx
movq %rbx, 0x10(%r11)
movups (%r10), %xmm0
movups %xmm0, (%r11)
addq $0x28, %r9
incl %edi
jne 0x108ad6
incl %esi
movl %eax, %edi
incl %eax
movq (%r14), %r8
decl %ecx
movq %rax, %r9
cmpq %rax, %r8
jae 0x108a5b
jmp 0x108b32
xorl %esi, %esi
movl %esi, %eax
movq %rax, (%r14)
movq 0x10(%r14), %rdi
movq 0xa8(%rsp), %rbx
movq %rbx, %rdx
movq 0xb0(%rsp), %rcx
callq 0x108131
movq (%rbx), %rax
testq %rax, %rax
movq 0x8(%rsp), %r8
je 0x108ec4
movq 0x30(%rsp), %rcx
cmpq $0x0, 0x38(%rcx)
je 0x108eb8
movq 0xa8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq -0x4(%rcx,%rax,4), %rax
leaq (%rax,%rax,4), %r15
shlq $0x3, %r15
addq 0x10(%r14), %r15
movl 0x48(%rsp), %eax
movq %rax, 0x80(%rsp)
xorl %esi, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
xorl %edi, %edi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movq %r15, 0x40(%rsp)
movq 0x70(%rsp), %rcx
movl (%rcx,%rsi,4), %ecx
movl %ecx, 0x10(%rsp)
movl %ecx, %edx
shrl %edx
movq 0x78(%rsp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rdx,%rdx,4), %rdx
cmpl $0x0, 0x10(%rcx,%rdx,8)
movq %rsi, 0x88(%rsp)
je 0x108e91
leaq (%rcx,%rdx,8), %r9
movl 0x10(%r9), %ecx
testl %ecx, %ecx
je 0x108e91
xorl %r10d, %r10d
movq %r9, 0x90(%rsp)
testb $0x1, 0x10(%rsp)
jne 0x108c14
movq 0x18(%r9), %rcx
movl 0x4(%rcx,%r10,8), %r12d
jmp 0x108c28
movq 0x18(%r9), %rdx
movl %r10d, %esi
notl %esi
addl %esi, %ecx
movl 0x4(%rdx,%rcx,8), %r12d
xorq $0x1, %r12
movq %r10, 0x20(%rsp)
cmpl $-0x1, %eax
movl %edi, 0x14(%rsp)
je 0x108c7c
movq 0x28(%r8), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
xorl %ebx, %ebx
testl %eax, %eax
je 0x108c80
movq 0x8(%r8), %rcx
movq %rax, %rsi
shrq $0x20, %rsi
movl %eax, %edx
leaq (%rsi,%rsi,2), %rsi
leaq (%rcx,%rsi,8), %rsi
addq $0xc, %rsi
xorl %ecx, %ecx
cmpl $0x0, (%rsi)
js 0x108c6c
cmpl %r12d, -0x4(%rsi)
je 0x108c84
incq %rcx
addq $0x18, %rsi
cmpq %rcx, %rdx
jne 0x108c61
movl %eax, %ecx
jmp 0x108c87
xorl %ebx, %ebx
jmp 0x108c8f
xorl %ecx, %ecx
jmp 0x108c87
movl -0xc(%rsi), %ebx
cmpl %eax, %ecx
je 0x108e82
addl %ebx, %ebp
movl %ebp, 0x28(%rsp)
movl %r12d, %eax
shrl %eax
movq (%r15), %rcx
shrq $0x21, %rcx
cmpq %rcx, %rax
jne 0x108e4b
cmpl $-0x1, 0x18(%rsp)
jne 0x108e4b
leaq (%rax,%rax,2), %rax
movq 0x98(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0x108e41
leaq (%rcx,%rax,8), %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
movq (%r14), %rdi
movl 0xc(%rdi,%rbp), %edx
leaq (%rdx,%rdx,2), %rcx
movl (%r13,%rcx,4), %eax
testl %eax, %eax
js 0x108e2b
movq 0x20(%r8), %r15
cmpl $0x0, (%r15,%rdx,8)
js 0x108e2b
movl 0x4(%rdi,%rbp), %edx
addq %rbp, %rdi
leaq (%rdx,%rdx,2), %rdx
leaq (,%rdx,4), %rdx
addq %r13, %rdx
leaq (%r13,%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 0x181a1c(%rip), %rax    # 0x28a758
movss 0x158(%rax), %xmm0
movl 0x3c(%rsp), %ecx
movl 0x38(%rsp), %r8d
leaq 0x58(%rsp), %r9
callq 0x107fb9
testl %eax, %eax
js 0x108e26
movl 0x60(%rsp), %eax
shrl %eax
cmpl $0x0, (%r15,%rax,8)
js 0x108e26
movq 0x50(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
cmpq $-0x1, %rcx
movq 0x8(%rsp), %r8
je 0x108e2b
movl %ecx, %edx
shrl %edx
cmpl %edx, %eax
jne 0x108e2b
movl %edx, %eax
movq 0x50(%rsp), %rdx
movl 0x4(%rdx,%rax,8), %r9d
subq $0x8, %rsp
movq %r8, %rdi
leaq 0x60(%rsp), %rsi
movl %r12d, %edx
movl 0x30(%rsp), %r8d
leaq 0x72(%rsp), %rax
pushq %rax
pushq 0x58(%rsp)
pushq $-0x1
callq 0x108317
addq $0x20, %rsp
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rcx, %rax
ja 0x108e26
movl %eax, %ecx
cmpl $-0x1, %ecx
movq 0x8(%rsp), %r8
je 0x108e2b
cmpb $0x0, 0x6a(%rsp)
jne 0x108e2b
movq 0x40(%rsp), %rdx
movq 0x18(%rdx), %rcx
cmpq %rcx, %rax
jne 0x108e2b
movl 0x60(%rsp), %eax
cmpl 0x8(%rdx), %eax
jne 0x108e2b
movq 0x58(%rsp), %rax
cmpq (%rdx), %rax
jne 0x108e2b
movq %rcx, %rdx
shrq $0x20, %rdx
movq 0x80(%rsp), %rax
subl %ecx, %eax
addl %eax, %edx
movq %rdx, 0x18(%rsp)
jmp 0x108e2b
movq 0x8(%rsp), %r8
incq %rbx
movl 0xc(%r14), %eax
addq $0x28, %rbp
cmpq %rax, %rbx
jb 0x108cde
jmp 0x108e4b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
movl 0x28(%rsp), %ebp
cmpl 0x18(%rsp), %ebp
jae 0x108eb2
movq 0x20(%rsp), %r10
incq %r10
movl 0x14(%rsp), %edi
incl %edi
movq 0x90(%rsp), %r9
movl 0x10(%r9), %ecx
movl %r12d, %eax
cmpq %rcx, %r10
movq 0x40(%rsp), %r15
jb 0x108c02
jmp 0x108e94
callq 0x1398b
movq 0x8(%rsp), %r8
jmp 0x108c8f
movl %eax, %r12d
movq 0x88(%rsp), %rsi
incl %esi
movl %r12d, %eax
movq 0x30(%rsp), %rcx
cmpq %rsi, 0x38(%rcx)
ja 0x108bb7
jmp 0x108eba
movl 0x14(%rsp), %edi
jmp 0x108eba
xorl %edi, %edi
movq 0x100(%rsp), %rax
movl %edi, (%rax)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq