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

    if (in_size < 7)
        return -1;

    // Starting context
    pm->context = in[in_idx] + (in[in_idx+1]<<8);
    in_idx += 2;

    // Bit flags
    pm->pflags     = in[in_idx++];
    pm->use_qtab   = pm->pflags & PFLAG_HAVE_QTAB;
    pm->use_dtab   = pm->pflags & PFLAG_HAVE_DTAB;
    pm->use_ptab   = pm->pflags & PFLAG_HAVE_PTAB;
    pm->do_sel     = pm->pflags & PFLAG_DO_SEL;
    pm->fixed_len  = pm->pflags & PFLAG_DO_LEN;
    pm->do_dedup   = pm->pflags & PFLAG_DO_DEDUP;
    pm->store_qmap = pm->pflags & PFLAG_HAVE_QMAP;
    pm->max_sym    = in[in_idx++];

    // Sub-context sizes and locations
    pm->qbits      = in[in_idx]>>4;
    pm->qmask      = (1<<pm->qbits)-1;
    pm->qshift     = in[in_idx++]&15;
    pm->qloc       = in[in_idx]>>4;
    pm->sloc       = in[in_idx++]&15;
    pm->ploc       = in[in_idx]>>4;
    pm->dloc       = in[in_idx++]&15;

    // Maps and tables
    if (pm->store_qmap) {
        for (i = 0; i < 256; i++) pm->qmap[i] = INT_MAX; // so dump_map works
        if (in_idx + pm->max_sym > in_size)
            return -1;
        for (i = 0; i < pm->max_sym; i++)
            pm->qmap[i] = in[in_idx++];
    } else {
        for (i = 0; i < 256; i++)
            pm->qmap[i] = i;
    }

    if (pm->qbits) {
        if (pm->use_qtab) {
            int used = read_array(in+in_idx, in_size-in_idx, pm->qtab, 256);
            if (used < 0)
                return -1;
            in_idx += used;
        } else {
            for (i = 0; i < 256; i++)
                pm->qtab[i] = i;
        }
    }

    if (pm->use_ptab) {
        int used = read_array(in+in_idx, in_size-in_idx, pm->ptab, 1024);
        if (used < 0)
            return -1;
        in_idx += used;
    } else {
        for (i = 0; i < 1024; i++)
            pm->ptab[i] = 0;
    }

    if (pm->use_dtab) {
        int used = read_array(in+in_idx, in_size-in_idx, pm->dtab, 256);
        if (used < 0)
            return -1;
        in_idx += used;
    } else {
        for (i = 0; i < 256; i++)
            pm->dtab[i] = 0;
    }

    return in_idx;
}

// 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 $0x7, -0x20(%rbp)
jae 0x8c78e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8cbcc
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x18(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
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 $0x80, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x19(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x20, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x1a(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x8, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x2, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x10, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
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, 0x3c(%rax)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c58(%rax)
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
andl $0xf, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c48(%rax)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
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
andl $0xf, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
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
andl $0xf, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x8c9e5
movq $0x0, -0x30(%rbp)
cmpq $0x100, -0x30(%rbp)     # imm = 0x100
jae 0x8c97c
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl $0x7fffffff, 0x48(%rax,%rcx,4) # imm = 0x7FFFFFFF
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8c954
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
addl 0x3c(%rcx), %eax
cltq
cmpq -0x20(%rbp), %rax
jbe 0x8c99a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8cbcc
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x3c(%rcx), %rcx
cmpq %rcx, %rax
jae 0x8c9e3
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl %edx, 0x48(%rax,%rcx,4)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8c9a2
jmp 0x8ca19
movq $0x0, -0x30(%rbp)
cmpq $0x100, -0x30(%rbp)     # imm = 0x100
jae 0x8ca17
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl %edx, 0x48(%rax,%rcx,4)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8c9ed
jmp 0x8ca19
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
je 0x8cab5
movq -0x10(%rbp), %rax
cmpb $0x0, 0x18(%rax)
je 0x8ca7c
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 $0x448, %rdx            # imm = 0x448
movl $0x100, %ecx            # imm = 0x100
callq 0x8c3d0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x8ca71
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8cbcc
movl -0x34(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x8cab3
movq $0x0, -0x30(%rbp)
cmpq $0x100, -0x30(%rbp)     # imm = 0x100
jae 0x8cab1
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl %edx, 0x448(%rax,%rcx,4)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8ca84
jmp 0x8cab3
jmp 0x8cab5
movq -0x10(%rbp), %rax
cmpb $0x0, 0x1a(%rax)
je 0x8cb0a
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 $0x848, %rdx            # imm = 0x848
movl $0x400, %ecx            # imm = 0x400
callq 0x8c3d0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0x8caff
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8cbcc
movl -0x38(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x8cb3f
movq $0x0, -0x30(%rbp)
cmpq $0x400, -0x30(%rbp)     # imm = 0x400
jae 0x8cb3d
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl $0x0, 0x848(%rax,%rcx,4)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8cb12
jmp 0x8cb3f
movq -0x10(%rbp), %rax
cmpb $0x0, 0x19(%rax)
je 0x8cb91
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 $0x1848, %rdx           # imm = 0x1848
movl $0x100, %ecx            # imm = 0x100
callq 0x8c3d0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x8cb86
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8cbcc
movl -0x3c(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x8cbc6
movq $0x0, -0x30(%rbp)
cmpq $0x100, -0x30(%rbp)     # imm = 0x100
jae 0x8cbc4
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl $0x0, 0x1848(%rax,%rcx,4)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x8cb99
jmp 0x8cbc6
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)