// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_xrle_decode_expand_char
static int cram_xrle_decode_expand_char(cram_slice *slice, cram_codec *c) {
    cram_block *b = slice->block_by_id[512 + c->codec_id];
    if (b)
        return 0;

    b = slice->block_by_id[512 + c->codec_id] = cram_new_block(0, 0);
    if (!b)
        return -1;
    cram_block *lit_b = c->u.xrle.lit_codec->get_block(slice, c->u.xrle.lit_codec);
    if (!lit_b)
        return -1;
    unsigned char *lit_dat = lit_b->data;
    unsigned int lit_sz = lit_b->uncomp_size;
    unsigned int len_sz = c->u.xrle.len_codec->size(slice, c->u.xrle.len_codec);

    cram_block *len_b = c->u.xrle.len_codec->get_block(slice, c->u.xrle.len_codec);
    if (!len_b)
        return -1;
    unsigned char *len_dat = len_b->data;

    uint8_t rle_syms[256];
    int rle_nsyms = 0;
    int i;
    for (i = 0; i < 256; i++) {
        if (c->u.xrle.rep_score[i] > 0)
            rle_syms[rle_nsyms++] = i;
    }

    uint64_t out_sz;
    int nb = var_get_u64(len_dat, len_dat+len_sz, &out_sz);
    if (!(b->data = malloc(out_sz)))
        return -1;
    hts_rle_decode(lit_dat, lit_sz,
                   len_dat+nb, len_sz-nb,
                   rle_syms, rle_nsyms,
                   b->data, &out_sz);
    b->uncomp_size = out_sz;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq 0x18(%rdi), %rax
movslq 0x18(%rsi), %rcx
cmpq $0x0, 0x1000(%rax,%rcx,8)
je 0x918f5
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq %rdi, %r13
xorl %edi, %edi
xorl %esi, %esi
callq 0x4ee42
movq %rax, %rbx
movq 0x18(%r13), %rax
movslq 0x18(%r14), %rcx
movq %rbx, 0x1000(%rax,%rcx,8)
testq %rbx, %rbx
je 0x918e3
movq 0x80(%r14), %rsi
movq %r13, %rdi
callq *0x50(%rsi)
testq %rax, %rax
je 0x918e3
movq 0x20(%rax), %rbp
movl 0x14(%rax), %r15d
movq 0x78(%r14), %rsi
movq %r13, %rdi
callq *0x40(%rsi)
movl %eax, %r12d
movq 0x78(%r14), %rsi
movq %r13, %rdi
callq *0x50(%rsi)
testq %rax, %rax
je 0x918e3
movq %rbp, 0x8(%rsp)
movq 0x20(%rax), %r13
xorl %eax, %eax
xorl %ebp, %ebp
cmpl $0x0, 0x90(%r14,%rax,4)
jle 0x91973
movslq %ebp, %rcx
incl %ebp
movb %al, 0x10(%rsp,%rcx)
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x9195f
cmpl $0xa, %r12d
ja 0x919be
testq %r13, %r13
je 0x919be
testl %r12d, %r12d
je 0x91a40
movl %r12d, %ecx
addq %r13, %rcx
xorl %eax, %eax
movq %r13, %r14
movzbl (%r14), %edx
incq %r14
movq %rax, %rsi
shlq $0x7, %rsi
movl %edx, %eax
andl $0x7f, %eax
orq %rsi, %rax
testb %dl, %dl
jns 0x919ea
cmpq %rcx, %r14
jb 0x9199d
jmp 0x919ea
xorl %ecx, %ecx
xorl %eax, %eax
movzbl (%r13,%rcx), %edx
movq %rax, %rsi
shlq $0x7, %rsi
movl %edx, %eax
andl $0x7f, %eax
orq %rsi, %rax
leaq 0x1(%rcx), %r14
testb %dl, %dl
jns 0x919e7
cmpl $0xa, %ecx
movq %r14, %rcx
jne 0x919c2
addq %r13, %r14
movq %rax, (%rsp)
subl %r13d, %r14d
movq (%rsp), %rdi
callq 0x4680
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x918e3
movslq %r14d, %rcx
addq %rcx, %r13
subl %ecx, %r12d
movq %rsp, %r14
leaq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
movl %ebp, %r9d
pushq %r14
pushq %rax
callq 0x7cead
addq $0x10, %rsp
movl (%r14), %eax
movl %eax, 0x14(%rbx)
jmp 0x918e3
movq $0x0, (%rsp)
xorl %r14d, %r14d
jmp 0x919f1