// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rax
movl %ecx, (%rsp)
movl %edx, %ebp
movl %esi, %r12d
movq %rdi, %r14
movl $0x240, %edi            # imm = 0x240
callq 0x4700
testq %rax, %rax
je 0x4cf98
movq %rax, %rbx
movslq %r12d, %r13
movl $0x4, (%rax)
leaq -0xe4(%rip), %rax       # 0x4cacd
movq %rax, 0x18(%rbx)
leaq -0x72(%rip), %rax       # 0x4cb4a
movq %rax, 0x10(%rbx)
cmpl $0x4, %r13d
jg 0x4cbe8
testl %r12d, %r12d
jle 0x4cbdf
movzbl (%r14), %eax
shrl $0x4, %eax
leaq 0x7b27(%rip), %rcx      # 0x54700
cmpl %r12d, (%rcx,%rax,4)
jle 0x4cbe8
xorl %edi, %edi
xorl %eax, %eax
jmp 0x4cc87
movzbl (%r14), %edi
movl $0x1, %eax
testb %dil, %dil
jns 0x4cc87
movzbl 0x1(%r14), %eax
cmpb $-0x41, %dil
ja 0x4cc14
andl $0x3f, %edi
shll $0x8, %edi
orl %eax, %edi
movl $0x2, %eax
jmp 0x4cc87
cmpb $-0x21, %dil
ja 0x4cc33
shll $0x8, %eax
movzbl 0x2(%r14), %ecx
andl $0x1f, %edi
shll $0x10, %edi
orl %eax, %edi
orl %ecx, %edi
movl $0x3, %eax
jmp 0x4cc87
cmpb $-0x11, %dil
ja 0x4cc5c
shll $0x10, %eax
movzbl 0x2(%r14), %ecx
shll $0x8, %ecx
movzbl 0x3(%r14), %edx
andl $0xf, %edi
shll $0x18, %edi
orl %eax, %edi
orl %ecx, %edi
orl %edx, %edi
movl $0x4, %eax
jmp 0x4cc87
shll $0x1c, %edi
shll $0x14, %eax
orl %edi, %eax
movzbl 0x2(%r14), %ecx
shll $0xc, %ecx
orl %eax, %ecx
movzbl 0x3(%r14), %eax
shll $0x4, %eax
orl %ecx, %eax
movzbl 0x4(%r14), %edi
andl $0xf, %edi
orl %eax, %edi
movl $0x5, %eax
leaq (%r14,%rax), %r12
movq %r13, %rcx
subq %rax, %rcx
cmpq $0x4, %rcx
movl %ebp, 0x4(%rsp)
jg 0x4ccc1
cmpq %rax, %r13
jle 0x4ccb8
movzbl (%r12), %eax
shrl $0x4, %eax
leaq 0x7a51(%rip), %rdx      # 0x54700
movslq (%rdx,%rax,4), %rax
cmpq %rax, %rcx
jge 0x4ccc1
xorl %edx, %edx
xorl %eax, %eax
jmp 0x4cd64
movzbl (%r12), %edx
movl $0x1, %eax
testb %dl, %dl
jns 0x4cd64
movzbl 0x1(%r12), %eax
cmpb $-0x41, %dl
ja 0x4cced
andl $0x3f, %edx
shll $0x8, %edx
orl %eax, %edx
movl $0x2, %eax
jmp 0x4cd64
cmpb $-0x21, %dl
ja 0x4cd0c
shll $0x8, %eax
movzbl 0x2(%r12), %ecx
andl $0x1f, %edx
shll $0x10, %edx
orl %eax, %edx
orl %ecx, %edx
movl $0x3, %eax
jmp 0x4cd64
cmpb $-0x11, %dl
ja 0x4cd36
shll $0x10, %eax
movzbl 0x2(%r12), %ecx
shll $0x8, %ecx
movzbl 0x3(%r12), %esi
andl $0xf, %edx
shll $0x18, %edx
orl %eax, %edx
orl %ecx, %edx
orl %esi, %edx
movl $0x4, %eax
jmp 0x4cd64
shll $0x1c, %edx
shll $0x14, %eax
orl %edx, %eax
movzbl 0x2(%r12), %ecx
shll $0xc, %ecx
orl %eax, %ecx
movzbl 0x3(%r12), %eax
shll $0x4, %eax
orl %ecx, %eax
movzbl 0x4(%r12), %edx
andl $0xf, %edx
orl %eax, %edx
movl $0x5, %eax
testl %edx, %edx
js 0x4cf8b
leaq (%r14,%r13), %r15
addq %rax, %r12
movq %r15, %rax
subq %r12, %rax
movl %edx, %ebp
cmpq %rbp, %rax
jl 0x4cf8b
movq %r12, %rsi
movl $0x1, %ecx
movl (%rsp), %r8d
callq 0x4cfac
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x4cf90
addq %rbp, %r12
movq %r15, %rax
subq %r12, %rax
cmpq $0x4, %rax
jg 0x4cdd7
cmpq %r15, %r12
jae 0x4cdce
movzbl (%r12), %ecx
shrl $0x4, %ecx
leaq 0x793b(%rip), %rdx      # 0x54700
movslq (%rdx,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x4cdd7
xorl %edi, %edi
xorl %eax, %eax
jmp 0x4ce7e
movzbl (%r12), %edi
movl $0x1, %eax
testb %dil, %dil
jns 0x4ce7e
movzbl 0x1(%r12), %eax
cmpb $-0x41, %dil
ja 0x4ce05
andl $0x3f, %edi
shll $0x8, %edi
orl %eax, %edi
movl $0x2, %eax
jmp 0x4ce7e
cmpb $-0x21, %dil
ja 0x4ce25
shll $0x8, %eax
movzbl 0x2(%r12), %ecx
andl $0x1f, %edi
shll $0x10, %edi
orl %eax, %edi
orl %ecx, %edi
movl $0x3, %eax
jmp 0x4ce7e
cmpb $-0x11, %dil
ja 0x4ce50
shll $0x10, %eax
movzbl 0x2(%r12), %ecx
shll $0x8, %ecx
movzbl 0x3(%r12), %edx
andl $0xf, %edi
shll $0x18, %edi
orl %eax, %edi
orl %ecx, %edi
orl %edx, %edi
movl $0x4, %eax
jmp 0x4ce7e
shll $0x1c, %edi
shll $0x14, %eax
orl %edi, %eax
movzbl 0x2(%r12), %ecx
shll $0xc, %ecx
orl %eax, %ecx
movzbl 0x3(%r12), %eax
shll $0x4, %eax
orl %ecx, %eax
movzbl 0x4(%r12), %edi
andl $0xf, %edi
orl %eax, %edi
movl $0x5, %eax
addq %rax, %r12
movq %r15, %rax
subq %r12, %rax
cmpq $0x4, %rax
jg 0x4ceb3
cmpq %r15, %r12
jae 0x4ceaa
movzbl (%r12), %ecx
shrl $0x4, %ecx
leaq 0x785f(%rip), %rdx      # 0x54700
movslq (%rdx,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x4ceb3
xorl %edx, %edx
xorl %eax, %eax
jmp 0x4cf56
movzbl (%r12), %edx
movl $0x1, %eax
testb %dl, %dl
jns 0x4cf56
movzbl 0x1(%r12), %eax
cmpb $-0x41, %dl
ja 0x4cedf
andl $0x3f, %edx
shll $0x8, %edx
orl %eax, %edx
movl $0x2, %eax
jmp 0x4cf56
cmpb $-0x21, %dl
ja 0x4cefe
shll $0x8, %eax
movzbl 0x2(%r12), %ecx
andl $0x1f, %edx
shll $0x10, %edx
orl %eax, %edx
orl %ecx, %edx
movl $0x3, %eax
jmp 0x4cf56
cmpb $-0x11, %dl
ja 0x4cf28
shll $0x10, %eax
movzbl 0x2(%r12), %ecx
shll $0x8, %ecx
movzbl 0x3(%r12), %esi
andl $0xf, %edx
shll $0x18, %edx
orl %eax, %edx
orl %ecx, %edx
orl %esi, %edx
movl $0x4, %eax
jmp 0x4cf56
shll $0x1c, %edx
shll $0x14, %eax
orl %edx, %eax
movzbl 0x2(%r12), %ecx
shll $0xc, %ecx
orl %eax, %ecx
movzbl 0x3(%r12), %eax
shll $0x4, %eax
orl %ecx, %eax
movzbl 0x4(%r12), %edx
andl $0xf, %edx
orl %eax, %edx
movl $0x5, %eax
testl %edx, %edx
js 0x4cf8b
addq %rax, %r12
subq %r12, %r15
movl %edx, %ebp
cmpq %rbp, %r15
jl 0x4cf8b
movq %r12, %rsi
movl 0x4(%rsp), %ecx
movl (%rsp), %r8d
callq 0x4cfac
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x4cf90
addq %rbp, %r12
subq %r14, %r12
cmpq %r13, %r12
je 0x4cf9a
callq 0x626e
movq %rbx, %rdi
callq 0x4610
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq