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

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

    c->codec  = E_BETA;
    if (option == E_INT || option == E_LONG)
	c->decode = cram_beta_decode_int;
    else if (option == E_BYTE_ARRAY || option == E_BYTE)
	c->decode = cram_beta_decode_char;
    else
	abort();
    c->free   = cram_beta_decode_free;
    
    cp += itf8_get(cp, &c->beta.offset);
    cp += itf8_get(cp, &c->beta.nbits);

    if (cp - data != size
        || c->beta.nbits < 0 || c->beta.nbits > 8 * sizeof(int)) {
	fprintf(stderr, "Malformed beta header stream\n");
	free(c);
	return NULL;
    }

    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %r14
movl $0x240, %edi            # imm = 0x240
callq 0x46f0
testq %rax, %rax
je 0x3c8cf
movq %rax, %rbx
movl $0x6, (%rax)
leal -0x1(%r15), %eax
cmpl $0x2, %eax
jae 0x3c74a
leaq -0x423(%rip), %rax      # 0x3c325
jmp 0x3c75f
addl $-0x3, %r15d
cmpl $0x2, %r15d
jae 0x3c8df
leaq -0x10a(%rip), %rax      # 0x3c655
movq %rax, 0x18(%rbx)
leaq -0x62(%rip), %rax       # 0x3c708
movq %rax, 0x10(%rbx)
movzbl (%r14), %ecx
pushq $0x1
popq %rax
testb %cl, %cl
js 0x3c77e
movq %rax, %rdx
jmp 0x3c7da
movzbl 0x1(%r14), %esi
cmpb $-0x41, %cl
ja 0x3c795
pushq $0x2
popq %rdx
andl $0x3f, %ecx
shll $0x8, %ecx
orl %esi, %ecx
jmp 0x3c7da
cmpb $-0x21, %cl
ja 0x3c7b1
pushq $0x3
popq %rdx
shll $0x8, %esi
movzbl 0x2(%r14), %edi
andl $0x1f, %ecx
shll $0x10, %ecx
orl %esi, %ecx
orl %edi, %ecx
jmp 0x3c7da
cmpb $-0x11, %cl
ja 0x3c843
pushq $0x4
popq %rdx
shll $0x10, %esi
movzbl 0x2(%r14), %edi
shll $0x8, %edi
movzbl 0x3(%r14), %r8d
andl $0xf, %ecx
shll $0x18, %ecx
orl %esi, %ecx
orl %edi, %ecx
orl %r8d, %ecx
movl %ecx, 0x30(%rbx)
leaq (%r14,%rdx), %rcx
movzbl (%r14,%rdx), %edx
testb %dl, %dl
jns 0x3c895
movzbl 0x1(%rcx), %eax
cmpb $-0x41, %dl
ja 0x3c806
andl $0x3f, %edx
shll $0x8, %edx
orl %eax, %edx
pushq $0x2
jmp 0x3c894
cmpb $-0x21, %dl
ja 0x3c820
shll $0x8, %eax
movzbl 0x2(%rcx), %esi
andl $0x1f, %edx
shll $0x10, %edx
orl %eax, %edx
orl %esi, %edx
pushq $0x3
jmp 0x3c894
cmpb $-0x11, %dl
ja 0x3c86f
shll $0x10, %eax
movzbl 0x2(%rcx), %esi
shll $0x8, %esi
movzbl 0x3(%rcx), %edi
andl $0xf, %edx
shll $0x18, %edx
orl %eax, %edx
orl %esi, %edx
orl %edi, %edx
pushq $0x4
jmp 0x3c894
pushq $0x5
popq %rdx
shll $0x1c, %ecx
shll $0x14, %esi
orl %ecx, %esi
movzbl 0x2(%r14), %ecx
shll $0xc, %ecx
orl %esi, %ecx
movzbl 0x3(%r14), %esi
shll $0x4, %esi
orl %ecx, %esi
movzbl 0x4(%r14), %ecx
andl $0xf, %ecx
jmp 0x3c791
shll $0x1c, %edx
shll $0x14, %eax
orl %edx, %eax
movzbl 0x2(%rcx), %edx
shll $0xc, %edx
orl %eax, %edx
movzbl 0x3(%rcx), %eax
shll $0x4, %eax
orl %edx, %eax
movzbl 0x4(%rcx), %edx
andl $0xf, %edx
orl %eax, %edx
pushq $0x5
popq %rax
movl %edx, 0x34(%rbx)
addq %rax, %rcx
subq %r14, %rcx
movslq %ebp, %rax
cmpq %rax, %rcx
jne 0x3c8ab
cmpl $0x21, %edx
jb 0x3c8d1
movq 0x1a71e(%rip), %rax     # 0x56fd0
movq (%rax), %rcx
leaq 0xacee(%rip), %rdi      # 0x475aa
pushq $0x1d
popq %rsi
pushq $0x1
popq %rdx
callq 0x4a20
movq %rbx, %rdi
callq 0x4600
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x42f0