// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: chain_origin_trans_uid_by_distance(hap_cov_t*, asg_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_origin_trans_uid_by_distance(hap_cov_t *cov, asg_t *read_sg, 
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 = &(cov->u_buffer);
    kvec_t_i32_warp* tailIndex = &(cov->tailIndex);
    trans_chain* t_ch = cov->t_ch;
    asg_arc_t_offset *tt = NULL;
    ca_buf_t *tx = NULL;

    if(i_pri_len) pri_len = (*i_pri_len);
    else pri_len = set_utg_offset(pri_a, pri_n, ug, read_sg, cov->pos_idx, 0, 1);

    if(i_aux_len) aux_len = (*i_aux_len);
    else aux_len = set_utg_offset(aux_a, aux_n, ug, read_sg, cov->pos_idx, 0, 1);
    
    tt = NULL; t_ch->c_buf.n = 0; t_ch->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, t_ch->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, t_ch->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, t_ch->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, t_ch->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, t_ch->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 = &(t_ch->c_buf.a[t_ch->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, t_ch->c_buf, &tx);
        tx->c_x_p = t_ch->c_buf.a[t_ch->c_buf.n-2].c_x_p + len;
        tx->c_y_p = t_ch->c_buf.a[t_ch->c_buf.n-2].c_y_p + len;     
    }

    tx = &(t_ch->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, t_ch->c_buf, &tx);
        for (i = 0; (i + 1)< t_ch->c_buf.n; i++)
        {
            t_ch->c_buf.a[t_ch->c_buf.n - i - 1] = t_ch->c_buf.a[t_ch->c_buf.n - i - 2];
        }
        t_ch->c_buf.a[0].c_x_p = t_ch->c_buf.a[1].c_x_p - len;
        t_ch->c_buf.a[0].c_y_p = t_ch->c_buf.a[1].c_y_p - len;
    }

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

    u_trans_hit_idx iter;
    u_trans_hit_t hit, *kh = NULL;
    ////////prx
    reset_u_trans_hit_idx(&iter, pri_a, pri_n, ug, read_sg, t_ch, 
                    t_ch->c_buf.a[0].c_x_p, t_ch->c_buf.a[t_ch->c_buf.n-1].c_x_p);    
    while(get_u_trans_hit(&iter, &hit))//get [qScur, qEcur), [qSpre, qEpre)
    {
        refine_u_trans_t(&hit, &(t_ch->c_buf)); ///get [tScur, tEcur)
        kv_push(u_trans_hit_t, t_ch->k_t_b, hit);
    }
    bn = t_ch->k_t_b.n;
    
    ////////aux
    reset_u_trans_hit_idx(&iter, aux_a, aux_n, ug, read_sg, t_ch, 
                    t_ch->c_buf.a[0].c_y_p, t_ch->c_buf.a[t_ch->c_buf.n-1].c_y_p);    
    while(get_u_trans_hit(&iter, &hit))
    {
        extract_sub_overlaps(hit.qScur, hit.qEcur, hit.qSpre, hit.qEpre, hit.qn, &(t_ch->k_t_b), bn);
    }

    
    if(t_ch->k_t_b.n - bn == 0) fprintf(stderr, "ERROR6\n");
    
    

    u_trans_t *kt = NULL;
    double x_score, y_score;
    for (i = bn; i < t_ch->k_t_b.n; i++)
    {
        kh = &(t_ch->k_t_b.a[i]);
        if(kh->qEpre <= kh->qSpre) continue;
        if(kh->tEpre <= kh->tSpre) continue;
        kv_pushp(u_trans_t, t_ch->k_trans, &kt);
        kt->f = flag; kt->rev = ((kh->qn ^ kh->tn) & 1); kt->del = 0; 
        kt->qn = kh->qn>>1; kt->qs = kh->qSpre; kt->qe = kh->qEpre;
        kt->tn = kh->tn>>1; kt->ts = kh->tSpre; kt->te = kh->tEpre;
        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)(t_ch->c_buf.a[t_ch->c_buf.n-1].c_x_p-t_ch->c_buf.a[0].c_x_p))*score;
            y_score = ((double)(kt->te-kt->ts)/(double)(t_ch->c_buf.a[t_ch->c_buf.n-1].c_y_p-t_ch->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 $0xc8, %rsp
movsd %xmm0, 0x30(%rsp)
movl %ecx, %r12d
movq %rsi, %r14
movq %rdi, %rbp
movq 0x120(%rsp), %r15
movq 0x118(%rsp), %rbx
movq 0xa8(%rdi), %r13
testq %r9, %r9
movq %rdx, 0x60(%rsp)
movl %r8d, 0xc(%rsp)
je 0xbca5b
movq (%r9), %rax
jmp 0xbca81
movq 0x10(%rbp), %r8
movl $0x1, (%rsp)
movq %rdx, %rdi
movl %r12d, %esi
movq %r15, %rdx
movq %r14, %rcx
xorl %r9d, %r9d
callq 0xbb724
movl 0xc(%rsp), %r8d
movl %eax, %eax
movq %rax, 0x20(%rsp)
movl 0x108(%rsp), %esi
movq 0x100(%rsp), %rdi
testq %rbx, %rbx
je 0xbca9f
movq (%rbx), %rax
jmp 0xbcabf
movq 0x10(%rbp), %r8
movl $0x1, (%rsp)
movq %r15, %rdx
movq %r14, %rcx
xorl %r9d, %r9d
callq 0xbb724
movl 0xc(%rsp), %r8d
movl %eax, %eax
movq %rax, 0x10(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x180(%r13)
movq %rcx, 0x168(%r13)
movq 0x60(%rbp), %rax
testq %rax, %rax
je 0xbcaf0
movq 0x70(%rbp), %rcx
movslq (%rcx), %rcx
leaq (%rcx,%rcx,4), %rcx
shlq $0x3, %rcx
addq 0x50(%rbp), %rcx
movl 0x110(%rsp), %r9d
testq %rcx, %rcx
movq %r14, 0x28(%rsp)
movl %r12d, 0x1c(%rsp)
je 0xbcb26
movq 0x18(%rcx), %rcx
movq %rcx, %rdx
shrq $0x20, %rdx
cmpl %r8d, %edx
setbe %dl
cmpl %r9d, %ecx
setbe %cl
orb %dl, %cl
jne 0xbd1c3
cmpq $0x0, 0x188(%r13)
jne 0xbcb60
movq $0x2, 0x188(%r13)
movq 0x190(%r13), %rdi
movl $0x38, %esi
callq 0x2370
movl 0x110(%rsp), %r9d
movl 0xc(%rsp), %r8d
movq %rax, 0x190(%r13)
movq 0x180(%r13), %rax
movq 0x190(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x180(%r13)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl %r8d, 0x10(%rcx,%rdx)
movl %r9d, 0x14(%rcx,%rdx)
cmpq $0x0, 0x60(%rbp)
je 0xbcc36
movl $0x1, %ebx
xorl %eax, %eax
movl $0x2, %r14d
movq 0x50(%rbp), %r15
movq 0x70(%rbp), %rcx
movslq (%rcx,%rax,4), %r12
movq 0x188(%r13), %rax
cmpq %rax, 0x180(%r13)
jne 0xbcbf2
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r14, %rcx
movq %rcx, 0x188(%r13)
movq 0x190(%r13), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, 0x190(%r13)
movq 0x180(%r13), %rax
movq 0x190(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x180(%r13)
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 %ebx, %eax
incl %ebx
cmpq %rax, 0x60(%rbp)
ja 0xbcba6
movq 0x180(%r13), %rax
movq 0x190(%r13), %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 0x20(%rsp), %r12
movq %r12, %rsi
subq %rdx, %rsi
movq 0x10(%rsp), %rbx
subq %rcx, %rbx
cmpq %rbx, %rsi
cmovbq %rsi, %rbx
testl %ebx, %ebx
movq 0x28(%rsp), %r14
movl 0x1c(%rsp), %ebp
je 0xbccee
movq 0x188(%r13), %rcx
cmpq %rcx, %rax
jne 0xbccb8
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmovneq %rax, %rcx
movq %rcx, 0x188(%r13)
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, 0x190(%r13)
movq 0x180(%r13), %rax
movq 0x190(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x180(%r13)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl -0xc(%rcx,%rdx), %eax
addl %ebx, %eax
movl %eax, 0x10(%rcx,%rdx)
addl -0x8(%rcx,%rdx), %ebx
movl %ebx, 0x14(%rcx,%rdx)
leaq 0x180(%r13), %r15
movq 0x190(%r13), %rdi
movl 0x10(%rdi), %eax
testl %eax, %eax
je 0xbcdbd
movl 0x14(%rdi), %ebx
testl %ebx, %ebx
je 0xbcdbd
cmpl %ebx, %eax
cmovbl %eax, %ebx
movq 0x188(%r13), %rax
cmpq %rax, 0x180(%r13)
jne 0xbcd55
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmovneq %rcx, %rax
movq %rax, 0x188(%r13)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
callq 0x2370
movq %rax, 0x190(%r13)
movq (%r15), %rax
incq %rax
movq %rax, (%r15)
cmpq $0x2, %rax
jb 0xbcda6
xorl %ecx, %ecx
movq 0x190(%r13), %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 0x180(%r13), %rax
incl %ecx
cmpq %rdx, %rax
ja 0xbcd66
movq 0x190(%r13), %rax
movl 0x2c(%rax), %ecx
movl 0x30(%rax), %edx
subl %ebx, %ecx
movl %ecx, 0x10(%rax)
subl %ebx, %edx
movl %edx, 0x14(%rax)
movq 0x190(%r13), %rax
cmpl $0x0, 0x10(%rax)
je 0xbcdd4
cmpl $0x0, 0x14(%rax)
jne 0xbd3f3
movq 0x180(%r13), %rdx
movq 0x190(%r13), %rax
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
movl -0xc(%rax,%rcx), %edx
cmpq %rdx, %r12
je 0xbce07
addq %rcx, %rax
movl -0x8(%rax), %eax
cmpq %rax, 0x10(%rsp)
jne 0xbd3fd
movq 0x180(%r13), %rax
movq 0x190(%r13), %rcx
movl 0x10(%rcx), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movl -0xc(%rcx,%rsi), %eax
leaq 0x70(%rsp), %rdi
movq 0x60(%rsp), %rcx
movq %rcx, 0x30(%rdi)
movl %ebp, 0x38(%rdi)
movq 0x120(%rsp), %rcx
movq %rcx, 0x40(%rdi)
movq %r14, 0x48(%rdi)
movq %r13, 0x50(%rdi)
movl %edx, 0x24(%rdi)
movl %eax, 0x28(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
movq $-0x1, 0x18(%rdi)
leaq 0x38(%rsp), %rsi
callq 0xbc3ab
testl %eax, %eax
je 0xbcf2b
leaq 0x38(%rsp), %r12
movl $0x2, %ebx
leaq 0x70(%rsp), %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0xbbe92
movq 0x170(%r13), %rax
cmpq %rax, 0x168(%r13)
jne 0xbceda
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %rbx, %rcx
movq %rcx, 0x170(%r13)
movq 0x178(%r13), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x178(%r13)
movq 0x168(%r13), %rax
movq 0x178(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x168(%r13)
leaq (%rax,%rax,4), %rax
movq 0x58(%rsp), %rdx
movq %rdx, 0x20(%rcx,%rax,8)
movupd 0x38(%rsp), %xmm0
movupd 0x48(%rsp), %xmm1
movupd %xmm1, 0x10(%rcx,%rax,8)
movupd %xmm0, (%rcx,%rax,8)
movq %r14, %rdi
movq %r12, %rsi
callq 0xbc3ab
testl %eax, %eax
jne 0xbce92
leaq 0x168(%r13), %r15
movq 0x168(%r13), %r12
movq 0x180(%r13), %rax
movl %r12d, %ebp
movq 0x190(%r13), %rcx
movl 0x14(%rcx), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movl -0x8(%rcx,%rsi), %eax
leaq 0x70(%rsp), %rdi
movq 0x100(%rsp), %rcx
movq %rcx, 0x30(%rdi)
movl 0x108(%rsp), %ecx
movl %ecx, 0x38(%rdi)
movq 0x120(%rsp), %rcx
movq %rcx, 0x40(%rdi)
movq 0x28(%rsp), %rcx
movq %rcx, 0x48(%rdi)
movq %r13, 0x50(%rdi)
movl %edx, 0x24(%rdi)
movl %eax, 0x28(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
movq $-0x1, 0x18(%rdi)
leaq 0x38(%rsp), %rsi
callq 0xbc3ab
testl %eax, %eax
je 0xbcffd
leaq 0x70(%rsp), %rbx
leaq 0x38(%rsp), %r14
movl 0x40(%rsp), %edi
movl 0x44(%rsp), %esi
movl 0x38(%rsp), %edx
movl 0x3c(%rsp), %ecx
movl 0x48(%rsp), %r8d
movl %r12d, (%rsp)
movq %r15, %r9
callq 0xbc0ee
movq %rbx, %rdi
movq %r14, %rsi
callq 0xbc3ab
testl %eax, %eax
jne 0xbcfcd
cmpq %rbp, (%r15)
je 0xbd3e9
cmpq %rbp, (%r15)
movsd 0x30(%rsp), %xmm4
jbe 0xbd1b1
movl 0x128(%rsp), %ebx
andb $0x3f, %bl
incl %r12d
movl $0x2, %r14d
xorpd %xmm5, %xmm5
movq 0x178(%r13), %rax
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
movl 0x4(%rax,%rcx,8), %edx
cmpl (%rax,%rcx,8), %edx
jbe 0xbd1a2
leaq (%rax,%rcx,8), %rbp
movl 0x18(%rbp), %eax
cmpl 0x14(%rbp), %eax
jbe 0xbd1a2
movq 0x140(%r13), %rax
cmpq %rax, 0x138(%r13)
jne 0xbd0a2
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r14, %rcx
movq %rcx, 0x140(%r13)
movq 0x148(%r13), %rdi
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
xorpd %xmm5, %xmm5
movsd 0x30(%rsp), %xmm4
movq %rax, 0x148(%r13)
movq 0x138(%r13), %rcx
movq 0x148(%r13), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x138(%r13)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movb 0x28(%rax,%rcx), %dl
andb $-0x40, %dl
orb %bl, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x24(%rbp), %edx
xorl 0x10(%rbp), %edx
shlb $0x6, %dl
andb $0x40, %dl
orb %bl, %dl
movb %dl, 0x28(%rax,%rcx)
movl 0x10(%rbp), %edx
shrl %edx
movl %edx, 0x8(%rax,%rcx)
movl (%rbp), %edx
movl %edx, (%rax,%rcx)
movl 0x4(%rbp), %edi
movl %edi, 0x4(%rax,%rcx)
movl 0x24(%rbp), %esi
shrl %esi
subl %edx, %edi
ucomisd %xmm4, %xmm5
movl %esi, 0x14(%rax,%rcx)
movl 0x14(%rbp), %esi
movl %esi, 0xc(%rax,%rcx)
movl 0x18(%rbp), %edx
movl %edx, 0x10(%rax,%rcx)
jbe 0xbd128
subl %esi, %edx
cmpl %edx, %edi
cmovbl %edi, %edx
xorps %xmm1, %xmm1
cvtsi2sd %rdx, %xmm1
jmp 0xbd19a
movl %edi, %edi
cvtsi2sd %rdi, %xmm0
movq 0x180(%r13), %rdi
movq 0x190(%r13), %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 %r12d, %ebp
incl %r12d
cmpq %rbp, (%r15)
ja 0xbd02c
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rax, %rax
je 0xbcc36
cmpq $0x1, %rax
jne 0xbd23f
cmpq $0x0, 0x188(%r13)
jne 0xbd20c
movq $0x2, 0x188(%r13)
movq 0x190(%r13), %rdi
movl $0x38, %esi
callq 0x2370
movl 0x110(%rsp), %r9d
movl 0xc(%rsp), %r8d
movq %rax, 0x190(%r13)
movq 0x180(%r13), %rax
movq 0x190(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x180(%r13)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl %r8d, 0x10(%rcx,%rdx)
movl %r9d, 0x14(%rcx,%rdx)
jmp 0xbcc36
movq 0x60(%rbp), %rdx
testq %rdx, %rdx
je 0xbcc36
xorl %eax, %eax
movl $0x1, %esi
xorl %r12d, %r12d
movq 0x50(%rbp), %rcx
movq 0x70(%rbp), %rdi
movl %esi, %ebx
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpq %rbx, %rdx
jbe 0xbd285
movslq (%rdi,%rbx,4), %rdx
leaq (%rdx,%rdx,4), %rdx
movq 0x18(%rcx,%rdx,8), %r14
movq %r14, %r11
shrq $0x20, %r11
movslq (%rdi,%rax,4), %rax
leaq (%rax,%rax,4), %rax
movq 0x18(%rcx,%rax,8), %r15
movq 0x188(%r13), %rax
cmpq %rax, 0x180(%r13)
jne 0xbd2f4
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x188(%r13)
movq 0x190(%r13), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
movq %rbx, 0x68(%rsp)
movq %r11, %rbx
callq 0x2370
movq %rbx, %r11
movq 0x68(%rsp), %rbx
movl 0x110(%rsp), %r9d
movl 0xc(%rsp), %r8d
movq %rax, 0x190(%r13)
movq %r15, %rdx
shrq $0x20, %rdx
movq 0x180(%r13), %rcx
movq 0x190(%r13), %rdi
leaq 0x1(%rcx), %rax
movq %rax, 0x180(%r13)
leaq (%rcx,%rcx,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rcx, %rsi
movl %edx, 0x10(%rdi,%rsi)
movl %r15d, 0x14(%rdi,%rsi)
movl $0x1, %ecx
testl %r12d, %r12d
jne 0xbd3ce
xorl %ecx, %ecx
cmpl %r8d, %edx
jae 0xbd3ce
cmpl %r8d, %r11d
jbe 0xbd3ce
cmpl %r9d, %r15d
jae 0xbd3ce
cmpl %r9d, %r14d
jbe 0xbd3ce
movq 0x188(%r13), %rcx
cmpq %rcx, %rax
jne 0xbd39b
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rax
movq %rax, 0x188(%r13)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
callq 0x2370
movl 0x110(%rsp), %r9d
movl 0xc(%rsp), %r8d
movq %rax, 0x190(%r13)
movq 0x180(%r13), %rax
movq 0x190(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x180(%r13)
leaq (%rax,%rax,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rax, %rdx
movl %r8d, 0x10(%rcx,%rdx)
movl %r9d, 0x14(%rcx,%rdx)
movl $0x1, %ecx
movq 0x60(%rbp), %rdx
leal 0x1(%rbx), %esi
movq %rbx, %rax
movl %ecx, %r12d
cmpq %rbx, %rdx
ja 0xbd256
jmp 0xbcc36
callq 0x10732
jmp 0xbd006
callq 0x106fa
jmp 0xbcdd4
callq 0x10716
jmp 0xbce07