// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/rANS_static4x16pr.c
// Function: rans_compress_O1_4x16
static
unsigned char *rans_compress_O1_4x16(unsigned char *in, unsigned int in_size,
                                     unsigned char *out, unsigned int *out_size) {
    unsigned char *cp, *out_end, *out_free = NULL;
    unsigned int tab_size;
    
    // -20 for order/size/meta
    uint32_t bound = rans_compress_bound_4x16(in_size,1)-20;

    if (!out) {
        *out_size = bound;
        out_free = out = malloc(*out_size);
    }
    if (!out || bound > *out_size)
        return NULL;

    if (((size_t)out)&1)
        bound--;
    out_end = out + bound;

    RansEncSymbol (*syms)[256] = htscodecs_tls_alloc(256 * (sizeof(*syms)));
    if (!syms) {
        free(out_free);
        return NULL;
    }

    cp = out;
    int shift = encode_freq1(in, in_size, 4, syms, &cp); 
    if (shift < 0) {
        htscodecs_tls_free(syms);
        return NULL;
    }
    tab_size = cp - out;

    RansState rans0, rans1, rans2, rans3;
    RansEncInit(&rans0);
    RansEncInit(&rans1);
    RansEncInit(&rans2);
    RansEncInit(&rans3);

    uint8_t* ptr = out_end;

    int isz4 = in_size>>2;
    int i0 = 1*isz4-2;
    int i1 = 2*isz4-2;
    int i2 = 3*isz4-2;
    int i3 = 4*isz4-2;

    unsigned char l0 = in[i0+1];
    unsigned char l1 = in[i1+1];
    unsigned char l2 = in[i2+1];
    unsigned char l3 = in[i3+1];

    // Deal with the remainder
    l3 = in[in_size-1];
    for (i3 = in_size-2; i3 > 4*isz4-2; i3--) {
        unsigned char c3 = in[i3];
        RansEncPutSymbol(&rans3, &ptr, &syms[c3][l3]);
        l3 = c3;
    }

    for (; i0 >= 0; i0--, i1--, i2--, i3--) {
        unsigned char c0, c1, c2, c3;
        RansEncSymbol *s3 = &syms[c3 = in[i3]][l3];
        RansEncSymbol *s2 = &syms[c2 = in[i2]][l2];
        RansEncSymbol *s1 = &syms[c1 = in[i1]][l1];
        RansEncSymbol *s0 = &syms[c0 = in[i0]][l0];

        RansEncPutSymbol(&rans3, &ptr, s3);
        RansEncPutSymbol(&rans2, &ptr, s2);
        RansEncPutSymbol(&rans1, &ptr, s1);
        RansEncPutSymbol(&rans0, &ptr, s0);

        l0 = c0;
        l1 = c1;
        l2 = c2;
        l3 = c3;
    }

    RansEncPutSymbol(&rans3, &ptr, &syms[0][l3]);
    RansEncPutSymbol(&rans2, &ptr, &syms[0][l2]);
    RansEncPutSymbol(&rans1, &ptr, &syms[0][l1]);
    RansEncPutSymbol(&rans0, &ptr, &syms[0][l0]);

    RansEncFlush(&rans3, &ptr);
    RansEncFlush(&rans2, &ptr);
    RansEncFlush(&rans1, &ptr);
    RansEncFlush(&rans0, &ptr);

    *out_size = (out_end - ptr) + tab_size;

    cp = out;
    memmove(out + tab_size, ptr, out_end-ptr);

    htscodecs_tls_free(syms);
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movl -0x14(%rbp), %edi
movl $0x1, %esi
callq 0x8e2d0
subl $0x14, %eax
movl %eax, -0x48(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x92f6a
movl -0x48(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
callq 0x4650
movq %rax, -0x20(%rbp)
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x92f7c
movl -0x48(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jbe 0x92f89
movq $0x0, -0x8(%rbp)
jmp 0x93407
movq -0x20(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x92fa0
movl -0x48(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movl -0x48(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl $0x100000, %edi         # imm = 0x100000
callq 0xce6a0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x92fd9
movq -0x40(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x93407
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x50(%rbp), %rcx
movl $0x4, %edx
leaq -0x30(%rbp), %r8
callq 0x93420
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jge 0x93019
movq -0x50(%rbp), %rdi
callq 0xce8f0
movq $0x0, -0x8(%rbp)
jmp 0x93407
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x44(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x8f300
leaq -0x5c(%rbp), %rdi
callq 0x8f300
leaq -0x60(%rbp), %rdi
callq 0x8f300
leaq -0x64(%rbp), %rdi
callq 0x8f300
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x14(%rbp), %eax
shrl $0x2, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
shll $0x0, %eax
subl $0x2, %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
shll %eax
subl $0x2, %eax
movl %eax, -0x7c(%rbp)
imull $0x3, -0x74(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x80(%rbp)
movl -0x74(%rbp), %eax
shll $0x2, %eax
subl $0x2, %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movl -0x78(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movq -0x10(%rbp), %rax
movl -0x7c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x86(%rbp)
movq -0x10(%rbp), %rax
movl -0x80(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x87(%rbp)
movq -0x10(%rbp), %rax
movl -0x84(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x88(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x88(%rbp)
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl -0x74(%rbp), %ecx
shll $0x2, %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jle 0x93179
movq -0x10(%rbp), %rax
movslq -0x84(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x89(%rbp)
movq -0x50(%rbp), %rdx
movzbl -0x89(%rbp), %eax
shlq $0xc, %rax
addq %rax, %rdx
movzbl -0x88(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdx
leaq -0x64(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movb -0x89(%rbp), %al
movb %al, -0x88(%rbp)
movl -0x84(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x93108
jmp 0x9317b
cmpl $0x0, -0x78(%rbp)
jl 0x93307
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x84(%rbp), %rdx
movb (%rcx,%rdx), %cl
movb %cl, -0x8d(%rbp)
movzbl %cl, %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movzbl -0x88(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x80(%rbp), %rdx
movb (%rcx,%rdx), %cl
movb %cl, -0x8c(%rbp)
movzbl %cl, %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movzbl -0x87(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x7c(%rbp), %rdx
movb (%rcx,%rdx), %cl
movb %cl, -0x8b(%rbp)
movzbl %cl, %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movzbl -0x86(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x78(%rbp), %rdx
movb (%rcx,%rdx), %cl
movb %cl, -0x8a(%rbp)
movzbl %cl, %ecx
shlq $0xc, %rcx
addq %rcx, %rax
movzbl -0x85(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0x98(%rbp), %rdx
leaq -0x64(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movq -0xa0(%rbp), %rdx
leaq -0x60(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movq -0xa8(%rbp), %rdx
leaq -0x5c(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movq -0xb0(%rbp), %rdx
leaq -0x58(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movb -0x8a(%rbp), %al
movb %al, -0x85(%rbp)
movb -0x8b(%rbp), %al
movb %al, -0x86(%rbp)
movb -0x8c(%rbp), %al
movb %al, -0x87(%rbp)
movb -0x8d(%rbp), %al
movb %al, -0x88(%rbp)
movl -0x78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x78(%rbp)
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x80(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x80(%rbp)
movl -0x84(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x9317b
movq -0x50(%rbp), %rdx
movzbl -0x88(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdx
leaq -0x64(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movq -0x50(%rbp), %rdx
movzbl -0x87(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdx
leaq -0x60(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movq -0x50(%rbp), %rdx
movzbl -0x86(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdx
leaq -0x5c(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
movq -0x50(%rbp), %rdx
movzbl -0x85(%rbp), %eax
shlq $0x4, %rax
addq %rax, %rdx
leaq -0x58(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f320
leaq -0x64(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f3e0
leaq -0x60(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f3e0
leaq -0x5c(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f3e0
leaq -0x58(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x8f3e0
movq -0x38(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rcx, %rax
movl -0x44(%rbp), %ecx
addq %rcx, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %eax
addq %rax, %rdi
movq -0x70(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x70(%rbp), %rax
subq %rax, %rdx
callq 0x4810
movq -0x50(%rbp), %rdi
callq 0xce8f0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)