// File: /workspace/github_c_makefile_star2_O2/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 0x41da
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 0x41c9
cmpb $0x0, 0xea(%rbx)
jne 0x41c9
movb $0x1, 0xeb(%rbx)
movb 0xe9(%rbx), %al
testb $0x10, %al
je 0x3909
cmpq $0x0, 0x80(%rbx)
je 0x3909
cmpl $0x1, 0xa0(%rbx)
ja 0x3909
testb $0x2, 0x74(%rbx)
jne 0x3909
movq (%rbx), %rdi
callq 0x2260
movq 0x80(%rbx), %rsi
movl %eax, %edi
callq 0x2170
movq (%rbx), %rsi
movq 0x80(%rbx), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x421c
andb $-0x11, 0xe9(%rbx)
jmp 0x392a
movl %eax, %ecx
orb $0x4, %cl
movb %cl, 0xe9(%rbx)
testb $0x8, %al
jne 0x392a
testb $0x2, 0x74(%rbx)
jne 0x41db
movq %rbx, %rdi
callq 0x44e8
movq %rbx, %rdi
callq 0x4f8c
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x3949
callq 0x2050
andq $0x0, 0x50(%rbx)
andl $0x0, 0x58(%rbx)
leaq 0x10(%rbx), %r12
movq 0x10(%rbx), %rdi
callq 0x2280
movq 0x10(%rbx), %rdi
callq 0x20b0
movq %rax, %r15
callq 0x2070
movq %rax, -0x38(%rbp)
andl $0x0, (%rax)
testq %r15, %r15
je 0x3ab0
movq (%r12), %rdi
callq 0x2260
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
xorl %edi, %edi
movq %r15, %rsi
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x2140
movq %rax, %r13
leaq 0xe981(%rip), %rdx      # 0x12321
movq %rax, %rdi
movl $0x7bf, %esi            # imm = 0x7BF
callq 0x4fcf
testq %r13, %r13
je 0x3ab0
movq %r12, -0x48(%rbp)
leaq -0x8060(%rbp), %r12
movq %r15, (%r12)
movq %r15, %rdi
callq 0x2290
movq %rax, %rdi
callq 0x2270
movq %rax, %r14
pushq $0x9
popq %r8
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2300
testl %eax, %eax
jne 0x39fa
cmpq %r15, -0x8060(%rbp)
jle 0x3a01
movq %r15, -0x8060(%rbp)
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r12
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rdi
movq -0x8060(%rbp), %rsi
addq $0x18, %rsi
callq 0x502a
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x502a
movq (%rbx), %rdi
movl 0x68(%rbx), %esi
callq 0x502a
movq -0x8060(%rbp), %rsi
cmpq %r15, %rsi
movq %r14, %rdi
cmoveq %r13, %rdi
movq (%rbx), %rcx
pushq $0x1
popq %rdx
callq 0x2390
movq (%rbx), %rdi
callq 0x2280
movq (%rbx), %rsi
movq %rbx, %rdi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x421c
movq (%rbx), %rsi
pushq $0x3
popq %rdi
callq 0x21c0
movq (%rbx), %rsi
pushq $0x2
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x421c
movq (%rbx), %rdi
callq 0x2280
movq %r14, %rdi
callq 0x2050
movq %r13, %rdi
movq %r15, %rsi
callq 0x22d0
movq -0x48(%rbp), %r12
cmpl $0x0, 0xd8(%rbx)
je 0x3bc9
movq %r12, %r13
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r14
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x502a
movq (%rbx), %rdi
movl 0xd8(%rbx), %esi
callq 0x5060
xorl %r12d, %r12d
cmpl 0xd8(%rbx), %r15d
jae 0x3b58
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 %r12, %rsi
callq 0x5060
movq 0xc8(%rbx), %rdi
movq (%rdi), %rax
movq 0x8(%rdi), %r12
movq %rax, 0xd0(%rbx)
callq 0x2050
movq 0xd0(%rbx), %rax
movq %rax, 0xc8(%rbx)
incl %r15d
jmp 0x3af6
movq %r14, %r15
incq %r15
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r12
movq (%rbx), %rsi
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x421c
movq (%rbx), %rdi
subq %r15, %r12
movq %r12, %rsi
callq 0x502a
movq (%rbx), %rdi
callq 0x2280
movq (%rbx), %rsi
movq %rbx, %rdi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x421c
movq (%rbx), %rsi
pushq $0x2
popq %r14
movl %r14d, %edi
callq 0x21c0
movq (%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl %r14d, %ecx
callq 0x421c
movq (%rbx), %rdi
callq 0x2280
movq %r13, %r12
testb $0x1, 0xe9(%rbx)
je 0x3ed2
movq 0x60(%rbx), %rdi
callq 0x2130
leaq 0x6(%rax), %rdi
callq 0x2270
movq %rax, %r15
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r13
movq (%rbx), %rsi
movl $0xff, %edi
callq 0x21c0
movq (%rbx), %rdi
callq 0x20b0
movq %rax, -0x50(%rbp)
movq (%rbx), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x502a
movq (%rbx), %rdi
movq 0x38(%rbx), %rsi
callq 0x502a
testb $0x4, 0x74(%rbx)
movq %r15, -0x60(%rbp)
movq %r13, -0x58(%rbp)
jne 0x3cee
movl $0x8000, %edi           # imm = 0x8000
callq 0x2270
movq %rax, -0x30(%rbp)
movq (%rbx), %rdi
callq 0x2260
movl %eax, %edi
callq 0x2180
movl %eax, %r15d
movq (%rbx), %rdi
callq 0x2280
leaq 0xe6bd(%rip), %rsi      # 0x12326
movl %r15d, %edi
callq 0x2100
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x3d69
movq %r12, -0x48(%rbp)
movq 0x8(%rbx), %rsi
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x421c
xorl %r14d, %r14d
movq -0x30(%rbp), %r13
movq 0x38(%rbx), %r15
cmpq %r15, %r14
jge 0x3d56
addq %r12, %r15
movq %r12, -0x38(%rbp)
movl $0x8000, %r12d          # imm = 0x8000
cmpq %r12, %r15
cmovgeq %r12, %r15
movl %r15d, %esi
movq 0x8(%rbx), %rcx
movq %r13, %rdi
pushq $0x1
popq %rdx
callq 0x20c0
movq -0x40(%rbp), %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x22b0
addq %r12, %r14
movq -0x38(%rbp), %r12
addq $-0x8000, %r12          # imm = 0x8000
jmp 0x3c9c
movq (%rbx), %rdi
callq 0x2280
movl 0x38(%rbx), %edi
callq 0xb56f
movslq %eax, %rdi
callq 0x2270
movq -0x38(%rbp), %rcx
andl $0x0, (%rcx)
movq %rax, -0x30(%rbp)
movq 0x38(%rbx), %r15
testq %r15, %r15
je 0x3d7e
movq 0x8(%rbx), %rdi
callq 0x2260
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
xorl %edi, %edi
movq %r15, %rsi
movl %eax, %r8d
xorl %r9d, %r9d
callq 0x2140
movq %rax, %r13
leaq 0xe5e7(%rip), %rdx      # 0x1232a
movq %rax, %rdi
movl $0x837, %esi            # imm = 0x837
callq 0x4fcf
movl 0x38(%rbx), %r14d
jmp 0x3d81
movq -0x40(%rbp), %rdi
callq 0x2040
pushq $0x6
popq %r13
movq -0x48(%rbp), %r12
jmp 0x3d75
movl %r15d, %edi
callq 0x21b0
pushq $0x6
popq %r13
movq -0x30(%rbp), %r15
jmp 0x3e20
xorl %r13d, %r13d
movq %r13, %rdi
movq -0x30(%rbp), %r15
movq %r15, %rsi
movl %r14d, %edx
callq 0x10bb4
movl %eax, %r14d
testq %r13, %r13
je 0x3da7
movq 0x38(%rbx), %rsi
movq %r13, %rdi
callq 0x22d0
testb $0x2, 0xe9(%rbx)
jne 0x3e0b
cmpq $0x400001, 0x38(%rbx)   # imm = 0x400001
jl 0x3e0b
movl %r14d, %edi
callq 0xb56f
movslq %eax, %rdi
callq 0x2270
movq %rax, %r15
movq -0x30(%rbp), %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x10bb4
movl %eax, %r13d
movq (%rbx), %rdi
movslq %r14d, %rsi
callq 0x5060
movslq %r13d, %rsi
movq (%rbx), %rcx
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x2390
movq %r15, %rdi
movq -0x30(%rbp), %r15
callq 0x2050
pushq $0x7
jmp 0x3e1e
movslq %r14d, %rsi
movq (%rbx), %rcx
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x2390
pushq $0x6
popq %r13
movq %r15, %rdi
callq 0x2050
movq (%rbx), %rsi
pushq $0x2
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x421c
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r15
movq (%rbx), %rsi
movq %rbx, %rdi
movq -0x50(%rbp), %r14
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x421c
movq (%rbx), %rdi
subq %r14, %r15
movq %r15, %rsi
callq 0x502a
movq (%rbx), %rdi
callq 0x2280
movq (%rbx), %rsi
movq %rbx, %rdi
movq -0x58(%rbp), %rdx
xorl %ecx, %ecx
callq 0x421c
testb $0x4, 0x74(%rbx)
pushq $0x4
popq %rdi
cmovnel %r13d, %edi
movq (%rbx), %rsi
callq 0x21c0
movq (%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
pushq $0x2
popq %rcx
callq 0x421c
movq (%rbx), %rdi
callq 0x2280
movq 0x60(%rbx), %rdx
leaq 0xe47b(%rip), %rsi      # 0x1232f
movq -0x60(%rbp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2370
movq %r14, %rdi
callq 0x2080
movq %r14, %rdi
callq 0x2050
movq (%rbx), %rsi
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x421c
movq (%rbx), %rdi
movq 0x98(%rbx), %rsi
callq 0x502a
movq (%rbx), %rdi
movq 0x90(%rbx), %rsi
callq 0x502a
movq (%rbx), %rsi
pushq $0x29
popq %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x421c
movq (%rbx), %rdi
movl 0xb8(%rbx), %esi
callq 0x502a
movq (%rbx), %rdi
movl 0x6c(%rbx), %esi
callq 0x502a
movq (%rbx), %rdi
movl 0x68(%rbx), %esi
callq 0x502a
movq (%rbx), %rdi
movl 0xa8(%rbx), %esi
callq 0x502a
movq (%rbx), %rdi
callq 0x2280
leaq 0x28(%rbx), %rdi
leaq 0x148(%rbx), %rsi
callq 0x3811
movq 0x30(%rbx), %rdi
callq 0x2050
andq $0x0, 0x30(%rbx)
leaq 0x20(%rbx), %rdi
leaq 0x140(%rbx), %rsi
callq 0x3811
leaq 0x18(%rbx), %rdi
leaq 0x138(%rbx), %rsi
callq 0x3811
leaq 0x130(%rbx), %rsi
movq %r12, %rdi
callq 0x3811
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x3faa
callq 0x2110
andq $0x0, 0x8(%rbx)
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x419d
testb $0x2, 0xe9(%rbx)
jne 0x3fcd
callq 0x2110
andq $0x0, (%rbx)
jmp 0x419d
movq 0x60(%rbx), %r14
movq %r14, %rdi
callq 0x2130
movq %rax, %r15
addl $0x5, %eax
movslq %eax, %rsi
pushq $0x1
popq %rdi
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 0xe32c(%rip), %rsi      # 0x1233c
movq %r12, %rdi
callq 0x2330
testq %rax, %rax
je 0x4116
movq %rax, %r15
movq (%rbx), %rsi
pushq $0x2
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x421c
movq (%rbx), %rdi
callq 0x20b0
movq %rax, %r13
movl $0xfe, %edi
movq %r15, %rsi
callq 0x21c0
movq %r15, %rdi
xorl %esi, %esi
callq 0x502a
movq %r15, %rdi
movq %r13, %rsi
callq 0x502a
movq %r15, %rdi
callq 0x2280
movq (%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x421c
movq %r15, %rdi
callq 0x2260
movl %eax, %edi
callq 0x2180
movl %eax, %r14d
leaq 0xe295(%rip), %rsi      # 0x12326
movl %eax, %edi
callq 0x2100
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x412b
movq %r15, -0x40(%rbp)
movq %r12, -0x30(%rbp)
xorl %r12d, %r12d
movq %r13, %r14
cmpq %r14, %r12
jge 0x4103
movl $0x8000, %ecx           # imm = 0x8000
cmpq %rcx, %r13
movl $0x8000, %r15d          # imm = 0x8000
cmovlq %r13, %r15
movq (%rbx), %rcx
leaq -0x8060(%rbp), %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x20c0
movq -0x38(%rbp), %rdi
leaq -0x8060(%rbp), %rsi
movl %r15d, %edx
callq 0x22b0
movl $0x8000, %ecx           # imm = 0x8000
addq %rcx, %r12
addq $-0x8000, %r13          # imm = 0x8000
jmp 0x40b3
movq -0x38(%rbp), %rdi
callq 0x2040
movq -0x30(%rbp), %r12
movq -0x40(%rbp), %r15
jmp 0x4133
andb $-0x3, 0xe9(%rbx)
movq (%rbx), %rdi
callq 0x2110
andq $0x0, (%rbx)
jmp 0x4195
movl %r14d, %edi
callq 0x21b0
pushq $0x2
popq %rcx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x421c
movq %r15, %rdi
callq 0x20b0
movq %rax, %r14
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x421c
decq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x502a
movq %r15, %rdi
callq 0x2110
movq (%rbx), %rdi
callq 0x2110
andq $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 0x41b8
leaq 0x120(%rbx), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x50ad
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
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4244
xorl %r14d, %r14d
movl 0x68(%rbx), %eax
cmpq %rax, %r14
jae 0x3922
incq %r14
movq 0x40(%rbx), %rax
movl %r15d, %ecx
andl $-0x4, %ecx
movl (%rax,%rcx,4), %edx
addq 0x48(%rbx), %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4363
addq $0x4, %r15
jmp 0x41eb