// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/htscodecs/htscodecs/utils.h
// Function: unstripe
static inline void unstripe(unsigned char *out, unsigned char *outN,
                            unsigned int ulen, unsigned int N,
                            unsigned int idxN[256]) {
    int j = 0, k;

    if (ulen >= N) {
        switch (N) {
        case 4:
#define LLN 16
            if (ulen >= 4*LLN) {
                while (j < ulen-4*LLN) {
                    int l;
                    for (l = 0; l < LLN; l++) {
                        for (k = 0; k < 4; k++)
                            out[j+k+l*4] = outN[idxN[k]+l];
                    }
                    for (k = 0; k < 4; k++)
                        idxN[k] += LLN;
                    j += 4*LLN;
                }
            }
            while (j < ulen-4) {
                for (k = 0; k < 4; k++)
                    out[j++] = outN[idxN[k]++];
            }
#undef LLN
            break;

        case 2:
#define LLN 4
            if (ulen >= 2*LLN) {
                while (j < ulen-2*LLN) {
                    int l;
                    for (l = 0; l < LLN; l++) {
                        for (k = 0; k < 2; k++)
                            out[j++] = outN[idxN[k]+l];
                    }
                    for (k = 0; k < 2; k++)
                        idxN[k] += l;
                }
            }
            while (j < ulen-2) {
                for (k = 0; k < 2; k++)
                    out[j++] = outN[idxN[k]++];
            }
#undef LLN
            break;

        default:
            // General case, around 25% slower overall decode
            while (j < ulen-N) {
                for (k = 0; k < N; k++)
                    out[j++] = outN[idxN[k]++];
            }
            break;
        }
    }
    for (k = 0; j < ulen; k++)
        out[j++] = outN[idxN[k]++];
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
xorl %eax, %eax
cmpl %ecx, %edx
jb 0x5dadf
cmpl $0x2, %ecx
je 0x5d9fd
cmpl $0x4, %ecx
jne 0x5daa3
xorl %eax, %eax
cmpl $0x40, %edx
jb 0x5d9bd
movl %edx, %ecx
addl $-0x40, %ecx
je 0x5d9bd
movl %ecx, %ecx
xorl %eax, %eax
movq %rdi, %r9
movq %r9, %r10
xorl %r11d, %r11d
xorl %ebx, %ebx
movl (%r8,%rbx,4), %r14d
addl %r11d, %r14d
movb (%rsi,%r14), %bpl
movb %bpl, (%r10,%rbx)
incq %rbx
cmpq $0x4, %rbx
jne 0x5d97a
incq %r11
addq $0x4, %r10
cmpq $0x10, %r11
jne 0x5d978
xorl %r10d, %r10d
addl $0x10, (%r8,%r10,4)
incq %r10
cmpq $0x4, %r10
jne 0x5d9a2
addq $0x40, %rax
addq $0x40, %r9
cmpq %rcx, %rax
jb 0x5d972
leal -0x4(%rdx), %ecx
cmpl %ecx, %eax
jae 0x5dadf
movl %eax, %r9d
cltq
addq %rdi, %rax
xorl %r10d, %r10d
movl (%r8,%r10,4), %r11d
leal 0x1(%r11), %ebx
movl %ebx, (%r8,%r10,4)
movb (%rsi,%r11), %r11b
movb %r11b, (%rax,%r10)
incq %r10
cmpq $0x4, %r10
jne 0x5d9d3
leal (%r9,%r10), %eax
cmpl %eax, %ecx
ja 0x5d9c8
jmp 0x5da9b
xorl %eax, %eax
cmpl $0x8, %edx
jb 0x5da64
movl %edx, %ecx
addl $-0x8, %ecx
je 0x5da64
xorl %r11d, %r11d
xorl %r9d, %r9d
movq %r9, %rax
movslq %eax, %r9
leaq (%rdi,%r9), %rbx
xorl %r10d, %r10d
movl (%r8,%r10,4), %r14d
addl %r11d, %r14d
movb (%rsi,%r14), %bpl
movb %bpl, (%rbx,%r10)
incq %r10
cmpq $0x1, %r10
je 0x5da1e
incl %r11d
addq %r10, %r9
cmpl $0x4, %r11d
jne 0x5da11
leaq (%rax,%r10), %rbx
xorl %r11d, %r11d
addl $0x4, (%r8,%r11,4)
incq %r11
cmpq $0x1, %r11
je 0x5da49
movl $0x0, %r11d
cmpl %ebx, %ecx
ja 0x5da11
addl %r10d, %eax
leal -0x2(%rdx), %ecx
cmpl %ecx, %eax
jae 0x5dadf
movl %eax, %r9d
cltq
addq %rdi, %rax
xorl %r10d, %r10d
movl (%r8,%r10,4), %r11d
leal 0x1(%r11), %ebx
movl %ebx, (%r8,%r10,4)
movb (%rsi,%r11), %r11b
movb %r11b, (%rax,%r10)
incq %r10
cmpq $0x1, %r10
je 0x5da76
leal (%r9,%r10), %eax
cmpl %eax, %ecx
ja 0x5da6b
addl %r10d, %r9d
movl %r9d, %eax
jmp 0x5dadf
movl %edx, %r9d
subl %ecx, %r9d
je 0x5dadf
movl %ecx, %r10d
xorl %eax, %eax
testl %ecx, %ecx
je 0x5dada
movslq %eax, %r11
addq %rdi, %r11
xorl %ebx, %ebx
movl (%r8,%rbx,4), %r14d
leal 0x1(%r14), %ebp
movl %ebp, (%r8,%rbx,4)
movb (%rsi,%r14), %bpl
movb %bpl, (%r11,%rbx)
incq %rbx
cmpq %rbx, %r10
jne 0x5dabc
addl %ebx, %eax
cmpl %r9d, %eax
jb 0x5dab0
subl %eax, %edx
jbe 0x5db04
cltq
addq %rax, %rdi
xorl %eax, %eax
movl (%r8,%rax,4), %ecx
leal 0x1(%rcx), %r9d
movl %r9d, (%r8,%rax,4)
movb (%rsi,%rcx), %cl
movb %cl, (%rdi,%rax)
incq %rax
cmpq %rax, %rdx
jne 0x5daea
popq %rbx
popq %r14
popq %rbp
retq