// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]oatk/syncmer.c
// Function: sr_read_analysis_thread
static void *sr_read_analysis_thread(void *args)
{
    p_data_t *dat = (p_data_t *) args;
    
    int len, k, w; 
    uint8_t *key;
    char *seq;
    k = dat->sr_db->s, w = dat->sr_db->k;
    assert(k > 0 && k < 32 && w > k);

    MYMALLOC(key, (w - 1) / 4 + 2);
    int r;
    for (r = 0; r < dat->n_reads; ++r) {
        sr_t sr;
        sr.sid = dat->sid[r];
        sr.sname = dat->name[r];

        seq = dat->seq[r];
        len = dat->len[r];

        kvec_t(uint8_t) hoco_s, ho_rl;
        kvec_t(uint32_t) ho_l_rl, n_nucl, m_pos;
        kvec_t(uint64_t) s_mer;
        kvec_t(uint64_t) k_mer;
    
        kv_init(hoco_s);
        kv_init(ho_rl);
        kv_init(ho_l_rl);
        kv_init(n_nucl);
        kv_init(m_pos);
        kv_init(s_mer);
        kv_init(k_mer);

        int q = w - k + 1; // buf q size
        uint64_t m, s, z, mz, shift1 = 2 * (k - 1), mask = (1ULL<<2*k) - 1, kmer[2] = {0, 0}, buf_m[q], buf_s[q];
        int i, j, l, c, neq, rl, hoco_l, buf_pos, mz_pos;

        MYBONE(buf_m, q);
        MYBONE(buf_s, q);
        mz = UINT64_MAX; // minimizer
        l = hoco_l = buf_pos = mz_pos = 0;
        for (i = 0; i < len; ++i) {
            c = seq_nt4_table[(uint8_t) seq[i]];
            m = s = UINT64_MAX;
            if ((hoco_l++ & 3) == 0) kv_push(uint8_t, hoco_s, 0);
            if (c < 4) { // not an ambiguous base
                // hoco_s.a[hoco_s.n - 1] = hoco_s.a[hoco_s.n - 1] << 2 | c;
                if (c) hoco_s.a[hoco_s.n - 1] |= c << ((((hoco_l-1)&3)^3)<<1); // 6 - ((hoco_l - 1) % 4) << 1;
                rl = 1;
#ifdef DO_HOCO_COMPRESSION    
                // hpc
                if (i + 1 < len && seq_nt4_table[(uint8_t)seq[i + 1]] == c) {
                    for (rl = 2; i + rl < len; ++rl)
                        if (seq_nt4_table[(uint8_t)seq[i + rl]] != c)
                            break;
                    i += rl - 1; // put $i at the end of the current homopolymer run
                }
#endif
                if (rl > 255)
                    kv_push(uint32_t, ho_l_rl, rl - 1);
                rl = MIN(rl, 256);
                kv_push(uint8_t, ho_rl, rl - 1);
            
                ++l;
                kmer[0] = (kmer[0] << 2 | c) & mask;           // forward k-mer
                kmer[1] = (kmer[1] >> 2) | (3ULL^c) << shift1; // reverse k-mer
                if (kmer[0] != kmer[1]) { // skip "symmetric k-mers" as we don't know it strand
                    z = kmer[0] < kmer[1]? 0 : 1; // strand
                    if (l >= k) {
                        m = hash64(kmer[z], mask);
                        s = kmer[z] << 1 | z;
                    }
                }
            } else {
                // ambiguous bases are converted to base 'A'
                // ambiguous bases are not homopolymer compressed
                // hoco_s.a[hoco_s.n - 1] <<= 2;
                kv_push(uint8_t, ho_rl, 0);
                kv_push(uint32_t, n_nucl, i);
                l = 0;
            }

            if (buf_pos == mz_pos && mz != UINT64_MAX && l > w) {
                // open syncmer
                z = buf_s[buf_pos] & 1;
                kv_push(uint64_t, s_mer, buf_s[buf_pos]);
                kv_push(uint32_t, m_pos, (hoco_l - w - 1) << 1 | z);
#ifdef DEBUG_KMER_EXTRACTION
                kv_push(uint64_t, k_mer, kmer_hash64(sr.sid, hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#else
                kv_push(uint64_t, k_mer, kmer_hash64(hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#endif
                // remove syncmers at the same position on a read
                // this is possible as a syncmer could start and end with the same smer
                if (m_pos.n >= 2 && m_pos.a[m_pos.n-1] >> 1 == m_pos.a[m_pos.n-2] >> 1) s_mer.n -= 2, m_pos.n -= 2, k_mer.n -= 2;
            }
            
            buf_m[buf_pos] = m;
            buf_s[buf_pos] = s;
            if (m <= mz && m != UINT64_MAX) {
                if (l >= w) {
                    // close syncmer
                    z = s & 1;
                    kv_push(uint64_t, s_mer, s^1);
                    kv_push(uint32_t, m_pos, (hoco_l - w) << 1 | z);
#ifdef DEBUG_KMER_EXTRACTION
                    kv_push(uint64_t, k_mer, kmer_hash64(sr.sid, hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#else
                    kv_push(uint64_t, k_mer, kmer_hash64(hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#endif
                }
                if (m < mz) mz = m, mz_pos = buf_pos;
            }
            if (m >= mz && buf_pos == mz_pos) {
                // m has been processed in the last 'if' statement if m == mz
                neq = m != mz;
                // update minimizer
                // find the first for identical minimizers
                for (j = buf_pos + 1, mz = UINT64_MAX; j < q; ++j)
                    if (mz > buf_m[j]) mz = buf_m[j], mz_pos = j;
                for (j = 0; j <= buf_pos; ++j)
                    if (mz > buf_m[j]) mz = buf_m[j], mz_pos = j;
                if (neq && ((mz_pos == q_next(buf_pos, q) && mz == m) || mz_pos == buf_pos) && mz != UINT64_MAX && l >= w) {
                    // newly added S-mer is a minimizer
                    // close syncmer
                    z = s & 1;
                    kv_push(uint64_t, s_mer, s^1);
                    kv_push(uint32_t, m_pos, (hoco_l - w) << 1 | z);
#ifdef DEBUG_KMER_EXTRACTION
                    kv_push(uint64_t, k_mer, kmer_hash64(sr.sid, hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#else
                    kv_push(uint64_t, k_mer, kmer_hash64(hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#endif
                }
            }
            
            buf_pos = q_next(buf_pos, q);
        }

        // for the last open mer
        if (buf_pos == mz_pos && mz != UINT64_MAX && l >= w) { // not (l > w) as l no self increment yet
            // open syncmer
            z = buf_s[buf_pos] & 1;
            kv_push(uint64_t, s_mer, buf_s[buf_pos]);
            kv_push(uint32_t, m_pos, (hoco_l - w) << 1 | z); // not (hoco_l - w - 1) as hoco_l no self increment yet
#ifdef DEBUG_KMER_EXTRACTION
            kv_push(uint64_t, k_mer, kmer_hash64(sr.sid, hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#else
            kv_push(uint64_t, k_mer, kmer_hash64(hoco_s.a, m_pos.a[m_pos.n-1], w, key));
#endif
            if (m_pos.n >= 2 && m_pos.a[m_pos.n-1] >> 1 == m_pos.a[m_pos.n-2] >> 1) s_mer.n -= 2, m_pos.n -= 2, k_mer.n -= 2;
        }
    
        if (hoco_s.n) MYREALLOC(hoco_s.a, hoco_s.n);
        if (ho_rl.n) MYREALLOC(ho_rl.a, ho_rl.n);
        if (ho_l_rl.n) MYREALLOC(ho_l_rl.a, ho_l_rl.n);
        if (n_nucl.n) MYREALLOC(n_nucl.a, n_nucl.n);
        if (m_pos.n) MYREALLOC(m_pos.a, m_pos.n);
        if (s_mer.n) MYREALLOC(s_mer.a, s_mer.n);
        if (k_mer.n) MYREALLOC(k_mer.a, k_mer.n);

        sr.hoco_l = hoco_l;
        sr.hoco_s = hoco_s.a;
        sr.ho_rl = ho_rl.a;
        sr.ho_l_rl = ho_l_rl.a;
        sr.n_nucl = n_nucl.a;
        sr.n = m_pos.n;
        sr.m_pos = m_pos.a;
        sr.s_mer = s_mer.a;
        sr.k_mer = k_mer.a;
        kv_push(sr_t, *dat->sr_db, sr);

        free(seq);
    }

    free(key);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq 0x28(%rdi), %rax
movl 0x1c(%rax), %ebx
leal -0x1(%rbx), %ecx
cmpl $0x1e, %ecx
ja 0xeaf2
movl 0x18(%rax), %r13d
cmpl %ebx, %r13d
jle 0xeaf2
movq %rdi, %r15
leal -0x1(%r13), %edi
shrl $0x2, %edi
addl $0x2, %edi
callq 0x2310
movq %rax, -0xf8(%rbp)
movl %r13d, %edx
subl %ebx, %edx
leal 0x1(%rdx), %eax
movq %rbx, -0x1a8(%rbp)
leaq (%rbx,%rbx), %rcx
pushq $-0x1
popq %rsi
shlq %cl, %rsi
addl $-0x2, %ecx
movq %rcx, -0x1b0(%rbp)
notq %rsi
movq %rsi, -0x170(%rbp)
movq %rdx, -0x180(%rbp)
movslq %edx, %r8
leaq 0x8(,%r8,8), %rcx
movq %rcx, -0x198(%rbp)
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
movq %rax, -0x190(%rbp)
xorl %r12d, %r12d
movq %r15, -0x108(%rbp)
movq %r13, -0x58(%rbp)
movq %r8, -0x98(%rbp)
movslq (%r15), %rax
cmpq %rax, %r12
jge 0xead5
movq %rsp, -0x1a0(%rbp)
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movq (%rax,%r12,8), %rax
movq %rax, -0x150(%rbp)
movq (%rcx,%r12,8), %rax
movq %rax, -0x148(%rbp)
movq 0x18(%r15), %rax
movq (%rax,%r12,8), %rax
movq %rax, -0x110(%rbp)
movq 0x20(%r15), %rax
movq %r12, -0x158(%rbp)
movslq (%rax,%r12,4), %rax
movq %rax, -0x188(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x140(%rbp)
movq %rsp, %r15
movq -0x190(%rbp), %rax
subq %rax, %r15
movq %r15, %rsp
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq %r15, %rdi
movl $0xff, %esi
movq -0x198(%rbp), %rbx
movq %rbx, %rdx
callq 0x21e0
movq %r14, -0x128(%rbp)
movq %r14, %rdi
movl $0xff, %esi
movq %rbx, %rdx
callq 0x21e0
movq -0x98(%rbp), %r8
movq $0x0, -0x160(%rbp)
movq $0x0, -0xf0(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0x120(%rbp)
movq $0x0, -0x100(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0xc8(%rbp)
pushq $-0x1
popq %r14
xorl %r9d, %r9d
movq $0x0, -0x118(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0x168(%rbp)
xorl %r10d, %r10d
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x60(%rbp)
xorl %r11d, %r11d
xorl %ebx, %ebx
movslq %r11d, %r12
cmpl -0x188(%rbp), %r10d
movq %r9, -0x48(%rbp)
jge 0xe78a
movq %r14, -0xb0(%rbp)
movslq %r10d, %r13
movq -0x110(%rbp), %rdx
movzbl (%rdx,%r13), %eax
leaq 0xc083(%rip), %rcx      # 0x19d90
movzbl (%rax,%rcx), %esi
movl %r9d, %r14d
andl $0x3, %r14d
movq %r11, -0xb8(%rbp)
movq %r12, -0xe0(%rbp)
movl %esi, -0x78(%rbp)
jne 0xdda3
movq -0xe8(%rbp), %r12
cmpq -0x168(%rbp), %r12
jne 0xdd85
leaq (%r12,%r12), %rsi
testq %r12, %r12
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq -0x60(%rbp), %rdi
movq %rsi, -0x168(%rbp)
movq %r10, -0x88(%rbp)
callq 0x2350
movl -0x78(%rbp), %esi
movq -0xb8(%rbp), %r11
movq -0x88(%rbp), %r10
movq -0x48(%rbp), %r9
movq -0x110(%rbp), %rdx
movq -0x98(%rbp), %r8
jmp 0xdd89
movq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movb $0x0, (%rax,%r12)
incq %r12
movq %r12, -0xe8(%rbp)
movq -0xe0(%rbp), %r12
cmpb $0x3, %sil
ja 0xde31
testl %esi, %esi
je 0xddd1
addl %r14d, %r14d
xorb $0x6, %r14b
movl %esi, %eax
movl %r14d, %ecx
shll %cl, %eax
movq -0x60(%rbp), %rcx
movq -0xe8(%rbp), %rsi
orb %al, -0x1(%rsi,%rcx)
movl -0x78(%rbp), %esi
leaq 0x1(%r13), %rax
movq -0x188(%rbp), %r14
cmpl %r14d, %eax
jge 0xde7a
movzbl (%rdx,%rax), %eax
leaq 0xbfa0(%rip), %rcx      # 0x19d90
cmpb %sil, (%rax,%rcx)
jne 0xde7a
leaq (%rdx,%r13), %rax
movl %r14d, %r12d
subl %r10d, %r12d
pushq $0x2
popq %rcx
leaq (%rcx,%r13), %rdx
cmpq %r14, %rdx
jge 0xe5a3
movzbl (%rax,%rcx), %edx
leaq 0xbf71(%rip), %rsi      # 0x19d90
movl -0x78(%rbp), %edi
cmpb %dil, (%rdx,%rsi)
jne 0xe5a0
incq %rcx
jmp 0xde07
cmpq -0x118(%rbp), %r9
movq %r10, -0x88(%rbp)
jne 0xdedb
leaq (%r9,%r9), %rsi
testq %r9, %r9
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq -0xa0(%rbp), %rdi
movq %rsi, -0x118(%rbp)
callq 0x2350
movq -0x48(%rbp), %r9
movq %rax, %r13
movq -0x58(%rbp), %rdi
movq -0x120(%rbp), %rax
jmp 0xdeed
pushq $0x1
popq %rax
movl %eax, %r12d
movq -0xa0(%rbp), %rdi
movl $0x100, %eax            # imm = 0x100
cmpl %eax, %r12d
cmovael %eax, %r12d
cmpq -0x118(%rbp), %r9
jne 0xdf46
leaq (%r9,%r9), %rsi
testq %r9, %r9
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, -0x118(%rbp)
movq %r10, %r14
callq 0x2350
movq -0xb8(%rbp), %r11
movq %r14, %r10
movl -0x4c(%rbp), %r14d
movq -0x48(%rbp), %r9
movq -0x98(%rbp), %r8
movq %rax, %rdi
jmp 0xdf4a
movq -0x58(%rbp), %rdi
movq -0x120(%rbp), %rax
movq -0xa0(%rbp), %r13
movb $0x0, (%r13,%r9)
cmpq %rax, -0x100(%rbp)
jne 0xe026
leaq (%rax,%rax), %r14
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r14
leaq (,%r14,4), %rsi
movq %rdi, %r12
movq -0xd0(%rbp), %rdi
callq 0x2350
movq %r12, %rdi
movq -0xe0(%rbp), %r12
movq -0x48(%rbp), %r9
movq %r14, -0x120(%rbp)
movq -0x98(%rbp), %r8
jmp 0xe034
movl -0x4c(%rbp), %r14d
decb %r12b
movq %rdi, %r13
movb %r12b, (%rdi,%r9)
incl %r14d
movl -0x78(%rbp), %edx
movq -0x140(%rbp), %rax
movq -0x138(%rbp), %rdi
leaq (%rdx,%rax,4), %rsi
andq -0x170(%rbp), %rsi
movq %rsi, -0x140(%rbp)
xorq $0x3, %rdx
movq -0x1b0(%rbp), %rcx
shlq %cl, %rdx
shrq $0x2, %rdi
orq %rdi, %rdx
movq %rdx, -0x138(%rbp)
cmpq %rdx, %rsi
je 0xe093
cmpl -0x1a8(%rbp), %r14d
movq -0xe0(%rbp), %r12
jl 0xe078
xorl %eax, %eax
cmpq %rdx, %rsi
setae %al
movq -0x140(%rbp,%rax,8), %rdx
movq %rdx, %rcx
leaq (%rax,%rdx,2), %rax
movq %rax, -0xc0(%rbp)
notq %rdx
shlq $0x15, %rcx
addq %rdx, %rcx
movq -0x170(%rbp), %rdx
andq %rdx, %rcx
movq %rcx, %rax
shrq $0x18, %rax
xorq %rcx, %rax
imulq $0x109, %rax, %rax      # imm = 0x109
andq %rdx, %rax
movq %rax, %rcx
shrq $0xe, %rcx
xorq %rax, %rcx
imulq $0x15, %rcx, %rax
andq %rdx, %rax
movq %rax, %rcx
shrq $0x1c, %rcx
xorq %rax, %rcx
movl $0x80000001, %eax       # imm = 0x80000001
imulq %rax, %rcx
andq %rdx, %rcx
movq %rcx, -0x78(%rbp)
jmp 0xe086
movq -0x98(%rbp), %r8
movq -0xd0(%rbp), %rax
movq -0x88(%rbp), %r10
movq -0xb8(%rbp), %r11
movq -0xb0(%rbp), %rsi
movq %rax, -0xd0(%rbp)
movq -0x100(%rbp), %rcx
movl %r10d, (%rax,%rcx,4)
incq %rcx
movq %rcx, -0x100(%rbp)
xorl %r14d, %r14d
pushq $-0x1
popq %rax
movq %rax, -0x78(%rbp)
movq %rax, -0xc0(%rbp)
jmp 0xe0b3
pushq $-0x1
popq %rax
movq %rax, -0x78(%rbp)
movq %rax, -0xc0(%rbp)
movq -0xb0(%rbp), %rsi
movq -0x58(%rbp), %rdi
jmp 0xe0b3
pushq $-0x1
popq %rax
movq %rax, -0x78(%rbp)
movq %rax, -0xc0(%rbp)
movq -0xb0(%rbp), %rsi
movq -0x58(%rbp), %rdi
movq -0xe0(%rbp), %r12
cmpl %ebx, %r11d
sete %al
cmpq $-0x1, %rsi
setne %cl
andb %al, %cl
cmpl %edi, %r14d
setg %al
andb %cl, %al
cmpb $0x1, %al
movq %r13, -0xa0(%rbp)
movl %r14d, -0x4c(%rbp)
jne 0xe12f
movq -0x128(%rbp), %rax
movq (%rax,%r12,8), %r14
movq -0x38(%rbp), %rdx
movq -0xd8(%rbp), %rax
cmpq %rax, %rdx
movq %r10, -0x88(%rbp)
jne 0xe137
leaq (%rax,%rax), %r13
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r13
leaq (,%r13,8), %rsi
movq -0x68(%rbp), %rdi
callq 0x2350
movq -0x38(%rbp), %rdx
movq %r13, -0xd8(%rbp)
movq -0x30(%rbp), %r8
movq -0x70(%rbp), %rcx
jmp 0xe143
movq %r10, %r11
jmp 0xe2c4
movq -0x30(%rbp), %r8
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %rax
movq -0xa8(%rbp), %rsi
movq %r14, (%rax,%rdx,8)
cmpq %rsi, %r8
movq %rax, -0x68(%rbp)
jne 0xe183
leaq (%rsi,%rsi), %r13
testq %rsi, %rsi
pushq $0x2
popq %rax
cmoveq %rax, %r13
leaq (,%r13,4), %rsi
movq %rcx, %rdi
callq 0x2350
movq -0x30(%rbp), %r8
movq %rax, %rcx
movq %r13, -0xa8(%rbp)
movq -0x58(%rbp), %rdx
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rdi
movq -0x90(%rbp), %r9
subl %edx, %eax
andl $0x1, %r14d
leal (%r14,%rax,2), %esi
movl %esi, (%rcx,%r8,4)
cmpq %r9, %rdi
movq %rcx, -0x70(%rbp)
jne 0xe1e8
leaq (%r9,%r9), %r14
testq %r9, %r9
pushq $0x2
popq %rax
cmoveq %rax, %r14
leaq (,%r14,8), %rsi
movq -0x80(%rbp), %rdi
movq %rcx, %r13
callq 0x2350
movq -0x30(%rbp), %r8
movq %rax, %r12
movl (%r13,%r8,4), %esi
movq -0x58(%rbp), %rdx
movq %r14, -0x90(%rbp)
jmp 0xe1ec
movq -0x80(%rbp), %r12
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rax
incq %rax
movq %rax, -0x178(%rbp)
leaq 0x1(%r8), %r14
movq -0xf8(%rbp), %rcx
movq %r8, %r13
callq 0xeb11
movq -0x40(%rbp), %rsi
leaq 0x1(%rsi), %rcx
movq %r12, -0x80(%rbp)
movq %rax, (%r12,%rsi,8)
cmpq $0x2, %r14
jb 0xe26d
movq -0x178(%rbp), %rsi
movq -0x70(%rbp), %rdx
movl -0x4(%rdx,%r13,4), %eax
xorl (%rdx,%r13,4), %eax
cmpl $0x1, %eax
movq -0x98(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x88(%rbp), %r11
movl -0x4c(%rbp), %edx
movq -0xe0(%rbp), %r12
ja 0xe2aa
decq %r13
movq %r13, -0x30(%rbp)
decq -0x38(%rbp)
decq -0x40(%rbp)
jmp 0xe2b6
movq %r14, -0x30(%rbp)
movq -0x178(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq -0x98(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x58(%rbp), %rdi
movq -0x88(%rbp), %r11
movl -0x4c(%rbp), %r14d
movq -0xb0(%rbp), %rsi
movq -0xe0(%rbp), %r12
jmp 0xe2c4
movq %r14, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq -0x58(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movl %edx, %r14d
incq %r9
movq -0x78(%rbp), %r13
movq %r13, (%r15,%r12,8)
cmpq %rsi, %r13
seta %al
movq -0x128(%rbp), %rcx
movq -0xc0(%rbp), %rdx
movq %rdx, (%rcx,%r12,8)
cmpq $-0x1, %r13
sete %cl
orb %al, %cl
jne 0xe30d
movq %rdi, %r13
cmpl %r13d, %r14d
jge 0xe323
movq -0x78(%rbp), %rax
movq %r11, %r10
movq -0xb8(%rbp), %r11
jmp 0xe497
movq -0x78(%rbp), %rax
movq %rdi, %r13
movq %r11, %r10
movq -0xb8(%rbp), %r11
jmp 0xe4a1
movq -0xd8(%rbp), %rax
cmpq %rax, -0x38(%rbp)
movq %r11, -0x88(%rbp)
movq %r9, %r13
jne 0xe366
leaq (%rax,%rax), %r14
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r14
leaq (,%r14,8), %rsi
movq -0x68(%rbp), %rdi
callq 0x2350
movq %r14, -0xd8(%rbp)
movq -0x30(%rbp), %rdx
jmp 0xe36e
movq -0x30(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0xc0(%rbp), %rcx
xorq $0x1, %rcx
movq -0x38(%rbp), %rsi
movq %rcx, (%rax,%rsi,8)
movq -0xa8(%rbp), %rcx
cmpq %rcx, %rdx
movq -0x70(%rbp), %r8
movq %rax, -0x68(%rbp)
jne 0xe3c1
leaq (%rcx,%rcx), %r14
testq %rcx, %rcx
pushq $0x2
popq %rax
cmoveq %rax, %r14
leaq (,%r14,4), %rsi
movq %r8, %rdi
callq 0x2350
movq -0x30(%rbp), %rdx
movq %rax, %r8
movq %r14, -0xa8(%rbp)
movq %r13, %rdi
movq -0x40(%rbp), %r9
movl %edi, %eax
subl -0x58(%rbp), %eax
movq -0xc0(%rbp), %rcx
andl $0x1, %ecx
leal (%rcx,%rax,2), %esi
movl %esi, (%r8,%rdx,4)
movq -0x90(%rbp), %rax
cmpq %rax, %r9
movq %r8, -0x70(%rbp)
movq %r13, -0x48(%rbp)
jne 0xe42f
leaq (%rax,%rax), %r14
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r14
leaq (,%r14,8), %rsi
movq -0x80(%rbp), %rdi
movq %r8, %r12
callq 0x2350
movq -0x30(%rbp), %rdx
movq %rax, %r13
movl (%r12,%rdx,4), %esi
movq -0xe0(%rbp), %r12
movq %r14, -0x90(%rbp)
jmp 0xe433
movq -0x80(%rbp), %r13
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rax
incq %rax
movq %rax, -0x38(%rbp)
incq %rdx
movq %rdx, -0x30(%rbp)
movq -0x58(%rbp), %r14
movl %r14d, %edx
movq -0xf8(%rbp), %rcx
callq 0xeb11
movq %r13, -0x80(%rbp)
movq -0x40(%rbp), %rcx
movq %rax, (%r13,%rcx,8)
movq %r14, %r13
incq %rcx
movq %rcx, -0x40(%rbp)
movq -0x98(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x88(%rbp), %r10
movq -0xb8(%rbp), %r11
movq -0xb0(%rbp), %rsi
movq -0x78(%rbp), %rax
cmpq %rsi, %rax
cmovbl %r11d, %ebx
movq %rax, %rsi
cmpq %rsi, %rax
jb 0xe4d4
cmpl %ebx, %r11d
jne 0xe4d4
leal 0x1(%r11), %eax
movq %r12, %rcx
pushq $-0x1
popq %r14
movl %r11d, %ebx
cmpq %r8, %rcx
jge 0xe4dc
movq 0x8(%r15,%rcx,8), %rdx
incq %rcx
cmpq %rdx, %r14
cmovaeq %rdx, %r14
cmoval %eax, %ebx
incl %eax
jmp 0xe4b9
movq %rsi, %r14
jmp 0xe740
xorl %eax, %eax
cmpq %r12, %rax
jg 0xe4f6
movq (%r15,%rax,8), %rcx
cmpq %rcx, %r14
cmovaeq %rcx, %r14
cmoval %eax, %ebx
incq %rax
jmp 0xe4de
cmpq %rsi, -0x78(%rbp)
je 0xe740
leal 0x1(%r11), %eax
cmpl -0x180(%rbp), %r11d
movl $0x0, %ecx
cmovel %ecx, %eax
movq -0x78(%rbp), %rcx
cmpl %eax, %ebx
jne 0xe538
cmpq %rcx, %r14
jne 0xe538
cmpq $-0x1, %rcx
je 0xe73c
cmpl %r13d, -0x4c(%rbp)
jge 0xe556
movq %rcx, %r14
jmp 0xe740
cmpl %r11d, %ebx
setne %al
cmpq $-0x1, %r14
sete %cl
orb %al, %cl
cmpl %r13d, -0x4c(%rbp)
setl %al
orb %cl, %al
jne 0xe740
movq -0xd8(%rbp), %rax
cmpq %rax, -0x38(%rbp)
movq %r10, -0x88(%rbp)
movq %r9, %r13
jne 0xe61e
leaq (%rax,%rax), %r12
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r12
leaq (,%r12,8), %rsi
movq -0x68(%rbp), %rdi
callq 0x2350
movq %r12, -0xd8(%rbp)
movq -0x30(%rbp), %rcx
jmp 0xe626
movl %ecx, %r12d
addl %r12d, %r10d
decl %r10d
cmpl $0x100, %r12d           # imm = 0x100
movq -0xa0(%rbp), %rdi
jb 0xde87
movq -0x160(%rbp), %rax
cmpq %rax, -0xf0(%rbp)
jne 0xe75e
leaq (%rax,%rax), %r13
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r13
leaq (,%r13,4), %rsi
movq -0xc8(%rbp), %rdi
movq %r10, %r14
callq 0x2350
movq -0xa0(%rbp), %rdi
movq -0xb8(%rbp), %r11
movq %r14, %r10
movq -0x48(%rbp), %r9
movq -0x98(%rbp), %r8
movq %r13, -0x160(%rbp)
jmp 0xe765
movq -0x30(%rbp), %rcx
movq -0x68(%rbp), %rax
movq -0xc0(%rbp), %rdx
xorq $0x1, %rdx
movq -0x38(%rbp), %rsi
movq %rdx, (%rax,%rsi,8)
movq -0xa8(%rbp), %rdx
cmpq %rdx, %rcx
movq -0x70(%rbp), %r8
movq %rax, -0x68(%rbp)
jne 0xe679
leaq (%rdx,%rdx), %r12
testq %rdx, %rdx
pushq $0x2
popq %rax
cmoveq %rax, %r12
leaq (,%r12,4), %rsi
movq %r8, %rdi
callq 0x2350
movq -0x30(%rbp), %rcx
movq %rax, %r8
movq %r12, -0xa8(%rbp)
movq %r13, %rdx
movq -0x40(%rbp), %rdi
movq -0x90(%rbp), %r9
movl %edx, %eax
subl -0x58(%rbp), %eax
movq -0xc0(%rbp), %rsi
andl $0x1, %esi
leal (%rsi,%rax,2), %esi
movl %esi, (%r8,%rcx,4)
cmpq %r9, %rdi
movq %r8, -0x70(%rbp)
movq %r13, -0x48(%rbp)
jne 0xe6e1
leaq (%r9,%r9), %r12
testq %r9, %r9
pushq $0x2
popq %rax
cmoveq %rax, %r12
leaq (,%r12,8), %rsi
movq -0x80(%rbp), %rdi
movq %r8, %r13
callq 0x2350
movq -0x30(%rbp), %rcx
movl (%r13,%rcx,4), %esi
movq %r12, -0x90(%rbp)
movq %rax, %r12
jmp 0xe6e5
movq -0x80(%rbp), %r12
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rax
incq %rax
movq %rax, -0x38(%rbp)
incq %rcx
movq %rcx, -0x30(%rbp)
movq -0x58(%rbp), %r13
movl %r13d, %edx
movq -0xf8(%rbp), %rcx
callq 0xeb11
movq %r12, -0x80(%rbp)
movq -0x40(%rbp), %rcx
movq %rax, (%r12,%rcx,8)
incq %rcx
movq %rcx, -0x40(%rbp)
movq -0x98(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x88(%rbp), %r10
movq -0xb8(%rbp), %r11
jmp 0xe740
pushq $-0x1
popq %r14
cmpl -0x180(%rbp), %r11d
leal 0x1(%r11), %eax
movl $0x0, %ecx
cmovel %ecx, %eax
incl %r10d
movl %eax, %r11d
jmp 0xdcdc
movq -0xc8(%rbp), %rax
leal -0x1(%r12), %edx
movq %rax, -0xc8(%rbp)
movq -0xf0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
incq %rcx
movq %rcx, -0xf0(%rbp)
jmp 0xde87
cmpl %ebx, %r11d
setne %al
cmpq $-0x1, %r14
sete %cl
orb %al, %cl
cmpl %r13d, -0x4c(%rbp)
setl %al
orb %cl, %al
je 0xe7c6
movq -0x108(%rbp), %r15
movq -0x158(%rbp), %r12
movq -0x30(%rbp), %r13
movq -0x80(%rbp), %rbx
movq -0xe8(%rbp), %rsi
jmp 0xe92c
movq -0x128(%rbp), %rax
movq (%rax,%r12,8), %rbx
movq -0x38(%rbp), %rdx
movq -0xd8(%rbp), %rax
cmpq %rax, %rdx
jne 0xe809
movq %rax, %rsi
shlq $0x4, %rsi
testq %rax, %rax
pushq $0x10
popq %rax
cmoveq %rax, %rsi
movq -0x68(%rbp), %rdi
callq 0x2350
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %r8
movq -0x70(%rbp), %rcx
jmp 0xe815
movq -0x30(%rbp), %r8
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %rax
movq -0xa8(%rbp), %rdi
movq %rbx, (%rax,%rdx,8)
cmpq %rdi, %r8
movq -0x158(%rbp), %r12
movq %rax, -0x68(%rbp)
jne 0xe851
leaq (,%rdi,8), %rsi
testq %rdi, %rdi
pushq $0x8
popq %rax
cmoveq %rax, %rsi
movq %rcx, %rdi
callq 0x2350
movq -0x30(%rbp), %r8
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rdx
movq -0x90(%rbp), %rdi
subl %r13d, %eax
andl $0x1, %ebx
leal (%rbx,%rax,2), %esi
movl %esi, (%rcx,%r8,4)
cmpq %rdi, %rdx
movq %rcx, -0x70(%rbp)
jne 0xe8a0
movq %rdi, %rsi
shlq $0x4, %rsi
testq %rdi, %rdi
pushq $0x10
popq %rax
cmoveq %rax, %rsi
movq -0x80(%rbp), %rdi
movq %rcx, %r14
callq 0x2350
movq -0x30(%rbp), %r8
movq %rax, %rbx
movl (%r14,%r8,4), %esi
jmp 0xe8a4
movq -0x80(%rbp), %rbx
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rax
leaq 0x1(%rax), %r15
leaq 0x1(%r8), %r14
movl %r13d, %edx
movq -0xf8(%rbp), %rcx
movq %r8, %r13
callq 0xeb11
movq -0x40(%rbp), %rdx
leaq 0x1(%rdx), %rcx
movq %rax, (%rbx,%rdx,8)
cmpq $0x2, %r14
jb 0xe902
movq -0x70(%rbp), %rdx
movl -0x4(%rdx,%r13,4), %eax
xorl (%rdx,%r13,4), %eax
cmpl $0x1, %eax
movq -0x48(%rbp), %r9
movq -0xe8(%rbp), %rsi
ja 0xe91a
decq %r13
decq -0x38(%rbp)
decq -0x40(%rbp)
jmp 0xe925
movq %r14, %r13
movq %r15, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq -0x48(%rbp), %r9
movq -0xe8(%rbp), %rsi
jmp 0xe925
movq %r14, %r13
movq %r15, -0x38(%rbp)
movq %rcx, -0x40(%rbp)
movq -0x108(%rbp), %r15
movq %rbx, %r14
movq %r13, -0x30(%rbp)
testq %rsi, %rsi
je 0xe949
movq -0x60(%rbp), %rdi
callq 0x2350
movq -0x48(%rbp), %r9
movq %rax, -0x60(%rbp)
movq -0x100(%rbp), %rbx
movq -0xf0(%rbp), %r13
testq %r9, %r9
je 0xe972
movq -0xa0(%rbp), %rdi
movq %r9, %rsi
callq 0x2350
movq %rax, -0xa0(%rbp)
movq -0xc8(%rbp), %rdi
testq %r13, %r13
je 0xe991
shlq $0x2, %r13
movq %r13, %rsi
callq 0x2350
movq %rax, -0xc8(%rbp)
movq -0xd0(%rbp), %rax
testq %rbx, %rbx
je 0xe9ac
shlq $0x2, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2350
movq -0x70(%rbp), %rdi
movq %rax, -0xd0(%rbp)
movq -0x30(%rbp), %rax
testq %rax, %rax
je 0xe9d0
leaq (,%rax,4), %rsi
callq 0x2350
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq %rdi, %r13
movq -0x38(%rbp), %rsi
testq %rsi, %rsi
je 0xe9ec
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2350
movq %r14, %rbx
movq %rax, %r14
movq -0x40(%rbp), %rsi
testq %rsi, %rsi
je 0xea0a
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x2350
movq %rax, %rbx
movq 0x28(%r15), %rcx
movq (%rcx), %rdx
cmpq 0x8(%rcx), %rdx
jne 0xea43
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
pushq $0x2
popq %rdx
cmoveq %rdx, %rax
movq %rax, 0x8(%rcx)
movq 0x10(%rcx), %rdi
imulq $0x58, %rax, %rsi
callq 0x2350
movq 0x28(%r15), %rcx
movq %rax, 0x10(%rcx)
movq (%rcx), %rdx
jmp 0xea47
movq 0x10(%rcx), %rax
movq -0x110(%rbp), %rdi
movq -0x150(%rbp), %r8
movq -0x148(%rbp), %r9
movq -0x48(%rbp), %r10
leaq 0x1(%rdx), %rsi
movq %rsi, (%rcx)
imulq $0x58, %rdx, %rcx
movq %r8, (%rax,%rcx)
movq %r9, 0x8(%rax,%rcx)
movl %r10d, 0x10(%rax,%rcx)
movq -0x60(%rbp), %rdx
movq %rdx, 0x18(%rax,%rcx)
movq -0xa0(%rbp), %rdx
movq %rdx, 0x20(%rax,%rcx)
movq -0xc8(%rbp), %rdx
movq %rdx, 0x28(%rax,%rcx)
movq -0xd0(%rbp), %rdx
movq %rdx, 0x30(%rax,%rcx)
movq -0x30(%rbp), %rdx
movl %edx, 0x38(%rax,%rcx)
movq %r13, 0x40(%rax,%rcx)
movq %r14, 0x48(%rax,%rcx)
movq %rbx, 0x50(%rax,%rcx)
callq 0x2060
movq -0x1a0(%rbp), %rsp
incq %r12
movq -0x58(%rbp), %r13
jmp 0xdb51
movq -0xf8(%rbp), %rdi
callq 0x2060
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb883(%rip), %rdi      # 0x1a37c
leaq 0xb50e(%rip), %rsi      # 0x1a00e
leaq 0xb88e(%rip), %rcx      # 0x1a395
movl $0xfb, %edx
callq 0x21d0