// File: /workspace/github_c_makefile_star2_O1/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 0x5e835
movl %eax, %r9d
xorl %edx, %edx
movw %dx, -0x76(%rsp,%rdx,4)
movw $0x1, -0x78(%rsp,%rdx,4)
incq %rdx
cmpq %rdx, %r9
jne 0x5e81f
jmp 0x5e837
xorl %edx, %edx
cmpl $0xff, %edx
ja 0x5e859
movl %edx, %edx
movw %dx, -0x76(%rsp,%rdx,4)
movw $0x0, -0x78(%rsp,%rdx,4)
incq %rdx
cmpq $0x100, %rdx            # imm = 0x100
jne 0x5e841
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 0x5e8ad
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 0x5e890
addq $0x6, %rdi
movq %rdi, %r11
testl %ecx, %ecx
je 0x5e9fc
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 0x5e8e4
movl %edi, %eax
xorl %edx, %edx
divl %r14d
movl %eax, %edi
movl %r9d, %eax
xorl %edx, %edx
divl %edi
jmp 0x5e8e6
xorl %eax, %eax
xorl %r12d, %r12d
cmpl $0xffef, %eax           # imm = 0xFFEF
ja 0x5e9e4
movq $-0x4, %rdx
movl %r12d, %r13d
movzwl -0x74(%rsp,%rdx), %r15d
leal (%r15,%r13), %r12d
addq $0x4, %rdx
cmpl %eax, %r12d
jbe 0x5e8fb
cmpq $0x400, %rdx            # imm = 0x400
jle 0x5e922
xorl %r12d, %r12d
jmp 0x5e9e4
imull %edi, %r13d
subl %r13d, %r9d
imull %r15d, %edi
cmpl $0xffffff, %edi         # imm = 0xFFFFFF
ja 0x5e962
cmpq %r10, %r11
jae 0x5e95d
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 0x5e935
movl %eax, %edi
jmp 0x5e962
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 0x5e9bd
movl $0x0, -0x80(%rsp)
movzwl -0x78(%rsp), %eax
testw %ax, %ax
je 0x5e9bd
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 0x5e996
movl %r14d, -0x80(%rsp)
movzwl -0x78(%rsp,%rdx), %eax
movzwl -0x76(%rsp,%rdx), %r12d
cmpw -0x7c(%rsp,%rdx), %ax
jbe 0x5e9e4
movl -0x7c(%rsp,%rdx), %r14d
movl %r14d, -0x78(%rsp,%rdx)
movw %ax, -0x7c(%rsp,%rdx)
movw %r12w, -0x7a(%rsp,%rdx)
movb %r12b, (%r8,%rsi)
incq %rsi
cmpq %rcx, %rsi
jne 0x5e8c5
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