// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_xdelta_encode_char
int cram_xdelta_encode_char(cram_slice *slice, cram_codec *c,
                            char *in, int in_size) {
    char *dat = malloc(in_size*5);
    if (!dat)
        return -1;
    char *cp = dat, *cp_end = dat + in_size*5;

    c->u.e_xdelta.last = 0; // reset for each new array
    if (c->u.e_xdelta.word_size == 2) {
        int i, part;

        part = in_size%2;
        if (part) {
            uint16_t z = in[0];
            c->u.e_xdelta.last = le_int2(z);
            cp += c->vv->varint_put32(cp, cp_end, zigzag16(c->u.e_xdelta.last));
        }

        uint16_t *in16 = (uint16_t *)(in+part);
        for (i = 0; i < in_size/2; i++) {
            uint16_t d = le_int2(in16[i]) - c->u.e_xdelta.last;
            c->u.e_xdelta.last = le_int2(in16[i]);
            cp += c->vv->varint_put32(cp, cp_end, zigzag16(d));
        }
    }
    if (c->u.e_xdelta.sub_codec->encode(slice, c->u.e_xdelta.sub_codec,
                                      (char *)dat, cp-dat)) {
        free(dat);
        return -1;
    }

    free(dat);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
imull $0x5, -0x24(%rbp), %eax
movslq %eax, %rdi
callq 0x4650
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0xe678d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe697d
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
imull $0x5, -0x24(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x18(%rbp), %rax
movzbl 0x68(%rax), %eax
cmpl $0x2, %eax
jne 0xe692d
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0xe684c
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movw %ax, -0x4a(%rbp)
movswl -0x4a(%rbp), %edi
callq 0xe5e80
movswq %ax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movswl %ax, %edi
callq 0xe6500
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
movw %ax, %cx
movq -0x68(%rbp), %rax
movzwl %cx, %edx
callq *%rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x24(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x7c(%rbp), %eax
cmpl %ecx, %eax
jge 0xe692b
movq -0x58(%rbp), %rax
movslq -0x44(%rbp), %rcx
movswl (%rax,%rcx,2), %edi
callq 0xe5e80
movswq %ax, %rax
movq -0x18(%rbp), %rcx
subq 0x60(%rcx), %rax
movw %ax, -0x5a(%rbp)
movq -0x58(%rbp), %rax
movslq -0x44(%rbp), %rcx
movswl (%rax,%rcx,2), %edi
callq 0xe5e80
movswq %ax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movswl -0x5a(%rbp), %edi
callq 0xe6500
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movw %ax, %cx
movq -0x88(%rbp), %rax
movzwl %cx, %edx
callq *%rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xe6862
jmp 0xe692d
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x78(%rcx), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %r8
subq %r8, %rcx
callq *%rax
cmpl $0x0, %eax
je 0xe696d
movq -0x30(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe697d
movq -0x30(%rbp), %rdi
callq 0x45a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)