// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_xdelta_encode_store
int cram_xdelta_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_xdelta.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
    len += (n = c->vv->varint_put32_blk(b, c->vv->varint_size(c->u.e_xdelta.word_size)
                                        + len2)); r |= n;

    // This and sub-codec
    len += (n = c->vv->varint_put32_blk(b, c->u.e_xdelta.word_size)); 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 $0x28, %rsp
movl %ecx, %r13d
movq %rsi, %r14
movq %rdi, %r15
testq %rdx, %rdx
je 0x8ebb2
movq %rdx, %r12
movq %rdx, %rdi
callq 0x41d0
movq %rax, %rbp
movq 0x30(%r14), %rbx
addq %rax, %rbx
movq 0x28(%r14), %rax
cmpq %rbx, %rax
ja 0x8eb8f
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %rbx, %rax
cmovaq %rax, %rbx
movq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x4840
testq %rax, %rax
je 0x8ecd5
movq %rbx, 0x28(%r14)
movq %rax, 0x20(%r14)
testq %rbp, %rbp
je 0x8ebab
movq 0x20(%r14), %rdi
addq 0x30(%r14), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x43c0
addq %rbp, 0x30(%r14)
movq %rbp, 0x18(%rsp)
jmp 0x8ebbb
movq $0x0, 0x18(%rsp)
movq 0x78(%r15), %rbx
xorl %edi, %edi
xorl %esi, %esi
callq 0x4c675
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x8ecda
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq *0x38(%rbx)
movl %eax, %r13d
movq 0x10(%r15), %rax
movl (%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
movl %eax, 0x14(%rsp)
movq 0x10(%r15), %rax
movq 0x58(%rax), %rbx
movzbl 0x68(%r15), %edi
callq *0x78(%rax)
leal (%rax,%r13), %esi
movq %r14, %rdi
callq *%rbx
movl %eax, 0x10(%rsp)
movq 0x10(%r15), %rax
movzbl 0x68(%r15), %esi
movq %r14, %rdi
callq *0x58(%rax)
movl %eax, 0xc(%rsp)
movq 0x20(%r12), %rsi
movq 0x30(%r12), %r15
movq 0x30(%r14), %rbx
addq %r15, %rbx
movq 0x28(%r14), %rax
cmpq %rbx, %rax
ja 0x8ec83
movq %rsi, 0x20(%rsp)
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %rbx, %rax
cmovaq %rax, %rbx
movq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x4840
testq %rax, %rax
je 0x8ecda
movq %rbx, 0x28(%r14)
movq %rax, 0x20(%r14)
movq 0x20(%rsp), %rsi
testq %r15, %r15
je 0x8ec9c
movq 0x20(%r14), %rdi
addq 0x30(%r14), %rdi
movq %r15, %rdx
callq 0x43c0
addq %r15, 0x30(%r14)
movl 0x10(%rsp), %r14d
movl %r14d, %ebx
movl 0x14(%rsp), %ebp
orl %ebp, %ebx
movl 0xc(%rsp), %r15d
orl %r15d, %ebx
movq %r12, %rdi
callq 0x4ceb6
addl 0x18(%rsp), %r13d
addl %ebp, %r13d
addl %r14d, %r13d
addl %r15d, %r13d
testl %ebx, %ebx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmovgl %r13d, %ebp
jmp 0x8ecda
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq