// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/cram/rANS_static.c
// Function: rans_compress_O0
unsigned char *rans_compress_O0(unsigned char *in, unsigned int in_size,
				unsigned int *out_size) {
    unsigned char *out_buf = malloc(1.05*in_size + 257*257*3 + 9);
    unsigned char *cp, *out_end;
    RansEncSymbol syms[256];
    RansState rans0, rans1, rans2, rans3;
    uint8_t* ptr;
    int F[256] = {0}, i, j, tab_size, rle, x, fsum = 0;
    int m = 0, M = 0;
    uint64_t tr;

    if (!out_buf)
	return NULL;

    ptr = out_end = out_buf + (int)(1.05*in_size) + 257*257*3 + 9;

    // Compute statistics
    for (i = 0; i < in_size; i++) {
	F[in[i]]++;
    }
    tr = ((uint64_t)TOTFREQ<<31)/in_size + (1<<30)/in_size;

    // Normalise so T[i] == TOTFREQ
    for (m = M = j = 0; j < 256; j++) {
	if (!F[j])
	    continue;

	if (m < F[j])
	    m = F[j], M = j;

	if ((F[j] = (F[j]*tr)>>31) == 0)
	    F[j] = 1;
	fsum += F[j];
    }

    fsum++;
    if (fsum < TOTFREQ)
	F[M] += TOTFREQ-fsum;
    else
	F[M] -= fsum-TOTFREQ;

    //printf("F[%d]=%d\n", M, F[M]);
    assert(F[M]>0);

    // Encode statistics.
    cp = out_buf+9;

    for (x = rle = j = 0; j < 256; j++) {
	if (F[j]) {
	    // j
	    if (rle) {
		rle--;
	    } else {
		*cp++ = j;
		if (!rle && j && F[j-1])  {
		    for(rle=j+1; rle<256 && F[rle]; rle++)
			;
		    rle -= j+1;
		    *cp++ = rle;
		}
		//fprintf(stderr, "%d: %d %d\n", j, rle, N[j]);
	    }

	    // F[j]
	    if (F[j]<128) {
		*cp++ = F[j];
	    } else {
		*cp++ = 128 | (F[j]>>8);
		*cp++ = F[j]&0xff;
	    }
	    RansEncSymbolInit(&syms[j], x, F[j], TF_SHIFT);
	    x += F[j];
	}
    }
    *cp++ = 0;

    //write(1, out_buf+4, cp-(out_buf+4));
    tab_size = cp-out_buf;

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

    switch (i=(in_size&3)) {
    case 3: RansEncPutSymbol(&rans2, &ptr, &syms[in[in_size-(i-2)]]);
    case 2: RansEncPutSymbol(&rans1, &ptr, &syms[in[in_size-(i-1)]]);
    case 1: RansEncPutSymbol(&rans0, &ptr, &syms[in[in_size-(i-0)]]);
    case 0:
	break;
    }
    for (i=(in_size &~3); i>0; i-=4) {
	RansEncSymbol *s3 = &syms[in[i-1]];
	RansEncSymbol *s2 = &syms[in[i-2]];
	RansEncSymbol *s1 = &syms[in[i-3]];
	RansEncSymbol *s0 = &syms[in[i-4]];

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

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

    // Finalise block size and return it
    *out_size = (out_end - ptr) + tab_size;

    cp = out_buf;

    *cp++ = 0; // order
    *cp++ = ((*out_size-9)>> 0) & 0xff;
    *cp++ = ((*out_size-9)>> 8) & 0xff;
    *cp++ = ((*out_size-9)>>16) & 0xff;
    *cp++ = ((*out_size-9)>>24) & 0xff;

    *cp++ = (in_size>> 0) & 0xff;
    *cp++ = (in_size>> 8) & 0xff;
    *cp++ = (in_size>>16) & 0xff;
    *cp++ = (in_size>>24) & 0xff;

    memmove(out_buf + tab_size, ptr, out_end-ptr);

    return out_buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1438, %rsp           # imm = 0x1438
movq %rdx, %r13
movl %esi, %r14d
movq %rdi, %r15
movl %esi, %ebx
cvtsi2sd %rbx, %xmm1
mulsd 0x334a3(%rip), %xmm1    # 0x92da0
movsd 0x39dab(%rip), %xmm0    # 0x996b0
movsd %xmm1, (%rsp)
addsd %xmm1, %xmm0
addsd 0x39da2(%rip), %xmm0    # 0x996b8
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x388a6(%rip), %xmm0    # 0x981d0
cvttsd2si %xmm0, %rdi
andq %rcx, %rdi
orq %rax, %rdi
callq 0x69d0
movq %rax, %r12
leaq 0x30(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x63b0
testq %r12, %r12
je 0x5ff3c
cvttsd2si (%rsp), %ecx
movslq %ecx, %rdi
xorl %esi, %esi
movq %r14, (%rsp)
testl %r14d, %r14d
je 0x5f97f
xorl %ecx, %ecx
movzbl (%r15,%rcx), %edx
incl 0x30(%rsp,%rdx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0x5f96c
jmp 0x5f981
xorl %ebx, %ebx
movq %r12, 0x8(%rsp)
leaq (%r12,%rdi), %rbp
addq $0x3060c, %rbp          # imm = 0x3060C
movabsq $0x80000000000, %rax    # imm = 0x80000000000
xorl %edx, %edx
divq %rbx
movq %rax, %rcx
movl $0x40000000, %eax       # imm = 0x40000000
xorl %edx, %edx
divl (%rsp)
addq %rcx, %rax
movl $0x1, %ecx
xorl %edi, %edi
xorl %r8d, %r8d
xorl %edx, %edx
movslq 0x30(%rsp,%rdi,4), %r9
testq %r9, %r9
je 0x5f9eb
cmpl %r9d, %r8d
cmovlel %r9d, %r8d
cmovll %edi, %esi
imulq %rax, %r9
shrq $0x1f, %r9
cmpl $0x2, %r9d
cmovbl %ecx, %r9d
movl %r9d, 0x30(%rsp,%rdi,4)
addl %edx, %r9d
movl %r9d, %edx
incq %rdi
cmpq $0x100, %rdi            # imm = 0x100
jne 0x5f9bc
movslq %esi, %rax
movl 0x30(%rsp,%rax,4), %ecx
subl %edx, %ecx
addl $0xfff, %ecx            # imm = 0xFFF
movl %ecx, 0x30(%rsp,%rax,4)
testl %ecx, %ecx
jle 0x5ffae
movq 0x8(%rsp), %rax
leaq 0x9(%rax), %r14
xorl %edi, %edi
movl $0x1, %r10d
xorl %ebx, %ebx
xorl %r11d, %r11d
cmpl $0x0, 0x30(%rsp,%rdi,4)
je 0x5fb1e
testl %ebx, %ebx
je 0x5fb33
decl %ebx
movq %r14, %r12
movl 0x30(%rsp,%rdi,4), %eax
movl $0x1, %r9d
cmpl $0x80, %eax
jge 0x5fa56
movq %r12, %rcx
jmp 0x5fa6e
shrl $0x8, %eax
orb $-0x80, %al
leaq 0x1(%r12), %rcx
movb %al, (%r12)
movl 0x30(%rsp,%rdi,4), %eax
movl $0x2, %r9d
movb %al, (%rcx)
cmpl $0x1001, %r11d          # imm = 0x1001
jae 0x5ff8f
movl 0x30(%rsp,%rdi,4), %r14d
movl $0x1000, %eax           # imm = 0x1000
subl %r11d, %eax
cmpl %r14d, %eax
jb 0x5ff70
movq %rdi, %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %r8
addq $0x430, %r8             # imm = 0x430
movl %r14d, %eax
shll $0x13, %eax
movl %eax, (%r8)
movl $0x1000, %eax           # imm = 0x1000
subl %r14d, %eax
movw %ax, 0xc(%r8)
cmpl $0x2, %r14d
jae 0x5fada
movl $0xffffffff, 0x4(%r8)   # imm = 0xFFFFFFFF
leal 0xfff(%r11), %eax
movl %eax, 0x8(%r8)
movw $0x20, %si
jmp 0x5fb0d
movl $0x1e, %esi
leal -0x1e(%rsi), %ecx
movl $0x1, %eax
shll %cl, %eax
incl %esi
cmpl %r14d, %eax
jb 0x5fadf
movl $0x1, %eax
movl %esi, %ecx
shlq %cl, %rax
addq %r14, %rax
decq %rax
xorl %edx, %edx
divq %r14
movl %eax, 0x4(%r8)
movl %r11d, 0x8(%r8)
addq %r9, %r12
movw %si, 0xe(%r8)
addl %r11d, %r14d
movl %r14d, %r11d
movq %r12, %r14
incq %rdi
incq %r10
cmpq $0x100, %rdi            # imm = 0x100
jne 0x5fa28
jmp 0x5fb88
leaq 0x1(%r14), %r12
movb %dil, (%r14)
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x5fa40
cmpl $0x0, 0x2c(%rsp,%rdi,4)
je 0x5fa40
leal 0x1(%rdi), %eax
movl %eax, %ebx
cmpq $0xff, %rdi
je 0x5fb79
movq %r10, %rbx
cmpl $0x0, 0x30(%rsp,%rbx,4)
je 0x5fb79
incq %rbx
cmpq $0x100, %rbx            # imm = 0x100
jne 0x5fb61
movl $0x100, %ebx            # imm = 0x100
subl %eax, %ebx
movb %bl, 0x1(%r14)
addq $0x2, %r14
jmp 0x5fa3d
movq %r13, %r11
movb $0x0, (%r14)
movq (%rsp), %r9
movl %r9d, %esi
andl $0x3, %esi
movl $0x800000, %r13d        # imm = 0x800000
leaq 0x39b22(%rip), %rax     # 0x996c8
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
movq %rbp, %rdx
movl $0x800000, %eax         # imm = 0x800000
jmpq *%rcx
movl %r9d, %esi
andl $-0x4, %esi
movl $0x800000, %ebx         # imm = 0x800000
movq %rbp, %rdx
jmp 0x5fcef
leal -0x1(%r9), %eax
movzbl (%r15,%rax), %eax
shll $0x4, %eax
movl 0x430(%rsp,%rax), %ecx
testl %ecx, %ecx
je 0x5ff51
leaq (%rsp,%rax), %rdi
addq $0x430, %rdi            # imm = 0x430
movl $0x800000, %eax         # imm = 0x800000
movq %rbp, %rdx
cmpl $0x800000, %ecx         # imm = 0x800000
ja 0x5fc10
movq %rbp, %rdx
movb %al, -0x1(%rdx)
decq %rdx
shrl $0x8, %eax
cmpl %ecx, %eax
jae 0x5fc03
movl %eax, %ecx
movl 0x4(%rdi), %r8d
imulq %rcx, %r8
movb 0xe(%rdi), %cl
shrq %cl, %r8
addl 0x8(%rdi), %eax
movzwl 0xc(%rdi), %r13d
imull %r8d, %r13d
addl %eax, %r13d
movl %r9d, %eax
subl %esi, %eax
incl %eax
movzbl (%r15,%rax), %eax
shll $0x4, %eax
movl 0x430(%rsp,%rax), %ecx
testl %ecx, %ecx
je 0x5ff51
addq %rsp, %rax
addq $0x430, %rax            # imm = 0x430
movl $0x800000, %esi         # imm = 0x800000
cmpl $0x800000, %ecx         # imm = 0x800000
ja 0x5fc71
movb %sil, -0x1(%rdx)
decq %rdx
shrl $0x8, %esi
cmpl %ecx, %esi
jae 0x5fc63
movl %esi, %ecx
movl 0x4(%rax), %edi
imulq %rcx, %rdi
movb 0xe(%rax), %cl
shrq %cl, %rdi
addl 0x8(%rax), %esi
movzwl 0xc(%rax), %eax
imull %edi, %eax
addl %esi, %eax
movl %r9d, %esi
andl $-0x4, %esi
movzbl (%r15,%rsi), %edi
shll $0x4, %edi
movl 0x430(%rsp,%rdi), %ecx
testl %ecx, %ecx
je 0x5ff51
leaq (%rsp,%rdi), %r8
addq $0x430, %r8             # imm = 0x430
movl $0x800000, %edi         # imm = 0x800000
cmpl $0x800000, %ecx         # imm = 0x800000
ja 0x5fccf
movb %dil, -0x1(%rdx)
decq %rdx
shrl $0x8, %edi
cmpl %ecx, %edi
jae 0x5fcc1
movl %edi, %ecx
movl 0x4(%r8), %r10d
imulq %rcx, %r10
movb 0xe(%r8), %cl
shrq %cl, %r10
addl 0x8(%r8), %edi
movzwl 0xc(%r8), %ebx
imull %r10d, %ebx
addl %edi, %ebx
movq %r14, 0x10(%rsp)
testl %esi, %esi
movq %r11, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
jle 0x5fe7e
movl %esi, %edi
movl $0x800000, %esi         # imm = 0x800000
movq %r15, 0x28(%rsp)
movzbl -0x1(%r15,%rdi), %ecx
shll $0x4, %ecx
movl 0x430(%rsp,%rcx), %r10d
testl %r10d, %r10d
je 0x5ff51
movzbl -0x2(%r15,%rdi), %r8d
movzbl -0x3(%r15,%rdi), %r14d
movzbl -0x4(%r15,%rdi), %r12d
cmpl %r10d, %esi
jb 0x5fd4f
movb %sil, -0x1(%rdx)
decq %rdx
shrl $0x8, %esi
jmp 0x5fd3e
leaq (%rsp,%rcx), %r11
addq $0x430, %r11            # imm = 0x430
movl %esi, %ecx
movl 0x4(%r11), %r10d
imulq %rcx, %r10
movb 0xe(%r11), %cl
shrq %cl, %r10
shll $0x4, %r8d
addq %rsp, %r8
addq $0x430, %r8             # imm = 0x430
movl (%r8), %ecx
testl %ecx, %ecx
je 0x5ff51
addl 0x8(%r11), %esi
movzwl 0xc(%r11), %r11d
movl %r13d, %r15d
cmpl %ecx, %r13d
jb 0x5fda5
movb %r15b, -0x1(%rdx)
decq %rdx
shrl $0x8, %r15d
cmpl %ecx, %r15d
jae 0x5fd95
movl %r15d, %ecx
movl 0x4(%r8), %r13d
imulq %rcx, %r13
movb 0xe(%r8), %cl
shrq %cl, %r13
shll $0x4, %r14d
leaq (%rsp,%r14), %rbp
addq $0x430, %rbp            # imm = 0x430
movl (%rbp), %ecx
testl %ecx, %ecx
je 0x5ff51
addl 0x8(%r8), %r15d
movzwl 0xc(%r8), %r14d
cmpl %ecx, %eax
jb 0x5fde9
movb %al, -0x1(%rdx)
decq %rdx
shrl $0x8, %eax
jmp 0x5fdda
movl %eax, %ecx
movl 0x4(%rbp), %r8d
imulq %rcx, %r8
movb 0xe(%rbp), %cl
shrq %cl, %r8
shll $0x4, %r12d
addq %rsp, %r12
addq $0x430, %r12            # imm = 0x430
movl (%r12), %ecx
testl %ecx, %ecx
je 0x5ff51
addl 0x8(%rbp), %eax
movzwl 0xc(%rbp), %ebp
cmpl %ecx, %ebx
jb 0x5fe29
movb %bl, -0x1(%rdx)
decq %rdx
shrl $0x8, %ebx
jmp 0x5fe1a
movl %ebx, %ecx
movl 0x4(%r12), %r9d
imulq %rcx, %r9
movb 0xe(%r12), %cl
shrq %cl, %r9
imull %r11d, %r10d
leaq -0x4(%rdi), %rcx
addl %r10d, %esi
imull %r14d, %r13d
addl %r13d, %r15d
movl %r15d, %r13d
imull %ebp, %r8d
addl %r8d, %eax
addl 0x8(%r12), %ebx
movzwl 0xc(%r12), %r8d
imull %r9d, %r8d
addl %r8d, %ebx
cmpq $0x4, %rdi
movq %rcx, %rdi
movq 0x28(%rsp), %r15
jg 0x5fd12
jmp 0x5fe83
movl $0x800000, %esi         # imm = 0x800000
movl %esi, -0x4(%rdx)
movl %r13d, %ecx
movb %cl, -0x8(%rdx)
movb %ch, -0x7(%rdx)
movl %r13d, %esi
shrl $0x10, %ecx
movb %cl, -0x6(%rdx)
shrl $0x18, %esi
movb %sil, -0x5(%rdx)
movb %al, -0xc(%rdx)
movb %ah, -0xb(%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, -0xa(%rdx)
shrl $0x18, %eax
movb %al, -0x9(%rdx)
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %rcx
subq %rbp, %rcx
incq %rcx
leaq -0x10(%rdx), %rsi
movb %bl, -0x10(%rdx)
movb %bh, -0xf(%rdx)
movl %ebx, %eax
shrl $0x10, %eax
movb %al, -0xe(%rdx)
shrl $0x18, %ebx
movb %bl, -0xd(%rdx)
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
movslq %ecx, %rdi
addq %rdx, %rcx
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
movb $0x0, (%rbp)
movl %ecx, %eax
addb $-0x9, %al
movb %al, 0x1(%rbp)
leal 0xfff7(%rcx), %eax
movb %ah, 0x2(%rbp)
leal 0xfffff7(%rcx), %eax
shrl $0x10, %eax
movb %al, 0x3(%rbp)
leal -0x9(%rcx), %eax
shrl $0x18, %eax
movb %al, 0x4(%rbp)
movq (%rsp), %rcx
movb %cl, 0x5(%rbp)
movb %ch, 0x6(%rbp)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x7(%rbp)
shrl $0x18, %ecx
movb %cl, 0x8(%rbp)
addq %rbp, %rdi
callq 0x6c60
movq %rbp, %r12
movq %r12, %rax
addq $0x1438, %rsp           # imm = 0x1438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x399b0(%rip), %rdi     # 0x99908
leaq 0x39911(%rip), %rsi     # 0x99870
leaq 0x399b2(%rip), %rcx     # 0x99918
movl $0x10f, %edx            # imm = 0x10F
callq 0x6460
leaq 0x3996e(%rip), %rdi     # 0x998e5
leaq 0x398f2(%rip), %rsi     # 0x99870
leaq 0x398fe(%rip), %rcx     # 0x99883
movl $0xbb, %edx
callq 0x6460
leaq 0x39933(%rip), %rdi     # 0x998c9
leaq 0x398d3(%rip), %rsi     # 0x99870
leaq 0x398df(%rip), %rcx     # 0x99883
movl $0xba, %edx
callq 0x6460
leaq 0x39733(%rip), %rdi     # 0x996e8
leaq 0x39733(%rip), %rsi     # 0x996ef
leaq 0x3973f(%rip), %rcx     # 0x99702
movl $0x6f, %edx
callq 0x6460