// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_codecs.c
// Function: cram_subexp_decode
int cram_subexp_decode(cram_slice *slice, cram_codec *c, cram_block *in, char *out, int *out_size) {
    int32_t *out_i = (int32_t *)out;
    int n, count;
    int k = c->u.subexp.k;

    for (count = 0, n = *out_size; count < n; count++) {
        int i = 0, tail;
        int val;

        /* Get number of 1s */
        //while (get_bit_MSB(in) == 1) i++;
        i = get_one_bits_MSB(in);
        if (i < 0 || cram_not_enough_bits(in, i > 0 ? i + k - 1 : k))
            return -1;
        /*
         * Val is
         * i > 0:  2^(k+i-1) + k+i-1 bits
         * i = 0:  k bits
         */
        if (i) {
            tail = i + k-1;
            val = 0;
            while (tail) {
                //val = val<<1; val |= get_bit_MSB(in);
                GET_BIT_MSB(in, val);
                tail--;
            }
            val += 1 << (i + k-1);
        } else {
            tail = k;
            val = 0;
            while (tail) {
                //val = val<<1; val |= get_bit_MSB(in);
                GET_BIT_MSB(in, val);
                tail--;
            }
        }

        out_i[count] = val - c->u.subexp.offset;
    }

    return 0;
}

// Assembly:
movslq (%r8), %r8
testq %r8, %r8
jle 0x9291d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rdi
movl 0x64(%rsi), %r9d
leal -0x1(%r9), %r10d
xorl %r11d, %r11d
movq 0x30(%rdx), %r15
movslq 0x14(%rdx), %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %r14, %r15
jae 0x92804
movq 0x20(%rdx), %r12
movl 0x38(%rdx), %ecx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movzbl (%r12,%r15), %ebp
shrl %cl, %ebp
subl $0x1, %ecx
movl %ecx, 0x38(%rdx)
jae 0x927f5
movl $0x7, 0x38(%rdx)
incq %r15
movq %r15, 0x30(%rdx)
movl $0x7, %ecx
cmpq %r14, %r15
jne 0x927f5
movl %ebp, %r13d
andl $0x1, %r13d
jne 0x927ff
incl %ebx
testb $0x1, %bpl
jne 0x927c5
jmp 0x92804
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %ebx, %ebx
js 0x92922
leal (%r10,%rbx), %ecx
testl %ebx, %ebx
movl %ecx, %ebp
cmovel %r9d, %ebp
testl %ebp, %ebp
js 0x92922
subq 0x30(%rdx), %r14
setbe %r15b
testl %ebp, %ebp
setne %r12b
testb %r15b, %r12b
jne 0x92922
cmpq $0x10000000, %r14       # imm = 0x10000000
ja 0x92858
movslq 0x38(%rdx), %r15
leaq (%r15,%r14,8), %r14
addq $-0x7, %r14
movl %ebp, %r15d
cmpq %r15, %r14
jb 0x92922
testl %ebx, %ebx
je 0x928ac
testl %ecx, %ecx
je 0x928f9
movq 0x20(%rdx), %rax
movq 0x30(%rdx), %r14
movl 0x38(%rdx), %r15d
xorl %ebx, %ebx
movl %ecx, %ebp
movzbl (%rax,%r14), %r12d
xorl %r13d, %r13d
btl %r15d, %r12d
setb %r13b
leal (%r13,%rbx,2), %ebx
xorl %r12d, %r12d
testl %r15d, %r15d
leal -0x1(%r15), %r15d
setle %r12b
addq %r12, %r14
movq %r14, 0x30(%rdx)
andl $0x7, %r15d
movl %r15d, 0x38(%rdx)
decl %ebp
jne 0x92874
jmp 0x928fb
testl %r9d, %r9d
je 0x92919
movq 0x20(%rdx), %rcx
movq 0x30(%rdx), %rbx
movl 0x38(%rdx), %r14d
xorl %eax, %eax
movl %r9d, %ebp
movzbl (%rcx,%rbx), %r15d
xorl %r12d, %r12d
btl %r14d, %r15d
setb %r12b
leal (%r12,%rax,2), %eax
xorl %r15d, %r15d
testl %r14d, %r14d
leal -0x1(%r14), %r14d
setle %r15b
addq %r15, %rbx
movq %rbx, 0x30(%rdx)
andl $0x7, %r14d
movl %r14d, 0x38(%rdx)
decl %ebp
jne 0x928c2
jmp 0x92904
xorl %ebx, %ebx
movl $0x1, %eax
shll %cl, %eax
addl %ebx, %eax
subl 0x60(%rsi), %eax
movl %eax, (%rdi,%r11,4)
incq %r11
cmpq %r8, %r11
jne 0x927a2
jmp 0x92920
xorl %eax, %eax
jmp 0x92904
xorl %eax, %eax
retq
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq