// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/tovlp.cpp
// Function: chain_trans_d(utg_trans_t*, unsigned int*, unsigned int, unsigned int, unsigned long*, unsigned int*, unsigned int, unsigned int, unsigned long*, ma_ug_t*, unsigned int, double, char const*)
void chain_trans_d(utg_trans_t *o, 
uint32_t *pri_a, uint32_t pri_n, uint32_t pri_beg, uint64_t *i_pri_len, 
uint32_t *aux_a, uint32_t aux_n, uint32_t aux_beg, uint64_t *i_aux_len,
ma_ug_t *ug, uint32_t flag, double score, const char* cmd)
{
    uint32_t i, len, bn;
    uint64_t pri_len, aux_len;
    kvec_asg_arc_t_offset* u_buffer = &(o->u_buffer);
    kvec_t_i32_warp* tailIndex = &(o->tailIndex);
    asg_arc_t_offset *tt = NULL;
    ca_buf_t *tx = NULL;

    if(i_pri_len) pri_len = (*i_pri_len);
    else pri_len = get_utg_chain_length(ug, pri_a, pri_n);
    
    if(i_aux_len) aux_len = (*i_aux_len);
    else aux_len = get_utg_chain_length(ug, aux_a, aux_n);
        
    tt = NULL; o->c_buf.n = 0; o->k_t_b.n = 0;
    if(tailIndex->a.n > 0) tt = &(u_buffer->a.a[tailIndex->a.a[0]]);
    if(!tt || (pri_beg < (tt->Off>>32) && aux_beg < ((uint32_t)tt->Off)))
    {
        kv_pushp(ca_buf_t, o->c_buf, &tx);
        tx->c_x_p = pri_beg; 
        tx->c_y_p = aux_beg;

        for (i = 0; i < tailIndex->a.n; i++)
        {
            tt = &(u_buffer->a.a[tailIndex->a.a[i]]);
            kv_pushp(ca_buf_t, o->c_buf, &tx);

            tx->c_x_p = tt->Off>>32;
            tx->c_y_p = (uint32_t)tt->Off;
        }
    }
    else if(tailIndex->a.n == 1)//1 ele in chain
    {
        kv_pushp(ca_buf_t, o->c_buf, &tx);
        tx->c_x_p = pri_beg; tx->c_y_p = aux_beg;
    }
    else if(tailIndex->a.n > 0)
    {
        uint32_t cx, cy, ax, ay, found = 0;
        for (i = 0; i < tailIndex->a.n; i++)
        {
            cx = cy = ax = ay = (uint32_t)-1;

            cx = u_buffer->a.a[tailIndex->a.a[i]].Off>>32;
            cy = (uint32_t)u_buffer->a.a[tailIndex->a.a[i]].Off;
            if((i + 1) < tailIndex->a.n)
            {
                ax = u_buffer->a.a[tailIndex->a.a[i+1]].Off>>32;
                ay = (uint32_t)u_buffer->a.a[tailIndex->a.a[i+1]].Off;
            }

            kv_pushp(ca_buf_t, o->c_buf, &tx);
            tx->c_x_p = cx; tx->c_y_p = cy;

            if(found) continue;
            if(pri_beg > cx && pri_beg < ax && aux_beg > cy && aux_beg < ay)
            {
                kv_pushp(ca_buf_t, o->c_buf, &tx);
                tx->c_x_p = pri_beg; tx->c_y_p = aux_beg;
                found = 1;
            } 
        }
    }

    
    // fprintf(stderr, "\ncmd-%s\n", cmd);
    // fprintf(stderr, "pri_beg=%u, pri_len=%lu\n", pri_beg, pri_len);
    // fprintf(stderr, "aux_beg=%u, aux_len=%lu\n", aux_beg, aux_len);

    // print_buf_t(ug, pri, "pri");
    // print_buf_t(ug, aux, "aux");


    tx = &(o->c_buf.a[o->c_buf.n-1]);
    len = MIN(pri_len - tx->c_x_p, aux_len - tx->c_y_p);
    if(len > 0)///insert boundary
    {
        kv_pushp(ca_buf_t, o->c_buf, &tx);
        tx->c_x_p = o->c_buf.a[o->c_buf.n-2].c_x_p + len;
        tx->c_y_p = o->c_buf.a[o->c_buf.n-2].c_y_p + len;     
    }

    tx = &(o->c_buf.a[0]);///insert boundary
    if(tx->c_x_p != 0 && tx->c_y_p != 0)///already at boundary
    {
        len = MIN(tx->c_x_p, tx->c_y_p);///offset
        kv_pushp(ca_buf_t, o->c_buf, &tx);
        for (i = 0; (i + 1)< o->c_buf.n; i++)
        {
            o->c_buf.a[o->c_buf.n - i - 1] = o->c_buf.a[o->c_buf.n - i - 2];
        }
        o->c_buf.a[0].c_x_p = o->c_buf.a[1].c_x_p - len;
        o->c_buf.a[0].c_y_p = o->c_buf.a[1].c_y_p - len;
    }

    ///chain is [s, e)
    if(o->c_buf.a[0].c_x_p != 0 && o->c_buf.a[0].c_y_p != 0) fprintf(stderr, "ERROR1\n");
    if(o->c_buf.a[o->c_buf.n-1].c_x_p!= pri_len && 
                                            o->c_buf.a[o->c_buf.n-1].c_y_p!= aux_len)
    {
        fprintf(stderr, "ERROR2\n");
    }

    utg_trans_hit_idx iter;
    utg_thit_t hit, *kh = NULL;
    ////////prx
    reset_utg_trans_hit_idx(&iter, pri_a, pri_n, ug, o, o->c_buf.a[0].c_x_p, o->c_buf.a[o->c_buf.n-1].c_x_p);    
    while(get_utg_trans_hit(&iter, &hit))//get [qs, qe), [qus, que)
    {
        refine_utg_thit_t(&hit, &(o->c_buf)); ///get [ts, te)
        kv_push(utg_thit_t, o->k_t_b, hit);
    }
    bn = o->k_t_b.n;
    
    ////////aux
    reset_utg_trans_hit_idx(&iter, aux_a, aux_n, ug, o, o->c_buf.a[0].c_y_p, o->c_buf.a[o->c_buf.n-1].c_y_p);    
    while(get_utg_trans_hit(&iter, &hit))
    {
        extract_sub_overlaps_utg_thit(hit.qs, hit.qe, hit.qus, hit.que, hit.qn, &(o->k_t_b), bn);
    }

    if(o->k_t_b.n - bn == 0) fprintf(stderr, "ERROR7\n");
    
    // fprintf(stderr, "\n******o->k_t_b.n: %u, bn: %u\n", (uint32_t)o->k_t_b.n, bn);
    // for (i = 0; i < pri_n; i++)
    // {
    //     fprintf(stderr, "p-utg%.6ul\n", (pri_a[i]>>1) + 1);
    // }
    // for (i = 0; i < aux_n; i++)
    // {
    //     fprintf(stderr, "a-utg%.6ul\n", (aux_a[i]>>1) + 1);
    // }

    u_trans_t *kt = NULL;
    double x_score, y_score;
    for (i = bn; i < o->k_t_b.n; i++)
    {
        kh = &(o->k_t_b.a[i]);
        if(kh->que <= kh->qus) continue;
        if(kh->tue <= kh->tus) continue;
        kv_pushp(u_trans_t, o->k_trans, &kt);
        kt->f = flag; kt->rev = ((kh->qn ^ kh->tn) & 1); kt->del = 0; 
        kt->qn = kh->qn>>1; kt->qs = kh->qus; kt->qe = kh->que; ///kt->qo = kh->qn&1;
        kt->tn = kh->tn>>1; kt->ts = kh->tus; kt->te = kh->tue; ///kt->to = kh->tn&1;
        if(score < 0)
        {
            kt->nw = (MIN((kt->qe - kt->qs), (kt->te - kt->ts)))*CHAIN_MATCH;
        } 
        else
        {
            x_score = ((double)(kt->qe-kt->qs)/(double)(o->c_buf.a[o->c_buf.n-1].c_x_p-o->c_buf.a[0].c_x_p))*score;
            y_score = ((double)(kt->te-kt->ts)/(double)(o->c_buf.a[o->c_buf.n-1].c_y_p-o->c_buf.a[0].c_y_p))*score;
            kt->nw = MIN(x_score, y_score);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm0, 0x20(%rsp)
movq %r9, %r15
movq %rsi, %r13
movq %rdi, %rbx
movq 0xe8(%rsp), %r12
movq 0xe0(%rsp), %r14
testq %r8, %r8
movl %ecx, 0x10(%rsp)
movl %edx, 0x14(%rsp)
je 0x18eaba
movl %ecx, %r9d
movq (%r8), %rax
jmp 0x18eaca
movq %r12, %rdi
movq %r13, %rsi
callq 0x18e2d7
movl 0x10(%rsp), %r9d
movq %rax, 0x18(%rsp)
movl 0xd0(%rsp), %edx
testq %r14, %r14
je 0x18eae0
movq (%r14), %rax
jmp 0x18eaf0
movq %r12, %rdi
movq %r15, %rsi
callq 0x18e2d7
movl 0x10(%rsp), %r9d
xorl %ecx, %ecx
movq %rcx, 0x98(%rbx)
movq %rcx, 0x80(%rbx)
movq 0x40(%rbx), %rsi
testq %rsi, %rsi
je 0x18eb1c
movq 0x50(%rbx), %rcx
movslq (%rcx), %rcx
leaq (%rcx,%rcx,4), %rcx
shlq $0x3, %rcx
addq 0x30(%rbx), %rcx
movq %rax, 0x50(%rsp)
movl 0xd8(%rsp), %r8d
testq %rcx, %rcx
movq %r15, 0x60(%rsp)
movq %r13, 0x58(%rsp)
je 0x18eb57
movq 0x18(%rcx), %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
cmpl %r9d, %edx
setbe %dl
cmpl %r8d, %ecx
setbe %cl
orb %dl, %cl
jne 0x18f1c0
cmpq $0x0, 0xa0(%rbx)
jne 0x18eb91
movq $0x2, 0xa0(%rbx)
movq 0xa8(%rbx), %rdi
movl $0x38, %esi
callq 0x2370
movl 0xd8(%rsp), %r8d
movl 0x10(%rsp), %r9d
movq %rax, 0xa8(%rbx)
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x98(%rbx)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl %r9d, 0x10(%rcx,%rdx)
movl %r8d, 0x14(%rcx,%rdx)
cmpq $0x0, 0x40(%rbx)
je 0x18ec67
movl $0x1, %ebp
xorl %eax, %eax
movl $0x2, %r14d
movq 0x30(%rbx), %r15
movq 0x50(%rbx), %rcx
movslq (%rcx,%rax,4), %r12
movq 0xa0(%rbx), %rax
cmpq %rax, 0x98(%rbx)
jne 0x18ec23
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r14, %rcx
movq %rcx, 0xa0(%rbx)
movq 0xa8(%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, 0xa8(%rbx)
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x98(%rbx)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
leaq (%r12,%r12,4), %rax
movq 0x18(%r15,%rax,8), %rax
rorq $0x20, %rax
movq %rax, 0x10(%rcx,%rdx)
movl %ebp, %eax
incl %ebp
cmpq %rax, 0x40(%rbx)
ja 0x18ebd7
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rdi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movl -0xc(%rdi,%rcx), %edx
movl -0x8(%rdi,%rcx), %ecx
movq 0x18(%rsp), %r15
movq %r15, %rsi
subq %rdx, %rsi
movq 0x50(%rsp), %rbp
movq %rbp, %r14
subq %rcx, %r14
cmpq %r14, %rsi
cmovbq %rsi, %r14
testl %r14d, %r14d
movq 0x58(%rsp), %r13
je 0x18ed22
movq 0xa0(%rbx), %rcx
cmpq %rcx, %rax
jne 0x18ece9
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rax, %rcx
movq %rcx, 0xa0(%rbx)
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, 0xa8(%rbx)
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x98(%rbx)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl -0xc(%rcx,%rdx), %eax
addl %r14d, %eax
movl %eax, 0x10(%rcx,%rdx)
addl -0x8(%rcx,%rdx), %r14d
movl %r14d, 0x14(%rcx,%rdx)
leaq 0x98(%rbx), %r14
movq 0xa8(%rbx), %rdi
movl 0x10(%rdi), %eax
testl %eax, %eax
je 0x18edf7
movl 0x14(%rdi), %r12d
testl %r12d, %r12d
je 0x18edf7
cmpl %r12d, %eax
cmovbl %eax, %r12d
movq 0xa0(%rbx), %rax
cmpq %rax, 0x98(%rbx)
jne 0x18ed8d
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmovneq %rcx, %rax
movq %rax, 0xa0(%rbx)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
callq 0x2370
movq %rax, 0xa8(%rbx)
movq (%r14), %rax
incq %rax
movq %rax, (%r14)
cmpq $0x2, %rax
jb 0x18edde
xorl %ecx, %ecx
movq 0xa8(%rbx), %rdx
movl %ecx, %esi
subq %rsi, %rax
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movupd -0x38(%rdx,%rsi), %xmm0
movupd -0x2c(%rdx,%rsi), %xmm1
movupd %xmm1, -0x10(%rdx,%rsi)
movupd %xmm0, -0x1c(%rdx,%rsi)
leal 0x2(%rcx), %edx
movq 0x98(%rbx), %rax
incl %ecx
cmpq %rdx, %rax
ja 0x18ed9e
movq 0xa8(%rbx), %rax
movl 0x2c(%rax), %ecx
movl 0x30(%rax), %edx
subl %r12d, %ecx
movl %ecx, 0x10(%rax)
subl %r12d, %edx
movl %edx, 0x14(%rax)
movq 0xa8(%rbx), %rax
cmpl $0x0, 0x10(%rax)
je 0x18ee0e
cmpl $0x0, 0x14(%rax)
jne 0x18f3e1
movq 0x98(%rbx), %rdx
movq 0xa8(%rbx), %rax
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
movl -0xc(%rax,%rcx), %edx
cmpq %rdx, %r15
movq 0xe8(%rsp), %r15
je 0x18ee47
addq %rcx, %rax
movl -0x8(%rax), %eax
cmpq %rax, %rbp
jne 0x18f3eb
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rcx
movl 0x10(%rcx), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movl -0xc(%rcx,%rsi), %eax
leaq 0x68(%rsp), %rdi
movq %r13, 0x10(%rdi)
movl 0x14(%rsp), %ecx
movl %ecx, 0x18(%rdi)
movq %r15, 0x20(%rdi)
movq %rbx, 0x28(%rdi)
movl %edx, 0x8(%rdi)
movl %eax, 0xc(%rdi)
movq $0x0, (%rdi)
leaq 0x28(%rsp), %rsi
callq 0x18e8bb
testl %eax, %eax
je 0x18ef47
leaq 0x28(%rsp), %r15
movl $0x2, %r13d
leaq 0x68(%rsp), %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x18e3b4
movq 0x88(%rbx), %rax
cmpq %rax, 0x80(%rbx)
jne 0x18eef6
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, 0x88(%rbx)
movq 0x90(%rbx), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x90(%rbx)
movq 0x80(%rbx), %rax
movq 0x90(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x80(%rbx)
leaq (%rax,%rax,4), %rax
movq 0x48(%rsp), %rdx
movq %rdx, 0x20(%rcx,%rax,8)
movupd 0x28(%rsp), %xmm0
movupd 0x38(%rsp), %xmm1
movupd %xmm1, 0x10(%rcx,%rax,8)
movupd %xmm0, (%rcx,%rax,8)
movq %r12, %rdi
movq %r15, %rsi
callq 0x18e8bb
testl %eax, %eax
jne 0x18eeae
leaq 0x80(%rbx), %r14
movq 0x80(%rbx), %r13
movq 0x98(%rbx), %rax
movl %r13d, %ebp
movq 0xa8(%rbx), %rcx
movl 0x14(%rcx), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movl -0x8(%rcx,%rsi), %eax
leaq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rcx
movq %rcx, 0x10(%rdi)
movl 0xd0(%rsp), %ecx
movl %ecx, 0x18(%rdi)
movq 0xe8(%rsp), %rcx
movq %rcx, 0x20(%rdi)
movq %rbx, 0x28(%rdi)
movl %edx, 0x8(%rdi)
movl %eax, 0xc(%rdi)
movq $0x0, (%rdi)
leaq 0x28(%rsp), %rsi
callq 0x18e8bb
testl %eax, %eax
je 0x18eff5
leaq 0x68(%rsp), %r15
leaq 0x28(%rsp), %r12
movl 0x28(%rsp), %edi
movl 0x2c(%rsp), %esi
movl 0x34(%rsp), %edx
movl 0x38(%rsp), %ecx
movl 0x30(%rsp), %r8d
movl %r13d, (%rsp)
movq %r14, %r9
callq 0x18e60f
movq %r15, %rdi
movq %r12, %rsi
callq 0x18e8bb
testl %eax, %eax
jne 0x18efc5
cmpq %rbp, (%r14)
je 0x18f3d7
cmpq %rbp, (%r14)
movsd 0x20(%rsp), %xmm4
jbe 0x18f1ae
movl 0xf0(%rsp), %r12d
andb $0x3f, %r12b
incl %r13d
movl $0x2, %r15d
xorpd %xmm5, %xmm5
movq 0x90(%rbx), %rax
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
movl 0x10(%rax,%rcx,8), %edx
cmpl 0xc(%rax,%rcx,8), %edx
jbe 0x18f19f
leaq (%rax,%rcx,8), %rbp
movl 0x24(%rbp), %eax
cmpl 0x20(%rbp), %eax
jbe 0x18f19f
movq 0xb8(%rbx), %rax
cmpq %rax, 0xb0(%rbx)
jne 0x18f09d
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r15, %rcx
movq %rcx, 0xb8(%rbx)
movq 0xc0(%rbx), %rdi
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
xorpd %xmm5, %xmm5
movsd 0x20(%rsp), %xmm4
movq %rax, 0xc0(%rbx)
movq 0xb0(%rbx), %rcx
movq 0xc0(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0xb0(%rbx)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movb 0x28(%rax,%rcx), %dl
andb $-0x40, %dl
orb %r12b, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x1c(%rbp), %edx
xorl 0x8(%rbp), %edx
shlb $0x6, %dl
andb $0x40, %dl
orb %r12b, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x8(%rbp), %edx
shrl %edx
movl %edx, 0x8(%rax,%rcx)
movl 0xc(%rbp), %edx
movl %edx, (%rax,%rcx)
movl 0x10(%rbp), %edi
movl %edi, 0x4(%rax,%rcx)
movl 0x1c(%rbp), %esi
shrl %esi
subl %edx, %edi
ucomisd %xmm4, %xmm5
movl %esi, 0x14(%rax,%rcx)
movl 0x20(%rbp), %esi
movl %esi, 0xc(%rax,%rcx)
movl 0x24(%rbp), %edx
movl %edx, 0x10(%rax,%rcx)
jbe 0x18f125
subl %esi, %edx
cmpl %edx, %edi
cmovbl %edi, %edx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
jmp 0x18f197
movl %edi, %edi
cvtsi2sd %rdi, %xmm0
movq 0x98(%rbx), %rdi
movq 0xa8(%rbx), %r8
leaq (%rdi,%rdi,8), %r9
leaq (%r9,%r9,2), %r9
addq %rdi, %r9
movl -0xc(%r8,%r9), %edi
subl 0x10(%r8), %edi
movl -0x8(%r8,%r9), %r9d
xorps %xmm1, %xmm1
cvtsi2sd %rdi, %xmm1
divsd %xmm1, %xmm0
mulsd %xmm4, %xmm0
subl %esi, %edx
cvtsi2sd %rdx, %xmm2
subl 0x14(%r8), %r9d
xorps %xmm1, %xmm1
cvtsi2sd %r9, %xmm1
divsd %xmm1, %xmm2
mulsd %xmm4, %xmm2
movapd %xmm0, %xmm1
cmplesd %xmm2, %xmm1
movapd %xmm1, %xmm3
andnpd %xmm2, %xmm3
andpd %xmm0, %xmm1
orpd %xmm3, %xmm1
addq %rcx, %rax
movsd %xmm1, 0x20(%rax)
movl %r13d, %ebp
incl %r13d
cmpq %rbp, (%r14)
ja 0x18f026
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rsi, %rsi
je 0x18ec67
cmpq $0x1, %rsi
jne 0x18f23c
cmpq $0x0, 0xa0(%rbx)
jne 0x18f209
movq $0x2, 0xa0(%rbx)
movq 0xa8(%rbx), %rdi
movl $0x38, %esi
callq 0x2370
movl 0xd8(%rsp), %r8d
movl 0x10(%rsp), %r9d
movq %rax, 0xa8(%rbx)
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x98(%rbx)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl %r9d, 0x10(%rcx,%rdx)
movl %r8d, 0x14(%rcx,%rdx)
jmp 0x18ec67
movq 0x40(%rbx), %rdx
testq %rdx, %rdx
je 0x18ec67
xorl %eax, %eax
movl $0x1, %esi
xorl %r15d, %r15d
movq 0x30(%rbx), %rcx
movq 0x50(%rbx), %rdi
movl %esi, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpq %r13, %rdx
jbe 0x18f282
movslq (%rdi,%r13,4), %rdx
leaq (%rdx,%rdx,4), %rdx
movq 0x18(%rcx,%rdx,8), %r12
movq %r12, %rbp
shrq $0x20, %rbp
movslq (%rdi,%rax,4), %rax
leaq (%rax,%rax,4), %rax
movq 0x18(%rcx,%rax,8), %r14
movq 0xa0(%rbx), %rax
cmpq %rax, 0x98(%rbx)
jne 0x18f2e1
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0xa0(%rbx)
movq 0xa8(%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movl 0xd8(%rsp), %r8d
movl 0x10(%rsp), %r9d
movq %rax, 0xa8(%rbx)
movq %r14, %rdx
shrq $0x20, %rdx
movq 0x98(%rbx), %rcx
movq 0xa8(%rbx), %rdi
leaq 0x1(%rcx), %rax
movq %rax, 0x98(%rbx)
leaq (%rcx,%rcx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rcx, %rsi
movl %edx, 0x10(%rdi,%rsi)
movl %r14d, 0x14(%rdi,%rsi)
movl $0x1, %ecx
testl %r15d, %r15d
jne 0x18f3bb
xorl %ecx, %ecx
cmpl %r9d, %edx
jae 0x18f3bb
cmpl %r9d, %ebp
jbe 0x18f3bb
cmpl %r8d, %r14d
jae 0x18f3bb
cmpl %r8d, %r12d
jbe 0x18f3bb
movq 0xa0(%rbx), %rcx
cmpq %rcx, %rax
jne 0x18f388
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rax
movq %rax, 0xa0(%rbx)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
callq 0x2370
movl 0xd8(%rsp), %r8d
movl 0x10(%rsp), %r9d
movq %rax, 0xa8(%rbx)
movq 0x98(%rbx), %rax
movq 0xa8(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x98(%rbx)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl %r9d, 0x10(%rcx,%rdx)
movl %r8d, 0x14(%rcx,%rdx)
movl $0x1, %ecx
movq 0x40(%rbx), %rdx
leal 0x1(%r13), %esi
movq %r13, %rax
movl %ecx, %r15d
cmpq %r13, %rdx
ja 0x18f253
jmp 0x18ec67
callq 0x245cf
jmp 0x18effe
callq 0x24597
jmp 0x18ee0e
callq 0x245b3
jmp 0x18ee47