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

    c = malloc(sizeof(*c));
    if (!c)
        return NULL;
    c->codec = E_EXTERNAL;
    c->free = cram_external_encode_free;
    if (CRAM_MAJOR_VERS(version) >= 4) {
        // Version 4 does not permit integer data to be encoded as a
        // series of bytes.  This is used purely for bytes, either
        // singular or declared as arrays
        switch (codec) {
        case E_EXTERNAL:
            if (option != E_BYTE && option != E_BYTE_ARRAY)
                return NULL;
            c->encode = cram_external_encode_char;
            break;
        default:
            return NULL;
        }
    } else {
        // CRAM 3 and earlier encodes integers as EXTERNAL.  We need
        // use the option field to indicate the input data format so
        // we know which serialisation format to use.
        if (option == E_INT)
            c->encode = cram_external_encode_int;
        else if (option == E_LONG)
            c->encode = cram_external_encode_long;
        else if (option == E_BYTE_ARRAY || option == E_BYTE)
            c->encode = cram_external_encode_char;
        else
            abort();
    }
    c->store = cram_external_encode_store;
    c->flush = NULL;

    c->u.e_external.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, -0x38(%rbp)
jne 0xe25c0
movq $0x0, -0x8(%rbp)
jmp 0xe26ad
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
movq -0x38(%rbp), %rax
leaq -0x255(%rip), %rcx      # 0xe2380
movq %rcx, 0x20(%rax)
movl -0x24(%rbp), %eax
sarl $0x8, %eax
cmpl $0x4, %eax
jl 0xe2627
movl -0x14(%rbp), %eax
subl $0x1, %eax
jne 0xe2618
jmp 0xe25ee
cmpl $0x3, -0x18(%rbp)
je 0xe2607
cmpl $0x4, -0x18(%rbp)
je 0xe2607
movq $0x0, -0x8(%rbp)
jmp 0xe26ad
movq -0x38(%rbp), %rax
leaq -0x362(%rip), %rcx      # 0xe22b0
movq %rcx, 0x30(%rax)
jmp 0xe2625
movq $0x0, -0x8(%rbp)
jmp 0xe26ad
jmp 0xe267d
cmpl $0x1, -0x18(%rbp)
jne 0xe263e
movq -0x38(%rbp), %rax
leaq -0x4e8(%rip), %rcx      # 0xe2150
movq %rcx, 0x30(%rax)
jmp 0xe267b
cmpl $0x2, -0x18(%rbp)
jne 0xe2655
movq -0x38(%rbp), %rax
leaq -0x45f(%rip), %rcx      # 0xe21f0
movq %rcx, 0x30(%rax)
jmp 0xe2679
cmpl $0x4, -0x18(%rbp)
je 0xe2661
cmpl $0x3, -0x18(%rbp)
jne 0xe2672
movq -0x38(%rbp), %rax
leaq -0x3bc(%rip), %rcx      # 0xe22b0
movq %rcx, 0x30(%rax)
jmp 0xe2677
callq 0x4260
jmp 0xe2679
jmp 0xe267b
jmp 0xe267d
movq -0x38(%rbp), %rax
leaq -0x2d8(%rip), %rcx      # 0xe23b0
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 (%rax,%rax)