// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/rANS_byte.h
// Function: RansEncPutSymbol4
static inline void RansEncPutSymbol4(RansState *r0,
                                     RansState *r1,
                                     RansState *r2,
                                     RansState *r3,
                                     uint8_t** pptr,
                                     RansEncSymbol const *sym0,
                                     RansEncSymbol const *sym1,
                                     RansEncSymbol const *sym2,
                                     RansEncSymbol const *sym3)
{
    RansAssert(sym0->x_max != 0); // can't encode symbol with freq=0
    RansAssert(sym1->x_max != 0); // can't encode symbol with freq=0
    RansAssert(sym2->x_max != 0); // can't encode symbol with freq=0
    RansAssert(sym3->x_max != 0); // can't encode symbol with freq=0

    // renormalize
    uint32_t x0, x1, x2, x3;
    uint8_t* ptr = *pptr;

    int o;
    uint32_t m[4] = {
        sym0->x_max,
        sym1->x_max,
        sym2->x_max,
        sym3->x_max
    };

    x0 = *r0;
    o = x0 >= m[0];
    ptr[-1] = x0;
    ptr -= o;
    x0 >>= o*8;
    if (x0 >= m[0]) {
        *--ptr = x0;
        x0 >>= 8;
    }

    x1 = *r1;
    o = x1 >= m[1];
    ptr[-1] = x1;
    ptr -= o;
    x1 >>= o*8;
    if (x1 >= m[1]) {
        *--ptr = x1;
        x1 >>= 8;
    }

    x2 = *r2;
    o = x2 >= m[2];
    ptr[-1] = x2;
    ptr -= o;
    x2 >>= o*8;
    if (x2 >= m[2]) {
        *--ptr = x2;
        x2 >>= 8;
    }

    x3 = *r3;
    o = x3 >= m[3];
    ptr[-1] = x3;
    ptr -= o;
    x3 >>= o*8;
    if (x3 >= m[3]) {
        *--ptr = x3;
        x3 >>= 8;
    }

    *pptr = ptr;

    // x = C(s,x)
    uint32_t qa, qb;
    qa = (uint32_t) (((uint64_t)x0 * sym0->rcp_freq) >> sym0->rcp_shift);
    uint32_t X0 = qa * sym0->cmpl_freq;
    qb = (uint32_t) (((uint64_t)x1 * sym1->rcp_freq) >> sym1->rcp_shift);
    uint32_t X1 = qb * sym1->cmpl_freq;

    *r0 = X0 + x0 + sym0->bias;
    *r1 = X1 + x1 + sym1->bias;

    qa = (uint32_t) (((uint64_t)x2 * sym2->rcp_freq) >> sym2->rcp_shift);
    uint32_t X2 = qa * sym2->cmpl_freq;
    qb = (uint32_t) (((uint64_t)x3 * sym3->rcp_freq) >> sym3->rcp_shift);
    uint32_t X3 = qb * sym3->cmpl_freq;

    *r2 = X2 + x2 + sym2->bias;
    *r3 = X3 + x3 + sym3->bias;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc6e9a
jmp 0xc6eb9
leaq 0x2faf3(%rip), %rdi     # 0xf6994
leaq 0x2fa76(%rip), %rsi     # 0xf691e
movl $0x14d, %edx            # imm = 0x14D
leaq 0x2faf1(%rip), %rcx     # 0xf69a5
callq 0x42e0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc6ec4
jmp 0xc6ee3
leaq 0x2fb8d(%rip), %rdi     # 0xf6a58
leaq 0x2fa4c(%rip), %rsi     # 0xf691e
movl $0x14e, %edx            # imm = 0x14E
leaq 0x2fac7(%rip), %rcx     # 0xf69a5
callq 0x42e0
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc6eee
jmp 0xc6f0d
leaq 0x2fb74(%rip), %rdi     # 0xf6a69
leaq 0x2fa22(%rip), %rsi     # 0xf691e
movl $0x14f, %edx            # imm = 0x14F
leaq 0x2fa9d(%rip), %rcx     # 0xf69a5
callq 0x42e0
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc6f18
jmp 0xc6f37
leaq 0x2fb5b(%rip), %rdi     # 0xf6a7a
leaq 0x2f9f8(%rip), %rsi     # 0xf691e
movl $0x150, %edx            # imm = 0x150
leaq 0x2fa73(%rip), %rcx     # 0xf69a5
callq 0x42e0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x60(%rbp)
movq 0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movq 0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x58(%rbp)
movq 0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x60(%rbp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movl -0x34(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movb %cl, -0x1(%rax)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %ecx
shll $0x3, %ecx
movl -0x34(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x60(%rbp), %eax
jb 0xc6fd8
movl -0x34(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x48(%rbp)
movb %cl, -0x1(%rax)
movl -0x34(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x5c(%rbp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movl -0x38(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movb %cl, -0x1(%rax)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %ecx
shll $0x3, %ecx
movl -0x38(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jb 0xc704a
movl -0x38(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x48(%rbp)
movb %cl, -0x1(%rax)
movl -0x38(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x58(%rbp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movb %cl, -0x1(%rax)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %ecx
shll $0x3, %ecx
movl -0x3c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x58(%rbp), %eax
jb 0xc70bc
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x48(%rbp)
movb %cl, -0x1(%rax)
movl -0x3c(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x54(%rbp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movl -0x40(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movb %cl, -0x1(%rax)
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x4c(%rbp), %ecx
shll $0x3, %ecx
movl -0x40(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x54(%rbp), %eax
jb 0xc712e
movl -0x40(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x48(%rbp)
movb %cl, -0x1(%rax)
movl -0x40(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x40(%rbp)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq -0x30(%rbp), %rcx
movzwl 0xe(%rcx), %ecx
movl %ecx, %ecx
shrq %cl, %rax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x30(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x6c(%rbp)
movl -0x38(%rbp), %eax
movq 0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq 0x10(%rbp), %rcx
movzwl 0xe(%rcx), %ecx
movl %ecx, %ecx
shrq %cl, %rax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movq 0x10(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %ecx
addl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
addl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movl -0x70(%rbp), %ecx
addl -0x38(%rbp), %ecx
movq 0x10(%rbp), %rax
addl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x3c(%rbp), %eax
movq 0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq 0x18(%rbp), %rcx
movzwl 0xe(%rcx), %ecx
movl %ecx, %ecx
shrq %cl, %rax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq 0x18(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x74(%rbp)
movl -0x40(%rbp), %eax
movq 0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq 0x20(%rbp), %rcx
movzwl 0xe(%rcx), %ecx
movl %ecx, %ecx
shrq %cl, %rax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movq 0x20(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movq 0x18(%rbp), %rax
addl 0x8(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x78(%rbp), %ecx
addl -0x40(%rbp), %ecx
movq 0x20(%rbp), %rax
addl 0x8(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)