// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_xrle_encode_store
int cram_xrle_encode_store(cram_codec *c, cram_block *b,
                            char *prefix, int version) {
    int len = 0, r = 0, n;
    cram_codec *tc;
    cram_block *b_rle, *b_len, *b_lit;

    if (prefix) {
        size_t l = strlen(prefix);
        BLOCK_APPEND(b, prefix, l);
        len += l;
    }

    // List of symbols to RLE
    b_rle = cram_new_block(0, 0);
    if (!b_rle)
        return -1;
    int i, nrle = 0, len1 = 0;
    for (i = 0; i < 256; i++) {
        if (c->u.e_xrle.rep_score[i] > 0) {
            nrle++;
            len1 += (n = c->vv->varint_put32_blk(b_rle,i)); r |= n;
        }
    }

    // Store length and literal sub-codecs to get encoded length
    tc = c->u.e_xrle.len_codec;
    b_len = cram_new_block(0, 0);
    if (!b_len)
        return -1;
    int len2 = tc->store(tc, b_len, NULL, version);

    tc = c->u.e_xrle.lit_codec;
    b_lit = cram_new_block(0, 0);
    if (!b_lit)
        return -1;
    int len3 = tc->store(tc, b_lit, NULL, version);

    len += (n = c->vv->varint_put32_blk(b, c->codec)); r |= n;
    len += (n = c->vv->varint_put32_blk(b, len1 + len2 + len3
                                        + c->vv->varint_size(nrle))); r |= n;
    len += (n = c->vv->varint_put32_blk(b, nrle)); r |= n;
    BLOCK_APPEND(b, BLOCK_DATA(b_rle), BLOCK_SIZE(b_rle));
    BLOCK_APPEND(b, BLOCK_DATA(b_len), BLOCK_SIZE(b_len));
    BLOCK_APPEND(b, BLOCK_DATA(b_lit), BLOCK_SIZE(b_lit));

    cram_free_block(b_rle);
    cram_free_block(b_len);
    cram_free_block(b_lit);

    if (r > 0)
        return len + len1 + len2 + len3;

 block_err:
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r12d
movq %rsi, %r15
movq %rdi, %r13
pushq $-0x1
popq %rbp
testq %rdx, %rdx
je 0x72069
movq %rdx, %rbx
movq %rdx, %rdi
callq 0x41d0
movq %rax, %r14
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x6f15a
xorl %ecx, %ecx
testl %eax, %eax
cmovsl %ecx, %r14d
jns 0x7206c
jmp 0x7222e
xorl %r14d, %r14d
movl %r12d, 0x8(%rsp)
movq %r15, 0x40(%rsp)
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
callq 0x3f426
testq %rax, %rax
je 0x7222e
movq %rax, %r12
movq %r14, 0x38(%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r14d, %r14d
cmpq $0x100, %rbp            # imm = 0x100
je 0x720c7
cmpl $0x0, 0x90(%r13,%rbp,4)
jle 0x720c2
incl %ebx
movq 0x10(%r13), %rax
movq %r12, %rdi
movl %ebp, %esi
callq *0x58(%rax)
addl %eax, %r14d
orl %eax, %r15d
incq %rbp
jmp 0x7209a
movq 0x78(%r13), %rbp
xorl %edi, %edi
xorl %esi, %esi
callq 0x3f426
testq %rax, %rax
je 0x7222b
movq %rbp, %rdi
movq %rax, 0x20(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl 0x8(%rsp), %ecx
callq *0x38(%rbp)
movq %rax, 0x28(%rsp)
movq 0x80(%r13), %rbp
xorl %edi, %edi
xorl %esi, %esi
callq 0x3f426
testq %rax, %rax
je 0x7222b
movq %rbp, %rdi
movq %rax, 0x30(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl 0x8(%rsp), %ecx
callq *0x38(%rbp)
movq %rax, 0x8(%rsp)
movq 0x10(%r13), %rax
movl (%r13), %esi
movq 0x40(%rsp), %rbp
movq %rbp, %rdi
callq *0x58(%rax)
movl %eax, 0x14(%rsp)
movq 0x10(%r13), %rax
movq 0x58(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x28(%rsp), %rcx
addl %r14d, %ecx
movl %ecx, 0x4(%rsp)
movslq %ebx, %rdi
callq *0x78(%rax)
movq 0x8(%rsp), %rcx
leal (%rax,%rcx), %esi
addl 0x4(%rsp), %esi
movq %rbp, %rdi
callq *0x18(%rsp)
movl %eax, 0x18(%rsp)
movq 0x10(%r13), %rax
movq %rbp, %rdi
movl %ebx, %esi
callq *0x58(%rax)
movl %eax, %r13d
movq 0x20(%r12), %rsi
movq 0x30(%r12), %rdx
movq %rbp, %rbx
movq %rbp, %rdi
callq 0x6f15a
testl %eax, %eax
js 0x7222b
movq 0x20(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x30(%rax), %rdx
movq %rbx, %rdi
callq 0x6f15a
testl %eax, %eax
pushq $-0x1
popq %rbp
js 0x7222e
movl %r13d, 0x4(%rsp)
movq 0x30(%rsp), %r13
movq 0x20(%r13), %rsi
movq 0x30(%r13), %rdx
movq %rbx, %rdi
callq 0x6f15a
testl %eax, %eax
js 0x7222e
orl 0x14(%rsp), %r15d
orl 0x4(%rsp), %r15d
movl 0x18(%rsp), %ebx
orl %ebx, %r15d
movq %r12, %rdi
callq 0x3f8fc
movq 0x20(%rsp), %rdi
callq 0x3f8fc
movq %r13, %rdi
callq 0x3f8fc
testl %r15d, %r15d
jle 0x7222e
addl 0x38(%rsp), %r14d
addl 0x28(%rsp), %r14d
movq 0x8(%rsp), %rax
addl 0x14(%rsp), %eax
addl %r14d, %eax
addl 0x4(%rsp), %eax
addl %ebx, %eax
movl %eax, %ebp
jmp 0x7222e
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq