// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
movl %edx, %r15d
movl %esi, %ebx
movq %rdi, %r14
movl $0x240, %edi            # imm = 0x240
callq 0x4700
testq %rax, %rax
je 0x49b1d
movl $0x6, (%rax)
leal -0x1(%r15), %ecx
cmpl $0x2, %ecx
jae 0x4999c
leaq -0x420(%rip), %rcx      # 0x4957a
jmp 0x499b1
addl $-0x3, %r15d
cmpl $0x2, %r15d
jae 0x49b25
leaq -0x121(%rip), %rcx      # 0x49890
movq %rcx, 0x18(%rax)
leaq -0x62(%rip), %rcx       # 0x4995a
movq %rcx, 0x10(%rax)
movzbl (%r14), %edx
movl $0x1, %ecx
testb %dl, %dl
js 0x499d7
movl $0x1, %esi
jmp 0x49a62
movzbl 0x1(%r14), %esi
cmpb $-0x41, %dl
ja 0x499f0
andl $0x3f, %edx
shll $0x8, %edx
orl %esi, %edx
movl $0x2, %esi
jmp 0x49a62
cmpb $-0x21, %dl
ja 0x49a0e
shll $0x8, %esi
movzbl 0x2(%r14), %edi
andl $0x1f, %edx
shll $0x10, %edx
orl %esi, %edx
orl %edi, %edx
movl $0x3, %esi
jmp 0x49a62
cmpb $-0x11, %dl
ja 0x49a37
shll $0x10, %esi
movzbl 0x2(%r14), %edi
shll $0x8, %edi
movzbl 0x3(%r14), %r8d
andl $0xf, %edx
shll $0x18, %edx
orl %esi, %edx
orl %edi, %edx
orl %r8d, %edx
movl $0x4, %esi
jmp 0x49a62
shll $0x1c, %edx
shll $0x14, %esi
orl %edx, %esi
movzbl 0x2(%r14), %edx
shll $0xc, %edx
orl %esi, %edx
movzbl 0x3(%r14), %esi
shll $0x4, %esi
orl %edx, %esi
movzbl 0x4(%r14), %edx
andl $0xf, %edx
orl %esi, %edx
movl $0x5, %esi
movl %edx, 0x30(%rax)
leaq (%r14,%rsi), %rdx
movzbl (%r14,%rsi), %esi
testb %sil, %sil
jns 0x49aff
movzbl 0x1(%rdx), %ecx
cmpb $-0x41, %sil
ja 0x49a90
andl $0x3f, %esi
shll $0x8, %esi
orl %ecx, %esi
movl $0x2, %ecx
jmp 0x49aff
cmpb $-0x21, %sil
ja 0x49aae
shll $0x8, %ecx
movzbl 0x2(%rdx), %edi
andl $0x1f, %esi
shll $0x10, %esi
orl %ecx, %esi
orl %edi, %esi
movl $0x3, %ecx
jmp 0x49aff
cmpb $-0x11, %sil
ja 0x49ad7
shll $0x10, %ecx
movzbl 0x2(%rdx), %edi
shll $0x8, %edi
movzbl 0x3(%rdx), %r8d
andl $0xf, %esi
shll $0x18, %esi
orl %ecx, %esi
orl %edi, %esi
orl %r8d, %esi
movl $0x4, %ecx
jmp 0x49aff
shll $0x1c, %esi
shll $0x14, %ecx
orl %esi, %ecx
movzbl 0x2(%rdx), %esi
shll $0xc, %esi
orl %ecx, %esi
movzbl 0x3(%rdx), %ecx
shll $0x4, %ecx
orl %esi, %ecx
movzbl 0x4(%rdx), %esi
andl $0xf, %esi
orl %ecx, %esi
movl $0x5, %ecx
movl %esi, 0x34(%rax)
addq %rcx, %rdx
subq %r14, %rdx
movslq %ebx, %rcx
cmpq %rcx, %rdx
jne 0x49b15
cmpl $0x21, %esi
jb 0x49b1f
movq %rax, %rdi
callq 0x60d6
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
callq 0x42e0