// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/arith_dynamic.c
// Function: arith_uncompress_O0_RLE
static
unsigned char *arith_uncompress_O0_RLE(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;
    unsigned char *out_free = NULL;

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

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

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

    for (i = 0; i < NSYM; i++)
        SIMPLE_MODEL(NSYM,_init)(&run_model[i], MAX_RUN);

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

    for (i = 0; i < out_sz; i++) {
        unsigned char last;
        last = out[i] = SIMPLE_MODEL(256, _decodeSymbol)(&byte_model, &rc);
        //fprintf(stderr, "lit %c\n", last);
        int run = 0, r = 0, rctx = out[i];
        do {
            r = SIMPLE_MODEL(NSYM, _decodeSymbol)(&run_model[rctx], &rc);
            if (rctx == last)
                rctx = 256;
            else
                rctx += (rctx < NSYM-1);
            //fprintf(stderr, "run %d (ctx %d, %d)\n", r, last, l);
            run += r;
        } while (r == MAX_RUN-1 && run < out_sz);
        while (run-- && i+1 < out_sz)
            out[++i] = last;
    }

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

    htscodecs_tls_free(run_model);
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x85334
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x4a4(%rbp)
jmp 0x85341
movl $0x100, %eax            # imm = 0x100
movl %eax, -0x4a4(%rbp)
jmp 0x85341
movl -0x4a4(%rbp), %eax
movl %eax, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8536b
movl -0x24(%rbp), %eax
movl %eax, %edi
callq 0x4650
movq %rax, -0x20(%rbp)
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8537f
movq $0x0, -0x8(%rbp)
jmp 0x855c9
movl -0x70(%rbp), %esi
leaq -0x488(%rbp), %rdi
callq 0x859d0
movl $0x42030, %edi          # imm = 0x42030
callq 0xce6a0
movq %rax, -0x490(%rbp)
cmpq $0x0, -0x490(%rbp)
jne 0x853bf
movq -0x78(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x855c9
movl $0x0, -0x6c(%rbp)
cmpl $0x102, -0x6c(%rbp)     # imm = 0x102
jge 0x853f9
movq -0x490(%rbp), %rdi
movslq -0x6c(%rbp), %rax
imulq $0x418, %rax, %rax      # imm = 0x418
addq %rax, %rdi
movl $0x4, %esi
callq 0x85aa0
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x853c6
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
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x85588
leaq -0x488(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x861a0
movq -0x20(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movb %al, (%rcx,%rdx)
movb %al, -0x491(%rbp)
movl $0x0, -0x498(%rbp)
movl $0x0, -0x49c(%rbp)
movq -0x20(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x4a0(%rbp)
movq -0x490(%rbp), %rdi
movslq -0x4a0(%rbp), %rax
imulq $0x418, %rax, %rax      # imm = 0x418
addq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x862e0
movzwl %ax, %eax
movl %eax, -0x49c(%rbp)
movl -0x4a0(%rbp), %eax
movzbl -0x491(%rbp), %ecx
cmpl %ecx, %eax
jne 0x854be
movl $0x100, -0x4a0(%rbp)    # imm = 0x100
jmp 0x854dc
cmpl $0x101, -0x4a0(%rbp)    # imm = 0x101
setl %al
andb $0x1, %al
movzbl %al, %eax
addl -0x4a0(%rbp), %eax
movl %eax, -0x4a0(%rbp)
movl -0x49c(%rbp), %eax
addl -0x498(%rbp), %eax
movl %eax, -0x498(%rbp)
xorl %eax, %eax
cmpl $0x3, -0x49c(%rbp)
movb %al, -0x4a5(%rbp)
jne 0x85511
movl -0x498(%rbp), %eax
cmpl -0x24(%rbp), %eax
setb %al
movb %al, -0x4a5(%rbp)
movb -0x4a5(%rbp), %al
testb $0x1, %al
jne 0x85477
jmp 0x85521
movl -0x498(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x498(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a6(%rbp)
je 0x85551
movl -0x6c(%rbp), %eax
addl $0x1, %eax
cmpl -0x24(%rbp), %eax
setb %al
movb %al, -0x4a6(%rbp)
movb -0x4a6(%rbp), %al
testb $0x1, %al
jne 0x8555d
jmp 0x85578
movb -0x491(%rbp), %dl
movq -0x20(%rbp), %rax
movl -0x6c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x6c(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x85521
jmp 0x8557a
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x85424
leaq -0x68(%rbp), %rdi
callq 0x86420
cmpl $0x0, %eax
jge 0x855b5
movq -0x490(%rbp), %rdi
callq 0xce8f0
movq -0x78(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x855c9
movq -0x490(%rbp), %rdi
callq 0xce8f0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
nopw %cs:(%rax,%rax)