// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/uuencode.c
// Function: UUENCODE_decode_uu
int UUENCODE_decode_uu( FFGET_FILE *f, char *unpackdir, char *input_filename, char *out_filename, int out_filename_size, int decode_whole_file, int keep )
{
	int filename_found = 0;
	char buf[ UUENCODE_STRLEN_MAX ];
	char *bp = buf, *fn, *fp;
	int n, i, expected;
	char fullpath[ UUENCODE_STRLEN_MAX ]="";
	struct PLD_strtok tx;
	unsigned char *writebuffer = NULL;
	unsigned char *wbpos;
	int wbcount = 0;
	int loop = 0;
	int buflen = 0;
	int filecount = 0;
	FFGET_FILE ffinf;	// Local static FFGET struct used if *f is  NULL
	FFGET_FILE *finf;	// Points to either *f or &ffinf
	FILE *outf;
	int outfo =0; 			// set if outfile was opened.
	FILE *inf = NULL;
	int output_filename_supplied = 0;
	int start_found = 0;

	if ((out_filename != NULL))
	{
		if ((out_filename[0] != '\0'))
		{
			output_filename_supplied = 1;
		}
	}

	bp = buf;

	if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Starting.(input=%s,output=%s)\n", FL, input_filename,out_filename );


	// If no FFGET_FILE param is passed to us directly, then we must create out own.

	if (!f)
	{
		if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: NULL FFGET source stream given to us, create our own.\n",FL);

		// Setup the full source-data file path.
		snprintf(fullpath, sizeof(fullpath),"%s", input_filename );

		if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Full INPUT file path set as '%s'\n", FL, fullpath);

		inf = fopen(fullpath,"r");
		if (!inf)
		{
			LOGGER_log("%s:%d:UUENCODE_decode_uu:ERROR: Cannot open file '%s' for reading (%s)", FL, fullpath, strerror(errno));
			uuencode_error = UUENCODE_STATUS_CANNOT_OPEN_FILE;
			return -1;
		}

		FFGET_setstream(&ffinf, inf);
		FFGET_set_watch_SDL( glb.doubleCR_mode );
		finf = &ffinf;

		if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Creation done. [FFGET-FILE=%p, FILE=%p]\n", FL, finf, inf);
	} else {
		if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: File handle already exists to read from, using",FL);	
		finf = f;
	}

	writebuffer = malloc( UUENCODE_WRITE_BUFFER_SIZE *sizeof(unsigned char));
	if (!writebuffer)
	{
		LOGGER_log("%s:%d:UUENCODE_decode_uu:ERROR: cannot allocate 100K of memory for the write buffer",FL);
		uuencode_error = UUENCODE_STATUS_CANNOT_ALLOCATE_MEMORY;
		return -1;
	}
	else {
		wbpos = writebuffer;
		wbcount = 0;
	}


	if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Beginning.(%s)\n",FL,fullpath);


	while (!FFGET_feof(finf))
	{
		filename_found = 0;


		// First lets locate the BEGIN line of this UUDECODE file

		//		if (output_filename_supplied == 0)

		if (1) /** 20041105-23H00:PLD: Stepan Kasal - UUbegin patch **/
		{

			while (FFGET_fgets(buf, sizeof(buf), finf))
			{

				if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: BUFFER: \n%s\n", FL, buf);

				// Check for the presence of 'BEGIN', but make sure it's not followed by a 
				//		colon ( which indicates a VCARD instead of UUENCODE

				if ((strncasecmp(buf,"begin",5)==0)&&(buf[5] !=':')&&(isspace((int)buf[5])))
				{
					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Located BEGIN\n",FL);
					// Okay, so the line contains begin at the start, now, lets get the decode details
					fp = fn = NULL;

					bp = PLD_strtok(&tx, buf, " \n\r\t"); // Get the begin

					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: BEGIN = '%s'\n", FL, bp);
					if (bp) fp = PLD_strtok(&tx, NULL, " \n\r\t"); // Get the file-permissions

					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Permissions/Name = '%s'\n", FL, fp);
					if (fp) fn = PLD_strtok(&tx, NULL, "\n\r"); // Get the file-name

					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Name = '%s'\n", FL, fn);

					if (!fn)
					{
						bp = fp;
					}
					else bp = fn;

					if ((!bp)&&(!f))
					{
						LOGGER_log("%s:%d:UUENCODE_decode_uu:WARNING: unable to obtain filename from UUencoded text file header", FL);
						if (writebuffer) free(writebuffer);
						fclose(inf);
						uuencode_error = UUENCODE_STATUS_CANNOT_FIND_FILENAME;
						return -1;
					}

					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Full path = (%s)\n",FL,bp);

					filename_found = 1;
					break;
				} // If line starts with BEGIN

			} // While more lines in the INPUT file.

		}

		/** 20041105-23H02:PLD: Stepan Kasal Patch **/
		// Filename from header has precedence:
		if (output_filename_supplied != 0)
		{
			filename_found = 1;
			bp = out_filename;
			if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Output filename set to '%s'",FL, bp);
		}




		// If we have a filename, and we have our bp as NON-null, then we shall commence
		//	to decode the UUencoded data from the stream.

		if ((filename_found != 0)&&(bp))
		{
			if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Located filename (%s), now decoding.\n", FL, bp);

			// Clean up the file name
			FNFILTER_filter( bp, out_filename_size );

			// If our filename wasn't supplied via the params, then copy it over here
			if (output_filename_supplied == 0) snprintf( out_filename, out_filename_size, "%s", bp );


			// Create the new output full path

			snprintf(fullpath, sizeof(fullpath), "%s/%s", unpackdir, bp );
			if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Filename = (%s)\n", FL, fullpath);

			outf = fopen(fullpath, "wb");
			if (!outf)
			{
				LOGGER_log("%s:%d:UUENCODE_decode_uu:ERROR: Cannot open file '%s' (%s)", FL, fullpath,strerror(errno));
				if (writebuffer) free(writebuffer);
				uuencode_error = UUENCODE_STATUS_CANNOT_OPEN_FILE;
				return -1;
			}
			else outfo = 1;

			// Allocate the write buffer.  By using the write buffer we gain an additional 10% in performance
			// due to the lack of function call (fwrite) overheads

			// Okay, now we have the UUDECODE data to decode...

			wbcount = 0;
			wbpos = writebuffer;

			while (outf)
			{

				// for each input line
				FFGET_fgets(buf, sizeof(buf), finf);
				if (UUENCODE_DPEDANTIC) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Read line:\n%s",FL,buf);
				if (FFGET_feof(finf) != 0)
				{
					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:WARNING: Short file (%s)\n",FL, fullpath);
					if (writebuffer != NULL) free(writebuffer);
					uuencode_error = UUENCODE_STATUS_SHORT_FILE;
					return -1;
				}

				// If we've reached the end of the UUencoding

				if (strncasecmp(buf,"end",3)==0)
				{
					if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: End of UUencoding detected\n",FL);
					break;
				}

				if ( !strpbrk(buf,"\r\n") )
				{
					LOGGER_log("%s:%d:UUENCODE_decode_uu:WARNING: Excessive length line\n",FL);
				}

				// The first char of the line indicates how many bytes are to be expected

				n = uudec[(int)*buf];


				// If the line is a -blank- then break out.

				if ((start_found == 0)&&((*buf == '\n')||(*buf == '\r'))) continue;
				else start_found =1 ;

				if ((start_found != 0)&&((n <= 0) || (*buf == '\n'))) break;

				// Calculate expected # of chars and pad if necessary

				expected = ((n+2)/3)<<2;
				buflen = strlen(buf) -1;
				for (i = buflen; i <= expected; i++) buf[i] = ' ';
				bp = &buf[1];

				// Decode input buffer to output file.

				while (n > 0)
				{
					// In order to reduce function call overheads, we've bought the UUDecoding
					// bit shifting routines into the UUDecode main decoding routines. This should
					// save us about 250,000 function calls per Mb.
					// UUENCODE_outdec(bp, outf, n);

					char c[3];
					int m = n;

					c[0] = uudec[(int)*bp] << 2 | uudec[(int)*(bp+1)] >> 4;
					c[1] = uudec[(int)*(bp+1)] << 4 | uudec[(int)*(bp+2)] >> 2;
					c[2] = uudec[(int)*(bp+2)] << 6 | uudec[(int)*(bp+3)];

					if (m > 3) m = 3;

					if ( wbcount >= UUENCODE_WRITE_BUFFER_LIMIT )
					{
						size_t bc;
						bc = fwrite(writebuffer, 1, wbcount, outf);
						if (bc != wbcount) {
							LOGGER_log("%s:%d:ERROR: Attempted to write %ld bytes, only wrote %ld\n", FL, wbcount, bc);
						}
						wbpos = writebuffer;
						wbcount = 0;
					}

					// Transfer the decoded data to the write buffer.
					// The reason why we use a loop, rather than just a set of if
					// statements is just for code-viewing simplicity.  It's a lot
					// easier to read than some nested chain of if's

					for (loop = 0; loop < m; loop++)
					{
						*wbpos = c[loop];
						wbpos++;
						wbcount++;
					}

					bp += 4;
					n -= 3;

				} // while (n > 0)

			} // While (1)

			if ((outfo)&&(wbcount > 0))
			{
				size_t bc;
				bc = fwrite(writebuffer, 1, wbcount, outf);
				if (bc != wbcount) {
					LOGGER_log("%s:%d:ERROR: Attempted to write %ld bytes, only wrote %ld\n", FL, wbcount, bc);
				}

			}


			if (outfo) fclose(outf);
			// Call our reporting function, else, if no function is defined, use the default
			//		standard call

			if ((UUENCODE_VERBOSE) && (output_filename_supplied == 0))
			{
				if (glb.filename_decoded_report == NULL)
				{
					LOGGER_log("Decoded: %s\n", fullpath);
				} else {
					glb.filename_decoded_report( fullpath, (glb.verbosity_contenttype>0?"uuencoded":NULL) );
				}
			}

			filecount++;

		} // If valid filename was found for UUdecode

		else
		{
			out_filename[0] = '\0';
			if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: No FILENAME was found in data...\n",FL);
		}

		if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Segment completed\n",FL);

		// If this file was a result of the x-uuencode content encoding, then we need to exit out
		// as we're reading in the -stream-, and we dont want to carry on reading because we'll
		// end up just absorbing email data which we weren't supposed to.

		if ((f)&&( !decode_whole_file )) break;


	} // While !feof(inf)



	if (writebuffer) free(writebuffer);

	if (UUENCODE_DNORMAL) LOGGER_log("%s:%d:UUENCODE_decode_uu:DEBUG: Completed\n",FL);

	if (inf) fclose(inf);


	return filecount;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28e8, %rsp           # imm = 0x28E8
movl %r9d, %ebx
movl %r8d, %ebp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, 0x58(%rsp)
movq %rdi, %r13
leaq 0x70(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x2170
testq %r15, %r15
je 0xdc2e
cmpb $0x0, (%r15)
sete 0x6(%rsp)
jmp 0xdc33
movb $0x1, 0x6(%rsp)
cmpl $0x0, 0x21d46(%rip)     # 0x2f980
jle 0xdc5c
leaq 0xa88c(%rip), %rdi      # 0x184cf
leaq 0xa78f(%rip), %rsi      # 0x183d9
movl $0x189, %edx            # imm = 0x189
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0xc960
movl 0x21d1e(%rip), %eax     # 0x2f980
testq %r13, %r13
je 0xdc97
testl %eax, %eax
jle 0xdd6b
leaq 0xa9c1(%rip), %rdi      # 0x18637
leaq 0xa75c(%rip), %rsi      # 0x183d9
movq $0x0, 0x20(%rsp)
movl $0x1a5, %edx            # imm = 0x1A5
xorl %eax, %eax
callq 0xc960
jmp 0xdd74
testl %eax, %eax
jle 0xdcb5
leaq 0xa86c(%rip), %rdi      # 0x1850e
leaq 0xa730(%rip), %rsi      # 0x183d9
movl $0x190, %edx            # imm = 0x190
xorl %eax, %eax
callq 0xc960
leaq 0xa3d1(%rip), %rdx      # 0x1808d
leaq 0x70(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rcx
xorl %eax, %eax
callq 0x2140
cmpl $0x0, 0x21ca9(%rip)     # 0x2f980
jle 0xdcf8
leaq 0xa885(%rip), %rdi      # 0x18565
leaq 0xa6f2(%rip), %rsi      # 0x183d9
leaq 0x70(%rsp), %rcx
movl $0x195, %edx            # imm = 0x195
xorl %eax, %eax
callq 0xc960
leaq 0x87d5(%rip), %rsi      # 0x164d4
leaq 0x70(%rsp), %rdi
callq 0x2350
testq %rax, %rax
je 0xe4cd
leaq 0x878(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %rax, %r14
callq 0x787b
movl 0x21c72(%rip), %edi     # 0x2f9a0
callq 0x76e4
cmpl $0x0, 0x21c46(%rip)     # 0x2f980
movq %r14, 0x20(%rsp)
jle 0xdd77
leaq 0xa8a6(%rip), %rdi      # 0x185ee
leaq 0xa68a(%rip), %rsi      # 0x183d9
leaq 0x878(%rsp), %r12
movl $0x1a3, %edx            # imm = 0x1A3
movq %r12, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0xc960
jmp 0xdd77
movq $0x0, 0x20(%rsp)
movq %r13, %r12
movl $0x1000, %edi           # imm = 0x1000
callq 0x22b0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0xe4a7
movq %r15, 0x28(%rsp)
cmpl $0x0, 0x21be5(%rip)     # 0x2f980
jle 0xddbc
leaq 0xa936(%rip), %rdi      # 0x186da
leaq 0xa62e(%rip), %rsi      # 0x183d9
leaq 0x70(%rsp), %rcx
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0xc960
movl %ebp, 0x3c(%rsp)
movslq %ebp, %rax
movq %rax, 0x50(%rsp)
movq %r13, 0x48(%rsp)
testq %r13, %r13
sete %al
testl %ebx, %ebx
setne %cl
orb %al, %cl
movb %cl, 0x7(%rsp)
leaq 0x470(%rsp), %r13
leaq 0xa5ec(%rip), %r15      # 0x183d9
movl $0x0, 0x1c(%rsp)
movq %r13, %rbx
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x7918
testl %eax, %eax
jne 0xe424
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x7a09
xorl %r14d, %r14d
testq %rax, %rax
je 0xdfbc
cmpl $0x0, 0x21b53(%rip)     # 0x2f980
jle 0xde48
leaq 0xa8d4(%rip), %rdi      # 0x1870a
movq %r15, %rsi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r13, %rcx
xorl %eax, %eax
callq 0xc960
movl $0x5, %edx
movq %r13, %rdi
leaq 0xa541(%rip), %rsi      # 0x18398
callq 0x22c0
testl %eax, %eax
sete %cl
movb 0x475(%rsp), %al
cmpb $0x3a, %al
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xde8f
movsbq %al, %r15
callq 0x23f0
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r15,2)
leaq 0xa54c(%rip), %r15      # 0x183d9
jne 0xdea4
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x7a09
jmp 0xde1d
cmpl $0x0, 0x21ad5(%rip)     # 0x2f980
jle 0xdec3
leaq 0xa883(%rip), %rdi      # 0x18737
movq %r15, %rsi
movl $0x1cf, %edx            # imm = 0x1CF
xorl %eax, %eax
callq 0xc960
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
leaq 0x83c4(%rip), %rdx      # 0x16296
callq 0xc168
movq %rax, %rbx
cmpl $0x0, 0x21a9f(%rip)     # 0x2f980
jle 0xdefc
leaq 0xa87c(%rip), %rdi      # 0x18766
movq %r15, %rsi
movl $0x1d5, %edx            # imm = 0x1D5
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
testq %rbx, %rbx
je 0xdf19
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
leaq 0x8387(%rip), %rdx      # 0x16296
callq 0xc168
movq %rax, %rbx
jmp 0xdf1b
xorl %ebx, %ebx
cmpl $0x0, 0x21a5e(%rip)     # 0x2f980
jle 0xdf3d
leaq 0xa869(%rip), %rdi      # 0x18794
movq %r15, %rsi
movl $0x1d8, %edx            # imm = 0x1D8
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
testq %rbx, %rbx
je 0xdf5a
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
leaq 0x9e5a(%rip), %rdx      # 0x17daa
callq 0xc168
movq %rax, %r14
jmp 0xdf5d
xorl %r14d, %r14d
cmpl $0x0, 0x21a1c(%rip)     # 0x2f980
jle 0xdf7f
leaq 0xa860(%rip), %rdi      # 0x187cd
movq %r15, %rsi
movl $0x1db, %edx            # imm = 0x1DB
movq %r14, %rcx
xorl %eax, %eax
callq 0xc960
testq %r14, %r14
cmovneq %r14, %rbx
movq 0x48(%rsp), %rax
orq %rbx, %rax
je 0xe556
movl $0x1, %r14d
cmpl $0x0, 0x219df(%rip)     # 0x2f980
jle 0xdfbc
leaq 0xa8ac(%rip), %rdi      # 0x18856
movq %r15, %rsi
movl $0x1ec, %edx            # imm = 0x1EC
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
cmpb $0x0, 0x6(%rsp)
jne 0xdff7
movl $0x1, %r14d
cmpl $0x0, 0x219b0(%rip)     # 0x2f980
jle 0xdff2
leaq 0xa8af(%rip), %rdi      # 0x18888
movq %r15, %rsi
movl $0x1fc, %edx            # imm = 0x1FC
movq 0x28(%rsp), %rbx
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
jmp 0xdff7
movq 0x28(%rsp), %rbx
testl %r14d, %r14d
je 0xe304
testq %rbx, %rbx
je 0xe304
cmpl $0x0, 0x21970(%rip)     # 0x2f980
leaq 0x70(%rsp), %r14
jle 0xe030
leaq 0xa8a6(%rip), %rdi      # 0x188c4
movq %r15, %rsi
movl $0x207, %edx            # imm = 0x207
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
movq %rbx, %rdi
movl 0x3c(%rsp), %esi
callq 0xe6c5
cmpb $0x0, 0x6(%rsp)
je 0xe05e
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rsi
leaq 0xa039(%rip), %rdx      # 0x1808d
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2140
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
leaq 0x439f(%rip), %rdx      # 0x1240c
movq 0x58(%rsp), %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2140
cmpl $0x0, 0x218fd(%rip)     # 0x2f980
jle 0xe09e
leaq 0xa87e(%rip), %rdi      # 0x1890a
movq %r15, %rsi
movl $0x213, %edx            # imm = 0x213
movq %r14, %rcx
xorl %eax, %eax
callq 0xc960
movq %r14, %rdi
leaq 0xa893(%rip), %rsi      # 0x1893b
callq 0x2350
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0xe51c
movl $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r14
leaq 0xa30a(%rip), %r15      # 0x183d9
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x7a09
cmpl $0xa, 0x2189a(%rip)     # 0x2f980
jl 0xe101
leaq 0xa88a(%rip), %rdi      # 0x18979
movq %r15, %rsi
movl $0x22c, %edx            # imm = 0x22C
movq %r13, %rcx
xorl %eax, %eax
callq 0xc960
movq %r12, %rdi
callq 0x7918
testl %eax, %eax
jne 0xe469
movl $0x3, %edx
movq %r13, %rdi
leaq 0xa8ba(%rip), %rsi      # 0x189da
callq 0x22c0
testl %eax, %eax
je 0xe334
movq %r13, %rdi
leaq 0x7100(%rip), %rsi      # 0x15237
callq 0x2300
testq %rax, %rax
jne 0xe157
leaq 0xa8d2(%rip), %rdi      # 0x18a1a
movq %r15, %rsi
movl $0x23f, %edx            # imm = 0x23F
xorl %eax, %eax
callq 0xc960
movsbq 0x470(%rsp), %rax
testl %ebp, %ebp
jne 0xe17a
xorl %ebp, %ebp
cmpb $0xa, %al
je 0xe0cf
movzbl %al, %ecx
cmpl $0xd, %ecx
je 0xe0cf
movl $0x1, %ebp
cmpb $0xa, %al
je 0xe353
leaq 0xa9c2(%rip), %rcx      # 0x18b50
movb (%rax,%rcx), %al
testb %al, %al
je 0xe353
movzbl %al, %r15d
leal 0x2(%r15), %eax
imulq $0x55555556, %rax, %rbx # imm = 0x55555556
shrq $0x20, %rbx
shll $0x2, %ebx
movq %r13, %rdi
callq 0x2110
leal -0x1(%rax), %ecx
cmpl %ebx, %ecx
jg 0xe1e1
movslq %ecx, %rcx
leaq (%rsp,%rcx), %rdi
addq $0x470, %rdi            # imm = 0x470
orl $0x1, %ebx
subl %eax, %ebx
incq %rbx
movl $0x20, %esi
movq %rbx, %rdx
callq 0x2170
movl $0x1, %ebp
leaq 0x471(%rsp), %rbx
testl %r15d, %r15d
je 0xe0c8
movl 0x8(%rsp), %r8d
movsbq (%rbx), %rax
leaq 0xa949(%rip), %rsi      # 0x18b50
movb (%rax,%rsi), %al
shlb $0x2, %al
movsbq 0x1(%rbx), %rcx
movb (%rcx,%rsi), %cl
movl %ecx, %edx
shrb $0x4, %dl
orb %al, %dl
movb %dl, 0xd(%rsp)
shlb $0x4, %cl
movsbq 0x2(%rbx), %rax
movb (%rax,%rsi), %al
movl %eax, %edx
shrb $0x2, %dl
orb %cl, %dl
movb %dl, 0xe(%rsp)
shlb $0x6, %al
movsbq 0x3(%rbx), %rcx
orb (%rcx,%rsi), %al
movb %al, 0xf(%rsp)
cmpl $0x3, %r15d
movl $0x3, %ebp
cmovll %r15d, %ebp
cmpl $0xfa0, %r8d            # imm = 0xFA0
jl 0xe2b5
movl %r8d, %edx
movq %rdx, 0x40(%rsp)
movl $0x1, %esi
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq 0x30(%rsp), %rcx
movl %r8d, 0x8(%rsp)
callq 0x23a0
xorl %edi, %edi
movq %r14, %rcx
cmpq 0x40(%rsp), %rax
je 0xe2bb
leaq 0xa7c1(%rip), %rdi      # 0x18a53
leaq 0xa140(%rip), %rsi      # 0x183d9
movl $0x26c, %edx            # imm = 0x26C
movl 0x8(%rsp), %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xc960
xorl %edi, %edi
movq 0x10(%rsp), %rcx
jmp 0xe2bb
movq %r14, %rcx
movl %r8d, %edi
movslq %ebp, %rdx
xorl %eax, %eax
movb 0xd(%rsp,%rax), %sil
movb %sil, (%rcx,%rax)
incq %rax
cmpq %rdx, %rax
jl 0xe2c0
addq $0x4, %rbx
leal -0x3(%r15), %edx
leal (%rdi,%rax), %r8d
leaq (%rcx,%rax), %r14
cmpl $0x3, %r15d
movl %edx, %r15d
jg 0xe1fc
addl %eax, %edi
addq %rax, %rcx
movl $0x1, %ebp
movq %rcx, %r14
movl %edi, 0x8(%rsp)
jmp 0xe0c8
movq 0x28(%rsp), %rax
movb $0x0, (%rax)
cmpl $0x0, 0x2166d(%rip)     # 0x2f980
jle 0xe3fa
leaq 0xa785(%rip), %rdi      # 0x18aa5
movq %r15, %rsi
movl $0x2a5, %edx            # imm = 0x2A5
xorl %eax, %eax
callq 0xc960
jmp 0xe3fa
cmpl $0x0, 0x21645(%rip)     # 0x2f980
jle 0xe353
leaq 0xa69a(%rip), %rdi      # 0x189de
movq %r15, %rsi
movl $0x239, %edx            # imm = 0x239
xorl %eax, %eax
callq 0xc960
movl 0x8(%rsp), %eax
testl %eax, %eax
jle 0xe397
movl %eax, %r14d
movl $0x1, %esi
movq 0x10(%rsp), %rdi
movq %r14, %rdx
movq 0x30(%rsp), %rcx
callq 0x23a0
movl 0x8(%rsp), %ecx
cmpq %r14, %rax
je 0xe397
leaq 0xa6ce(%rip), %rdi      # 0x18a53
movq %r15, %rsi
movl $0x28a, %edx            # imm = 0x28A
movq %rax, %r8
xorl %eax, %eax
callq 0xc960
movq 0x30(%rsp), %rdi
callq 0x20f0
cmpl $0x0, 0x215e0(%rip)     # 0x2f988
setle %al
movb 0x6(%rsp), %cl
xorb $0x1, %cl
orb %al, %cl
leaq 0x70(%rsp), %rcx
jne 0xe3f6
movq 0x215e6(%rip), %rax     # 0x2f9a8
testq %rax, %rax
je 0xe3e5
cmpl $0x0, 0x215c2(%rip)     # 0x2f990
movl $0x0, %esi
leaq 0xa6c1(%rip), %rdx      # 0x18a9b
cmovgq %rdx, %rsi
movq %rcx, %rdi
callq *%rax
jmp 0xe3f6
leaq 0xa6a2(%rip), %rdi      # 0x18a8e
movq %rcx, %rsi
xorl %eax, %eax
callq 0xc960
incl 0x1c(%rsp)
cmpl $0x0, 0x2157f(%rip)     # 0x2f980
jle 0xe419
leaq 0xa6dd(%rip), %rdi      # 0x18ae7
movq %r15, %rsi
movl $0x2a8, %edx            # imm = 0x2A8
xorl %eax, %eax
callq 0xc960
cmpb $0x0, 0x7(%rsp)
jne 0xddfa
movq 0x10(%rsp), %rdi
callq 0x2030
cmpl $0x0, 0x2154b(%rip)     # 0x2f980
jle 0xe451
leaq 0xa6dc(%rip), %rdi      # 0x18b1a
leaq 0x9f94(%rip), %rsi      # 0x183d9
movl $0x2b7, %edx            # imm = 0x2B7
xorl %eax, %eax
callq 0xc960
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xe460
callq 0x20f0
movl 0x1c(%rsp), %eax
jmp 0xe50a
cmpl $0x0, 0x21510(%rip)     # 0x2f980
jle 0xe491
leaq 0xa52e(%rip), %rdi      # 0x189a7
leaq 0x9f59(%rip), %rsi      # 0x183d9
leaq 0x70(%rsp), %rcx
movl $0x22f, %edx            # imm = 0x22F
xorl %eax, %eax
callq 0xc960
movq 0x10(%rsp), %rdi
callq 0x2030
movl $0x64, 0x2150b(%rip)    # 0x2f9b0
jmp 0xe505
leaq 0xa1d8(%rip), %rdi      # 0x18686
leaq 0x9f24(%rip), %rsi      # 0x183d9
movl $0x1ac, %edx            # imm = 0x1AC
xorl %eax, %eax
callq 0xc960
movl $0x66, 0x214e5(%rip)    # 0x2f9b0
jmp 0xe505
callq 0x2060
movl (%rax), %edi
callq 0x23c0
leaq 0xa0c7(%rip), %rdi      # 0x185a7
leaq 0x9ef2(%rip), %rsi      # 0x183d9
leaq 0x70(%rsp), %rcx
movl $0x19a, %edx            # imm = 0x19A
movq %rax, %r8
xorl %eax, %eax
callq 0xc960
movl $0x65, 0x214ab(%rip)    # 0x2f9b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x28e8, %rsp           # imm = 0x28E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2060
movl (%rax), %edi
callq 0x23c0
leaq 0xa40f(%rip), %rdi      # 0x1893e
leaq 0x9ea3(%rip), %rsi      # 0x183d9
leaq 0x70(%rsp), %rcx
movl $0x218, %edx            # imm = 0x218
movq %rax, %r8
xorl %eax, %eax
callq 0xc960
movq 0x10(%rsp), %rdi
callq 0x2030
jmp 0xe4fb
leaq 0xa29d(%rip), %rdi      # 0x187fa
leaq 0x9e75(%rip), %rsi      # 0x183d9
movl $0x1e5, %edx            # imm = 0x1E5
xorl %eax, %eax
callq 0xc960
movq 0x10(%rsp), %rdi
callq 0x2030
movq 0x20(%rsp), %rdi
callq 0x20f0
movl $0x67, 0x21422(%rip)    # 0x2f9b0
jmp 0xe505
nop