// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_xrle_decode_init
cram_codec *cram_xrle_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;
    int err = 0;

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

    c->codec  = E_XRLE;
    if (option == E_LONG)
        c->decode = cram_xrle_decode_long;
    else if (option == E_INT)
        c->decode = cram_xrle_decode_int;
    else if (option == E_BYTE_ARRAY || option == E_BYTE)
        c->decode = cram_xrle_decode_char;
    else {
        fprintf(stderr, "BYTE_ARRAYs not supported by this codec\n");
        free(c);
        return NULL;
    }
    c->free   = cram_xrle_decode_free;
    c->size   = cram_xrle_decode_size;
    c->get_block = cram_xrle_get_block;
    c->describe = NULL;
    c->u.xrle.cur_len = 0;
    c->u.xrle.cur_lit = -1;

    // RLE map
    int i, j, nrle = vv->varint_get32(&cp, endp, &err);
    memset(c->u.xrle.rep_score, 0, 256*sizeof(*c->u.xrle.rep_score));
    for (i = 0; i < nrle && i < 256; i++) {
        j = vv->varint_get32(&cp, endp, &err);
        if (j >= 0 && j < 256)
            c->u.xrle.rep_score[j] = 1;
    }

    // Length and literal sub encodings
    c->u.xrle.len_encoding = vv->varint_get32(&cp, endp, &err);
    int sub_size = vv->varint_get32(&cp, endp, &err);
    if (sub_size < 0 || endp - cp < sub_size)
        goto malformed;
    c->u.xrle.len_codec = cram_decoder_init(hdr, c->u.xrle.len_encoding,
                                            cp, sub_size, E_INT, version, vv);
    if (c->u.xrle.len_codec == NULL)
        goto malformed;
    cp += sub_size;

    c->u.xrle.lit_encoding = vv->varint_get32(&cp, endp, &err);
    sub_size = vv->varint_get32(&cp, endp, &err);
    if (sub_size < 0 || endp - cp < sub_size)
        goto malformed;
    c->u.xrle.lit_codec = cram_decoder_init(hdr, c->u.xrle.lit_encoding,
                                            cp, sub_size, option, version, vv);
    if (c->u.xrle.lit_codec == NULL)
        goto malformed;
    cp += sub_size;

    if (err)
        goto malformed;

    return c;

 malformed:
    fprintf(stderr, "Malformed xrle header stream\n");
    cram_xrle_decode_free(c);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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 $0x0, -0x44(%rbp)
movl $0x1, %edi
movl $0x880, %esi            # imm = 0x880
callq 0x42f0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xe6f96
movq $0x0, -0x8(%rbp)
jmp 0xe72a6
movq -0x30(%rbp), %rax
movl $0x34, (%rax)
cmpl $0x2, -0x24(%rbp)
jne 0xe6fb7
movq -0x30(%rbp), %rax
leaq -0x4a1(%rip), %rcx      # 0xe6b10
movq %rcx, 0x28(%rax)
jmp 0xe701d
cmpl $0x1, -0x24(%rbp)
jne 0xe6fce
movq -0x30(%rbp), %rax
leaq -0x498(%rip), %rcx      # 0xe6b30
movq %rcx, 0x28(%rax)
jmp 0xe701b
cmpl $0x4, -0x24(%rbp)
je 0xe6fda
cmpl $0x3, -0x24(%rbp)
jne 0xe6feb
movq -0x30(%rbp), %rax
leaq -0x1b5(%rip), %rcx      # 0xe6e30
movq %rcx, 0x28(%rax)
jmp 0xe7019
movq 0x25fee(%rip), %rax     # 0x10cfe0
movq (%rax), %rdi
leaq 0x11e87(%rip), %rsi     # 0xf8e83
movb $0x0, %al
callq 0x46d0
movq -0x30(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0xe72a6
jmp 0xe701b
jmp 0xe701d
movq -0x30(%rbp), %rax
leaq -0x168(%rip), %rcx      # 0xe6ec0
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
leaq -0x4e7(%rip), %rcx      # 0xe6b50
movq %rcx, 0x40(%rax)
movq -0x30(%rbp), %rax
leaq -0x256(%rip), %rcx      # 0xe6df0
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x88(%rax)
movq -0x30(%rbp), %rax
movl $0xffffffff, 0x8c(%rax) # imm = 0xFFFFFFFF
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rdx
callq *%rax
movl %eax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
addq $0x60, %rdi
addq $0x30, %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4250
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %ecx
xorl %eax, %eax
cmpl -0x50(%rbp), %ecx
movb %al, -0x55(%rbp)
jge 0xe70c4
cmpl $0x100, -0x48(%rbp)     # imm = 0x100
setl %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0xe70cd
jmp 0xe7115
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rdx
callq *%rax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0xe7108
cmpl $0x100, -0x4c(%rbp)     # imm = 0x100
jge 0xe7108
movq -0x30(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl $0x1, 0x90(%rax,%rcx,4)
jmp 0xe710a
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xe70aa
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rdx
callq *%rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x60(%rax)
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rdx
callq *%rax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jl 0xe7167
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movslq -0x54(%rbp), %rcx
cmpq %rcx, %rax
jge 0xe716c
jmp 0xe727d
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x60(%rax), %esi
movq -0x38(%rbp), %rdx
movl -0x54(%rbp), %ecx
movl -0x28(%rbp), %r9d
movq 0x10(%rbp), %rax
movl $0x1, %r8d
movq %rax, (%rsp)
callq 0xe5250
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x78(%rax)
jne 0xe71b0
jmp 0xe727d
movl -0x54(%rbp), %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rdx
callq *%rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x64(%rax)
movq 0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rdx
callq *%rax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jl 0xe7213
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movslq -0x54(%rbp), %rcx
cmpq %rcx, %rax
jge 0xe7215
jmp 0xe727d
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x64(%rax), %esi
movq -0x38(%rbp), %rdx
movl -0x54(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
callq 0xe5250
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0xe725a
jmp 0xe727d
movl -0x54(%rbp), %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0xe7273
jmp 0xe727d
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe72a6
movq 0x25d5c(%rip), %rax     # 0x10cfe0
movq (%rax), %rdi
leaq 0x11cb1(%rip), %rsi     # 0xf8f3f
movb $0x0, %al
callq 0x46d0
movq -0x30(%rbp), %rdi
callq 0xe6ec0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq