// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_varint_decode_init
cram_codec *cram_varint_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, *cp_end = data+size;

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

    c->codec  = codec;

    // Function pointer choice is theoretically by codec type.
    // Given we have some vars as int32 and some as int64 we
    // use option too for sizing, although on disk format
    // does not change.
    switch(codec) {
    case E_VARINT_UNSIGNED:
        c->decode = (option == E_INT)
            ? cram_varint_decode_int
            : cram_varint_decode_long;
        break;
    case E_VARINT_SIGNED:
        c->decode = (option == E_INT)
            ? cram_varint_decode_sint
            : cram_varint_decode_slong;
        break;
    default:
        return NULL;
    }

    c->free   = cram_varint_decode_free;
    c->size   = cram_varint_decode_size;
    c->get_block = cram_varint_get_block;
    c->describe = cram_varint_describe;

    c->u.varint.content_id = vv->varint_get32 (&cp, cp_end, NULL);
    c->u.varint.offset     = vv->varint_get64s(&cp, cp_end, NULL);

    if (cp - data != size) {
        fprintf(stderr, "Malformed varint header stream\n");
        free(c);
        return NULL;
    }

    c->u.varint.type = option;

    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %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)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x880, %edi            # imm = 0x880
callq 0x4650
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xe2bda
movq $0x0, -0x8(%rbp)
jmp 0xe2d18
movl -0x20(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
subl $0x29, %eax
je 0xe2bfa
jmp 0xe2bf0
movl -0x44(%rbp), %eax
subl $0x2a, %eax
je 0xe2c1c
jmp 0xe2c3e
movl -0x24(%rbp), %edx
leaq -0x364(%rip), %rcx      # 0xe28a0
leaq -0x54b(%rip), %rax      # 0xe26c0
cmpl $0x1, %edx
cmoveq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0xe2c4b
movl -0x24(%rbp), %edx
leaq -0x296(%rip), %rcx      # 0xe2990
leaq -0x47d(%rip), %rax      # 0xe27b0
cmpl $0x1, %edx
cmoveq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0xe2c4b
movq $0x0, -0x8(%rbp)
jmp 0xe2d18
movq -0x30(%rbp), %rax
leaq -0x1d6(%rip), %rcx      # 0xe2a80
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
leaq -0x1b5(%rip), %rcx      # 0xe2ab0
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
leaq -0x174(%rip), %rcx      # 0xe2b00
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rax
leaq -0x153(%rip), %rcx      # 0xe2b30
movq %rcx, 0x58(%rax)
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %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 0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq *%rax
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
je 0xe2d06
movq 0x2a2fe(%rip), %rax     # 0x10cfe0
movq (%rax), %rdi
leaq 0x160d4(%rip), %rsi     # 0xf8dc0
movb $0x0, %al
callq 0x46d0
movq -0x30(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xe2d18
movl -0x24(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x70(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)