// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_beta_decode_init
cram_codec *cram_beta_decode_init(cram_block_compression_hdr *hdr,
                                  char *data, int size,
                                  enum cram_encoding codec,
                                  enum cram_external_type option,
                                  int version, varint_vec *vv) {
    cram_codec *c;
    char *cp = data;

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

    c->codec  = E_BETA;
    if (option == E_INT || option == E_SINT)
        c->decode = cram_beta_decode_int;
    else if (option == E_LONG || option == E_SLONG)
        c->decode = cram_beta_decode_long;
    else if (option == E_BYTE_ARRAY || option == E_BYTE)
        c->decode = cram_beta_decode_char;
    else {
        hts_log_error("BYTE_ARRAYs not supported by this codec");
        free(c);
        return NULL;
    }
    c->free   = cram_beta_decode_free;
    c->describe = cram_beta_describe;

    c->u.beta.nbits = -1;
    c->u.beta.offset = vv->varint_get32(&cp, data + size, NULL);
    if (cp < data + size) // Ensure test below works
        c->u.beta.nbits  = vv->varint_get32(&cp, data + size, NULL);

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

    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x880, %edi            # imm = 0x880
callq 0x4650
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xe406b
movq $0x0, -0x8(%rbp)
jmp 0xe41ea
movq -0x30(%rbp), %rax
movl $0x6, (%rax)
cmpl $0x1, -0x24(%rbp)
je 0xe4081
cmpl $0x6, -0x24(%rbp)
jne 0xe4092
movq -0x30(%rbp), %rax
leaq -0x2ec(%rip), %rcx      # 0xe3da0
movq %rcx, 0x28(%rax)
jmp 0xe4100
cmpl $0x2, -0x24(%rbp)
je 0xe409e
cmpl $0x7, -0x24(%rbp)
jne 0xe40af
movq -0x30(%rbp), %rax
leaq -0x939(%rip), %rcx      # 0xe3770
movq %rcx, 0x28(%rax)
jmp 0xe40fe
cmpl $0x4, -0x24(%rbp)
je 0xe40bb
cmpl $0x3, -0x24(%rbp)
jne 0xe40cc
movq -0x30(%rbp), %rax
leaq -0x246(%rip), %rcx      # 0xe3e80
movq %rcx, 0x28(%rax)
jmp 0xe40fc
movl $0x1, %edi
leaq 0x14d50(%rip), %rsi     # 0xf8e28
leaq 0x14d5f(%rip), %rdx     # 0xf8e3e
movb $0x0, %al
callq 0x1b030
movq -0x30(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xe41ea
jmp 0xe40fe
jmp 0xe4100
movq -0x30(%rbp), %rax
leaq -0x16b(%rip), %rcx      # 0xe3fa0
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
leaq -0x14a(%rip), %rcx      # 0xe3fd0
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
movl $0xffffffff, 0x64(%rax) # imm = 0xFFFFFFFF
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rcx
addq %rcx, %rsi
leaq -0x38(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0xe4189
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rcx
addq %rcx, %rsi
leaq -0x38(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jne 0xe41b5
movq -0x30(%rbp), %rax
cmpl $0x0, 0x64(%rax)
jl 0xe41b5
movq -0x30(%rbp), %rax
movslq 0x64(%rax), %rax
cmpq $0x20, %rax
jbe 0xe41e2
movl $0x1, %edi
leaq 0x14c67(%rip), %rsi     # 0xf8e28
leaq 0x14c9e(%rip), %rdx     # 0xf8e66
movb $0x0, %al
callq 0x1b030
movq -0x30(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xe41ea
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)