// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/cram/cram_codecs.c
// Function: cram_byte_array_len_decode_init
cram_codec *cram_byte_array_len_decode_init(char *data, int size,
					    enum cram_external_type option,
					    int version) {
    cram_codec *c;
    char *cp   = data;
    char *endp = data + size;
    int32_t encoding = 0;
    int32_t sub_size = -1;

    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;
    
    cp += safe_itf8_get(cp, endp, &encoding);
    cp += safe_itf8_get(cp, endp, &sub_size);
    if (sub_size < 0 || endp - cp < sub_size)
        goto malformed;
    c->byte_array_len.len_codec = cram_decoder_init(encoding, cp, sub_size,
						    E_INT, version);
    if (c->byte_array_len.len_codec == NULL)
        goto no_codec;
    cp += sub_size;

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

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

    return c;

 malformed:
    fprintf(stderr, "Malformed byte_array_len header stream\n");
 no_codec:
    free(c);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %r12d
movl %esi, %r15d
andl $0x0, (%rsp)
movq %rdi, %r14
orl $-0x1, 0x4(%rsp)
movl $0x240, %edi            # imm = 0x240
callq 0x46f0
testq %rax, %rax
je 0x3e425
movq %rax, %rbx
movl %r12d, 0xc(%rsp)
movslq %r15d, %rax
movq %rax, 0x10(%rsp)
leaq (%r14,%rax), %r12
movl $0x4, (%rbx)
leaq -0xf9(%rip), %rax       # 0x3e21c
movq %rax, 0x18(%rbx)
leaq -0x8c(%rip), %rax       # 0x3e294
movq %rax, 0x10(%rbx)
movq %rsp, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3bc89
movl %eax, %r13d
addq %r14, %r13
leaq 0x4(%rsp), %r15
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3bc89
movslq (%r15), %r15
testq %r15, %r15
js 0x3e401
movl %eax, %eax
addq %rax, %r13
movq %r12, %rax
subq %r13, %rax
cmpq %r15, %rax
jl 0x3e401
movl (%rsp), %edi
pushq $0x1
popq %rcx
movq %r13, %rsi
movl %r15d, %edx
movl %ebp, %r8d
callq 0x3e439
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x3e41d
addq %r15, %r13
movl %ebp, 0x8(%rsp)
leaq 0x4(%rsp), %rbp
orl $-0x1, (%rbp)
movq %rsp, %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x3bc89
movl %eax, %r15d
addq %r13, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x3bc89
movslq (%rbp), %r13
movl 0x8(%rsp), %r8d
testq %r13, %r13
js 0x3e401
movl %eax, %eax
addq %rax, %r15
subq %r15, %r12
cmpq %r13, %r12
jl 0x3e401
movl (%rsp), %edi
movq %r15, %rsi
movl %r13d, %edx
movl 0xc(%rsp), %ecx
callq 0x3e439
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x3e41d
addq %r13, %r15
subq %r14, %r15
cmpq 0x10(%rsp), %r15
je 0x3e427
movq 0x18bc8(%rip), %rax     # 0x56fd0
movq (%rax), %rcx
leaq 0x93c6(%rip), %rdi      # 0x477d8
pushq $0x27
popq %rsi
pushq $0x1
popq %rdx
callq 0x4a20
movq %rbx, %rdi
callq 0x4600
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq