// File: /workspace/github_cpp_makefile_star2_O3/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 0x4beb1
movq %rax, %rbx
movslq %r12d, %r15
movl $0x4, (%rax)
leaq -0xe4(%rip), %rax       # 0x4b9d5
movq %rax, 0x18(%rbx)
leaq -0x72(%rip), %rax       # 0x4ba52
movq %rax, 0x10(%rbx)
cmpl $0x5, %r15d
jge 0x4baf2
testl %r12d, %r12d
jle 0x4bae9
movzbl (%r14), %ecx
movl %ecx, %eax
shrl $0x4, %eax
leaq 0x6d7d(%rip), %rdx      # 0x52860
cmpl %r12d, (%rdx,%rax,4)
jle 0x4baf5
xorl %edi, %edi
xorl %eax, %eax
jmp 0x4bb90
movb (%r14), %cl
movzbl %cl, %edi
movl $0x1, %eax
testb %dil, %dil
jns 0x4bb90
movzbl 0x1(%r14), %eax
cmpb $-0x41, %cl
ja 0x4bb1f
andl $0x3f, %edi
shll $0x8, %edi
orl %eax, %edi
movl $0x2, %eax
jmp 0x4bb90
cmpb $-0x21, %cl
ja 0x4bb3d
shll $0x8, %eax
movzbl 0x2(%r14), %ecx
andl $0x1f, %edi
shll $0x10, %edi
orl %eax, %edi
orl %ecx, %edi
movl $0x3, %eax
jmp 0x4bb90
cmpb $-0x11, %cl
ja 0x4bb65
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 0x4bb90
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 %r15, %rcx
subq %rax, %rcx
cmpq $0x5, %rcx
movl %ebp, 0x4(%rsp)
jge 0x4bbc9
cmpq %rax, %r15
jle 0x4bbc3
movzbl (%r12), %edx
movl %edx, %eax
shrl $0x4, %eax
leaq 0x6ca6(%rip), %rsi      # 0x52860
movslq (%rsi,%rax,4), %rax
cmpq %rax, %rcx
jge 0x4bbcd
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x4bc3e
movb (%r12), %dl
movzbl %dl, %eax
movl $0x1, %ecx
testb %al, %al
jns 0x4bc3e
movzbl 0x1(%r12), %ecx
cmpb $-0x41, %dl
ja 0x4bbf3
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ecx
jmp 0x4bc3e
cmpb $-0x21, %dl
ja 0x4bc12
shll $0x8, %ecx
movzbl 0x2(%r12), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ecx
jmp 0x4bc3e
movzbl 0x2(%r12), %esi
cmpb $-0x11, %dl
ja 0x4bd2d
shll $0x10, %ecx
shll $0x8, %esi
movzbl 0x3(%r12), %edx
andl $0xf, %eax
shll $0x18, %eax
orl %ecx, %eax
orl %esi, %eax
orl %edx, %eax
movl $0x4, %ecx
addq %rcx, %r12
leaq (%r14,%r15), %rbp
movq %rbp, %rcx
subq %r12, %rcx
movl %eax, %r13d
cmpq %r13, %rcx
jl 0x4bea4
movq %r12, %rsi
movl %r13d, %edx
movl $0x1, %ecx
movl (%rsp), %r8d
callq 0x4bec5
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x4bea9
addq %r13, %r12
movq %rbp, %rax
subq %r12, %rax
cmpq $0x5, %rax
jge 0x4bcaf
cmpq %rbp, %r12
jae 0x4bca6
movzbl (%r12), %ecx
movl %ecx, %edx
shrl $0x4, %edx
leaq 0x6bc3(%rip), %rsi      # 0x52860
movslq (%rsi,%rdx,4), %rdx
cmpq %rdx, %rax
jge 0x4bcb3
xorl %edi, %edi
xorl %eax, %eax
jmp 0x4bd8f
movb (%r12), %cl
movzbl %cl, %edi
movl $0x1, %eax
testb %dil, %dil
jns 0x4bd8f
movzbl 0x1(%r12), %eax
cmpb $-0x41, %cl
ja 0x4bce1
andl $0x3f, %edi
shll $0x8, %edi
orl %eax, %edi
movl $0x2, %eax
jmp 0x4bd8f
cmpb $-0x21, %cl
ja 0x4bd03
shll $0x8, %eax
movzbl 0x2(%r12), %ecx
andl $0x1f, %edi
shll $0x10, %edi
orl %eax, %edi
orl %ecx, %edi
movl $0x3, %eax
jmp 0x4bd8f
cmpb $-0x11, %cl
ja 0x4bd61
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 0x4bd8f
shll $0x1c, %eax
js 0x4bea4
shll $0x14, %ecx
shll $0xc, %esi
orl %ecx, %esi
movzbl 0x3(%r12), %ecx
shll $0x4, %ecx
orl %esi, %ecx
movzbl 0x4(%r12), %edx
andl $0xf, %edx
orl %ecx, %edx
orl %eax, %edx
addq $0x5, %r12
movl %edx, %eax
jmp 0x4bc41
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 %rbp, %rax
subq %r12, %rax
cmpq $0x5, %rax
jge 0x4bdc6
cmpq %rbp, %r12
jae 0x4bdbd
movzbl (%r12), %edx
movl %edx, %ecx
shrl $0x4, %ecx
leaq 0x6aac(%rip), %rsi      # 0x52860
movslq (%rsi,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x4bdca
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x4be6b
movb (%r12), %dl
movzbl %dl, %eax
movl $0x1, %ecx
testb %al, %al
jns 0x4be6b
movzbl 0x1(%r12), %ecx
cmpb $-0x41, %dl
ja 0x4bdf4
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ecx
jmp 0x4be6b
cmpb $-0x21, %dl
ja 0x4be13
shll $0x8, %ecx
movzbl 0x2(%r12), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ecx
jmp 0x4be6b
cmpb $-0x11, %dl
ja 0x4be3d
shll $0x10, %ecx
movzbl 0x2(%r12), %edx
shll $0x8, %edx
movzbl 0x3(%r12), %esi
andl $0xf, %eax
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl $0x4, %ecx
jmp 0x4be6b
shll $0x1c, %eax
shll $0x14, %ecx
orl %eax, %ecx
movzbl 0x2(%r12), %eax
shll $0xc, %eax
orl %ecx, %eax
movzbl 0x3(%r12), %ecx
shll $0x4, %ecx
orl %eax, %ecx
movzbl 0x4(%r12), %eax
andl $0xf, %eax
orl %ecx, %eax
movl $0x5, %ecx
testl %eax, %eax
js 0x4bea4
addq %rcx, %r12
subq %r12, %rbp
movl %eax, %r13d
cmpq %r13, %rbp
jl 0x4bea4
movq %r12, %rsi
movl %r13d, %edx
movl 0x4(%rsp), %ecx
movl (%rsp), %r8d
callq 0x4bec5
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x4bea9
addq %r13, %r12
subq %r14, %r12
cmpq %r15, %r12
je 0x4beb3
callq 0x61cf
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