// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/realn.c
// Function: sam_prob_realn
int sam_prob_realn(bam1_t *b, const char *ref, hts_pos_t ref_len, int flag) {
    int k, bw, y, yb, ye, xb, xe, fix_bq = 0, apply_baq = flag & BAQ_APPLY,
        extend_baq = flag & BAQ_EXTEND, redo_baq = flag & BAQ_REDO;
    enum htsRealnFlags system = flag & (0xff << 3);
    hts_pos_t i, x;
    uint32_t *cigar = bam_get_cigar(b);
    bam1_core_t *c = &b->core;

    // d(I) e(M) band
    probaln_par_t conf = { 0.001, 0.1, 10 }; // Illumina

    if (b->core.l_qseq > 1000 || system > BAQ_ILLUMINA) {
        // Params that work well on PacBio CCS 15k.  Unknown if they
        // help other long-read platforms yet, but likely better than
        // the short-read tuned ones.
        //
        // This function has no access to the SAM header.
        // Ideally the calling function would check for e.g.
        // @RG PL = "PACBIO" and DS contains "READTYPE=CCS".
        //
        // In the absense of this, we simply auto-detect via a crude
        // short vs long strategy.
        conf.d = 1e-7;
        conf.e = 1e-1;
    }

    uint8_t *bq = NULL, *zq = NULL, *qual = bam_get_qual(b);
    int *state = NULL;
    if ((c->flag & BAM_FUNMAP) || b->core.l_qseq == 0 || qual[0] == (uint8_t)-1)
        return -1; // do nothing

    // test if BQ or ZQ is present, and make sanity checks
    if ((bq = bam_aux_get(b, "BQ")) != NULL) {
        if (!redo_baq) {
            if (realn_check_tag(bq, HTS_LOG_WARNING, "BQ", b) < 0)
                fix_bq = 1;
        }
        ++bq;
    }
    if ((zq = bam_aux_get(b, "ZQ")) != NULL) {
        if (realn_check_tag(zq, HTS_LOG_ERROR, "ZQ", b) < 0)
            return -4;
        ++zq;
    }
    if (bq && redo_baq)
    {
        bam_aux_del(b, bq-1);
        bq = 0;
    }
    if (bq && zq) { // remove the ZQ tag
        bam_aux_del(b, zq-1);
        zq = 0;
    }
    if (!zq && fix_bq) { // Need to fix invalid BQ tag (by realigning)
        assert(bq != NULL);
        bam_aux_del(b, bq-1);
        bq = 0;
    }

    if (bq || zq) {
        if ((apply_baq && zq) || (!apply_baq && bq)) return -3; // in both cases, do nothing
        if (bq && apply_baq) { // then convert BQ to ZQ
            for (i = 0; i < c->l_qseq; ++i)
                qual[i] = qual[i] + 64 < bq[i]? 0 : qual[i] - ((int)bq[i] - 64);
            *(bq - 3) = 'Z';
        } else if (zq && !apply_baq) { // then convert ZQ to BQ
            for (i = 0; i < c->l_qseq; ++i)
                qual[i] += (int)zq[i] - 64;
            *(zq - 3) = 'B';
        }
        return 0;
    }
    // find the start and end of the alignment
    x = c->pos, y = 0, yb = ye = xb = xe = -1;
    for (k = 0; k < c->n_cigar; ++k) {
        int op, l;
        op = cigar[k]&0xf; l = cigar[k]>>4;
        if (op == BAM_CMATCH || op == BAM_CEQUAL || op == BAM_CDIFF) {
            if (yb < 0) yb = y;
            if (xb < 0) xb = x;
            ye = y + l; xe = x + l;
            x += l; y += l;
        } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) y += l;
        else if (op == BAM_CDEL) x += l;
        else if (op == BAM_CREF_SKIP) return -1; // do nothing if there is a reference skip
    }
    if (xb == -1) // No matches in CIGAR.
        return -1;
    // set bandwidth and the start and the end
    bw = 7;
    if (abs((xe - xb) - (ye - yb)) > bw)
        bw = abs((xe - xb) - (ye - yb)) + 3;
    conf.bw = bw;

    xb -= yb + bw/2; if (xb < 0) xb = 0;
    xe += c->l_qseq - ye + bw/2;
    if (xe - xb - c->l_qseq > bw)
        xb += (xe - xb - c->l_qseq - bw) / 2, xe -= (xe - xb - c->l_qseq - bw) / 2;
    { // glocal
        uint8_t *seq = bam_get_seq(b);
        uint8_t *tseq; // translated seq A=>0,C=>1,G=>2,T=>3,other=>4
        uint8_t *tref; // translated ref
        uint8_t *q; // Probability of incorrect alignment from probaln_glocal()
        size_t lref = xe > xb ? xe - xb : 1;
        size_t align_lqseq;
        if (extend_baq && lref < c->l_qseq)
            lref = c->l_qseq; // So we can recycle tseq,tref for left,rght below
        // Try to make q,tref,tseq reasonably well aligned
        align_lqseq = ((c->l_qseq + 1) | 0xf) + 1;
        // Overflow check - 3 for *bq, sizeof(int) for *state
        if ((SIZE_MAX - lref) / (3 + sizeof(int)) < align_lqseq) {
            errno = ENOMEM;
            goto fail;
        }

        assert(bq == NULL); // bq was used above, but should now be NULL
        bq = malloc(align_lqseq * 3 + lref);
        if (!bq) goto fail;
        q = bq + align_lqseq;
        tseq = q + align_lqseq;
        tref = tseq + align_lqseq;

        memcpy(bq, qual, c->l_qseq); bq[c->l_qseq] = 0;
        for (i = 0; i < c->l_qseq; ++i)
            tseq[i] = seq_nt16_int[bam_seqi(seq, i)];
        for (i = xb; i < xe; ++i) {
            if (i >= ref_len || ref[i] == '\0') { xe = i; break; }
            tref[i-xb] = seq_nt16_int[seq_nt16_table[(unsigned char)ref[i]]];
        }

        state = malloc(c->l_qseq * sizeof(int));
        if (!state) goto fail;
        if (probaln_glocal(tref, xe-xb, tseq, c->l_qseq, qual,
                           &conf, state, q) == INT_MIN) {
            goto fail;
        }

        if (!extend_baq) { // in this block, bq[] is capped by base quality qual[]
            for (k = 0, x = c->pos, y = 0; k < c->n_cigar; ++k) {
                int op = cigar[k]&0xf, l = cigar[k]>>4;
                if (l == 0) continue;
                if (op == BAM_CMATCH || op == BAM_CEQUAL || op == BAM_CDIFF) {
                    // Sanity check running off the end of the sequence
                    // Can only happen if the alignment is broken
                    if (l > c->l_qseq - y)
                        l = c->l_qseq - y;
                    for (i = y; i < y + l; ++i) {
                        if ((state[i]&3) != 0 || state[i]>>2 != x - xb + (i - y)) bq[i] = 0;
                        else bq[i] = bq[i] < q[i]? bq[i] : q[i];
                    }
                    x += l; y += l;
                } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) {
                    // Need sanity check here too.
                    if (l > c->l_qseq - y)
                        l = c->l_qseq - y;
                    y += l;
                } else if (op == BAM_CDEL) {
                    x += l;
                }
            }
            for (i = 0; i < c->l_qseq; ++i) bq[i] = qual[i] - bq[i] + 64; // finalize BQ
        } else { // in this block, bq[] is BAQ that can be larger than qual[] (different from the above!)
            // tseq,tref are no longer needed, so we can steal them to avoid mallocs
            uint8_t *left = tseq;
            uint8_t *rght = tref;
            int len = 0;

            for (k = 0, x = c->pos, y = 0; k < c->n_cigar; ++k) {
                int op = cigar[k]&0xf, l = cigar[k]>>4;

                // concatenate alignment matches (including sequence (mis)matches)
                // otherwise 50M50M gives a different result to 100M
                if (op == BAM_CMATCH || op == BAM_CEQUAL || op == BAM_CDIFF) {
                    if ((k + 1) < c->n_cigar) {
                        int next_op = bam_cigar_op(cigar[k + 1]);

                        if (next_op == BAM_CMATCH || next_op == BAM_CEQUAL || next_op == BAM_CDIFF) {
                            len += l;
                            continue;
                        }
                    }

                    // last of M/X/= ops
                    l += len;
                    len = 0;
                }

                if (l == 0) continue;
                if (op == BAM_CMATCH || op == BAM_CEQUAL || op == BAM_CDIFF) {
                    // Sanity check running off the end of the sequence
                    // Can only happen if the alignment is broken
                    if (l > c->l_qseq - y)
                        l = c->l_qseq - y;
                    for (i = y; i < y + l; ++i)
                        bq[i] = ((state[i]&3) != 0 || state[i]>>2 != x - xb + (i - y))? 0 : q[i];
                    for (left[y] = bq[y], i = y + 1; i < y + l; ++i)
                        left[i] = bq[i] > left[i-1]? bq[i] : left[i-1];
                    for (rght[y+l-1] = bq[y+l-1], i = y + l - 2; i >= y; --i)
                        rght[i] = bq[i] > rght[i+1]? bq[i] : rght[i+1];
                    for (i = y; i < y + l; ++i)
                        bq[i] = left[i] < rght[i]? left[i] : rght[i];
                    x += l; y += l;
                } else if (op == BAM_CSOFT_CLIP || op == BAM_CINS) {
                    // Need sanity check here too.
                    if (l > c->l_qseq - y)
                        l = c->l_qseq - y;
                    y += l;
                } else if (op == BAM_CDEL) {
                    x += l;
                }
            }
            for (i = 0; i < c->l_qseq; ++i) bq[i] = 64 + (qual[i] <= bq[i]? 0 : qual[i] - bq[i]); // finalize BQ
        }
        if (apply_baq) {
            for (i = 0; i < c->l_qseq; ++i) qual[i] -= bq[i] - 64; // modify qual
            bam_aux_append(b, "ZQ", 'Z', c->l_qseq + 1, bq);
        } else bam_aux_append(b, "BQ", 'Z', c->l_qseq + 1, bq);
        free(bq); free(state);
    }

    return 0;

 fail:
    free(bq); free(state);
    return -4;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %ecx, %ebp
