// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_xdelta_decode_init
cram_codec *cram_xdelta_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;
    char *endp = data+size;

    if (!(c = calloc(1, sizeof(*c))))
        return NULL;

    c->codec  = E_XDELTA;
    if (option == E_LONG)
        c->decode = cram_xdelta_decode_long;
    else if (option == E_INT)
        c->decode = cram_xdelta_decode_int;
    else if (option == E_BYTE_ARRAY || option == E_BYTE)
        c->decode = cram_xdelta_decode_char;
    else if (option == E_BYTE_ARRAY_BLOCK) {
        option = E_BYTE_ARRAY;
        c->decode = cram_xdelta_decode_block;
    } else {
        free(c);
        return NULL;
    }
    c->free = cram_xdelta_decode_free;
    c->size = cram_xdelta_decode_size;
    c->get_block = cram_xdelta_get_block;
    c->describe = NULL;

    c->u.xdelta.word_size = vv->varint_get32(&cp, endp, NULL);
    c->u.xdelta.last = 0;

    int encoding = vv->varint_get32(&cp, endp, NULL);
    int sub_size = vv->varint_get32(&cp, endp, NULL);
    if (sub_size < 0 || endp - cp < sub_size)
        goto malformed;
    c->u.xdelta.sub_codec = cram_decoder_init(hdr, encoding, cp, sub_size,
                                              option, version, vv);
    if (c->u.xdelta.sub_codec == NULL)
        goto malformed;
    cp += sub_size;

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

    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %ebp
movl %r8d, %r15d
movl %edx, %r13d
movq %rdi, %r12
movq %rsi, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
movl $0x1, %edi
movl $0x880, %esi            # imm = 0x880
callq 0x4300
testq %rax, %rax
je 0x912dd
movq %rax, %rbx
movl $0x35, (%rax)
cmpl $0x2, %r15d
movl %ebp, 0x1c(%rsp)
movq %r12, 0x30(%rsp)
je 0x911ce
cmpl $0x1, %r15d
jne 0x911d7
leaq -0x2bd(%rip), %rax      # 0x90f0f
jmp 0x91200
leaq -0x2cc(%rip), %rax      # 0x90f09
jmp 0x91200
leal -0x3(%r15), %eax
cmpl $0x2, %eax
jae 0x911e9
leaq -0x252(%rip), %rax      # 0x90f95
jmp 0x91200
cmpl $0x5, %r15d
jne 0x912d5
movl $0x4, %r15d
leaq -0x265(%rip), %rax      # 0x90f9b
movq 0x70(%rsp), %r14
movslq %r13d, %rcx
movq %rcx, 0x28(%rsp)
movq 0x20(%rsp), %rdx
leaq (%rdx,%rcx), %r13
movq %rax, 0x28(%rbx)
leaq -0xfa(%rip), %rax       # 0x91127
movq %rax, 0x20(%rbx)
leaq -0xe6(%rip), %rax       # 0x91146
movq %rax, 0x40(%rbx)
leaq -0xdd(%rip), %rax       # 0x9115a
movq %rax, 0x50(%rbx)
xorl %ebp, %ebp
movq %rbp, 0x58(%rbx)
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x18(%r14)
movb %al, 0x68(%rbx)
movq %rbp, 0x60(%rbx)
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x18(%r14)
movq %rax, %rbp
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq *0x18(%r14)
testl %eax, %eax
js 0x912cd
movq 0x10(%rsp), %rdx
subq %rdx, %r13
movl %eax, %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
cmpq %r12, %r13
jl 0x912cd
movq 0x70(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x30(%rsp), %rdi
movl %ebp, %esi
movl %eax, %ecx
movl %r15d, %r8d
movl 0x1c(%rsp), %r9d
callq 0x90872
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0x912cd
addq 0x10(%rsp), %r12
movq %r12, 0x10(%rsp)
subq 0x20(%rsp), %r12
cmpq 0x28(%rsp), %r12
je 0x912df
movq %rbx, %rdi
callq 0x4c75
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq