// File: /workspace/github_c_makefile_star2_O3/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, 0x24(%rsp)
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, 0x58(%rsp)
movq %rdi, %r15
leaq 0x70(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x2170
testq %rbp, %rbp
je 0xda8d
cmpb $0x0, (%rbp)
sete 0x3(%rsp)
jmp 0xda92
movb $0x1, 0x3(%rsp)
cmpl $0x0, 0x21ee7(%rip)     # 0x2f980
jle 0xdabb
leaq 0xaa1d(%rip), %rdi      # 0x184bf
leaq 0xa920(%rip), %rsi      # 0x183c9
movl $0x189, %edx            # imm = 0x189
movq %r14, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0xc84f
movl 0x21ebf(%rip), %eax     # 0x2f980
testq %r15, %r15
je 0xdaf0
testl %eax, %eax
jle 0xdbbf
leaq 0xab52(%rip), %rdi      # 0x18627
leaq 0xa8ed(%rip), %rsi      # 0x183c9
xorl %r14d, %r14d
movl $0x1a5, %edx            # imm = 0x1A5
xorl %eax, %eax
callq 0xc84f
jmp 0xdbc2
testl %eax, %eax
jle 0xdb0e
leaq 0xaa03(%rip), %rdi      # 0x184fe
leaq 0xa8c7(%rip), %rsi      # 0x183c9
movl $0x190, %edx            # imm = 0x190
xorl %eax, %eax
callq 0xc84f
leaq 0xa54b(%rip), %rdx      # 0x18060
leaq 0x70(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rcx
xorl %eax, %eax
callq 0x2140
cmpl $0x0, 0x21e50(%rip)     # 0x2f980
jle 0xdb51
leaq 0xaa1c(%rip), %rdi      # 0x18555
leaq 0xa889(%rip), %rsi      # 0x183c9
leaq 0x70(%rsp), %rcx
movl $0x195, %edx            # imm = 0x195
xorl %eax, %eax
callq 0xc84f
leaq 0x89ac(%rip), %rsi      # 0x16504
leaq 0x70(%rsp), %rdi
callq 0x2340
testq %rax, %rax
je 0xe387
movq %rax, %r14
leaq 0x878(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x77bb
movl 0x21e19(%rip), %edi     # 0x2f9a0
callq 0x7624
cmpl $0x0, 0x21ded(%rip)     # 0x2f980
jle 0xdbc5
leaq 0xaa42(%rip), %rdi      # 0x185de
leaq 0xa826(%rip), %rsi      # 0x183c9
leaq 0x878(%rsp), %r13
movl $0x1a3, %edx            # imm = 0x1A3
movq %r13, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0xc84f
jmp 0xdbc5
xorl %r14d, %r14d
movq %r15, %r13
movl $0x1000, %edi           # imm = 0x1000
callq 0x22a0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xe361
movq %r14, 0x30(%rsp)
cmpl $0x0, 0x21d97(%rip)     # 0x2f980
jle 0xdc0a
leaq 0xaad8(%rip), %rdi      # 0x186ca
leaq 0xa7d0(%rip), %rsi      # 0x183c9
leaq 0x70(%rsp), %rcx
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0xc84f
movslq 0x24(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %r15, 0x40(%rsp)
testq %r15, %r15
sete %al
testl %ebx, %ebx
setne %cl
orb %al, %cl
movb %cl, 0x4(%rsp)
leaq 0x470(%rsp), %r14
movl $0x0, 0x14(%rsp)
movq %r14, %r12
movl $0x0, 0x20(%rsp)
movb 0x3(%rsp), %r15b
movq %rbp, 0x48(%rsp)
movq %r13, 0x38(%rsp)
movq %r13, %rdi
callq 0x7858
testl %eax, %eax
jne 0xe2de
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x7949
xorl %ebx, %ebx
testq %rax, %rax
je 0xde3f
cmpl $0x0, 0x21cfa(%rip)     # 0x2f980
jle 0xdca5
leaq 0xaa6b(%rip), %rdi      # 0x186fa
leaq 0xa733(%rip), %rsi      # 0x183c9
movl $0x1c8, %edx            # imm = 0x1C8
movq %r14, %rcx
xorl %eax, %eax
callq 0xc84f
movl $0x5, %edx
movq %r14, %rdi
leaq 0xa6d4(%rip), %rsi      # 0x18388
callq 0x22b0
testl %eax, %eax
sete %cl
movb 0x475(%rsp), %al
cmpb $0x3a, %al
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xdced
movsbq %al, %r14
callq 0x23e0
movq (%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
leaq 0x470(%rsp), %r14
jne 0xdd02
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x7949
jmp 0xdc76
cmpl $0x0, 0x21c77(%rip)     # 0x2f980
jle 0xdd25
leaq 0xaa15(%rip), %rdi      # 0x18727
leaq 0xa6b0(%rip), %rsi      # 0x183c9
movl $0x1cf, %edx            # imm = 0x1CF
xorl %eax, %eax
callq 0xc84f
leaq 0x60(%rsp), %rdi
movq %r14, %rsi
leaq 0x8592(%rip), %rdx      # 0x162c6
callq 0xc093
movq %rax, %r15
cmpl $0x0, 0x21c3d(%rip)     # 0x2f980
jle 0xdd62
leaq 0xaa0a(%rip), %rdi      # 0x18756
leaq 0xa676(%rip), %rsi      # 0x183c9
movl $0x1d5, %edx            # imm = 0x1D5
movq %r15, %rcx
xorl %eax, %eax
callq 0xc84f
testq %r15, %r15
je 0xdd7f
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
leaq 0x8551(%rip), %rdx      # 0x162c6
callq 0xc093
movq %rax, %r12
jmp 0xdd82
xorl %r12d, %r12d
cmpl $0x0, 0x21bf7(%rip)     # 0x2f980
movq %r12, %rbx
jle 0xddae
leaq 0xa9ef(%rip), %rdi      # 0x18784
leaq 0xa62d(%rip), %rsi      # 0x183c9
movl $0x1d8, %edx            # imm = 0x1D8
movq %r12, %rcx
xorl %eax, %eax
callq 0xc84f
movq %rbx, %r12
testq %r12, %r12
je 0xddce
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
leaq 0x9fbc(%rip), %rdx      # 0x17d7d
callq 0xc093
movq %rbx, %r12
movq %rax, %r15
jmp 0xddd1
xorl %r15d, %r15d
cmpl $0x0, 0x21ba8(%rip)     # 0x2f980
jle 0xddfa
leaq 0xa9dc(%rip), %rdi      # 0x187bd
leaq 0xa5e1(%rip), %rsi      # 0x183c9
movl $0x1db, %edx            # imm = 0x1DB
movq %r15, %rcx
xorl %eax, %eax
callq 0xc84f
movq %rbx, %r12
testq %r15, %r15
cmovneq %r15, %r12
movq 0x40(%rsp), %rax
orq %r12, %rax
je 0xe410
movl $0x1, %ebx
cmpl $0x0, 0x21b65(%rip)     # 0x2f980
jle 0xde3a
leaq 0xaa22(%rip), %rdi      # 0x18846
leaq 0xa59e(%rip), %rsi      # 0x183c9
movl $0x1ec, %edx            # imm = 0x1EC
movq %r12, %rcx
xorl %eax, %eax
callq 0xc84f
movb 0x3(%rsp), %r15b
testb %r15b, %r15b
jne 0xde72
movl $0x1, %ebx
cmpl $0x0, 0x21b30(%rip)     # 0x2f980
jle 0xde6f
leaq 0xaa1f(%rip), %rdi      # 0x18878
leaq 0xa569(%rip), %rsi      # 0x183c9
movl $0x1fc, %edx            # imm = 0x1FC
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc84f
movq %rbp, %r12
testl %ebx, %ebx
je 0xe19d
testq %r12, %r12
je 0xe19d
cmpl $0x0, 0x21af6(%rip)     # 0x2f980
jle 0xdea9
leaq 0xaa21(%rip), %rdi      # 0x188b4
leaq 0xa52f(%rip), %rsi      # 0x183c9
movl $0x207, %edx            # imm = 0x207
movq %r12, %rcx
xorl %eax, %eax
callq 0xc84f
movq %r12, %rdi
movl 0x24(%rsp), %esi
callq 0xe573
testb %r15b, %r15b
je 0xded3
movq %rbp, %rdi
movq 0x50(%rsp), %rsi
leaq 0xa197(%rip), %rdx      # 0x18060
movq %r12, %rcx
xorl %eax, %eax
callq 0x2140
movl $0x400, %esi            # imm = 0x400
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
leaq 0x4525(%rip), %rdx      # 0x1240c
movq 0x58(%rsp), %rcx
movq %r12, 0x18(%rsp)
movq %r12, %r8
xorl %eax, %eax
callq 0x2140
cmpl $0x0, 0x21a7e(%rip)     # 0x2f980
movl 0x20(%rsp), %r15d
jle 0xdf26
leaq 0xa9ea(%rip), %rdi      # 0x188fa
leaq 0xa4b2(%rip), %rsi      # 0x183c9
movl $0x213, %edx            # imm = 0x213
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc84f
movq %rbx, %rdi
leaq 0xa9fb(%rip), %rsi      # 0x1892b
callq 0x2340
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xe3d6
xorl %r12d, %r12d
movq 0x8(%rsp), %rbp
leaq 0xaa17(%rip), %rbx      # 0x18969
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x7949
cmpl $0xa, 0x21a17(%rip)     # 0x2f980
jl 0xdf84
movq %rbx, %rdi
leaq 0xa454(%rip), %rsi      # 0x183c9
movl $0x22c, %edx            # imm = 0x22C
movq %r14, %rcx
xorl %eax, %eax
callq 0xc84f
movq %r13, %rdi
callq 0x7858
testl %eax, %eax
jne 0xe323
movl $0x3, %edx
movq %r14, %rdi
leaq 0xaa27(%rip), %rsi      # 0x189ca
callq 0x22b0
testl %eax, %eax
je 0xe1d2
movq %r14, %rdi
leaq 0x72ad(%rip), %rsi      # 0x15267
callq 0x22f0
testq %rax, %rax
jne 0xdfde
leaq 0xaa3f(%rip), %rdi      # 0x18a0a
leaq 0xa3f7(%rip), %rsi      # 0x183c9
movl $0x23f, %edx            # imm = 0x23F
xorl %eax, %eax
callq 0xc84f
movsbq 0x470(%rsp), %rax
testl %r15d, %r15d
jne 0xe003
xorl %r15d, %r15d
cmpb $0xa, %al
je 0xdf52
movzbl %al, %ecx
cmpl $0xd, %ecx
je 0xdf52
movl $0x1, %r15d
cmpb $0xa, %al
je 0xe1f5
leaq 0xab28(%rip), %rcx      # 0x18b40
movb (%rax,%rcx), %al
testb %al, %al
je 0xe1f5
movzbl %al, %ebx
imull $0x5556, %ebx, %r13d    # imm = 0x5556
addl $0xaaac, %r13d          # imm = 0xAAAC
shrl $0xe, %r13d
andl $-0x4, %r13d
movq %r14, %rdi
callq 0x2110
leal -0x1(%rax), %ecx
cmpl %r13d, %ecx
jg 0xe071
movslq %ecx, %rcx
leaq (%rsp,%rcx), %rdi
addq $0x470, %rdi            # imm = 0x470
orl $0x1, %r13d
subl %eax, %r13d
incq %r13
movl $0x20, %esi
movq %r13, %rdx
callq 0x2170
leaq 0x471(%rsp), %r8
movq 0x38(%rsp), %r13
movl %r12d, %r9d
movsbq (%r8), %rax
leaq 0xaab4(%rip), %rsi      # 0x18b40
movb (%rax,%rsi), %al
shlb $0x2, %al
movsbq 0x1(%r8), %rcx
movb (%rcx,%rsi), %cl
movl %ecx, %edx
shrb $0x4, %dl
orb %al, %dl
movb %dl, 0x5(%rsp)
shlb $0x4, %cl
movsbq 0x2(%r8), %rax
movb (%rax,%rsi), %al
movl %eax, %edx
shrb $0x2, %dl
orb %cl, %dl
movb %dl, 0x6(%rsp)
shlb $0x6, %al
movsbq 0x3(%r8), %rcx
orb (%rcx,%rsi), %al
movb %al, 0x7(%rsp)
cmpl $0x3, %ebx
movl $0x3, %r14d
cmovbl %ebx, %r14d
cmpl $0xfa0, %r9d            # imm = 0xFA0
jl 0xe146
movl %r9d, %ebp
movl $0x1, %esi
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rdx
movq 0x28(%rsp), %rcx
movl %r9d, 0x18(%rsp)
movq %r8, %r15
callq 0x2390
movq %r15, %r8
xorl %r12d, %r12d
movq %r13, %rcx
movq 0x38(%rsp), %r13
cmpq %rbp, %rax
je 0xe14c
xorl %r12d, %r12d
leaq 0xa921(%rip), %rdi      # 0x18a43
leaq 0xa2a0(%rip), %rsi      # 0x183c9
movl $0x26c, %edx            # imm = 0x26C
movl 0x18(%rsp), %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xc84f
movq %r15, %r8
movq 0x8(%rsp), %rcx
jmp 0xe14c
movq %rbp, %rcx
movl %r9d, %r12d
movl %r14d, %edx
xorl %eax, %eax
movb 0x5(%rsp,%rax), %sil
movb %sil, (%rcx,%rax)
incq %rax
cmpq %rdx, %rax
jb 0xe151
addq $0x4, %r8
leal -0x3(%rbx), %edx
leal (%r12,%rax), %r9d
leaq (%rcx,%rax), %rbp
cmpl $0x3, %ebx
movl %edx, %ebx
jg 0xe081
movq %r8, 0x18(%rsp)
addl %eax, %r12d
addq %rax, %rcx
movl $0x1, %r15d
movq %rcx, %rbp
leaq 0x470(%rsp), %r14
jmp 0xdf4b
movb $0x0, (%rbp)
cmpl $0x0, 0x217d8(%rip)     # 0x2f980
jle 0xe2d3
movq %r12, 0x18(%rsp)
leaq 0xa8db(%rip), %rdi      # 0x18a95
leaq 0xa208(%rip), %rsi      # 0x183c9
movl $0x2a5, %edx            # imm = 0x2A5
xorl %eax, %eax
callq 0xc84f
jmp 0xe2ab
cmpl $0x0, 0x217a7(%rip)     # 0x2f980
jle 0xe1f5
leaq 0xa7ec(%rip), %rdi      # 0x189ce
leaq 0xa1e0(%rip), %rsi      # 0x183c9
movl $0x239, %edx            # imm = 0x239
xorl %eax, %eax
callq 0xc84f
movl %r15d, 0x20(%rsp)
testl %r12d, %r12d
jle 0xe240
movl %r12d, %ebx
movl %r12d, %r15d
movl $0x1, %esi
movq 0x8(%rsp), %rdi
movq %r15, %rdx
movq 0x28(%rsp), %rcx
callq 0x2390
cmpq %r15, %rax
je 0xe240
leaq 0xa81b(%rip), %rdi      # 0x18a43
leaq 0xa19a(%rip), %rsi      # 0x183c9
movl $0x28a, %edx            # imm = 0x28A
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xc84f
movq 0x28(%rsp), %rdi
callq 0x20f0
cmpl $0x0, 0x21737(%rip)     # 0x2f988
setle %al
movb 0x3(%rsp), %r15b
movl %r15d, %ecx
xorb $0x1, %cl
orb %al, %cl
movq 0x48(%rsp), %rbp
jne 0xe2a7
movq 0x21739(%rip), %rax     # 0x2f9a8
testq %rax, %rax
je 0xe294
cmpl $0x0, 0x21715(%rip)     # 0x2f990
movl $0x0, %esi
leaq 0xa804(%rip), %rcx      # 0x18a8b
cmovgq %rcx, %rsi
leaq 0x70(%rsp), %rdi
callq *%rax
jmp 0xe2a7
leaq 0xa7e3(%rip), %rdi      # 0x18a7e
leaq 0x70(%rsp), %rsi
xorl %eax, %eax
callq 0xc84f
incl 0x14(%rsp)
cmpl $0x0, 0x216ce(%rip)     # 0x2f980
jle 0xe2ce
leaq 0xa81c(%rip), %rdi      # 0x18ad7
leaq 0xa107(%rip), %rsi      # 0x183c9
movl $0x2a8, %edx            # imm = 0x2A8
xorl %eax, %eax
callq 0xc84f
movq 0x18(%rsp), %r12
cmpb $0x0, 0x4(%rsp)
jne 0xdc54
movq 0x8(%rsp), %rdi
callq 0x2030
cmpl $0x0, 0x21691(%rip)     # 0x2f980
jle 0xe30b
leaq 0xa812(%rip), %rdi      # 0x18b0a
leaq 0xa0ca(%rip), %rsi      # 0x183c9
movl $0x2b7, %edx            # imm = 0x2B7
xorl %eax, %eax
callq 0xc84f
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xe31a
callq 0x20f0
movl 0x14(%rsp), %eax
jmp 0xe3c4
cmpl $0x0, 0x21656(%rip)     # 0x2f980
jle 0xe34b
leaq 0xa664(%rip), %rdi      # 0x18997
leaq 0xa08f(%rip), %rsi      # 0x183c9
leaq 0x70(%rsp), %rcx
movl $0x22f, %edx            # imm = 0x22F
xorl %eax, %eax
callq 0xc84f
movq 0x8(%rsp), %rdi
callq 0x2030
movl $0x64, 0x21651(%rip)    # 0x2f9b0
jmp 0xe3bf
leaq 0xa30e(%rip), %rdi      # 0x18676
leaq 0xa05a(%rip), %rsi      # 0x183c9
movl $0x1ac, %edx            # imm = 0x1AC
xorl %eax, %eax
callq 0xc84f
movl $0x66, 0x2162b(%rip)    # 0x2f9b0
jmp 0xe3bf
callq 0x2060
movl (%rax), %edi
callq 0x23b0
leaq 0xa1fd(%rip), %rdi      # 0x18597
leaq 0xa028(%rip), %rsi      # 0x183c9
leaq 0x70(%rsp), %rcx
movl $0x19a, %edx            # imm = 0x19A
movq %rax, %r8
xorl %eax, %eax
callq 0xc84f
movl $0x65, 0x215f1(%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 0x23b0
leaq 0xa545(%rip), %rdi      # 0x1892e
leaq 0x9fd9(%rip), %rsi      # 0x183c9
leaq 0x70(%rsp), %rcx
movl $0x218, %edx            # imm = 0x218
movq %rax, %r8
xorl %eax, %eax
callq 0xc84f
movq 0x8(%rsp), %rdi
callq 0x2030
jmp 0xe3b5
leaq 0xa3d3(%rip), %rdi      # 0x187ea
leaq 0x9fab(%rip), %rsi      # 0x183c9
movl $0x1e5, %edx            # imm = 0x1E5
xorl %eax, %eax
callq 0xc84f
movq 0x8(%rsp), %rdi
callq 0x2030
movq 0x30(%rsp), %rdi
callq 0x20f0
movl $0x67, 0x21568(%rip)    # 0x2f9b0
jmp 0xe3bf
nopl (%rax)