// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/rANS_byte.h
// Function: RansEncPutSymbol
static inline void RansEncPutSymbol(RansState* r, uint8_t** pptr, RansEncSymbol const* sym)
{
    RansAssert(sym->x_max != 0); // can't encode symbol with freq=0

    // renormalize
    uint32_t x = *r;
    uint32_t x_max = sym->x_max;

    // This is better for 40-qual illumina (3.7% quicker overall CRAM).
    // The old method was better for low complexity data such as NovaSeq
    // quals (2.6% quicker overall CRAM).
    int o = x >= x_max;
    uint8_t* ptr = *pptr;
    ptr[-1] = x & 0xff;
    ptr -= o;
    x >>= o*8;

    if (unlikely(x >= x_max)) {
        *--ptr = (uint8_t) (x & 0xff);
        x >>= 8;
    }
    *pptr = ptr;

    //uint32_t q = (uint32_t) (((uint64_t)x * sym->rcp_freq) >> sym->rcp_shift);
    //*r = q * sym->cmpl_freq + x + sym->bias;

    // x = C(s,x)
    // NOTE: written this way so we get a 32-bit "multiply high" when
    // available. If you're on a 64-bit platform with cheap multiplies
    // (e.g. x64), just bake the +32 into rcp_shift.
    //uint32_t q = (uint32_t) (((uint64_t)x * sym->rcp_freq) >> 32) >> sym->rcp_shift;

    // The extra >>32 has already been added to RansEncSymbolInit
    uint32_t q = (uint32_t) (((uint64_t)x * sym->rcp_freq) >> sym->rcp_shift);
    *r = q * sym->cmpl_freq + x + sym->bias;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xc6d4f
jmp 0xc6d6e
leaq 0x2fbe8(%rip), %rdi     # 0xf693e
leaq 0x2fbc1(%rip), %rsi     # 0xf691e
movl $0x11d, %edx            # imm = 0x11D
leaq 0x2fbe5(%rip), %rcx     # 0xf694e
callq 0x42e0
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, -0x1(%rax)
movl -0x24(%rbp), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %ecx
shll $0x3, %ecx
movl -0x1c(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setae %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0xc6e0c
movl -0x1c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, -0x1(%rax)
movl -0x1c(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x1c(%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, -0x34(%rbp)
movl -0x34(%rbp), %ecx
movq -0x18(%rbp), %rax
movzwl 0xc(%rax), %eax
imull %eax, %ecx
addl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
addl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)