movq %rdx, %r15
movq %rdi, %rbx
movl %ecx, %edx
andl $0x7f8, %edx            # imm = 0x7F8
movq 0x38(%rdi), %rdi
movzwl 0x12(%rbx), %ecx
movabsq $0x3dcccccd3a83126f, %rax # imm = 0x3DCCCCCD3A83126F
movq %rax, 0x58(%rsp)
movl $0xa, 0x60(%rsp)
movl 0x18(%rbx), %eax
cmpl $0x3e9, %eax            # imm = 0x3E9
setl %r8b
cmpl $0x9, %edx
setb %dl
testb %r8b, %dl
jne 0x19e11
movsd 0x787d5(%rip), %xmm0    # 0x925e0
movsd %xmm0, 0x58(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x1a45b
movzwl 0x10(%rbx), %edx
andl $0x4, %edx
jne 0x1a45b
addq %rcx, %rdi
movl 0x14(%rbx), %ecx
shll $0x2, %ecx
addq %rdi, %rcx
incl %eax
sarl %eax
cltq
addq %rcx, %rax
movq %rax, 0x8(%rsp)
cmpb $-0x1, (%rax)
je 0x1a45b
movq %rsi, 0x18(%rsp)
movq %rdi, 0x70(%rsp)
leaq 0x78790(%rip), %rsi     # 0x925f0
movq %rbx, %rdi
callq 0x25011
testq %rax, %rax
movq %r15, 0x38(%rsp)
je 0x19e9c
movq %rax, %r12
movl %ebp, %r14d
testb $0x4, %bpl
jne 0x19ea6
leaq 0x7876b(%rip), %rdx     # 0x925f0
movq %r12, %rdi
movl $0x3, %esi
movq %rbx, %rcx
callq 0x1a7b9
movl %eax, %ebp
shrl $0x1f, %ebp
jmp 0x19ea8
movl %ebp, %r14d
xorl %r12d, %r12d
xorl %ebp, %ebp
jmp 0x19eab
xorl %ebp, %ebp
incq %r12
leaq 0x78741(%rip), %rsi     # 0x925f3
movq %rbx, %rdi
callq 0x25011
testq %rax, %rax
je 0x19ee6
movq %rax, %r15
leaq 0x7872a(%rip), %rdx     # 0x925f3
movq %rax, %rdi
movl $0x1, %esi
movq %rbx, %rcx
callq 0x1a7b9
testl %eax, %eax
js 0x1a455
incq %r15
jmp 0x19ee9
xorl %r15d, %r15d
testq %r12, %r12
setne %al
movl %r14d, %ecx
shrb $0x2, %cl
testb %al, %cl
je 0x19f17
decq %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x27175
testq %r15, %r15
sete %al
testb %al, %bpl
je 0x19f62
jmp 0x1a79a
testq %r12, %r12
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x19f3b
decq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27175
xorl %r15d, %r15d
testq %r15, %r15
sete %al
testb %al, %bpl
je 0x19f65
testq %r12, %r12
je 0x1a79a
decq %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x27175
movb $0x1, %al
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r15, %rcx
orq %r12, %rcx
je 0x19ffb
testq %r15, %r15
setne %sil
testq %r12, %r12
setne %cl
testb $0x1, %r14b
sete %dl
movl $0xfffffffd, %r13d      # imm = 0xFFFFFFFD
testb %sil, %r14b
jne 0x1a45b
andb %cl, %dl
jne 0x1a45b
testb $0x1, %r14b
sete %cl
testq %r12, %r12
sete %dl
orb %cl, %dl
jne 0x1a18b
cmpl $0x0, 0x18(%rbx)
movq 0x8(%rsp), %r8
jle 0x19fed
xorl %eax, %eax
xorl %ecx, %ecx
movzbl (%r8,%rcx), %edx
movl %edx, %esi
addl $0x40, %esi
movzbl (%r12,%rcx), %edi
subb %dil, %dl
addb $0x40, %dl
cmpl %edi, %esi
movzbl %dl, %edx
cmovbl %eax, %edx
movb %dl, (%r8,%rcx)
incq %rcx
movslq 0x18(%rbx), %rdx
cmpq %rdx, %rcx
jl 0x19fc0
movb $0x5a, -0x3(%r12)
xorl %r13d, %r13d
jmp 0x1a45b
movl 0x14(%rbx), %r15d
testq %r15, %r15
je 0x1a45b
movl %r14d, 0x4(%rsp)
movq (%rbx), %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
leaq 0x7859d(%rip), %r9      # 0x925bc
xorl %r10d, %r10d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x70(%rsp), %r14
movl (%r14,%r8,4), %ebp
movl %ebp, %r12d
andl $0xf, %r12d
movl %ebp, %r11d
shrl $0x4, %r11d
cmpl $0x7, %r12d
setne %r13b
testb $0x7, %bpl
setne %bpl
testb %r13b, %bpl
jne 0x1a078
testl %ecx, %ecx
cmovsl %r10d, %ecx
testl %edx, %edx
cmovsl %edi, %edx
movl %r11d, %esi
addl %r10d, %esi
addq %r11, %rdi
movl %edi, %eax
movl %esi, %r10d
jmp 0x1a099
decl %r12d
cmpl $0x3, %r12d
ja 0x1a099
movslq (%r9,%r12,4), %r12
addq %r9, %r12
jmpq *%r12
addl %r10d, %r11d
movl %r11d, %r10d
jmp 0x1a099
movl %r11d, %r11d
addq %r11, %rdi
incq %r8
cmpq %r8, %r15
jne 0x1a036
cmpl $-0x1, %edx
je 0x1a180
movl %eax, %r8d
subl %edx, %r8d
subl %esi, %r8d
addl %ecx, %r8d
movl %r8d, %edi
negl %edi
cmovsl %r8d, %edi
leal 0x3(%rdi), %r8d
cmpl $0x8, %edi
movl $0x7, %edi
cmovael %r8d, %edi
movl %edi, %r8d
shrl %r8d
addl %r8d, %ecx
subl %ecx, %edx
xorl %r9d, %r9d
testl %edx, %edx
cmovgl %edx, %r9d
movl %edi, 0x60(%rsp)
movslq 0x18(%rbx), %r13
subl %esi, %eax
addl %r8d, %eax
leal (%rax,%r13), %r10d
movl %eax, %ecx
subl %r9d, %ecx
subl %edi, %ecx
jle 0x1a11a
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
addl %edx, %r9d
addl %r9d, %edi
subl %edi, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
subl %ecx, %r10d
movl %r10d, %eax
subl %r9d, %eax
movl $0x1, %ecx
cmovgl %eax, %ecx
cmpl %r13d, %ecx
movl %r13d, %eax
cmoval %ecx, %eax
testb $0x2, 0x4(%rsp)
cmovel %ecx, %eax
movslq %eax, %rsi
leaq 0x1(%r13), %r8
orq $0xf, %r8
leaq 0x1(%r8), %rbp
movq %rsi, %rcx
notq %rcx
movabsq $0x2492492492492493, %rdx # imm = 0x2492492492492493
movq %rcx, %rax
mulq %rdx
subq %rdx, %rcx
shrq %rcx
addq %rdx, %rcx
shrq $0x2, %rcx
cmpq %rbp, %rcx
jae 0x1a1cb
callq 0x4050
movl $0xc, (%rax)
jmp 0x1a439
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x1a45b
orb %al, %r14b
xorl %r13d, %r13d
testb $0x1, %r14b
movq 0x8(%rsp), %rdx
jne 0x1a45b
cmpl $0x0, 0x18(%rbx)
jle 0x1a1c1
xorl %eax, %eax
movb (%r15,%rax), %cl
addb (%rdx,%rax), %cl
addb $-0x40, %cl
movb %cl, (%rdx,%rax)
incq %rax
movslq 0x18(%rbx), %rcx
cmpq %rcx, %rax
jl 0x1a1a8
movb $0x42, -0x3(%r15)
jmp 0x1a45b
movl %r10d, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movl %r9d, 0x20(%rsp)
shll $0x2, %r15d
addq 0x38(%rbx), %r15
movzwl 0x12(%rbx), %eax
movq %rax, 0x10(%rsp)
leaq (,%rbp,2), %rdi
addq %rbp, %rdi
addq %rsi, %rdi
callq 0x4680
testq %rax, %rax
je 0x1a439
movq %rax, %r12
addq %rbp, %rax
movq %rax, 0x50(%rsp)
movq %rbp, 0x30(%rsp)
addq %rax, %rbp
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x43c0
movq %r12, 0x28(%rsp)
movb $0x0, (%r12,%r13)
testl %r13d, %r13d
jle 0x1a272
addq 0x10(%rsp), %r15
xorl %eax, %eax
leaq 0x76dd9(%rip), %rdx     # 0x91020
xorl %esi, %esi
movq %rsi, %rcx
shrq %rcx
movzbl (%r15,%rcx), %edi
movl %eax, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %edi
andl $0xf, %edi
movb (%rdx,%rdi,4), %cl
movb %cl, (%rbp,%rsi)
incq %rsi
addl $0x4, %eax
cmpq %rsi, %r13
jne 0x1a249
movq 0x30(%rsp), %rsi
addq %rbp, %rsi
movl 0x20(%rsp), %eax
movslq %eax, %r12
movl 0x48(%rsp), %r10d
cmpl %eax, %r10d
movq 0x18(%rsp), %r9
movq %r12, 0x10(%rsp)
movq %rsi, 0x30(%rsp)
jle 0x1a2d5
movslq %r10d, %rax
leaq 0x76c5c(%rip), %rcx     # 0x90f00
leaq 0x76d75(%rip), %rdx     # 0x91020
movq 0x38(%rsp), %r8
cmpq %r8, %r12
jge 0x1a2d8
movzbl (%r9,%r12), %edi
testq %rdi, %rdi
je 0x1a2d8
movzbl (%rcx,%rdi), %edi
movb (%rdx,%rdi,4), %dil
movb %dil, (%rsi)
incq %r12
incq %rsi
cmpq %r12, %rax
jne 0x1a2b0
movl %r10d, %r12d
leaq (,%r13,4), %rdi
callq 0x4680
testq %rax, %rax
je 0x1a440
movq %rax, %r15
subl 0x20(%rsp), %r12d
leaq 0x58(%rsp), %r9
movq 0x30(%rsp), %rdi
movl %r12d, %esi
movq %rbp, %rdx
movl %r13d, %ecx
movq 0x8(%rsp), %r8
pushq 0x50(%rsp)
pushq %rax
callq 0x87618
addq $0x10, %rsp
negl %eax
jo 0x1a443
movq %rbp, 0x20(%rsp)
movl 0x14(%rbx), %r12d
movl 0x4(%rsp), %ebp
testb $0x2, %bpl
movq 0x28(%rsp), %r13
jne 0x1a46d
testq %r12, %r12
je 0x1a700
movq (%rbx), %rcx
negq 0x10(%rsp)
xorl %edx, %edx
xorl %edi, %edi
movl (%r14,%rdx,4), %r8d
cmpl $0x10, %r8d
jae 0x1a366
movl %edi, %esi
jmp 0x1a41e
movl %r8d, %esi
andl $0xf, %esi
movl %r8d, %r9d
shrl $0x4, %r9d
cmpl $0x7, %esi
setne %r10b
testb $0x7, %r8b
setne %r8b
testb %r10b, %r8b
jne 0x1a3fd
movl 0x18(%rbx), %r8d
subl %edi, %r8d
cmpl %r8d, %r9d
cmovll %r9d, %r8d
leal (%r8,%rdi), %esi
testl %r8d, %r8d
jle 0x1a3f5
movslq %esi, %r9
movslq %edi, %rdi
movq 0x10(%rsp), %rax
leaq (%rax,%rcx), %r10
movl (%r15,%rdi,4), %r11d
testb $0x3, %r11b
jne 0x1a3e4
sarl $0x2, %r11d
movslq %r11d, %r11
cmpq %r11, %r10
jne 0x1a3e4
movzbl (%r13,%rdi), %r11d
movq 0x50(%rsp), %rax
movzbl (%rax,%rdi), %ebp
cmpb %bpl, %r11b
cmovbl %r11d, %ebp
movb %bpl, (%r13,%rdi)
movl 0x4(%rsp), %ebp
jmp 0x1a3ea
movb $0x0, (%r13,%rdi)
incq %rdi
incq %r10
cmpq %r9, %rdi
jl 0x1a3ad
movslq %r8d, %rdi
addq %rdi, %rcx
jmp 0x1a41e
cmpl $0x4, %esi
je 0x1a410
cmpl $0x2, %esi
je 0x1a431
cmpl $0x1, %esi
jne 0x1a35f
movl 0x18(%rbx), %esi
subl %edi, %esi
cmpl %esi, %r9d
cmovll %r9d, %esi
addl %edi, %esi
incq %rdx
movl %esi, %edi
cmpq %r12, %rdx
jne 0x1a355
jmp 0x1a700
addq %r9, %rcx
jmp 0x1a35f
xorl %r15d, %r15d
xorl %edi, %edi
jmp 0x1a448
xorl %r15d, %r15d
movq 0x28(%rsp), %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
movl $0xfffffffc, %r13d      # imm = 0xFFFFFFFC
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x1a6bb
movq (%rbx), %rax
movslq 0x40(%rsp), %rcx
leaq 0x1(,%rcx,2), %rdx
addq %r13, %rdx
movq %rdx, 0x68(%rsp)
leaq (%rcx,%rcx,2), %rdx
leaq (%rdx,%r13), %rsi
addq $0x4, %rsi
movq %rsi, 0x40(%rsp)
negq 0x10(%rsp)
leaq 0x2(,%rcx,2), %rdi
addq %r13, %rdi
leaq (%rdx,%r13), %r8
addq $0x3, %r8
xorl %r9d, %r9d
movl $0x0, 0x18(%rsp)
xorl %r11d, %r11d
movq %r12, 0x48(%rsp)
movl (%r14,%r9,4), %esi
movl %esi, %ecx
andl $0xf, %ecx
movl %esi, %edx
shrl $0x4, %edx
cmpl $0x7, %ecx
setne %r10b
testb $0x7, %sil
setne %bpl
testb %r10b, %bpl
jne 0x1a521
leaq 0x1(%r9), %rcx
cmpq %r12, %rcx
jae 0x1a554
movl 0x4(%r14,%r9,4), %ecx
movl %ecx, %esi
andl $0xf, %esi
cmpl $0x7, %esi
sete %sil
testb $0x7, %cl
sete %cl
addl 0x18(%rsp), %edx
orb %sil, %cl
je 0x1a558
movl %r11d, %ebp
movl %edx, 0x18(%rsp)
jmp 0x1a6ac
cmpl $0x10, %esi
jb 0x1a6a9
cmpl $0x4, %ecx
je 0x1a541
cmpl $0x2, %ecx
je 0x1a6a6
cmpl $0x1, %ecx
jne 0x1a6a9
movl 0x18(%rbx), %ebp
subl %r11d, %ebp
cmpl %ebp, %edx
cmovll %edx, %ebp
addl %r11d, %ebp
jmp 0x1a6ac
addl 0x18(%rsp), %edx
movl $0x0, 0x18(%rsp)
testl %edx, %edx
je 0x1a6a9
movq %rax, 0x38(%rsp)
movl 0x18(%rbx), %r12d
subl %r11d, %r12d
cmpl %r12d, %edx
cmovll %edx, %r12d
movslq %r11d, %rcx
leal (%r12,%r11), %ebp
movslq %ebp, %rdx
testl %r12d, %r12d
jle 0x1a61c
movq 0x10(%rsp), %rax
movq 0x38(%rsp), %rsi
addq %rax, %rsi
movq %rcx, %r13
movl (%r15,%r13,4), %r10d
testb $0x3, %r10b
jne 0x1a5bf
sarl $0x2, %r10d
movslq %r10d, %r10
cmpq %r10, %rsi
jne 0x1a5bf
movq 0x50(%rsp), %rax
movb (%rax,%r13), %r10b
jmp 0x1a5c2
xorl %r10d, %r10d
movq 0x28(%rsp), %rax
movb %r10b, (%rax,%r13)
incq %r13
incq %rsi
cmpq %rdx, %r13
jl 0x1a59e
movq 0x28(%rsp), %rax
movb (%rax,%rcx), %sil
movq 0x20(%rsp), %r10
movb %sil, (%r10,%rcx)
cmpl $0x1, %r12d
je 0x1a62d
leal 0x1(%r11), %esi
movslq %esi, %rsi
movq 0x68(%rsp), %r10
movb (%r10,%rsi), %r13b
movzbl (%rax,%rsi), %r10d
movzbl %r13b, %r13d
cmpb %r13b, %r10b
cmoval %r10d, %r13d
movb %r13b, (%rdi,%rsi)
incq %rsi
cmpq %rdx, %rsi
jl 0x1a5fe
jmp 0x1a62d
movb (%r13,%rcx), %sil
movq 0x20(%rsp), %rax
movb %sil, (%rax,%rcx)
movq %r13, %rax
movb -0x1(%rax,%rdx), %sil
movq 0x30(%rsp), %r10
movb %sil, -0x1(%r10,%rdx)
leaq -0x2(%rdx), %rsi
cmpl %r11d, %esi
movq %rax, %r13
jl 0x1a672
movq 0x40(%rsp), %rax
movb (%rax,%rsi), %r11b
incq %rsi
movzbl -0x1(%r13,%rsi), %r10d
movzbl %r11b, %r11d
cmpb %r11b, %r10b
cmoval %r10d, %r11d
movb %r11b, -0x1(%r8,%rsi)
decq %rsi
cmpq %rcx, %rsi
jg 0x1a654
testl %r12d, %r12d
movq 0x38(%rsp), %rax
jle 0x1a699
movzbl (%rdi,%rcx), %esi
movzbl (%r8,%rcx), %r10d
cmpb %r10b, %sil
cmovbl %esi, %r10d
movb %r10b, (%r13,%rcx)
incq %rcx
cmpq %rdx, %rcx
jl 0x1a67c
movslq %r12d, %rcx
addq %rcx, %rax
movq 0x48(%rsp), %r12
jmp 0x1a6ac
addq %rdx, %rax
movl %r11d, %ebp
incq %r9
movl %ebp, %r11d
cmpq %r12, %r9
jne 0x1a4ca
movslq 0x18(%rbx), %rcx
testq %rcx, %rcx
jle 0x1a72b
xorl %eax, %eax
movl $0x40, %edx
movq 0x8(%rsp), %r9
movl 0x4(%rsp), %ebp
movb (%r9,%rax), %sil
movb (%r13,%rax), %dil
movl %esi, %r8d
subb %dil, %r8b
addb $0x40, %r8b
cmpb %dil, %sil
movzbl %r8b, %esi
cmovbel %edx, %esi
movb %sil, (%r13,%rax)
incq %rax
cmpq %rax, %rcx
jne 0x1a6d4
jmp 0x1a73b
movslq 0x18(%rbx), %rcx
testq %rcx, %rcx
jle 0x1a736
xorl %eax, %eax
movq 0x8(%rsp), %r9
movb (%r9,%rax), %dl
subb (%r13,%rax), %dl
addb $0x40, %dl
movb %dl, (%r13,%rax)
incq %rax
cmpq %rax, %rcx
jne 0x1a710
jmp 0x1a73b
movq 0x8(%rsp), %r9
movl 0x4(%rsp), %ebp
jmp 0x1a73b
movq 0x8(%rsp), %r9
testb $0x1, %bpl
jne 0x1a74a
leaq 0x77ea8(%rip), %rsi     # 0x925f0
jmp 0x1a773
testl %ecx, %ecx
jle 0x1a76c
xorl %eax, %eax
movb (%r9,%rax), %cl
subb (%r13,%rax), %cl
addb $0x40, %cl
movb %cl, (%r9,%rax)
incq %rax
movslq 0x18(%rbx), %rcx
cmpq %rcx, %rax
jl 0x1a750
leaq 0x77e80(%rip), %rsi     # 0x925f3
incl %ecx
movq %rbx, %rdi
movl $0x5a, %edx
movq %r13, %r8
callq 0x26fc1
movq %r13, %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
jmp 0x19ff3
leaq 0x77e55(%rip), %rdi     # 0x925f6
leaq 0x77e59(%rip), %rsi     # 0x92601
leaq 0x77e5a(%rip), %rcx     # 0x92609
movl $0xa0, %edx
callq 0x42f0