// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xe7df5
movq -0x20(%rbp), %rdi
callq 0x41b0
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0xe2300
cmpl $0x0, %eax
jge 0xe7de7
jmp 0xe8055
movq -0x58(%rbp), %rcx
movslq -0x28(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x28(%rbp)
xorl %esi, %esi
movl %esi, %edi
callq 0x6ede0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe7e15
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe805c
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x5c(%rbp)
cmpl $0x100, -0x5c(%rbp)     # imm = 0x100
jge 0xe7e82
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpl $0x0, 0x90(%rax,%rcx,4)
jle 0xe7e75
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq -0x40(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq *%rax
movl %eax, -0x30(%rbp)
addl -0x64(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x30(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0xe7e77
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0xe7e2a
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0x38(%rbp)
xorl %esi, %esi
movl %esi, %edi
callq 0x6ede0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xe7eae
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe805c
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x24(%rbp), %ecx
xorl %edx, %edx
callq *%rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x38(%rbp)
xorl %esi, %esi
movl %esi, %edi
callq 0x6ede0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xe7ef7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe805c
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x24(%rbp), %ecx
xorl %edx, %edx
callq *%rax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl (%rcx), %esi
callq *%rax
movl %eax, -0x30(%rbp)
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x30(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x64(%rbp), %eax
addl -0x68(%rbp), %eax
addl -0x6c(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x78(%rax), %rax
movslq -0x60(%rbp), %rdi
callq *%rax
movl -0x84(%rbp), %esi
movq -0x80(%rbp), %rdi
movl %eax, %ecx
movq -0x78(%rbp), %rax
addl %ecx, %esi
callq *%rax
movl %eax, -0x30(%rbp)
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x30(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movq -0x18(%rbp), %rdi
movl -0x60(%rbp), %esi
callq *%rax
movl %eax, -0x30(%rbp)
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x30(%rbp), %eax
orl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x40(%rbp), %rax
movq 0x30(%rax), %rdx
callq 0xe2300
cmpl $0x0, %eax
jge 0xe7fe1
jmp 0xe8055
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rdx
callq 0xe2300
cmpl $0x0, %eax
jge 0xe8001
jmp 0xe8055
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdx
callq 0xe2300
cmpl $0x0, %eax
jge 0xe8021
jmp 0xe8055
movq -0x40(%rbp), %rdi
callq 0x6f940
movq -0x48(%rbp), %rdi
callq 0x6f940
movq -0x50(%rbp), %rdi
callq 0x6f940
cmpl $0x0, -0x2c(%rbp)
jle 0xe8053
movl -0x28(%rbp), %eax
addl -0x64(%rbp), %eax
addl -0x68(%rbp), %eax
addl -0x6c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xe805c
jmp 0xe8055
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)