// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/htscodecs/htscodecs/fqzcomp_qual.c
// Function: read_array
static int read_array(unsigned char *in, size_t in_size, unsigned int *array, int size) {
    unsigned char R[1024];
    int i, j, z, last = -1, nb = 0;

    size = MIN(1024, size);

    // Remove level one of run-len encoding
    for (i = j = z = 0; z < size && i < in_size; i++) {
        int run = in[i];
        R[j++] = run;
        z += run;
        if (run == last) {
            if (i+1 >= in_size)
                return -1;
            int copy = in[++i];
            z += run * copy;
            while (copy-- && z <= size && j < 1024)
                R[j++] = run;
        }
        if (j >= 1024)
            return -1;
        last = run;
    }
    nb = i;

    // Now expand inner level of run-length encoding
    int R_max = j;
    for (i = j = z = 0; j < size; i++) {
        int run_len = 0;
        int run_part;
        if (z >= R_max)
            return -1;
        do {
            run_part = R[z++];
            run_len += run_part;
        } while (run_part == 255 && z < R_max);
        if (run_part == 255)
            return -1;

        while (run_len && j < size)
            run_len--, array[j++] = i;
    }

    return nb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x388, %rsp            # imm = 0x388
testl %ecx, %ecx
setle %al
testq %rsi, %rsi
sete %r8b
xorl %r9d, %r9d
orb %al, %r8b
movl $0x0, %r8d
jne 0x6145d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r11d, %r11d
xorl %r8d, %r8d
xorl %r10d, %r10d
xorl %r9d, %r9d
movb (%rdi,%r11), %r11b
movzbl %r11b, %eax
movslq %r9d, %r14
incl %r9d
movb %r11b, -0x80(%rsp,%r14)
movl %r10d, %ebp
addl %eax, %ebp
cmpl %eax, %ebx
jne 0x61432
movslq %r8d, %r8
incq %r8
cmpq %rsi, %r8
jae 0x61506
movzbl (%rdi,%r8), %r14d
imull %r14d, %ebx
movl %ebx, %r10d
addl %ebp, %r10d
testl %r14d, %r14d
je 0x6143a
movslq %r9d, %rbx
leal (%r9,%r14), %ebp
negl %r14d
xorl %r15d, %r15d
cmpl %ecx, %r10d
jg 0x61437
cmpq $0x3ff, %rbx            # imm = 0x3FF
jg 0x61437
movb %r11b, -0x80(%rsp,%rbx)
incq %rbx
decl %r15d
cmpl %r15d, %r14d
jne 0x6140f
movl %ebp, %r9d
jmp 0x6143a
movl %ebp, %r10d
jmp 0x6143a
subl %r15d, %r9d
cmpl $0x400, %r9d            # imm = 0x400
jge 0x61506
incl %r8d
cmpl %ecx, %r10d
jge 0x6145d
movslq %r8d, %r11
movl %eax, %ebx
cmpq %rsi, %r11
jb 0x613c3
testl %ecx, %ecx
jle 0x61501
movslq %r9d, %rsi
movl %ecx, %edi
xorl %r10d, %r10d
xorl %r11d, %r11d
xorl %ebx, %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %r9d, %r11d
jge 0x6150b
movslq %r11d, %r12
incq %r12
xorl %ebp, %ebp
movl %ebp, %r14d
movzbl -0x81(%rsp,%r12), %r15d
leal (%r14,%r15), %ebp
incl %r11d
cmpl $0xff, %r15d
jne 0x614b1
leaq 0x1(%r12), %r13
cmpq %rsi, %r12
movq %r13, %r12
jl 0x61488
cmpl $0xff, %r15d
je 0x6150b
testl %ebp, %ebp
je 0x614f6
cmpl %ecx, %ebx
jge 0x614f6
movslq %ebx, %rax
incq %rax
addl %r15d, %r14d
movl $0x1, %ebp
subl %r14d, %ebp
xorl %r14d, %r14d
movl %r14d, %r15d
movl %r10d, -0x4(%rdx,%rax,4)
leal -0x1(%r15), %r14d
cmpl %r15d, %ebp
je 0x614f3
leaq 0x1(%rax), %r15
cmpq %rdi, %rax
movq %r15, %rax
jl 0x614d6
subl %r14d, %ebx
incl %r10d
cmpl %ecx, %ebx
jl 0x61472
movl %r8d, %eax
jmp 0x6150b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)