// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: gen_raln(ul_idx_t const*, char*, UC_Read*, overlap_region*, bit_extz_t*, long, long, long, long, long, long, long, double, unsigned long, rtrace_t*, ul_ov_t*)
void gen_raln(const ul_idx_t *uref, char* qstr, UC_Read *tu, overlap_region *o, bit_extz_t *exz, 
int64_t wsid, int64_t weid, int64_t ts, int64_t te, int64_t ql, int64_t id, int64_t rev, double e_rate, 
uint64_t rid, rtrace_t *tc, ul_ov_t *res)
{
    // fprintf(stderr, "\n[M::%s::] ii::[%ld, %ld), t::[%ld, %ld), ql::%ld, id::%ld\n", 
    //         __func__, wsid, weid, ts, te, ql, id);
    int64_t k, q[2], t[2], c[2], ct[2], cq[2], mode, qwl, twl, aln_e = 0, cur_e, is_aln; 
    bit_extz_t aux; window_list *wa = o->w_list.a; 
    memset(res, 0, sizeof((*res))); 
    res->qs = res->ts = UINT32_MAX; res->qe = res->te = 0;
    memset(tc, 0, sizeof((*tc)));
    tc->c_qs = tc->c_ts = INT32_MAX; tc->c_qe = tc->c_te = -1;
    tc->pfx_e = tc->mid_e = tc->sfx_e = 0;

    q[0] = q[1] = -1; t[0] = ts; t[1] = te;///[q[0], q[1]) && [t[0], t[1])
    for (k = wsid; k < weid; k++) {
        q[1] = wa[k].x_start; t[1] = wa[k].y_start; 
        mode = - 1; cur_e = 0; is_aln = 1;
        // if(rid == 53 && id == 6) {
        //     fprintf(stderr, "0-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld)\n", __func__, k, q[0], q[1], t[0], t[1]);
        // }
        //before window; there are gaps before the window that need to be filled
        if(t[0] < t[1] && q[0] < q[1]) {
            if(q[0] < 0) { ///backward extension
                mode = 2;
                adjust_ext_offset_fixed_t(&(q[0]), &(q[1]), &(t[0]), &(t[1]), 0, q[1], t[0], t[1], 0, mode);
            } else {
                mode = 0;
            }
            // if(rid == 53 && id == 6) {
            //     fprintf(stderr, "1-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), mode::%ld\n", 
            //     __func__, k, q[0], q[1], t[0], t[1], mode);
            // }
            qwl = q[1] - q[0]; twl = t[1] - t[0];
            if(qwl || twl) {
                if(qwl == 0 && twl > 0) {
                    cur_e = twl;
                    // tot_e += twl;
                } else if(twl == 0 && qwl > 0) {
                    cur_e = qwl;
                    // tot_e += qwl;
                } else {
                    if(hc_aln_exz_simi_adv(id, rev, uref, NULL, NULL, qstr, tu, q[0], q[1], t[0], t[1], 
                            0, ql, ts, te, mode, exz, ql, e_rate, MAX_CNS_L, MAX_CNS_E, FORCE_CNS_L, -1, NULL, 0)) {
                        cur_e = exz->err; 
                        // tot_e += exz->err; 
                        q[0] = exz->ts; q[1] = exz->te + 1; t[0] = exz->ps; t[1] = exz->pe + 1;
                        // if(rid == 53 && id == 6) {
                        //     fprintf(stderr, "2-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), mode::%ld, cur_e::%ld\n", 
                        //     __func__, k, q[0], q[1], t[0], t[1], mode, cur_e);
                        // }
                    } else {
                        cur_e = gen_err_unaligned(qwl, twl); is_aln = 0;
                        // tot_e += gen_err_unaligned(qwl, twl); 
                        // if(rid == 53 && id == 6) {
                        //     fprintf(stderr, "2-b[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), mode::%ld, cur_e::%ld\n", 
                        //     __func__, k, q[0], q[1], t[0], t[1], mode, cur_e);
                        // }
                    }
                }
                aln_e += cur_e;
                update_ul_ov_t_coor((*res), q[0], q[1], t[0], t[1]);
                if(k == wsid) tc->pfx_e = cur_e*(is_aln?1:-1);
            }
        } 
        
        ///within window
        q[0] = wa[k].x_start; t[0] = wa[k].y_start;
        q[1] = wa[k].x_end+1; t[1] = wa[k].y_end+1;
        qwl = q[1] - q[0]; twl = t[1] - t[0]; cur_e = 0; is_aln = 1;
        // if(rid == 53 && id == 6) {
        //     fprintf(stderr, "3-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld)\n", 
        //     __func__, k, q[0], q[1], t[0], t[1]);
        // }
        if((ts <= t[0]) && (te >= t[1])) {///cover the whole window
            if(!is_ualn_win(wa[k])) cur_e = wa[k].error;
            else cur_e = gen_err_unaligned(qwl, twl); 
            update_trace_idx(tc, k, 0, wa[k].clen, q[0], q[1], t[0], t[1]);
            // if(rid == 53 && id == 6) {
            //     fprintf(stderr, "4-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld\n", 
            //     __func__, k, q[0], q[1], t[0], t[1], cur_e);
            // }
        } else {///te < t[1]->cover a part of window
            if(ts > t[0]) {
                t[0] = ts; q[0] = -1;
            }
            if(te < t[1]) {
                t[1] = te; q[1] = -1;
            }

            if((q[0] != -1) && (q[1] != -1)) {
                mode = 0;//global
            } else if((q[0] != -1) && (q[1] == -1)) {
                mode = 1;///forward extension
            } else if((q[0] == -1) && (q[1] != -1)) {
                mode = 2;///backward extension
            } else {
                mode = 3;///no primary hit within [ibeg, iend] 
            }
            // if(rid == 53 && id == 6) {
            //     fprintf(stderr, "5-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), mode::%ld\n", 
            //     __func__, k, q[0], q[1], t[0], t[1], mode);
            // }
            if(!is_ualn_win(wa[k])) {///scan cigar by the coordinates of y/t
                set_bit_extz_t(aux, (*o), k); 
                cur_e = hc_aln_exz_by_exist_cigar_with_p(&aux, mode, t[0], t[1], &(q[0]), &(q[1]), 
                &(c[0]), &(c[1]), &(ct[0]), &(ct[1]), &(cq[0]), &(cq[1]));
                update_trace_idx(tc, k, c[0], c[1], cq[0], cq[1], ct[0], ct[1]);
                // if(rid == 53 && id == 6) {
                //     fprintf(stderr, "6-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld, c_q::[%ld, %ld), c_t::[%ld, %ld)\n", 
                //     __func__, k, q[0], q[1], t[0], t[1], cur_e, cq[0], cq[1], ct[0], ct[1]);
                // }
            } else {
                assert(mode == 1 || mode == 2);
                adjust_ext_offset_fixed_t(&(q[0]), &(q[1]), &(t[0]), &(t[1]), q[0], q[1], t[0], t[1], 0, mode);
                qwl = q[1] - q[0]; twl = t[1] - t[0];
                // if(rid == 53 && id == 6) {
                //     fprintf(stderr, "7-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld\n", 
                //     __func__, k, q[0], q[1], t[0], t[1], cur_e);
                // }
                if(qwl || twl) {
                    if(qwl == 0 && twl > 0) {
                        cur_e = twl;
                    } else if(twl == 0 && qwl > 0) {
                        cur_e = qwl;
                    } else {
                        if(hc_aln_exz_simi_adv(id, rev, uref, NULL, NULL, qstr, tu, q[0], q[1], t[0], t[1], 
                                0, ql, ts, te, mode, exz, ql, e_rate, MAX_CNS_L, MAX_CNS_E, FORCE_CNS_L, -1, NULL, 0)) {
                            cur_e = exz->err; 
                            q[0] = exz->ts; q[1] = exz->te + 1; t[0] = exz->ps; t[1] = exz->pe + 1;
                            // if(rid == 53 && id == 6) {
                            //     fprintf(stderr, "7-b[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld\n", 
                            //     __func__, k, q[0], q[1], t[0], t[1], cur_e);
                            // }
                        } else {
                            cur_e = gen_err_unaligned(qwl, twl); is_aln = 0;
                            // if(rid == 53 && id == 6) {
                            //     fprintf(stderr, "7-c[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld\n", 
                            //     __func__, k, q[0], q[1], t[0], t[1], cur_e);
                            // }
                        }
                    }
                    tc->sfx_e = cur_e*(is_aln?1:-1);
                }
            }
        }
        aln_e += cur_e;
        update_ul_ov_t_coor((*res), q[0], q[1], t[0], t[1]);

        q[0] = q[1]; t[0] = t[1];
    }
    // if(ts == 8087 && te == 28530 && ql == 127662) {
    //     fprintf(stderr, "8-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld, ql::%ld\n", 
    //     __func__, k, q[0], q[1], t[0], t[1], cur_e, ql);
    // }
    if(q[0] >= 0 && q[0] < ql) {///forward extension
        q[1] = ql; t[1] = te; cur_e = 0; mode = 1;///forward extension
        adjust_ext_offset_fixed_t(&(q[0]), &(q[1]), &(t[0]), &(t[1]), q[0], q[1], t[0], t[1], 0, mode);
        qwl = q[1] - q[0]; twl = t[1] - t[0]; is_aln = 1;
        // if(rid == 53 && id == 6) {
        //     fprintf(stderr, "9-a[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld\n", 
        //     __func__, k, q[0], q[1], t[0], t[1], cur_e);
        // }
        if(qwl || twl) {
            if(qwl == 0 && twl > 0) {
                cur_e = twl;
            } else if(twl == 0 && qwl > 0) {
                cur_e = qwl;
            } else {
                if(hc_aln_exz_simi_adv(id, rev, uref, NULL, NULL, qstr, tu, q[0], q[1], t[0], t[1], 
                        0, ql, ts, te, mode, exz, ql, e_rate, MAX_CNS_L, MAX_CNS_E, FORCE_CNS_L, -1, NULL, 0)) {
                    cur_e = exz->err; 
                    q[0] = exz->ts; q[1] = exz->te + 1; t[0] = exz->ps; t[1] = exz->pe + 1;
                    // if(rid == 53 && id == 6) {
                    //     fprintf(stderr, "9-b[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld, thre::%d\n", 
                    //     __func__, k, q[0], q[1], t[0], t[1], cur_e, exz->thre);
                    // }
                } else {
                    cur_e = gen_err_unaligned(qwl, twl); is_aln = 0;
                    // if(rid == 53 && id == 6) {
                    //     fprintf(stderr, "9-c[M::%s::k->%ld] q::[%ld, %ld), t::[%ld, %ld), cur_e::%ld\n", 
                    //     __func__, k, q[0], q[1], t[0], t[1], cur_e);
                    // }
                }
            }
            update_ul_ov_t_coor((*res), q[0], q[1], t[0], t[1]);
            tc->sfx_e = cur_e*(is_aln?1:-1);
        }
        aln_e += cur_e;
    }
    tc->mid_e = aln_e - abs(tc->pfx_e) - abs(tc->sfx_e); 
    if(aln_e <= MAX_SEC_ERR) res->sec = aln_e;
    else res->sec = MAX_SEC_ERR;
    // fprintf(stderr, "10-a[M::%s::k->%ld] q::[%u, %u), t::[%u, %u), tot_e::%u\n\n", 
    //                 __func__, k, res->qs, res->qe, res->ts, res->te, res->sec);


    // aln_e = get_sub_cigar_err(res, tc, uref, qstr, tu, o, exz, e_rate);
    // if(aln_e != (int64_t)res->sec) {
    //     fprintf(stderr, "[M::%s::rid->%lu] tot_e::%u, aln_e::%ld, id::%ld\n", 
    //     __func__, rid, res->sec, aln_e, id);
    //     exit(1);
    // }
    
    // assert(aln_e == get_sub_cigar_err(res, tc, uref, qstr, tu, o, exz, e_rate, 0));
    // assert(aln_e == get_sub_cigar_err(res, tc, uref, qstr, tu, o, exz, e_rate, 1));
    // debug_backtrace_step_err(rid, res, tc, uref, qstr, tu, o, exz, e_rate);
    // if(rid == 42 && res->sec == 706 && res->qs == 63686 && res->qe == 75773 
    //                     && res->ts == 9404 && res->te == 21663) {
    //     debug_backtrace_step_err(rid, res, tc, uref, qstr, tu, o, exz, e_rate);
    // }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %xmm0, 0xe8(%rsp)
movq %r8, %r15
movq %rdx, 0xd0(%rsp)
movq %rsi, 0xe0(%rsp)
movq %rdi, 0xd8(%rsp)
movq 0x280(%rsp), %rbx
movq 0x278(%rsp), %r13
movq %rcx, 0x120(%rsp)
movq 0x58(%rcx), %r10
pxor %xmm0, %xmm0
movdqu %xmm0, 0xc(%rbx)
movdqu %xmm0, (%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x10(%rbx)
movq %rax, 0x4(%rbx)
movdqu %xmm0, (%r13)
movdqu %xmm0, 0x20(%r13)
xorl %r11d, %r11d
movl %r11d, 0x30(%r13)
movdqu %xmm0, 0x10(%r13)
movabsq $-0x80000001, %rax      # imm = 0xFFFFFFFF7FFFFFFF
movq %rax, 0x8(%r13)
movq %rax, (%r13)
movq 0x248(%rsp), %r8
movq $0x0, 0x24(%r13)
movl %r11d, 0x2c(%r13)
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x90(%rsp)
movq 0x240(%rsp), %rax
subq %r9, %rax
movq %rax, 0x128(%rsp)
jle 0x81c65
movq %r9, 0xc8(%rsp)
movq %r9, %r14
shlq $0x5, %r14
orq $0x1c, %r14
movq $0x0, 0xc0(%rsp)
xorl %r11d, %r11d
movq %r15, 0xb0(%rsp)
movq %r15, %r9
movq %r10, 0xa8(%rsp)
movslq -0x1c(%r10,%r14), %rax
movq %rax, 0x98(%rsp)
movslq -0x14(%r10,%r14), %r15
movq %r15, %rcx
subq %r8, %rcx
jle 0x81225
movq 0x90(%rsp), %rdx
cmpq %rax, %rdx
jge 0x81225
testq %rdx, %rdx
js 0x81611
xorl %ecx, %ecx
jmp 0x816a7
movq %r11, %rbp
movq %rbx, %r11
movq 0x250(%rsp), %r12
movq 0x248(%rsp), %r8
movslq -0x1c(%r10,%r14), %rsi
movq %rsi, 0x90(%rsp)
movl -0x14(%r10,%r14), %edi
movq %r10, %rcx
movslq %edi, %r10
movslq -0x18(%rcx,%r14), %rdx
leaq 0x1(%rdx), %rax
movq %rax, 0x98(%rsp)
movslq -0x10(%rcx,%r14), %r15
leaq 0x1(%r15), %rcx
movq %r10, %rbx
cmpq %r8, %r10
jl 0x8131e
cmpq %r12, %rcx
jg 0x8131e
movq 0xa8(%rsp), %r10
movswq -0x8(%r10,%r14), %r12
cmpq $0x7fff, %r12           # imm = 0x7FFF
movq %rcx, 0xb8(%rsp)
jne 0x812ac
cmpl $0x0, (%r10,%r14)
je 0x81626
movq 0xc8(%rsp), %rcx
movl (%r10,%r14), %r8d
cmpl %esi, (%r13)
jg 0x812c4
cmpl %edi, 0x8(%r13)
jle 0x812e2
movl %esi, (%r13)
movl %edi, 0x8(%r13)
movq 0xc0(%rsp), %rsi
addl %ecx, %esi
movl %esi, 0x10(%r13)
movl $0x0, 0x18(%r13)
cmpl %edx, 0x4(%r13)
jle 0x812ee
cmpl %r15d, 0xc(%r13)
jg 0x81310
movl %eax, 0x4(%r13)
movq 0xb8(%rsp), %rax
movl %eax, 0xc(%r13)
movq 0xc0(%rsp), %rax
addl %ecx, %eax
movl %eax, 0x14(%r13)
movl %r8d, 0x1c(%r13)
movq %rbx, %rdi
movq %r11, %rbx
movq %rbp, %r11
jmp 0x81597
movq %rbx, %r10
cmpq %r8, %rbx
jge 0x81335
movq $-0x1, 0x90(%rsp)
movq %r8, %r10
cmpq %r12, %rcx
movq %r11, %rbx
jle 0x8134c
movq $-0x1, 0x98(%rsp)
movq %r12, %rcx
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %r15
cmpq $-0x1, %rax
setne %dl
cmpq $-0x1, %r15
setne %sil
testb %sil, %dl
movq %rbp, %r11
movq %r10, 0xa0(%rsp)
je 0x81383
xorl %edi, %edi
xorl %edx, %edx
xorl %esi, %esi
jmp 0x813be
cmpq $-0x1, %rax
setne %dl
cmpq $-0x1, %r15
sete %sil
testb %sil, %dl
je 0x813a3
movl $0x1, %esi
movb $0x1, %dil
xorl %edx, %edx
jmp 0x813be
cmpq $-0x1, %r15
setne %sil
cmpq $-0x1, %rax
sete %dl
andb %sil, %dl
movzbl %dl, %esi
xorq $0x3, %rsi
xorl %edi, %edi
movq 0xa8(%rsp), %r8
cmpw $0x7fff, -0x8(%r8,%r14) # imm = 0x7FFF
jne 0x813e4
cmpl $0x0, (%r8,%r14)
jne 0x813e4
cmpw $0x0, -0xa(%r8,%r14)
js 0x8171d
movq %r11, %r15
movq 0x120(%rsp), %rdi
movq 0x58(%rdi), %rax
movl -0x4(%rax,%r14), %edx
addq %rdx, %rdx
addq 0x70(%rdi), %rdx
movq %rdx, 0x1e8(%rsp)
movl (%rax,%r14), %edx
movq %rdx, 0x1e0(%rsp)
movq %rdx, 0x1d8(%rsp)
movl -0x1c(%rax,%r14), %edx
movl %edx, 0x14c(%rsp)
movl -0x18(%rax,%r14), %edx
movl %edx, 0x150(%rsp)
movl -0x14(%rax,%r14), %edx
movl %edx, 0x140(%rsp)
movl -0x10(%rax,%r14), %edx
movl %edx, 0x144(%rsp)
movswl -0x8(%rax,%r14), %eax
movl %eax, 0x15c(%rsp)
movl %eax, 0x158(%rsp)
leaq 0xf8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x108(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x118(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, (%rsp)
leaq 0x130(%rsp), %rdi
movq 0xa0(%rsp), %rdx
movq %rcx, 0xb8(%rsp)
leaq 0x90(%rsp), %r8
leaq 0x98(%rsp), %r9
callq 0x7e185
movq %rax, %r12
movq 0x110(%rsp), %rax
movq 0xf0(%rsp), %rdx
movq 0x100(%rsp), %rcx
movslq (%r13), %rsi
cmpq %rsi, %rdx
jl 0x81506
movslq 0x8(%r13), %rsi
cmpq %rsi, %rcx
jge 0x81528
movl %edx, (%r13)
movl %ecx, 0x8(%r13)
movq 0xc8(%rsp), %rcx
movq 0xc0(%rsp), %rdx
addl %edx, %ecx
movl %ecx, 0x10(%r13)
movl %eax, 0x18(%r13)
movq 0x118(%rsp), %rax
movq 0xf8(%rsp), %rdx
movq 0x108(%rsp), %rcx
movslq 0x4(%r13), %rsi
cmpq %rsi, %rdx
movq 0x280(%rsp), %rbx
movq %r15, %r11
movq 0xb0(%rsp), %r9
jg 0x81565
movslq 0xc(%r13), %rsi
cmpq %rsi, %rcx
jle 0x81587
movl %edx, 0x4(%r13)
movl %ecx, 0xc(%r13)
movq 0xc8(%rsp), %rcx
movq 0xc0(%rsp), %rdx
addl %edx, %ecx
movl %ecx, 0x14(%r13)
movl %eax, 0x1c(%r13)
movq 0xa0(%rsp), %rdi
movq 0xa8(%rsp), %r10
movl 0x4(%rbx), %ecx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
jge 0x815aa
movl %eax, 0x4(%rbx)
movl 0x8(%rbx), %ecx
movq 0x98(%rsp), %rax
cmpq %rcx, %rax
movq 0xb8(%rsp), %r8
jle 0x815c5
movl %eax, 0x8(%rbx)
movl 0x10(%rbx), %ecx
cmpq %rcx, %rdi
jge 0x815d0
movl %edi, 0x10(%rbx)
movl 0x14(%rbx), %ecx
cmpq %rcx, %r8
jle 0x815dc
movl %r8d, 0x14(%rbx)
addq %r12, %r11
movq %rax, 0x90(%rsp)
addq $0x20, %r14
movq 0xc0(%rsp), %rcx
incq %rcx
movq %rcx, 0xc0(%rsp)
cmpq %rcx, 0x128(%rsp)
jne 0x811ee
jmp 0x81c68
movq %rax, %rdx
subq %rcx, %rdx
jle 0x8166d
movq %rdx, 0x90(%rsp)
movq %r8, %rcx
jmp 0x8167f
cmpw $0x0, -0xa(%r10,%r14)
movq 0xc8(%rsp), %rcx
jns 0x812b4
movq %rax, %r8
subq %rsi, %r8
movq 0xb8(%rsp), %r9
subq %rbx, %r9
cmpq $0x200, %r8             # imm = 0x200
jg 0x8190f
cmpq %r9, %r8
cmovgq %r8, %r9
xorps %xmm0, %xmm0
cvtsi2sd %r9, %xmm0
jmp 0x81945
movq $0x0, 0x90(%rsp)
movq %r15, %rcx
subq %rax, %rcx
movq 0x90(%rsp), %rax
testq %rax, %rax
movl $0x0, %edx
cmovleq %rdx, %rax
movq %rax, 0x90(%rsp)
cmpq %r8, %rcx
cmovgq %rcx, %r8
movl $0x2, %ecx
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rdx
movq %rdx, %r12
subq %rax, %r12
movq %r15, %r13
subq %r8, %r13
movq %r12, %rsi
orq %r13, %rsi
je 0x816e7
movl $0x1, %esi
testq %r12, %r12
jne 0x816fa
testq %r13, %r13
jle 0x816fa
movq 0x250(%rsp), %r12
jmp 0x81893
movq %r11, %rbp
movq %rbx, %r11
movq 0x278(%rsp), %r13
jmp 0x8122b
testq %r13, %r13
sete %sil
testq %r12, %r12
setg %dil
testb %dil, %sil
je 0x8176b
movq %r12, %r13
movq 0x250(%rsp), %r12
jmp 0x8188e
orb %dl, %dil
je 0x81f50
cmpl $0x2, %esi
movq 0xa0(%rsp), %rdi
je 0x8197c
movq %rcx, %rdx
movq %rdi, %r10
cmpl $0x1, %esi
jne 0x81a10
movq %r15, %rdx
subq %rax, %rdx
movq %rcx, %r8
subq %rdi, %r8
cmpq %r8, %rdx
jle 0x819ff
addq %rax, %r8
movq %r8, 0x98(%rsp)
jmp 0x8199b
movq %r11, 0xa0(%rsp)
xorl %esi, %esi
movq %rsi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %r9, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq 0x250(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq 0x248(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq 0x258(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq $-0x1, 0x78(%rsp)
movq $0x100, 0x70(%rsp)      # imm = 0x100
movq $0x3ff, 0x68(%rsp)      # imm = 0x3FF
movq $0xc00, 0x60(%rsp)      # imm = 0xC00
movq 0x260(%rsp), %rdi
movq 0x268(%rsp), %rsi
movq 0xd8(%rsp), %rdx
xorl %ecx, %ecx
movq %r8, %rbx
xorl %r8d, %r8d
movq %r9, %rbp
movq 0xe0(%rsp), %r9
movq 0xe8(%rsp), %xmm0
callq 0x7db99
testq %rax, %rax
je 0x81957
movslq 0x2c(%rbp), %r13
movslq 0x1c(%rbp), %rax
movq %rax, 0x90(%rsp)
movslq 0x20(%rbp), %rax
incq %rax
movq %rax, 0x98(%rsp)
movslq 0x10(%rbp), %r8
movslq 0x14(%rbp), %r15
incq %r15
movq 0x280(%rsp), %rbx
movq 0xa0(%rsp), %r11
movq %rbp, %r9
movq 0x250(%rsp), %r12
movq 0xa8(%rsp), %r10
movl $0x1, %esi
movl 0x4(%rbx), %ecx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
jge 0x818a6
movl %eax, 0x4(%rbx)
movl 0x8(%rbx), %ecx
movq 0x98(%rsp), %rax
cmpq %rcx, %rax
jle 0x818b9
movl %eax, 0x8(%rbx)
movl 0x10(%rbx), %eax
cmpq %rax, %r8
jge 0x818c5
movl %r8d, 0x10(%rbx)
movq %r11, %rbp
movl 0x14(%rbx), %eax
cmpq %rax, %r15
jle 0x818d4
movl %r15d, 0x14(%rbx)
movq %rbx, %r11
addq %r13, %rbp
cmpq $0x0, 0xc0(%rsp)
movq 0x248(%rsp), %r8
je 0x818fa
movq 0x278(%rsp), %r13
jmp 0x8123b
imull %r13d, %esi
movq 0x278(%rsp), %r13
movl %esi, 0x28(%r13)
jmp 0x8123b
cmpq %r9, %r8
cmovlq %r8, %r9
cvtsi2sd %r9, %xmm1
cvtsi2sd %r8, %xmm2
mulsd 0x1a3c20(%rip), %xmm2   # 0x225548
addsd 0x1a3940(%rip), %xmm2   # 0x225270
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
cvttsd2si %xmm0, %r12
movq 0xb0(%rsp), %r9
jmp 0x812b4
movq %rbx, %r8
cmpq $0x200, %r12            # imm = 0x200
movq 0x280(%rsp), %rbx
jg 0x819a0
cmpq %r13, %r12
cmovgq %r12, %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
jmp 0x819d6
movq %r15, %rdx
subq %rax, %rdx
movq %rcx, %r8
subq %rdi, %r8
cmpq %r8, %rdx
jle 0x81a07
movq %r15, %rdx
subq %r8, %rdx
movq %rdx, 0x90(%rsp)
movq %rcx, %rdx
jmp 0x81a02
cmpq %r13, %r12
cmovlq %r12, %r13
cvtsi2sd %r13, %xmm1
cvtsi2sd %r12, %xmm2
mulsd 0x1a3b8f(%rip), %xmm2   # 0x225548
addsd 0x1a38af(%rip), %xmm2   # 0x225270
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq 0xa0(%rsp), %r11
movq 0xb0(%rsp), %r9
movq 0xa8(%rsp), %r10
cvttsd2si %xmm0, %r13
movq $-0x1, %rsi
jmp 0x816da
addq %rdi, %rdx
movq %rdi, %r10
jmp 0x81a10
movq %rcx, %r10
subq %rdx, %r10
movq %rcx, %rdx
movq 0x90(%rsp), %r8
movq 0x98(%rsp), %r9
cmpq %rax, %r8
cmovgq %r8, %rax
movq %rcx, %r8
movq %rax, 0x90(%rsp)
cmpq %rdi, %r10
cmovgq %r10, %rdi
cmpq %r15, %r9
cmovlq %r9, %r15
movq %r15, 0x98(%rsp)
cmpq %rcx, %rdx
cmovlq %rdx, %r8
movq %r15, %r13
subq %rax, %r13
movq %r8, %r12
subq %rdi, %r12
movq %r13, %rdx
orq %r12, %rdx
movq %r8, 0xb8(%rsp)
je 0x81a98
movl $0x1, %ebp
testq %r13, %r13
movq 0xb0(%rsp), %r9
jne 0x81a86
testq %r12, %r12
jg 0x81c48
testq %r12, %r12
jne 0x81ab0
testq %r13, %r13
jle 0x81ab0
movq %r13, %r12
jmp 0x81c48
xorl %r12d, %r12d
movq 0x278(%rsp), %r13
movq 0xb0(%rsp), %r9
jmp 0x8158f
movq %r11, 0xa0(%rsp)
xorl %edx, %edx
movq %rdx, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %r9, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x250(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq 0x248(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movq 0x258(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq $-0x1, 0x78(%rsp)
movq $0x100, 0x70(%rsp)      # imm = 0x100
movq $0x3ff, 0x68(%rsp)      # imm = 0x3FF
movq $0xc00, 0x60(%rsp)      # imm = 0xC00
movq %rdi, %rbx
movq 0x260(%rsp), %rdi
movq 0x268(%rsp), %rsi
movq 0xd8(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r9, %r15
movq 0xe0(%rsp), %r9
movq 0xe8(%rsp), %xmm0
callq 0x7db99
testq %rax, %rax
je 0x81bd1
movslq 0x2c(%r15), %r12
movslq 0x1c(%r15), %rax
movq %rax, 0x90(%rsp)
movslq 0x20(%r15), %rax
incq %rax
movq %rax, 0x98(%rsp)
movslq 0x10(%r15), %rdi
movslq 0x14(%r15), %rax
incq %rax
movq %rax, 0xb8(%rsp)
movq 0x280(%rsp), %rbx
movq 0x278(%rsp), %r13
movq 0xa0(%rsp), %r11
movq %r15, %r9
jmp 0x81c50
movq %rbx, %rdi
cmpq $0x200, %r13            # imm = 0x200
jg 0x81bee
cmpq %r12, %r13
cmovgq %r13, %r12
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
jmp 0x81c24
cmpq %r12, %r13
cmovlq %r13, %r12
cvtsi2sd %r12, %xmm1
cvtsi2sd %r13, %xmm2
mulsd 0x1a3941(%rip), %xmm2   # 0x225548
addsd 0x1a3661(%rip), %xmm2   # 0x225270
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq 0x280(%rsp), %rbx
movq 0xa0(%rsp), %r11
movq 0xb0(%rsp), %r9
cvttsd2si %xmm0, %r12
movq $-0x1, %rbp
movq 0x278(%rsp), %r13
movq 0xa8(%rsp), %r10
imull %r12d, %ebp
movl %ebp, 0x24(%r13)
jmp 0x81597
movq %r15, %r9
movq %rbx, %r10
movq 0x90(%rsp), %rax
testq %rax, %rax
sets %cl
movq 0x258(%rsp), %rsi
movq %rsi, %rbx
subq %rax, %rbx
setle %dl
orb %cl, %dl
jne 0x81ef8
movq %rsi, 0x98(%rsp)
movq 0x250(%rsp), %rdx
movq %rdx, %rcx
subq %r8, %rcx
cmpq %rcx, %rbx
jle 0x81cbd
addq %rax, %rcx
movq %rcx, 0x98(%rsp)
movq %rdx, %rbx
jmp 0x81cc8
movq %rsi, 0x98(%rsp)
addq %r8, %rbx
movq 0x98(%rsp), %rcx
cmpq %rsi, %rcx
cmovgeq %rsi, %rcx
movq %rcx, 0x98(%rsp)
cmpq %rdx, %rbx
cmovgeq %rdx, %rbx
movq %rcx, %r12
subq %rax, %r12
movq %rbx, %r14
subq %r8, %r14
movq %r12, %rdx
orq %r14, %rdx
je 0x81d20
movl $0x1, %r15d
testq %r12, %r12
jne 0x81d0e
testq %r14, %r14
jg 0x81eab
testq %r14, %r14
jne 0x81d28
testq %r12, %r12
jle 0x81d28
movq %r12, %r14
jmp 0x81eab
xorl %r14d, %r14d
jmp 0x81ef5
movq %r11, 0xa0(%rsp)
xorl %edx, %edx
movq %rdx, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %r9, 0x50(%rsp)
movq 0x250(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movq 0x248(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq $-0x1, 0x78(%rsp)
movq $0x100, 0x70(%rsp)      # imm = 0x100
movq $0x3ff, 0x68(%rsp)      # imm = 0x3FF
movq $0xc00, 0x60(%rsp)      # imm = 0xC00
movq $0x1, 0x48(%rsp)
movq 0x260(%rsp), %rdi
movq 0x268(%rsp), %rsi
movq 0xd8(%rsp), %rdx
xorl %ecx, %ecx
movq %r8, 0xb8(%rsp)
xorl %r8d, %r8d
movq %r9, %rbp
movq 0xe0(%rsp), %r9
movq 0xe8(%rsp), %xmm0
callq 0x7db99
testq %rax, %rax
je 0x81e37
movslq 0x2c(%rbp), %r14
movslq 0x1c(%rbp), %rax
movq %rax, 0x90(%rsp)
movslq 0x20(%rbp), %rax
incq %rax
movq %rax, 0x98(%rsp)
movslq 0x10(%rbp), %r8
movslq 0x14(%rbp), %rbx
incq %rbx
movq 0x280(%rsp), %r10
movq 0xa0(%rsp), %r11
jmp 0x81eab
movq 0xb8(%rsp), %r8
cmpq $0x200, %r12            # imm = 0x200
jg 0x81e59
cmpq %r14, %r12
cmovgq %r12, %r14
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
jmp 0x81e8f
cmpq %r14, %r12
cmovlq %r12, %r14
cvtsi2sd %r14, %xmm1
cvtsi2sd %r12, %xmm2
mulsd 0x1a36d6(%rip), %xmm2   # 0x225548
addsd 0x1a33f6(%rip), %xmm2   # 0x225270
movapd %xmm2, %xmm0
cmplesd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq 0x280(%rsp), %r10
movq 0xa0(%rsp), %r11
cvttsd2si %xmm0, %r14
movq $-0x1, %r15
movq %r10, %rdx
movl 0x4(%r10), %ecx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
jge 0x81ec2
movl %eax, 0x4(%rdx)
movl 0x8(%rdx), %ecx
movq 0x98(%rsp), %rax
cmpq %rcx, %rax
jle 0x81ed5
movl %eax, 0x8(%rdx)
movl 0x10(%rdx), %eax
cmpq %rax, %r8
jge 0x81ee1
movl %r8d, 0x10(%rdx)
movl 0x14(%rdx), %eax
cmpq %rax, %rbx
jle 0x81eed
movl %ebx, 0x14(%r10)
imull %r14d, %r15d
movl %r15d, 0x24(%r13)
addq %r14, %r11
movl 0x24(%r13), %eax
movl 0x28(%r13), %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
addl %edx, %ecx
movl %r11d, %eax
subl %ecx, %eax
movl %eax, 0x2c(%r13)
movl 0x18(%r10), %eax
movl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %eax, %edx
orl %ecx, %edx
andl %r11d, %ecx
andl $0xc0000000, %eax       # imm = 0xC0000000
orl %ecx, %eax
cmpq $0x40000000, %r11       # imm = 0x40000000
cmovgel %edx, %eax
movl %eax, 0x18(%r10)
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a743f(%rip), %rdi    # 0x229396
leaq 0x1a36e5(%rip), %rsi    # 0x225643
leaq 0x1a7448(%rip), %rcx    # 0x2293ad
movl $0x5fcd, %edx           # imm = 0x5FCD
callq 0x2110