// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/htscodecs/htscodecs/arith_dynamic.c
// Function: arith_compress_O0
static
unsigned char *arith_compress_O0(unsigned char *in, unsigned int in_size,
                                 unsigned char *out, unsigned int *out_size) {
    int i, bound = arith_compress_bound(in_size,0)-5; // -5 for order/size
    unsigned char *out_free = NULL;

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

    unsigned int m = 0;
    for (i = 0; i < in_size; i++)
        if (m < in[i])
            m = in[i];
    m++;
    *out = m;

    SIMPLE_MODEL(256,_) byte_model;
    SIMPLE_MODEL(256,_init)(&byte_model, m);

    RangeCoder rc;
    RC_SetOutput(&rc, (char *)out+1);
    RC_SetOutputEnd(&rc, (char *)out + *out_size);
    RC_StartEncode(&rc);

    for (i = 0; i < in_size; i++)
        SIMPLE_MODEL(256, _encodeSymbol)(&byte_model, &rc, in[i]);

    if (RC_FinishEncode(&rc) < 0) {
        free(out_free);
        return NULL;
    }

    // Finalise block size and return it
    *out_size = RC_OutSize(&rc)+1;

    return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x458, %rsp            # imm = 0x458
movq %rcx, %rbx
movl %esi, %ebp
movq %rdi, %r15
movl %esi, %r13d
cvtsi2sd %r13, %xmm0
mulsd 0x40914(%rip), %xmm0    # 0x9ada8
addsd 0x4157c(%rip), %xmm0    # 0x9ba18
addsd 0x4156c(%rip), %xmm0    # 0x9ba10
addsd 0x41574(%rip), %xmm0    # 0x9ba20
cvttsd2si %xmm0, %rax
addl $-0x5, %eax
testq %rdx, %rdx
je 0x5a4c5
xorl %r8d, %r8d
cmpl (%rbx), %eax
jbe 0x5a4dd
jmp 0x5a7db
movl %eax, (%rbx)
movl %eax, %edi
callq 0x4680
movq %rax, %rdx
movq %rax, %r8
testq %rax, %rax
je 0x5a7d8
testl %ebp, %ebp
je 0x5a4f9
xorl %ecx, %ecx
xorl %eax, %eax
movzbl (%r15,%rcx), %esi
cmpl %esi, %eax
cmovbel %esi, %eax
incq %rcx
cmpq %rcx, %r13
jne 0x5a4e5
jmp 0x5a4fb
xorl %eax, %eax
movl %eax, %ecx
incl %eax
movb %al, (%rdx)
leaq 0x1(%rcx), %rdi
xorl %esi, %esi
movw %si, 0x52(%rsp,%rsi,4)
movw $0x1, 0x50(%rsp,%rsi,4)
incq %rsi
cmpq %rsi, %rdi
jne 0x5a507
cmpl $0xfe, %ecx
ja 0x5a53f
leaq 0x1(%rcx), %rsi
movw %si, 0x56(%rsp,%rcx,4)
movw $0x0, 0x54(%rsp,%rcx,4)
movq %rsi, %rcx
cmpq $0xff, %rsi
jne 0x5a523
movl %eax, 0x48(%rsp)
movl $0xffef, %eax           # imm = 0xFFEF
movl %eax, 0x4c(%rsp)
movl %eax, 0x454(%rsp)
movw $0x0, 0x450(%rsp)
leaq 0x1(%rdx), %r12
movq %rbx, 0x28(%rsp)
movl (%rbx), %r10d
movq %rdx, 0x20(%rsp)
addq %rdx, %r10
testl %ebp, %ebp
movq %r8, 0x10(%rsp)
movq %r12, 0x18(%rsp)
je 0x5a725
movq %r13, 0x30(%rsp)
movq %r15, 0x38(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %edi, %edi
xorl %r11d, %r11d
movl $0x0, 0xc(%rsp)
xorl %r13d, %r13d
xorl %ecx, %ecx
xorl %esi, %esi
movq 0x38(%rsp), %rdx
movq %rdi, 0x40(%rsp)
movzbl (%rdx,%rdi), %edx
leaq 0x50(%rsp), %r14
movl $0x0, %ebx
cmpw %dx, 0x52(%rsp)
je 0x5a5db
xorl %ebx, %ebx
movq %r14, %rdi
movzwl (%r14), %r8d
addq $0x4, %r14
addl %r8d, %ebx
cmpw %dx, 0x6(%rdi)
jne 0x5a5c7
movzwl (%r14), %edi
movl 0x48(%rsp), %r8d
xorl %edx, %edx
divl %r8d
movl %eax, %ebp
imull %eax, %ebx
imull %edi, %ebp
addl %r11d, %ebx
adcl $0x0, %esi
cmpl $0xffffff, %ebp         # imm = 0xFFFFFF
ja 0x5a68e
movl %esi, %r8d
movl %esi, %edi
cmpl $0xff000000, %ebx       # imm = 0xFF000000
jb 0x5a619
testl %edi, %edi
jne 0x5a619
incl %r13d
jmp 0x5a665
movl %r13d, %edx
movq %r10, %rax
subq %r12, %rax
cmpq %rdx, %rax
jle 0x5a66c
addl %ecx, %r8d
leaq 0x1(%r12), %rdi
movb %r8b, (%r12)
testl %r13d, %r13d
je 0x5a655
decb %sil
movzbl %sil, %esi
movq %r10, %r15
callq 0x4260
movq %r15, %r10
decl %r13d
leaq (%r12,%r13), %rdi
addq $0x2, %rdi
movl %ebx, %ecx
shrl $0x18, %ecx
xorl %esi, %esi
movq %rdi, %r12
xorl %r13d, %r13d
xorl %r8d, %r8d
shll $0x8, %ebx
xorl %edi, %edi
jmp 0x5a674
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movl %ebp, %eax
shll $0x8, %eax
cmpl $0x10000, %ebp          # imm = 0x10000
movl %eax, %ebp
jb 0x5a608
movzwl (%r14), %edi
movl 0x48(%rsp), %r8d
jmp 0x5a690
movl %ebp, %eax
movl %ebx, %r11d
addl $0x10, %edi
movw %di, (%r14)
addl $0x10, %r8d
movl %r8d, 0x48(%rsp)
cmpl $0xfff0, %r8d           # imm = 0xFFF0
jb 0x5a6ee
movl $0x0, 0x48(%rsp)
movzwl 0x50(%rsp), %edx
testw %dx, %dx
je 0x5a6ee
xorl %edi, %edi
leaq 0x54(%rsp), %r8
movzwl %dx, %r9d
shrl %r9d
subl %r9d, %edx
movw %dx, -0x4(%r8)
movzwl %dx, %edx
addl %edx, %edi
movzwl (%r8), %edx
addq $0x4, %r8
testw %dx, %dx
jne 0x5a6c5
movl %edi, 0x48(%rsp)
movzwl (%r14), %edi
cmpw -0x4(%r14), %di
jbe 0x5a706
movq -0x4(%r14), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, -0x4(%r14)
movq 0x40(%rsp), %rdi
incq %rdi
cmpq 0x30(%rsp), %rdi
jne 0x5a5a6
shrl $0x1f, 0xc(%rsp)
movq 0x10(%rsp), %r8
jmp 0x5a737
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r13d, %r13d
movl $0x0, 0xc(%rsp)
xorl %r11d, %r11d
xorl %ebx, %ebx
movl $0x5, %ebp
cmpl $0xff000000, %r11d      # imm = 0xFF000000
setae %dl
testl %esi, %esi
sete %al
andb %dl, %al
movl %r13d, %r13d
movq %r10, %rdx
subq %r12, %rdx
movl %ebp, %edi
testb %al, %al
jne 0x5a769
cmpq %r13, %rdx
jg 0x5a76e
decl %edi
jne 0x5a75a
jmp 0x5a7d0
incl %r13d
jmp 0x5a7b6
addl %esi, %ecx
leaq 0x1(%r12), %rdi
movb %cl, (%r12)
testq %r13, %r13
je 0x5a7aa
decb %sil
movzbl %sil, %esi
movq %r13, %rdx
movq %r10, %r15
movl %r11d, %r14d
callq 0x4260
movq 0x10(%rsp), %r8
movl %r14d, %r11d
movq %r15, %r10
leal -0x1(%r13), %eax
leaq (%r12,%rax), %rdi
addq $0x2, %rdi
movl %r11d, %ecx
shrl $0x18, %ecx
xorl %r13d, %r13d
movq %rdi, %r12
shll $0x8, %r11d
incl %ebx
decl %ebp
xorl %esi, %esi
cmpl $0x5, %ebx
jne 0x5a73e
cmpb $0x0, 0xc(%rsp)
je 0x5a7f0
movq %r8, %rdi
callq 0x45c0
xorl %r8d, %r8d
movq %r8, %rax
addq $0x458, %rsp            # imm = 0x458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl 0x18(%rsp), %r12d
incl %r12d
movq 0x28(%rsp), %rax
movl %r12d, (%rax)
movq 0x20(%rsp), %r8
jmp 0x5a7db