// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: update_integer_seq(ul_resolve_t*, integer_t*, unsigned int, unsigned long*, unsigned long, unsigned int)
void update_integer_seq(ul_resolve_t *uidx, integer_t *buf, uint32_t id, uint64_t *seq, uint64_t seq_n, uint32_t tid)
{
    // if((((uint32_t)-1) - uidx->idx->a[id].rlen) < asm_opt.thread_num) {
    //     fprintf(stderr, "id->%u, c_tid->%u, l_tid->%u\n", id, tid, (((uint32_t)-1) - uidx->idx->a[id].rlen));
    //     exit(0);
    // }
    // assert(uidx->idx->a[id].rlen!=(uint32_t)-1);
    // fprintf(stderr, "dd->%u\n", uidx->idx->a[id].dd);
    // if(id != 1487) return;
    if(seq_n <= 0) return;
    buf->n_correct++;
    ul_str_t *str = &(uidx->pstr.str.a[id]); uc_block_t *z; ul_chain_t sc, msc;
    uint64_t k, i, pp; integer_aln_t *b; ma_ug_t *ug = uidx->l1_ug;
    assert((seq[0]>>32) == (ug->g->seq[((uint32_t)seq[0])>>1].len));
    // fprintf(stderr, "\n[M::%s::id->%u] seq_n::%lu\n", __func__, id, seq_n);
    // print_primary_ul_chain(str, &(uidx->idx->a[id]), ug);
    if(seq_n == 1) {
        pp = ug->g->seq[((uint32_t)seq[0])>>1].len;
        push_integer_seq_exact(&(uidx->idx->a[id]), ug, seq, seq_n, &pp, tid);
        return;
    }
    
    buf->u.n = 0;
    for (k = 0; k < str->cn; k++) {///old seq
        pp = ((uint32_t)str->a[k])>>1; pp <<= 33; pp += ((uint64_t)(0x100000000));
        pp += (k<<1); pp += ((uint32_t)str->a[k])&1;
        kv_push(uint64_t, buf->u, pp);
        // fprintf(stderr, "ok::%lu, ov::%u\n", k, ((uint32_t)str->a[k]));
    }
    for (k = 0; k < seq_n; k++) {///new seq
        pp = ((uint32_t)seq[k])>>1; pp <<= 33; 
        pp += (k<<1); pp += ((uint32_t)seq[k])&1;
        kv_push(uint64_t, buf->u, pp);
        // fprintf(stderr, "nk::%lu, nv::%u\n", k, ((uint32_t)seq[k]));

        // fprintf(stderr, ">>>>>>[M::%s::c_k->%lu] utg%.6d%c(%c::len->%u)\n", __func__, k,
        //             (((uint32_t)seq[k])>>1)+1, "lc"[ug->u.a[(((uint32_t)seq[k])>>1)].circ], 
        //             "+-"[((uint32_t)seq[k])&1], ug->u.a[(((uint32_t)seq[k])>>1)].len);
    }

    radix_sort_srt64(buf->u.a, buf->u.a + buf->u.n);
    for (k = 0, buf->b.n = 0; k < buf->u.n; k++) {
        if(buf->u.a[k]&((uint64_t)(0x100000000))) continue;///skip nodes in the old seq
        for (i = k+1; (i < buf->u.n) && ((buf->u.a[k]>>33) == (buf->u.a[i]>>33)); i++) {
            if((buf->u.a[i]&((uint64_t)(0x100000000))) == 0) continue;///skip nodes in the new seq
            if((buf->u.a[k]&1) != (buf->u.a[i]&1)) continue;///ignore reverse alignment;
            ///a[k] is the new seq (q); a[i] is old seq (t)
            kv_pushp(integer_aln_t, buf->b, &b);
            b->vq = ((buf->u.a[k]>>33)<<1) + (buf->u.a[k]&1);
            b->tn_rev_qk = ((uint32_t)buf->u.a[k])>>1;
            b->tk = ((uint32_t)buf->u.a[i])>>1; 
            z = &(uidx->idx->a[id].bb.a[str->a[b->tk]>>32]);
            assert(((z->hid<<1)+z->rev)==(((buf->u.a[i]>>33)<<1) + (buf->u.a[i]&1)));
            if((buf->u.a[k]&1) != (buf->u.a[i]&1)) {
                b->tk = str->cn - b->tk - 1;
                b->tn_rev_qk |= ((uint64_t)(0x100000000));
            }            
            b->sc = ug_occ_w(z->ts, z->te, &(ug->u.a[z->hid]));
            assert(b->sc > 0);
        }
    }

    msc.v = msc.s = msc.e = (uint32_t)-1; msc.sc = 0;
    if(buf->b.n > 0) {
        radix_sort_integer_aln_t_srt(buf->b.a, buf->b.a + buf->b.n); ///sorted by rev|qk
        for (k = 1, i = 0; k <= buf->b.n; k++) {
            // fprintf(stderr, "[M::%s::z->%lu] rev::%u, qk::%u, tk::%u\n", 
            // __func__, k-1, (uint32_t)(!!(buf->b.a[k-1].tn_rev_qk>>32)), (uint32_t)buf->b.a[k-1].tn_rev_qk, buf->b.a[k-1].tk);
            if(k == buf->b.n || (buf->b.a[i].tn_rev_qk>>32) != (buf->b.a[k].tn_rev_qk>>32)) {
                if(integer_chain(id, buf->b.a + i, k - i, i, buf, ug, NULL, NULL, &sc) && sc.v != (uint32_t)-1) {
                    if(msc.s == (uint32_t)-1 || msc.sc < sc.sc) msc = sc;
                }
                i = k;
            }
        }
    }
    // fprintf(stderr, "[M::%s::id->%u] seq_n::%lu, align_n::%u, buf->b.n::%u\n", 
    // __func__, id, seq_n, msc.e - msc.s, (uint32_t)buf->b.n);

    
    uint64_t l, v, pd, uls, ule, p_ls, p_le, is_rev, qk, tk, bc; integer_aln_t *x; uc_block_t *tb;
    buf->u.n = 0; kv_resize(uint64_t, buf->u, seq_n); 
    // assert((seq[0]>>32) == (ug->g->seq[((uint32_t)seq[0])>>1].len));
    for (k = l = 0, p_ls = p_le = (uint64_t)-1; k < seq_n; k++) {
        v = (uint32_t)seq[k]; pd = (seq[k]<<1)>>33;
        ule = l + pd; uls = ((ule >= ug->g->seq[v>>1].len)?(ule - ug->g->seq[v>>1].len):(0));
        bc = 0;
        if(k > 0){
            bc = (!!(seq[k]&((uint64_t)(0x8000000000000000))));///if connected in the graph
            if(bc) bc = double_check_gconnect(ug->g, ((uint32_t)seq[k])^1, ((uint32_t)seq[k-1])^1, pd);
            // fprintf(stderr, "bc->%lu\n", bc);
        }
        if(p_ls != (uint64_t)-1) {
            ///uls should uls>=p_ls && uls<=p_le
            if(uls < p_ls) uls = p_ls;
            if(bc && uls > p_le) uls = p_le;
            ///ule should ule > p_le
            if(ule <= p_le) ule = p_le + 1;
        }
        buf->u.a[k] = uls; buf->u.a[k] <<= 32; buf->u.a[k] |= ule;
        p_ls = uls; p_le = ule;
        l = ule;
        // fprintf(stderr, "[init_k->%lu] uls::%lu, ule::%lu, pd::%lu\n", k, uls, ule, pd);
    }
    buf->u.n = seq_n;

    int64_t beg_nl, end_nl; ma_utg_t *u;
    v = (uint32_t)seq[0]; u = &(ug->u.a[v>>1]); beg_nl = u->len;
    v = (uint32_t)seq[seq_n-1]; u = &(ug->u.a[v>>1]); end_nl = u->len;
    // fprintf(stderr, "+[M::%s] beg_nl::%lu, end_nl::%lu\n", __func__, beg_nl, end_nl);

    ///q -> new seq; t -> old seq
    if(msc.s != (uint32_t)-1 && msc.e > msc.s) {
        int64_t qoff, toff, beg_cut = 0, end_cut = 0; uint32_t r_end;
        is_rev = ((buf->b.a[msc.s].tn_rev_qk>>32)&1);

        ///beg
        x = &(buf->b.a[msc.s]); 
        qk = (uint32_t)(x->tn_rev_qk); tk = ((is_rev == 0)? (x->tk):(str->cn - x->tk - 1));
        tb = &(uidx->idx->a[id].bb.a[str->a[tk]>>32]);
        if((!!tb->rev) == (!!is_rev)) {
            if(tb->te == ug->u.a[tb->hid].len) r_end = 1;
            else r_end = 0;
        } else {
            if(tb->ts == 0) r_end = 1;
            else r_end = 0;
        }
        if(r_end) {///start from right end
            qoff = (uint32_t)buf->u.a[qk]; toff = (is_rev?(uidx->idx->a[id].rlen-tb->qs):(tb->qe));
        } else {///start from left end
            qoff = buf->u.a[qk]>>32; toff = (is_rev?(uidx->idx->a[id].rlen-tb->qe):(tb->qs));
        }
        
        if(qk == 0) toff = tb->te - tb->ts;
        if(toff < qoff) beg_cut = qoff - toff;
        // fprintf(stderr, "[M::%s::beg::is_rev->%lu] qoff::%ld, toff::%ld, r_end::%u\n", __func__, is_rev, qoff, toff, r_end);
        

        ///end
        x = &(buf->b.a[msc.e-1]);
        qk = (uint32_t)(x->tn_rev_qk); tk = ((is_rev == 0)? (x->tk):(str->cn - x->tk - 1));
        tb = &(uidx->idx->a[id].bb.a[str->a[tk]>>32]);
        if((!!tb->rev) == (!!is_rev)) {
            if(tb->ts == 0) r_end = 0;
            else r_end = 1;
        } else {
            if(tb->te == ug->u.a[tb->hid].len) r_end = 0;
            else r_end = 1;
        }
        if(!r_end) {
            qoff = l - (buf->u.a[qk]>>32); toff = (is_rev?(tb->qe):(uidx->idx->a[id].rlen-tb->qs));
        } else {
            qoff = l - (uint32_t)(buf->u.a[qk]); toff = (is_rev?(tb->qs):(uidx->idx->a[id].rlen-tb->qe));
        }
        if(qk+1==seq_n) toff = tb->te - tb->ts;
        if(toff < qoff) end_cut = qoff - toff;
        // fprintf(stderr, "[M::%s::end::is_rev->%lu] qoff::%ld, toff::%ld, r_end::%u\n", __func__, is_rev, qoff, toff, r_end);

        if(beg_cut > 0) {
            v = (uint32_t)seq[0]; u = &(ug->u.a[v>>1]);
            if(beg_cut < u->len) beg_cut = u->len - beg_cut;
            else beg_cut = 0;
            if(v&1) { 
                beg_nl = (int64_t)(Get_READ_LENGTH(R_INF, (u->a[0]>>33)));
            } else {
                beg_nl = (int64_t)(Get_READ_LENGTH(R_INF, (u->a[u->n-1]>>33)));
            }
            if(beg_cut > beg_nl) beg_nl = beg_cut;
            if(beg_nl == u->len) beg_cut = 0;
            else beg_cut = 1;
        }

        
        if(end_cut > 0) {
            v = (uint32_t)seq[seq_n-1]; u = &(ug->u.a[v>>1]);
            if(end_cut < u->len) end_cut = u->len - end_cut;
            else end_cut = 0;
            if(v&1) { 
                end_nl = Get_READ_LENGTH(R_INF, (u->a[u->n-1]>>33));
            } else {
                end_nl = Get_READ_LENGTH(R_INF, (u->a[0]>>33));
            }
            if(end_cut > end_nl) end_nl = end_cut;
            if(end_nl == u->len) end_cut = 0;
            else end_cut = 1;
        }
        // fprintf(stderr, "++[M::%s] beg_nl::%lu, end_nl::%lu\n", __func__, beg_nl, end_nl);
        if(beg_cut || end_cut) {
            k = 0; uls = 0; ule = beg_nl; 
            buf->u.a[k] = uls; buf->u.a[k] <<= 32; buf->u.a[k] |= ule;
            l = ule; p_ls = uls; p_le = ule;
            for (k += 1; k + 1 < seq_n; k++) {
                v = (uint32_t)seq[k]; pd = (seq[k]<<1)>>33;
                ule = l + pd; uls = ((ule >= ug->g->seq[v>>1].len)?(ule - ug->g->seq[v>>1].len):(0));
                bc = 0;
                if(k > 0){
                    bc = (!!(seq[k]&((uint64_t)(0x8000000000000000))));///if connected in the graph
                    if(bc) bc = double_check_gconnect(ug->g, ((uint32_t)seq[k])^1, ((uint32_t)seq[k-1])^1, pd);
                    // fprintf(stderr, "bc->%lu\n", bc);
                }
                if(p_ls != (uint64_t)-1) {
                    ///uls should uls>=p_ls && uls<=p_le
                    if(uls < p_ls) uls = p_ls;
                    if(bc && uls > p_le) uls = p_le;
                    ///ule should ule > p_le
                    if(ule <= p_le) ule = p_le + 1;
                }
                buf->u.a[k] = uls; buf->u.a[k] <<= 32; buf->u.a[k] |= ule;
                p_ls = uls; p_le = ule;
                l = ule;
            }

            assert(k < seq_n);
            v = (uint32_t)seq[k]; pd = (seq[k]<<1)>>33;
            ule = l + pd; uls = ((ule >= ug->g->seq[v>>1].len)?(ule - ug->g->seq[v>>1].len):(0));
            ule = uls + end_nl;
            bc = 0;
            if(k > 0){
                bc = (!!(seq[k]&((uint64_t)(0x8000000000000000))));///if connected in the graph
                if(bc) bc = double_check_gconnect(ug->g, ((uint32_t)seq[k])^1, ((uint32_t)seq[k-1])^1, pd);
                // fprintf(stderr, "bc->%lu\n", bc);
            }
            if(p_ls != (uint64_t)-1) {
                ///uls should uls>=p_ls && uls<=p_le
                if(uls < p_ls) uls = p_ls;
                if(bc && uls > p_le) uls = p_le;
                ///ule should ule > p_le
                if(ule <= p_le) ule = p_le + 1;
            }
            if(ule - uls < (uint64_t)end_nl) ule = uls + end_nl;
            buf->u.a[k] = uls; buf->u.a[k] <<= 32; buf->u.a[k] |= ule;
            p_ls = uls; p_le = ule;
            l = ule;
        }
    }
    
    push_integer_seq_exact(&(uidx->idx->a[id]), ug, seq, seq_n, buf->u.a, tid);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, 0x18(%rsp)
testq %r8, %r8
je 0x1fdbfd
movq %rcx, %r9
movq %rsi, %r12
movq %rdi, %r14
incq 0x318(%rsi)
movq 0x18(%rdi), %rdx
movq (%rcx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movq %rdx, 0x40(%rsp)
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
shrl %eax
movl (%rdx,%rax,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl %eax, %ecx
jne 0x1fdc4d
movl 0x18(%rsp), %ecx
cmpq $0x1, %r8
jne 0x1fd06a
leaq 0x78(%rsp), %r8
movq %rax, (%r8)
movq 0x30(%r14), %rax
imulq $0x58, %rcx, %rdi
addq 0x48(%rax), %rdi
movl $0x1, %ecx
movq 0x40(%rsp), %rsi
movq %r9, %rdx
jmp 0x1fdbf8
movq %r8, 0x48(%rsp)
movq %rcx, 0x60(%rsp)
movq %rcx, %rbp
shlq $0x5, %rbp
addq 0x1d0(%r14), %rbp
movq $0x0, 0x90(%r12)
testl $0x7fffffff, 0x18(%rbp) # imm = 0x7FFFFFFF
movq %r9, 0x38(%rsp)
je 0x1fd148
xorl %ebx, %ebx
movl $0x2, %r15d
movq 0x10(%rbp), %rax
movq (%rax,%rbx,8), %r13
movq 0x98(%r12), %rax
cmpq %rax, 0x90(%r12)
jne 0x1fd0f3
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r15, %rsi
movq %rsi, 0x98(%r12)
movq 0xa0(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x38(%rsp), %r9
movq %rax, 0xa0(%r12)
movq %r13, %rax
shlq $0x20, %rax
movabsq $0x100000000, %rcx      # imm = 0x100000000
orq %rcx, %rax
leaq (%rax,%rbx,2), %rax
andl $0x1, %r13d
orq %rax, %r13
movq 0x90(%r12), %rax
movq 0xa0(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x90(%r12)
movq %r13, (%rcx,%rax,8)
incq %rbx
movl 0x18(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %rbx
jb 0x1fd0a8
jmp 0x1fd14d
movq 0x78(%rsp), %r13
movq %rbp, 0x28(%rsp)
movq %r14, 0x70(%rsp)
movq %r13, 0x78(%rsp)
movq 0x48(%rsp), %r13
cmpq $0x1, %r13
adcq $0x0, %r13
xorl %ebp, %ebp
movq %r13, 0x20(%rsp)
movl $0x2, %ebx
movabsq $0x100000000, %r14      # imm = 0x100000000
movq (%r9,%rbp,4), %r15
movq 0x98(%r12), %rax
cmpq %rax, 0x90(%r12)
jne 0x1fd1cb
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x98(%r12)
movq 0xa0(%r12), %rdi
shlq $0x3, %rsi
callq 0x2370
movq 0x38(%rsp), %r9
movq %rax, 0xa0(%r12)
movl %r15d, %eax
andl $-0x2, %eax
shlq $0x20, %rax
movl %r15d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
addq %rbp, %rcx
movq 0x90(%r12), %rax
movq 0xa0(%r12), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, 0x90(%r12)
movq %rcx, (%rdx,%rax,8)
addq $-0x2, %rbx
addq $0x2, %rbp
decq %r13
jne 0x1fd17f
movl %r15d, %eax
shrl %eax
shlq $0x21, %rax
andl $0x1, %r15d
orq %rax, %r15
subq %rbx, %r15
movq %r15, 0x78(%rsp)
movq 0x90(%r12), %rax
movq 0xa0(%r12), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x1e3b6a
movq $0x0, 0x30(%r12)
cmpq $0x0, 0x90(%r12)
je 0x1fd413
xorl %ebp, %ebp
imulq $0x58, 0x60(%rsp), %r13
movq 0xa0(%r12), %rax
testq %r14, (%rax,%rbp,8)
jne 0x1fd402
leaq 0x1(%rbp), %rbx
cmpq 0x90(%r12), %rbx
jae 0x1fd402
movq 0xa0(%r12), %rax
movq (%rax,%rbx,8), %rcx
movq (%rax,%rbp,8), %rax
xorq %rcx, %rax
movq %rax, %rdx
shrq $0x21, %rdx
jne 0x1fd402
testq %r14, %rcx
je 0x1fd3fa
andl $0x1, %eax
jne 0x1fd3fa
movq 0x38(%r12), %rax
cmpq %rax, 0x30(%r12)
jne 0x1fd2f1
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x38(%r12)
movq 0x40(%r12), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x40(%r12)
movq 0x30(%r12), %rax
movq 0x40(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%r12)
leaq (%rax,%rax,2), %rsi
movq 0xa0(%r12), %rdx
movq (%rdx,%rbp,8), %rax
movq %rax, %rdi
shrq $0x20, %rdi
andl $-0x2, %edi
movl %eax, %r8d
andl $0x1, %r8d
orl %edi, %r8d
movl %r8d, 0x4(%rcx,%rsi,8)
shrl %eax
movq %rax, 0x10(%rcx,%rsi,8)
movq (%rdx,%rbx,8), %r11
movl %r11d, %r8d
shrl %r8d
movl %r8d, (%rcx,%rsi,8)
movq 0x70(%rsp), %rdi
movq 0x30(%rdi), %rdi
movq 0x48(%rdi), %rdi
movq 0x30(%rdi,%r13), %rdi
movq 0x28(%rsp), %r9
movq 0x10(%r9), %r9
movl 0x4(%r9,%r8,8), %r9d
leaq (%r9,%r9,8), %r10
movl (%rdi,%r10,4), %r9d
movl 0x20(%rdi,%r10,4), %r15d
shrl $0x5, %r15d
andl $0x1, %r15d
leal (%r15,%r9,2), %r15d
movq %r11, %r14
shrq $0x20, %r14
andl $-0x2, %r14d
andl $0x1, %r11d
addl %r11d, %r14d
cmpl %r15d, %r14d
jne 0x1fdc2e
leaq (%rcx,%rsi,8), %r15
movl (%rdx,%rbp,8), %ecx
andl $0x1, %ecx
cmpl %r11d, %ecx
movabsq $0x100000000, %r14      # imm = 0x100000000
je 0x1fd3ce
movq 0x28(%rsp), %rcx
movl 0x18(%rcx), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
notl %r8d
addl %ecx, %r8d
movl %r8d, (%r15)
orq %r14, %rax
movq %rax, 0x10(%r15)
leaq (%rdi,%r10,4), %rax
movl 0xc(%rax), %edi
movl 0x10(%rax), %esi
leaq (%r9,%r9,4), %rdx
shlq $0x3, %rdx
movq 0x40(%rsp), %rax
addq 0x10(%rax), %rdx
callq 0x1f2d50
movl %eax, 0x8(%r15)
testl %eax, %eax
je 0x1fdc0f
incq %rbx
jmp 0x1fd279
incq %rbp
cmpq 0x90(%r12), %rbp
jb 0x1fd263
movq 0x30(%r12), %rax
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x1fd52c
movq 0x40(%r12), %rdi
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x1e4585
movq 0x30(%r12), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, 0x58(%rsp)
testq %rax, %rax
movq 0x48(%rsp), %r15
je 0x1fd53b
movl $0x1, %ebx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %rcx, 0x58(%rsp)
movl $0x28, %r14d
xorl %ebp, %ebp
leaq 0x80(%rsp), %r13
xorl %ecx, %ecx
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
cmpq %rax, %rbx
je 0x1fd49e
movq 0x40(%r12), %rax
leaq (%rcx,%rcx,2), %rdx
movq (%rax,%r14), %rsi
xorq 0x10(%rax,%rdx,8), %rsi
shrq $0x20, %rsi
je 0x1fd515
leaq (%rcx,%rcx,2), %rsi
shlq $0x3, %rsi
addq 0x40(%r12), %rsi
movq %rbx, %rdx
subq %rcx, %rdx
movq %r13, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movl 0x18(%rsp), %edi
movq %r12, %r8
movq 0x40(%rsp), %r9
callq 0x1f436a
testl %eax, %eax
je 0x1fd512
cmpl $-0x1, 0x88(%rsp)
je 0x1fd512
movq 0x90(%rsp), %rax
cmpl $-0x1, 0x30(%rsp)
je 0x1fd4f3
movq %rbx, %rcx
cmpq %rax, %rbp
jae 0x1fd515
movl 0x80(%rsp), %ecx
movl %ecx, 0x30(%rsp)
movl 0x84(%rsp), %ecx
movq %rcx, 0x58(%rsp)
movq %rbx, %rcx
movq %rax, %rbp
jmp 0x1fd515
movq %rbx, %rcx
incq %rbx
movq 0x30(%r12), %rax
addq $0x18, %r14
cmpq %rax, %rbx
jbe 0x1fd481
jmp 0x1fd53b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x58(%rsp)
movq 0x48(%rsp), %r15
movq $0x0, 0x90(%r12)
cmpq %r15, 0x98(%r12)
jae 0x1fd5af
leaq -0x1(%r15), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x98(%r12)
movq 0xa0(%r12), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq %rax, 0xa0(%r12)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x20(%rax), %rdx
movq 0xa0(%r12), %rdi
movq $-0x1, %rbp
xorl %r8d, %r8d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq $-0x1, %r13
xorl %eax, %eax
xorl %r15d, %r15d
movq 0x38(%rsp), %r10
movq 0x20(%rsp), %rcx
movq %rdx, 0x68(%rsp)
movq (%r10,%r15,8), %rsi
movq %rsi, %r14
shrq $0x20, %r14
andq %r9, %r14
addq %rax, %r14
movl %esi, %eax
shrl %eax
movl (%rdx,%rax,8), %eax
andq %r9, %rax
movq %r14, %rbx
subq %rax, %rbx
cmovbq %r8, %rbx
movl $0x0, %eax
testq %r15, %r15
je 0x1fd670
testq %rsi, %rsi
js 0x1fd631
shrq $0x3f, %rsi
movq %rsi, %rax
jmp 0x1fd670
xorl $0x1, %esi
movq %rbp, 0x18(%rsp)
movl -0x8(%r10,%r15,8), %edx
xorl $0x1, %edx
movq %rdi, %rbp
movq 0x50(%rsp), %rdi
callq 0x1fcf79
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movq %rbp, %rdi
movq 0x68(%rsp), %rdx
movq 0x18(%rsp), %rbp
movq 0x20(%rsp), %rcx
movq 0x38(%rsp), %r10
movl %eax, %eax
cmpq $-0x1, %r13
je 0x1fd69b
cmpq %r13, %rbx
cmovaq %rbx, %r13
cmpq %rbp, %r13
movq %rbp, %rbx
cmovbq %r13, %rbx
testq %rax, %rax
cmoveq %r13, %rbx
cmpq %rbp, %r14
leaq 0x1(%rbp), %rbp
cmovaq %r14, %rbp
jmp 0x1fd69e
movq %r14, %rbp
movq %rbx, %rax
shlq $0x20, %rax
orq %rbp, %rax
movq %rax, (%rdi,%r15,8)
incq %r15
movq %rbx, %r13
movq %rbp, %rax
cmpq %r15, %rcx
jne 0x1fd5f4
movq 0x48(%rsp), %r15
movq %r15, 0x90(%r12)
movl 0x30(%rsp), %edx
cmpl $-0x1, %edx
setne %al
cmpl %edx, 0x58(%rsp)
seta %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1fdbd2
movq 0x40(%r12), %r11
movl %edx, %eax
leaq (%rax,%rax,2), %rax
leaq (%r11,%rax,8), %rax
movq 0x10(%rax), %rdx
movq %rdx, %rdi
shrq $0x20, %rdi
andl $0x1, %edi
movl %edx, %ecx
btq $0x20, %rdx
jb 0x1fd716
movl (%rax), %edx
movq 0x28(%rsp), %r8
jmp 0x1fd72a
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq 0x28(%rsp), %r8
andl 0x18(%r8), %esi
movl (%rax), %edx
notl %edx
addl %esi, %edx
movq (%r10), %r9
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rbx
movl %edx, %edx
movq 0x70(%rsp), %rsi
movq 0x30(%rsi), %rsi
movq 0x48(%rsi), %rax
imulq $0x58, 0x60(%rsp), %rsi
movq %rax, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x30(%rax,%rsi), %r13
movq 0x10(%r8), %r14
movl 0x4(%r14,%rdx,8), %edx
leaq (%rdx,%rdx,8), %rdx
leaq (,%rdx,4), %rdx
addq %r13, %rdx
movzbl 0x20(%rdx), %esi
btl $0x5, %esi
movl %edi, %esi
sbbl $0x0, %esi
jne 0x1fd797
movl (%rdx), %esi
leaq (%rsi,%rsi,4), %rsi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl (%rbx,%rsi,8), %r8d
cmpl %r8d, 0x10(%rdx)
jmp 0x1fd79b
cmpl $0x0, 0xc(%rdx)
setne %sil
movq -0x8(%r10,%r15,8), %rax
movl %r9d, %r15d
movq 0xa0(%r12), %r8
movq (%r8,%rcx,8), %r8
testb %sil, %sil
je 0x1fd7c6
shrq $0x20, %r8
testq %rdi, %rdi
jne 0x1fd7d3
movl 0x4(%rdx), %esi
jmp 0x1fd7f9
movl %r8d, %r8d
testq %rdi, %rdi
jne 0x1fd7e7
movl 0x8(%rdx), %esi
jmp 0x1fd7f9
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %r10
movl 0x18(%rsi,%r10), %esi
subl 0x8(%rdx), %esi
jmp 0x1fd7f9
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %r10
movl 0x18(%rsi,%r10), %esi
subl 0x4(%rdx), %esi
movq %r9, 0x68(%rsp)
shrl %r15d
testq %rcx, %rcx
jne 0x1fd80c
movl 0x10(%rdx), %esi
subl 0xc(%rdx), %esi
movl %eax, %r9d
shrl %r9d
movl %esi, %r10d
xorl %esi, %esi
movq %r8, %rcx
subq %r10, %rcx
cmovaeq %rcx, %rsi
movq 0x58(%rsp), %rcx
decl %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%r11,%rcx,8), %rcx
movl 0x10(%rcx), %edx
testq %rdi, %rdi
movq %r10, 0x30(%rsp)
jne 0x1fd842
movl (%rcx), %r11d
jmp 0x1fd85a
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movq 0x28(%rsp), %r11
andl 0x18(%r11), %r10d
movl (%rcx), %r11d
notl %r11d
addl %r10d, %r11d
leaq (%r15,%r15,4), %rcx
movl %r11d, %r10d
movl 0x4(%r14,%r10,8), %r10d
leaq (%r10,%r10,8), %r10
leaq (%r13,%r10,4), %r13
movzbl 0x20(%r13), %r10d
btl $0x5, %r10d
movl %edi, %r10d
sbbl $0x0, %r10d
movq %rax, 0x50(%rsp)
jne 0x1fd88e
cmpl $0x0, 0xc(%r13)
jmp 0x1fd8a4
movl (%r13), %r10d
leaq (%r10,%r10,4), %r10
movl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
andl (%rbx,%r10,8), %r11d
cmpl %r11d, 0x10(%r13)
sete %r14b
movq 0x48(%rsp), %r15
leaq (%r9,%r9,4), %r11
movl (%rbx,%rcx,8), %eax
movq 0xa0(%r12), %r9
movq (%r9,%rdx,8), %r9
testb %r14b, %r14b
je 0x1fd8e3
shrq $0x20, %r9
testq %rdi, %rdi
jne 0x1fd900
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r10
movl 0x18(%rdi,%r10), %r10d
subl 0x4(%r13), %r10d
jmp 0x1fd90a
movl %r9d, %r9d
testq %rdi, %rdi
jne 0x1fd906
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r10
movl 0x18(%rdi,%r10), %r10d
subl 0x8(%r13), %r10d
jmp 0x1fd90a
movl 0x8(%r13), %r10d
jmp 0x1fd90a
movl 0x4(%r13), %r10d
movq %rbx, %rdi
movl (%rbx,%r11,8), %ebx
subq %r9, %rbp
incq %rdx
cmpq %r15, %rdx
jne 0x1fd924
movl 0x10(%r13), %r10d
subl 0xc(%r13), %r10d
movq %rax, %r14
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
andq %r13, %r14
movl %r10d, %r9d
xorl %edx, %edx
subq %r9, %rbp
cmovgq %rbp, %rdx
cmpl 0x30(%rsp), %r8d
jbe 0x1fd996
leaq (%rdi,%rcx,8), %r9
xorl %ecx, %ecx
movq %r14, %rax
subq %rsi, %r14
cmovaeq %r14, %rcx
leaq 0x8d8d6(%rip), %rsi     # 0x28b230
movq 0x18(%rsi), %rsi
movq 0x18(%r9), %r8
testb $0x1, 0x68(%rsp)
movq 0x38(%rsp), %r10
jne 0x1fd979
movl 0x10(%r9), %r9d
decl %r9d
leaq (%r8,%r9,8), %r8
movq (%r8), %r8
shrq $0x21, %r8
movq (%rsi,%r8,8), %r14
cmpq %r14, %rcx
cmovgq %rcx, %r14
xorl %esi, %esi
cmpq %rax, %r14
setne %sil
jmp 0x1fd99b
movq 0x38(%rsp), %r10
andq %r13, %rbx
testq %rdx, %rdx
jle 0x1fd9ef
leaq (%rdi,%r11,8), %rdi
xorl %eax, %eax
movq %rbx, %rcx
subq %rdx, %rcx
cmovgq %rcx, %rax
leaq 0x8d876(%rip), %rcx     # 0x28b230
movq 0x18(%rcx), %rcx
movq 0x18(%rdi), %rdx
testb $0x1, 0x50(%rsp)
je 0x1fd9d2
movl 0x10(%rdi), %edi
decl %edi
leaq (%rdx,%rdi,8), %rdx
movq (%rdx), %rdx
shrq $0x21, %rdx
movq (%rcx,%rdx,8), %rcx
cmpq %rcx, %rax
cmovgq %rax, %rcx
xorl %edx, %edx
cmpq %rbx, %rcx
setne %dl
movq %rcx, %rbx
orq %rdx, %rsi
je 0x1fdbd2
movq %rbx, 0x50(%rsp)
movq 0xa0(%r12), %r11
movq %r14, (%r11)
cmpq $0x3, %r15
jb 0x1fdb05
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rax), %rdx
movl $0x2, %edi
subq %r15, %rdi
movl $0x1, %r13d
xorl %ebx, %ebx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %r14, %r15
movq %r11, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, 0x30(%rsp)
movq (%r10,%r13,8), %rsi
movq %rsi, %r14
shrq $0x20, %r14
andq %r8, %r14
addq %r15, %r14
movl %esi, %eax
shrl %eax
movl (%rdx,%rax,8), %eax
andq %r8, %rax
movq %r14, %rcx
subq %rax, %rcx
movl $0x0, %ebp
cmovaeq %rcx, %rbp
testq %rsi, %rsi
js 0x1fda81
shrq $0x3f, %rsi
jmp 0x1fdab2
xorl $0x1, %esi
movl -0x8(%r10,%r13,8), %edx
xorl $0x1, %edx
movq 0x18(%rsp), %rdi
callq 0x1fcf79
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %r11
movq 0x38(%rsp), %r10
movl %eax, %esi
cmpq $-0x1, %rbx
je 0x1fdadb
cmpq %rbx, %rbp
cmovaq %rbp, %rbx
cmpq %r15, %rbx
movq %r15, %rbp
cmovbq %rbx, %rbp
testq %rsi, %rsi
cmoveq %rbx, %rbp
leaq 0x1(%r15), %rax
cmpq %r15, %r14
cmovbeq %rax, %r14
movq %rbp, %rax
shlq $0x20, %rax
orq %r14, %rax
movq %rax, (%r11,%r13,8)
leaq (%rdi,%r13), %rax
incq %rax
incq %r13
movq %r14, %r15
movq %rbp, %rbx
cmpq $0x1, %rax
jne 0x1fda4c
jmp 0x1fdb0d
movl $0x1, %r13d
xorl %ebp, %ebp
movq 0x48(%rsp), %r15
cmpq %r15, %r13
jae 0x1fdc6c
movq (%r10,%r13,8), %rsi
movq %rsi, %rax
shrq $0x20, %rax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %rax
addq %r14, %rax
movq 0x40(%rsp), %rdx
movq 0x18(%rdx), %rdi
movq 0x20(%rdi), %rdx
movl %esi, %r8d
shrl %r8d
movl (%rdx,%r8,8), %edx
andq %rcx, %rdx
xorl %ebx, %ebx
subq %rdx, %rax
cmovaeq %rax, %rbx
testq %rsi, %rsi
js 0x1fdb5f
shrq $0x3f, %rsi
jmp 0x1fdb80
xorl $0x1, %esi
movl -0x8(%r10,%r13,8), %edx
xorl $0x1, %edx
movq %r11, 0x28(%rsp)
callq 0x1fcf79
movq 0x28(%rsp), %r11
movq 0x38(%rsp), %r10
movl %eax, %esi
movq 0x50(%rsp), %rax
addq %rbx, %rax
cmpq $-0x1, %rbp
je 0x1fdbb1
cmpq %rbp, %rbx
cmovaq %rbx, %rbp
cmpq %r14, %rbp
movq %r14, %rbx
cmovbq %rbp, %rbx
testq %rsi, %rsi
cmoveq %rbp, %rbx
leaq 0x1(%r14), %rcx
cmpq %r14, %rax
cmovbeq %rcx, %rax
movq %rax, %rcx
subq %rbx, %rcx
movq 0x50(%rsp), %rsi
leaq (%rbx,%rsi), %rdx
cmpq %rsi, %rcx
cmovaeq %rax, %rdx
shlq $0x20, %rbx
orq %rdx, %rbx
movq %rbx, (%r11,%r13,8)
movq 0x70(%rsp), %rax
movq 0x30(%rax), %rax
imulq $0x58, 0x60(%rsp), %rdi
addq 0x48(%rax), %rdi
movq 0xa0(%r12), %r8
movq 0x40(%rsp), %rsi
movq %r10, %rdx
movq %r15, %rcx
callq 0x1fcceb
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3db65(%rip), %rdi     # 0x23b77b
leaq 0x3b708(%rip), %rsi     # 0x239325
leaq 0x3dab7(%rip), %rcx     # 0x23b6db
movl $0x1d00, %edx           # imm = 0x1D00
callq 0x2110
leaq 0x3db05(%rip), %rdi     # 0x23b73a
leaq 0x3b6e9(%rip), %rsi     # 0x239325
leaq 0x3da98(%rip), %rcx     # 0x23b6db
movl $0x1cfa, %edx           # imm = 0x1CFA
callq 0x2110
leaq 0x3da4f(%rip), %rdi     # 0x23b6a3
leaq 0x3b6ca(%rip), %rsi     # 0x239325
leaq 0x3da79(%rip), %rcx     # 0x23b6db
movl $0x1cd3, %edx           # imm = 0x1CD3
callq 0x2110
leaq 0x3db12(%rip), %rdi     # 0x23b785
leaq 0x3b6ab(%rip), %rsi     # 0x239325
leaq 0x3da5a(%rip), %rcx     # 0x23b6db
movl $0x1d9a, %edx           # imm = 0x1D9A
callq 0x2110