// File: /workspace/github_c_makefile_star2_O3/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
jae 0x5af7e
subl %eax, %edx
jbe 0x5af79
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 0x5af5f
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x2, %ecx
je 0x5b03b
cmpl $0x4, %ecx
jne 0x5b0ed
xorl %eax, %eax
cmpl $0x40, %edx
jb 0x5aff5
movl %edx, %ecx
addl $-0x40, %ecx
je 0x5aff5
movl %ecx, %ecx
xorl %eax, %eax
movdqa 0x3fce6(%rip), %xmm0    # 0x9ac90
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 0x5afb5
incq %r11
addq $0x4, %r10
cmpq $0x10, %r11
jne 0x5afb3
movdqu (%r8), %xmm1
paddd %xmm0, %xmm1
movdqu %xmm1, (%r8)
addq $0x40, %rax
addq $0x40, %r9
cmpq %rcx, %rax
jb 0x5afad
leal -0x4(%rdx), %ecx
cmpl %ecx, %eax
jae 0x5af54
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 0x5b00b
leal (%r9,%r10), %eax
cmpl %eax, %ecx
ja 0x5b000
addl %r10d, %r9d
movl %r9d, %eax
jmp 0x5af54
xorl %eax, %eax
cmpl $0x8, %edx
jb 0x5b0a4
movl %edx, %ecx
addl $-0x8, %ecx
je 0x5b0a4
xorl %r9d, %r9d
movdqa 0x409ec(%rip), %xmm0    # 0x9ba40
xorl %r10d, %r10d
movl %r10d, %eax
movslq %r10d, %r10
movb $0x1, %r11b
xorl %ebx, %ebx
movl (%r8,%rbx,4), %ebx
addl %r9d, %ebx
movb (%rsi,%rbx), %bl
movb %bl, (%rdi,%r10)
incq %r10
incl %eax
movl $0x1, %ebx
testb $0x1, %r11b
movl $0x0, %r11d
jne 0x5b062
incl %r9d
cmpl $0x4, %r9d
jne 0x5b057
movq (%r8), %xmm1
paddd %xmm0, %xmm1
movq %xmm1, (%r8)
xorl %r9d, %r9d
cmpl %eax, %ecx
ja 0x5b057
leal -0x2(%rdx), %ecx
cmpl %ecx, %eax
jae 0x5af54
movslq %eax, %r9
addq %rdi, %r9
movb $0x1, %r10b
xorl %r11d, %r11d
movl (%r8,%r11,4), %ebx
leal 0x1(%rbx), %ebp
movl %ebp, (%r8,%r11,4)
movb (%rsi,%rbx), %r11b
movb %r11b, (%r9)
incq %r9
incl %eax
movl $0x1, %r11d
testb $0x1, %r10b
movl $0x0, %r10d
jne 0x5b0bb
cmpl %eax, %ecx
ja 0x5b0af
jmp 0x5af54
movl %edx, %r9d
subl %ecx, %r9d
je 0x5af54
movl %ecx, %r10d
xorl %eax, %eax
testl %ecx, %ecx
je 0x5b128
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 0x5b10a
addl %ebx, %eax
cmpl %r9d, %eax
jb 0x5b0fe
jmp 0x5af54