// File: 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
movq %rsp, %rbp
subq $0x50, %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)
movl $0x240, %edi            # imm = 0x240
callq 0x47a0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x6f54e
movq $0x0, -0x8(%rbp)
jmp 0x6f8ef
movq -0x28(%rbp), %rax
movl $0x6, (%rax)
cmpl $0x1, -0x18(%rbp)
je 0x6f564
cmpl $0x2, -0x18(%rbp)
jne 0x6f575
movq -0x28(%rbp), %rax
leaq -0x79f(%rip), %rcx      # 0x6edd0
movq %rcx, 0x18(%rax)
jmp 0x6f599
cmpl $0x4, -0x18(%rbp)
je 0x6f581
cmpl $0x3, -0x18(%rbp)
jne 0x6f592
movq -0x28(%rbp), %rax
leaq -0x1dc(%rip), %rcx      # 0x6f3b0
movq %rcx, 0x18(%rax)
jmp 0x6f597
callq 0x42e0
jmp 0x6f599
movq -0x28(%rbp), %rax
leaq -0xc4(%rip), %rcx       # 0x6f4e0
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x80, %eax
jge 0x6f5d1
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x30(%rax)
movl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x6f70b
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc0, %eax
jge 0x6f60d
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
shll $0x8, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
orl %eax, %ecx
andl $0x3fff, %ecx           # imm = 0x3FFF
movq -0x28(%rbp), %rax
movl %ecx, 0x30(%rax)
movl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x6f705
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe0, %eax
jge 0x6f656
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
shll $0x10, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %eax
orl %eax, %ecx
andl $0x1fffff, %ecx         # imm = 0x1FFFFF
movq -0x28(%rbp), %rax
movl %ecx, 0x30(%rax)
movl $0x3, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6f6ff
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf0, %eax
jge 0x6f6a9
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
shll $0x18, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x10, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x3(%rax), %eax
orl %eax, %ecx
andl $0xfffffff, %ecx        # imm = 0xFFFFFFF
movq -0x28(%rbp), %rax
movl %ecx, 0x30(%rax)
movl $0x4, %eax
movl %eax, -0x40(%rbp)
jmp 0x6f6f9
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
andl $0xf, %ecx
shll $0x1c, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x14, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0xc, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x3(%rax), %eax
shll $0x4, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0xf, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x30(%rax)
movl $0x5, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x80, %eax
jge 0x6f745
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x6f87f
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc0, %eax
jge 0x6f781
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
shll $0x8, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
orl %eax, %ecx
andl $0x3fff, %ecx           # imm = 0x3FFF
movq -0x28(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x2, %eax
movl %eax, -0x48(%rbp)
jmp 0x6f879
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe0, %eax
jge 0x6f7ca
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
shll $0x10, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %eax
orl %eax, %ecx
andl $0x1fffff, %ecx         # imm = 0x1FFFFF
movq -0x28(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x3, %eax
movl %eax, -0x4c(%rbp)
jmp 0x6f873
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf0, %eax
jge 0x6f81d
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
shll $0x18, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x10, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x3(%rax), %eax
orl %eax, %ecx
andl $0xfffffff, %ecx        # imm = 0xFFFFFFF
movq -0x28(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x4, %eax
movl %eax, -0x50(%rbp)
jmp 0x6f86d
movq -0x30(%rbp), %rax
movzbl (%rax), %ecx
andl $0xf, %ecx
shll $0x1c, %ecx
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x14, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x2(%rax), %eax
shll $0xc, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x3(%rax), %eax
shll $0x4, %eax
orl %eax, %ecx
movq -0x30(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0xf, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x34(%rax)
movl $0x5, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%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
jne 0x6f8bc
movq -0x28(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jl 0x6f8bc
movq -0x28(%rbp), %rax
movslq 0x34(%rax), %rax
cmpq $0x20, %rax
jbe 0x6f8e7
movq 0x1a70d(%rip), %rax     # 0x89fd0
movq (%rax), %rdi
leaq 0xf18d(%rip), %rsi      # 0x7ea5a
movb $0x0, %al
callq 0x4830
movq -0x28(%rbp), %rdi
callq 0x46a0
movq $0x0, -0x8(%rbp)
jmp 0x6f8ef
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)