// File: /workspace/github_c_makefile_star2_O2/bluecmd[P]fst-example/gtkwave/fstapi.c
// Function: fstWriterEmitVariableLengthValueChange
void fstWriterEmitVariableLengthValueChange(void *ctx, fstHandle handle, const void *val, uint32_t len)
{
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
const unsigned char *buf = (const unsigned char *)val;

if(FST_LIKELY((xc) && (handle <= xc->maxhandle)))
        {
        uint32_t fpos;
        uint32_t *vm4ip;

        if(FST_UNLIKELY(!xc->valpos_mem))
                {
                xc->vc_emitted = 1;
                fstWriterCreateMmaps(xc);
                }

        handle--; /* move starting at 1 index to starting at 0 */
        vm4ip = &(xc->valpos_mem[4*handle]);

        /* there is no initial time dump for variable length value changes */
        if(FST_LIKELY(!vm4ip[1])) /* len of zero = variable length */
                {
                fpos = xc->vchg_siz;

                if(FST_UNLIKELY((fpos + len + 10 + 5) > xc->vchg_alloc_siz))
                        {
                        xc->vchg_alloc_siz += (xc->fst_break_add_size + len + 5); /* +len added in the case of extremely long vectors and small break add sizes */
                        xc->vchg_mem = (unsigned char *)realloc(xc->vchg_mem, xc->vchg_alloc_siz);
                        if(FST_UNLIKELY(!xc->vchg_mem))
                                {
                                fprintf(stderr, FST_APIMESS "Could not realloc() in fstWriterEmitVariableLengthValueChange, exiting.\n");
                                exit(255);
                                }
                        }

                xc->vchg_siz += fstWriterUint32WithVarint32AndLength(xc, &vm4ip[2], xc->tchn_idx - vm4ip[3], buf, len); /* do one fwrite op only */
                vm4ip[3] = xc->tchn_idx;
                vm4ip[2] = fpos;
                }
        }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x6574
movl %esi, %r12d
movq %rdi, %rbx
cmpl %esi, 0x68(%rdi)
jb 0x6574
movl %ecx, %r15d
movq %rdx, %r8
movq 0x40(%rbx), %r13
testq %r13, %r13
je 0x6583
leal -0x4(,%r12,4), %r12d
cmpl $0x0, 0x4(%r13,%r12,4)
jne 0x6574
movl 0xa0(%rbx), %edx
movl 0xa4(%rbx), %eax
leal (%r15,%rdx), %ecx
addl $0xf, %ecx
cmpl %eax, %ecx
movq %rdx, -0x30(%rbp)
ja 0x659e
movq 0x30(%rbx), %rax
movl 0x8c(%rbx), %ecx
subl 0xc(%r13,%r12,4), %ecx
movl %edx, %edx
movl 0x8(%r13,%r12,4), %esi
leaq (%rax,%rdx), %rdi
addq $0x6, %rdi
movl %esi, -0x6(%rdi)
leal 0x6(%r15), %r14d
cmpl $0x80, %ecx
jb 0x652a
movl %ecx, %eax
shrl $0x7, %eax
orb $-0x80, %cl
movb %cl, -0x2(%rdi)
incl %r14d
incq %rdi
movl %eax, %ecx
jmp 0x650d
movb %cl, -0x2(%rdi)
movl %r15d, %eax
cmpl $0x80, %eax
jb 0x654b
movl %eax, %ecx
shrl $0x7, %ecx
orb $-0x80, %al
movb %al, -0x1(%rdi)
incl %r14d
incq %rdi
movl %ecx, %eax
jmp 0x6530
movb %al, -0x1(%rdi)
movl %r15d, %edx
movq %r8, %rsi
callq 0x2240
addl %r14d, 0xa0(%rbx)
movl 0x8c(%rbx), %eax
movl %eax, 0xc(%r13,%r12,4)
movq -0x30(%rbp), %rax
movl %eax, 0x8(%r13,%r12,4)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
orb $0x1, 0x74(%rbx)
movq %rbx, %rdi
movq %r8, %r14
callq 0x5ff1
movq %r14, %r8
movq 0x40(%rbx), %r13
jmp 0x64b5
movq %r8, %r14
movl 0x108(%rbx), %ecx
addl %r15d, %eax
leal (%rcx,%rax), %esi
addl $0x5, %esi
movl %esi, 0xa4(%rbx)
movq 0x30(%rbx), %rdi
callq 0x22c0
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x65d6
movl 0xa0(%rbx), %edx
movq %r14, %r8
jmp 0x64ec
movq 0xfa1b(%rip), %rax      # 0x15ff8
movq (%rax), %rcx
leaq 0xbe9d(%rip), %rdi      # 0x12484
pushq $0x52
popq %rsi
pushq $0x1
popq %rdx
callq 0x2390
movl $0xff, %edi
callq 0x2380