// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/fqzcomp_qual.c
// Function: store_array
static int store_array(unsigned char *out, unsigned int *array, int size) {
    unsigned char tmp[2048];

    int i, j, k;
    for (i = j = k = 0; i < size; j++) {
        int run_len = i;
        while (i < size && array[i] == j)
            i++;
        run_len = i-run_len;

        int r;
        do {
            r = MIN(255, run_len);
            tmp[k++] = r;
            run_len -= r;
        } while (r == 255);
    }
    while (i < size)
        tmp[k++] = 0, j++;

    // RLE on out.
    //    1 2 3 3 3 3 3 4 4    5
    // => 1 2 3 3 +3... 4 4 +0 5
    int last = -1;
    for (i = j = 0; j < k; i++) {
        out[i] = tmp[j++];
        if (out[i] == last) {
            int n = j;
            while (j < k && tmp[j] == last)
                j++;
            out[++i] = j-n;
        } else {
            last = out[i];
        }
    }
    k = i;

//    fprintf(stderr, "Store_array %d => %d {", size, k);
//    for (i = 0; i < k; i++)
//      fprintf(stderr, "%d,", out[i]);
//    fprintf(stderr, "}\n");
    return k;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7d0, %rsp            # imm = 0x7D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x82c(%rbp)
movl $0x0, -0x828(%rbp)
movl $0x0, -0x824(%rbp)
movl -0x824(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x8b108
movl -0x824(%rbp), %eax
movl %eax, -0x830(%rbp)
movl -0x824(%rbp), %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x83d(%rbp)
jge 0x8b04f
movq -0x10(%rbp), %rax
movslq -0x824(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x828(%rbp), %eax
sete %al
movb %al, -0x83d(%rbp)
movb -0x83d(%rbp), %al
testb $0x1, %al
jne 0x8b05b
jmp 0x8b06c
movl -0x824(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x824(%rbp)
jmp 0x8b01f
movl -0x824(%rbp), %eax
subl -0x830(%rbp), %eax
movl %eax, -0x830(%rbp)
movl $0xff, %eax
cmpl -0x830(%rbp), %eax
jge 0x8b098
movl $0xff, %eax
movl %eax, -0x844(%rbp)
jmp 0x8b0a4
movl -0x830(%rbp), %eax
movl %eax, -0x844(%rbp)
movl -0x844(%rbp), %eax
movl %eax, -0x834(%rbp)
movl -0x834(%rbp), %eax
movb %al, %cl
movl -0x82c(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x82c(%rbp)
cltq
movb %cl, -0x820(%rbp,%rax)
movl -0x834(%rbp), %ecx
movl -0x830(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x830(%rbp)
cmpl $0xff, -0x834(%rbp)
je 0x8b07e
jmp 0x8b0f4
movl -0x828(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x828(%rbp)
jmp 0x8b004
jmp 0x8b10a
movl -0x824(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x8b141
movl -0x82c(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x82c(%rbp)
cltq
movb $0x0, -0x820(%rbp,%rax)
movl -0x828(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x828(%rbp)
jmp 0x8b10a
movl $0xffffffff, -0x838(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x828(%rbp)
movl $0x0, -0x824(%rbp)
movl -0x828(%rbp), %eax
cmpl -0x82c(%rbp), %eax
jge 0x8b265
movl -0x828(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x828(%rbp)
cltq
movb -0x820(%rbp,%rax), %dl
movq -0x8(%rbp), %rax
movslq -0x824(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rax
movslq -0x824(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl -0x838(%rbp), %eax
jne 0x8b23a
movl -0x828(%rbp), %eax
movl %eax, -0x83c(%rbp)
movl -0x828(%rbp), %ecx
xorl %eax, %eax
cmpl -0x82c(%rbp), %ecx
movb %al, -0x845(%rbp)
jge 0x8b1f4
movslq -0x828(%rbp), %rax
movzbl -0x820(%rbp,%rax), %eax
cmpl -0x838(%rbp), %eax
sete %al
movb %al, -0x845(%rbp)
movb -0x845(%rbp), %al
testb $0x1, %al
jne 0x8b200
jmp 0x8b211
movl -0x828(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x828(%rbp)
jmp 0x8b1c0
movl -0x828(%rbp), %eax
subl -0x83c(%rbp), %eax
movb %al, %dl
movq -0x8(%rbp), %rax
movl -0x824(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x824(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x8b24f
movq -0x8(%rbp), %rax
movslq -0x824(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x838(%rbp)
jmp 0x8b251
movl -0x824(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x824(%rbp)
jmp 0x8b15f
movl -0x824(%rbp), %eax
movl %eax, -0x82c(%rbp)
movl -0x82c(%rbp), %eax
addq $0x7d0, %rsp            # imm = 0x7D0
popq %rbp
retq