// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_varint_encode_init
cram_codec *cram_varint_encode_init(cram_stats *st,
                                    enum cram_encoding codec,
                                    enum cram_external_type option,
                                    void *dat,
                                    int version, varint_vec *vv) {
    cram_codec *c;

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

    c->u.e_varint.offset = 0;
    if (st) {
        // Marginal difference so far! Not worth the hassle?
        if (st->min_val < 0 && st->min_val >= -127
            && st->max_val / -st->min_val > 100) {
            c->u.e_varint.offset = -st->min_val;
            codec = E_VARINT_UNSIGNED;
        } else if (st->min_val > 0) {
            c->u.e_varint.offset = -st->min_val;
        }
    }

    c->codec = codec;
    c->free = cram_varint_encode_free;

    // 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->encode = (option == E_INT)
            ? cram_varint_encode_int
            : cram_varint_encode_long;
        break;
    case E_VARINT_SIGNED:
        c->encode = (option == E_INT)
            ? cram_varint_encode_sint
            : cram_varint_encode_slong;
        break;
    default:
        return NULL;
    }
    c->store = cram_varint_encode_store;
    c->flush = NULL;

    c->u.e_varint.content_id = (size_t)dat;

    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movl $0x880, %edi            # imm = 0x880
callq 0x4650
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xe30cf
movq $0x0, -0x8(%rbp)
jmp 0xe3217
movq -0x38(%rbp), %rax
movq $0x0, 0x68(%rax)
cmpq $0x0, -0x10(%rbp)
je 0xe316a
movq -0x10(%rbp), %rax
cmpq $0x0, 0x1010(%rax)
jge 0xe3143
movq -0x10(%rbp), %rax
cmpq $-0x7f, 0x1010(%rax)
jl 0xe3143
movq -0x10(%rbp), %rax
movq 0x1018(%rax), %rax
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
subq 0x1010(%rdx), %rcx
cqto
idivq %rcx
cmpq $0x64, %rax
jle 0xe3143
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
subq 0x1010(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x68(%rax)
movl $0x29, -0x14(%rbp)
jmp 0xe3168
movq -0x10(%rbp), %rax
cmpq $0x0, 0x1010(%rax)
jle 0xe3166
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
subq 0x1010(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x68(%rax)
jmp 0xe3168
jmp 0xe316a
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
leaq -0x2ce(%rip), %rcx      # 0xe2eb0
movq %rcx, 0x20(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $0x29, %eax
je 0xe3199
jmp 0xe318f
movl -0x3c(%rbp), %eax
subl $0x2a, %eax
je 0xe31bb
jmp 0xe31dd
movl -0x18(%rbp), %edx
leaq -0x3b3(%rip), %rcx      # 0xe2df0
leaq -0x47a(%rip), %rax      # 0xe2d30
cmpl $0x1, %edx
cmoveq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0xe31e7
movl -0x18(%rbp), %edx
leaq -0x375(%rip), %rcx      # 0xe2e50
leaq -0x43c(%rip), %rax      # 0xe2d90
cmpl $0x1, %edx
cmoveq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0xe31e7
movq $0x0, -0x8(%rbp)
jmp 0xe3217
movq -0x38(%rbp), %rax
leaq -0x312(%rip), %rcx      # 0xe2ee0
movq %rcx, 0x38(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x20(%rbp), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x60(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)