// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/fqzcomp_qual.c
// Function: fqz_read_parameters
static
int fqz_read_parameters(fqz_gparams *gp, unsigned char *in, size_t in_size) {
    int in_idx = 0;
    int i;

    if (in_size < 10)
        return -1;

    // Format version
    gp->vers = in[in_idx++];
    if (gp->vers != FQZ_VERS)
        return -1;

    // Global glags
    gp->gflags = in[in_idx++];

    // Number of param blocks and param selector details
    gp->nparam = (gp->gflags & GFLAG_MULTI_PARAM) ? in[in_idx++] : 1;
    if (gp->nparam <= 0)
        return -1;
    gp->max_sel = gp->nparam > 1 ? gp->nparam : 0;

    if (gp->gflags & GFLAG_HAVE_STAB) {
        gp->max_sel = in[in_idx++];
        int used = read_array(in+in_idx, in_size-in_idx, gp->stab, 256);
        if (used < 0)
            goto err;
        in_idx += used;
    } else {
        for (i = 0; i < gp->nparam; i++)
            gp->stab[i] = i;
        for (; i < 256; i++)
            gp->stab[i] = gp->nparam-1;
    }

    // Load the individual parameter locks
    if (!(gp->p = malloc(gp->nparam * sizeof(*gp->p))))
        return -1;

    gp->max_sym = 0;
    for (i = 0; i < gp->nparam; i++) {
        int e = fqz_read_parameters1(&gp->p[i], in + in_idx, in_size-in_idx);
        if (e < 0)
            goto err;
        if (gp->p[i].do_sel && gp->max_sel == 0)
            goto err; // Inconsistent
        in_idx += e;

        if (gp->max_sym < gp->p[i].max_sym)
            gp->max_sym = gp->p[i].max_sym;
    }

    //fprintf(stderr, "Decoded %d bytes of param\n", in_idx);
    return in_idx;

 err:
    fqz_free_parameters(gp);
    gp->nparam = 0;
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpq $0xa, -0x20(%rbp)
jae 0x8bafe
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8bddc
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movzbl (%rax,%rcx), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x5, (%rax)
je 0x8bb2f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8bddc
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movzbl (%rax,%rcx), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8bb76
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
jmp 0x8bb80
movl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8bb80
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jg 0x8bba0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8bddc
movq -0x10(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jle 0x8bbb6
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x38(%rbp)
jmp 0x8bbbd
xorl %eax, %eax
movl %eax, -0x38(%rbp)
jmp 0x8bbbd
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8bc34
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movzbl (%rax,%rcx), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rdi
movslq -0x24(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movslq -0x24(%rbp), %rax
subq %rax, %rsi
movq -0x10(%rbp), %rdx
addq $0x10, %rdx
movl $0x100, %ecx            # imm = 0x100
callq 0x8c3d0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jge 0x8bc29
jmp 0x8bdc1
movl -0x2c(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x8bc8f
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8bc61
movl -0x28(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl %edx, 0x10(%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x8bc3b
jmp 0x8bc63
cmpl $0x100, -0x28(%rbp)     # imm = 0x100
jge 0x8bc8d
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
subl $0x1, %edx
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl %edx, 0x10(%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x8bc63
jmp 0x8bc8f
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rax
imulq $0x1c64, %rax, %rdi     # imm = 0x1C64
callq 0x4650
movq -0x10(%rbp), %rcx
movq %rax, 0x418(%rcx)
cmpq $0x0, %rax
jne 0x8bcc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8bddc
movq -0x10(%rbp), %rax
movl $0x0, 0x410(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8bdb9
movq -0x10(%rbp), %rax
movq 0x418(%rax), %rdi
movslq -0x28(%rbp), %rax
imulq $0x1c64, %rax, %rax     # imm = 0x1C64
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movslq -0x24(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rax
subq %rax, %rdx
callq 0x8c760
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0x8bd27
jmp 0x8bdc1
movq -0x10(%rbp), %rax
movq 0x418(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x1c64, %rcx, %rcx     # imm = 0x1C64
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
je 0x8bd52
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x8bd52
jmp 0x8bdc1
movl -0x30(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x410(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x418(%rcx), %rcx
movslq -0x28(%rbp), %rdx
imulq $0x1c64, %rdx, %rdx     # imm = 0x1C64
addq %rdx, %rcx
cmpl 0x3c(%rcx), %eax
jge 0x8bda9
movq -0x10(%rbp), %rax
movq 0x418(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x1c64, %rcx, %rcx     # imm = 0x1C64
addq %rcx, %rax
movl 0x3c(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x410(%rax)
jmp 0x8bdab
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x8bcd5
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x8bddc
movq -0x10(%rbp), %rdi
callq 0x8aeb0
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)