// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x1, %edi
movl $0x158, %esi            # imm = 0x158
callq 0x21f0
movq %rax, -0x18(%rbp)
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movb %cl, %dl
movb 0xe9(%rax), %cl
andb $0x1, %dl
andb $-0x2, %cl
orb %dl, %cl
movb %cl, 0xe9(%rax)
movq -0x18(%rbp), %rdi
callq 0x49f0
cmpq $0x0, -0x8(%rbp)
je 0x476c
movq -0x8(%rbp), %rdi
leaq 0x267c2(%rip), %rsi     # 0x2af1c
callq 0x4ba0
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x4782
movq -0x18(%rbp), %rdi
callq 0x2040
movq $0x0, -0x18(%rbp)
jmp 0x49da
movq -0x8(%rbp), %rdi
callq 0x2130
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x6, %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x21f0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0x1c(%rbp), %rdx
callq 0x2250
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
leaq 0x2677d(%rip), %rsi     # 0x2af45
callq 0x2090
movq -0x28(%rbp), %rdi
leaq 0x26744(%rip), %rsi     # 0x2af1c
callq 0x4ba0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
callq 0x4bd0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rdi
addq $0x138, %rdi            # imm = 0x138
callq 0x4bd0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0x4bd0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x4bd0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x100(%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x108(%rcx), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xa4(%rax)
movq -0x18(%rbp), %rax
movl 0xa4(%rax), %eax
movl %eax, %edi
callq 0x2280
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4926
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4926
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x4926
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x4926
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x4926
movq -0x18(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x4926
movq -0x8(%rbp), %rdi
callq 0x23a0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movb 0x74(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x74(%rax)
movq -0x18(%rbp), %rdi
callq 0x4c10
leaq 0x26614(%rip), %rdi     # 0x2af20
xorl %eax, %eax
movl %eax, %esi
callq 0x20d0
movq -0x18(%rbp), %rax
movsd %xmm0, 0xc0(%rax)
jmp 0x49d1
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x2110
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4953
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2110
movq -0x28(%rbp), %rdi
callq 0x2070
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rsi
addq $0x130, %rsi            # imm = 0x130
callq 0x4df0
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x18(%rbp), %rsi
addq $0x138, %rsi            # imm = 0x138
callq 0x4df0
movq -0x18(%rbp), %rdi
addq $0x20, %rdi
movq -0x18(%rbp), %rsi
addq $0x140, %rsi            # imm = 0x140
callq 0x4df0
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x18(%rbp), %rsi
addq $0x148, %rsi            # imm = 0x148
callq 0x4df0
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x2040
movq -0x18(%rbp), %rdi
callq 0x2040
movq $0x0, -0x18(%rbp)
movq -0x28(%rbp), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)