// File: /workspace/github_cpp_makefile_star2_O3/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 $0xe8, %rsp
movq %r9, 0x60(%rsp)
movq %rdx, 0xb8(%rsp)
leaq 0x18(%rdi), %rax
leaq 0x8(%rsi), %r9
leaq 0x20(%rdi), %rbx
leaq 0x110(%rsi), %r10
leaq 0x38(%rdi), %rdx
leaq 0x3c(%rdi), %r11
leaq 0x40(%rdi), %r14
leaq 0x60(%rdi), %r15
leaq 0x80(%rdi), %r12
addq $0x10, %rdi
testq %rsi, %rsi
cmovneq %r9, %rbx
cmovneq %r10, %rdx
movq %rcx, %r10
movq 0x120(%rsp), %rcx
leaq 0x114(%rsi), %r9
cmovneq %r9, %r11
leaq 0x20(%rsi), %r9
cmovneq %r9, %r14
leaq 0x40(%rsi), %r9
cmovneq %rsi, %rax
cmovneq %r9, %r15
movq %r15, 0xd0(%rsp)
leaq 0x60(%rsi), %r9
leaq 0xe0(%rsi), %rsi
movq (%rax), %rax
movq %rax, 0x90(%rsp)
movq (%rbx), %rax
movq %rax, 0x58(%rsp)
movl (%rdx), %eax
movl %eax, 0x34(%rsp)
movl (%r11), %eax
movl %eax, 0x30(%rsp)
cmovneq %r9, %r12
movq %r12, 0xe0(%rsp)
cmovneq %rsi, %rdi
movq (%rdi), %rax
movq %rax, 0xd8(%rsp)
movq $0x0, (%r14)
movl $0x0, (%rcx)
movq 0x38(%r8), %rax
movq %r8, 0x68(%rsp)
movq 0x48(%r8), %rcx
movq %rcx, 0xb0(%rsp)
testq %rax, %rax
movq %r10, 0x8(%rsp)
je 0x10d4bf
movq %r14, 0x78(%rsp)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x60(%rsp), %r8
movq 0xb0(%rsp), %rdx
movl (%rdx,%r9,4), %r11d
movl %r11d, %edx
shrl %edx
movq 0xb8(%rsp), %rsi
movq 0x10(%rsi), %rsi
leaq (%rdx,%rdx,4), %rdi
movl 0x10(%rsi,%rdi,8), %edx
testl %edx, %edx
je 0x10cf67
leaq (%rsi,%rdi,8), %r13
xorl %r14d, %r14d
movq 0x18(%r13), %rax
testb $0x1, %r11b
jne 0x10ceb6
movl 0x4(%rax,%r14,8), %r12d
jmp 0x10cec6
movl %r14d, %esi
notl %esi
addl %esi, %edx
movl 0x4(%rax,%rdx,8), %r12d
xorq $0x1, %r12
cmpl $-0x1, %ecx
je 0x10cf12
movq 0x28(%r10), %rax
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
xorl %r15d, %r15d
testl %eax, %eax
je 0x10cf17
movq 0x8(%r10), %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 0x10cf02
cmpl %r12d, -0x4(%rsi)
je 0x10cf1b
incq %rcx
addq $0x18, %rsi
cmpq %rcx, %rdx
jne 0x10cef7
movl %eax, %ecx
jmp 0x10cf1f
xorl %r15d, %r15d
jmp 0x10cf23
xorl %ecx, %ecx
jmp 0x10cf1f
movl -0xc(%rsi), %r15d
cmpl %eax, %ecx
je 0x10cf42
addl %r15d, %ebp
cmpl %r8d, %ebp
jae 0x10cf6c
incq %r14
incl %ebx
movl 0x10(%r13), %edx
movl %r12d, %ecx
cmpq %rdx, %r14
jb 0x10cea5
jmp 0x10cf81
movq %r9, 0x28(%rsp)
movl %r11d, 0x10(%rsp)
callq 0x132a9
movl 0x10(%rsp), %r11d
movq 0x28(%rsp), %r9
movq 0x8(%rsp), %r10
movq 0x60(%rsp), %r8
jmp 0x10cf23
movl %ecx, %r12d
jmp 0x10cf8a
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $-0x1, %ebx
je 0x10cf8c
jmp 0x10cf9d
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rax
movl %ebx, %ecx
incl %r9d
movl %ecx, %ebx
movl %r12d, %ecx
cmpq %r9, %rax
ja 0x10ce71
cmpl $0x1, %ebx
movl %ebx, %ecx
adcl $0x0, %ecx
movl %ecx, 0xa8(%rsp)
testq %rax, %rax
movq 0x78(%rsp), %r14
je 0x10d4bf
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq $0x0, 0x70(%rsp)
xorl %r8d, %r8d
movl $0x0, 0x88(%rsp)
movl %ebx, 0x80(%rsp)
movq 0xb0(%rsp), %rdx
movq 0x70(%rsp), %rsi
movl (%rdx,%rsi,4), %edx
movl %edx, 0x1c(%rsp)
shrl %edx
movq 0xb8(%rsp), %rsi
movq 0x10(%rsi), %rsi
leaq (%rdx,%rdx,4), %rdi
movl 0x10(%rsi,%rdi,8), %edx
testl %edx, %edx
je 0x10d4a6
cmpl 0xa8(%rsp), %r8d
jae 0x10d4bf
leaq (%rsi,%rdi,8), %rsi
xorl %r9d, %r9d
movq %rsi, 0xc0(%rsp)
movq 0x18(%rsi), %rax
testb $0x1, 0x1c(%rsp)
movq %r9, 0x98(%rsp)
jne 0x10d046
movl 0x4(%rax,%r9,8), %ebx
jmp 0x10d055
movl %r9d, %esi
notl %esi
addl %esi, %edx
movl 0x4(%rax,%rdx,8), %ebx
xorq $0x1, %rbx
movq 0x8(%rsp), %rdx
movl %r8d, 0x50(%rsp)
cmpl $-0x1, %ecx
movq 0x90(%rsp), %rdi
je 0x10d0b1
movq 0x28(%rdx), %rax
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
xorl %ebp, %ebp
testl %eax, %eax
je 0x10d0b5
movq 0x8(%rdx), %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 0x10d0a1
cmpl %ebx, -0x4(%rsi)
je 0x10d0b9
incq %rcx
addq $0x18, %rsi
cmpq %rcx, %rdx
jne 0x10d097
movl %eax, %ecx
jmp 0x10d0bc
xorl %ebp, %ebp
jmp 0x10d0c4
xorl %ecx, %ecx
jmp 0x10d0bc
movl -0xc(%rsi), %ebp
cmpl %eax, %ecx
je 0x10d484
addl %ebp, 0x88(%rsp)
movq %rbx, 0x20(%rsp)
movl %ebx, %eax
shrl %eax
leaq (%rax,%rax,2), %rax
cmpl $0x0, 0xc(%rdi,%rax,8)
je 0x10d443
movq 0x90(%rsp), %rcx
leaq (%rcx,%rax,8), %r13
movl $0x21, %ebp
xorl %r14d, %r14d
movq %r13, 0xa0(%rsp)
movq (%r13), %rdx
movl -0x15(%rdx,%rbp), %eax
leaq (%rax,%rax,2), %rsi
movq 0x58(%rsp), %rcx
movl (%rcx,%rsi,4), %ecx
testl %ecx, %ecx
js 0x10d230
movq 0x8(%rsp), %rdi
movq 0x20(%rdi), %rdi
movq %rdi, 0x28(%rsp)
cmpl $0x0, (%rdi,%rax,8)
js 0x10d230
movq 0x58(%rsp), %rdi
leaq (%rdi,%rsi,4), %rsi
movl 0x4(%rsi), %edi
subl %ecx, %edi
movq -0x9(%rdx,%rbp), %rcx
movq %rcx, 0xc8(%rsp)
testl %ecx, %ecx
js 0x10d169
movl -0x11(%rdx,%rbp), %ecx
movl -0xd(%rdx,%rbp), %r12d
subl %r12d, %edi
movl %edi, %r10d
movl %ecx, 0x10(%rsp)
movl %ecx, %edi
jmp 0x10d17b
movl -0x11(%rdx,%rbp), %r10d
movl -0xd(%rdx,%rbp), %r12d
subl %r12d, %edi
movl %r10d, 0x10(%rsp)
movq -0x21(%rdx,%rbp), %r9
movq %r9, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x58(%rsp), %rsi
leaq (%rsi,%rcx,4), %rsi
movl 0x4(%rsi), %ecx
movl (%rsi), %esi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %esi
subl %esi, %ecx
cmpl %r9d, %edi
movl %r9d, %r15d
cmovll %edi, %r15d
movl -0x19(%rdx,%rbp), %r11d
movl %ecx, %r8d
subl %r11d, %r8d
cmpl %r10d, %r8d
movl %r10d, %ebx
cmovll %r8d, %ebx
cmpl 0x34(%rsp), %r15d
jg 0x10d230
cmpl 0x34(%rsp), %ebx
jg 0x10d230
movl %r11d, %esi
subl %r9d, %esi
xorps %xmm1, %xmm1
cvtsi2ss %rsi, %xmm1
addl %r15d, %esi
addl %ebx, %esi
xorps %xmm2, %xmm2
cvtsi2ss %rsi, %xmm2
leaq 0x188566(%rip), %r13    # 0x295758
movss 0x158(%r13), %xmm0
movq 0xa0(%rsp), %r13
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x10d230
subl 0x10(%rsp), %r12d
xorps %xmm1, %xmm1
cvtsi2ss %r12, %xmm1
addl %r15d, %ebx
addl %r12d, %ebx
xorps %xmm2, %xmm2
cvtsi2ss %rbx, %xmm2
mulss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x10d249
incq %r14
movl 0xc(%r13), %eax
addq $0x28, %rbp
cmpq %rax, %r14
jb 0x10d0ff
jmp 0x10d443
cmpl %r10d, %r8d
setl %r8b
setg %r12b
cmpl %edi, %r9d
setg %r13b
setl %r15b
orb %r12b, %r13b
cmpb $0x1, %r13b
movq 0xa0(%rsp), %r13
jne 0x10d230
orb %r8b, %r15b
je 0x10d230
cmpl 0x30(%rsp), %esi
jl 0x10d230
cmpl 0x30(%rsp), %ebx
jl 0x10d230
movq 0xc8(%rsp), %rbx
testl %ebx, %ebx
setns %sil
addl %r11d, %r10d
movl %ecx, %r8d
subl %r10d, %r8d
xorl %r11d, %r11d
movl %r9d, %r10d
subl %edi, %r10d
setle %r11b
setg %dil
cmovlel %r8d, %r10d
xorb %sil, %dil
movzbl %dil, %esi
shrq $0x1f, %r9
andl $-0x2, %r9d
orl %r9d, %r11d
leal (%rsi,%rax,2), %esi
shlq $0x20, %r11
leaq (%r10,%r11), %rdi
movq %rdi, 0x38(%rsp)
movl %esi, 0x40(%rsp)
subl %r10d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0x44(%rsp)
movzwl 0x48(%rsp), %ecx
shrl $0x10, %ebx
andl $0x4000, %ebx           # imm = 0x4000
andl $0x3fff, %ecx           # imm = 0x3FFF
orl %ebx, %ecx
movb -0x1(%rdx,%rbp), %sil
movb %sil, 0x4a(%rsp)
movzbl (%rdx,%rbp), %edx
shll $0xf, %edx
orl %ecx, %edx
movw %dx, 0x48(%rsp)
testl %r10d, %r10d
js 0x10d230
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rcx
cmpl $0x0, (%rcx,%rax,8)
js 0x10d230
movq 0xd8(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
cmpq $-0x1, %rcx
je 0x10d230
movl %ecx, %edx
shrl %edx
cmpl %edx, %eax
jne 0x10d230
movq %rcx, %r9
shrq $0x20, %r9
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl 0x90(%rsp), %r8d
leaq 0x52(%rsp), %rax
pushq %rax
pushq 0x70(%rsp)
pushq $-0x1
callq 0x10cc5d
addq $0x20, %rsp
movq %rax, %rbx
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rax, %rbx
ja 0x10d230
movl %ebx, %eax
cmpl $-0x1, %eax
je 0x10d230
cmpb $0x0, 0x4a(%rsp)
jne 0x10d230
movq 0x38(%rsp), %rsi
movl 0x40(%rsp), %r15d
movq 0x78(%rsp), %r12
movq (%r12), %rcx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rcx
jne 0x10d407
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%r12)
shlq $0x3, %rdx
movq %rsi, 0x28(%rsp)
leaq (%rdx,%rdx,4), %rsi
movq %rax, %rdi
callq 0x2370
movq 0x28(%rsp), %rsi
movq %rax, 0x10(%r12)
movq (%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
leaq (%rcx,%rcx,4), %rcx
movq %rsi, (%rax,%rcx,8)
movl %r15d, 0x8(%rax,%rcx,8)
leaq 0x44(%rsp), %rsi
movq (%rsi), %rdx
movq %rdx, 0xc(%rax,%rcx,8)
movl 0x8(%rsi), %edx
movl %edx, 0x14(%rax,%rcx,8)
movq %rbx, 0x18(%rax,%rcx,8)
movq $0x1, 0x20(%rax,%rcx,8)
jmp 0x10d230
movq 0x98(%rsp), %r9
incq %r9
movl 0x50(%rsp), %r8d
incl %r8d
movq 0xc0(%rsp), %rsi
movl 0x10(%rsi), %edx
cmpq %rdx, %r9
movq 0x78(%rsp), %r14
movl 0x80(%rsp), %eax
movq 0x20(%rsp), %rdi
jae 0x10d496
movl %edi, %ecx
cmpl %r8d, %eax
ja 0x10d02c
jmp 0x10d496
callq 0x132c5
movq 0x90(%rsp), %rdi
jmp 0x10d0c4
cmpl %r8d, %eax
jbe 0x10d4bf
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rax
jmp 0x10d4a8
movl %ecx, %edi
movq 0x70(%rsp), %rsi
incl %esi
movl %edi, %ecx
movq %rsi, 0x70(%rsp)
cmpq %rsi, %rax
ja 0x10cfdd
movq (%r14), %rsi
testq %rsi, %rsi
je 0x10db31
movq 0x10(%r14), %rdi
leaq -0x2e62(%rip), %rcx     # 0x10a674
movl $0x28, %edx
callq 0x23f0
movq (%r14), %r8
testq %r8, %r8
je 0x10d5d8
movl $0x1, %eax
movl $0x1, %r10d
xorl %ecx, %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %esi, %esi
xorl %edi, %edi
movq 0x10(%r14), %r9
cmpq %r10, %r8
jne 0x10d510
movl %edi, %r10d
jmp 0x10d53d
leaq (%r10,%r10,4), %r11
movb 0x12(%r9,%r11,8), %bpl
movl %edi, %r10d
leaq (%r10,%r10,4), %rbx
cmpb 0x12(%r9,%rbx,8), %bpl
jne 0x10d53d
leaq (%r9,%r11,8), %r11
leaq (%r9,%rbx,8), %rbx
movq 0x18(%r11), %r11
cmpq 0x18(%rbx), %r11
je 0x10d5c6
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 0x10d5bf
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 0x10d5b7
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 0x10d57e
incl %esi
movq (%r14), %r8
movl %eax, %edi
incl %eax
decl %ecx
movq %rax, %r10
cmpq %rax, %r8
jae 0x10d502
jmp 0x10d5da
xorl %esi, %esi
movl %esi, %eax
movq %rax, (%r14)
movq 0x10(%r14), %rdi
movq 0xd0(%rsp), %rbx
movq %rbx, %rdx
movq 0xe0(%rsp), %rcx
callq 0x10ca61
movq (%rbx), %rax
testq %rax, %rax
movq 0x8(%rsp), %r8
je 0x10db31
movq 0x68(%rsp), %rcx
movq 0x38(%rcx), %rcx
testq %rcx, %rcx
je 0x10db23
movq 0xd0(%rsp), %rdx
movq 0x10(%rdx), %rdx
movslq -0x4(%rdx,%rax,4), %rax
leaq (%rax,%rax,4), %rbx
shlq $0x3, %rbx
addq 0x10(%r14), %rbx
movl 0x60(%rsp), %eax
movq %rax, 0xa8(%rsp)
xorl %edx, %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x20(%rsp)
xorl %r9d, %r9d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movq %rbx, 0x80(%rsp)
movq %rdx, %rsi
movq 0xb0(%rsp), %rdx
movq %rsi, 0x70(%rsp)
movl (%rdx,%rsi,4), %edx
movl %edx, 0xc0(%rsp)
shrl %edx
movq 0xb8(%rsp), %rsi
movq 0x10(%rsi), %rsi
leaq (%rdx,%rdx,4), %rdi
movl 0x10(%rsi,%rdi,8), %edx
testl %edx, %edx
je 0x10daf9
leaq (%rsi,%rdi,8), %rdi
xorl %r10d, %r10d
movq %rdi, 0x78(%rsp)
movq 0x18(%rdi), %rcx
testb $0x1, 0xc0(%rsp)
jne 0x10d6bf
movl 0x4(%rcx,%r10,8), %r13d
jmp 0x10d6cf
movl %r10d, %esi
notl %esi
addl %esi, %edx
movl 0x4(%rcx,%rdx,8), %r13d
xorq $0x1, %r13
movq %r10, 0x88(%rsp)
cmpl $-0x1, %eax
movl %r9d, 0x1c(%rsp)
je 0x10d727
movq 0x28(%r8), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
xorl %ebp, %ebp
testl %eax, %eax
je 0x10d72b
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 0x10d717
cmpl %r13d, -0x4(%rsi)
je 0x10d72f
incq %rcx
addq $0x18, %rsi
cmpq %rcx, %rdx
jne 0x10d70c
movl %eax, %ecx
jmp 0x10d732
xorl %ebp, %ebp
jmp 0x10d73a
xorl %ecx, %ecx
jmp 0x10d732
movl -0xc(%rsi), %ebp
cmpl %eax, %ecx
je 0x10daea
addl %ebp, %r14d
movl %r14d, 0x98(%rsp)
movl %r13d, %eax
shrl %eax
movq (%rbx), %rcx
shrq $0x21, %rcx
cmpq %rcx, %rax
jne 0x10daaa
cmpl $-0x1, 0x20(%rsp)
jne 0x10daaa
leaq (%rax,%rax,2), %rax
movq 0x90(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
je 0x10daa0
leaq (%rcx,%rax,8), %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x20(%rsp)
movl $0x21, %r14d
xorl %ebp, %ebp
movq %r13, 0x50(%rsp)
movq %rdi, 0x10(%rsp)
movq (%rdi), %rdx
movl -0x15(%rdx,%r14), %eax
leaq (%rax,%rax,2), %rsi
movq 0x58(%rsp), %rcx
movl (%rcx,%rsi,4), %ecx
testl %ecx, %ecx
js 0x10da8b
movq 0x20(%r8), %r9
cmpl $0x0, (%r9,%rax,8)
js 0x10da8b
movq 0x58(%rsp), %rdi
leaq (%rdi,%rsi,4), %rsi
movl 0x4(%rsi), %edi
subl %ecx, %edi
movq -0x9(%rdx,%r14), %rcx
testl %ecx, %ecx
movq %r9, 0xa0(%rsp)
movq %rcx, 0xc8(%rsp)
js 0x10d806
movl -0x11(%rdx,%r14), %ecx
movl -0xd(%rdx,%r14), %r11d
subl %r11d, %edi
movl %edi, %r10d
movl %ecx, 0x28(%rsp)
movl %ecx, %edi
jmp 0x10d818
movl -0x11(%rdx,%r14), %r10d
movl -0xd(%rdx,%r14), %r11d
subl %r11d, %edi
movl %r10d, 0x28(%rsp)
movq -0x21(%rdx,%r14), %r9
movq %r9, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x58(%rsp), %rsi
leaq (%rsi,%rcx,4), %rcx
movl 0x4(%rcx), %r12d
movl (%rcx), %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
subl %ecx, %r12d
cmpl %r9d, %edi
movl %r9d, %ecx
cmovll %edi, %ecx
movl -0x19(%rdx,%r14), %r15d
movl %r12d, %r8d
subl %r15d, %r8d
cmpl %r10d, %r8d
movl %r10d, %ebx
cmovll %r8d, %ebx
movl 0x34(%rsp), %esi
cmpl %esi, %ecx
jg 0x10da81
cmpl %esi, %ebx
jg 0x10da81
movl %r15d, %esi
subl %r9d, %esi
cvtsi2ss %rsi, %xmm1
addl %ecx, %esi
addl %ebx, %esi
cvtsi2ss %rsi, %xmm2
leaq 0x187eca(%rip), %r13    # 0x295758
movss 0x158(%r13), %xmm0
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x10d8c3
subl 0x28(%rsp), %r11d
xorps %xmm1, %xmm1
cvtsi2ss %r11, %xmm1
addl %ecx, %ebx
addl %r11d, %ebx
xorps %xmm2, %xmm2
cvtsi2ss %rbx, %xmm2
mulss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x10d8d2
movq 0x8(%rsp), %r8
movq 0x50(%rsp), %r13
jmp 0x10da86
cmpl %r10d, %r8d
setl %cl
setg %r11b
cmpl %edi, %r9d
setg %r13b
setl %r8b
orb %r11b, %r13b
cmpb $0x1, %r13b
jne 0x10d8c3
orb %cl, %r8b
movq 0x50(%rsp), %r13
je 0x10da81
movl 0x30(%rsp), %ecx
cmpl %ecx, %esi
jl 0x10da81
cmpl %ecx, %ebx
jl 0x10da81
movq 0xc8(%rsp), %r11
testl %r11d, %r11d
setns %cl
addl %r15d, %r10d
movl %r12d, %esi
subl %r10d, %esi
xorl %r8d, %r8d
movl %r9d, %r10d
subl %edi, %r10d
setle %r8b
setg %dil
cmovlel %esi, %r10d
xorb %cl, %dil
movzbl %dil, %ecx
shrq $0x1f, %r9
andl $-0x2, %r9d
orl %r9d, %r8d
leal (%rcx,%rax,2), %ecx
shlq $0x20, %r8
leaq (%r10,%r8), %rsi
movq %rsi, 0x38(%rsp)
movl %ecx, 0x40(%rsp)
subl %r10d, %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl %r12d, 0x44(%rsp)
movzwl 0x48(%rsp), %ecx
shrl $0x10, %r11d
andl $0x4000, %r11d          # imm = 0x4000
andl $0x3fff, %ecx           # imm = 0x3FFF
orl %r11d, %ecx
movb -0x1(%rdx,%r14), %sil
movb %sil, 0x4a(%rsp)
movzbl (%rdx,%r14), %edx
shll $0xf, %edx
orl %ecx, %edx
movw %dx, 0x48(%rsp)
testl %r10d, %r10d
js 0x10da81
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0xa0(%rsp), %rcx
cmpl $0x0, (%rcx,%rax,8)
movq 0x60(%rsp), %r10
js 0x10da81
movq 0xd8(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
cmpq $-0x1, %rcx
je 0x10da81
movl %ecx, %edx
shrl %edx
cmpl %edx, %eax
jne 0x10da81
movq %rcx, %r9
shrq $0x20, %r9
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl %r13d, %edx
movl 0xa0(%rsp), %r8d
leaq 0x52(%rsp), %rax
pushq %rax
pushq %r10
pushq $-0x1
callq 0x10cc5d
addq $0x20, %rsp
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
cmpq %rcx, %rax
ja 0x10da81
movl %eax, %ecx
cmpl $-0x1, %ecx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
je 0x10da8b
cmpb $0x0, 0x4a(%rsp)
jne 0x10da8b
movq 0x80(%rsp), %rdx
cmpq 0x18(%rdx), %rax
jne 0x10da8b
movl 0x40(%rsp), %ecx
cmpl 0x8(%rdx), %ecx
jne 0x10da8b
movq 0x38(%rsp), %rcx
cmpq (%rdx), %rcx
jne 0x10da8b
movq %rax, %rdx
shrq $0x20, %rdx
movq 0xa8(%rsp), %rcx
subl %eax, %ecx
addl %ecx, %edx
movq %rdx, 0x20(%rsp)
jmp 0x10da8b
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
incq %rbp
movl 0xc(%rdi), %eax
addq $0x28, %r14
cmpq %rax, %rbp
jb 0x10d79c
jmp 0x10daaa
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x20(%rsp)
movl 0x98(%rsp), %r14d
cmpl 0x20(%rsp), %r14d
jae 0x10db1c
movq 0x88(%rsp), %r10
incq %r10
movl 0x1c(%rsp), %r9d
incl %r9d
movq 0x78(%rsp), %rdi
movl 0x10(%rdi), %edx
movl %r13d, %eax
cmpq %rdx, %r10
movq 0x80(%rsp), %rbx
jb 0x10d6aa
jmp 0x10dafe
callq 0x132e1
movq 0x8(%rsp), %r8
jmp 0x10d73a
movl %eax, %r13d
jmp 0x10db07
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x70(%rsp), %rdx
incl %edx
movl %r13d, %eax
cmpq %rdx, %rcx
ja 0x10d666
jmp 0x10db26
movl 0x1c(%rsp), %r9d
jmp 0x10db26
xorl %r9d, %r9d
movq 0x120(%rsp), %rax
movl %r9d, (%rax)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq