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

#ifdef FST_WRITER_PARALLEL
if(xc)
        {
        pthread_mutex_lock(&xc->mutex);
        pthread_mutex_unlock(&xc->mutex);
        }
#endif

if(xc && !xc->already_in_close && !xc->already_in_flush)
        {
        unsigned char *tmem = NULL;
        off_t fixup_offs, tlen, hlen;

        xc->already_in_close = 1; /* never need to zero this out as it is freed at bottom */

        if(xc->section_header_only && xc->section_header_truncpos && (xc->vchg_siz <= 1) && (!xc->is_initial_time))
                {
                fstFtruncate(fileno(xc->handle), xc->section_header_truncpos);
                fstWriterFseeko(xc, xc->handle, xc->section_header_truncpos, SEEK_SET);
                xc->section_header_only = 0;
                }
                else
                {
                xc->skip_writing_section_hdr = 1;
                if(!xc->size_limit_locked)
                        {
                        if(FST_UNLIKELY(xc->is_initial_time)) /* simulation time never advanced so mock up the changes as time zero ones */
                                {
                                fstHandle dupe_idx;

                                fstWriterEmitTimeChange(xc, 0); /* emit some time change just to have one */
                                for(dupe_idx = 0; dupe_idx < xc->maxhandle; dupe_idx++) /* now clone the values */
                                        {
                                        fstWriterEmitValueChange(xc, dupe_idx+1, xc->curval_mem + xc->valpos_mem[4*dupe_idx]);
                                        }
                                }
                        fstWriterFlushContextPrivate(xc);
#ifdef FST_WRITER_PARALLEL
                        pthread_mutex_lock(&xc->mutex);
                        pthread_mutex_unlock(&xc->mutex);

			while (xc->in_pthread) 
				{ 
				pthread_mutex_lock(&xc->mutex); 
				pthread_mutex_unlock(&xc->mutex); 
				};
#endif
                        }
                }
        fstDestroyMmaps(xc, 1);
	if(xc->outval_mem)
		{
		free(xc->outval_mem); xc->outval_mem = NULL;
		xc->outval_alloc_siz = 0;
		}

        /* write out geom section */
        fflush(xc->geom_handle);
        tlen = ftello(xc->geom_handle);
	errno = 0;
	if(tlen)
		{
	        fstWriterMmapSanity(tmem = (unsigned char *)fstMmap(NULL, tlen, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->geom_handle), 0), __FILE__, __LINE__, "tmem");
		}

        if(tmem)
                {
                unsigned long destlen = tlen;
                unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen));
                int rc = compress2(dmem, &destlen, tmem, tlen, 9);

                if((rc != Z_OK) || (((off_t)destlen) > tlen))
                        {
                        destlen = tlen;
                        }

                fixup_offs = ftello(xc->handle);
                fputc(FST_BL_SKIP, xc->handle);                 /* temporary tag */
                fstWriterUint64(xc->handle, destlen + 24);      /* section length */
                fstWriterUint64(xc->handle, tlen);              /* uncompressed */
                                                                /* compressed len is section length - 24 */
                fstWriterUint64(xc->handle, xc->maxhandle);     /* maxhandle */
                fstFwrite((((off_t)destlen) != tlen) ? dmem : tmem, destlen, 1, xc->handle);
                fflush(xc->handle);

                fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET);
                fputc(FST_BL_GEOM, xc->handle);                 /* actual tag */

                fstWriterFseeko(xc, xc->handle, 0, SEEK_END);           /* move file pointer to end for any section adds */
                fflush(xc->handle);

                free(dmem);
                fstMunmap(tmem, tlen);
                }

        if(xc->num_blackouts)
                {
                uint64_t cur_bl = 0;
                off_t bpos, eos;
                uint32_t i;

                fixup_offs = ftello(xc->handle);
                fputc(FST_BL_SKIP, xc->handle);                 /* temporary tag */
                bpos = fixup_offs + 1;
                fstWriterUint64(xc->handle, 0);                 /* section length */
                fstWriterVarint(xc->handle, xc->num_blackouts);

                for(i=0;i<xc->num_blackouts;i++)
                        {
                        fputc(xc->blackout_head->active, xc->handle);
                        fstWriterVarint(xc->handle, xc->blackout_head->tim - cur_bl);
                        cur_bl = xc->blackout_head->tim;
                        xc->blackout_curr = xc->blackout_head->next;
                        free(xc->blackout_head);
                        xc->blackout_head = xc->blackout_curr;
                        }

                eos = ftello(xc->handle);
                fstWriterFseeko(xc, xc->handle, bpos, SEEK_SET);
                fstWriterUint64(xc->handle, eos - bpos);
                fflush(xc->handle);

                fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET);
                fputc(FST_BL_BLACKOUT, xc->handle);     /* actual tag */

                fstWriterFseeko(xc, xc->handle, 0, SEEK_END);   /* move file pointer to end for any section adds */
                fflush(xc->handle);
                }

        if(xc->compress_hier)
                {
                off_t hl, eos;
                gzFile zhandle;
                int zfd;
                int fourpack_duo = 0;
#ifndef __MINGW32__
                char *fnam = (char *)malloc(strlen(xc->filename) + 5 + 1);
#endif

                fixup_offs = ftello(xc->handle);
                fputc(FST_BL_SKIP, xc->handle);                 /* temporary tag */
                hlen = ftello(xc->handle);
                fstWriterUint64(xc->handle, 0);                 /* section length */
                fstWriterUint64(xc->handle, xc->hier_file_len); /* uncompressed length */

                if(!xc->fourpack)
                        {
                        unsigned char *mem = (unsigned char *)malloc(FST_GZIO_LEN);
                        zfd = dup(fileno(xc->handle));
                        fflush(xc->handle);
                        zhandle = gzdopen(zfd, "wb4");
                        if(zhandle)
                                {
                                fstWriterFseeko(xc, xc->hier_handle, 0, SEEK_SET);
                                for(hl = 0; hl < xc->hier_file_len; hl += FST_GZIO_LEN)
                                        {
                                        unsigned len = ((xc->hier_file_len - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (xc->hier_file_len - hl);
                                        fstFread(mem, len, 1, xc->hier_handle);
                                        gzwrite(zhandle, mem, len);
                                        }
                                gzclose(zhandle);
                                }
                                else
                                {
                                close(zfd);
                                }
                        free(mem);
                        }
                        else
                        {
                        int lz4_maxlen;
                        unsigned char *mem;
                        unsigned char *hmem = NULL;
                        int packed_len;

                        fflush(xc->handle);

                        lz4_maxlen = LZ4_compressBound(xc->hier_file_len);
                        mem = (unsigned char *)malloc(lz4_maxlen);
			errno = 0;
			if(xc->hier_file_len)
				{
	                        fstWriterMmapSanity(hmem = (unsigned char *)fstMmap(NULL, xc->hier_file_len, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->hier_handle), 0), __FILE__, __LINE__, "hmem");
				}
                        packed_len = LZ4_compress((char *)hmem, (char *)mem, xc->hier_file_len);
                        fstMunmap(hmem, xc->hier_file_len);

                        fourpack_duo = (!xc->repack_on_close) && (xc->hier_file_len > FST_HDR_FOURPACK_DUO_SIZE); /* double pack when hierarchy is large */

                        if(fourpack_duo)        /* double packing with LZ4 is faster than gzip */
                                {
                                unsigned char *mem_duo;
                                int lz4_maxlen_duo;
                                int packed_len_duo;

                                lz4_maxlen_duo = LZ4_compressBound(packed_len);
                                mem_duo = (unsigned char *)malloc(lz4_maxlen_duo);
                                packed_len_duo = LZ4_compress((char *)mem, (char *)mem_duo, packed_len);

                                fstWriterVarint(xc->handle, packed_len); /* 1st round compressed length */
                                fstFwrite(mem_duo, packed_len_duo, 1, xc->handle);
                                free(mem_duo);
                                }
                                else
                                {
                                fstFwrite(mem, packed_len, 1, xc->handle);
                                }

                        free(mem);
                        }

                fstWriterFseeko(xc, xc->handle, 0, SEEK_END);
                eos = ftello(xc->handle);
                fstWriterFseeko(xc, xc->handle, hlen, SEEK_SET);
                fstWriterUint64(xc->handle, eos - hlen);
                fflush(xc->handle);

                fstWriterFseeko(xc, xc->handle, fixup_offs, SEEK_SET);
                fputc(xc->fourpack ?
                        ( fourpack_duo ? FST_BL_HIER_LZ4DUO : FST_BL_HIER_LZ4) :
                        FST_BL_HIER, xc->handle); /* actual tag now also == compression type */

                fstWriterFseeko(xc, xc->handle, 0, SEEK_END);   /* move file pointer to end for any section adds */
                fflush(xc->handle);

#ifndef __MINGW32__
                sprintf(fnam, "%s.hier", xc->filename);
                unlink(fnam);
                free(fnam);
#endif
                }

        /* finalize out header */
        fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_START_TIME, SEEK_SET);
        fstWriterUint64(xc->handle, xc->firsttime);
        fstWriterUint64(xc->handle, xc->curtime);
        fstWriterFseeko(xc, xc->handle, FST_HDR_OFFS_NUM_SCOPES, SEEK_SET);
        fstWriterUint64(xc->handle, xc->numscopes);
        fstWriterUint64(xc->handle, xc->numsigs);
        fstWriterUint64(xc->handle, xc->maxhandle);
        fstWriterUint64(xc->handle, xc->secnum);
        fflush(xc->handle);

        tmpfile_close(&xc->tchn_handle, &xc->tchn_handle_nam);
        free(xc->vchg_mem); xc->vchg_mem = NULL;
        tmpfile_close(&xc->curval_handle, &xc->curval_handle_nam);
        tmpfile_close(&xc->valpos_handle, &xc->valpos_handle_nam);
        tmpfile_close(&xc->geom_handle, &xc->geom_handle_nam);
        if(xc->hier_handle) { fclose(xc->hier_handle); xc->hier_handle = NULL; }
        if(xc->handle)
                {
                if(xc->repack_on_close)
                        {
                        FILE *fp;
                        off_t offpnt, uclen;
                        int flen = strlen(xc->filename);
                        char *hf = (char *)calloc(1, flen + 5);

                        strcpy(hf, xc->filename);
                        strcpy(hf+flen, ".pak");
                        fp = fopen(hf, "wb");

                        if(fp)
                                {
                                gzFile dsth;
                                int zfd;
                                char gz_membuf[FST_GZIO_LEN];

                                fstWriterFseeko(xc, xc->handle, 0, SEEK_END);
                                uclen = ftello(xc->handle);

                                fputc(FST_BL_ZWRAPPER, fp);
                                fstWriterUint64(fp, 0);
                                fstWriterUint64(fp, uclen);
                                fflush(fp);

                                fstWriterFseeko(xc, xc->handle, 0, SEEK_SET);
                                zfd = dup(fileno(fp));
                                dsth = gzdopen(zfd, "wb4");
                                if(dsth)
                                        {
                                        for(offpnt = 0; offpnt < uclen; offpnt += FST_GZIO_LEN)
                                                {
                                                size_t this_len = ((uclen - offpnt) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - offpnt);
                                                fstFread(gz_membuf, this_len, 1, xc->handle);
                                                gzwrite(dsth, gz_membuf, this_len);
                                                }
                                        gzclose(dsth);
                                        }
                                        else
                                        {
                                        close(zfd);
                                        }
                                fstWriterFseeko(xc, fp, 0, SEEK_END);
                                offpnt = ftello(fp);
                                fstWriterFseeko(xc, fp, 1, SEEK_SET);
                                fstWriterUint64(fp, offpnt - 1);
                                fclose(fp);
                                fclose(xc->handle); xc->handle = NULL;

                                unlink(xc->filename);
                                rename(hf, xc->filename);
                                }
                                else
                                {
                                xc->repack_on_close = 0;
                                fclose(xc->handle); xc->handle = NULL;
                                }

                        free(hf);
                        }
                        else
                        {
                        fclose(xc->handle); xc->handle = NULL;
                        }
                }

