// File: /workspace/github_c_makefile_star2_O0/bluecmd[P]fst-example/gtkwave/fstapi.c
// Function: fstWriterCreateVar
fstHandle fstWriterCreateVar(void *ctx, enum fstVarType vt, enum fstVarDir vd,
        uint32_t len, const char *nam, fstHandle aliasHandle)
{
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
unsigned int i;
int nlen, is_real;

if(xc && nam)
        {
        if(xc->valpos_mem)
                {
                fstDestroyMmaps(xc, 0);
                }

        fputc(vt, xc->hier_handle);
        fputc(vd, xc->hier_handle);
        nlen = strlen(nam);
        fstFwrite(nam, nlen, 1, xc->hier_handle);
        fputc(0, xc->hier_handle);
        xc->hier_file_len += (nlen+3);

        if((vt == FST_VT_VCD_REAL) || (vt == FST_VT_VCD_REAL_PARAMETER) || (vt == FST_VT_VCD_REALTIME) || (vt == FST_VT_SV_SHORTREAL))
                {
                is_real = 1;
                len = 8; /* recast number of bytes to that of what a double is */
                }
                else
                {
                is_real = 0;
                if(vt == FST_VT_GEN_STRING)
                        {
                        len = 0;
                        }
                }

        xc->hier_file_len += fstWriterVarint(xc->hier_handle, len);

        if(aliasHandle > xc->maxhandle) aliasHandle = 0;
        xc->hier_file_len += fstWriterVarint(xc->hier_handle, aliasHandle);
        xc->numsigs++;
        if(xc->numsigs == xc->next_huge_break)
                {
                if(xc->fst_break_size < xc->fst_huge_break_size)
                        {
                        xc->next_huge_break += FST_ACTIVATE_HUGE_INC;
                        xc->fst_break_size += xc->fst_orig_break_size;
                        xc->fst_break_add_size += xc->fst_orig_break_add_size;

                        xc->vchg_alloc_siz = xc->fst_break_size + xc->fst_break_add_size;
                        if(xc->vchg_mem)
                                {
                                xc->vchg_mem = (unsigned char *)realloc(xc->vchg_mem, xc->vchg_alloc_siz);
                                }
                        }
                }

        if(!aliasHandle)
                {
                uint32_t zero = 0;

                if(len)
                        {
                        fstWriterVarint(xc->geom_handle, !is_real ? len : 0); /* geom section encodes reals as zero byte */
                        }
                        else
                        {
                        fstWriterVarint(xc->geom_handle, 0xFFFFFFFF);         /* geom section encodes zero len as 32b -1 */
                        }

                fstFwrite(&xc->maxvalpos, sizeof(uint32_t), 1, xc->valpos_handle);
                fstFwrite(&len, sizeof(uint32_t), 1, xc->valpos_handle);
                fstFwrite(&zero, sizeof(uint32_t), 1, xc->valpos_handle);
                fstFwrite(&zero, sizeof(uint32_t), 1, xc->valpos_handle);

                if(!is_real)
                        {
                        for(i=0;i<len;i++)
                                {
                                fputc('x', xc->curval_handle);
                                }
                        }
                        else
                        {
                        fstFwrite(&xc->nan, 8, 1, xc->curval_handle); /* initialize doubles to NaN rather than x */
                        }

                xc->maxvalpos+=len;
                xc->maxhandle++;
                return(xc->maxhandle);
                }
                else
                {
                return(aliasHandle);
                }
        }

return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x8973
cmpq $0x0, -0x28(%rbp)
je 0x8973
movq -0x38(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x8641
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x7740
movl -0x14(%rbp), %edi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x21c0
movl -0x18(%rbp), %edi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x21c0
movq -0x28(%rbp), %rdi
callq 0x2130
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movl $0x1, %edx
callq 0x78b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edi, %edi
callq 0x21c0
movl -0x40(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rcx
movq -0x38(%rbp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
cmpl $0x3, -0x14(%rbp)
je 0x86c3
cmpl $0x4, -0x14(%rbp)
je 0x86c3
cmpl $0x14, -0x14(%rbp)
je 0x86c3
cmpl $0x1d, -0x14(%rbp)
jne 0x86d3
movl $0x1, -0x44(%rbp)
movl $0x8, -0x1c(%rbp)
jmp 0x86e9
movl $0x0, -0x44(%rbp)
cmpl $0x15, -0x14(%rbp)
jne 0x86e7
movl $0x0, -0x1c(%rbp)
jmp 0x86e9
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x78f0
movslq %eax, %rcx
movq -0x38(%rbp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
movl -0x2c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x68(%rcx), %eax
jbe 0x871d
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %esi
callq 0x78f0
movslq %eax, %rcx
movq -0x38(%rbp), %rax
addq 0x38(%rax), %rcx
movq %rcx, 0x38(%rax)
movq -0x38(%rbp), %rax
movl 0x6c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x6c(%rax)
movq -0x38(%rbp), %rax
movl 0x6c(%rax), %eax
movq -0x38(%rbp), %rcx
cmpl 0x118(%rcx), %eax
jne 0x8823
movq -0x38(%rbp), %rax
movq 0x100(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x110(%rcx), %rax
jae 0x8821
movq -0x38(%rbp), %rax
movl 0x118(%rax), %ecx
addl $0xf4240, %ecx          # imm = 0xF4240
movl %ecx, 0x118(%rax)
movq -0x38(%rbp), %rax
movq 0xf0(%rax), %rcx
movq -0x38(%rbp), %rax
addq 0x100(%rax), %rcx
movq %rcx, 0x100(%rax)
movq -0x38(%rbp), %rax
movq 0xf8(%rax), %rcx
movq -0x38(%rbp), %rax
addq 0x108(%rax), %rcx
movq %rcx, 0x108(%rax)
movq -0x38(%rbp), %rax
movq 0x100(%rax), %rax
movq -0x38(%rbp), %rcx
addq 0x108(%rcx), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xa4(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x881f
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x38(%rbp), %rax
movl 0xa4(%rax), %eax
movl %eax, %esi
callq 0x22c0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x8821
jmp 0x8823
cmpl $0x0, -0x2c(%rbp)
jne 0x896b
movl $0x0, -0x48(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x886d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x8854
movl -0x1c(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x885b
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0x885b
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x78f0
jmp 0x887f
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x78f0
movq -0x38(%rbp), %rdi
addq $0x70, %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x78b0
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
leaq -0x1c(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x78b0
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
leaq -0x48(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x78b0
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rcx
leaq -0x48(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x78b0
cmpl $0x0, -0x44(%rbp)
jne 0x8923
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x8921
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x78, %edi
callq 0x21c0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x88fc
jmp 0x8945
movq -0x38(%rbp), %rdi
addq $0xc0, %rdi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x78b0
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %rax
addl 0x70(%rax), %ecx
movl %ecx, 0x70(%rax)
movq -0x38(%rbp), %rax
movl 0x68(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x68(%rax)
movq -0x38(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x897a
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x897a
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)