// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %rax, %rbx
movb 0xe9(%rax), %al
andb $0x1, %r14b
andb $-0x2, %al
orb %r14b, %al
movb %al, 0xe9(%r15)
leaq 0x11f15(%rip), %rdi     # 0x15855
leaq 0x11cc0(%rip), %rsi     # 0x15607
callq 0x2330
testq %rax, %rax
je 0x396c
movq %rax, %r14
movq %rax, %rdi
callq 0x2220
testl %eax, %eax
je 0x3e20
movq %r14, %rdi
callq 0x2110
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 0x3d72
movq %r12, %rdi
callq 0x2080
leaq 0x11949(%rip), %rsi     # 0x15308
movq %r12, %rdi
callq 0x2330
movq %rax, (%rbx)
testq %rax, %rax
je 0x3d72
movq %r12, %rdi
callq 0x2130
movq %rax, %r14
addl $0x6, %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x21e0
movq %rax, %r13
movslq %r14d, %r14
movq %rax, %rdi
movq %r12, -0x38(%rbp)
movq %r12, %rsi
movq %r14, %rdx
callq 0x2240
movl $0x6569682e, (%r13,%r14) # imm = 0x6569682E
movw $0x72, 0x4(%r13,%r14)
movq %r13, %rdi
callq 0x2080
leaq 0x118e2(%rip), %rsi     # 0x15308
movq %r13, %rdi
callq 0x2330
movq %rax, 0x8(%rbx)
callq 0x21f0
xorl %r12d, %r12d
movq %r12, 0x130(%rbx)
leaq 0x10(%r15), %rcx
movq %rcx, -0x50(%rbp)
movq %rax, 0x10(%rbx)
callq 0x21f0
movq %r12, 0x138(%rbx)
leaq 0x18(%r15), %rcx
movq %rcx, -0x48(%rbp)
movq %rax, 0x18(%rbx)
callq 0x21f0
movq %r12, 0x140(%rbx)
leaq 0x20(%r15), %rcx
movq %rcx, -0x40(%rbp)
movq %rax, 0x20(%rbx)
callq 0x21f0
movq %rax, %r14
movq %r12, 0x148(%rbx)
movq %rax, 0x28(%rbx)
movq 0x108(%rbx), %rax
addq 0x100(%rbx), %rax
movl %eax, 0xa4(%rbx)
movl %eax, %edi
callq 0x2270
movq %rax, 0x30(%rbx)
cmpq %r12, 0x8(%rbx)
movq %r13, -0x30(%rbp)
je 0x3d7c
movq -0x50(%rbp), %rcx
cmpq $0x0, (%rcx)
je 0x3d7c
movq -0x48(%rbp), %rcx
cmpq $0x0, (%rcx)
je 0x3d7c
testq %r14, %r14
je 0x3d7c
testq %rax, %rax
je 0x3d7c
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3d7c
movq -0x38(%rbp), %rdi
callq 0x23a0
movq %rax, 0x60(%rbx)
orb $0x2, 0x74(%rbx)
movabsq $0x4005bf0a8b145769, %rax # imm = 0x4005BF0A8B145769
movq %rax, -0x58(%rbp)
movq (%rbx), %rsi
xorl %edi, %edi
callq 0x21c0
movq (%rbx), %rcx
movl $0x149, %eax            # imm = 0x149
movl $0x8, %edx
movb %al, -0x171(%rbp,%rdx)
shrq $0x8, %rax
decq %rdx
jne 0x3b2f
leaq -0x170(%rbp), %r14
movl $0x8, %r15d
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rcx
xorl %r12d, %r12d
movq %r12, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rcx
movq %r12, (%r14)
leaq -0x170(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
leaq -0x58(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movq 0x100(%rbx), %rax
movb %al, -0x171(%rbp,%r15)
shrq $0x8, %rax
decq %r15
jne 0x3bb5
leaq -0x170(%rbp), %r14
movl $0x8, %r12d
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rcx
xorl %r13d, %r13d
movq %r13, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rcx
movq %r13, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rcx
movq %r13, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rcx
movq %r13, (%r14)
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x2390
movq (%rbx), %rsi
movl $0xf7, %edi
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 %r13, 0x78(%r14)
movabsq $0x6574697257747366, %rax # imm = 0x6574697257747366
movq %rax, (%r14)
movw $0x72, 0x8(%r14)
movq (%rbx), %rcx
leaq -0x170(%rbp), %rdi
movl $0x80, %esi
movl $0x1, %edx
callq 0x2390
leaq -0x1f0(%rbp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x50(%r15)
movaps %xmm0, 0x60(%r15)
movq %r13, 0x6f(%r15)
leaq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x2250
movq %r14, %rdi
callq 0x2060
movq %rax, %rdi
callq 0x2150
movq %r15, %rdi
movq %rax, %rsi
callq 0x20a0
movq (%rbx), %rcx
movl $0x77, %esi
movl $0x1, %edx
movq %r15, %rdi
callq 0x2390
movzbl 0xe8(%rbx), %edi
movq (%rbx), %rsi
callq 0x21c0
movq (%rbx), %rcx
movq 0x78(%rbx), %rax
movb %al, -0x61(%rbp,%r12)
shrq $0x8, %rax
decq %r12
jne 0x3d2e
leaq -0x60(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
callq 0x2280
leaq 0x115ae(%rip), %rdi     # 0x1530c
xorl %esi, %esi
callq 0x20d0
movsd %xmm0, 0xc0(%rbx)
jmp 0x3e02
movq %rbx, %rdi
xorl %ebx, %ebx
jmp 0x3e06
leaq 0x130(%r15), %r12
leaq 0x138(%r15), %r14
leaq 0x140(%r15), %r13
leaq 0x148(%r15), %rax
movq %rax, -0x38(%rbp)
addq $0x28, %r15
movq (%rbx), %rdi
callq 0x2110
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x3dbf
callq 0x2110
movq -0x30(%rbp), %rdi
callq 0x2080
movq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x3ee0
movq -0x48(%rbp), %rdi
movq %r14, %rsi
callq 0x3ee0
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x3ee0
movq %r15, %rdi
movq -0x38(%rbp), %rsi
callq 0x3ee0
movq 0x30(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
xorl %ebx, %ebx
movq -0x30(%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
movq %r12, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
leaq -0x170(%rbp), %r13
movb $0x0, -0x170(%rbp)
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x21d0
testq %rax, %rax
je 0x3eb5
movq %rax, %r12
cmpb $0x0, (%rax)
je 0x3eb5
movl $0x9, %edx
movq %r12, %rdi
leaq 0x119fe(%rip), %rsi     # 0x15863
callq 0x2090
testl %eax, %eax
jne 0x3eb5
addq $0xa, %r12
movq %r12, %rdi
callq 0x2310
shlq $0x7, %rax
movabsq $0x1fffffffffffff80, %rcx # imm = 0x1FFFFFFFFFFFFF80
andq %rcx, %rax
cmpq $0x8000001, %rax        # imm = 0x8000001
jb 0x3ead
movl $0x80000000, %ecx       # imm = 0x80000000
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, 0x110(%rbx)
movl $0x1, -0x30(%rbp)
cmpq $0x8000000, %rax        # imm = 0x8000000
ja 0x3ec5
movq %r14, %rdi
callq 0x2220
testl %eax, %eax
je 0x3e32
movq %r14, %rdi
callq 0x2110
cmpl $0x0, -0x30(%rbp)
movq -0x38(%rbp), %r12
jne 0x3977
jmp 0x396c