// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, %rbx
movq %rdi, %r13
testq %rdx, %rdx
movl %ecx, 0x10(%rsp)
je 0x921d3
movq %rdx, %r12
movq %rdx, %rdi
callq 0x41d0
movq %rax, %r14
movq 0x30(%rbx), %rbp
addq %rax, %rbp
movq 0x28(%rbx), %rax
cmpq %rbp, %rax
ja 0x921a0
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %rbp, %rax
cmovaq %rax, %rbp
movq 0x20(%rbx), %rdi
movq %rbp, %rsi
callq 0x4840
testq %rax, %rax
je 0x924c3
movq %rbp, 0x28(%rbx)
movq %rax, 0x20(%rbx)
testq %r14, %r14
je 0x921bc
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x43c0
addq %r14, 0x30(%rbx)
xorl %ecx, %ecx
xorl %r15d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
cmovel %r14d, %r15d
je 0x921d6
jmp 0x924b4
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %edi, %edi
xorl %esi, %esi
callq 0x4ee42
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x924b4
movl %r15d, 0x24(%rsp)
movq %rbx, 0x40(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r15d, %r15d
cmpl $0x0, 0x90(%r13,%r12,4)
jle 0x92223
incl %ebx
movq 0x10(%r13), %rax
movq %r14, %rdi
movl %r12d, %esi
callq *0x58(%rax)
addl %eax, %ebp
orl %eax, %r15d
incq %r12
cmpq $0x100, %r12            # imm = 0x100
jne 0x92204
movq 0x78(%r13), %r12
xorl %edi, %edi
xorl %esi, %esi
callq 0x4ee42
testq %rax, %rax
je 0x924af
movq %r12, %rdi
movq %rax, 0x30(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl 0x10(%rsp), %ecx
callq *0x38(%r12)
movq %rax, 0x38(%rsp)
movq 0x80(%r13), %r12
xorl %edi, %edi
xorl %esi, %esi
callq 0x4ee42
testq %rax, %rax
je 0x924af
movq %r12, %rdi
movq %rax, 0x28(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl 0x10(%rsp), %ecx
callq *0x38(%r12)
movq %rax, 0x10(%rsp)
movq 0x10(%r13), %rax
movl (%r13), %esi
movq 0x40(%rsp), %r12
movq %r12, %rdi
callq *0x58(%rax)
movl %eax, 0x20(%rsp)
movq 0x10(%r13), %rax
movq 0x58(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x38(%rsp), %rcx
addl %ebp, %ecx
movl %ecx, 0x4(%rsp)
movslq %ebx, %rdi
movq %r12, %rbx
movq %rdi, %r12
callq *0x78(%rax)
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %esi
addl 0x4(%rsp), %esi
movq %rbx, %rdi
callq *0x18(%rsp)
movl %eax, 0x18(%rsp)
movq 0x10(%r13), %rax
movq %rbx, %rdi
movl %r12d, %esi
callq *0x58(%rax)
movl %eax, 0x4(%rsp)
movq 0x20(%r14), %rsi
movq 0x30(%r14), %r12
movq 0x30(%rbx), %r13
addq %r12, %r13
movq 0x28(%rbx), %rax
cmpq %r13, %rax
ja 0x92351
movq %rsi, 0x8(%rsp)
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movq 0x20(%rbx), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
je 0x924af
movq %r13, 0x28(%rbx)
movq %rax, 0x20(%rbx)
movq 0x8(%rsp), %rsi
testq %r12, %r12
je 0x9236a
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x30(%rbx)
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x30(%rax), %r12
movq 0x30(%rbx), %r13
addq %r12, %r13
movq 0x28(%rbx), %rax
cmpq %r13, %rax
ja 0x923c9
movq %rsi, 0x8(%rsp)
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movq 0x20(%rbx), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
je 0x924af
movq %r13, 0x28(%rbx)
movq %rax, 0x20(%rbx)
movq 0x8(%rsp), %rsi
testq %r12, %r12
je 0x923e2
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x30(%rbx)
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x30(%rax), %r12
movq 0x30(%rbx), %r13
addq %r12, %r13
movq 0x28(%rbx), %rax
cmpq %r13, %rax
ja 0x9243d
movq %rsi, 0x8(%rsp)
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movq 0x20(%rbx), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
je 0x924af
movq %r13, 0x28(%rbx)
movq %rax, 0x20(%rbx)
movq 0x8(%rsp), %rsi
movl 0x20(%rsp), %r13d
orl %r13d, %r15d
orl 0x4(%rsp), %r15d
orl 0x18(%rsp), %r15d
testq %r12, %r12
je 0x92468
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r12, %rdx
callq 0x43c0
addq %r12, 0x30(%rbx)
movq %r14, %rdi
callq 0x4f82d
movq 0x30(%rsp), %rdi
callq 0x4f82d
movq 0x28(%rsp), %rdi
callq 0x4f82d
testl %r15d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl 0x24(%rsp), %ecx
movq 0x38(%rsp), %rdx
jle 0x924b4
addl %ecx, %ebp
addl %edx, %ebp
movq 0x10(%rsp), %rax
addl %r13d, %eax
addl %ebp, %eax
addl 0x4(%rsp), %eax
addl 0x18(%rsp), %eax
jmp 0x924b4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %cl
jmp 0x921be