// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movl $0x240, %edi            # imm = 0x240
callq 0x69c0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0xd211b
movq $0x0, -0x8(%rbp)
jmp 0xd22d5
movq -0x28(%rbp), %rax
movl $0x4, (%rax)
movq -0x28(%rbp), %rax
leaq -0x1a0(%rip), %rcx      # 0xd1f90
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
leaq -0xef(%rip), %rcx       # 0xd2050
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0xcd280
movl %eax, %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0xcd280
movl %eax, %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x40(%rbp)
jl 0xd219f
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movslq -0x40(%rbp), %rcx
cmpq %rcx, %rax
jge 0xd21a4
jmp 0xd22ac
movl -0x3c(%rbp), %edi
movq -0x30(%rbp), %rsi
movl -0x40(%rbp), %edx
movl -0x1c(%rbp), %r8d
movl $0x1, %ecx
callq 0xd22e0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0xd21d7
jmp 0xd22c4
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0xcd280
movl %eax, %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0xcd280
movl %eax, %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x40(%rbp)
jl 0xd224b
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movslq -0x40(%rbp), %rcx
cmpq %rcx, %rax
jge 0xd224d
jmp 0xd22ac
movl -0x3c(%rbp), %edi
movq -0x30(%rbp), %rsi
movl -0x40(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
callq 0xd22e0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0xd227b
jmp 0xd22c4
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
je 0xd22a2
jmp 0xd22ac
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd22d5
movq 0x32d1d(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x13a3f(%rip), %rsi     # 0xe5cfc
movb $0x0, %al
callq 0x6a80
movq -0x28(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop