// File: /workspace/github_c_makefile_star2_O3/bluecmd[P]fst-example/gtkwave/fstapi.c
// Function: fstWriterCreate
void *fstWriterCreate(const char *nam, int use_compressed_hier)
{
struct fstWriterContext *xc = (struct fstWriterContext *)calloc(1, sizeof(struct fstWriterContext));

xc->compress_hier = use_compressed_hier;
fstDetermineBreakSize(xc);

if((!nam)||
        (!(xc->handle=unlink_fopen(nam, "w+b"))))
        {
        free(xc);
        xc=NULL;
        }
        else
        {
        int flen = strlen(nam);
        char *hf = (char *)calloc(1, flen + 6);

        memcpy(hf, nam, flen);
        strcpy(hf + flen, ".hier");
        xc->hier_handle = unlink_fopen(hf, "w+b");

        xc->geom_handle = tmpfile_open(&xc->geom_handle_nam);           /* .geom */
        xc->valpos_handle = tmpfile_open(&xc->valpos_handle_nam);       /* .offs */
        xc->curval_handle = tmpfile_open(&xc->curval_handle_nam);       /* .bits */
        xc->tchn_handle = tmpfile_open(&xc->tchn_handle_nam);           /* .tchn */
        xc->vchg_alloc_siz = xc->fst_break_size + xc->fst_break_add_size;
        xc->vchg_mem = (unsigned char *)malloc(xc->vchg_alloc_siz);

        if(xc->hier_handle && xc->geom_handle && xc->valpos_handle && xc->curval_handle && xc->vchg_mem && xc->tchn_handle)
                {
                xc->filename = strdup(nam);
                xc->is_initial_time = 1;

                fstWriterEmitHdrBytes(xc);
                xc->nan = strtod("NaN", NULL);
#ifdef FST_WRITER_PARALLEL
                pthread_mutex_init(&xc->mutex, NULL);
                pthread_attr_init(&xc->thread_attr);
                pthread_attr_setdetachstate(&xc->thread_attr, PTHREAD_CREATE_DETACHED);
#endif
                }
                else
                {
                fclose(xc->handle);
                if(xc->hier_handle) { fclose(xc->hier_handle); unlink(hf); }
                tmpfile_close(&xc->geom_handle, &xc->geom_handle_nam);
                tmpfile_close(&xc->valpos_handle, &xc->valpos_handle_nam);
                tmpfile_close(&xc->curval_handle, &xc->curval_handle_nam);
                tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
                free(xc->vchg_mem);
                free(xc);
                xc=NULL;
                }

        free(hf);
        }

return(xc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl %esi, %r14d
movq %rdi, %r12
movl $0x1, %edi
movl $0x158, %esi            # imm = 0x158
callq 0x21e0
movq %rax, %rbx
andb $0x1, %r14b
movb %r14b, 0xe9(%rax)
leaq 0xf53f(%rip), %rdi      # 0x14855
leaq 0xf2ea(%rip), %rsi      # 0x14607
callq 0x2330
testq %rax, %rax
movq %r12, -0x38(%rbp)
je 0x53c5
movq %rax, %r14
movq %rax, %rdi
callq 0x2220
testl %eax, %eax
jne 0x53b9
leaq -0x170(%rbp), %r15
leaq 0xf517(%rip), %r13      # 0x14863
movb $0x0, -0x170(%rbp)
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x21d0
testq %rax, %rax
je 0x53ad
movq %rax, %r12
cmpb $0x0, (%rax)
je 0x53ad
movl $0x9, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2090
testl %eax, %eax
jne 0x53ad
addq $0xa, %r12
movq %r12, %rdi
callq 0x2310
shlq $0x7, %rax
movabsq $0x1fffffffffffff80, %rcx # imm = 0x1FFFFFFFFFFFFF80
andq %rcx, %rax
cmpq $0x8000000, %rax        # imm = 0x8000000
ja 0x5870
movq %r14, %rdi
callq 0x2220
testl %eax, %eax
je 0x534c
movq %r14, %rdi
callq 0x2110
movq -0x38(%rbp), %r12
movq $0x8000000, 0x110(%rbx) # imm = 0x8000000
movl $0x8000000, %eax        # imm = 0x8000000
movq %rax, 0xf0(%rbx)
movq %rax, 0x100(%rbx)
movl $0x400000, %eax         # imm = 0x400000
movq %rax, 0xf8(%rbx)
movq %rax, 0x108(%rbx)
movl $0xf4240, 0x118(%rbx)   # imm = 0xF4240
testq %r12, %r12
je 0x5537
movq %r12, %rdi
callq 0x2080
leaq 0xeef0(%rip), %rsi      # 0x14308
movq %r12, %rdi
callq 0x2330
movq %rax, (%rbx)
testq %rax, %rax
je 0x5537
movq %rax, -0x30(%rbp)
movq %r12, %rdi
callq 0x2130
movq %rax, %r14
addl $0x6, %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x21e0
movq %rax, %r15
movslq %r14d, %r14
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2240
movl $0x6569682e, (%r15,%r14) # imm = 0x6569682E
movw $0x72, 0x4(%r15,%r14)
movq %r15, %rdi
callq 0x2080
leaq 0xee8a(%rip), %rsi      # 0x14308
movq %r15, -0x40(%rbp)
movq %r15, %rdi
callq 0x2330
movq %rax, %r15
movq %rax, 0x8(%rbx)
callq 0x21f0
xorl %r13d, %r13d
movq %r13, 0x130(%rbx)
movq %rax, -0x50(%rbp)
movq %rax, 0x10(%rbx)
callq 0x21f0
movq %rax, %r14
movq %r13, 0x138(%rbx)
movq %rax, 0x18(%rbx)
callq 0x21f0
movq %r13, 0x140(%rbx)
movq %rax, -0x48(%rbp)
movq %rax, 0x20(%rbx)
callq 0x21f0
movq %rax, %r12
movq %r13, 0x148(%rbx)
movq %rax, 0x28(%rbx)
movl $0x8400000, 0xa4(%rbx)  # imm = 0x8400000
movl $0x8400000, %edi        # imm = 0x8400000
callq 0x2270
movq %rax, 0x30(%rbx)
testq %r15, %r15
je 0x5546
movq %r15, %r13
cmpq $0x0, -0x50(%rbp)
sete %cl
testq %r14, %r14
sete %dl
orb %cl, %dl
movq -0x30(%rbp), %r14
je 0x55df
movq %r14, %rdi
callq 0x2110
movq %r13, %rdi
callq 0x2110
movq -0x40(%rbp), %rdi
callq 0x2080
jmp 0x554f
movq %rbx, %rdi
callq 0x2050
xorl %ebx, %ebx
jmp 0x55ca
movq -0x30(%rbp), %rdi
callq 0x2110
leaq 0x130(%rbx), %rsi
leaq 0x10(%rbx), %rdi
leaq 0x138(%rbx), %r14
leaq 0x18(%rbx), %r15
leaq 0x140(%rbx), %rax
movq %rax, -0x30(%rbp)
leaq 0x20(%rbx), %r13
leaq 0x148(%rbx), %rax
movq %rax, -0x38(%rbp)
movq %rbx, %r12
addq $0x28, %r12
callq 0x5894
movq %r15, %rdi
movq %r14, %rsi
callq 0x5894
movq %r13, %rdi
movq -0x30(%rbp), %rsi
callq 0x5894
movq %r12, %rdi
movq -0x38(%rbp), %rsi
callq 0x5894
movq 0x30(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
xorl %ebx, %ebx
movq -0x40(%rbp), %rdi
callq 0x2050
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x551c
testq %rax, %rax
je 0x551c
cmpq $0x0, -0x48(%rbp)
je 0x551c
movq -0x38(%rbp), %rdi
callq 0x23a0
movq %rax, 0x60(%rbx)
movb $0x2, 0x74(%rbx)
movabsq $0x4005bf0a8b145769, %rax # imm = 0x4005BF0A8B145769
movq %rax, -0x58(%rbp)
xorl %edi, %edi
movq %r14, %rsi
callq 0x21c0
movw $0x149, %ax             # imm = 0x149
movl $0x8, %ecx
movzwl %ax, %eax
movb %al, -0x171(%rbp,%rcx)
shrl $0x8, %eax
decq %rcx
jne 0x562e
leaq -0x170(%rbp), %r14
movl $0x8, %r15d
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq -0x30(%rbp), %r13
movq %r13, %rcx
callq 0x2390
xorl %r12d, %r12d
movq %r12, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0x2390
movq %r12, (%r14)
leaq -0x170(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2390
leaq -0x58(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2390
movl $0x8000000, %eax        # imm = 0x8000000
movb %al, -0x171(%rbp,%r15)
shrq $0x8, %rax
decq %r15
jne 0x56b8
leaq -0x170(%rbp), %r14
movl $0x8, %r12d
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq -0x30(%rbp), %r13
movq %r13, %rcx
callq 0x2390
xorl %r15d, %r15d
movq %r15, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0x2390
movq %r15, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0x2390
movq %r15, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0x2390
movq %r15, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0x2390
movl $0xf7, %edi
movq %r13, %rsi
callq 0x21c0
xorps %xmm0, %xmm0
movups %xmm0, 0xa(%r14)
movups %xmm0, 0x1a(%r14)
movups %xmm0, 0x2a(%r14)
movups %xmm0, 0x3a(%r14)
movups %xmm0, 0x4a(%r14)
movups %xmm0, 0x5a(%r14)
movups %xmm0, 0x6a(%r14)
movq %r15, 0x78(%r14)
movabsq $0x6574697257747366, %rax # imm = 0x6574697257747366
movq %rax, (%r14)
movw $0x72, 0x8(%r14)
leaq -0x170(%rbp), %rdi
movl $0x80, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2390
leaq -0x1f0(%rbp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x40(%r14)
movaps %xmm0, 0x50(%r14)
movaps %xmm0, 0x60(%r14)
movq %r15, 0x6f(%r14)
leaq -0x68(%rbp), %r15
movq %r15, %rdi
callq 0x2250
movq %r15, %rdi
callq 0x2060
movq %rax, %rdi
callq 0x2150
movq %r14, %rdi
movq %rax, %rsi
callq 0x20a0
movl $0x77, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0x2390
xorl %edi, %edi
movq %r13, %rsi
callq 0x21c0
movb $0x0, -0x61(%rbp,%r12)
decq %r12
jne 0x582c
leaq -0x60(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2390
movq %r13, %rdi
callq 0x2280
leaq 0xeab0(%rip), %rdi      # 0x1430c
xorl %esi, %esi
callq 0x20d0
movsd %xmm0, 0xc0(%rbx)
jmp 0x55c1
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, 0x110(%rbx)
movq %r14, %rdi
callq 0x2110
movq -0x38(%rbp), %r12
jmp 0x53d0