// File: chhylp123[P]hifiasm/ecovlp.cpp
// Function: wcns_gen(overlap_region_alloc*, All_reads*, UC_Read*, UC_Read*, bit_extz_t*, kv_ul_ov_t*, asg64_v*, asg64_v*, long, unsigned long, long, unsigned long, double, overlap_region*, asg32_v*, cns_gfa*, unsigned long, unsigned int)
uint64_t wcns_gen(overlap_region_alloc* ol, All_reads *rref, UC_Read* qu, UC_Read* tu, bit_extz_t *exz, kv_ul_ov_t *c_idx, asg64_v* idx, asg64_v* buf, int64_t bd, uint64_t wl, int64_t ql, uint64_t occ_tot, double occ_exact, overlap_region *aux_o, asg32_v* b32, cns_gfa *cns, uint64_t cns_g_wl, uint32_t rid)
{
    int64_t on = ol->length, k, i, zwn, q[2]; cns->cns_g_wl = cns_g_wl;
    uint64_t m, *ra, rn, nec = 0, n_id, l_nid, p[2], li; overlap_region *z; ul_ov_t *cp; 
    bit_extz_t ez; uint64_t ci; uint32_t cl; uint16_t c;

    for (k = idx->n = c_idx->n = 0; k < on; k++) {
        z = &(ol->list[k]); zwn = z->w_list.n; z->without_large_indel = l_nid = 0;
        if((!zwn) || (z->is_match != 1)) continue;
        for (i = 0, li = (uint64_t)-1; i < zwn; i++) {
            if(is_ualn_win(z->w_list.a[i])) {
                n_id = z->w_list.a[i].x_end + 1 - z->w_list.a[i].x_start; 
                if(n_id >= 6) l_nid = 1;
                continue;
            }
            q[0] = z->w_list.a[i].x_start; q[1] = z->w_list.a[i].x_end;
            q[0] += bd; q[1] -= bd;
            if(q[1] >= q[0]) {
                m = ((uint64_t)q[0]); m <<= 32; 
                m += c_idx->n; kv_push(uint64_t, *idx, m);

                kv_pushp(ul_ov_t, *c_idx, &cp);
                ovlp_id(*cp) = k; ///ovlp id
                // ovlp_min_wid(*cp) = i; ///beg id of windows
                // ovlp_max_wid(*cp) = i; ///end id of windows
                ovlp_cur_wid(*cp) = i; ///cur id of windows
                ovlp_cur_xoff(*cp) = z->w_list.a[i].x_start; ///cur xpos
                ovlp_cur_yoff(*cp) = z->w_list.a[i].y_start; ///cur xpos
                ovlp_cur_ylen(*cp) = 0;
                ovlp_cur_coff(*cp) = 0; ///cur cigar off in cur window
                ovlp_bd(*cp) = bd;
            }

            if(l_nid == 0) {
                if(i == 0) {
                    p[0] = z->w_list.a[i].x_start; p[1] = z->x_pos_s;
                    n_id = ((p[0] >= p[1])? (p[0] - p[1]): (p[1] - p[0]));
                    if(n_id >= 6) l_nid = 1;
                } 
                
                if(li != (uint64_t)-1) {
                    p[0] = z->w_list.a[i].x_start; p[1] = z->w_list.a[li].x_end + 1;
                    n_id = ((p[0] >= p[1])? (p[0] - p[1]): (p[1] - p[0]));
                    if(n_id >= 6) l_nid = 1;

                    p[0] = z->w_list.a[i].y_start; p[1] = z->w_list.a[li].y_end + 1;
                    n_id = ((p[0] >= p[1])? (p[0] - p[1]): (p[1] - p[0]));
                    if(n_id >= 6) l_nid = 1;
                }

                if(i + 1 == zwn) {
                    p[0] = z->w_list.a[i].x_end; p[1] = z->x_pos_e;
                    n_id = ((p[0] >= p[1])? (p[0] - p[1]): (p[1] - p[0]));
                    if(n_id >= 6) l_nid = 1;
                } 

                if(l_nid == 0) {
                    set_bit_extz_t(ez, (*z), i); ci = 0;
                    while (ci < ez.cigar.n && l_nid == 0) {
                        ci = pop_trace(&(ez.cigar), ci, &c, &cl);
                        if(c >= 2 && cl >= 6) l_nid = 1;
                    }
                }
            }

            li = i;
        }
        z->without_large_indel = (l_nid?0:1);
    }

    int64_t srt_n = idx->n, s, e, t, rr; i = 0;
    radix_sort_ec64(idx->a, idx->a+idx->n);
    for (k = 1, i = 0; k < srt_n; k++) {
        if (k == srt_n || (idx->a[k]>>32) != (idx->a[i]>>32)) {
            if(k - i > 1) {
                for (t = i; t < k; t++) {
                    cp = &(c_idx->a[(uint32_t)idx->a[t]]);
                    // s = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_start+ovlp_bd(*cp);
                    // assert(s == (int64_t)(idx->a[i]>>32));
                    m = ol->list[ovlp_id(*cp)].w_list.a[ovlp_cur_wid(*cp)].x_end+1-ovlp_bd(*cp);
                    m <<= 32; m += ((uint32_t)idx->a[t]); idx->a[t] = m;
                    // fprintf(stderr, "[M::%s] s::%ld\tsi::%lu\n", __func__, s, (idx->a[i]>>32));
                }
                radix_sort_ec64(idx->a + i, idx->a + k);
            }
            i = k;
        }
    }

    // print_debug_ovlp_cigar(ol, idx, c_idx);

    ///second index
    kv_resize(ul_ov_t, *c_idx, (c_idx->n<<1));
    ul_ov_t *idx_a = NULL, *idx_b = NULL;
    idx_a = c_idx->a; idx_b = c_idx->a;
    memcpy(idx_b, idx_a, c_idx->n * (sizeof((*(idx_a)))));

    kv_resize(uint64_t, *buf, ((wl<<1) + idx->n)); buf->n = ((wl<<1) + idx->n);
    memcpy(buf->a + (wl<<1), idx->a, idx->n * (sizeof((*(idx->a)))));
    memset(buf->a, 0, (wl<<1)*(sizeof((*(idx->a)))));

    cc_idx_t ii_a, ii_b; memset(&ii_a, 0, sizeof(ii_a)); memset(&ii_b, 0, sizeof(ii_b));

    ii_a.c_idx = idx_a; ii_a.idx = idx; ii_a.i = ii_a.i0 = 0; ii_a.srt_n = ii_a.idx->n; ii_a.mms = ii_a.mme = (uint64_t)-1;
    ii_b.c_idx = idx_b; ii_b.idx = buf; ii_b.i = ii_b.i0 = (wl<<1); ii_b.srt_n = ii_b.idx->n; ii_b.mms = ii_b.mme = (uint64_t)-1;

    s = 0; e = wl; e = ((e<=ql)?e:ql); rr = 0; 
    aux_o->w_list.n = aux_o->w_list.c.n = 0; ///for cigar
    for (; s < ql; ) {
        rn = iter_cc_idx_t(ol->list, &ii_a, s, e, rr, 0, &ra);
        // debug_inter0(ol->list, ii_a.c_idx, ii_a.idx->a + ii_a.i0, ii_a.srt_n - ii_a.i0, ra, rn, s, e, 0, 1, "-0-");
        rr = wcns_vote(ol->list, rref, qu->seq, ql, tu, exz, ra, rn, s, e, ii_a.c_idx, &ii_b, occ_tot, occ_exact, aux_o, b32, cns, rid, &nec);
        s += wl; e += wl; e = ((e<=ql)?e:ql);
    }

    if(ii_b.mme > ii_b.mms && ii_b.mms != (uint64_t)-1) {
        nec += push_cns_anchor(ol->list, rref, ii_b.mms, ii_b.mme, qu->seq, ql, tu, exz, &ii_b, aux_o, 0, occ_tot, occ_exact, b32, cns, rid);
    }

    nec += push_cns_anchor(ol->list, rref, ql, ql, qu->seq, ql, tu, exz, &ii_b, aux_o, 1, occ_tot, occ_exact, b32, cns, rid);



    ///for debug
    // zwn = aux_o->w_list.n;
    // fprintf(stderr, "\n******[M::%s]****** wn::%ld, ql::%ld\n", __func__, zwn, ql);
    // prt_correct0_dbg(aux_o);
    // for (i = 0; i < zwn; i++) {
    //     fprintf(stderr, "[M::%s] (%ld)[%d, %d)\n", __func__, i, aux_o->w_list.a[i].x_start, aux_o->w_list.a[i].x_end+1);
    // }
    return nec;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movl 0x60(%rbp), %eax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
movq 0x58(%rbp), %rax
movl %eax, %ecx
movq 0x50(%rbp), %rax
movl %ecx, 0x30(%rax)
movq $0x0, -0xb0(%rbp)
movq -0x58(%rbp), %rax
movq $0x0, 0x8(%rax)
movq 0x10(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x2551da
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x70(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x80(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0xe0(%rbp), %rax
movb $0x0, 0x2d(%rax)
cmpq $0x0, -0x80(%rbp)
je 0x2549c2
movq -0xe0(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
je 0x2549c7
jmp 0x2551c9
movq $0x0, -0x78(%rbp)
movq $-0x1, -0xd8(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0x2551a8
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x254a9f
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x254a9f
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x12(%rax), %eax
cmpl $0x0, %eax
jge 0x254a9f
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movq -0xe0(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x78(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
subl (%rcx), %eax
cltq
movq %rax, -0xb8(%rbp)
cmpq $0x6, -0xb8(%rbp)
jb 0x254a9a
movq $0x1, -0xc0(%rbp)
jmp 0x255197
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0x88(%rbp)
movq 0x20(%rbp), %rax
addq -0x90(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x20(%rbp), %rcx
movq -0x88(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
jl 0x254d1e
movq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x98(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
addq -0x98(%rbp), %rax
movq %rax, -0x98(%rbp)
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x254bc2
movq 0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x254b81
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x2a0(%rbp)
jmp 0x254b8f
movl $0x2, %eax
movq %rax, -0x2a0(%rbp)
jmp 0x254b8f
movq -0x2a0(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rdx
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x254be8
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x58(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x254c55
movq -0x58(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x254c19
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x2a8(%rbp)
jmp 0x254c27
movl $0x2, %eax
movq %rax, -0x2a8(%rbp)
jmp 0x254c27
movq -0x2a8(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rdi
movq -0x58(%rbp), %rax
imulq $0x1c, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq -0x58(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0x70(%rbp), %rax
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x78(%rbp), %rax
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movl %ecx, (%rax)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0xe8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0xe8(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0xe8(%rbp), %rax
movl $0x0, 0x8(%rax)
movq 0x20(%rbp), %rax
movl %eax, %edx
movq -0xe8(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl %edx, %ecx
movl %ecx, 0x18(%rax)
cmpq $0x0, -0xc0(%rbp)
jne 0x25518c
cmpq $0x0, -0x78(%rbp)
jne 0x254dc9
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xe0(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jb 0x254d8f
movq -0xd0(%rbp), %rax
subq -0xc8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
jmp 0x254da4
movq -0xc8(%rbp), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x6, -0xb8(%rbp)
jb 0x254dc7
movq $0x1, -0xc0(%rbp)
jmp 0x254dc9
cmpq $-0x1, -0xd8(%rbp)
je 0x254f28
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0xd8(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jb 0x254e46
movq -0xd0(%rbp), %rax
subq -0xc8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
jmp 0x254e5b
movq -0xc8(%rbp), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x2b8(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x6, -0xb8(%rbp)
jb 0x254e7e
movq $0x1, -0xc0(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0xd8(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jb 0x254eee
movq -0xd0(%rbp), %rax
subq -0xc8(%rbp), %rax
movq %rax, -0x2c0(%rbp)
jmp 0x254f03
movq -0xc8(%rbp), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x6, -0xb8(%rbp)
jb 0x254f26
movq $0x1, -0xc0(%rbp)
jmp 0x254f28
movq -0x78(%rbp), %rax
addq $0x1, %rax
cmpq -0x80(%rbp), %rax
jne 0x254fcd
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xe0(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jb 0x254f93
movq -0xd0(%rbp), %rax
subq -0xc8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x254fa8
movq -0xc8(%rbp), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x6, -0xb8(%rbp)
jb 0x254fcb
movq $0x1, -0xc0(%rbp)
jmp 0x254fcd
cmpq $0x0, -0xc0(%rbp)
jne 0x25518a
jmp 0x254fdd
movq -0xe0(%rbp), %rax
movq 0x70(%rax), %rax
movq -0xe0(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x78(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movq %rax, -0x110(%rbp)
movq %rax, -0x118(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x1a4(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x1a0(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x1b0(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x1ac(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x194(%rbp)
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x198(%rbp)
movq $0x0, -0x1c8(%rbp)
movq -0x1c8(%rbp), %rcx
xorl %eax, %eax
cmpq -0x118(%rbp), %rcx
movb %al, -0x2c9(%rbp)
jae 0x255124
cmpq $0x0, -0xc0(%rbp)
sete %al
movb %al, -0x2c9(%rbp)
movb -0x2c9(%rbp), %al
testb $0x1, %al
jne 0x255130
jmp 0x255188
leaq -0x1c0(%rbp), %rdi
addq $0xa8, %rdi
movq -0x1c8(%rbp), %rax
movl %eax, %esi
leaq -0x1ce(%rbp), %rdx
leaq -0x1cc(%rbp), %rcx
callq 0xa1ee0
movl %eax, %eax
movq %rax, -0x1c8(%rbp)
movzwl -0x1ce(%rbp), %eax
cmpl $0x2, %eax
jl 0x255183
cmpl $0x6, -0x1cc(%rbp)
jb 0x255183
movq $0x1, -0xc0(%rbp)
jmp 0x2550fb
jmp 0x25518a
jmp 0x25518c
movq -0x78(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2549da
movq -0xc0(%rbp), %rdx
movl $0x1, %eax
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movb %al, %cl
movq -0xe0(%rbp), %rax
movb %cl, 0x2d(%rax)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x25495f
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
movq $0x0, -0x78(%rbp)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq 0x10(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x24aba0
movq $0x1, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jge 0x2553c6
movq -0x70(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
je 0x255272
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq 0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x78(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x2553b3
movq -0x70(%rbp), %rax
subq -0x78(%rbp), %rax
cmpq $0x1, %rax
jle 0x2553ab
movq -0x78(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rax
cmpq -0x70(%rbp), %rax
jge 0x255380
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x1f0(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl %ecx, %ecx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0xe8(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movq 0x58(%rax), %rax
movq -0xe8(%rbp), %rcx
movl (%rcx), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movq -0xe8(%rbp), %rcx
movl 0x18(%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
subl %ecx, %eax
cltq
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x98(%rbp)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x1f0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
addq -0x98(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdx
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x1f0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x1f0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1f0(%rbp)
jmp 0x25528f
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x78(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x70(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x24aba0
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x2553b5
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x255223
jmp 0x2553c8
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x8(%rcx), %rcx
shlq %rcx
cmpq %rcx, %rax
jae 0x2554ad
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rcx
shlq %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
shrq %rcx
movq -0x58(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x2, %rcx
movq -0x58(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x4, %rcx
movq -0x58(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x8, %rcx
movq -0x58(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
shrq $0x10, %rcx
movq -0x58(%rbp), %rax
orq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rax
movq (%rax), %rdi
movq -0x58(%rbp), %rax
imulq $0x1c, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2554af
movq $0x0, -0x200(%rbp)
movq $0x0, -0x208(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x200(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rdi
movq -0x200(%rbp), %rsi
movq -0x58(%rbp), %rax
imulq $0x1c, 0x8(%rax), %rdx
callq 0x2180
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rbp), %rcx
shlq %rcx
movq 0x10(%rbp), %rdx
addq (%rdx), %rcx
cmpq %rcx, %rax
jae 0x2555ed
movq 0x28(%rbp), %rcx
shlq %rcx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
shrq %rcx
movq 0x18(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x2, %rcx
movq 0x18(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x4, %rcx
movq 0x18(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x8, %rcx
movq 0x18(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x10, %rcx
movq 0x18(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x2555ef
movq 0x28(%rbp), %rcx
shlq %rcx
movq 0x10(%rbp), %rax
addq (%rax), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x28(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq 0x10(%rbp), %rax
movq (%rax), %rdx
shlq $0x3, %rdx
callq 0x2180
movq 0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x28(%rbp), %rdx
shlq %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2100
leaq -0x250(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x2100
leaq -0x298(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x2100
movq -0x200(%rbp), %rax
movq %rax, -0x250(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x248(%rbp)
movq $0x0, -0x238(%rbp)
movq $0x0, -0x240(%rbp)
movq -0x248(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x230(%rbp)
movq $-0x1, -0x210(%rbp)
movq $-0x1, -0x218(%rbp)
movq -0x208(%rbp), %rax
movq %rax, -0x298(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0x290(%rbp)
movq 0x28(%rbp), %rax
shlq %rax
movq %rax, -0x280(%rbp)
movq %rax, -0x288(%rbp)
movq -0x290(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x278(%rbp)
movq $-0x1, -0x258(%rbp)
movq $-0x1, -0x260(%rbp)
movq $0x0, -0x1e0(%rbp)
movq 0x28(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
cmpq 0x30(%rbp), %rax
jg 0x255750
movq -0x1e8(%rbp), %rax
movq %rax, -0x2d8(%rbp)
jmp 0x25575b
movq 0x30(%rbp), %rax
movq %rax, -0x2d8(%rbp)
movq -0x2d8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq $0x0, -0x1f8(%rbp)
movq 0x40(%rbp), %rax
movq $0x0, 0x60(%rax)
movq 0x40(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x1e0(%rbp), %rax
cmpq 0x30(%rbp), %rax
jge 0x255930
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x1e0(%rbp), %rdx
movq -0x1e8(%rbp), %rcx
movq -0x1f8(%rbp), %r8
leaq -0x250(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r9d
leaq -0xa0(%rbp), %rax
movq %rax, (%rsp)
callq 0x24e580
movq %rax, -0xa8(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
movq (%rax), %rdx
movq 0x30(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x50(%rbp), %r9
movq -0xa0(%rbp), %rax
movq %rax, -0x300(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq -0x250(%rbp), %r13
movq 0x38(%rbp), %r15
movsd -0x60(%rbp), %xmm0
movq 0x40(%rbp), %r14
movq 0x48(%rbp), %rbx
movq 0x50(%rbp), %r11
movl 0x60(%rbp), %r10d
leaq -0x298(%rbp), %r12
leaq -0xb0(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movq -0x300(%rbp), %rax
movq %rax, (%rsp)
movq -0x2f8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x2f0(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0x2e8(%rbp), %rax
movq %rax, 0x18(%rsp)
movq -0x2e0(%rbp), %rax
movq %r13, 0x20(%rsp)
movq %r12, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movq %r14, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movq %r11, 0x48(%rsp)
movl %r10d, 0x50(%rsp)
movq %rax, 0x58(%rsp)
callq 0x253c40
movq %rax, -0x1f8(%rbp)
movq 0x28(%rbp), %rax
addq -0x1e0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq 0x28(%rbp), %rax
addq -0x1e8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
cmpq 0x30(%rbp), %rax
jg 0x255912
movq -0x1e8(%rbp), %rax
movq %rax, -0x308(%rbp)
jmp 0x25591d
movq 0x30(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x308(%rbp), %rax
movq %rax, -0x1e8(%rbp)
jmp 0x25578c
movq -0x258(%rbp), %rax
cmpq -0x260(%rbp), %rax
jbe 0x2559ed
cmpq $-0x1, -0x260(%rbp)
je 0x2559ed
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x260(%rbp), %rdx
movq -0x258(%rbp), %rcx
movq -0x40(%rbp), %rax
movq (%rax), %r8
movq 0x30(%rbp), %r9
movq -0x48(%rbp), %r13
movq -0x50(%rbp), %r12
movq 0x40(%rbp), %r14
movq 0x38(%rbp), %rbx
movsd -0x60(%rbp), %xmm0
movq 0x48(%rbp), %r11
movq 0x50(%rbp), %r10
movl 0x60(%rbp), %eax
movl %eax, -0x30c(%rbp)
leaq -0x298(%rbp), %r15
xorl %eax, %eax
movl -0x30c(%rbp), %eax
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movl %eax, 0x40(%rsp)
callq 0x253650
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
movq 0x30(%rbp), %rdx
movq 0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq (%rax), %r8
movq 0x30(%rbp), %r9
movq -0x48(%rbp), %r13
movq -0x50(%rbp), %r12
movq 0x40(%rbp), %r14
movq 0x38(%rbp), %rbx
movsd -0x60(%rbp), %xmm0
movq 0x48(%rbp), %r11
movq 0x50(%rbp), %r10
movl 0x60(%rbp), %eax
leaq -0x298(%rbp), %r15
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq $0x1, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movl %eax, 0x40(%rsp)
callq 0x253650
addq -0xb0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)