// File: /workspace/github_c_makefile_star2_O2/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 $0x898, %rsp            # imm = 0x898
testl %esi, %esi
js 0x4fdc3
movl %r8d, %r14d
movq %rdx, %r13
movq %rdi, %rbp
testq %rdx, %rdx
movq %rcx, 0x8(%rsp)
je 0x4fcfb
movl (%rcx), %ebx
testq %rbx, %rbx
je 0x4fdc3
xorl %r15d, %r15d
jmp 0x4fd39
movq %rsi, %r12
movq %rsi, %rdi
movl %r14d, %esi
callq 0x4edbc
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
testl %eax, %eax
je 0x4fdc6
movl %eax, %ebx
movq %rbx, %rdi
callq 0x4680
movq 0x8(%rsp), %rcx
movq %rax, %r15
movq %rax, %r13
testq %rax, %rax
movq %r12, %rsi
je 0x4fdc3
addq %r13, %rbx
movq %rbx, 0x48(%rsp)
movl %r14d, %eax
andl $0x20008, %eax          # imm = 0x20008
movl %r14d, %edx
orl $0x4, %edx
cmpl $0x20000, %eax          # imm = 0x20000
cmovnel %r14d, %edx
cmpl $0xc350, %esi           # imm = 0xC350
cmovbl %r14d, %edx
movl %edx, %eax
andl $-0xd, %eax
cmpl $0x15, %esi
cmovael %edx, %eax
andl $-0x5, %eax
cmpl $0x3e9, %esi            # imm = 0x3E9
cmovael %edx, %eax
movl %esi, %r12d
testb $0x8, %al
movl %eax, 0x4(%rsp)
jne 0x4fdde
testb $0x20, %al
jne 0x4fee2
movl %eax, %edx
movb %al, (%r13)
andl $0x10, %edx
movl %edx, 0x58(%rsp)
jne 0x501d0
movq %rsi, %rbx
leaq 0x1(%r13), %rdi
movq 0x48(%rsp), %rsi
movl %ebx, %edx
callq 0x50765
movq %rbx, %rsi
movq 0x8(%rsp), %rcx
movl %eax, %ebx
incl %ebx
jmp 0x501d3
andl $0x0, (%rcx)
xorl %r13d, %r13d
movq %r13, %rax
addq $0x898, %rsp            # imm = 0x898
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x40(%rsp)
movzbl %ah, %eax
testl %eax, %eax
pushq $0x4
popq %rbx
cmovnel %eax, %ebx
cmpl %esi, %ebx
movq %rsi, 0x18(%rsp)
cmovael %esi, %ebx
movq %r12, %rdi
callq 0x4680
testq %rax, %rax
je 0x4ff19
movq %rax, %r15
movq %r13, 0x28(%rsp)
movl %ebx, %r13d
xorl %ecx, %ecx
movq 0x18(%rsp), %rdi
movq %rbx, %r8
cmpq %rcx, %r13
je 0x4fe58
movl %edi, %eax
xorl %edx, %edx
divl %r8d
xorl %esi, %esi
cmpq %rdx, %rcx
adcl $0x0, %eax
movl %eax, 0x490(%rsp,%rcx,4)
testq %rcx, %rcx
je 0x4fe4c
movl 0x48c(%rsp,%rcx,4), %esi
addl 0x8c(%rsp,%rcx,4), %esi
movl %esi, 0x90(%rsp,%rcx,4)
incq %rcx
jmp 0x4fe1e
leal (,%r8,8), %esi
xorl %ecx, %ecx
movl %edi, %edx
movl $0x0, %eax
subl %esi, %edx
movq %rdx, 0x58(%rsp)
movq %r8, 0x10(%rsp)
jb 0x4ff35
leaq (,%r13,8), %rsi
xorl %eax, %eax
movq %rbp, %rdi
xorl %ecx, %ecx
cmpq 0x58(%rsp), %rcx
jae 0x4ff30
movq %rdi, %r8
xorl %r9d, %r9d
cmpq %r13, %r9
je 0x4fed1
movl 0x90(%rsp,%r9,4), %r10d
addl %eax, %r10d
movq %r8, %r11
xorl %ebx, %ebx
cmpq $0x8, %rbx
je 0x4fec9
movb (%r11), %dl
leal (%r10,%rbx), %r14d
movb %dl, (%r15,%r14)
incq %rbx
addq %r13, %r11
jmp 0x4feb0
incq %r9
incq %r8
jmp 0x4fe9b
addq $0x8, %rax
addq %rsi, %rcx
addq %rsi, %rdi
movq 0x10(%rsp), %r8
jmp 0x4fe8a
movb $0x20, (%r13)
movq %rsi, %rbx
leaq 0x1(%r13), %rdi
movq 0x48(%rsp), %rsi
movl %ebx, %edx
callq 0x50765
movq %rbx, %rdx
movq 0x8(%rsp), %rcx
addl %eax, %ebx
incl %ebx
cmpl (%rcx), %ebx
jbe 0x50218
movq %r15, %rdi
movq %rcx, %rbx
jmp 0x506a6
movq 0x40(%rsp), %rdi
callq 0x45c0
movq 0x8(%rsp), %rax
andl $0x0, (%rax)
jmp 0x4fdc6
movq 0x18(%rsp), %rdi
movl %edi, %edx
subl %r8d, %edx
movslq %ecx, %rsi
leaq (%rsi,%rbp), %rdi
cmpl %esi, %edx
jbe 0x4ff73
xorl %r8d, %r8d
cmpq %r8, %r13
je 0x4ff65
movb (%rdi,%r8), %r9b
movl 0x90(%rsp,%r8,4), %r10d
addl %eax, %r10d
movb %r9b, (%r15,%r10)
incq %r8
jmp 0x4ff48
addq %r13, %rsi
incl %eax
addl 0x10(%rsp), %ecx
addq %r13, %rdi
jmp 0x4ff41
movl %ecx, %ecx
addq %rcx, %rbp
cmpq %r12, %rcx
jae 0x4ffa9
xorl %edx, %edx
leaq (%rcx,%rdx), %rsi
cmpq %r12, %rsi
jae 0x4ff9f
movb (%rbp,%rdx), %sil
movl 0x90(%rsp,%rdx,4), %edi
addl %eax, %edi
movb %sil, (%r15,%rdi)
incq %rdx
jmp 0x4ff7f
addq %r13, %rcx
incl %eax
addq %r13, %rbp
jmp 0x4ff78
movl 0x4(%rsp), %ebp
movl %ebp, %eax
andb $-0x11, %al
movq 0x28(%rsp), %rbx
movb %al, (%rbx)
leaq 0x1(%rbx), %rdi
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x50765
movl %eax, %r14d
leal 0x1(%r14), %eax
movq 0x8(%rsp), %rsi
cmpl (%rsi), %eax
jae 0x50300
addl $0x2, %r14d
movl %eax, %eax
movq 0x10(%rsp), %rcx
movb %cl, (%rbx,%rax)
leal (%rcx,%rcx,4), %eax
addq %rax, %rbx
addq $0x7, %rbx
movl %ebp, %eax
andl $0x4, %eax
movl %eax, 0x30(%rsp)
xorl %r9d, %r9d
movq %rbx, 0x80(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x50(%rsp)
movl %ebp, %edx
movl %r14d, %r12d
cmpq %r13, %r9
je 0x502bb
movq %r12, 0x78(%rsp)
movq %r14, 0x70(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
subq 0x28(%rsp), %rdi
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %ebx, %ebx
leaq 0x2db70(%rip), %r14     # 0x7dbc0
movl $0x0, 0x68(%rsp)
movq %r9, 0x58(%rsp)
movq %rdi, 0x18(%rsp)
cmpq $0x4, %rbx
je 0x50151
btl $0x10, %edx
setae %al
movl (%r14), %r8d
notl %edx
testq %rbx, %rbx
sete %cl
testl %edx, %r8d
jne 0x5008e
orb %cl, %al
je 0x5008e
movl (%rsi), %eax
cmpq %rax, %rdi
jle 0x5009a
movl %r12d, %ebp
movl 0x4(%rsp), %edx
jmp 0x50142
subl %edi, %eax
movl %eax, 0x60(%rsp)
movl 0x90(%rsp,%r9,4), %edi
addq %r15, %rdi
movl 0x490(%rsp,%r9,4), %esi
orl 0x30(%rsp), %r8d
orl $0x10, %r8d
movq 0x10(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x4fcbf
testq %rax, %rax
setne %al
movl 0x60(%rsp), %ebp
testl %ebp, %ebp
setne %cl
cmpl %ebp, %r12d
seta %dl
andb %cl, %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x50113
cmpl 0x50(%rsp), %ebp
jbe 0x50118
movl %ebp, %esi
movq 0x20(%rsp), %rdi
callq 0x4840
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x50300
movl 0x60(%rsp), %eax
movl %eax, 0x50(%rsp)
jmp 0x5011a
movl %r12d, %ebp
jmp 0x5012f
movl %ebp, %eax
movl %eax, %edx
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x43c0
movl %ebx, 0x68(%rsp)
movq 0x8(%rsp), %rsi
movl 0x4(%rsp), %edx
movq 0x58(%rsp), %r9
movq 0x18(%rsp), %rdi
incq %rbx
addq $0x4, %r14
movl %ebp, %r12d
jmp 0x50062
cmpl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
je 0x502f6
cmpl $0x4, 0x68(%rsp)
jae 0x50189
movl %r12d, %ebx
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x43c0
movl %r12d, 0x60(%rsp)
movq 0x70(%rsp), %r14
jmp 0x5019a
movl 0x60(%rsp), %ebx
movl %ebx, %r12d
movq 0x70(%rsp), %r14
movq 0x10(%rsp), %rbp
addq %rbx, %rbp
movq 0x78(%rsp), %rdi
addq 0x28(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl %r12d, %edx
callq 0x50765
addl %eax, %r14d
movq 0x58(%rsp), %r9
incq %r9
movq 0x8(%rsp), %rsi
movl 0x4(%rsp), %edx
movq %rbp, %rbx
jmp 0x5001e
pushq $0x1
popq %rbx
movl 0x4(%rsp), %edx
movl %edx, %edi
andl $0x4, %edi
testl %esi, %esi
je 0x50207
movl %edx, %eax
andl $0x80, %eax
je 0x50207
leal 0x100(%rbx), %eax
cmpl (%rcx), %eax
jbe 0x5023a
movq %rcx, %r14
movq %r15, %rdi
callq 0x45c0
andl $0x0, (%r14)
jmp 0x4fdc6
testb %dl, %dl
jns 0x50210
andb $0x7f, (%r13)
xorl %r14d, %r14d
jmp 0x5033c
testl %edx, %edx
je 0x50233
incl %eax
movl %eax, %edi
addq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x43c0
movq 0x8(%rsp), %rcx
movl %ebx, (%rcx)
jmp 0x4fdc9
movl %edi, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
movl %ebx, %edx
addq %r13, %rdx
leaq 0x90(%rsp), %rcx
leaq 0x490(%rsp), %r8
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4e5a4
movq %rax, %r14
testq %rax, %rax
je 0x50323
movl 0x490(%rsp), %r12d
addl 0x90(%rsp), %ebx
leaq (%rbx,%r13), %rdi
movq 0x48(%rsp), %rsi
movl %r12d, %edx
callq 0x50765
movq %r12, %rsi
addl %eax, %ebx
movq 0x8(%rsp), %rcx
subl %eax, (%rcx)
movl 0x10(%rsp), %edi
testl %edi, %edi
sete %al
cmpl $0x20, %esi
setae %dl
orb %al, %dl
jne 0x50339
xorl %edi, %edi
movb $-0x5, %al
movq %r14, %rbp
jmp 0x50333
movq 0x20(%rsp), %rdi
callq 0x45c0
movq 0x28(%rsp), %r13
addq %r13, %r12
movq %rbx, %rdx
movq %r12, %rdi
movq 0x80(%rsp), %r12
subq %r12, %rdx
movq %r12, %rsi
callq 0x4830
movq %r15, %rdi
callq 0x45c0
addl %r14d, %ebx
subl %r12d, %ebx
jmp 0x50317
movq 0x20(%rsp), %rdi
callq 0x45c0
movq 0x40(%rsp), %rdi
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
xorl %ebx, %ebx
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movl %ebx, (%rax)
jmp 0x4fdc9
movb $0x7f, %al
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rsi
movl 0x10(%rsp), %edi
andb %al, (%r13)
jmp 0x5033c
movq %r14, %rbp
testb $0x40, 0x4(%rsp)
je 0x50567
testl %esi, %esi
je 0x50567
movl %edi, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
movq %rsi, %rbx
leal 0x101(%rsi), %edi
movl %edi, 0x3c(%rsp)
callq 0x4680
testq %rax, %rax
je 0x5066b
movq %r14, 0x30(%rsp)
movq %r15, 0x40(%rsp)
leaq 0x8c(%rsp), %r14
andl $0x0, (%r14)
movq %rbx, 0x18(%rsp)
movl %ebx, %esi
leaq 0x90(%rsp), %r10
leaq 0x60(%rsp), %rcx
leaq 0x490(%rsp), %r8
movq %rbp, %rdi
movq %rsi, 0x68(%rsp)
movq %rax, %r15
movq %rax, %rdx
movq %r14, %r9
pushq %r10
pushq $0x0
callq 0x61058
popq %rcx
popq %rdx
movq %rax, %rbx
movslq (%r14), %r14
leaq (%r15,%r14), %rdi
incq %rdi
movq %r15, %r12
incq %r12
leaq 0x60(%rsp), %rax
movq (%rax), %rdx
movq %r15, %rsi
movq %rdx, 0x28(%rsp)
callq 0x4830
movq %r15, 0x50(%rsp)
movb %r14b, (%r15)
movq %r12, %rdi
leaq 0x490(%rsp), %rsi
movq %r14, %rdx
callq 0x43c0
movq %rbx, %r15
testq %rbx, %rbx
je 0x5057d
movq 0x28(%rsp), %rax
leal (%r14,%rax), %ecx
incl %ecx
movl %ecx, %edx
movq 0x90(%rsp), %rax
addq %rdx, %rax
movq %rax, %xmm0
punpckldq 0x2732b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x27333(%rip), %xmm0    # 0x77770
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
cvtsi2sdq 0x68(%rsp), %xmm0
mulsd 0x2d6f8(%rip), %xmm0    # 0x7db50
ucomisd %xmm0, %xmm1
jae 0x5057d
movq %rdx, 0x68(%rsp)
movq %r13, %rax
movq 0x20(%rsp), %rbx
movl %ebx, %r13d
movq %rax, 0x28(%rsp)
addq %rax, %r13
leal (%rcx,%rcx), %edx
movq %r13, %rdi
movq %rcx, %r14
movq 0x48(%rsp), %r12
movq %r12, %rsi
movl %edx, 0x70(%rsp)
callq 0x50765
movslq %eax, %rbp
movq %r13, %rdi
addq %rbp, %rdi
movl 0x90(%rsp), %edx
movq %r12, %rsi
callq 0x50765
addl %eax, %ebp
leal (%rbx,%rbp), %ecx
addl $0x5, %ecx
movq 0x8(%rsp), %rdx
movl (%rdx), %eax
subl %ecx, %eax
jb 0x50682
movq %r14, 0x18(%rsp)
movl %eax, 0x3c(%rsp)
movl 0x10(%rsp), %edi
testl %edi, %edi
je 0x504ee
cmpl $0x20, 0x18(%rsp)
jb 0x504e6
cmpq $0x1f, 0x90(%rsp)
ja 0x504f0
movq 0x28(%rsp), %rax
andb $-0x5, (%rax)
xorl %edi, %edi
movl %edi, 0x10(%rsp)
xorl %esi, %esi
callq 0x50887
movslq %ebp, %rbx
leaq (%rbx,%r13), %rdx
addq $0x5, %rdx
leaq 0x3c(%rsp), %rcx
movq 0x50(%rsp), %rdi
movq 0x18(%rsp), %r14
movl %r14d, %esi
movq %rdx, 0x78(%rsp)
callq *%rax
testq %rax, %rax
movq 0x8(%rsp), %rdx
je 0x50682
movl 0x3c(%rsp), %edx
cmpl %r14d, %edx
jae 0x506f0
addq %rbx, %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x50765
movl %eax, %r12d
movslq %eax, %rdi
addq %r13, %rdi
movl 0x3c(%rsp), %ebx
movq 0x78(%rsp), %rsi
movq %rbx, %rdx
callq 0x4830
jmp 0x50739
movq %rsi, 0x18(%rsp)
testb $0x40, 0x4(%rsp)
je 0x50578
andb $-0x41, (%r13)
xorl %r12d, %r12d
jmp 0x505af
andb $-0x41, (%r13)
movq %r15, %rdi
callq 0x45c0
xorl %r12d, %r12d
movq 0x30(%rsp), %r14
movq 0x20(%rsp), %rbx
movq 0x50(%rsp), %rdi
callq 0x45c0
movq 0x8(%rsp), %rcx
movq 0x40(%rsp), %r15
movl 0x10(%rsp), %edi
movl (%rcx), %eax
subl %ebx, %eax
jae 0x505d0
movq %r15, %rdi
movq %rcx, %rbx
callq 0x45c0
movq %r12, %rdi
callq 0x45c0
movq %r14, %rdi
jmp 0x506a6
movl 0x4(%rsp), %esi
movl %eax, (%rcx)
andl $0x3, %esi
movq %r14, 0x30(%rsp)
movq %r12, 0x10(%rsp)
je 0x505f8
cmpl $0x7, 0x18(%rsp)
ja 0x505f8
andb $-0x2, (%r13)
movl 0x4(%rsp), %esi
andl $0x2, %esi
callq 0x50887
movq %rbx, 0x20(%rsp)
movl %ebx, %r14d
addq %r13, %r14
movq %rbp, %rdi
movq 0x18(%rsp), %r12
movl %r12d, %esi
movq %r14, %rdx
movq 0x8(%rsp), %rbx
movq %rbx, %rcx
callq *%rax
testq %rax, %rax
je 0x50673
cmpl %r12d, (%rbx)
jb 0x506d0
movb (%r13), %al
andb $-0x24, %al
movl 0x58(%rsp), %ecx
orb %al, %cl
orb $0x20, %cl
movb %cl, (%r13)
movl %r12d, %edx
leaq (%r14,%rdx), %rax
cmpq 0x48(%rsp), %rax
jbe 0x506b3
movq %r15, %rdi
callq 0x45c0
movq 0x10(%rsp), %rdi
callq 0x45c0
movq 0x30(%rsp), %rdi
jmp 0x4ff1e
movq %r15, %rdi
jmp 0x4ff1e
movq %r15, %rdi
callq 0x45c0
movq 0x10(%rsp), %rdi
jmp 0x5069c
movq 0x40(%rsp), %rdi
movq %rdx, %rbx
callq 0x45c0
movq %r15, %rdi
callq 0x45c0
movq 0x50(%rsp), %rdi
callq 0x45c0
movq 0x30(%rsp), %rdi
callq 0x45c0
andl $0x0, (%rbx)
jmp 0x4fdc6
testl %r12d, %r12d
je 0x506c8
movq %r14, %rdi
movq %rbp, %rsi
callq 0x43c0
movq 0x18(%rsp), %r12
movq 0x8(%rsp), %rbx
movl %r12d, (%rbx)
movq 0x10(%rsp), %rdi
callq 0x45c0
movq 0x30(%rsp), %rdi
callq 0x45c0
movq 0x20(%rsp), %rax
addl %eax, (%rbx)
jmp 0x4fdc9
movl 0x70(%rsp), %edx
orl $0x1, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x50765
movl %eax, %ebp
movslq %eax, %r14
addq %r13, %r14
movl 0x90(%rsp), %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x50765
movl %eax, %r12d
movslq %eax, %rdi
addq %r14, %rdi
movq 0x50(%rsp), %rsi
movq 0x68(%rsp), %rdx
callq 0x43c0
movq 0x18(%rsp), %rbx
addl 0x20(%rsp), %ebp
addl %ebx, %ebp
addl %r12d, %ebp
movl 0x90(%rsp), %eax
movq %rax, 0x18(%rsp)
movl %ebp, %ebx
movq %r15, %r12
movq %r15, %rbp
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %r14
jmp 0x50597