// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/htscodecs/htscodecs/rANS_static4x16pr.c
// Function: rans_compress_to_4x16
unsigned char *rans_compress_to_4x16(unsigned char *in, unsigned int in_size,
                                     unsigned char *out,unsigned int *out_size,
                                     int order) {
    if (in_size > INT_MAX || (out && *out_size == 0)) {
        *out_size = 0;
        return NULL;
    }

#ifdef VALIDATE_RANS
    int orig_order = order;
    int orig_in_size = in_size;
    unsigned char *orig_in = in;
#endif

    unsigned int c_meta_len;
    uint8_t *meta = NULL, *rle = NULL, *packed = NULL;
    uint8_t *out_free = NULL;

    if (!out) {
        *out_size = rans_compress_bound_4x16(in_size, order);
        if (*out_size == 0)
            return NULL;
        if (!(out_free = out = malloc(*out_size))) {
            *out_size = 0;
            return NULL;
        }
    }

    unsigned char *out_end = out + *out_size;

    // Permit 32-way unrolling for large blocks, paving the way for
    // AVX2 and AVX512 SIMD variants.
    if ((order & RANS_ORDER_SIMD_AUTO) && in_size >= 50000
        && !(order & RANS_ORDER_STRIPE))
        order |= X_32;

    if (in_size <= 20)
        order &= ~RANS_ORDER_STRIPE;
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    if (in_size <= 1000)
        order &= ~RANS_ORDER_X32;
#endif
    if (order & RANS_ORDER_STRIPE) {
        int N = (order>>8) & 0xff;
        if (N == 0) N = 4; // default for compatibility with old tests

        if (N > in_size)
            N = in_size;

        unsigned char *transposed = malloc(in_size);
        unsigned int part_len[256];
        unsigned int idx[256];
        if (!transposed) {
            free(out_free);
            *out_size = 0;
            return NULL;
        }
        int i, j, x;

        for (i = 0; i < N; i++) {
            part_len[i] = in_size / N + ((in_size % N) > i);
            idx[i] = i ? idx[i-1] + part_len[i-1] : 0; // cumulative index
        }

#define KN 8
        i = x = 0;
        if (in_size >= N*KN) {
            for (; i < in_size-N*KN;) {
                int k;
                unsigned char *ink = in+i;
                for (j = 0; j < N; j++)
                    for (k = 0; k < KN; k++)
                        transposed[idx[j]+x+k] = ink[j+N*k];
                x += KN; i+=N*KN;
            }
        }
#undef KN
        for (; i < in_size-N; i += N, x++) {
            for (j = 0; j < N; j++)
                transposed[idx[j]+x] = in[i+j];
        }

        for (; i < in_size; i += N, x++) {
            for (j = 0; i+j < in_size; j++)
                transposed[idx[j]+x] = in[i+j];
        }

        unsigned int olen2;
        unsigned char *out2, *out2_start;
        c_meta_len = 1;
        *out = order & ~RANS_ORDER_NOSZ;
        c_meta_len += var_put_u32(out+c_meta_len, out_end, in_size);
        if (c_meta_len >= *out_size) {
            free(out_free);
            free(transposed);
            *out_size = 0;
            return NULL;
        }

        out[c_meta_len++] = N;
        
        unsigned char *out_best = NULL;
        unsigned int out_best_len = 0;

        out2_start = out2 = out+7+5*N; // shares a buffer with c_meta
        for (i = 0; i < N; i++) {
            // Brute force try all methods.
            uint8_t *r;
            int j, m[] = {1,64,128,0}, best_j = 0, best_sz = INT_MAX;
            for (j = 0; j < sizeof(m)/sizeof(*m); j++) {
                if ((order & m[j]) != m[j])
                    continue;

                // order-1 *only*; bit check above cannot elide order-0
                if ((order & RANS_ORDER_STRIPE_NO0) && (m[j]&1) == 0)
                    continue;

                if (out2 - out > *out_size)
                    continue; // an error, but caught in best_sz check later

                olen2 = *out_size - (out2 - out);
                r = rans_compress_to_4x16(transposed+idx[i], part_len[i],
                                          out2, &olen2,
                                          m[j] | RANS_ORDER_NOSZ
                                          | (order&RANS_ORDER_X32));
                if (r && olen2 && best_sz > olen2) {
                    best_sz = olen2;
                    best_j = j;
                    if (j < sizeof(m)/sizeof(*m) && olen2 > out_best_len) {
                        unsigned char *tmp = realloc(out_best, olen2);
                        if (!tmp) {
                            free(out_free);
                            free(transposed);
                            *out_size = 0;
                            return NULL;
                        }
                        out_best = tmp;
                        out_best_len = olen2;
                    }

                    // Cache a copy of the best so far
                    memcpy(out_best, out2, olen2);
                }
            }

            if (best_sz == INT_MAX) {
                free(out_best);
                free(out_free);
                free(transposed);
                *out_size = 0;
                return NULL;
            }

            if (best_j < sizeof(m)/sizeof(*m)) {
                // Copy the best compression to output buffer if not current
                memcpy(out2, out_best, best_sz);
                olen2 = best_sz;
            }

            out2 += olen2;
            c_meta_len += var_put_u32(out+c_meta_len, out_end, olen2);
        }
        if (out_best)
            free(out_best);

        memmove(out+c_meta_len, out2_start, out2-out2_start);
        free(transposed);
        *out_size = c_meta_len + out2-out2_start;
        return out;
    }

    if (order & RANS_ORDER_CAT) {
        out[0] = RANS_ORDER_CAT;
        c_meta_len = 1;
        c_meta_len += var_put_u32(&out[1], out_end, in_size);

        if (c_meta_len + in_size > *out_size) {
            free(out_free);
            *out_size = 0;
            return NULL;
        }
        if (in_size)
            memcpy(out+c_meta_len, in, in_size);
        *out_size = c_meta_len + in_size;
        return out;
    }

    int do_pack = order & RANS_ORDER_PACK;
    int do_rle  = order & RANS_ORDER_RLE;
    int no_size = order & RANS_ORDER_NOSZ;
    int do_simd = order & RANS_ORDER_X32;

    out[0] = order;
    c_meta_len = 1;

    if (!no_size)
        c_meta_len += var_put_u32(&out[1], out_end, in_size);

    order &= 3;

    // Format is compressed meta-data, compressed data.
    // Meta-data can be empty, pack, rle lengths, or pack + rle lengths.
    // Data is either the original data, bit-packed packed, rle literals or
    // packed + rle literals.

    if (do_pack && in_size) {
        // PACK 2, 4 or 8 symbols into one byte.
        int pmeta_len;
        uint64_t packed_len;
        if (c_meta_len + 256 > *out_size) {
            free(out_free);
            *out_size = 0;
            return NULL;
        }
        packed = hts_pack(in, in_size, out+c_meta_len, &pmeta_len, &packed_len);
        if (!packed) {
            out[0] &= ~RANS_ORDER_PACK;
            do_pack = 0;
            free(packed);
            packed = NULL;
        } else {
            in = packed;
            in_size = packed_len;
            c_meta_len += pmeta_len;

            // Could derive this rather than storing verbatim.
            // Orig size * 8/nbits (+1 if not multiple of 8/n)
            int sz = var_put_u32(out+c_meta_len, out_end, in_size);
            c_meta_len += sz;
            *out_size -= sz;

            if (do_simd && in_size < 32) {
                do_simd = 0;
                out[0] &= ~RANS_ORDER_X32;
            }
        }
    } else if (do_pack) {
        out[0] &= ~RANS_ORDER_PACK;
    }

    if (do_rle && in_size) {
        // RLE 'in' -> rle_length + rle_literals arrays
        unsigned int rmeta_len, c_rmeta_len;
        uint64_t rle_len;
        c_rmeta_len = in_size+257;
        if (!(meta = malloc(c_rmeta_len))) {
            free(out_free);
            *out_size = 0;
            return NULL;
        }

        uint8_t rle_syms[256];
        int rle_nsyms = 0;
        uint64_t rmeta_len64;
        rle = hts_rle_encode(in, in_size, meta, &rmeta_len64,
                             rle_syms, &rle_nsyms, NULL, &rle_len);
        memmove(meta+1+rle_nsyms, meta, rmeta_len64);
        meta[0] = rle_nsyms;
        memcpy(meta+1, rle_syms, rle_nsyms);
        rmeta_len = rmeta_len64 + rle_nsyms+1;

        if (!rle || rle_len + rmeta_len >= .99*in_size) {
            // Not worth the speed hit.
            out[0] &= ~RANS_ORDER_RLE;
            do_rle = 0;
            free(rle);
            rle = NULL;
        } else {
            // Compress lengths with O0 and literals with O0/O1 ("order" param)
            int sz = var_put_u32(out+c_meta_len, out_end, rmeta_len*2), sz2;
            sz += var_put_u32(out+c_meta_len+sz, out_end, rle_len);
            if ((c_meta_len+sz+5) > *out_size) {
                free(out_free);
                free(rle);
                free(meta);
                free(packed);
                *out_size = 0;
                return NULL;
            }
            c_rmeta_len = *out_size - (c_meta_len+sz+5);
            if (do_simd && (rmeta_len < 32 || rle_len < 32)) {
                do_simd = 0;
                out[0] &= ~RANS_ORDER_X32;
            }
            if (!rans_enc_func(do_simd, 0)(meta, rmeta_len, out+c_meta_len+sz+5, &c_rmeta_len)) {
                free(out_free);
                free(rle);
                free(meta);
                free(packed);
                *out_size = 0;
                return NULL;
            }
            if (c_rmeta_len < rmeta_len) {
                sz2 = var_put_u32(out+c_meta_len+sz, out_end, c_rmeta_len);
                memmove(out+c_meta_len+sz+sz2, out+c_meta_len+sz+5, c_rmeta_len);
            } else {
                // Uncompressed RLE meta-data as too small
                sz = var_put_u32(out+c_meta_len, out_end, rmeta_len*2+1);
                sz2 = var_put_u32(out+c_meta_len+sz, out_end, rle_len);
                memcpy(out+c_meta_len+sz+sz2, meta, rmeta_len);
                c_rmeta_len = rmeta_len;
            }

            c_meta_len += sz + sz2 + c_rmeta_len;

            in = rle;
            in_size = rle_len;
        }

        free(meta);
    } else if (do_rle) {
        out[0] &= ~RANS_ORDER_RLE;
    }

    if (c_meta_len > *out_size) {
        free(out_free);
        free(rle);
        free(packed);
        *out_size = 0;
        return NULL;
    }

    *out_size -= c_meta_len;
    if (order && in_size < 8) {
        out[0] &= ~1;
        order  &= ~1;
    }

    if (!rans_enc_func(do_simd, order)(in, in_size, out+c_meta_len, out_size)) {
        free(out_free);
        free(rle);
        free(packed);
        *out_size = 0;
        return NULL;
    }

    if (*out_size >= in_size) {
        out[0] &= ~3;
        out[0] |= RANS_ORDER_CAT | no_size;

        if (out + c_meta_len + in_size > out_end) {
            free(out_free);
            free(rle);
            free(packed);
            *out_size = 0;
            return NULL;
        }
        if (in_size)
            memcpy(out+c_meta_len, in, in_size);
        *out_size = in_size;
    }

    free(rle);
    free(packed);

    *out_size += c_meta_len;

// Validation mode
#ifdef VALIDATE_RANS
    unsigned int decoded_size = orig_in_size;
    unsigned char *decoded = malloc(decoded_size);
    decoded = rans_uncompress_to_4x16(out, *out_size,
                                      decoded, &decoded_size);
    if (!decoded ||
        decoded_size != orig_in_size ||
        memcmp(orig_in, decoded, orig_in_size) != 0) {
        fprintf(stderr, "rans round trip failed for order %d. Written to fd 5\n", orig_order);
        if (write(5, orig_in, orig_in_size) < 0)
            abort();
        abort();
    }
    free(decoded);
#endif


    return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8a8, %rsp            # imm = 0x8A8
movl %r8d, %r15d
movq %rcx, %r8
testl %esi, %esi
js 0x65d77
movq %rdx, %rbx
movl %esi, %r13d
movq %rdi, %rbp
testq %rdx, %rdx
movq %r8, 0x10(%rsp)
je 0x65c46
cmpl $0x0, (%r8)
je 0x65d77
movq $0x0, 0x38(%rsp)
jmp 0x65c7d
movl %r13d, %edi
movl %r15d, %esi
callq 0x64798
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
testl %eax, %eax
je 0x65d7e
movl %eax, %edi
callq 0x4680
movq 0x10(%rsp), %r8
movq %rax, %rbx
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x65d77
movl (%r8), %eax
movq %rax, 0x30(%rsp)
movl %r15d, %eax
andl $0x20008, %eax          # imm = 0x20008
movl %r15d, %ecx
orl $0x4, %ecx
cmpl $0x20000, %eax          # imm = 0x20000
cmovnel %r15d, %ecx
cmpl $0xc350, %r13d          # imm = 0xC350
cmovbl %r15d, %ecx
movl %ecx, %eax
andl $-0xd, %eax
cmpl $0x15, %r13d
cmovael %ecx, %eax
andl $-0x5, %eax
cmpl $0x3e9, %r13d           # imm = 0x3E9
cmovael %ecx, %eax
testb $0x8, %al
movl %eax, 0xc(%rsp)
jne 0x65d95
testb $0x20, %al
jne 0x65ff9
movl %eax, %ecx
movb %al, (%rbx)
movl $0x1, %r14d
andl $0x10, %ecx
movl %ecx, 0x54(%rsp)
jne 0x667ec
cmpl $0x5, 0x30(%rsp)
ja 0x660f4
movq $-0x1, %rdx
xorl %ecx, %ecx
movl %r13d, %esi
movl %r13d, %eax
shrl $0x7, %eax
incq %rdx
addq $0x7, %rcx
cmpl $0x7f, %esi
movl %eax, %esi
ja 0x65d05
movq 0x30(%rsp), %rsi
leaq (,%rsi,8), %rax
subq %rsi, %rax
addq $-0x7, %rax
cmpq %rcx, %rax
jl 0x667ec
addq $-0x7, %rcx
cmpq $0x4, %rdx
movl $0x4, %eax
cmovbq %rdx, %rax
incq %rax
xorl %r14d, %r14d
movl %r13d, %edx
shrl %cl, %edx
xorl %esi, %esi
testl %ecx, %ecx
setne %sil
andl $0x7f, %edx
shll $0x7, %esi
orl %edx, %esi
movb %sil, 0x1(%rbx,%r14)
incq %r14
addl $-0x7, %ecx
cmpl %r14d, %eax
jne 0x65d4a
incl %r14d
jmp 0x667ec
movl $0x0, (%r8)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8a8, %rsp            # imm = 0x8A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %ah, %eax
testl %eax, %eax
movl $0x4, %r15d
cmovnel %eax, %r15d
cmpl %r13d, %r15d
movl %r13d, %r14d
cmovbl %r15d, %r14d
movl %r13d, %edi
callq 0x4680
testq %rax, %rax
je 0x6608a
movq %rax, %r12
testl %r13d, %r13d
movq 0x10(%rsp), %r10
je 0x65e16
movl %r13d, %eax
xorl %edx, %edx
divl %r14d
xorl %ecx, %ecx
cmpl $0x1, %r14d
movl %r14d, %esi
adcl $0x0, %esi
cmpq %rdx, %rcx
movl %eax, %edi
adcl $0x0, %edi
movl %edi, 0x4a0(%rsp,%rcx,4)
movl $0x0, %edi
testq %rcx, %rcx
je 0x65e07
movl 0x49c(%rsp,%rcx,4), %edi
addl 0x9c(%rsp,%rcx,4), %edi
movl %edi, 0xa0(%rsp,%rcx,4)
incq %rcx
cmpq %rcx, %rsi
jne 0x65de0
leal (,%r14,8), %edx
xorl %ecx, %ecx
movl %r13d, %esi
movl $0x0, %eax
subl %edx, %esi
movq %rsi, 0x28(%rsp)
jbe 0x65ec7
movq %r15, 0x20(%rsp)
movq %rbx, 0x48(%rsp)
movl %r14d, %esi
cmpl $0x1, %r14d
movq %r14, 0x68(%rsp)
movl %r14d, %edi
adcl $0x0, %edi
leaq (,%rsi,8), %rax
movq %rax, 0x18(%rsp)
xorl %ecx, %ecx
movq %rbp, %r9
xorl %eax, %eax
movq %r9, %r10
xorl %r11d, %r11d
movl 0xa0(%rsp,%r11,4), %r14d
addl %eax, %r14d
movq %r10, %r15
xorl %edx, %edx
movb (%r15), %bl
leal (%r14,%rdx), %r8d
movb %bl, (%r12,%r8)
incq %rdx
addq %rsi, %r15
cmpq $0x8, %rdx
jne 0x65e7b
incq %r11
incq %r10
cmpq %rdi, %r11
jne 0x65e6b
addq $0x8, %rax
movq 0x18(%rsp), %rdx
addq %rdx, %rcx
addq %rdx, %r9
cmpq 0x28(%rsp), %rcx
jb 0x65e65
movq 0x10(%rsp), %r10
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %r14
movq 0x20(%rsp), %r15
movl %r13d, %edx
subl %r14d, %edx
cmpl %edx, %ecx
jae 0x65f20
cmpl $0x1, %r14d
movl %r14d, %esi
adcl $0x0, %esi
movslq %ecx, %rcx
cmpl %r13d, %r15d
movl %r13d, %edi
cmovbl %r15d, %edi
leaq (%rcx,%rbp), %r8
testl %r13d, %r13d
je 0x65f0f
xorl %r9d, %r9d
movb (%r8,%r9), %r10b
movl 0xa0(%rsp,%r9,4), %r11d
addl %eax, %r11d
movb %r10b, (%r12,%r11)
incq %r9
cmpq %r9, %rsi
jne 0x65ef4
addq %rdi, %rcx
incl %eax
addq %rdi, %r8
cmpl %ecx, %edx
ja 0x65eec
movq 0x10(%rsp), %r10
cmpl %r13d, %ecx
jae 0x65f65
movslq %ecx, %rdx
cmpl %r13d, %r15d
cmovael %r13d, %r15d
addq %rdx, %rbp
movl %ecx, %ecx
xorl %esi, %esi
movb (%rbp,%rsi), %dil
movl 0xa0(%rsp,%rsi,4), %r8d
addl %eax, %r8d
movb %dil, (%r12,%r8)
incq %rsi
leal (%rcx,%rsi), %edi
cmpl %r13d, %edi
jb 0x65f36
addq %r15, %rdx
incl %eax
addq %r15, %rbp
addq %r15, %rcx
cmpl %r13d, %edx
jb 0x65f34
movl 0xc(%rsp), %eax
andb $-0x11, %al
movb %al, (%rbx)
cmpl $0x5, 0x30(%rsp)
ja 0x660a4
movq $-0x1, %rdx
xorl %ecx, %ecx
movl %r13d, %esi
movl %r13d, %eax
shrl $0x7, %eax
incq %rdx
addq $0x7, %rcx
cmpl $0x7f, %esi
movl %eax, %esi
ja 0x65f87
movq 0x30(%rsp), %rsi
leaq (,%rsi,8), %rax
subq %rsi, %rax
addq $-0x7, %rax
xorl %r15d, %r15d
cmpq %rcx, %rax
jl 0x662a4
addq $-0x7, %rcx
cmpq $0x4, %rdx
movl $0x4, %eax
cmovbq %rdx, %rax
incq %rax
xorl %r15d, %r15d
movl %r13d, %edx
shrl %cl, %edx
xorl %esi, %esi
testl %ecx, %ecx
setne %sil
andl $0x7f, %edx
shll $0x7, %esi
orl %edx, %esi
movb %sil, 0x1(%rbx,%r15)
incq %r15
addl $-0x7, %ecx
cmpl %r15d, %eax
jne 0x65fcf
jmp 0x662a4
movb $0x20, (%rbx)
cmpl $0x5, 0x30(%rsp)
ja 0x660b9
movq $-0x1, %rsi
xorl %ecx, %ecx
movl %r13d, %edx
movl %r13d, %eax
shrl $0x7, %eax
incq %rsi
addq $0x7, %rcx
cmpl $0x7f, %edx
movl %eax, %edx
ja 0x66016
movq 0x30(%rsp), %rax
leaq (,%rax,8), %rdx
subq %rax, %rdx
addq $-0x7, %rdx
movl $0x1, %eax
cmpq %rcx, %rdx
jl 0x66777
addq $-0x7, %rcx
cmpq $0x4, %rsi
movl $0x4, %edx
cmovbq %rsi, %rdx
incq %rdx
xorl %eax, %eax
movl %r13d, %esi
shrl %cl, %esi
xorl %edi, %edi
testl %ecx, %ecx
setne %dil
andl $0x7f, %esi
shll $0x7, %edi
orl %esi, %edi
movb %dil, 0x1(%rbx,%rax)
incq %rax
addl $-0x7, %ecx
cmpl %eax, %edx
jne 0x6605f
incl %eax
jmp 0x66777
movq 0x38(%rsp), %rdi
callq 0x45c0
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
jmp 0x65d7e
cmpl $0x7f, %r13d
ja 0x660cd
movb %r13b, 0x1(%rbx)
movl $0x1, %r15d
jmp 0x662a4
cmpl $0x7f, %r13d
ja 0x66109
movb %r13b, 0x1(%rbx)
movl $0x2, %eax
jmp 0x66777
movl %r13d, %eax
cmpl $0x3fff, %r13d          # imm = 0x3FFF
ja 0x6612f
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x2(%rbx)
movl $0x2, %r15d
jmp 0x662a4
cmpl $0x7f, %r13d
ja 0x66162
movb %r13b, 0x1(%rbx)
movl $0x2, %r14d
jmp 0x667ec
movl %r13d, %eax
cmpl $0x3fff, %r13d          # imm = 0x3FFF
ja 0x6618d
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x2(%rbx)
movl $0x3, %eax
jmp 0x66777
cmpl $0x1fffff, %r13d        # imm = 0x1FFFFF
ja 0x661bf
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x3(%rbx)
movl $0x3, %r15d
jmp 0x662a4
movl %r13d, %eax
cmpl $0x3fff, %r13d          # imm = 0x3FFF
ja 0x661fd
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x2(%rbx)
movl $0x3, %r14d
jmp 0x667ec
cmpl $0x1fffff, %r13d        # imm = 0x1FFFFF
ja 0x66230
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x3(%rbx)
movl $0x4, %eax
jmp 0x66777
cmpl $0xfffffff, %r13d       # imm = 0xFFFFFFF
ja 0x6626d
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x3(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x4(%rbx)
movl $0x4, %r15d
jmp 0x662a4
cmpl $0x1fffff, %r13d        # imm = 0x1FFFFF
ja 0x66703
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x3(%rbx)
movl $0x4, %r14d
jmp 0x667ec
cmpl $0xfffffff, %r13d       # imm = 0xFFFFFFF
ja 0x66741
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x3(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x4(%rbx)
movl $0x5, %eax
jmp 0x66777
shrl $0x1c, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x3(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x4(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x5(%rbx)
movl $0x5, %r15d
leal 0x1(%r15), %eax
cmpl (%r10), %eax
jae 0x6669d
addl $0x2, %r15d
movl %eax, %eax
movb %r14b, (%rbx,%rax)
leal (%r14,%r14,4), %eax
leaq (%rbx,%rax), %rbp
addq $0x7, %rbp
testl %r13d, %r13d
movq %rbp, 0x90(%rsp)
je 0x666b5
movl 0xc(%rsp), %edx
movl %edx, %ecx
andl $0x4, %ecx
movl %ecx, 0x80(%rsp)
cmpl $0x1, %r14d
adcl $0x0, %r14d
movl %edx, %ecx
notl %ecx
movl %ecx, 0x54(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x78(%rsp)
movq $0x0, 0x18(%rsp)
movq %rbx, 0x48(%rsp)
movq %r14, 0x68(%rsp)
movq %r15, 0x88(%rsp)
movq %rbp, %rdi
subq %rbx, %rdi
xorl %r15d, %r15d
movl $0x7fffffff, 0x28(%rsp) # imm = 0x7FFFFFFF
leaq 0x38864(%rip), %r14     # 0x9eba0
movl $0x0, 0x58(%rsp)
movl 0x54(%rsp), %esi
movq %rdi, 0x70(%rsp)
btl $0x10, %edx
setae %al
movl (%r14), %r8d
testq %r15, %r15
sete %cl
testl %esi, %r8d
jne 0x66468
orb %cl, %al
je 0x66468
movl (%r10), %eax
cmpq %rax, %rdi
jg 0x66468
subl %edi, %eax
movl %eax, 0x60(%rsp)
movq 0x20(%rsp), %rax
movl 0xa0(%rsp,%rax,4), %edi
addq %r12, %rdi
movl 0x4a0(%rsp,%rax,4), %esi
orl 0x80(%rsp), %r8d
orl $0x10, %r8d
movq %rbp, %r13
movq %rbp, %rdx
leaq 0x60(%rsp), %rcx
callq 0x65bff
testq %rax, %rax
setne %al
movl 0x60(%rsp), %ebx
testl %ebx, %ebx
setne %cl
cmpl %ebx, 0x28(%rsp)
seta %dl
andb %cl, %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x663ff
cmpl 0x78(%rsp), %ebx
jbe 0x66434
movl %ebx, %esi
movq 0x18(%rsp), %rdi
callq 0x4840
movq %rax, %rbp
testq %rax, %rax
je 0x6640d
movl 0x60(%rsp), %eax
movl %eax, 0x78(%rsp)
movq %rbp, 0x18(%rsp)
movq 0x10(%rsp), %r10
jmp 0x6642b
movq 0x10(%rsp), %r10
movl 0xc(%rsp), %edx
movq %r13, %rbp
jmp 0x6645f
movq 0x38(%rsp), %rdi
callq 0x45c0
movq %r12, %rdi
callq 0x45c0
movq 0x10(%rsp), %r10
movl $0x0, (%r10)
testq %rbp, %rbp
je 0x665c2
movq 0x18(%rsp), %rdi
movl 0x60(%rsp), %edx
movq %rdi, 0x18(%rsp)
movq %r13, %rsi
callq 0x43c0
movl %r15d, 0x58(%rsp)
movl %ebx, 0x28(%rsp)
movq %r13, %rbp
movq 0x10(%rsp), %r10
movl 0xc(%rsp), %edx
movl 0x54(%rsp), %esi
movq 0x70(%rsp), %rdi
incq %r15
addq $0x4, %r14
cmpq $0x4, %r15
jne 0x6634d
cmpl $0x7fffffff, 0x28(%rsp) # imm = 0x7FFFFFFF
movq 0x88(%rsp), %r15
jne 0x664c4
movq 0x18(%rsp), %rdi
callq 0x45c0
movq 0x38(%rsp), %rdi
callq 0x45c0
movq %r12, %rdi
callq 0x45c0
movq 0x10(%rsp), %r10
movl $0x0, (%r10)
xorl %eax, %eax
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %r14
jmp 0x66679
cmpl $0x3, 0x58(%rsp)
movq 0x68(%rsp), %r14
ja 0x664ec
movl 0x28(%rsp), %ebx
movl %ebx, %edx
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
callq 0x43c0
movq 0x10(%rsp), %r10
movl %ebx, 0x60(%rsp)
movl 0x60(%rsp), %eax
movl %r15d, %ecx
movq 0x48(%rsp), %rbx
leaq (%rbx,%rcx), %rdx
movq 0x30(%rsp), %rdi
subq %rcx, %rdi
cmpq $0x4, %rdi
jg 0x6658e
xorl %r10d, %r10d
xorl %r8d, %r8d
movl %eax, %r11d
movl %eax, %r9d
movq %r8, %rcx
movq %r10, %rsi
shrl $0x7, %r9d
addq $0x7, %r8
incq %r10
cmpl $0x7f, %r11d
movl %r9d, %r11d
ja 0x6651a
leaq (,%rdi,8), %r9
subq %rdi, %r9
xorl %edi, %edi
cmpq %r8, %r9
movq 0x10(%rsp), %r10
jl 0x66671
cmpq $0x4, %rsi
movl $0x4, %edi
cmovaeq %rdi, %rsi
incq %rsi
xorl %edi, %edi
movl %eax, %r8d
shrl %cl, %r8d
xorl %r9d, %r9d
testl %ecx, %ecx
setne %r9b
andl $0x7f, %r8d
shll $0x7, %r9d
orl %r8d, %r9d
movb %r9b, (%rdx,%rdi)
incq %rdi
addl $-0x7, %ecx
cmpl %edi, %esi
jne 0x66561
jmp 0x66671
cmpl $0x7f, %eax
ja 0x6659f
movb %al, (%rdx)
movl $0x1, %edi
jmp 0x66671
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x665de
shrl $0x7, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movl %eax, %ecx
andb $0x7f, %cl
movb %cl, 0x1(%rdx)
movl $0x2, %edi
jmp 0x66671
xorl %eax, %eax
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %r14
movq 0x88(%rsp), %r15
movq %r13, %rbp
jmp 0x66679
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x66607
shrl $0xe, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x7, %ecx
orb $-0x80, %cl
movb %cl, 0x1(%rdx)
movl %eax, %ecx
andb $0x7f, %cl
movb %cl, 0x2(%rdx)
movl $0x3, %edi
jmp 0x66671
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x6663b
shrl $0x15, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0xe, %ecx
orb $-0x80, %cl
movb %cl, 0x1(%rdx)
movl %eax, %ecx
shrl $0x7, %ecx
orb $-0x80, %cl
movb %cl, 0x2(%rdx)
movl %eax, %ecx
andb $0x7f, %cl
movb %cl, 0x3(%rdx)
movl $0x4, %edi
jmp 0x66671
shrl $0x1c, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x15, %ecx
orb $-0x80, %cl
movb %cl, 0x1(%rdx)
movl %eax, %ecx
shrl $0xe, %ecx
orb $-0x80, %cl
movb %cl, 0x2(%rdx)
movl %eax, %ecx
shrl $0x7, %ecx
orb $-0x80, %cl
movb %cl, 0x3(%rdx)
movl %eax, %ecx
andb $0x7f, %cl
movb %cl, 0x4(%rdx)
movl $0x5, %edi
addq %rax, %rbp
addl %edi, %r15d
movb $0x1, %al
testb %al, %al
movl 0xc(%rsp), %edx
je 0x65d7e
movq 0x20(%rsp), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
cmpq %r14, %rcx
jne 0x6631c
jmp 0x666be
movq 0x38(%rsp), %rdi
callq 0x45c0
movq %r12, %rdi
callq 0x45c0
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0x666f7
movq $0x0, 0x18(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x666cd
callq 0x45c0
movl %r15d, %edi
addq %rbx, %rdi
movq %rbp, %rdx
movq 0x90(%rsp), %r14
subq %r14, %rdx
movq %r14, %rsi
callq 0x4830
movq %r12, %rdi
callq 0x45c0
addl %r15d, %ebp
subl %r14d, %ebp
movq 0x10(%rsp), %rax
movl %ebp, (%rax)
jmp 0x65d80
cmpl $0xfffffff, %r13d       # imm = 0xFFFFFFF
ja 0x667b5
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x3(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x4(%rbx)
movl $0x5, %r14d
jmp 0x667ec
shrl $0x1c, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x3(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x4(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x5(%rbx)
movl $0x6, %eax
movq %rbx, %r14
leal (%rax,%r13), %ebx
cmpl (%r8), %ebx
jbe 0x66790
movq 0x38(%rsp), %rdi
movq %r8, %rbx
jmp 0x66d66
testl %r13d, %r13d
je 0x667aa
movl %eax, %edi
addq %r14, %rdi
movl %r13d, %edx
movq %rbp, %rsi
callq 0x43c0
movq 0x10(%rsp), %r8
movl %ebx, (%r8)
movq %r14, %rbx
jmp 0x65d80
shrl $0x1c, %eax
orb $-0x80, %al
movb %al, 0x1(%rbx)
movl %r13d, %eax
shrl $0x15, %eax
orb $-0x80, %al
movb %al, 0x2(%rbx)
movl %r13d, %eax
shrl $0xe, %eax
orb $-0x80, %al
movb %al, 0x3(%rbx)
movl %r13d, %eax
shrl $0x7, %eax
orb $-0x80, %al
movb %al, 0x4(%rbx)
movl %r13d, %eax
andb $0x7f, %al
movb %al, 0x5(%rbx)
movl $0x6, %r14d
addq %rbx, 0x30(%rsp)
movl 0xc(%rsp), %ecx
movl %ecx, %eax
andl $0x4, %eax
movl %eax, 0x28(%rsp)
testl %r13d, %r13d
je 0x6683f
movl %ecx, %eax
andl $0x80, %eax
je 0x6683f
movq %rbx, 0x48(%rsp)
leal 0x100(%r14), %ebx
movl (%r8), %r15d
cmpl %r15d, %ebx
jbe 0x6684d
movq %r8, %r12
movq 0x38(%rsp), %rdi
callq 0x45c0
movl $0x0, (%r12)
xorl %eax, %eax
movq %r12, %r8
jmp 0x668d8
testb %cl, %cl
jns 0x66846
andb $0x7f, (%rbx)
xorl %eax, %eax
jmp 0x668ea
movl %r13d, %esi
movl %r14d, %edx
movq 0x48(%rsp), %r12
addq %r12, %rdx
leaq 0xa0(%rsp), %rcx
leaq 0x4a0(%rsp), %r8
movq %rbp, %rdi
callq 0x63eb0
testq %rax, %rax
je 0x668cc
movq %rax, %rbp
movl 0x4a0(%rsp), %r13d
addl 0xa0(%rsp), %r14d
leaq (%r12,%r14), %rdi
movq 0x30(%rsp), %rsi
movl %r13d, %edx
callq 0x66dad
addl %eax, %r14d
movq 0x10(%rsp), %r8
subl %eax, (%r8)
cmpl $0x0, 0x28(%rsp)
sete %al
cmpl $0x20, %r13d
setae %cl
orb %al, %cl
jne 0x668c7
andb $-0x5, (%r12)
movl $0x0, 0x28(%rsp)
movq %rbp, %rax
jmp 0x668d8
andb $0x7f, (%r12)
xorl %eax, %eax
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %ecx
cmpl %r15d, %ebx
movq 0x48(%rsp), %rbx
ja 0x65d7e
testb $0x40, %cl
movq %rax, 0x18(%rsp)
je 0x66abc
testl %r13d, %r13d
je 0x66abc
leal 0x101(%r13), %edi
movl %edi, 0x44(%rsp)
callq 0x4680
testq %rax, %rax
je 0x66af0
leaq 0x9c(%rsp), %r15
movl $0x0, (%r15)
movl %r13d, %esi
leaq 0xa0(%rsp), %r10
leaq 0x60(%rsp), %rcx
leaq 0x4a0(%rsp), %r8
movq %rbp, %rdi
movq %rsi, 0x58(%rsp)
movq %rax, %r12
movq %rax, %rdx
movq %r15, %r9
pushq %r10
pushq $0x0
callq 0x7cac8
addq $0x10, %rsp
movq %rax, 0x20(%rsp)
movslq (%r15), %rax
movq %rax, 0x80(%rsp)
leaq (%r12,%rax), %rdi
incq %rdi
movq %r12, %r15
incq %r15
leaq 0x60(%rsp), %rax
movq (%rax), %rdx
movq %r12, %rsi
movq %rdx, 0x78(%rsp)
callq 0x4830
movq %r12, 0x70(%rsp)
movq 0x80(%rsp), %rax
movb %al, (%r12)
movq %rax, %r12
movq %r15, %rdi
movq 0x20(%rsp), %r15
leaq 0x4a0(%rsp), %rsi
movq %rax, %rdx
callq 0x43c0
testq %r15, %r15
je 0x66acc
movq 0x78(%rsp), %rax
leal (%r12,%rax), %ecx
incl %ecx
movl %ecx, %edx
movq 0xa0(%rsp), %rax
addq %rdx, %rax
movq %rax, %xmm0
punpckldq 0x31d15(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x31d1d(%rip), %xmm0    # 0x98710
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdq 0x58(%rsp), %xmm0
mulsd 0x3816f(%rip), %xmm0    # 0x9eb80
ucomisd %xmm0, %xmm1
jae 0x66acc
movq %rdx, 0x78(%rsp)
movl %r14d, %r12d
addq %rbx, %r12
movq %rcx, 0x80(%rsp)
leal (%rcx,%rcx), %edx
movq %r12, %rdi
movq 0x30(%rsp), %r15
movq %r15, %rsi
movl %edx, 0x88(%rsp)
callq 0x66dad
cltq
movq %r12, 0x58(%rsp)
leaq (%r12,%rax), %rdi
movl 0xa0(%rsp), %edx
movq %r15, %rsi
movq %rax, %r15
callq 0x66dad
addl %eax, %r15d
leal (%r14,%r15), %ecx
addl $0x5, %ecx
movq 0x10(%rsp), %rax
movl (%rax), %eax
subl %ecx, %eax
jae 0x66b10
movq 0x38(%rsp), %rdi
callq 0x45c0
movq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x45c0
movq 0x70(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rdi
callq 0x45c0
movq 0x10(%rsp), %r8
movl $0x0, (%r8)
xorl %eax, %eax
jmp 0x66c8b
testb $0x40, %cl
je 0x66ac4
andb $-0x41, (%rbx)
xorl %r12d, %r12d
jmp 0x66ca1
andb $-0x41, (%rbx)
movq %r15, %rdi
callq 0x45c0
xorl %r12d, %r12d
movq 0x70(%rsp), %rdi
callq 0x45c0
movb $0x1, %al
movq 0x10(%rsp), %r8
jmp 0x66c95
movq 0x38(%rsp), %rdi
callq 0x45c0
movq 0x10(%rsp), %r8
movl $0x0, (%r8)
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x66c95
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x28(%rsp)
je 0x66b33
cmpl $0x20, 0x80(%rsp)
jb 0x66b30
cmpq $0x1f, 0xa0(%rsp)
ja 0x66b3b
andb $-0x5, (%rbx)
movl $0x0, 0x28(%rsp)
movq %rbx, 0x48(%rsp)
movl 0x28(%rsp), %edi
xorl %esi, %esi
callq 0x66ee2
movq %r15, 0x68(%rsp)
movslq %r15d, %rbx
movq 0x58(%rsp), %rcx
leaq (%rcx,%rbx), %rdx
addq $0x5, %rdx
leaq 0x44(%rsp), %rcx
movq 0x70(%rsp), %r15
movq %r15, %rdi
movq 0x80(%rsp), %r12
movl %r12d, %esi
movq %rdx, 0x90(%rsp)
callq *%rax
testq %rax, %rax
je 0x66bce
movl 0x44(%rsp), %edx
cmpl %r12d, %edx
jae 0x66c0c
movq 0x58(%rsp), %r15
addq %rbx, %r15
movq %r15, %rdi
movq 0x30(%rsp), %rsi
callq 0x66dad
movl %eax, %r13d
movslq %eax, %rdi
addq %r15, %rdi
movl 0x44(%rsp), %edx
movq 0x90(%rsp), %rsi
callq 0x4830
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %rbp
jmp 0x66c67
movq 0x38(%rsp), %rdi
callq 0x45c0
movq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
movq 0x18(%rsp), %rdi
callq 0x45c0
movq 0x10(%rsp), %r8
movl $0x0, (%r8)
xorl %eax, %eax
movq 0x48(%rsp), %rbx
jmp 0x66c8b
movl 0x88(%rsp), %edx
orl $0x1, %edx
movq 0x58(%rsp), %r13
movq %r13, %rdi
movq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0x66dad
movl %eax, %ebp
movslq %eax, %r15
addq %r13, %r15
movl 0xa0(%rsp), %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x66dad
movl %eax, %r13d
movslq %eax, %rdi
addq %r15, %rdi
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
callq 0x43c0
movl %r12d, 0x44(%rsp)
movq 0x48(%rsp), %rbx
addl %r14d, %ebp
addl %r13d, %ebp
addl 0x44(%rsp), %ebp
movl 0xa0(%rsp), %r13d
movb $0x1, %al
movl %ebp, %r14d
movq 0x20(%rsp), %r12
movq %r12, %rbp
movq 0x10(%rsp), %r8
testb %al, %al
jne 0x66ada
xorl %eax, %eax
movl 0xc(%rsp), %ecx
testb %al, %al
je 0x65d7e
movl (%r8), %eax
subl %r14d, %eax
jae 0x66cbe
movq 0x38(%rsp), %rdi
movq %r8, %rbx
callq 0x45c0
movq %r12, %rdi
jmp 0x66d5c
movl %ecx, %esi
movl %eax, (%r8)
andl $0x3, %esi
movq %r12, 0x20(%rsp)
je 0x66cdb
cmpl $0x7, %r13d
ja 0x66cdb
andb $-0x2, (%rbx)
andl $0x2, %ecx
movl %ecx, %esi
movl 0x28(%rsp), %edi
callq 0x66ee2
movl %r14d, %r15d
movq %rbx, %r12
addq %rbx, %r15
movq %rbp, %rdi
movl %r13d, %esi
movq %r15, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq *%rax
testq %rax, %rax
je 0x66d4d
cmpl %r13d, (%rbx)
jb 0x66d8e
movb (%r12), %al
andb $-0x24, %al
movl 0x54(%rsp), %edx
orb %al, %dl
orb $0x20, %dl
movb %dl, (%r12)
movl %r13d, %edx
leaq (%r15,%rdx), %rax
cmpq 0x30(%rsp), %rax
jbe 0x66d76
movq 0x38(%rsp), %rdi
callq 0x45c0
movq 0x20(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rdi
jmp 0x6608f
movq 0x38(%rsp), %rdi
callq 0x45c0
movq 0x20(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rdi
callq 0x45c0
movl $0x0, (%rbx)
jmp 0x65d7e
testl %r13d, %r13d
je 0x66d86
movq %r15, %rdi
movq %rbp, %rsi
callq 0x43c0
movq 0x10(%rsp), %rbx
movl %r13d, (%rbx)
movq 0x20(%rsp), %rdi
callq 0x45c0
movq 0x18(%rsp), %rdi
callq 0x45c0
addl %r14d, (%rbx)
movq %r12, %rbx
jmp 0x65d80