// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/htscodecs/htscodecs/arith_dynamic.c
// Function: arith_uncompress_O0
static
unsigned char *arith_uncompress_O0(unsigned char *in, unsigned int in_size,
                                   unsigned char *out, unsigned int out_sz) {
    RangeCoder rc;
    int i;
    unsigned int m = in[0] ? in[0] : 256;

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

    unsigned char *out_free = NULL;
    if (!out)
        out_free = out = malloc(out_sz);
    if (!out)
        return NULL;

    RC_SetInput(&rc, (char *)in+1, (char *)in+in_size);
    RC_StartDecode(&rc);

    for (i = 0; i < out_sz; i++)
        out[i] = SIMPLE_MODEL(256, _decodeSymbol)(&byte_model, &rc);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x390, %rsp            # imm = 0x390
movq %rdx, %r8
movzbl (%rdi), %edx
testl %edx, %edx
movl $0x100, %eax            # imm = 0x100
cmovnel %edx, %eax
testl %eax, %eax
je 0x5be23
movl %eax, %r9d
xorl %r10d, %r10d
movw %r10w, -0x76(%rsp,%r10,4)
movw $0x1, -0x78(%rsp,%r10,4)
incq %r10
cmpq %r10, %r9
jne 0x5be07
testl %edx, %edx
jne 0x5be25
jmp 0x5be3f
xorl %edx, %edx
movl %edx, %edx
movw %dx, -0x76(%rsp,%rdx,4)
movw $0x0, -0x78(%rsp,%rdx,4)
incq %rdx
cmpq $0x100, %rdx            # imm = 0x100
jne 0x5be27
movl %eax, -0x80(%rsp)
movl $0xffef, %eax           # imm = 0xFFEF
movl %eax, -0x7c(%rsp)
movl %eax, 0x38c(%rsp)
movw $0x0, 0x388(%rsp)
movl %esi, %r10d
addq %rdi, %r10
xorl %r9d, %r9d
movq %r10, %r11
cmpl $0x6, %esi
jb 0x5be93
xorl %r9d, %r9d
movl $0x1, %eax
movl %r9d, %edx
shll $0x8, %edx
movzbl (%rdi,%rax), %r9d
orl %edx, %r9d
incq %rax
cmpl $0x6, %eax
jne 0x5be76
addq $0x6, %rdi
movq %rdi, %r11
testl %ecx, %ecx
je 0x5bfe5
movl %ecx, %ecx
xorl %esi, %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq -0x74(%rsp), %rbx
xorl %ebp, %ebp
movl -0x80(%rsp), %r14d
leal -0x1(%r14), %eax
cmpl %edi, %eax
jae 0x5bed7
xorl %r12d, %r12d
movl %edi, %eax
xorl %edx, %edx
divl %r14d
movl %eax, %edi
movl %r9d, %eax
xorl %edx, %edx
divl %edi
cmpl $0xffef, %eax           # imm = 0xFFEF
jbe 0x5bed9
jmp 0x5bfcd
xorl %eax, %eax
xorl %r13d, %r13d
movq $-0x4, %rdx
movl %r13d, %r12d
movzwl -0x74(%rsp,%rdx), %r15d
leal (%r12,%r15), %r13d
addq $0x4, %rdx
cmpl %eax, %r13d
jbe 0x5bee3
cmpq $0x400, %rdx            # imm = 0x400
jle 0x5bf0a
xorl %r12d, %r12d
jmp 0x5bfcd
imull %edi, %r12d
subl %r12d, %r9d
imull %r15d, %edi
cmpl $0xffffff, %edi         # imm = 0xFFFFFF
ja 0x5bf4a
cmpq %r10, %r11
jae 0x5bf45
movl %r9d, %eax
shll $0x8, %eax
movzbl (%r11), %r9d
incq %r11
orl %eax, %r9d
movl %edi, %eax
shll $0x8, %eax
cmpl $0x10000, %edi          # imm = 0x10000
movl %eax, %edi
jb 0x5bf1d
movl %eax, %edi
jmp 0x5bf4a
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
addl $0x10, %r15d
movw %r15w, -0x78(%rsp,%rdx)
addl $0x10, %r14d
movl %r14d, -0x80(%rsp)
cmpl $0xfff0, %r14d          # imm = 0xFFF0
jb 0x5bfab
movl $0x0, -0x80(%rsp)
movzwl -0x78(%rsp), %eax
testw %ax, %ax
je 0x5bfab
xorl %r14d, %r14d
movq %rbx, %r15
movzwl %ax, %r12d
shrl %r12d
subl %r12d, %eax
movw %ax, -0x4(%r15)
movzwl %ax, %eax
addl %eax, %r14d
movzwl (%r15), %eax
addq $0x4, %r15
testw %ax, %ax
jne 0x5bf7e
movl %r14d, -0x80(%rsp)
movzwl -0x78(%rsp,%rdx), %r15d
movzwl -0x76(%rsp,%rdx), %r12d
cmpw -0x7c(%rsp,%rdx), %r15w
jbe 0x5bfcd
movl -0x7c(%rsp,%rdx), %eax
movl %eax, -0x78(%rsp,%rdx)
movw %r15w, -0x7c(%rsp,%rdx)
movw %r12w, -0x7a(%rsp,%rdx)
movb %r12b, (%r8,%rsi)
incq %rsi
cmpq %rcx, %rsi
jne 0x5beab
xorl %eax, %eax
testl %ebp, %ebp
cmovsq %rax, %r8
movq %r8, %rax
addq $0x390, %rsp            # imm = 0x390
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq