// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
testq %rdi, %rdi
je 0x8e18
movl %esi, %r12d
movq %rdi, %r14
cmpl %esi, 0x68(%rdi)
jb 0x8e18
movq %rdx, %rbx
movq 0x40(%r14), %r15
testq %r15, %r15
je 0x8e27
leal -0x4(,%r12,4), %esi
cmpl $0x0, 0x4(%r15,%rsi,4)
jne 0x8e18
movl 0xa0(%r14), %edi
movl 0xa4(%r14), %eax
leal (%rcx,%rdi), %edx
addl $0xf, %edx
cmpl %eax, %edx
movq %rsi, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
ja 0x8e49
movq 0x30(%r14), %r12
movl %edi, %eax
movl 0x8c(%r14), %edi
subl 0xc(%r15,%rsi,4), %edi
movl 0x8(%r15,%rsi,4), %edx
movl %eax, %eax
leaq (%r12,%rax), %r13
addq $0x4, %r13
movl %edx, -0x4(%r13)
cmpl $0x80, %edi
jae 0x8d8d
movl %edi, %edx
jmp 0x8da9
movl %edi, %edx
shrl $0x7, %edx
movl %edi, %esi
orb $-0x80, %sil
movb %sil, (%r13)
incq %r13
cmpl $0x3fff, %edi           # imm = 0x3FFF
movl %edx, %edi
ja 0x8d8f
addq %rax, %r12
movb %dl, (%r13)
leaq 0x1(%r13), %rax
movl %ecx, %edi
cmpl $0x80, %ecx
jb 0x8ddb
movl %edi, %edx
shrl $0x7, %edi
movl %edx, %esi
orb $-0x80, %sil
movb %sil, (%rax)
incq %rax
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x8dbe
leaq -0x1(%rax), %r13
addq $0x2, %r13
movb %dil, (%rax)
movl %ecx, %edx
movq %r13, %rdi
movq %rbx, %rsi
movq %rcx, %rbx
callq 0x2240
subl %r12d, %r13d
addl %ebx, %r13d
addl %r13d, 0xa0(%r14)
movl 0x8c(%r14), %eax
movq -0x30(%rbp), %rcx
movl %eax, 0xc(%r15,%rcx,4)
movq -0x38(%rbp), %rax
movl %eax, 0x8(%r15,%rcx,4)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
orb $0x1, 0x74(%r14)
movq %r14, %rdi
movq %rbx, %r15
movq %rcx, %rbx
callq 0x878b
movq %rbx, %rcx
movq %r15, %rbx
movq 0x40(%r14), %r15
jmp 0x8d24
movl 0x108(%r14), %edx
movq %rcx, %r13
addl %ecx, %eax
leal (%rdx,%rax), %esi
addl $0x5, %esi
movl %esi, 0xa4(%r14)
movq 0x30(%r14), %rdi
callq 0x22c0
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x8e8a
movq %rax, %r12
movl 0xa0(%r14), %eax
movq %r13, %rcx
movq -0x30(%rbp), %rsi
jmp 0x8d62
callq 0x2a7c