// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8a8, %rsp            # imm = 0x8A8
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, 0x30(%rsp)
pushq $0x1
popq %rsi
movl %r15d, %edi
movl %esi, %r12d
callq 0x4edbc
movl %eax, %ecx
leal -0x14(%rcx), %ebp
movq %rbx, (%rsp)
testq %rbx, %rbx
je 0x5158e
xorl %ebx, %ebx
cmpl (%r14), %ebp
jbe 0x515ae
jmp 0x51b5f
movl %ebp, (%r14)
movl %ebp, %edi
movq %rcx, %rbx
callq 0x4680
movq %rbx, %rcx
movq %rax, %rbx
movq %rax, (%rsp)
testq %rax, %rax
je 0x51b5d
movq %r15, 0x38(%rsp)
addl $-0x15, %ecx
testb $0x1, (%rsp)
cmovel %ebp, %ecx
movq %rcx, 0x50(%rsp)
movl $0x100000, %edi         # imm = 0x100000
callq 0x6412c
testq %rax, %rax
je 0x51771
movq %rax, %r15
movl $0x100, %edi            # imm = 0x100
movl $0x400, %esi            # imm = 0x400
callq 0x6426c
testq %rax, %rax
je 0x51b55
movq %rax, %r13
movq %r14, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x420, %edx            # imm = 0x420
xorl %esi, %esi
callq 0x4260
movq 0x38(%rsp), %rdx
movl %edx, %eax
movl %edx, %ecx
shrl $0x2, %ecx
movq 0x30(%rsp), %rbx
movq %rax, 0x58(%rsp)
leaq (%rbx,%rax), %r14
movq %rcx, 0x48(%rsp)
movl %ecx, %r10d
cmpl $0x7a120, %edx          # imm = 0x7A120
movq %r15, 0x28(%rsp)
movq %r10, 0x70(%rsp)
jbe 0x5177e
movl $0x100, %edi            # imm = 0x100
movl $0x40c, %esi            # imm = 0x40C
callq 0x6426c
testq %rax, %rax
je 0x51b43
leaq -0x8(%r14), %rdx
xorl %esi, %esi
movq %rbx, %rcx
cmpq %rdx, %rcx
jae 0x5170f
movzbl (%rcx), %r8d
movzbl 0x1(%rcx), %r9d
movzbl 0x2(%rcx), %r10d
movzbl 0x3(%rcx), %edi
movzbl %sil, %esi
shll $0xa, %esi
addq %r13, %rsi
incl (%rsi,%r8,4)
imulq $0x40c, %r8, %rsi       # imm = 0x40C
addq %rax, %rsi
incl (%rsi,%r9,4)
shll $0xa, %r9d
addq %r13, %r9
incl (%r9,%r10,4)
imulq $0x40c, %r10, %rsi      # imm = 0x40C
addq %rax, %rsi
incl (%rsi,%rdi,4)
movzbl 0x4(%rcx), %r8d
movzbl 0x5(%rcx), %r9d
movzbl 0x6(%rcx), %r10d
movzbl 0x7(%rcx), %esi
shll $0xa, %edi
addq %r13, %rdi
incl (%rdi,%r8,4)
imulq $0x40c, %r8, %rdi       # imm = 0x40C
addq %rax, %rdi
incl (%rdi,%r9,4)
addq $0x8, %rcx
shll $0xa, %r9d
addq %r13, %r9
incl (%r9,%r10,4)
imulq $0x40c, %r10, %rdi      # imm = 0x40C
addq %rax, %rdi
incl (%rdi,%rsi,4)
jmp 0x51665
movzbl (%rcx), %esi
incq %rcx
shll $0xa, %edx
addq %r13, %rdx
incl (%rdx,%rsi,4)
movzbl %sil, %edx
cmpq %r14, %rcx
jb 0x51700
incl 0x80(%rsp,%rdx,4)
xorl %ecx, %ecx
movq %rax, %rdx
movq %r13, %rsi
cmpq $0x100, %rcx            # imm = 0x100
je 0x51864
xorl %edi, %edi
xorl %r8d, %r8d
cmpq $0x100, %rdi            # imm = 0x100
je 0x51756
movl (%rsi,%rdi,4), %r9d
addl (%rdx,%rdi,4), %r9d
movl %r9d, (%rsi,%rdi,4)
addl %r9d, %r8d
incq %rdi
jmp 0x51739
addl %r8d, 0x80(%rsp,%rcx,4)
incq %rcx
addq $0x400, %rsi            # imm = 0x400
addq $0x40c, %rdx            # imm = 0x40C
jmp 0x51727
movq %rbx, %rdi
callq 0x45c0
jmp 0x51b5d
leaq -0x8(%r14), %rcx
xorl %edx, %edx
movq %rbx, %rax
cmpq %rcx, %rax
jae 0x51820
movzbl (%rax), %edi
movzbl 0x1(%rax), %r8d
movzbl 0x2(%rax), %r9d
movzbl 0x3(%rax), %esi
movzbl %dl, %edx
shll $0xa, %edx
addq %r13, %rdx
incl (%rdx,%rdi,4)
shll $0xa, %edi
addq %r13, %rdi
incl (%rdi,%r8,4)
shll $0xa, %r8d
addq %r13, %r8
incl (%r8,%r9,4)
shll $0xa, %r9d
addq %r13, %r9
incl (%r9,%rsi,4)
movzbl 0x4(%rax), %r8d
movzbl 0x5(%rax), %r9d
movzbl 0x6(%rax), %edi
movzbl 0x7(%rax), %edx
shll $0xa, %esi
addq %r13, %rsi
incl (%rsi,%r8,4)
shll $0xa, %r8d
addq %r13, %r8
incl (%r8,%r9,4)
addq $0x8, %rax
shll $0xa, %r9d
addq %r13, %r9
incl (%r9,%rdi,4)
shll $0xa, %edi
addq %r13, %rdi
incl (%rdi,%rdx,4)
jmp 0x51787
movzbl (%rax), %edx
incq %rax
shll $0xa, %ecx
addq %r13, %rcx
incl (%rcx,%rdx,4)
movzbl %dl, %ecx
cmpq %r14, %rax
jb 0x51811
incl 0x80(%rsp,%rcx,4)
xorl %eax, %eax
movq %r13, %rcx
cmpq $0x100, %rax            # imm = 0x100
je 0x51871
xorl %edx, %edx
xorl %esi, %esi
cmpq $0x100, %rdx            # imm = 0x100
je 0x51851
addl (%rcx,%rdx,4), %esi
incq %rdx
jmp 0x51840
addl %esi, 0x80(%rsp,%rax,4)
incq %rax
addq $0x400, %rcx            # imm = 0x400
jmp 0x51834
movq %rax, %rdi
callq 0x64291
movq 0x70(%rsp), %r10
leaq (%rbx,%r10), %rax
pushq $0x3
popq %rcx
subq $0x1, %rcx
jb 0x5188b
movzbl (%rax), %edx
incl (%r13,%rdx,4)
addq %r10, %rax
jmp 0x51878
leaq 0x80(%rsp), %r14
movl (%r14), %ebx
addl $0x3, %ebx
movl %r12d, %ebp
movl %r12d, (%r14)
movq (%rsp), %rax
movq %r15, %r12
movq %rax, %r15
leaq 0x1(%rax), %rdi
movb $0x0, (%rax)
movq %rdi, 0x68(%rsp)
movq %r14, %rsi
callq 0x513f2
cltq
addq %r15, %rax
incq %rax
movq %rax, 0x10(%rsp)
movl %ebx, (%r14)
leaq 0x4a0(%rsp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x4260
movq %r14, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x4fa19
movl %eax, %r15d
movl %r15d, %ecx
shll %cl, %ebp
movl %ebp, 0x20(%rsp)
movq %r12, %rax
xorl %r12d, %r12d
movq %r13, %rbx
movq %r13, 0x60(%rsp)
cmpq $0x100, %r12            # imm = 0x100
je 0x51a7e
movl 0x80(%rsp,%r12,4), %esi
testl %esi, %esi
je 0x51a69
movq %rax, 0x18(%rsp)
movl 0x4a0(%rsp,%r12,4), %eax
movl $0x400, %ecx            # imm = 0x400
cmpl %ecx, %eax
movl $0x400, %r14d           # imm = 0x400
cmovbl %eax, %r14d
cmpl $0xa, %r15d
cmovnel %eax, %r14d
movq %r12, %rbp
shlq $0xa, %rbp
addq %r13, %rbp
movq %rbp, %rdi
movl %r14d, %edx
callq 0x4f3d2
testl %eax, %eax
js 0x51b32
movq %r12, 0x40(%rsp)
movl %r14d, 0x80(%rsp,%r12,4)
xorl %r13d, %r13d
movq 0x10(%rsp), %r14
xorl %r12d, %r12d
cmpq $0x100, %r13            # imm = 0x100
je 0x519de
cmpl $0x0, 0x80(%rsp,%r13,4)
je 0x519d9
movl (%rbx,%r13,4), %edx
testl %edx, %edx
je 0x519cf
testl %r12d, %r12d
je 0x519bb
decl %r12d
movslq %r12d, %rax
subq %rax, %r14
movb %al, (%r14)
incq %r14
movl (%rbx,%r13,4), %edx
xorl %r12d, %r12d
movq %r14, %rdi
xorl %esi, %esi
callq 0x50765
cltq
addq %rax, %r14
jmp 0x519d9
incl %r12d
movb $0x0, (%r14)
incq %r14
incq %r13
jmp 0x51987
testl %r12d, %r12d
je 0x519f2
decl %r12d
movslq %r12d, %rax
subq %rax, %r14
movb %al, (%r14)
incq %r14
subl 0x10(%rsp), %r14d
shlq $0x20, %r14
movq 0x40(%rsp), %r12
movl 0x80(%rsp,%r12,4), %esi
movq %rbp, %rdi
movl 0x20(%rsp), %ebp
movl %ebp, %edx
callq 0x4f9ec
movl %ebp, 0x80(%rsp,%r12,4)
xorl %r12d, %r12d
movq 0x18(%rsp), %rbp
xorl %r13d, %r13d
cmpq $0x100, %r12            # imm = 0x100
je 0x51a51
movl (%rbx,%r12,4), %edx
movq %rbp, %rdi
movl %r13d, %esi
movl %r15d, %ecx
callq 0x4f4f5
addl (%rbx,%r12,4), %r13d
incq %r12
addq $0x10, %rbp
jmp 0x51a29
sarq $0x20, %r14
addq %r14, 0x10(%rsp)
movq 0x60(%rsp), %r13
movq 0x40(%rsp), %r12
movq 0x18(%rsp), %rax
incq %r12
addq $0x400, %rbx            # imm = 0x400
addq $0x1000, %rax           # imm = 0x1000
jmp 0x5190f
shlb $0x4, %r15b
movq (%rsp), %rax
movb %r15b, (%rax)
movq 0x10(%rsp), %r14
movq %r14, %rbx
subq %rax, %rbx
cmpq $0x3e9, %rbx            # imm = 0x3E9
jl 0x51b3a
movl %r14d, %ebp
movq 0x68(%rsp), %rdi
subl %edi, %ebp
leaq 0xc(%rsp), %rcx
movl %ebp, %esi
xorl %edx, %edx
callq 0x4ee61
movq %rax, %r14
testq %rax, %rax
je 0x51b1c
movl 0xc(%rsp), %r15d
leal 0x6(%r15), %eax
cmpq %rax, %rbx
jbe 0x51b1c
movq (%rsp), %rax
orb $0x1, (%rax)
movq 0x68(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x50765
movq %r13, %rbx
movslq %eax, %r13
addq %r12, %r13
movq %r13, %rdi
xorl %esi, %esi
movl %r15d, %edx
callq 0x50765
movslq %eax, %r12
addq %r13, %r12
movq %rbx, %r13
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, %r12
movq %r12, 0x10(%rsp)
movq %r14, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq 0x28(%rsp), %r15
movq 0x10(%rsp), %r14
jmp 0x51b49
movb $0x1, %bl
movq (%rsp), %r14
jmp 0x51b3c
xorl %ebx, %ebx
movq 0x28(%rsp), %r15
jmp 0x51b49
movb $0x1, %bl
movq (%rsp), %r14
movq %r13, %rdi
callq 0x64291
testb %bl, %bl
je 0x51b74
movq %r15, %rdi
callq 0x64291
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8a8, %rsp            # imm = 0x8A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x10(%rsp)
movq 0x50(%rsp), %rcx
addq (%rsp), %rcx
movl $0x8000, %eax           # imm = 0x8000
movl %eax, 0x4a0(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x80(%rsp), %rax
movq %rcx, 0x50(%rsp)
movq %rcx, (%rax)
movq 0x70(%rsp), %rdi
leaq (%rdi,%rdi,2), %r10
movq 0x38(%rsp), %rsi
movl %esi, %eax
andl $-0x4, %eax
addl $-0x2, %eax
movq 0x30(%rsp), %rdx
movq 0x48(%rsp), %rcx
movb -0x1(%rdx,%rcx), %bl
movb -0x1(%rdx,%rdi,2), %r14b
movq %r10, 0x18(%rsp)
movb -0x1(%rdx,%r10), %r13b
leal -0x1(%rsi), %ecx
movb (%rdx,%rcx), %dl
addl $-0x2, %esi
movslq %esi, %r12
movslq %eax, %rbp
cmpq %rbp, %r12
jle 0x51c2c
movq 0x30(%rsp), %rax
movzbl (%rax,%r12), %r15d
movl %r15d, %eax
shll $0xc, %eax
movzbl %dl, %edx
shll $0x4, %edx
addq 0x28(%rsp), %rdx
addq %rax, %rdx
leaq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x4f5c0
decq %r12
movl %r15d, %edx
jmp 0x51bef
movq 0x48(%rsp), %rcx
addl $-0x2, %ecx
movq 0x18(%rsp), %rax
addl $-0x2, %eax
cltq
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rax
shrl %eax
andl $-0x2, %eax
movq %rax, 0x58(%rsp)
movq 0x30(%rsp), %rax
movzbl %dl, %edx
movzbl %r13b, %ebp
movzbl %r14b, %r14d
movzbl %bl, %ebx
testl %ecx, %ecx
js 0x51d5b
movzbl (%rax,%r12), %edi
movl %edi, 0x40(%rsp)
movq %rax, 0x18(%rsp)
movl %edi, %eax
shll $0xc, %eax
shll $0x4, %edx
movq 0x28(%rsp), %rdi
addq %rdi, %rdx
addq %rax, %rdx
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %r8
movzbl (%r8,%rax), %eax
movl %eax, 0x60(%rsp)
shll $0xc, %eax
shll $0x4, %ebp
addq %rdi, %rbp
addq %rax, %rbp
movq 0x58(%rsp), %rax
movq 0x18(%rsp), %r8
movzbl -0x2(%r8,%rax), %eax
movl %eax, 0x20(%rsp)
shll $0xc, %eax
shll $0x4, %r14d
addq %rdi, %r14
addq %rax, %r14
movl %ecx, %eax
movq %rcx, 0x48(%rsp)
movq 0x30(%rsp), %rcx
movzbl (%rcx,%rax), %r13d
movl %r13d, %eax
shll $0xc, %eax
shll $0x4, %ebx
addq %rdi, %rbx
addq %rax, %rbx
leaq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %r15
movq %r15, %rsi
callq 0x4f5c0
leaq 0x24(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x4f5c0
leaq 0xc(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4f5c0
leaq 0x4a0(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4f5c0
movq 0x18(%rsp), %rax
movl %r13d, %ebx
movl 0x20(%rsp), %r14d
movl 0x40(%rsp), %edx
movl 0x60(%rsp), %r13d
movq 0x48(%rsp), %rcx
decl %ecx
decq %rax
jmp 0x51c57
movq (%rsp), %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %r12
subq %rax, %r12
shll $0x4, %edx
movq 0x28(%rsp), %r13
addq %r13, %rdx
leaq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %r15
movq %r15, %rsi
callq 0x4f5c0
shll $0x4, %ebp
addq %r13, %rbp
leaq 0x24(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x4f5c0
shll $0x4, %r14d
addq %r13, %r14
leaq 0xc(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4f5c0
shll $0x4, %ebx
addq %r13, %rbx
leaq 0x4a0(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4f5c0
leaq 0x8(%rsp), %rax
movl (%rax), %eax
movq (%r15), %rsi
movl %eax, -0x4(%rsi)
leaq 0x24(%rsp), %rax
movl (%rax), %eax
movl %eax, -0x8(%rsi)
movl (%rbp), %eax
movl %eax, -0xc(%rsi)
movl (%r14), %eax
movl %eax, -0x10(%rsi)
addq $-0x10, %rsi
movq 0x50(%rsp), %rdx
subq %rsi, %rdx
movl %r12d, %edi
addl %edx, %r12d
movq 0x78(%rsp), %rax
movl %r12d, (%rax)
movq (%rsp), %rbx
addq %rbx, %rdi
callq 0x4830
movq %r13, %rdi
callq 0x64291
jmp 0x51b5f