// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_huffman_decode_int
int cram_huffman_decode_int(cram_slice *slice, cram_codec *c,
                            cram_block *in, char *out, int *out_size) {
    int32_t *out_i = (int32_t *)out;
    int i, n, ncodes = c->u.huffman.ncodes;
    const cram_huffman_code * const codes = c->u.huffman.codes;

    for (i = 0, n = *out_size; i < n; i++) {
        int idx = 0;
        int val = 0, len = 0, last_len = 0;

        // Now one bit at a time for remaining checks
        for (;;) {
            int dlen = codes[idx].len - last_len;
            if (cram_not_enough_bits(in, dlen))
                return -1;

            //val <<= dlen;
            //val  |= get_bits_MSB(in, dlen);
            //last_len = (len += dlen);

            last_len = (len += dlen);
            for (; dlen; dlen--) GET_BIT_MSB(in, val);

            idx = val - codes[idx].p;
            if (idx >= ncodes || idx < 0)
                return -1;

            if (codes[idx].code == val && codes[idx].len == len) {
                out_i[i] = codes[idx].symbol;
                break;
            }
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0xe9129
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl -0x60(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x20(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0xe3860
cmpl $0x0, %eax
je 0xe9017
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe9130
movl -0x64(%rbp), %eax
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0xe9096
movl -0x58(%rbp), %eax
shll %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x30(%rcx), %rcx
movzbl (%rax,%rcx), %eax
movq -0x20(%rbp), %rcx
movl 0x38(%rcx), %ecx
sarl %cl, %eax
andl $0x1, %eax
orl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rcx
movl 0x38(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x38(%rcx)
cmpl $0x0, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
movl 0x38(%rax), %ecx
andl $0x7, %ecx
movl %ecx, 0x38(%rax)
movl -0x64(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xe9023
movl -0x58(%rbp), %eax
movq -0x50(%rbp), %rcx
movslq -0x54(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subl 0x8(%rcx), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0xe90bc
cmpl $0x0, -0x54(%rbp)
jge 0xe90c5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xe9130
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpl -0x58(%rbp), %eax
jne 0xe9114
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
cmpl -0x5c(%rbp), %eax
jne 0xe9114
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xe9119
jmp 0xe8fe2
jmp 0xe911b
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xe8fba
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)