#ifdef __MINGW32__
        {
        int flen = strlen(xc->filename);
        char *hf = (char *)calloc(1, flen + 6);
        strcpy(hf, xc->filename);

        if(xc->compress_hier)
                {
                strcpy(hf + flen, ".hier");
                unlink(hf); /* no longer needed as a section now exists for this */
                }

        free(hf);
        }
#endif

#ifdef FST_WRITER_PARALLEL
        pthread_mutex_destroy(&xc->mutex);
        pthread_attr_destroy(&xc->thread_attr);
#endif

        if(xc->path_array)
                {
#ifndef _WAVE_HAVE_JUDY
                const uint32_t hashmask = FST_PATH_HASHMASK;
#endif
                JudyHSFreeArray(&(xc->path_array), NULL);
                }

        free(xc->filename); xc->filename = NULL;
        free(xc);
        }
}

// Assembly:
testq %rdi, %rdi
je 0x65a1
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8038, %rsp           # imm = 0x8038
movq %rdi, %rbx
cmpb $0x0, 0xeb(%rdi)
jne 0x6590
cmpb $0x0, 0xea(%rbx)
jne 0x6590
movb $0x1, 0xeb(%rbx)
movb 0xe9(%rbx), %al
testb $0x10, %al
je 0x599a
cmpq $0x0, 0x80(%rbx)
je 0x599a
cmpl $0x1, 0xa0(%rbx)
ja 0x599a
testb $0x2, 0x74(%rbx)
jne 0x599a
movq (%rbx), %rdi
callq 0x2260
movq 0x80(%rbx), %rsi
movl %eax, %edi
callq 0x2170
movq (%rbx), %rdi
movq 0x80(%rbx), %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x5991
orb $0x1, 0x12c(%rbx)
andb $-0x11, 0xe9(%rbx)
jmp 0x59bb
movl %eax, %ecx
orb $0x4, %cl
movb %cl, 0xe9(%rbx)
testb $0x8, %al
jne 0x59bb
testb $0x2, 0x74(%rbx)
jne 0x65a2
movq %rbx, %rdi
callq 0x67e0
movq %rbx, %rdi
callq 0x76df
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x59e0
callq 0x2050
movq $0x0, 0x50(%rbx)
movl $0x0, 0x58(%rbx)
leaq 0x10(%rbx), %r13
movq 0x10(%rbx), %rdi
callq 0x2280
movq 0x10(%rbx), %rdi
callq 0x20b0
movq %rax, %r14
callq 0x2070
movq %rax, -0x30(%rbp)
movl $0x0, (%rax)
testq %r14, %r14
movq %r13, -0x50(%rbp)
je 0x5bcd
movq (%r13), %rdi
callq 0x2260
xorl %edi, %edi
movq %r14, %rsi
movl $0x3, %edx
movl $0x1, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x2140
movq %rax, %r12
leaq 0xe8df(%rip), %rdx      # 0x14321
movq %rax, %rdi
movl $0x7bf, %esi            # imm = 0x7BF
callq 0x7728
testq %r12, %r12
je 0x5bcd
leaq -0x48(%rbp), %r15
movq %r14, (%r15)
movq %r14, %rdi
callq 0x2290
movq %rax, %rdi
callq 0x2270
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
movl $0x9, %r8d
callq 0x2300
testl %eax, %eax
jne 0x5a93
cmpq %r14, -0x48(%rbp)
jle 0x5a97
movq %r14, -0x48(%rbp)
movq (%rbx), %rdi
callq 0x20b0
movq %rax, -0x38(%rbp)
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rcx
movq -0x48(%rbp), %rax
addq $0x18, %rax
movl $0x8, %edx
movb %al, -0x8061(%rbp,%rdx)
shrq $0x8, %rax
decq %rdx
jne 0x5ac0
leaq -0x8060(%rbp), %rdi
movl $0x8, %r15d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movq %r14, %rax
movb %al, -0x8061(%rbp,%r15)
shrq $0x8, %rax
decq %r15
jne 0x5af2
leaq -0x8060(%rbp), %rdi
movl $0x8, %r15d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movl 0x68(%rbx), %eax
movb %al, -0x8061(%rbp,%r15)
shrl $0x8, %eax
decq %r15
jne 0x5b25
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq -0x48(%rbp), %rsi
cmpq %r14, %rsi
movq %r13, %rdi
cmoveq %r12, %rdi
movq (%rbx), %rcx
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
callq 0x2280
movq (%rbx), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x5b87
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rsi
movl $0x3, %edi
callq 0x21c0
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x5bae
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x2280
movq %r13, %rdi
callq 0x2050
movq %r12, %rdi
movq %r14, %rsi
callq 0x22d0
movq -0x50(%rbp), %r13
cmpl $0x0, 0xd8(%rbx)
je 0x5d3b
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r14
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rcx
leaq -0x8060(%rbp), %rdi
movq $0x0, (%rdi)
leaq 0x1(%r14), %r15
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
movl 0xd8(%rbx), %esi
callq 0x773d
cmpl $0x0, 0xd8(%rbx)
je 0x5c93
movq 0xc8(%rbx), %rax
xorl %r13d, %r13d
xorl %r12d, %r12d
movzbl 0x10(%rax), %edi
andl $0x1, %edi
movq (%rbx), %rsi
callq 0x21c0
movq (%rbx), %rdi
movq 0xc8(%rbx), %rax
movq 0x8(%rax), %rsi
subq %r13, %rsi
callq 0x773d
movq 0xc8(%rbx), %rdi
movq (%rdi), %rax
movq 0x8(%rdi), %r13
movq %rax, 0xd0(%rbx)
callq 0x2050
movq 0xd0(%rbx), %rax
movq %rax, 0xc8(%rbx)
incl %r12d
cmpl 0xd8(%rbx), %r12d
jb 0x5c3a
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r12
movq (%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x5cb6
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
subq %r15, %r12
movl $0x8, %eax
movb %r12b, -0x8061(%rbp,%rax)
shrq $0x8, %r12
decq %rax
jne 0x5cc1
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
callq 0x2280
movq (%rbx), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
movq -0x50(%rbp), %r13
jns 0x5d0c
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rsi
movl $0x2, %edi
callq 0x21c0
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x5d33
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x2280
testb $0x1, 0xe9(%rbx)
je 0x60fb
movq 0x60(%rbx), %rdi
callq 0x2130
leaq 0x6(%rax), %rdi
callq 0x2270
movq %rax, -0x40(%rbp)
movq (%rbx), %rdi
callq 0x20b0
movq %rax, -0x60(%rbp)
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r15
movq (%rbx), %rcx
leaq -0x8060(%rbp), %rdi
movq $0x0, (%rdi)
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movq 0x38(%rbx), %rax
movb %al, -0x8061(%rbp,%r14)
shrq $0x8, %rax
decq %r14
jne 0x5daf
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
testb $0x4, 0x74(%rbx)
movq %r15, -0x58(%rbp)
jne 0x5ebc
movl $0x8000, %edi           # imm = 0x8000
callq 0x2270
movq %rax, -0x30(%rbp)
movq (%rbx), %rdi
callq 0x2260
movl %eax, %edi
callq 0x2180
movl %eax, %r14d
movq (%rbx), %rdi
callq 0x2280
leaq 0xe513(%rip), %rsi      # 0x14326
movl %r14d, %edi
callq 0x2100
testq %rax, %rax
je 0x5f4b
movq %rax, %r12
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x5e3f
orb $0x1, 0x12c(%rbx)
movq 0x38(%rbx), %r14
testq %r14, %r14
movq %r12, -0x38(%rbp)
jle 0x5ea0
xorl %r12d, %r12d
xorl %r15d, %r15d
movq -0x30(%rbp), %r13
addq %r12, %r14
movl $0x8000, %eax           # imm = 0x8000
cmpq %rax, %r14
cmovgeq %rax, %r14
movl %r14d, %esi
movq 0x8(%rbx), %rcx
movl $0x1, %edx
movq %r13, %rdi
callq 0x20c0
movq -0x38(%rbp), %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x22b0
movl $0x8000, %eax           # imm = 0x8000
addq %rax, %r15
movq 0x38(%rbx), %r14
addq $-0x8000, %r12          # imm = 0x8000
cmpq %r14, %r15
jl 0x5e56
movq -0x38(%rbp), %rdi
callq 0x2040
movl $0x6, %r15d
movq -0x40(%rbp), %r13
movq -0x30(%rbp), %r12
jmp 0x5ff9
movq (%rbx), %rdi
callq 0x2280
movl 0x38(%rbx), %edi
callq 0xe5a3
movslq %eax, %rdi
callq 0x2270
movq %rax, %r15
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq 0x38(%rbx), %r14
testq %r14, %r14
je 0x5f62
movq 0x8(%rbx), %rdi
callq 0x2260
xorl %edi, %edi
movq %r14, %rsi
movl $0x3, %edx
movl $0x1, %ecx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x2140
movq %rax, %r14
leaq 0xe413(%rip), %rdx      # 0x1432a
movq %rax, %rdi
movl $0x837, %esi            # imm = 0x837
callq 0x7728
movl 0x38(%rbx), %edx
movq %r14, %rdi
movq %r15, %r12
movq %r15, %rsi
callq 0x45d1
movl %eax, %r15d
testq %r14, %r14
je 0x5f74
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x22d0
jmp 0x5f74
movl %r14d, %edi
callq 0x21b0
movl $0x6, %r15d
movq -0x30(%rbp), %r12
jmp 0x5ff5
xorl %edi, %edi
movq %r15, %r12
movq %r15, %rsi
xorl %edx, %edx
callq 0x45d1
movl %eax, %r15d
testb $0x2, 0xe9(%rbx)
movslq %r15d, %r14
jne 0x5fdc
cmpq $0x400001, 0x38(%rbx)   # imm = 0x400001
jl 0x5fdc
movl %r14d, %edi
callq 0xe5a3
movslq %eax, %rdi
callq 0x2270
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x45d1
movl %eax, %r13d
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x773d
movslq %r13d, %rsi
movq (%rbx), %rcx
movl $0x1, %edx
movq %r15, %rdi
callq 0x2390
movq %r15, %rdi
callq 0x2050
movl $0x7, %r15d
jmp 0x5ff5
movq (%rbx), %rcx
movl $0x1, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x2390
movl $0x6, %r15d
movq -0x40(%rbp), %r13
movq %r12, %rdi
callq 0x2050
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x601b
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r14
movq (%rbx), %rdi
movq -0x58(%rbp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x6042
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
subq %r12, %r14
movl $0x8, %eax
movb %r14b, -0x8061(%rbp,%rax)
shrq $0x8, %r14
decq %rax
jne 0x604d
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
callq 0x2280
movq (%rbx), %rdi
movq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
movq %r13, %r14
jns 0x6098
orb $0x1, 0x12c(%rbx)
testb $0x4, 0x74(%rbx)
movl $0x4, %eax
cmovel %eax, %r15d
movq (%rbx), %rsi
movl %r15d, %edi
callq 0x21c0
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
movq -0x50(%rbp), %r13
jns 0x60ce
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x2280
movq 0x60(%rbx), %rdx
leaq 0xe24e(%rip), %rsi      # 0x1432f
movq %r14, %rdi
xorl %eax, %eax
callq 0x2370
movq %r14, %rdi
callq 0x2080
movq %r14, %rdi
callq 0x2050
movq (%rbx), %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x6115
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
movq 0x98(%rbx), %rax
movl $0x8, %edx
movb %al, -0x8061(%rbp,%rdx)
shrq $0x8, %rax
decq %rdx
jne 0x6124
leaq -0x8060(%rbp), %rdi
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movq 0x90(%rbx), %rax
movb %al, -0x8061(%rbp,%r14)
shrq $0x8, %rax
decq %r14
jne 0x615a
leaq -0x8060(%rbp), %rdi
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
movl $0x29, %esi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x61a1
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
movl 0xb8(%rbx), %eax
movb %al, -0x8061(%rbp,%r14)
shrl $0x8, %eax
decq %r14
jne 0x61aa
leaq -0x8060(%rbp), %rdi
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movl 0x6c(%rbx), %eax
movb %al, -0x8061(%rbp,%r14)
shrl $0x8, %eax
decq %r14
jne 0x61dc
leaq -0x8060(%rbp), %rdi
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movl 0x68(%rbx), %eax
movb %al, -0x8061(%rbp,%r14)
shrl $0x8, %eax
decq %r14
jne 0x620e
leaq -0x8060(%rbp), %rdi
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rcx
movl 0xa8(%rbx), %eax
movb %al, -0x8061(%rbp,%r14)
shrl $0x8, %eax
decq %r14
jne 0x6243
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
callq 0x2280
leaq 0x28(%rbx), %rdi
leaq 0x148(%rbx), %rsi
callq 0x5894
movq 0x30(%rbx), %rdi
callq 0x2050
movq $0x0, 0x30(%rbx)
leaq 0x20(%rbx), %rdi
leaq 0x140(%rbx), %rsi
callq 0x5894
leaq 0x18(%rbx), %rdi
leaq 0x138(%rbx), %rsi
callq 0x5894
leaq 0x130(%rbx), %rsi
movq %r13, %rdi
callq 0x5894
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x62d7
callq 0x2110
movq $0x0, 0x8(%rbx)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x6564
testb $0x2, 0xe9(%rbx)
jne 0x62fd
callq 0x2110
movq $0x0, (%rbx)
jmp 0x6564
movq 0x60(%rbx), %r14
movq %r14, %rdi
callq 0x2130
movq %rax, %r15
addl $0x5, %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x21e0
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x20a0
movslq %r15d, %rax
movl $0x6b61702e, (%r12,%rax) # imm = 0x6B61702E
movb $0x0, 0x4(%r12,%rax)
leaq 0xdffa(%rip), %rsi      # 0x1433c
movq %r12, %rdi
callq 0x2330
testq %rax, %rax
je 0x64a2
movq %rax, %r15
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x6370
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r13
movl $0xfe, %edi
movq %r15, %rsi
callq 0x21c0
leaq -0x8060(%rbp), %rdi
movq $0x0, (%rdi)
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2390
movq %r13, %rax
movb %al, -0x8061(%rbp,%r14)
shrq $0x8, %rax
decq %r14
jne 0x63b1
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2390
movq %r15, %rdi
callq 0x2280
movq (%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x63fa
orb $0x1, 0x12c(%rbx)
movq %r15, %rdi
callq 0x2260
movl %eax, %edi
callq 0x2180
movl %eax, %r14d
leaq 0xdf13(%rip), %rsi      # 0x14326
movl %eax, %edi
callq 0x2100
testq %rax, %rax
je 0x64bd
movq %r15, -0x40(%rbp)
movq %r12, -0x50(%rbp)
testq %r13, %r13
movq %r13, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jle 0x648f
xorl %r12d, %r12d
movq -0x38(%rbp), %r13
movl $0x8000, %eax           # imm = 0x8000
cmpq %rax, %r13
movl $0x8000, %r15d          # imm = 0x8000
cmovlq %r13, %r15
movq (%rbx), %rcx
movl $0x1, %edx
leaq -0x8060(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x20c0
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x22b0
movl $0x8000, %eax           # imm = 0x8000
addq %rax, %r12
addq $-0x8000, %r13          # imm = 0x8000
cmpq -0x38(%rbp), %r12
jl 0x643f
movq -0x30(%rbp), %rdi
callq 0x2040
movq -0x50(%rbp), %r12
movq -0x40(%rbp), %r15
jmp 0x64c5
andb $-0x3, 0xe9(%rbx)
movq (%rbx), %rdi
callq 0x2110
movq $0x0, (%rbx)
jmp 0x655c
movl %r14d, %edi
callq 0x21b0
movq %r15, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x64df
orb $0x1, 0x12c(%rbx)
movq %r15, %rdi
callq 0x20b0
movq %rax, %r14
movl $0x1, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x6504
orb $0x1, 0x12c(%rbx)
decq %r14
movl $0x8, %eax
movb %r14b, -0x49(%rbp,%rax)
shrq $0x8, %r14
decq %rax
jne 0x650c
leaq -0x48(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2390
movq %r15, %rdi
callq 0x2110
movq (%rbx), %rdi
callq 0x2110
movq $0x0, (%rbx)
movq 0x60(%rbx), %rdi
callq 0x2080
movq 0x60(%rbx), %rsi
movq %r12, %rdi
callq 0x2350
movq %r12, %rdi
callq 0x2050
cmpq $0x0, 0x120(%rbx)
je 0x657f
leaq 0x120(%rbx), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x77a3
movq 0x60(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
addq $0x8038, %rsp           # imm = 0x8038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x2830
jmp 0x59b3