// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/rle.c
// Function: hts_rle_decode
uint8_t *hts_rle_decode(uint8_t *lit, uint64_t lit_len,
                        uint8_t *run, uint64_t run_len,
                        uint8_t *rle_syms, int rle_nsyms,
                        uint8_t *out, uint64_t *out_len) {
    uint64_t j;
    uint8_t *run_end = run + run_len;

#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    if (*out_len > 100000)
        return NULL;
#endif

    int saved[256] = {0};
    for (j = 0; j < rle_nsyms; j++)
        saved[rle_syms[j]] = 1;

    uint8_t *lit_end = lit + lit_len;
    uint8_t *out_end = out + *out_len;
    uint8_t *outp = out;

    while (lit < lit_end) {
        if (outp >= out_end)
            goto err;

        uint8_t b = *lit;
        if (saved[b]) {
            uint32_t rlen;
            run += var_get_u32(run, run_end, &rlen);
            if (rlen) {
                if (outp + rlen >= out_end)
                    goto err;
                memset(outp, b, rlen+1);
                outp += rlen+1;
            } else {
                *outp++ = b;
            }
        } else {
            *outp++ = b;
        }
        lit++;
    }

    *out_len = outp-out;
    return out;

 err:
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x450(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4250
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jae 0xc82d4
movq -0x30(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl $0x1, -0x450(%rbp,%rax,4)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xc82a2
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x458(%rbp)
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rcx
addq (%rcx), %rax
movq %rax, -0x460(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x458(%rbp), %rax
jae 0xc8420
movq -0x468(%rbp), %rax
cmpq -0x460(%rbp), %rax
jb 0xc8326
jmp 0xc843f
movq -0x10(%rbp), %rax
movb (%rax), %al
movb %al, -0x469(%rbp)
movzbl -0x469(%rbp), %eax
cmpl $0x0, -0x450(%rbp,%rax,4)
je 0xc83f2
movq -0x20(%rbp), %rdi
movq -0x48(%rbp), %rsi
leaq -0x470(%rbp), %rdx
callq 0xc8460
movl %eax, %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x470(%rbp)
je 0xc83d3
movq -0x468(%rbp), %rax
movl -0x470(%rbp), %ecx
addq %rcx, %rax
cmpq -0x460(%rbp), %rax
jb 0xc8392
jmp 0xc843f
movq -0x468(%rbp), %rdi
movzbl -0x469(%rbp), %eax
movl -0x470(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movzbl %al, %esi
callq 0x4250
movl -0x470(%rbp), %ecx
addl $0x1, %ecx
movq -0x468(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x468(%rbp)
jmp 0xc83f0
movb -0x469(%rbp), %cl
movq -0x468(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x468(%rbp)
movb %cl, (%rax)
jmp 0xc840f
movb -0x469(%rbp), %cl
movq -0x468(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x468(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0xc8300
movq -0x468(%rbp), %rcx
movq 0x10(%rbp), %rax
subq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xc8447
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq
nopw %cs:(%rax,%rax)