// File: /workspace/github_c_makefile_star2_O2/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, %r13d
movq %rsi, %r14
movq %rdi, %r15
pushq $-0x1
popq %rbx
testq %rdx, %rdx
je 0x70b64
movq %rdx, %r12
movq %rdx, %rdi
callq 0x41d0
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x6f15a
xorl %ecx, %ecx
testl %eax, %eax
cmovsl %ecx, %ebp
jns 0x70b66
jmp 0x70c8f
xorl %ebp, %ebp
movq %rbp, 0x8(%rsp)
movq 0x70(%r15), %r12
xorl %ebp, %ebp
xorl %edi, %edi
xorl %esi, %esi
callq 0x3f426
testq %rax, %rax
je 0x70c8f
movq %r12, %rdi
movq %rax, 0x10(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq *0x38(%r12)
movl %eax, 0x4(%rsp)
movq 0x10(%r15), %rax
movl (%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
movl %eax, %r13d
xorl %ebx, %ebx
movl %eax, %r12d
movslq 0x78(%r15), %rax
cmpq %rax, %rbx
jge 0x70bd0
movq 0x10(%r15), %rax
movl 0x7c(%r15,%rbx,4), %edi
callq *0x78(%rax)
addl %eax, %ebp
orl %eax, %r12d
incq %rbx
jmp 0x70bb1
addl 0x8(%rsp), %r13d
movq 0x10(%r15), %rax
movq 0x58(%rax), %rcx
movq %rcx, 0x8(%rsp)
movslq 0x60(%r15), %rdi
callq *0x78(%rax)
movl %eax, %ebx
movq 0x10(%r15), %rax
movslq 0x78(%r15), %rdi
callq *0x78(%rax)
addl 0x4(%rsp), %ebp
addl %ebx, %ebp
addl %eax, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq *0x8(%rsp)
movl %eax, %ebx
movq 0x10(%r15), %rax
movl 0x60(%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
addl %eax, %r13d
orl %eax, %r12d
movq 0x10(%r15), %rax
movl 0x78(%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
addl %eax, %r13d
addl %ebx, %r13d
orl %eax, %r12d
orl %ebx, %r12d
xorl %ebx, %ebx
movslq 0x78(%r15), %rax
cmpq %rax, %rbx
jge 0x70c5c
movq 0x10(%r15), %rax
movl 0x7c(%r15,%rbx,4), %esi
movq %r14, %rdi
callq *0x58(%rax)
addl %eax, %r13d
orl %eax, %r12d
incq %rbx
jmp 0x70c39
movq 0x10(%rsp), %r15
movq 0x20(%r15), %rsi
movq 0x30(%r15), %rdx
movq %r14, %rdi
callq 0x6f15a
testl %eax, %eax
pushq $-0x1
popq %rbx
js 0x70c8f
movq %r15, %rdi
callq 0x3f8fc
addl 0x4(%rsp), %r13d
testl %r12d, %r12d
pushq $-0x1
popq %rbx
cmovgl %r13d, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq