// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x18(%rcx), %ecx
addl $0x200, %ecx            # imm = 0x200
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xe6be6
movl $0x0, -0x4(%rbp)
jmp 0xe6ddc
xorl %esi, %esi
movl %esi, %edi
callq 0x6ede0
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x18(%rbp), %rdx
movl 0x18(%rdx), %edx
addl $0x200, %edx            # imm = 0x200
movslq %edx, %rdx
movq %rax, (%rcx,%rdx,8)
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xe6c22
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe6ddc
movq -0x18(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x80(%rcx), %rsi
callq *%rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xe6c59
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe6ddc
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x78(%rcx), %rsi
callq *%rax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x50(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x78(%rcx), %rsi
callq *%rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe6cbd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe6ddc
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x154(%rbp)
movl $0x0, -0x158(%rbp)
cmpl $0x100, -0x158(%rbp)    # imm = 0x100
jge 0xe6d33
movq -0x18(%rbp), %rax
movslq -0x158(%rbp), %rcx
cmpl $0x0, 0x90(%rax,%rcx,4)
jle 0xe6d20
movl -0x158(%rbp), %eax
movb %al, %cl
movl -0x154(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x154(%rbp)
cltq
movb %cl, -0x150(%rbp,%rax)
jmp 0xe6d22
movl -0x158(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x158(%rbp)
jmp 0xe6cdd
movq -0x48(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x38(%rbp), %eax
addq %rax, %rsi
leaq -0x160(%rbp), %rdx
callq 0xecbb0
movl %eax, -0x164(%rbp)
movq -0x160(%rbp), %rdi
callq 0x4650
movq -0x20(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0xe6d76
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe6ddc
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %esi
movq -0x48(%rbp), %rdx
movslq -0x164(%rbp), %rax
addq %rax, %rdx
movl -0x38(%rbp), %eax
subl -0x164(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
leaq -0x150(%rbp), %r8
movl -0x154(%rbp), %r9d
movq -0x20(%rbp), %rax
movq 0x20(%rax), %r10
leaq -0x160(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xc8250
movq -0x160(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopl (%rax,%rax)