// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/arith_dynamic.c
// Function: arith_uncompress_O1
static
unsigned char *arith_uncompress_O1(unsigned char *in, unsigned int in_size,
                                   unsigned char *out, unsigned int out_sz) {
    RangeCoder rc;
    unsigned char *out_free = NULL;

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


    SIMPLE_MODEL(256,_) *byte_model =
        htscodecs_tls_alloc(256 * sizeof(*byte_model));
    if (!byte_model) {
        free(out_free);
        return NULL;
    }

    unsigned int m = in[0] ? in[0] : 256, i;
    for (i = 0; i < 256; i++)
        SIMPLE_MODEL(256,_init)(&byte_model[i], m);

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

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq $0x0, -0x70(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8561a
movl -0x24(%rbp), %eax
movl %eax, %edi
callq 0x4650
movq %rax, -0x20(%rbp)
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8562e
movq $0x0, -0x8(%rbp)
jmp 0x85778
movl $0x41000, %edi          # imm = 0x41000
callq 0xce6a0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x85659
movq -0x70(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x85778
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x85674
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x88(%rbp)
jmp 0x85681
movl $0x100, %eax            # imm = 0x100
movl %eax, -0x88(%rbp)
jmp 0x85681
movl -0x88(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
cmpl $0x100, -0x80(%rbp)     # imm = 0x100
jae 0x856be
movq -0x78(%rbp), %rdi
movl -0x80(%rbp), %eax
imulq $0x410, %rax, %rax      # imm = 0x410
addq %rax, %rdi
movl -0x7c(%rbp), %esi
callq 0x859d0
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x85691
movq -0x10(%rbp), %rsi
addq $0x1, %rsi
movq -0x10(%rbp), %rdx
movl -0x14(%rbp), %eax
addq %rax, %rdx
leaq -0x68(%rbp), %rdi
callq 0x860a0
leaq -0x68(%rbp), %rdi
callq 0x860e0
movb $0x0, -0x81(%rbp)
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x8573d
movq -0x78(%rbp), %rdi
movzbl -0x81(%rbp), %eax
imulq $0x410, %rax, %rax      # imm = 0x410
addq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x861a0
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x80(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl -0x80(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x81(%rbp)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x856f0
leaq -0x68(%rbp), %rdi
callq 0x86420
cmpl $0x0, %eax
jge 0x85767
movq -0x78(%rbp), %rdi
callq 0xce8f0
movq -0x70(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x85778
movq -0x78(%rbp), %rdi
callq 0xce8f0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)