// File: /workspace/github_c_makefile_star2_O2/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 $0x1d8, %rsp            # imm = 0x1D8
movl %esi, %ebx
movq %rdi, %r12
pushq $0x1
popq %rdi
movl $0x158, %esi            # imm = 0x158
callq 0x21e0
movq %rax, %r15
andb $0x1, %bl
movq %rax, -0x68(%rbp)
movb %bl, 0xe9(%rax)
leaq 0xf4f4(%rip), %rdi      # 0x12855
leaq 0xf29f(%rip), %rsi      # 0x12607
callq 0x2330
testq %rax, %rax
movq %r15, -0x38(%rbp)
movq %r12, -0x30(%rbp)
je 0x3433
movq %rax, %r14
leaq -0x180(%rbp), %r15
leaq 0xf4d4(%rip), %r13      # 0x12863
pushq $0x9
popq %r12
movq %r14, %rdi
callq 0x2220
testl %eax, %eax
jne 0x3423
movb $0x0, -0x180(%rbp)
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x21d0
testq %rax, %rax
je 0x3393
movq %rax, %rbx
cmpb $0x0, (%rax)
je 0x3393
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2090
testl %eax, %eax
jne 0x3393
addq $0xa, %rbx
movq %rbx, %rdi
callq 0x2310
shlq $0x7, %rax
movabsq $0x1fffffffffffff80, %rcx # imm = 0x1FFFFFFFFFFFFF80
andq %rcx, %rax
cmpq $0x8000001, %rax        # imm = 0x8000001
jb 0x3393
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq -0x38(%rbp), %r15
movq %rcx, 0x110(%r15)
movq %r14, %rdi
callq 0x2110
movq -0x30(%rbp), %r12
jmp 0x343e
movq %r14, %rdi
callq 0x2110
movq -0x38(%rbp), %r15
movq -0x30(%rbp), %r12
movq $0x8000000, 0x110(%r15) # imm = 0x8000000
movl $0x8000000, %eax        # imm = 0x8000000
movq %rax, 0xf0(%r15)
movq %rax, 0x100(%r15)
movl $0x400000, %eax         # imm = 0x400000
movq %rax, 0xf8(%r15)
movq %rax, 0x108(%r15)
movl $0xf4240, 0x118(%r15) # imm = 0xF4240
testq %r12, %r12
je 0x371e
movq %r12, %rdi
callq 0x37ee
movq %rax, (%r15)
testq %rax, %rax
je 0x371e
movq %rax, -0x50(%rbp)
movq %r12, %rdi
callq 0x2130
movq %rax, %rbx
addl $0x6, %eax
movslq %eax, %rsi
pushq $0x1
popq %rdi
callq 0x21e0
movq %rax, %r14
movslq %ebx, %rbx
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2240
movl $0x6569682e, (%r14,%rbx) # imm = 0x6569682E
movw $0x72, 0x4(%r14,%rbx)
movq %r14, -0x48(%rbp)
movq %r14, %rdi
callq 0x37ee
movq %rax, %r14
movq %rax, 0x8(%r15)
callq 0x21f0
movq %rax, %r13
andq $0x0, 0x130(%r15)
movq %rax, 0x10(%r15)
callq 0x21f0
movq %rax, %r12
andq $0x0, 0x138(%r15)
movq %rax, 0x18(%r15)
callq 0x21f0
andq $0x0, 0x140(%r15)
movq %rax, -0x40(%rbp)
movq %rax, 0x20(%r15)
callq 0x21f0
andq $0x0, 0x148(%r15)
movq %rax, %rbx
movq %rax, 0x28(%r15)
movl $0x8400000, 0xa4(%r15) # imm = 0x8400000
movl $0x8400000, %edi        # imm = 0x8400000
callq 0x2270
movq %rax, 0x30(%r15)
testq %r13, %r13
je 0x3729
testq %r12, %r12
je 0x3729
testq %r14, %r14
je 0x3729
testq %rbx, %rbx
je 0x3729
testq %rax, %rax
je 0x3729
cmpq $0x0, -0x40(%rbp)
je 0x3729
movq -0x30(%rbp), %rdi
callq 0x23a0
movq -0x38(%rbp), %r15
movq %rax, 0x60(%r15)
movb $0x2, 0x74(%r15)
movabsq $0x4005bf0a8b145769, %rax # imm = 0x4005BF0A8B145769
leaq -0x78(%rbp), %rbx
movq %rax, (%rbx)
xorl %edi, %edi
movq -0x50(%rbp), %r13
movq %r13, %rsi
callq 0x21c0
movl $0x149, %esi            # imm = 0x149
movq %r13, %rdi
callq 0x502a
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
pushq $0x8
popq %rsi
pushq $0x1
popq %r12
movq %rbx, %rdi
movq %r12, %rdx
movq %r13, %rcx
callq 0x2390
movl $0x8000000, %esi        # imm = 0x8000000
movq %r13, %rdi
callq 0x502a
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
movl $0xf7, %edi
movq %r13, %rsi
callq 0x21c0
xorps %xmm0, %xmm0
leaq -0x180(%rbp), %rdi
movups %xmm0, 0xa(%rdi)
movups %xmm0, 0x1a(%rdi)
movups %xmm0, 0x2a(%rdi)
movups %xmm0, 0x3a(%rdi)
movups %xmm0, 0x4a(%rdi)
movups %xmm0, 0x6a(%rdi)
andq $0x0, 0x78(%rdi)
movups %xmm0, 0x5a(%rdi)
movabsq $0x6574697257747366, %rax # imm = 0x6574697257747366
movq %rax, (%rdi)
movw $0x72, 0x8(%rdi)
movl $0x80, %esi
movq %r12, %rdx
movq %r13, %rcx
callq 0x2390
leaq -0x200(%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)
andq $0x0, 0x6f(%r14)
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x2250
movq %rbx, %rdi
callq 0x2060
movq %rax, %rdi
callq 0x2150
movq %r14, %rdi
movq %rax, %rsi
callq 0x20a0
pushq $0x77
popq %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %r13, %rcx
callq 0x2390
xorl %edi, %edi
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
xorl %esi, %esi
callq 0x502a
movq %r13, %rdi
callq 0x2280
leaq 0xec03(%rip), %rdi      # 0x1230c
xorl %esi, %esi
callq 0x20d0
movsd %xmm0, 0xc0(%r15)
jmp 0x37d0
movq %r15, %rdi
xorl %r15d, %r15d
jmp 0x37d4
movq -0x68(%rbp), %rbx
leaq 0x130(%rbx), %r13
leaq 0x10(%rbx), %r12
leaq 0x138(%rbx), %rax
movq %rax, -0x60(%rbp)
leaq 0x18(%rbx), %rax
movq %rax, -0x58(%rbp)
leaq 0x140(%rbx), %rax
movq %rax, -0x30(%rbp)
leaq 0x20(%rbx), %rax
movq %rax, -0x40(%rbp)
leaq 0x148(%rbx), %r15
addq $0x28, %rbx
movq -0x50(%rbp), %rdi
callq 0x2110
testq %r14, %r14
je 0x3788
movq %r14, %rdi
callq 0x2110
movq -0x48(%rbp), %rdi
callq 0x2080
movq %r12, %rdi
movq %r13, %rsi
callq 0x3811
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x3811
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3811
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3811
movq -0x38(%rbp), %rbx
movq 0x30(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
xorl %r15d, %r15d
movq -0x48(%rbp), %rdi
callq 0x2050
movq %r15, %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq