// File: /workspace/github_c_makefile_star2_O0/bluecmd[P]fst-example/gtkwave/fstapi.c
// Function: fstWriterEmitSectionHeader
static void fstWriterEmitSectionHeader(void *ctx)
{
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;

if(xc)
        {
        unsigned long destlen;
        unsigned char *dmem;
        int rc;

        destlen = xc->maxvalpos;
        dmem = (unsigned char *)malloc(compressBound(destlen));
        rc = compress2(dmem, &destlen, xc->curval_mem, xc->maxvalpos, 4); /* was 9...which caused performance drag on traces with many signals */

        fputc(FST_BL_SKIP, xc->handle);                 /* temporarily tag the section, use FST_BL_VCDATA on finalize */
        xc->section_start = ftello(xc->handle);
#ifdef FST_WRITER_PARALLEL
        if(xc->xc_parent) xc->xc_parent->section_start = xc->section_start;
#endif
        xc->section_header_only = 1;                    /* indicates truncate might be needed */
        fstWriterUint64(xc->handle, 0);                 /* placeholder = section length */
        fstWriterUint64(xc->handle, xc->is_initial_time ? xc->firsttime : xc->curtime);         /* begin time of section */
        fstWriterUint64(xc->handle, xc->curtime);       /* end time of section (placeholder) */
        fstWriterUint64(xc->handle, 0);                 /* placeholder = amount of buffer memory required in reader for full vc traversal */
        fstWriterVarint(xc->handle, xc->maxvalpos);     /* maxvalpos = length of uncompressed data */

        if((rc == Z_OK) && (destlen < xc->maxvalpos))
                {
                fstWriterVarint(xc->handle, destlen);   /* length of compressed data */
                }
                else
                {
                fstWriterVarint(xc->handle, xc->maxvalpos); /* length of (unable to be) compressed data */
                }
        fstWriterVarint(xc->handle, xc->maxhandle);     /* max handle associated with this data (in case of dynamic facility adds) */

        if((rc == Z_OK) && (destlen < xc->maxvalpos))
                {
                fstFwrite(dmem, destlen, 1, xc->handle);
                }
                else /* comparison between compressed / decompressed len tells if compressed */
                {
                fstFwrite(xc->curval_mem, xc->maxvalpos, 1, xc->handle);
                }

        free(dmem);
        }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xa2dc
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x22a0
movq %rax, %rdi
callq 0x2280
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, %ecx
leaq -0x18(%rbp), %rsi
movl $0x4, %r8d
callq 0x2300
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl $0xff, %edi
callq 0x21c0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x20a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x10(%rbp), %rax
movb 0xe9(%rax), %cl
andb $-0x11, %cl
orb $0x10, %cl
movb %cl, 0xe9(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7840
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movb 0x74(%rax), %al
shrb %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0xa1d6
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0xa1e5
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x7840
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rsi
callq 0x7840
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7840
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, %esi
callq 0x78f0
cmpl $0x0, -0x24(%rbp)
jne 0xa256
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x70(%rcx), %ecx
cmpq %rcx, %rax
jae 0xa256
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x78f0
jmp 0xa26b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, %esi
callq 0x78f0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
movl %eax, %esi
callq 0x78f0
cmpl $0x0, -0x24(%rbp)
jne 0xa2b1
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x70(%rcx), %ecx
cmpq %rcx, %rax
jae 0xa2b1
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %edx
callq 0x78b0
jmp 0xa2d3
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, %esi
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %edx
callq 0x78b0
movq -0x20(%rbp), %rdi
callq 0x2040
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)