// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/rANS_static16_int.h
// Function: decode_freq1
static inline int decode_freq1(uint8_t *cp, uint8_t *cp_end, int shift,
                               uint32_t s3 [256][TOTFREQ_O1],
                               uint32_t s3F[256][TOTFREQ_O1_FAST],
                               uint8_t *sfb[256], fb_t fb[256][256]) {
    uint8_t *cp_start = cp;
    int i, j, x;
    uint32_t F0[256] = {0};
    int fsz = decode_alphabet(cp, cp_end, F0);
    if (!fsz)
        goto err;
    cp += fsz;

    if (cp >= cp_end)
        goto err;

    // silence false gcc warnings
    if (fb) {fb [0][0].b= 0;}
    if (s3) {s3 [0][0]  = 0;}
    if (s3F){s3F[0][0]  = 0;}

    for (i = 0; i < 256; i++) {
        if (F0[i] == 0)
            continue;

        uint32_t F[256] = {0}, T = 0;
        fsz = decode_freq_d(cp, cp_end, F0, F, &T);
        if (!fsz)
            goto err;
        cp += fsz;

        if (!T) {
            //fprintf(stderr, "No freq for F_%d\n", i);
            continue;
        }

        normalise_freq_shift(F, T, 1<<shift);

        // Build symbols; fixme, do as part of decode, see the _d variant
        for (j = x = 0; j < 256; j++) {
            if (F[j]) {
                if (F[j] > (1<<shift) - x)
                    goto err;

                if (sfb && shift == TF_SHIFT_O1) {
                    memset(&sfb[i][x], j, F[j]);
                    fb[i][j].f = F[j];
                    fb[i][j].b = x;
                } else if (s3 && shift == TF_SHIFT_O1) {
                    int y;
                    for (y = 0; y < F[j]; y++)
                        s3[i][y+x] = (((uint32_t)F[j])<<(shift+8)) |(y<<8) |j;
                } else if (s3F && shift == TF_SHIFT_O1_FAST) {
                    int y;
                    for (y = 0; y < F[j]; y++)
                        s3F[i][y+x] = (((uint32_t)F[j])<<(shift+8)) |(y<<8) |j;
                }

                x += F[j];
            }
        }
        if (x != (1<<shift))
            goto err;
    }

    return cp - cp_start;

 err:
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x870, %rsp            # imm = 0x870
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x450(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4250
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x450(%rbp), %rdx
callq 0xa5ea0
movl %eax, -0x454(%rbp)
cmpl $0x0, -0x454(%rbp)
jne 0xa5639
jmp 0xa5969
movl -0x454(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0xa565c
jmp 0xa5969
cmpq $0x0, 0x10(%rbp)
je 0xa566d
movq 0x10(%rbp), %rax
movw $0x0, 0x2(%rax)
cmpq $0x0, -0x28(%rbp)
je 0xa567e
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0xa568f
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x44(%rbp)
cmpl $0x100, -0x44(%rbp)     # imm = 0x100
jge 0xa5959
movslq -0x44(%rbp), %rax
cmpl $0x0, -0x450(%rbp,%rax,4)
jne 0xa56b6
jmp 0xa594b
leaq -0x860(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x4250
movl $0x0, -0x864(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x450(%rbp), %rdx
leaq -0x860(%rbp), %rcx
leaq -0x864(%rbp), %r8
callq 0xa66f0
movl %eax, -0x454(%rbp)
cmpl $0x0, -0x454(%rbp)
jne 0xa5709
jmp 0xa5969
movl -0x454(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x864(%rbp)
jne 0xa572b
jmp 0xa594b
leaq -0x860(%rbp), %rdi
movl -0x864(%rbp), %esi
movl -0x1c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
callq 0x9c440
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x48(%rbp)
cmpl $0x100, -0x48(%rbp)     # imm = 0x100
jge 0xa5934
movslq -0x48(%rbp), %rax
cmpl $0x0, -0x860(%rbp,%rax,4)
je 0xa5924
movslq -0x48(%rbp), %rax
movl -0x860(%rbp,%rax,4), %eax
movl -0x1c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
subl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
jbe 0xa5797
jmp 0xa5969
cmpq $0x0, -0x38(%rbp)
je 0xa5817
cmpl $0xc, -0x1c(%rbp)
jne 0xa5817
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x4c(%rbp), %rax
addq %rax, %rdi
movl -0x48(%rbp), %eax
movslq -0x48(%rbp), %rcx
movl -0x860(%rbp,%rcx,4), %ecx
movl %ecx, %edx
movzbl %al, %esi
callq 0x4250
movslq -0x48(%rbp), %rax
movl -0x860(%rbp,%rax,4), %eax
movw %ax, %dx
movq 0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x48(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
movl -0x4c(%rbp), %eax
movw %ax, %dx
movq 0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x48(%rbp), %rcx
movw %dx, 0x2(%rax,%rcx,4)
jmp 0xa5913
cmpq $0x0, -0x28(%rbp)
je 0xa5893
cmpl $0xc, -0x1c(%rbp)
jne 0xa5893
movl $0x0, -0x868(%rbp)
movl -0x868(%rbp), %eax
movslq -0x48(%rbp), %rcx
cmpl -0x860(%rbp,%rcx,4), %eax
jae 0xa5891
movslq -0x48(%rbp), %rax
movl -0x860(%rbp,%rax,4), %edx
movl -0x1c(%rbp), %ecx
addl $0x8, %ecx
shll %cl, %edx
movl -0x868(%rbp), %eax
shll $0x8, %eax
orl %eax, %edx
orl -0x48(%rbp), %edx
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
shlq $0xe, %rcx
addq %rcx, %rax
movl -0x868(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x868(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x868(%rbp)
jmp 0xa582e
jmp 0xa5911
cmpq $0x0, -0x30(%rbp)
je 0xa590f
cmpl $0xa, -0x1c(%rbp)
jne 0xa590f
movl $0x0, -0x86c(%rbp)
movl -0x86c(%rbp), %eax
movslq -0x48(%rbp), %rcx
cmpl -0x860(%rbp,%rcx,4), %eax
jae 0xa590d
movslq -0x48(%rbp), %rax
movl -0x860(%rbp,%rax,4), %edx
movl -0x1c(%rbp), %ecx
addl $0x8, %ecx
shll %cl, %edx
movl -0x86c(%rbp), %eax
shll $0x8, %eax
orl %eax, %edx
orl -0x48(%rbp), %edx
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movl -0x86c(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x86c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x86c(%rbp)
jmp 0xa58aa
jmp 0xa590f
jmp 0xa5911
jmp 0xa5913
movslq -0x48(%rbp), %rax
movl -0x860(%rbp,%rax,4), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xa5926
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xa5755
movl -0x4c(%rbp), %eax
movl -0x1c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
je 0xa5949
jmp 0xa5969
jmp 0xa594b
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xa5696
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0xa5970
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x870, %rsp            # imm = 0x870
popq %rbp
retq
nopl (%rax)