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

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

    tc = c->u.e_byte_array_len.len_codec;
    b_len = cram_new_block(0, 0);
    if (!b_len) goto block_err;
    len2 = tc->store(tc, b_len, NULL, version);
    if (len2 < 0) goto block_err;

    tc = c->u.e_byte_array_len.val_codec;
    b_val = cram_new_block(0, 0);
    if (!b_val) goto block_err;
    len3 = tc->store(tc, b_val, NULL, version);
    if (len3 < 0) goto block_err;

    len += (n = c->vv->varint_put32_blk(b, c->codec));  r |= n;
    len += (n = c->vv->varint_put32_blk(b, len2+len3)); r |= n;
    BLOCK_APPEND(b, BLOCK_DATA(b_len), BLOCK_SIZE(b_len));
    BLOCK_APPEND(b, BLOCK_DATA(b_val), BLOCK_SIZE(b_val));

    cram_free_block(b_len);
    cram_free_block(b_val);

    if (r > 0)
        return len + len2 + len3;

 block_err:
    if (b_len) cram_free_block(b_len);
    if (b_val) cram_free_block(b_val);
    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, %r12
testq %rdx, %rdx
je 0x91cf8
movq %rdx, %r15
movq %rdx, %rdi
callq 0x41d0
movq %rax, %rbx
movq 0x30(%r14), %rbp
addq %rax, %rbp
movq 0x28(%r14), %rax
cmpq %rbp, %rax
ja 0x91cda
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %rbp, %rax
cmovaq %rax, %rbp
movq 0x20(%r14), %rdi
movq %rbp, %rsi
callq 0x4840
testq %rax, %rax
je 0x91ee1
movq %rbp, 0x28(%r14)
movq %rax, 0x20(%r14)
testq %rbx, %rbx
je 0x91cfa
movq 0x20(%r14), %rdi
addq 0x30(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x43c0
addq %rbx, 0x30(%r14)
jmp 0x91cfa
xorl %ebx, %ebx
movq 0x78(%r12), %rbp
xorl %edi, %edi
xorl %esi, %esi
callq 0x4c675
movq %rax, %r15
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r15, %r15
je 0x91ee6
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq *0x38(%rbp)
movq %rax, 0x20(%rsp)
testl %eax, %eax
js 0x91db8
movq 0x80(%r12), %rbp
xorl %edi, %edi
xorl %esi, %esi
callq 0x4c675
testq %rax, %rax
je 0x91db8
movq %rbp, %rdi
movq %rax, 0x10(%rsp)
movq %rax, %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq *0x38(%rbp)
movq %rax, 0x18(%rsp)
testl %eax, %eax
js 0x91ecf
movq 0x10(%r12), %rax
movl (%r12), %esi
movq %r14, %rdi
callq *0x58(%rax)
movl %eax, 0x4(%rsp)
movq 0x10(%r12), %rax
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdx
leal (%rdx,%rcx), %esi
movq %r14, %rdi
callq *0x58(%rax)
movl %eax, (%rsp)
movq 0x20(%r15), %rsi
movq 0x30(%r15), %rbp
movq 0x28(%r14), %rax
movq 0x30(%r14), %r13
movq %r13, %r12
addq %rbp, %r12
cmpq %r12, %rax
jbe 0x91dc0
movq %rax, %r12
jmp 0x91e06
movq %r15, %rdi
jmp 0x91edc
movq %rsi, 0x8(%rsp)
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r12, %rax
cmovaq %rax, %r12
movq 0x20(%r14), %rdi
movq %r12, %rsi
callq 0x4840
testq %rax, %rax
je 0x91ecf
movq %r12, 0x28(%r14)
movq %rax, 0x20(%r14)
movq 0x30(%r14), %r13
movq 0x8(%rsp), %rsi
testq %rbp, %rbp
je 0x91e29
addq 0x20(%r14), %r13
movq %r13, %rdi
movq %rbp, %rdx
callq 0x43c0
addq 0x30(%r14), %rbp
movq %rbp, 0x30(%r14)
movq 0x28(%r14), %r12
movq %rbp, %r13
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x30(%rax), %rbp
addq %rbp, %r13
cmpq %r13, %r12
ja 0x91e7d
movq %rsi, 0x8(%rsp)
leaq 0x320(%r12), %rax
shrq $0x2, %rax
addq %r12, %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 0x91ecf
movq %r13, 0x28(%r14)
movq %rax, 0x20(%r14)
movq 0x8(%rsp), %rsi
movl (%rsp), %r12d
orl 0x4(%rsp), %r12d
testq %rbp, %rbp
je 0x91e9f
movq 0x20(%r14), %rdi
addq 0x30(%r14), %rdi
movq %rbp, %rdx
callq 0x43c0
addq %rbp, 0x30(%r14)
movq %r15, %rdi
callq 0x4ceb6
movq 0x10(%rsp), %rdi
callq 0x4ceb6
testl %r12d, %r12d
jle 0x91ecf
movq 0x20(%rsp), %rax
addl %ebx, %eax
movq 0x18(%rsp), %rcx
addl 0x4(%rsp), %ecx
addl %eax, %ecx
addl (%rsp), %ecx
movl %ecx, %eax
jmp 0x91ee6
movq %r15, %rdi
callq 0x4ceb6
movq 0x10(%rsp), %rdi
callq 0x4ceb6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq