// File: /workspace/github_c_makefile_star2_O1/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 0x4bf2
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 0x4be1
cmpb $0x0, 0xea(%rbx)
jne 0x4be1
movb $0x1, 0xeb(%rbx)
movb 0xe9(%rbx), %al
testb $0x10, %al
je 0x3fe6
cmpq $0x0, 0x80(%rbx)
je 0x3fe6
cmpl $0x1, 0xa0(%rbx)
ja 0x3fe6
testb $0x2, 0x74(%rbx)
jne 0x3fe6
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 0x3fdd
orb $0x1, 0x12c(%rbx)
andb $-0x11, 0xe9(%rbx)
jmp 0x4007
movl %eax, %ecx
orb $0x4, %cl
movb %cl, 0xe9(%rbx)
testb $0x8, %al
jne 0x4007
testb $0x2, 0x74(%rbx)
jne 0x4bf3
movq %rbx, %rdi
callq 0x4e17
movq %rbx, %rdi
callq 0x5cdd
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x402c
callq 0x2050
movq $0x0, 0x50(%rbx)
movl $0x0, 0x58(%rbx)
leaq 0x10(%rbx), %r15
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 %r15, -0x48(%rbp)
je 0x4098
movq (%r15), %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 0x11298(%rip), %rdx     # 0x15321
movq %rax, %rdi
movl $0x7bf, %esi            # imm = 0x7BF
callq 0x5d26
jmp 0x409b
xorl %r12d, %r12d
testq %r12, %r12
je 0x4216
leaq -0x40(%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 0x40df
cmpq %r14, -0x40(%rbp)
jle 0x40e3
movq %r14, -0x40(%rbp)
movq (%rbx), %rdi
callq 0x20b0
movq %rax, -0x38(%rbp)
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rcx
movq -0x40(%rbp), %rax
addq $0x18, %rax
movl $0x8, %edx
movb %al, -0x8061(%rbp,%rdx)
shrq $0x8, %rax
decq %rdx
jne 0x410c
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 0x413e
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)
shrq $0x8, %rax
decq %r15
jne 0x4171
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
movq -0x40(%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 0x41d4
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 0x41fb
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x2280
movq %r13, %rdi
callq 0x2050
movq %r12, %rdi
movq %r14, %rsi
callq 0x22d0
cmpl $0x0, 0xd8(%rbx)
je 0x4380
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 0x5d3b
cmpl $0x0, 0xd8(%rbx)
je 0x42dc
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%rbx), %rsi
movq 0xc8(%rbx), %rax
movzbl 0x10(%rax), %edi
andl $0x1, %edi
callq 0x21c0
movq (%rbx), %rdi
movq 0xc8(%rbx), %rax
movq 0x8(%rax), %rsi
subq %r13, %rsi
callq 0x5d3b
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 0x427c
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r12
movq (%rbx), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x42ff
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
subq %r15, %r12
movl $0x8, %eax
movb %r12b, -0x8061(%rbp,%rax)
shrq $0x8, %r12
decq %rax
jne 0x430a
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
jns 0x4351
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 0x4378
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x2280
testb $0x1, 0xe9(%rbx)
movq -0x48(%rbp), %r12
je 0x4740
movq 0x60(%rbx), %rdi
callq 0x2130
leaq 0x6(%rax), %rdi
callq 0x2270
movq %rax, -0x50(%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 0x43f8
leaq -0x8060(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x2390
testb $0x4, 0x74(%rbx)
movq %r15, -0x58(%rbp)
jne 0x4508
movl $0x8000, %edi           # imm = 0x8000
callq 0x2270
movq %rax, %r13
movq (%rbx), %rdi
callq 0x2260
movl %eax, %edi
callq 0x2180
movl %eax, %r14d
movq (%rbx), %rdi
callq 0x2280
leaq 0x10ecb(%rip), %rsi     # 0x15326
movl %r14d, %edi
callq 0x2100
testq %rax, %rax
je 0x4578
movq %rax, %r12
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2320
testl %eax, %eax
jns 0x4487
orb $0x1, 0x12c(%rbx)
movq 0x38(%rbx), %r14
testq %r14, %r14
movq %r13, -0x38(%rbp)
movq %r12, -0x30(%rbp)
jle 0x44ec
xorl %r12d, %r12d
xorl %r15d, %r15d
movq -0x38(%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 -0x30(%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 0x44a2
movq -0x30(%rbp), %rdi
callq 0x2040
movl $0x6, %r15d
movq -0x48(%rbp), %r12
movq -0x38(%rbp), %rdi
jmp 0x463e
movq (%rbx), %rdi
callq 0x2280
movl 0x38(%rbx), %edi
callq 0xcce3
movslq %eax, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq 0x38(%rbx), %r14
testq %r14, %r14
je 0x458e
movq 0x8(%rbx), %rdi
movq %rcx, %r15
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 0x10dc4(%rip), %rdx     # 0x1532a
movq %rax, %rdi
movl $0x837, %esi            # imm = 0x837
callq 0x5d26
movq %r15, %rcx
jmp 0x4591
movl %r14d, %edi
callq 0x21b0
movl $0x6, %r15d
movq %r13, %rdi
jmp 0x463e
xorl %r14d, %r14d
movl 0x38(%rbx), %edx
movq %r14, %rdi
movq %rcx, %r13
movq %rcx, %rsi
callq 0x13cdf
movl %eax, %r15d
testq %r14, %r14
je 0x45b6
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x22d0
testb $0x2, 0xe9(%rbx)
movslq %r15d, %r14
jne 0x4622
cmpq $0x400001, 0x38(%rbx)   # imm = 0x400001
jl 0x4622
movl %r14d, %edi
callq 0xcce3
movslq %eax, %rdi
callq 0x2270
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x13cdf
movl %eax, -0x30(%rbp)
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x5d3b
movslq -0x30(%rbp), %rsi
movq (%rbx), %rcx
movl $0x1, %edx
movq %r15, %rdi
callq 0x2390
movq %r15, %rdi
callq 0x2050
movq %r13, %rdi
movl $0x7, %r15d
jmp 0x463e
movq (%rbx), %rcx
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0x2390
movq %r13, %rdi
movl $0x6, %r15d
movq %r12, %r13
callq 0x2050
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x4660
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 0x4687
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
subq %r12, %r14
movl $0x8, %eax
movb %r14b, -0x8061(%rbp,%rax)
shrq $0x8, %r14
decq %rax
jne 0x4692
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, %r12
jns 0x46dd
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), %r14
jns 0x4713
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rdi
callq 0x2280
movq 0x60(%rbx), %rdx
leaq 0x10c09(%rip), %rsi     # 0x1532f
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 0x475a
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 0x4769
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 0x479f
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 0x47e6
orb $0x1, 0x12c(%rbx)
movq (%rbx), %rcx
movl 0xb8(%rbx), %eax
movb %al, -0x8061(%rbp,%r14)
shrq $0x8, %rax
decq %r14
jne 0x47ef
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)
shrq $0x8, %rax
decq %r14
jne 0x4822
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)
shrq $0x8, %rax
decq %r14
jne 0x4855
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)
shrq $0x8, %rax
decq %r14
jne 0x488b
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 0x3ee0
movq 0x30(%rbx), %rdi
callq 0x2050
movq $0x0, 0x30(%rbx)
leaq 0x20(%rbx), %rdi
leaq 0x140(%rbx), %rsi
callq 0x3ee0
leaq 0x18(%rbx), %rdi
leaq 0x138(%rbx), %rsi
callq 0x3ee0
leaq 0x130(%rbx), %rsi
movq %r12, %rdi
callq 0x3ee0
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x4920
callq 0x2110
movq $0x0, 0x8(%rbx)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4bad
testb $0x2, 0xe9(%rbx)
jne 0x4946
callq 0x2110
movq $0x0, (%rbx)
jmp 0x4bad
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 0x109b1(%rip), %rsi     # 0x1533c
movq %r12, %rdi
callq 0x2330
testq %rax, %rax
je 0x4aeb
movq %rax, %r15
movq (%rbx), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x49b9
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 0x49fa
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 0x4a43
orb $0x1, 0x12c(%rbx)
movq %r15, %rdi
callq 0x2260
movl %eax, %edi
callq 0x2180
movl %eax, %r14d
leaq 0x108ca(%rip), %rsi     # 0x15326
movl %eax, %edi
callq 0x2100
testq %rax, %rax
je 0x4b06
movq %r15, -0x50(%rbp)
movq %r12, -0x48(%rbp)
testq %r13, %r13
movq %r13, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jle 0x4ad8
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 0x4a88
movq -0x30(%rbp), %rdi
callq 0x2040
movq -0x48(%rbp), %r12
movq -0x50(%rbp), %r15
jmp 0x4b0e
andb $-0x3, 0xe9(%rbx)
movq (%rbx), %rdi
callq 0x2110
movq $0x0, (%rbx)
jmp 0x4ba5
movl %r14d, %edi
callq 0x21b0
movq %r15, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2320
testl %eax, %eax
jns 0x4b28
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 0x4b4d
orb $0x1, 0x12c(%rbx)
decq %r14
movl $0x8, %eax
movb %r14b, -0x41(%rbp,%rax)
shrq $0x8, %r14
decq %rax
jne 0x4b55
leaq -0x40(%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 0x4bc8
leaq 0x120(%rbx), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x5da1
movq 0x60(%rbx), %rdi
callq 0x2050
movq $0x0, 0x60(%rbx)
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 0x23c0
jmp 0x3fff