// File: /workspace/github_c_makefile_star2_O1/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:
testq %rdi, %rdi
je 0x7410
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r12d
movq %rdi, %r14
cmpl %esi, 0x68(%rdi)
jb 0x7402
movl %ecx, %r8d
movq %rdx, %r13
cmpq $0x0, 0x40(%r14)
je 0x7411
movq 0x40(%r14), %rsi
leal -0x4(,%r12,4), %r15d
cmpl $0x0, 0x4(%rsi,%r15,4)
jne 0x7402
movl 0xa0(%r14), %eax
movl 0xa4(%r14), %edx
movq %rax, -0x30(%rbp)
addl %r8d, %eax
addl $0xf, %eax
cmpl %edx, %eax
ja 0x7424
movl 0x8c(%r14), %ecx
subl 0xc(%rsi,%r15,4), %ecx
movq 0x30(%r14), %rbx
movl 0xa0(%r14), %eax
movq %rsi, -0x38(%rbp)
movl 0x8(%rsi,%r15,4), %edx
leaq (%rbx,%rax), %r12
addq $0x4, %r12
movl %edx, -0x4(%r12)
cmpl $0x80, %ecx
jae 0x7374
movl %ecx, %edx
jmp 0x7390
movl %ecx, %edx
shrl $0x7, %edx
movl %ecx, %esi
orb $-0x80, %sil
movb %sil, (%r12)
incq %r12
cmpl $0x3fff, %ecx           # imm = 0x3FFF
movl %edx, %ecx
ja 0x7376
addq %rax, %rbx
movb %dl, (%r12)
leaq 0x1(%r12), %rax
movl %r8d, %ecx
cmpl $0x80, %r8d
jb 0x73c5
movl %ecx, %edx
shrl $0x7, %ecx
movl %edx, %esi
orb $-0x80, %sil
movb %sil, (%rax)
incq %rax
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x73a8
leaq -0x1(%rax), %r12
addq $0x2, %r12
movb %cl, (%rax)
movl %r8d, %edx
movq %r12, %rdi
movq %r13, %rsi
movq %r8, %r13
callq 0x2240
subl %ebx, %r12d
addl %r13d, %r12d
addl %r12d, 0xa0(%r14)
movl 0x8c(%r14), %eax
movq -0x38(%rbp), %rcx
movl %eax, 0xc(%rcx,%r15,4)
movq -0x30(%rbp), %rax
movl %eax, 0x8(%rcx,%r15,4)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r8, %rbx
callq 0x2636
movq %rbx, %r8
jmp 0x7303
leaq 0xa4(%r14), %rcx
movq %r14, %rdi
movq %rsi, %r12
movl %r8d, %esi
movq %r8, %rbx
callq 0x2644
movq %r12, %rsi
movq %rbx, %r8
jmp 0x733b