// File: /workspace/github_c_makefile_star2_O1/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, %r12d
movq %rsi, %rbx
movq %rdi, %r14
testq %rdx, %rdx
je 0x90a2c
movq %rdx, %r13
movq %rdx, %rdi
callq 0x41d0
movq %rax, %r15
movq 0x30(%rbx), %rbp
addq %rax, %rbp
movq 0x28(%rbx), %rax
cmpq %rbp, %rax
ja 0x909fa
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 0x90bcd
movq %rbp, 0x28(%rbx)
movq %rax, 0x20(%rbx)
testq %r15, %r15
je 0x90a16
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, 0x30(%rbx)
xorl %eax, %eax
xorl %ebp, %ebp
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb %al, %al
cmovel %r15d, %ebp
je 0x90a2e
jmp 0x90bbc
xorl %ebp, %ebp
movq 0x70(%r14), %r13
xorl %r15d, %r15d
xorl %edi, %edi
xorl %esi, %esi
callq 0x4ee42
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x90bbc
movq %r13, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl %r12d, %ecx
callq *0x38(%r13)
movl %eax, 0x4(%rsp)
movq 0x10(%r14), %rax
movl (%r14), %esi
movq %rbx, %rdi
callq *0x58(%rax)
movl %eax, %r13d
addl %eax, %ebp
cmpl $0x0, 0x78(%r14)
jle 0x90aa1
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x10(%r14), %rax
movl 0x7c(%r14,%r12,4), %edi
callq *0x78(%rax)
addl %eax, %r15d
orl %eax, %r13d
incq %r12
movslq 0x78(%r14), %rax
cmpq %rax, %r12
jl 0x90a83
movq 0x10(%r14), %rax
movq 0x58(%rax), %rcx
movq %rcx, 0x10(%rsp)
movslq 0x60(%r14), %rdi
callq *0x78(%rax)
movl %eax, %r12d
movq 0x10(%r14), %rax
movslq 0x78(%r14), %rdi
callq *0x78(%rax)
addl 0x4(%rsp), %r12d
addl %r15d, %r12d
addl %eax, %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq *0x10(%rsp)
movl %eax, %r12d
movq 0x10(%r14), %rax
movl 0x60(%r14), %esi
movq %rbx, %rdi
callq *0x58(%rax)
addl %eax, %ebp
orl %eax, %r13d
movq 0x10(%r14), %rax
movl 0x78(%r14), %esi
movq %rbx, %rdi
callq *0x58(%rax)
addl %eax, %ebp
addl %r12d, %ebp
orl %eax, %r13d
orl %r12d, %r13d
cmpl $0x0, 0x78(%r14)
jle 0x90b31
xorl %r15d, %r15d
movq 0x10(%r14), %rax
movl 0x7c(%r14,%r15,4), %esi
movq %rbx, %rdi
callq *0x58(%rax)
addl %eax, %ebp
orl %eax, %r13d
incq %r15
movslq 0x78(%r14), %rax
cmpq %rax, %r15
jl 0x90b11
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r15
movq 0x30(%rax), %r14
movq 0x30(%rbx), %r12
addq %r14, %r12
movq 0x28(%rbx), %rax
cmpq %r12, %rax
ja 0x90b87
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r12, %rax
cmovaq %rax, %r12
movq 0x20(%rbx), %rdi
movq %r12, %rsi
callq 0x4840
testq %rax, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
je 0x90bbc
movq %r12, 0x28(%rbx)
movq %rax, 0x20(%rbx)
testq %r14, %r14
je 0x90ba3
movq 0x20(%rbx), %rdi
addq 0x30(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x43c0
addq %r14, 0x30(%rbx)
movq 0x8(%rsp), %rdi
callq 0x4f82d
addl 0x4(%rsp), %ebp
testl %r13d, %r13d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovgl %ebp, %ecx
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
jmp 0x90a18