// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl $0xffffffff, -0x440(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x444(%rbp)
movl $0x400, %eax            # imm = 0x400
cmpl -0x24(%rbp), %eax
jge 0x8c415
movl $0x400, %eax            # imm = 0x400
movl %eax, -0x45c(%rbp)
jmp 0x8c41e
movl -0x24(%rbp), %eax
movl %eax, -0x45c(%rbp)
movl -0x45c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x43c(%rbp)
movl $0x0, -0x438(%rbp)
movl $0x0, -0x434(%rbp)
movl -0x43c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x24(%rbp), %ecx
movb %al, -0x45d(%rbp)
jge 0x8c46c
movslq -0x434(%rbp), %rax
cmpq -0x18(%rbp), %rax
setb %al
movb %al, -0x45d(%rbp)
movb -0x45d(%rbp), %al
testb $0x1, %al
jne 0x8c47b
jmp 0x8c5da
movq -0x10(%rbp), %rax
movslq -0x434(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x448(%rbp)
movl -0x448(%rbp), %eax
movb %al, %cl
movl -0x438(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x438(%rbp)
cltq
movb %cl, -0x430(%rbp,%rax)
movl -0x448(%rbp), %eax
addl -0x43c(%rbp), %eax
movl %eax, -0x43c(%rbp)
movl -0x448(%rbp), %eax
cmpl -0x440(%rbp), %eax
jne 0x8c5a2
movl -0x434(%rbp), %eax
addl $0x1, %eax
cltq
cmpq -0x18(%rbp), %rax
jb 0x8c4f3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8c745
movq -0x10(%rbp), %rax
movl -0x434(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x434(%rbp)
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x44c(%rbp)
movl -0x448(%rbp), %eax
imull -0x44c(%rbp), %eax
addl -0x43c(%rbp), %eax
movl %eax, -0x43c(%rbp)
movl -0x44c(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x44c(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x45e(%rbp)
je 0x8c570
movl -0x43c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x24(%rbp), %ecx
movb %al, -0x45e(%rbp)
jg 0x8c570
cmpl $0x400, -0x438(%rbp)    # imm = 0x400
setl %al
movb %al, -0x45e(%rbp)
movb -0x45e(%rbp), %al
testb $0x1, %al
jne 0x8c57c
jmp 0x8c5a0
movl -0x448(%rbp), %eax
movb %al, %cl
movl -0x438(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x438(%rbp)
cltq
movb %cl, -0x430(%rbp,%rax)
jmp 0x8c52c
jmp 0x8c5a2
cmpl $0x400, -0x438(%rbp)    # imm = 0x400
jl 0x8c5ba
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8c745
movl -0x448(%rbp), %eax
movl %eax, -0x440(%rbp)
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x8c445
movl -0x434(%rbp), %eax
movl %eax, -0x444(%rbp)
movl -0x438(%rbp), %eax
movl %eax, -0x450(%rbp)
movl $0x0, -0x43c(%rbp)
movl $0x0, -0x438(%rbp)
movl $0x0, -0x434(%rbp)
movl -0x438(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x8c73c
movl $0x0, -0x454(%rbp)
movl -0x43c(%rbp), %eax
cmpl -0x450(%rbp), %eax
jl 0x8c643
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8c745
jmp 0x8c645
movl -0x43c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x43c(%rbp)
cltq
movzbl -0x430(%rbp,%rax), %eax
movl %eax, -0x458(%rbp)
movl -0x458(%rbp), %eax
addl -0x454(%rbp), %eax
movl %eax, -0x454(%rbp)
xorl %eax, %eax
cmpl $0xff, -0x458(%rbp)
movb %al, -0x45f(%rbp)
jne 0x8c6a1
movl -0x43c(%rbp), %eax
cmpl -0x450(%rbp), %eax
setl %al
movb %al, -0x45f(%rbp)
movb -0x45f(%rbp), %al
testb $0x1, %al
jne 0x8c645
cmpl $0xff, -0x458(%rbp)
jne 0x8c6c3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8c745
jmp 0x8c6c5
xorl %eax, %eax
cmpl $0x0, -0x454(%rbp)
movb %al, -0x460(%rbp)
je 0x8c6e8
movl -0x438(%rbp), %eax
cmpl -0x24(%rbp), %eax
setl %al
movb %al, -0x460(%rbp)
movb -0x460(%rbp), %al
testb $0x1, %al
jne 0x8c6f4
jmp 0x8c726
movl -0x454(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x454(%rbp)
movl -0x434(%rbp), %edx
movq -0x20(%rbp), %rax
movl -0x438(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x438(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x8c6c5
jmp 0x8c728
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x8c610
movl -0x444(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
nopw %cs:(%rax,%rax)