// File: chhylp123[P]hifiasm/Correct.cpp
// Function: extract_sub_cigar_hc(overlap_region*, All_reads*, haplotype_evdience_alloc*, char*, unsigned long, UC_Read*, long, long, ul_ov_t*, long, unsigned char*, unsigned char, unsigned long)
int64_t extract_sub_cigar_hc(overlap_region *z, All_reads *rref, haplotype_evdience_alloc* hp, char *qstr, uint64_t ql, UC_Read* tu, int64_t s, int64_t e, ul_ov_t *p, int64_t set_f, uint8_t *f, uint8_t occ_thres, uint64_t hpc_len/**, uint8_t is_dbg**/)
{
    // fprintf(stderr, "\n[M::%s]\ts::%ld\te::%ld\tset_f::%ld\tovlp_id::%u\twid::%u\n", __func__, s, e, set_f, ovlp_id(*p), ovlp_cur_wid(*p));
    // if((!set_f) && (!ovlp_cur_ylen(*p))) return 1;///no potential informative site
    int64_t wk = ovlp_cur_wid(*p), xk = ovlp_cur_xoff(*p), yk = ovlp_cur_yoff(*p), ck = ovlp_cur_coff(*p), os, oe, t;
    bit_extz_t ez; int64_t bd = ovlp_bd(*p), s0, e0; char *ystr = NULL;
    s0 = ((int64_t)(z->w_list.a[wk].x_start)) + bd; 
    e0 = ((int64_t)(z->w_list.a[wk].x_end)) + 1 - bd;
    if(s < s0) s = s0; if(e > e0) e = e0;///exclude boundary
    if(s >= e) return -1;
    os = MAX(s, s0); oe = MIN(e, e0);
    if(oe <= os) return -1;

    set_bit_extz_t(ez, (*z), wk);
    if(!ez.cigar.n) return -1;
    int64_t cn = ez.cigar.n, op; int64_t ws, we, ovlp, xk0, yk0, ck0, yk1 = -1, /**xk1 = -1, ck1 = -1,**/ yl; haplotype_evdience ev; uint8_t om;
    xk0 = xk; yk0 = yk; ck0 = ck; ///for assertion
    if((ck < 0) || (ck > cn)) {//(*ck) == cn is allowed
        ck = 0; xk = ez.ts; yk = ez.ps;
    }
    
    while (ck > 0 && xk > s) {///x -> t; y -> p
        --ck;
        op = ez.cigar.a[ck]>>14;
        if(op!=2) xk -= (ez.cigar.a[ck]&(0x3fff));
        if(op!=3) yk -= (ez.cigar.a[ck]&(0x3fff)); 
    }
    
    if(set_f) {
        ovlp_cur_ylen(*p) = 0;
        xk0 = xk; yk0 = yk; ck0 = ck; 
    } else {
        assert(xk0 == xk); assert(yk0 == yk); assert(ck0 == ck);
        yk1 = yk0 + ovlp_cur_ylen(*p); yl = Get_READ_LENGTH((*rref), z->y_id);

        // UC_Read_resize(*tu, ovlp_cur_ylen(*p)); ystr = tu->seq; 
        // if(is_dbg) fprintf(stderr, "[M::%s] set_f::%ld, yk0::%ld, ovlp_cur_ylen::%u, ylen::%lu\n", __func__, set_f, yk0, ovlp_cur_ylen(*p), Get_READ_LENGTH((*rref), z->y_id));
        // recover_UC_Read_sub_region(ystr, yk0, ovlp_cur_ylen(*p), z->y_pos_strand, rref, z->y_id);
    }

    // if(is_dbg) fprintf(stderr, "---0---[M::%s] set_f::%ld, yk::%ld\n", __func__, set_f, yk);
     //some cigar will span s or e
    while (ck < cn && xk < e) {//[s, e)
        ws = xk; 
        op = ez.cigar.a[ck]>>14;
        if(op!=2) xk += (ez.cigar.a[ck]&(0x3fff));
        if(op!=3) yk += (ez.cigar.a[ck]&(0x3fff)); 
        ck++; we = xk;
        if(op != 0 && op != 1) continue;///only collect match/snp

        os = MAX(s, ws); oe = MIN(e, we);
        ovlp = ((oe>os)? (oe-os):0);
        if(!ovlp) continue;

        if(set_f) {
            if(op == 1) {
                for (t = os; t < oe; t++) {
                    f[t-s] = ((f[t-s]<=126)?(f[t-s]+1):(127));
                }
                // if(!hpc_len) {
                //     yk1 = oe-xk+yk;
                // } else {
                //     yk1 = yk; xk1 = xk; ck1 = ck;
                // } 
                yk1 = oe-xk+yk;
            }
        } else {
            if(op == 0) {
                for (t = os; t < oe; t++) {
                    if(f[t-s]) {
                        om = ((f[t-s]==3)?1:0);
                        ev.misBase = qstr[t];
                        ev.overlapID = ovlp_id(*p);
                        ev.site = t;
                        ev.overlapSite = t-xk+yk;
                        ev.type = (om<<1);
                        ev.cov = 1;
                        addHaplotypeEvdience(hp, &ev, NULL);
                    }
                }
            } else if(op == 1) {
                for (t = os; t < oe; t++) {
                    if(f[t-s]) {
                        if(!ystr) {
                            // yk0 = ((hpc_len)?(detect_near_cc_tlen(&ez, ck, xk, yk, 1)):(t-xk+yk));
                            yk0 = t-xk+yk;
                            yk0 -= hpc_len; if(yk0 < 0) yk0 = 0;
                            UC_Read_resize(*tu, (yk1 - yk0)); ystr = tu->seq; 
                            recover_UC_Read_sub_region(ystr, yk0, (yk1 - yk0), z->y_pos_strand, rref, z->y_id);
                        }

                        om = ((f[t-s]==3)?1:0);
                        if((!om) && (hpc_len) && (hpc_mask_ff(ystr, yk1 - yk0, t-xk+yk-yk0, hpc_len, HPC_RR, NULL, -1, -1, HPC_CC))) om = 1;

                        ev.misBase = ystr[t-xk+yk-yk0];
                        ev.overlapID = ovlp_id(*p);
                        ev.site = t;
                        ev.overlapSite = t-xk+yk;
                        ev.type = (om<<1) + 1;
                        ev.cov = 1;
                        addHaplotypeEvdience(hp, &ev, NULL);
                        // if(ev.overlapID == 21 && ev.site == 17129) {
                        //     fprintf(stderr, "[M::%s]\ts::%ld\te::%ld\tck::%ld\txk::%ld\tyk::%ld\tset_f::%ld\n", __func__, s, e, ck, xk, yk, set_f);
                        // }
                    }

                }
            }
        }
    }
    // if(is_dbg) fprintf(stderr, "---1---[M::%s] set_f::%ld, yk::%ld\n", __func__, set_f, yk);

    if(set_f) {
        ovlp_cur_xoff(*p) = xk0; ovlp_cur_yoff(*p) = yk0; ovlp_cur_coff(*p) = ck0; 
        if(yk1 != -1) {
            // if((xk1 != -1) && (yk1 != -1)) {///detect nearby differences
            //     yk1 = detect_near_cc_tlen(&ez, ck1, xk1, yk1, 0);
            // }
            yk1 += hpc_len;
            yl = Get_READ_LENGTH((*rref), z->y_id);
            if(yk1 > yl) yk1 = yl;
            ovlp_cur_ylen(*p) = yk1 - yk0;
        } else {///no potential informative site; no second round
            ovlp_cur_ylen(*p) = 0;
        }
    } else {
        ovlp_cur_xoff(*p) = xk; ovlp_cur_yoff(*p) = yk; ovlp_cur_coff(*p) = ck; ovlp_cur_ylen(*p) = 0;
    }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq 0x40(%rbp), %rax
movb 0x38(%rbp), %al
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq 0x20(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x40(%rbp)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x48(%rbp)
movq 0x20(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x50(%rbp)
movq 0x20(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x58(%rbp)
movq 0x20(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, %eax
movq %rax, -0x150(%rbp)
movq $0x0, -0x168(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
addq -0x150(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
addq $0x1, %rax
subq -0x150(%rbp), %rax
movq %rax, -0x160(%rbp)
movq 0x10(%rbp), %rax
cmpq -0x158(%rbp), %rax
jge 0x6e0fe
movq -0x158(%rbp), %rax
movq %rax, 0x10(%rbp)
movq 0x18(%rbp), %rax
cmpq -0x160(%rbp), %rax
jle 0x6e116
movq -0x160(%rbp), %rax
movq %rax, 0x18(%rbp)
movq 0x10(%rbp), %rax
cmpq 0x18(%rbp), %rax
jl 0x6e12d
movq $-0x1, -0x8(%rbp)
jmp 0x6eb1d
movq 0x10(%rbp), %rax
cmpq -0x158(%rbp), %rax
jl 0x6e147
movq 0x10(%rbp), %rax
movq %rax, -0x1e0(%rbp)
jmp 0x6e155
movq -0x158(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x18(%rbp), %rax
cmpq -0x160(%rbp), %rax
jg 0x6e17a
movq 0x18(%rbp), %rax
movq %rax, -0x1e8(%rbp)
jmp 0x6e188
movq -0x160(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jg 0x6e1aa
movq $-0x1, -0x8(%rbp)
jmp 0x6eb1d
jmp 0x6e1ac
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movq -0x40(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movq %rax, -0x98(%rbp)
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x12c(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x128(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x138(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x134(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x11c(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
movl %eax, -0x120(%rbp)
cmpq $0x0, -0xa0(%rbp)
jne 0x6e2bb
movq $-0x1, -0x8(%rbp)
jmp 0x6eb1d
movq -0xa0(%rbp), %rax
movq %rax, -0x170(%rbp)
movq $-0x1, -0x1b0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x1a8(%rbp)
cmpq $0x0, -0x58(%rbp)
jl 0x6e309
movq -0x58(%rbp), %rax
cmpq -0x170(%rbp), %rax
jle 0x6e327
movq $0x0, -0x58(%rbp)
movslq -0x12c(%rbp), %rax
movq %rax, -0x48(%rbp)
movslq -0x138(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x6e329
xorl %eax, %eax
cmpq $0x0, -0x58(%rbp)
movb %al, -0x1e9(%rbp)
jle 0x6e349
movq -0x48(%rbp), %rax
cmpq 0x10(%rbp), %rax
setg %al
movb %al, -0x1e9(%rbp)
movb -0x1e9(%rbp), %al
testb $0x1, %al
jne 0x6e358
jmp 0x6e3dc
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
sarl $0xe, %eax
cltq
movq %rax, -0x178(%rbp)
cmpq $0x2, -0x178(%rbp)
je 0x6e3ab
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
movslq %eax, %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x48(%rbp)
cmpq $0x3, -0x178(%rbp)
je 0x6e3d7
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
movslq %eax, %rcx
movq -0x50(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x50(%rbp)
jmp 0x6e329
cmpq $0x0, 0x28(%rbp)
je 0x6e414
movq 0x20(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x1a8(%rbp)
jmp 0x6e4d0
movq -0x198(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x6e423
jmp 0x6e442
leaq 0x3164fc(%rip), %rdi    # 0x384926
leaq 0x313eea(%rip), %rsi    # 0x38231b
movl $0x488d, %edx           # imm = 0x488D
leaq 0x3164f3(%rip), %rcx    # 0x384930
callq 0x2130
movq -0x1a0(%rbp), %rax
cmpq -0x50(%rbp), %rax
jne 0x6e451
jmp 0x6e470
leaq 0x316591(%rip), %rdi    # 0x3849e9
leaq 0x313ebc(%rip), %rsi    # 0x38231b
movl $0x488d, %edx           # imm = 0x488D
leaq 0x3164c5(%rip), %rcx    # 0x384930
callq 0x2130
movq -0x1a8(%rbp), %rax
cmpq -0x58(%rbp), %rax
jne 0x6e47f
jmp 0x6e49e
leaq 0x31656d(%rip), %rdi    # 0x3849f3
leaq 0x313e8e(%rip), %rsi    # 0x38231b
movl $0x488d, %edx           # imm = 0x488D
leaq 0x316497(%rip), %rcx    # 0x384930
callq 0x2130
movq -0x1a0(%rbp), %rax
movq 0x20(%rbp), %rcx
movl 0x14(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x1b0(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1b8(%rbp)
jmp 0x6e4d2
movq -0x58(%rbp), %rcx
xorl %eax, %eax
cmpq -0x170(%rbp), %rcx
movb %al, -0x1ea(%rbp)
jge 0x6e4f8
movq -0x48(%rbp), %rax
cmpq 0x18(%rbp), %rax
setl %al
movb %al, -0x1ea(%rbp)
movb -0x1ea(%rbp), %al
testb $0x1, %al
jne 0x6e507
jmp 0x6ea2e
movq -0x48(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
sarl $0xe, %eax
cltq
movq %rax, -0x178(%rbp)
cmpq $0x2, -0x178(%rbp)
je 0x6e555
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cltq
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x3, -0x178(%rbp)
je 0x6e57d
movq -0x90(%rbp), %rax
movq -0x58(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cltq
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x178(%rbp)
je 0x6e5ad
cmpq $0x1, -0x178(%rbp)
je 0x6e5ad
jmp 0x6e4d2
movq 0x10(%rbp), %rax
cmpq -0x180(%rbp), %rax
jl 0x6e5c7
movq 0x10(%rbp), %rax
movq %rax, -0x1f8(%rbp)
jmp 0x6e5d5
movq -0x180(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x18(%rbp), %rax
cmpq -0x188(%rbp), %rax
jg 0x6e5fa
movq 0x18(%rbp), %rax
movq %rax, -0x200(%rbp)
jmp 0x6e608
movq -0x188(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x200(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jle 0x6e62e
movq -0x68(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0x208(%rbp)
jmp 0x6e639
xorl %eax, %eax
movq %rax, -0x208(%rbp)
jmp 0x6e639
movq -0x208(%rbp), %rax
movq %rax, -0x190(%rbp)
cmpq $0x0, -0x190(%rbp)
jne 0x6e656
jmp 0x6e4d2
cmpq $0x0, 0x28(%rbp)
je 0x6e6fb
cmpq $0x1, -0x178(%rbp)
jne 0x6e6f6
movq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x6e6e3
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x7e, %eax
jg 0x6e6b1
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
movzbl (%rax,%rcx), %eax
addl $0x1, %eax
movl %eax, -0x20c(%rbp)
jmp 0x6e6be
movl $0x7f, %eax
movl %eax, -0x20c(%rbp)
jmp 0x6e6be
movl -0x20c(%rbp), %eax
movb %al, %dl
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x6e677
movq -0x68(%rbp), %rax
subq -0x48(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x1b0(%rbp)
jmp 0x6ea29
cmpq $0x0, -0x178(%rbp)
jne 0x6e7d7
movq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x6e7d2
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x6e7bf
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x3, %edx
cmovel %ecx, %eax
movb %al, -0x1d1(%rbp)
movq -0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x1bc(%rbp)
movq 0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1cc(%rbp)
movq -0x70(%rbp), %rax
movl %eax, -0x1d0(%rbp)
movq -0x70(%rbp), %rax
subq -0x48(%rbp), %rax
addq -0x50(%rbp), %rax
movl %eax, -0x1c8(%rbp)
movzbl -0x1d1(%rbp), %eax
shll %eax
movb %al, -0x1c4(%rbp)
movl $0x1, -0x1c0(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xa0e90
jmp 0x6e7c1
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x6e711
jmp 0x6ea27
cmpq $0x1, -0x178(%rbp)
jne 0x6ea25
movq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jge 0x6ea23
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x6ea10
cmpq $0x0, -0x168(%rbp)
jne 0x6e900
movq -0x70(%rbp), %rax
subq -0x48(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq 0x40(%rbp), %rcx
movq -0x1a0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x1a0(%rbp)
cmpq $0x0, -0x1a0(%rbp)
jge 0x6e85c
movq $0x0, -0x1a0(%rbp)
jmp 0x6e85e
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x1b0(%rbp), %rcx
subq -0x1a0(%rbp), %rcx
cmpq %rcx, %rax
jge 0x6e8b7
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x1b0(%rbp), %rsi
subq -0x1a0(%rbp), %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x1b0(%rbp), %rcx
subq -0x1a0(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x6e8b9
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
subq -0x1a0(%rbp), %rdx
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x18(%rbp), %r8
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, %r9d
movzbl %al, %ecx
callq 0x9a30
movq 0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
subq 0x10(%rbp), %rcx
movzbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x3, %edx
cmovel %ecx, %eax
movb %al, -0x1d1(%rbp)
cmpb $0x0, -0x1d1(%rbp)
jne 0x6e994
cmpq $0x0, 0x40(%rbp)
je 0x6e994
movq -0x168(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
subq -0x1a0(%rbp), %rsi
movq -0x70(%rbp), %rdx
subq -0x48(%rbp), %rdx
addq -0x50(%rbp), %rdx
subq -0x1a0(%rbp), %rdx
movq 0x40(%rbp), %rcx
movl $0x4, %r8d
xorl %eax, %eax
movl %eax, %r9d
movq $-0x1, (%rsp)
movq $-0x1, 0x8(%rsp)
movq $0x2, 0x10(%rsp)
callq 0x499f0
cmpb $0x0, %al
je 0x6e994
movb $0x1, -0x1d1(%rbp)
movq -0x168(%rbp), %rax
movq -0x70(%rbp), %rcx
subq -0x48(%rbp), %rcx
addq -0x50(%rbp), %rcx
subq -0x1a0(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x1bc(%rbp)
movq 0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1cc(%rbp)
movq -0x70(%rbp), %rax
movl %eax, -0x1d0(%rbp)
movq -0x70(%rbp), %rax
subq -0x48(%rbp), %rax
addq -0x50(%rbp), %rax
movl %eax, -0x1c8(%rbp)
movzbl -0x1d1(%rbp), %eax
shll %eax
addl $0x1, %eax
movb %al, -0x1c4(%rbp)
movl $0x1, -0x1c0(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xa0e90
jmp 0x6ea12
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x6e7ed
jmp 0x6ea25
jmp 0x6ea27
jmp 0x6ea29
jmp 0x6e4d2
cmpq $0x0, 0x28(%rbp)
je 0x6eae3
movq -0x198(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x1a0(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x1a8(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
cmpq $-0x1, -0x1b0(%rbp)
je 0x6ead6
movq 0x40(%rbp), %rax
addq -0x1b0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b0(%rbp), %rax
cmpq -0x1b8(%rbp), %rax
jle 0x6eabd
movq -0x1b8(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
subq -0x1a0(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x6eae1
movq 0x20(%rbp), %rax
movl $0x0, 0x14(%rax)
jmp 0x6eb15
movq -0x48(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x58(%rbp), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq 0x20(%rbp), %rax
movl $0x0, 0x14(%rax)
movq $0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw (%rax,%rax)