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

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

    // Store sub-codec
    cram_codec *tc = c->u.e_xpack.sub_codec;
    cram_block *tb = cram_new_block(0, 0);
    if (!tb)
        return -1;
    int len2 = tc->store(tc, tb, NULL, version);

    len += (n = c->vv->varint_put32_blk(b, c->codec)); r |= n;

    // codec length
    int len1 = 0, i;
    for (i = 0; i < c->u.e_xpack.nval; i++)
        len1 += (n = c->vv->varint_size(c->u.e_xpack.rmap[i])), r |= n;
    len += (n = c->vv->varint_put32_blk(b, c->vv->varint_size(c->u.e_xpack.nbits)
                                        +  c->vv->varint_size(c->u.e_xpack.nval)
                                        + len1 + len2)); r |= n;

    // The map and sub-codec
    len += (n = c->vv->varint_put32_blk(b, c->u.e_xpack.nbits)); r |= n;
    len += (n = c->vv->varint_put32_blk(b, c->u.e_xpack.nval));  r |= n;
    for (i = 0; i < c->u.e_xpack.nval; i++)
        len += (n = c->vv->varint_put32_blk(b, c->u.e_xpack.rmap[i])), r |= n;

    BLOCK_APPEND(b, BLOCK_DATA(tb), BLOCK_SIZE(tb));

    cram_free_block(tb);

    return r > 0 ? len + len2 : -1;

 block_err:
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movq %rsi, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0x8e0d2
movq %rdx, %r12
movq %rdx, %rdi
callq 0x41d0
movq %rax, %rbx
movq 0x30(%r14), %r13
addq %rax, %r13
movq 0x28(%r14), %rax
cmpq %r13, %rax
ja 0x8e0b4
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movq 0x20(%r14), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
je 0x8e25d
movq %r13, 0x28(%r14)
movq %rax, 0x20(%r14)
testq %rbx, %rbx
je 0x8e0d4
movq 0x20(%r14), %rdi
addq 0x30(%r14), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x43c0
addq %rbx, 0x30(%r14)
jmp 0x8e0d4
xorl %ebx, %ebx
movq 0x70(%r15), %r13
xorl %r12d, %r12d
xorl %edi, %edi
xorl %esi, %esi
callq 0x4c675
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x8e262
movq %r13, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl %ebp, %ecx
callq *0x38(%r13)
movl %eax, 0x4(%rsp)
movq 0x10(%r15), %rax
movl (%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
movl %eax, %ebp
addl %eax, %ebx
cmpl $0x0, 0x78(%r15)
jle 0x8e144
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x10(%r15), %rax
movl 0x7c(%r15,%r13,4), %edi
callq *0x78(%rax)
addl %eax, %r12d
orl %eax, %ebp
incq %r13
movslq 0x78(%r15), %rax
cmpq %rax, %r13
jl 0x8e127
movq 0x10(%r15), %rax
movq 0x58(%rax), %rcx
movq %rcx, 0x10(%rsp)
movslq 0x60(%r15), %rdi
callq *0x78(%rax)
movl %eax, %r13d
movq 0x10(%r15), %rax
movslq 0x78(%r15), %rdi
callq *0x78(%rax)
addl 0x4(%rsp), %r13d
addl %r12d, %r13d
addl %eax, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq *0x10(%rsp)
movl %eax, %r13d
movq 0x10(%r15), %rax
movl 0x60(%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
addl %eax, %ebx
orl %eax, %ebp
movq 0x10(%r15), %rax
movl 0x78(%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
addl %eax, %ebx
addl %r13d, %ebx
orl %eax, %ebp
orl %r13d, %ebp
cmpl $0x0, 0x78(%r15)
jle 0x8e1d1
xorl %r12d, %r12d
movq 0x10(%r15), %rax
movl 0x7c(%r15,%r12,4), %esi
movq %r14, %rdi
callq *0x58(%rax)
addl %eax, %ebx
orl %eax, %ebp
incq %r12
movslq 0x78(%r15), %rax
cmpq %rax, %r12
jl 0x8e1b2
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r12
movq 0x30(%rax), %r15
movq 0x30(%r14), %r13
addq %r15, %r13
movq 0x28(%r14), %rax
cmpq %r13, %rax
ja 0x8e227
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movq 0x20(%r14), %rdi
movq %r13, %rsi
callq 0x4840
testq %rax, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
je 0x8e262
movq %r13, 0x28(%r14)
movq %rax, 0x20(%r14)
testq %r15, %r15
je 0x8e243
movq 0x20(%r14), %rdi
addq 0x30(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, 0x30(%r14)
movq 0x8(%rsp), %rdi
callq 0x4ceb6
addl 0x4(%rsp), %ebx
testl %ebp, %ebp
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovgl %ebx, %ecx
jmp 0x8e262
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq