// File: chhylp123[P]hifiasm/Correct.cpp
// Function: gen_backtrace_adv(window_list*, overlap_region*, All_reads*, hpc_t*, ul_idx_t const*, char*, char*, char*, Correct_dumy*, unsigned int, unsigned int)
inline uint32_t gen_backtrace_adv(window_list *p, overlap_region *z, All_reads *rref, hpc_t *hpc_g, const ul_idx_t *uref, 
char *qstr, char *tstr, char *tstr1, Correct_dumy* dumy, uint32_t rev, uint32_t id)
{
    int64_t qs, qe, ql, aln_l, t_pri_l, thres, ts; 
    int r_ts = 0, t_end; int64_t aux_beg, aux_end;
    char *q_string, *t_string; unsigned int error;
    ///there is no problem for x
    qs = p->x_start; qe = p->x_end; ql = qe + 1 - qs;
    thres = p->error_threshold; aln_l = ql + (thres<<1);

    ///y_start is the real y_start
    ///for the window with cigar, y_start has already reduced extra_begin
    ts = p->y_start; aux_beg = p->extra_begin; aux_end = p->extra_end;
    t_pri_l = aln_l - aux_beg - aux_end;

    q_string = qstr + qs; 
    if(rref) {
        fill_subregion(tstr, ts, t_pri_l, rev, rref, id, aux_beg, aux_end); t_string = tstr;
    } else {
        t_string = return_str_seq(tstr, ts, t_pri_l, rev, hpc_g, uref, id, aux_beg, aux_end);
    }
    
    t_end = Reserve_Banded_BPM_PATH(t_string, aln_l, q_string, ql, thres, &error, &r_ts,
        &(dumy->path_length), dumy->matrix_bit, dumy->path, p->error, p->y_end - ts);

    // assert(error != (unsigned int)-1);
    if(error != (unsigned int)-1) {
        /**
        bit_extz_t exz, exz64; init_bit_extz_t(&exz, thres); init_bit_extz_t(&exz64, thres);
        // ed_band_cal_extension_64_0_w(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz64);
        // ed_band_cal_extension_64_0_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz64);
        // cigar_check(t_string+r_ts, q_string, &(exz64));
        // exz64.err = INT32_MAX;
        // ed_band_cal_extension_64_0_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz64);
        // cigar_check(t_string+r_ts, q_string, &(exz64));

        // ed_band_cal_extension_infi_0_w(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, NULL, &exz);
        // ed_band_cal_extension_infi_0_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, NULL, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_extension_infi_0_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, NULL, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // assert(exz.err <= (int32_t)error && exz.err >= 0); 
        // assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);
        
        // ed_band_cal_extension_256_0_w(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz);
        // ed_band_cal_extension_256_0_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_extension_256_0_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // assert(exz.err <= (int32_t)error && exz.err >= 0); 
        // assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);

        // char *qr, *tr;
        // gen_rev_str(q_string, &qr, ql); gen_rev_str(t_string+r_ts, &tr, t_end+1-r_ts); 

        // ed_band_cal_extension_64_1_w(tr, t_end+1-r_ts, qr, ql, thres, &exz64);
        // ed_band_cal_extension_64_1_w_trace(tr, t_end+1-r_ts, qr, ql, thres, &exz64);
        // cigar_check(tr, qr, &exz64);
        // exz64.err = INT32_MAX;
        // ed_band_cal_extension_64_1_w_trace(tr, t_end+1-r_ts, qr, ql, thres, &exz64);
        // cigar_check(tr, qr, &exz64);
        // assert(exz.err == exz64.err && exz.ps == (exz64.pl-exz64.pe-1) && exz.pe == (exz64.pl-exz64.ps-1) && exz.ts == (exz64.tl-exz64.te-1) && exz.te == (exz64.tl-exz64.ts-1));

        // ed_band_cal_extension_infi_1_w(tr, t_end+1-r_ts, qr, ql, thres, NULL, &exz);
        // ed_band_cal_extension_infi_1_w_trace(tr, t_end+1-r_ts, qr, ql, thres, NULL, &exz);
        // cigar_check(tr, qr, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_extension_infi_1_w_trace(tr, t_end+1-r_ts, qr, ql, thres, NULL, &exz);
        // cigar_check(tr, qr, &exz);
        // assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);

        // ed_band_cal_extension_256_1_w(tr, t_end+1-r_ts, qr, ql, thres, &exz);
        // ed_band_cal_extension_256_1_w_trace(tr, t_end+1-r_ts, qr, ql, thres, &exz);
        // cigar_check(tr, qr, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_extension_256_1_w_trace(tr, t_end+1-r_ts, qr, ql, thres, &exz);
        // cigar_check(tr, qr, &exz);
        // assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);

        // free(qr); free(tr);


        // ed_band_cal_global_64_w(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz64);
        // ed_band_cal_global_64_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz64);
        // cigar_check(t_string+r_ts, q_string, &(exz64));
        // exz64.err = INT32_MAX;
        // ed_band_cal_global_64_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz64);
        // cigar_check(t_string+r_ts, q_string, &(exz64));

        // ed_band_cal_global_infi_w(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, NULL, &exz);
        // ed_band_cal_global_infi_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, NULL, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_global_infi_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, NULL, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // assert(exz.err <= (int32_t)error && exz.err >= 0); 
        // assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);

        // ed_band_cal_global_256_w(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz);
        // ed_band_cal_global_256_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_global_256_w_trace(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres, &exz);
        // cigar_check(t_string+r_ts, q_string, &exz);
        // assert(exz.err <= (int32_t)error && exz.err >= 0); 
        // assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);

        
        // ed_band_cal_semi_64_w(t_string, aln_l, q_string, ql, thres, &exz64);
        // ed_band_cal_semi_64_w_trace(t_string, aln_l, q_string, ql, thres, &exz64);
        // cigar_check(t_string, q_string, &(exz64));
        // exz64.err = INT32_MAX;
        // ed_band_cal_semi_64_w_trace(t_string, aln_l, q_string, ql, thres, &exz64);
        // cigar_check(t_string, q_string, &(exz64));

        // ed_band_cal_semi_infi_w(t_string, aln_l, q_string, ql, thres, NULL, &exz);
        // ed_band_cal_semi_infi_w_trace(t_string, aln_l, q_string, ql, thres, NULL, &exz);
        // cigar_check(t_string, q_string, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_semi_infi_w_trace(t_string, aln_l, q_string, ql, thres, NULL, &exz);
        // cigar_check(t_string, q_string, &exz);
        // assert(exz.err <= (int32_t)error && exz.err >= 0); 
        // assert(exz.err == exz64.err && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);

        // ed_band_cal_semi_256_w(t_string, aln_l, q_string, ql, thres, &exz);
        // ed_band_cal_semi_256_w_trace(t_string, aln_l, q_string, ql, thres, &exz);
        // cigar_check(t_string, q_string, &exz);
        // exz.err = INT32_MAX;
        // ed_band_cal_semi_256_w_trace(t_string, aln_l, q_string, ql, thres, &exz);
        // cigar_check(t_string, q_string, &exz);
        // assert(exz.err <= (int32_t)error && exz.err >= 0); 
        // assert(exz.err == exz64.err && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);



        ed_band_cal_semi_64_w_absent_diag(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, &exz64);
        // ed_band_cal_semi_64_w_absent_diag_trace(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
        //                                                                         thres, aux_beg, &exz64);
        // cigar_check(t_string+aux_beg, q_string, &(exz64));
        // exz64.err = INT32_MAX;
        // ed_band_cal_semi_64_w_absent_diag_trace(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
        //                                                                         thres, aux_beg, &exz64);
        // cigar_check(t_string+aux_beg, q_string, &(exz64));



        ed_band_cal_semi_infi_w_absent_diag(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, NULL, &exz);
        ed_band_cal_semi_infi_w_absent_diag_trace(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, NULL, &exz);
        cigar_check(t_string+aux_beg, q_string, &(exz));
        exz.err = INT32_MAX;
        ed_band_cal_semi_infi_w_absent_diag_trace(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, NULL, &exz);
        cigar_check(t_string+aux_beg, q_string, &(exz));
        assert(exz.err <= (int32_t)error && exz.err >= 0); 
        assert(exz.err == exz64.err && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);
        exz64.err = exz.err; exz64.ps = exz.ps; exz64.pe = exz.pe; exz64.ts = exz.ts; exz64.te = exz.te;


        ed_band_cal_semi_256_w_absent_diag(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, &exz);
        ed_band_cal_semi_256_w_absent_diag_trace(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, &exz);
        cigar_check(t_string+aux_beg, q_string, &(exz));
        exz.err = INT32_MAX;
        ed_band_cal_semi_256_w_absent_diag_trace(t_string+aux_beg, aln_l-aux_beg-aux_end, q_string, ql, 
                                                                                thres, aux_beg, &exz);
        cigar_check(t_string+aux_beg, q_string, &(exz));
        assert(exz.err <= (int32_t)error && exz.err >= 0); 
        assert(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te);
        // if((!(exz.err == exz64.err && exz.ps == exz64.ps && exz.pe == exz64.pe && exz.ts == exz64.ts && exz.te == exz64.te)) || (exz.err != (int32_t)error)) {
        //     fprintf(stderr, "\n[M::%s::semi] error::%u, ql::%ld, thres::%ld, exz.err::%d, exz64.err::%d, exz.ps::%d, exz64.ps::%d, exz.pe::%d, exz64.pe::%d, exz.ts::%d, exz64.ts::%d, exz.te::%d, exz64.te::%d\n", __func__, 
        //     error, ql, thres, exz.err, exz64.err, exz.ps, exz64.ps, exz.pe, exz64.pe, exz.ts, exz64.ts, exz.te, exz64.te);
        //     fprintf(stderr, "[tstr] %.*s\n", (int32_t)aln_l, t_string);
        //     fprintf(stderr, "[qstr] %.*s\n", (int32_t)ql, q_string);
        // }
        destroy_bit_extz_t(&exz); destroy_bit_extz_t(&exz64);

        // if(exz.err > (int32_t)error && ql == 1) {
        //     fprintf(stderr, "[M::%s::] error::%u, ed_extension::%d, ql::%ld, thres::%ld\n", 
        //     __func__, error, exz.err, ql, thres);
        //     fprintf(stderr, "[tstr] %.*s\n", t_end+1-r_ts, t_string+r_ts);
        //     fprintf(stderr, "[qstr] %.*s\n", (int32_t)ql, q_string);
        // }
        
        // assert(ed_band_cal_global(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres) == 
        //                 ed_band_cal_global_128bit(t_string+r_ts, t_end+1-r_ts, q_string, ql, thres));
        **/
        
        ///this condition is always wrong
        ///in best case, r_ts = threshold, t_end = aln_l - thres - 1
        if (((t_end+1) == aln_l) || (r_ts == 0)) {
            if(recal_boundary(q_string, tstr1, ql, thres, ts, r_ts, t_end,
            aux_beg, aux_end, error, id, aln_l, rev, dumy, rref, hpc_g, uref, 
            &ts, &r_ts, &t_end, &aux_beg, &aux_end, &error)) {
                p->error = error; p->extra_begin = aux_beg; p->extra_end = aux_end;
                t_string = update_des_str(tstr, ts, aln_l-aux_beg-aux_end, rev, rref, hpc_g, uref,
                                                    id, aux_beg, aux_end, hpc_g?NULL:tstr1);
            }
        }

        generate_cigar(dumy->path, dumy->path_length, p, &(z->w_list), &r_ts, &t_end, &error, q_string, ql, t_string);    

        p->y_start = ts + r_ts - aux_beg; 
        p->y_end = ts + t_end - aux_beg;
        p->error = error;         
        return 1;                     
    }
    p->error = -1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movl $0x0, -0x9c(%rbp)
movq -0x38(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movslq 0x4(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
subq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movswq 0x16(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rax
movq -0x90(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rax
movslq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x38(%rbp), %rax
movswq 0x10(%rax), %rax
movq %rax, -0xa8(%rbp)
movq -0x38(%rbp), %rax
movswq 0x12(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x80(%rbp), %rax
subq -0xa8(%rbp), %rax
subq -0xb0(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rax
addq -0x68(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xa6c51
movq 0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x88(%rbp), %rdx
movl 0x28(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %r8
movl 0x30(%rbp), %eax
movl %eax, %r9d
movq -0xa8(%rbp), %rax
movl %eax, %r10d
movq -0xb0(%rbp), %rax
movzbl %cl, %ecx
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x32160
movq 0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0xa6ca1
movq 0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x88(%rbp), %rdx
movl 0x28(%rbp), %eax
movb %al, %cl
movq -0x50(%rbp), %r8
movq -0x58(%rbp), %r9
movl 0x30(%rbp), %eax
movl %eax, %r11d
movq -0xa8(%rbp), %r10
movq -0xb0(%rbp), %rax
movzbl %cl, %ecx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0xa71f0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
movq -0x80(%rbp), %rax
movl %eax, %esi
movq -0xb8(%rbp), %rdx
movq -0x78(%rbp), %rax
movl %eax, %ecx
movq -0x90(%rbp), %rax
movw %ax, %r8w
movq 0x20(%rbp), %r14
addq $0x7d70, %r14           # imm = 0x7D70
movq 0x20(%rbp), %rbx
addq $0xff0, %rbx            # imm = 0xFF0
movq 0x20(%rbp), %r11
addq $0xa14, %r11            # imm = 0xA14
movq -0x38(%rbp), %rax
movswl 0x14(%rax), %r10d
movq -0x38(%rbp), %rax
movslq 0xc(%rax), %rax
subq -0x98(%rbp), %rax
leaq -0xc4(%rbp), %r9
leaq -0x9c(%rbp), %r15
movzwl %r8w, %r8d
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x28(%rsp)
callq 0x9e3d0
movl %eax, -0xa0(%rbp)
cmpl $-0x1, -0xc4(%rbp)
je 0xa70d9
movl -0xa0(%rbp), %eax
addl $0x1, %eax
cltq
cmpq -0x80(%rbp), %rax
je 0xa6d63
cmpl $0x0, -0x9c(%rbp)
jne 0xa701a
movq -0xb8(%rbp), %rdi
movq 0x18(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x98(%rbp), %r8
movslq -0x9c(%rbp), %r9
movslq -0xa0(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl 0x30(%rbp), %eax
movq %rax, -0xf8(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0xe4(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x50(%rbp), %r13
movq -0x58(%rbp), %r12
leaq -0x98(%rbp), %r15
leaq -0x9c(%rbp), %r14
leaq -0xa0(%rbp), %rbx
leaq -0xa8(%rbp), %r11
leaq -0xb0(%rbp), %r10
leaq -0xc4(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x118(%rbp), %rax
movq %rax, (%rsp)
movq -0x110(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x108(%rbp), %rax
movq %rax, 0x10(%rsp)
movl -0xfc(%rbp), %eax
movl %eax, 0x18(%rsp)
movq -0xf8(%rbp), %rax
movq %rax, 0x20(%rsp)
movq -0xf0(%rbp), %rax
movq %rax, 0x28(%rsp)
movl -0xe4(%rbp), %eax
movl %eax, 0x30(%rsp)
movq -0xe0(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0xd8(%rbp), %rax
movq %rax, 0x40(%rsp)
movq -0xd0(%rbp), %rax
movq %r13, 0x48(%rsp)
movq %r12, 0x50(%rsp)
movq %r15, 0x58(%rsp)
movq %r14, 0x60(%rsp)
movq %rbx, 0x68(%rsp)
movq %r11, 0x70(%rsp)
movq %r10, 0x78(%rsp)
movq %rax, 0x80(%rsp)
callq 0xc6a20
cmpl $0x0, %eax
je 0xa7018
movl -0xc4(%rbp), %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x14(%rax)
movq -0xa8(%rbp), %rax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x10(%rax)
movq -0xb0(%rbp), %rax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x12(%rax)
movq 0x10(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x80(%rbp), %rax
subq -0xa8(%rbp), %rax
subq -0xb0(%rbp), %rax
movq %rax, -0x158(%rbp)
movl 0x28(%rbp), %eax
movb %al, -0x149(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x138(%rbp)
movl 0x30(%rbp), %eax
movq %rax, -0x130(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0xa6f9a
xorl %eax, %eax
movq %rax, -0x170(%rbp)
jmp 0xa6fa5
movq 0x18(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x120(%rbp), %r10
movq -0x128(%rbp), %r11
movq -0x130(%rbp), %rbx
movq -0x138(%rbp), %r14
movq -0x140(%rbp), %r9
movq -0x148(%rbp), %r8
movb -0x149(%rbp), %cl
movq -0x158(%rbp), %rdx
movq -0x160(%rbp), %rsi
movq -0x168(%rbp), %rdi
movq -0x170(%rbp), %rax
movzbl %cl, %ecx
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0xc6da0
movq %rax, -0xc0(%rbp)
jmp 0xa701a
movq 0x20(%rbp), %rdi
addq $0xa14, %rdi            # imm = 0xA14
movq 0x20(%rbp), %rax
movl 0x7d70(%rax), %esi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
addq $0x48, %rcx
movq -0xb8(%rbp), %r11
movq -0x78(%rbp), %rax
movl %eax, %r10d
movq -0xc0(%rbp), %rax
leaq -0x9c(%rbp), %r8
leaq -0xa0(%rbp), %r9
leaq -0xc4(%rbp), %rbx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x9f0f0
movq -0x98(%rbp), %rax
movslq -0x9c(%rbp), %rcx
addq %rcx, %rax
subq -0xa8(%rbp), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x98(%rbp), %rax
movslq -0xa0(%rbp), %rcx
addq %rcx, %rax
subq -0xa8(%rbp), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0xc4(%rbp), %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x14(%rax)
movl $0x1, -0x2c(%rbp)
jmp 0xa70ea
movq -0x38(%rbp), %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop