// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_byte_array_len_decode_init
cram_codec *cram_byte_array_len_decode_init(cram_block_compression_hdr *hdr,
                                            char *data, int size,
                                            enum cram_encoding codec,
                                            enum cram_external_type option,
                                            int version, varint_vec *vv) {
    cram_codec *c;
    char *cp   = data;
    char *endp = data + size;

    if (!(c = malloc(sizeof(*c))))
        return NULL;

    c->codec  = E_BYTE_ARRAY_LEN;
    c->decode = cram_byte_array_len_decode;
    c->free   = cram_byte_array_len_decode_free;
    c->describe = cram_byte_array_len_describe;
    c->u.byte_array_len.len_codec = NULL;
    c->u.byte_array_len.val_codec = NULL;

    int encoding = vv->varint_get32(&cp, endp, NULL);
    int sub_size = vv->varint_get32(&cp, endp, NULL);
    if (sub_size < 0 || endp - cp < sub_size)
        goto malformed;
    c->u.byte_array_len.len_codec = cram_decoder_init(hdr, encoding, cp, sub_size,
                                                      E_INT, version, vv);
    if (c->u.byte_array_len.len_codec == NULL)
        goto no_codec;
    cp += sub_size;

    encoding = vv->varint_get32(&cp, endp, NULL);
    sub_size = vv->varint_get32(&cp, endp, NULL);
    if (sub_size < 0 || endp - cp < sub_size)
        goto malformed;
    c->u.byte_array_len.val_codec = cram_decoder_init(hdr, encoding, cp, sub_size,
                                                      option, version, vv);
    if (c->u.byte_array_len.val_codec == NULL)
        goto no_codec;
    cp += sub_size;

    if (cp - data != size)
        goto malformed;

    return c;

 malformed:
    hts_log_error("Malformed byte_array_len header stream");
 no_codec:
    cram_byte_array_len_decode_free(c);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r12d
movl %r8d, %ebp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %r13
movq %rsi, 0x10(%rsp)
movl $0x880, %edi            # imm = 0x880
callq 0x4680
testq %rax, %rax
je 0x91b0b
movq %rax, %rbx
movl %r12d, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
movq 0x70(%rsp), %r12
movslq %r15d, %rax
movq %rax, 0x30(%rsp)
leaq (%r14,%rax), %r13
movl $0x4, (%rbx)
leaq -0x1ce(%rip), %rax      # 0x918bc
movq %rax, 0x28(%rbx)
leaq -0x15c(%rip), %rax      # 0x91939
movq %rax, 0x20(%rbx)
leaq -0x13c(%rip), %rax      # 0x91964
movq %rax, 0x58(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x18(%r12)
movq %rax, %r15
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x18(%r12)
testl %eax, %eax
js 0x91ae9
movq 0x10(%rsp), %rdx
movq %r13, %rcx
subq %rdx, %rcx
movl %eax, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq %rbp, %rcx
jge 0x91b1f
leaq 0x113b7(%rip), %rsi     # 0xa2ea7
leaq 0x113d0(%rip), %rdx     # 0xa2ec7
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
movq %rbx, %rdi
callq 0x91939
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %r12
addq $0x60, %r12
movq 0x70(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x20(%rsp), %rdi
movl %r15d, %esi
movl %eax, %ecx
movl $0x1, %r8d
movl 0x18(%rsp), %r9d
callq 0x8df2c
movq %rax, (%r12)
testq %rax, %rax
je 0x91b03
leaq 0x10(%rsp), %r15
addq %rbp, (%r15)
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq 0x70(%rsp), %r12
callq *0x18(%r12)
movq %rax, 0x28(%rsp)
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x18(%r12)
testl %eax, %eax
movl 0x18(%rsp), %r9d
js 0x91ae9
movq 0x10(%rsp), %rdx
subq %rdx, %r13
movl %eax, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq %rbp, %r13
jl 0x91ae9
movq 0x70(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl %eax, %ecx
movl 0x1c(%rsp), %r8d
callq 0x8df2c
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x91b03
addq 0x10(%rsp), %rbp
movq %rbp, 0x10(%rsp)
subq %r14, %rbp
cmpq 0x30(%rsp), %rbp
jne 0x91ae9
jmp 0x91b0d