// File: /workspace/github_c_makefile_star2_O2/salextpuru[P]speccy-toochain/src/bin2tap/bin2tap.c
// Function: main
int main (int argc, char *argv[]) {

	int	inputlen;		/* inputlen - input file lenght*/

	FILE	*foutput, *finput;	/* foutput - output file descriptor */
					/* finput - input file description */
	int	foutname_i = 0;		/* foutname_i - index to name in argv field */
	char	foutname[255];		/* foutname - output file name */
	int	finname_i = 0;		/* finname_i - index to name in argv field */

	int	checksum;		/* checksum - TAP checksum */
	int	i, in_name, no;		/* general purpose variables */

	int	address = ADDRESS;	/* address - start address of binary file */
	int	basic = 0;		/* basic - indicator of BASIC loader */
	int	clear = CLEAR;		/* clear - CLEAR value for BASIC loader */
	int	run = RUN;		/* run - address where to start binary file */
	int	cb = 0, cp = 0, ci = 7;	/* cb, cp, ci - colors for border, paper and ink*/
	int	d80 = 0;		/* d80 - indicate D80 loader */
	int	hp = 0;			/* hp - add poke for header dissable */
	char	run_name[] = "run       "; /* run_name - alternative name of basic loader */

	char	loader_template[] = "\0\x0A\x16\0\xEAloader by bin2tap1.2\x0D\
\0\x14\x12\0\xE7\xB0\"\":\xDA\xB0\"\":\xD9\xB0\"\"\x0D\
\0\x1E\x0A\0\xFD\xB0\"\"\x0D\
\0\x28\x0F\0\xF4\xB0\"23739\",\xAF\"o\"\x0D\
\0\x32\x05\0\xEF\"\xAF\x0D\
\0\x3C\x0B\0\xF9\xC0\xB0\"\"\x0D";	/* loader - fiel for BASIC loader */

	char tap[49152+115], *loader;
	int tap_index = 0;

	loader = loader_template;
	for (i = 1; i<argc; i++) {
		if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
			usage();
			return 0;
		}
		if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
			version();
			return 0;
		}
		if (!strcmp(argv[i], "-o")) {
			foutname_i = ++i;
			continue;
		}
		if (!strcmp(argv[i], "-a")) {
			if (str2int(argv[++i], &address)) {
				fprintf(stderr, "After -a must follow decadic address !\n");
				return 1;
			}
			if (address > 65535) {
				fprintf(stderr, "Maximum number after -a is 65535!\n");
				return 1;
			}
			continue;
		}
		if (!strcmp(argv[i], "-b")) {
			basic = 1;
			continue;
		}
		if (!strcmp(argv[i], "-c")) {
			if (str2int(argv[++i], &clear)) {
				fprintf(stderr, "After -c must follow decadic address !\n");
				return 1;
			}
			if (clear > 65535) {
				fprintf(stderr, "Maximum number after -c is 65535!\n");
				return 1;
			}
			continue;
		}
		if (!strcmp(argv[i], "-r")) {
			if (str2int(argv[++i], &run)) {
				fprintf(stderr, "After -r must follow decadic address !\n");
				return 1;
			}
			if (run > 65535) {
				fprintf(stderr, "Maximum number after -r is 65535!\n");
				return 1;
			}
			continue;
		}
		if (!strcmp(argv[i], "-cb")) {
			if (str2int(argv[++i], &cb)) {
				fprintf(stderr, "After -cb must follow decadic address !\n");
				return 1;
			}
			if (cb > 7) {
				fprintf(stderr, "Maximum number after -cb is 7!\n");
				return 1;
			}
			continue;
		}
		if (!strcmp(argv[i], "-cp")) {
			if (str2int(argv[++i], &cp)) {
				fprintf(stderr, "After -cp must follow decadic address !\n");
				return 1;
			}
			if (cp > 65535) {
				fprintf(stderr, "Maximum number after -cp is 7!\n");
				return 1;
			}
			continue;
		}
		if (!strcmp(argv[i], "-ci")) {
			if (str2int(argv[++i], &ci)) {
				fprintf(stderr, "After -ci must follow decadic address !\n");
				return 1;
			}
			if (ci > 65535) {
				fprintf(stderr, "Maximum number after -ci is 7!\n");
				return 1;
			}
			continue;
		}
		if (!strcmp(argv[i], "-d80")) {
			d80 = 1;
			continue;
		}
		if (!strcmp(argv[i], "-hp") || !strcmp(argv[i], "--header-poke")) {
			hp = 1;
			continue;
		}
		if (!strcmp(argv[i], "-soaz") || !strcmp(argv[i], "--soaz")) {
			printf("Yebo!\n");
			return 1;
		}
		if (!finname_i)
			finname_i = i;
		else {
			fprintf(stderr, "Input only one bin. file!\n");
			return 1;
		}
	}

	if (!finname_i) {
		printf("Enter input filename!\nTry `bin2tap --help` for help.\n");
		return 1;
	}

	if (!foutname_i) {
		strncpy(foutname, argv[finname_i], 255-5);
		foutname[254-5] = '\0';
		i = strlen(foutname);
		no = 0;
		i--;
		while ((no < 4) && (i-no > 0)) {
			if (foutname[i-no] == '.') {
				foutname[i-no] = '\0';
				break;
			}
			++no;
		}
		strcat (foutname, ".tap");
	}
	else {
		strncpy(foutname, argv[foutname_i], 254);
		foutname[254] = '\0';
	}

	finput = fopen(argv[finname_i], "rb");
	if (!finput) {
		printf("Input file open failed!\n");
		return 1;
	}

	foutput = fopen(foutname, "wb+");
	if (!foutput) {
		printf("Output file open failed!\n");
		return 1;
	}

	if (basic) {
		tap_index = 110+d80;
		i = 0;
		while ((*(foutname+i) != '.' && *(foutname+i) != '\0') && i<10) {
			*(tap+tap_index+i) = *(foutname+i);
			i++;
		}
		*(tap+14) = (86+d80+i+19*hp) % 256;
		*(tap+15) = (86+d80+i+19*hp) / 256; 

		tap_index = 0;

		*(tap+tap_index++) = 19;		/* tap lenght */
		*(tap+tap_index++) = 0;
		checksum = *(tap+tap_index++) = 0;	/* 00 - header, FF - data*/
		checksum ^= *(tap+tap_index++) = 0;
		if (d80) {
			for (i = 0; i < 10; i++)
				checksum ^= *(tap+tap_index++) = *(run_name+i);
		}
		else {
			in_name = 1;
			for (i = 0; i < 10; ++i) {			/* filename  */
				if (in_name && (foutname[i] == '.' || foutname[i] == '\0'))
					in_name = 0;
				if (in_name)
					checksum ^= *(tap+tap_index++) = foutname[i];
				else
					checksum ^= *(tap+tap_index++) = ' ';
			}
		}
		checksum ^= *(tap+tap_index++);		/* lenght of data block */
		checksum ^= *(tap+tap_index++);
		checksum ^= *(tap+tap_index++) = 10;	/* param1 - autostart of BASIC */
		checksum ^= *(tap+tap_index++) = 0;
		checksum ^= *(tap+tap_index++) = *(tap+14);	/* param2 - start of variables */
		checksum ^= *(tap+tap_index++) = *(tap+15);
		*(tap+tap_index++) = checksum;

		i = *(tap+15)*256 + *(tap+14) + 2;
		*(tap+tap_index++) = i % 256;
		*(tap+tap_index++) = i / 256;
		checksum = *(tap+tap_index++) = 255;

		l_copy (tap, loader, &tap_index, &checksum, 33);
		loader += 33;
		checksum ^= *(tap+tap_index++) = '0' + cb;
		l_copy (tap, loader, &tap_index, &checksum, 5);
		loader += 5;
		checksum ^= *(tap+tap_index++) = '0' + cp;
		l_copy (tap, loader, &tap_index, &checksum, 5);
		loader += 5;
		checksum ^= *(tap+tap_index++) = '0' + ci;
		l_copy (tap, loader, &tap_index, &checksum, 9);
		loader += 9;
		checksum ^= *(tap+tap_index++) = '0' + clear/10000;
		clear -= 10000 * (clear/10000);
		checksum ^= *(tap+tap_index++) = '0' + clear/1000;
		clear -= 1000 * (clear/1000);
		checksum ^= *(tap+tap_index++) = '0' + clear/100;
		clear -= 100 * (clear/100);
		checksum ^= *(tap+tap_index++) = '0' + clear/10;
		clear -= 10 * (clear/10);
		checksum ^= *(tap+tap_index++) = '0' + clear;
		l_copy (tap, loader, &tap_index, &checksum, 2);
		loader += 2;
		if (hp)
			l_copy (tap, loader, &tap_index, &checksum, 19);
		loader += 19;
		l_copy (tap, loader, &tap_index, &checksum, 5);
		loader += 5;
		checksum ^= *(tap+tap_index-2);
		checksum ^= *(tap+tap_index-3);
		if (d80)
			checksum ^= *(tap+tap_index++) = '*';
		checksum ^= *(tap+tap_index++) = '\"';
		i = 0;
		while (((no = foutname[i]) != '.' && no != '\0') && i<10) {
			checksum ^= *(tap+tap_index++) = no;
			i++;
		}
		checksum ^= *(tap+tap_index-d80-i-4) = (i+d80+5) % 256;	/* dlzka riadku */
		checksum ^= *(tap+tap_index-d80-i-3) = (i+d80+5) / 256;
		l_copy (tap, loader, &tap_index, &checksum, 11);
		loader += 11;
		checksum ^= *(tap+tap_index++) = '0' + run/10000;
		run -= 10000 * (run/10000);
		checksum ^= *(tap+tap_index++) = '0' + run/1000;
		run -= 1000 * (run/1000);
		checksum ^= *(tap+tap_index++) = '0' + run/100;
		run -= 100 * (run/100);
		checksum ^= *(tap+tap_index++) = '0' + run/10;
		run -= 10 * (run/10);
		checksum ^= *(tap+tap_index++) = '0' + run;
		l_copy (tap, loader, &tap_index, &checksum, 2);
		loader += 2;
		*(tap+tap_index++) = checksum;
	}
	*(tap+tap_index++) = 19;	/* bytes header len */
	*(tap+tap_index++) = 0;
	*(tap+tap_index++) = 0;		/* header */
	checksum = *(tap+tap_index++) = 3;		/* bytes file */
	in_name = 1;
	for (i = 0; i < 10; ++i) {	/* filename  */
		if (in_name && (foutname[i] == '.' || foutname[i] == '\0'))
			in_name = 0;
		if (in_name)
			checksum ^= *(tap+tap_index++) = foutname[i];
		else
			checksum ^= *(tap+tap_index++) = ' ';
	}
	inputlen = fread (tap+tap_index+10, 1, 49152, finput);
	if (!feof(finput))
		printf("Warning: File exceed 49151 limit!\n");
	checksum ^= *(tap+tap_index++) = inputlen % 256;
	checksum ^= *(tap+tap_index++) = inputlen / 256;
	checksum ^= *(tap+tap_index++) = address % 256;
	checksum ^= *(tap+tap_index++) = address / 256;
	checksum ^= *(tap+tap_index++) = 0;
	checksum ^= *(tap+tap_index++) = 32768 / 256;
	*(tap+tap_index++) = checksum;

	*(tap+tap_index++) = (inputlen + 2) % 256;
	*(tap+tap_index++) = (inputlen + 2) / 256;
	checksum = *(tap+tap_index++) = 255;
	for (i = 0; i < inputlen; i++)
		checksum ^= *(tap+tap_index++);
	*(tap+tap_index++) = checksum;

	inputlen = fwrite(tap, 1, tap_index, foutput);
	if (ferror(foutput)) {
		printf("Error in save file!\n");
		return 1;
	}
	fclose(finput);
	fclose(foutput);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc1c8, %rsp           # imm = 0xC1C8
movq %rsi, %rbx
movl %edi, %ebp
movl $0x8000, %eax           # imm = 0x8000
leaq 0x18(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x14(%rsp), %rcx
movl $0x5fff, (%rcx)         # imm = 0x5FFF
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x44(%rsp), %rax
andl $0x0, (%rax)
leaq 0x40(%rsp), %rax
andl $0x0, (%rax)
leaq 0xc(%rsp), %rax
andl $0x0, 0x8(%rsp)
movl $0x7, (%rax)
pushq $0x1
popq %r15
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x38(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x4(%rsp)
cmpl %ebp, %r15d
jge 0x15b5
movslq %r15d, %r14
movq (%rbx,%r14,8), %r13
movb (%r13), %r12b
cmpb $0x2d, %r12b
jne 0x1304
cmpb $0x68, 0x1(%r13)
jne 0x1304
cmpb $0x0, 0x2(%r13)
je 0x15a2
movq %r13, %rdi
leaq 0xd01(%rip), %rsi       # 0x200f
callq 0x1070
testl %eax, %eax
je 0x15a2
cmpb $0x2d, %r12b
jne 0x1333
cmpb $0x76, 0x1(%r13)
jne 0x1333
cmpb $0x0, 0x2(%r13)
je 0x15a9
movq %r13, %rdi
leaq 0xcd9(%rip), %rsi       # 0x2016
callq 0x1070
testl %eax, %eax
je 0x15a9
cmpb $0x2d, %r12b
jne 0x13aa
cmpb $0x6f, 0x1(%r13)
jne 0x1362
cmpb $0x0, 0x2(%r13)
je 0x14fd
cmpb $0x61, 0x1(%r13)
jne 0x1374
cmpb $0x0, 0x2(%r13)
je 0x150a
cmpb $0x62, 0x1(%r13)
jne 0x1386
cmpb $0x0, 0x2(%r13)
je 0x1543
cmpb $0x63, 0x1(%r13)
jne 0x1398
cmpb $0x0, 0x2(%r13)
je 0x154c
cmpb $0x72, 0x1(%r13)
jne 0x13aa
cmpb $0x0, 0x2(%r13)
je 0x1572
movq %r13, %rdi
leaq 0xd4d(%rip), %rsi       # 0x2101
callq 0x1070
testl %eax, %eax
je 0x1477
movq %r13, %rdi
leaq 0xd83(%rip), %rsi       # 0x214e
callq 0x1070
testl %eax, %eax
je 0x14a4
movq %r13, %rdi
leaq 0xdb9(%rip), %rsi       # 0x219b
callq 0x1070
testl %eax, %eax
je 0x14d3
movq %r13, %rdi
leaq 0xdef(%rip), %rsi       # 0x21e8
callq 0x1070
testl %eax, %eax
je 0x1539
movq %r13, %rdi
leaq 0xddd(%rip), %rsi       # 0x21ed
callq 0x1070
testl %eax, %eax
je 0x1530
movq %r13, %rdi
leaq 0xdca(%rip), %rsi       # 0x21f1
callq 0x1070
testl %eax, %eax
je 0x1530
movq %r13, %rdi
leaq 0xdc2(%rip), %rsi       # 0x2200
callq 0x1070
testl %eax, %eax
je 0x1793
movq %r13, %rdi
leaq 0xdaa(%rip), %rsi       # 0x21ff
callq 0x1070
testl %eax, %eax
je 0x1793
cmpl $0x0, 0x28(%rsp)
movl %r15d, 0x28(%rsp)
je 0x159a
jmp 0x1fb8
movq 0x8(%rbx,%r14,8), %rdi
leaq 0x44(%rsp), %rsi
callq 0x11cc
testl %eax, %eax
jne 0x1ebd
movl 0x44(%rsp), %eax
movl %eax, 0x48(%rsp)
cmpl $0x8, %eax
jl 0x1597
jmp 0x1ed0
movq 0x8(%rbx,%r14,8), %rdi
leaq 0x40(%rsp), %rsi
callq 0x11cc
testl %eax, %eax
jne 0x1ee3
movl 0x40(%rsp), %eax
movl %eax, 0x3c(%rsp)
cmpl $0x10000, %eax          # imm = 0x10000
jl 0x1597
jmp 0x1ef6
movq 0x8(%rbx,%r14,8), %rdi
leaq 0xc(%rsp), %rsi
callq 0x11cc
testl %eax, %eax
jne 0x1f09
cmpl $0x10000, 0xc(%rsp)     # imm = 0x10000
jl 0x1597
jmp 0x1f21
incl %r15d
movl %r15d, 0x30(%rsp)
jmp 0x159a
movq 0x8(%rbx,%r14,8), %rdi
leaq 0x18(%rsp), %rsi
callq 0x11cc
testl %eax, %eax
jne 0x1f36
cmpl $0x10000, 0x18(%rsp)    # imm = 0x10000
jl 0x1597
jmp 0x1f49
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
jmp 0x159a
pushq $0x1
popq %rax
movq %rax, 0x20(%rsp)
jmp 0x159a
pushq $0x1
popq %rax
movl %eax, 0x38(%rsp)
jmp 0x159a
movq 0x8(%rbx,%r14,8), %rdi
leaq 0x14(%rsp), %rsi
callq 0x11cc
testl %eax, %eax
jne 0x1f5c
cmpl $0x10000, 0x14(%rsp)    # imm = 0x10000
jl 0x1597
jmp 0x1f6f
movq 0x8(%rbx,%r14,8), %rdi
leaq 0x10(%rsp), %rsi
callq 0x11cc
testl %eax, %eax
jne 0x1f82
cmpl $0x10000, 0x10(%rsp)    # imm = 0x10000
jge 0x1f97
incl %r15d
incl %r15d
jmp 0x12d8
callq 0x120a
jmp 0x15ae
callq 0x11fe
xorl %eax, %eax
jmp 0x1e94
movl 0x28(%rsp), %eax
testl %eax, %eax
je 0x15ee
movslq %eax, %r15
movl 0x30(%rsp), %eax
testl %eax, %eax
je 0x15fa
cltq
movq (%rbx,%rax,8), %rsi
leaq 0x50(%rsp), %r14
movl $0xfe, %edx
movq %r14, %rdi
callq 0x1040
movb $0x0, 0xfe(%r14)
movq (%rbx,%r15,8), %rbx
jmp 0x165b
leaq 0xf0b(%rip), %rdi       # 0x2500
jmp 0x1e8c
movq (%rbx,%r15,8), %rbx
leaq 0x50(%rsp), %r14
movl $0xfa, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1040
movb $0x0, 0xf9(%r14)
movq %r14, %rdi
callq 0x1030
decl %eax
xorl %ecx, %ecx
cmpq $0x3, %rcx
ja 0x1644
testl %eax, %eax
jle 0x1644
movl %eax, %edx
incq %rcx
decl %eax
cmpb $0x2e, 0x50(%rsp,%rdx)
jne 0x1627
movb $0x0, 0x50(%rsp,%rdx)
leaq 0x50(%rsp), %rdi
callq 0x1030
movl $0x7061742e, 0x50(%rsp,%rax) # imm = 0x7061742E
movb $0x0, 0x54(%rsp,%rax)
leaq 0xbc4(%rip), %rsi       # 0x2226
movq %rbx, %rdi
callq 0x1060
testq %rax, %rax
je 0x1709
movq %rax, %r14
leaq 0xbac(%rip), %rsi       # 0x2229
leaq 0x50(%rsp), %rdi
callq 0x1060
testq %rax, %rax
je 0x177f
movabsq $0x900000000, %r10      # imm = 0x900000000
movabsq $0x800000000, %r11      # imm = 0x800000000
movabsq $0x700000000, %r12      # imm = 0x700000000
movabsq $0x600000000, %r13      # imm = 0x600000000
movabsq $0x100000000, %rbx      # imm = 0x100000000
cmpl $0x0, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movq %rax, 0x28(%rsp)
je 0x178b
pushq $0x20
popq %rcx
movslq 0x20(%rsp), %rax
addq %rsp, %rax
addq $0x1be, %rax            # imm = 0x1BE
xorl %edx, %edx
movb 0x50(%rsp,%rdx), %sil
cmpb $0x2e, %sil
je 0x1715
cmpq $0x9, %rdx
ja 0x1715
testb %sil, %sil
je 0x1715
movb %sil, (%rax,%rdx)
incq %rdx
jmp 0x16ea
leaq 0xe25(%rip), %rdi       # 0x2535
jmp 0x1e8c
imull $0x13, 0x4(%rsp), %esi
movq 0x20(%rsp), %rdi
leal (%rdi,%rsi), %eax
addl %edx, %eax
addl $0x56, %eax
addl %edi, %esi
addb $0x56, %sil
movzbl %sil, %esi
addl %edx, %esi
movb %sil, 0x15e(%rsp)
movl $0x100, %esi            # imm = 0x100
cltd
idivl %esi
movb %al, 0x15f(%rsp)
movl $0x13, 0x150(%rsp)
testl %edi, %edi
je 0x179f
pushq $0x4
popq %rdx
xorl %eax, %eax
leaq 0x89f(%rip), %rcx       # 0x2004
cmpq $0xe, %rdx
je 0x17e6
movsbl -0x4(%rdx,%rcx), %esi
movb %sil, 0x150(%rsp,%rdx)
incq %rdx
xorl %esi, %eax
jmp 0x1765
leaq 0xdc7(%rip), %rdi       # 0x254d
jmp 0x1e8c
xorl %r8d, %r8d
jmp 0x1c47
leaq 0xe02(%rip), %rdi       # 0x259c
jmp 0x1e8c
pushq $0x1
popq %rsi
xorl %eax, %eax
pushq $0x4
popq %rdx
movl %esi, %edi
cmpq $0xe, %rdx
je 0x17e6
testl %edi, %edi
je 0x17c1
movzbl 0x4c(%rsp,%rdx), %edi
testl %edi, %edi
je 0x17c1
cmpl $0x2e, %edi
jne 0x17d0
movb $0x20, 0x150(%rsp,%rdx)
xorl %edi, %edi
movl %ecx, %r8d
jmp 0x17de
movsbl %dil, %r8d
movb %r8b, 0x150(%rsp,%rdx)
movl %esi, %edi
xorl %r8d, %eax
incq %rdx
jmp 0x17a9
movq %rdx, %rcx
shlq $0x20, %rcx
movslq %edx, %rsi
leaq (%rcx,%rbx), %rdx
sarq $0x20, %rdx
movabsq $0x200000000, %rdi      # imm = 0x200000000
addq %rcx, %rdi
xorb 0x150(%rsp,%rsi), %al
xorb 0x150(%rsp,%rdx), %al
sarq $0x20, %rdi
movb $0xa, %dl
movb %dl, 0x150(%rsp,%rdi)
movb $0xa, %r9b
movabsq $0x300000000, %rdx      # imm = 0x300000000
addq %rcx, %rdx
sarq $0x20, %rdx
movb $0x0, 0x150(%rsp,%rdx)
leaq 0x150(%rsp), %r15
movb 0xe(%r15), %dl
movabsq $0x400000000, %rdi      # imm = 0x400000000
addq %rcx, %rdi
sarq $0x20, %rdi
movb %dl, 0x150(%rsp,%rdi)
movb 0xf(%r15), %dil
movabsq $0x500000000, %r8       # imm = 0x500000000
addq %rcx, %r8
sarq $0x20, %r8
movb %dil, 0x150(%rsp,%r8)
xorb %dil, %dl
xorb %r9b, %dl
xorb %al, %dl
leaq (%rcx,%r13), %rax
sarq $0x20, %rax
movb %dl, 0x150(%rsp,%rax)
movsbl 0xf(%r15), %eax
shll $0x8, %eax
movsbl 0xe(%r15), %edx
addl %edx, %eax
addl $0x2, %eax
addl $0x2, %edx
leaq (%rcx,%r12), %rdi
sarq $0x20, %rdi
movb %dl, 0x150(%rsp,%rdi)
movl $0x100, %edi            # imm = 0x100
cltd
idivl %edi
leaq (%rcx,%r11), %rdx
sarq $0x20, %rdx
movb %al, 0x150(%rsp,%rdx)
addl $0xa, %esi
leaq 0x8(%rsp), %r14
movl %esi, (%r14)
addq %r10, %rcx
sarq $0x20, %rcx
movb $-0x1, 0x150(%rsp,%rcx)
leaq 0x1c(%rsp), %r13
orl $-0x1, (%r13)
leaq 0xcb6(%rip), %rsi       # 0x25b0
pushq $0x21
popq %r8
movq %r15, %rdi
movq %r14, %rdx
movq %r13, %rcx
callq 0x121d
movl 0x48(%rsp), %edx
addb $0x30, %dl
movslq (%r14), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r14)
movb %dl, 0x150(%rsp,%rax)
movsbl %dl, %eax
xorl %eax, (%r13)
leaq 0xca0(%rip), %rsi       # 0x25d1
pushq $0x5
popq %rbp
movq %r15, %rdi
movq %r14, %rdx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x121d
movl 0x3c(%rsp), %edx
addb $0x30, %dl
movslq (%r14), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r14)
movb %dl, 0x150(%rsp,%rax)
movsbl %dl, %eax
xorl %eax, (%r13)
leaq 0xc6c(%rip), %rsi       # 0x25d6
movq %r15, %rdi
movq %r14, %rdx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x121d
movb 0xc(%rsp), %al
addb $0x30, %al
movslq (%r14), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r14)
movb %al, 0x150(%rsp,%rcx)
movsbl %al, %eax
xorl %eax, (%r13)
leaq 0xc3c(%rip), %rsi       # 0x25db
pushq $0x9
popq %r8
movq %r15, %rdi
movq %r14, %rdx
movq %r13, %rcx
callq 0x121d
movl 0x14(%rsp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
addb $0x30, %al
movslq (%r14), %rsi
movsbl %al, %edi
xorl (%r13), %edi
movb %al, 0x150(%rsp,%rsi)
movw $0x3e8, %cx             # imm = 0x3E8
movl %edx, %eax
cwtd
idivw %cx
movl %eax, %ecx
addb $0x30, %cl
movb %cl, 0x151(%rsp,%rsi)
movw $0x64, %r8w
movl %edx, %eax
cwtd
idivw %r8w
movzbl %cl, %ecx
xorl %edi, %ecx
addb $0x30, %al
movb %al, 0x152(%rsp,%rsi)
movzbl %al, %edi
xorl %ecx, %edi
movsbl %dl, %eax
movb $0xa, %cl
idivb %cl
movsbl %ah, %ecx
addb $0x30, %al
movb %al, 0x153(%rsp,%rsi)
movzbl %al, %eax
addb $0x30, %cl
leal 0x5(%rsi), %edx
movl %edx, (%r14)
movb %cl, 0x154(%rsp,%rsi)
movzbl %cl, %ecx
xorl %edi, %ecx
xorl %eax, %ecx
movl %ecx, (%r13)
leaq 0xba5(%rip), %rsi       # 0x25e4
pushq $0x2
popq %r8
movq %r15, %rdi
movq %r14, %rdx
movq %r13, %rcx
callq 0x121d
cmpl $0x0, 0x4(%rsp)
je 0x1a7a
leaq 0xb87(%rip), %rsi       # 0x25e6
leaq 0x150(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
pushq $0x13
popq %r8
callq 0x121d
leaq 0xb78(%rip), %rsi       # 0x25f9
leaq 0x150(%rsp), %r12
leaq 0x8(%rsp), %r15
leaq 0x1c(%rsp), %r13
pushq $0x5
popq %r8
movq %r12, %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0x121d
movl (%r15), %eax
movslq %eax, %rdx
movsbl 0x14e(%rsp,%rdx), %ecx
xorl (%r13), %ecx
movsbl 0x14d(%rsp,%rdx), %esi
xorl %ecx, %esi
cmpl $0x0, 0x20(%rsp)
je 0x1ad8
movb $0x2a, 0x150(%rsp,%rdx)
incq %rdx
xorl $0x2a, %esi
movl %edx, %eax
leal 0x1(%rax), %ecx
movb $0x22, 0x150(%rsp,%rdx)
xorl $0x22, %esi
movslq %ecx, %rdx
addl $0xb, %eax
movl 0x20(%rsp), %edi
subq %rdi, %r12
addq $-0x4, %r12
leaq (%rsp,%rdx), %r8
addq $0x150, %r8             # imm = 0x150
xorl %edi, %edi
pushq $0xa
popq %rdx
cmpq $0xa, %rdi
je 0x1b3a
movb 0x50(%rsp,%rdi), %r9b
movzbl %r9b, %r10d
testl %r10d, %r10d
je 0x1b34
cmpl $0x2e, %r10d
je 0x1b34
movsbl %r9b, %r10d
movb %r9b, (%r8,%rdi)
xorl %r10d, %esi
incq %rdi
decq %r12
jmp 0x1b07
addl %edi, %ecx
movl %ecx, %eax
movl %edi, %edx
leaq 0x8(%rsp), %r15
movl %eax, (%r15)
movq 0x20(%rsp), %rcx
addl %edx, %ecx
addl $0x5, %ecx
movslq %eax, %rdi
movb %cl, (%r12,%rdi)
movl $0x100, %r8d            # imm = 0x100
movl %ecx, %eax
cltd
idivl %r8d
movb %al, 0x1(%r12,%rdi)
xorl %eax, %ecx
movsbl %cl, %eax
xorl %esi, %eax
leaq 0x1c(%rsp), %r12
movl %eax, (%r12)
leaq 0xa83(%rip), %rsi       # 0x25fe
leaq 0x150(%rsp), %r13
pushq $0xb
popq %r8
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x121d
movl 0x10(%rsp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
addb $0x30, %al
movslq (%r15), %rsi
movb %al, 0x150(%rsp,%rsi)
movsbl %al, %edi
xorl (%r12), %edi
movl %edx, %eax
cwtd
movw $0x3e8, %cx             # imm = 0x3E8
idivw %cx
movl %eax, %ecx
addb $0x30, %cl
movb %cl, 0x151(%rsp,%rsi)
movw $0x64, %r8w
movl %edx, %eax
cwtd
idivw %r8w
movzbl %cl, %ecx
xorl %edi, %ecx
addb $0x30, %al
movb %al, 0x152(%rsp,%rsi)
movzbl %al, %edi
xorl %ecx, %edi
movsbl %dl, %eax
movb $0xa, %cl
idivb %cl
movsbl %ah, %ecx
addb $0x30, %al
movb %al, 0x153(%rsp,%rsi)
movzbl %al, %eax
addb $0x30, %cl
leal 0x5(%rsi), %edx
movl %edx, (%r15)
movb %cl, 0x154(%rsp,%rsi)
movzbl %cl, %ecx
xorl %edi, %ecx
xorl %eax, %ecx
movl %ecx, (%r12)
leaq 0x9e6(%rip), %rsi       # 0x2609
pushq $0x2
popq %r8
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x121d
movb (%r12), %al
movslq (%r15), %rcx
leal 0x1(%rcx), %r8d
movb %al, 0x150(%rsp,%rcx)
movslq %r8d, %rax
leal 0x4(%rax), %ecx
movl $0x3000013, 0x150(%rsp,%rax) # imm = 0x3000013
movslq %ecx, %r12
leaq (%rsp,%r12), %rax
addq $0x150, %rax            # imm = 0x150
shlq $0x20, %r12
pushq $0x1
popq %rcx
pushq $0x3
popq %r13
xorl %r14d, %r14d
pushq $0x20
popq %rdx
movl %ecx, %esi
cmpq $0xa, %r14
je 0x1cb1
testl %esi, %esi
je 0x1c91
movzbl 0x50(%rsp,%r14), %esi
testl %esi, %esi
je 0x1c91
cmpl $0x2e, %esi
jne 0x1c9c
movb $0x20, (%rax,%r14)
xorl %esi, %esi
movl %edx, %edi
jmp 0x1ca6
movsbl %sil, %edi
movb %dil, (%rax,%r14)
movl %ecx, %esi
xorl %edi, %r13d
incq %r14
addq %rbx, %r12
jmp 0x1c78
movq %r12, %rax
sarq $0x20, %rax
leaq (%rsp,%rax), %rcx
addq $0x150, %rcx            # imm = 0x150
movq %rcx, 0x48(%rsp)
leaq 0x15a(%rsp,%rax), %rdi
pushq $0x1
popq %rsi
movl $0xc000, %edx           # imm = 0xC000
movl %r8d, %ebx
movq 0x30(%rsp), %rbp
movq %rbp, %rcx
callq 0x1080
movq %rax, %r15
movq %rbp, %rdi
movl %ebx, %ebp
callq 0x10a0
movl %ebx, %ecx
leaq (%rcx,%r14), %rbx
addq $0xe, %rbx
testl %eax, %eax
jne 0x1d0f
leaq 0x85c(%rip), %rdi       # 0x2566
callq 0x1090
movq 0x48(%rsp), %rax
movb %r15b, (%rax)
movl $0x100, %esi            # imm = 0x100
movl %r15d, %eax
cltd
idivl %esi
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %r12, %rcx
sarq $0x20, %rcx
movb %al, 0x150(%rsp,%rcx)
movl 0x18(%rsp), %ecx
movabsq $0x200000000, %rdx      # imm = 0x200000000
addq %r12, %rdx
sarq $0x20, %rdx
movb %cl, 0x150(%rsp,%rdx)
movl %r15d, %edi
xorl %ecx, %edi
xorl %eax, %edi
movl %ecx, %eax
cltd
idivl %esi
movabsq $0x300000000, %rcx      # imm = 0x300000000
addq %r12, %rcx
sarq $0x20, %rcx
movb %al, 0x150(%rsp,%rcx)
xorl %r13d, %edi
xorl %eax, %edi
movabsq $0x400000000, %rax      # imm = 0x400000000
addq %r12, %rax
sarq $0x20, %rax
movb $0x0, 0x150(%rsp,%rax)
movabsq $0x500000000, %rax      # imm = 0x500000000
addq %r12, %rax
sarq $0x20, %rax
movb $-0x80, 0x150(%rsp,%rax)
addb $-0x80, %dil
movabsq $0x600000000, %rax      # imm = 0x600000000
addq %r12, %rax
sarq $0x20, %rax
movb %dil, 0x150(%rsp,%rax)
leal 0x2(%r15), %eax
movabsq $0x700000000, %rcx      # imm = 0x700000000
addq %r12, %rcx
sarq $0x20, %rcx
movb %al, 0x150(%rsp,%rcx)
cltd
idivl %esi
movabsq $0x800000000, %rcx      # imm = 0x800000000
addq %r12, %rcx
sarq $0x20, %rcx
movb %al, 0x150(%rsp,%rcx)
movabsq $0x900000000, %rax      # imm = 0x900000000
addq %r12, %rax
sarq $0x20, %rax
xorl %ecx, %ecx
testl %r15d, %r15d
cmovlel %ecx, %r15d
movb $-0x1, 0x150(%rsp,%rax)
movslq %ebx, %rax
leaq 0x150(%rsp,%rax), %rdx
pushq $-0x1
popq %rax
movq 0x28(%rsp), %rbx
cmpl %ecx, %r15d
je 0x1e4a
movsbl (%rdx,%rcx), %esi
xorl %esi, %eax
incq %rcx
jmp 0x1e3a
addl %ebp, %r15d
leal (%r14,%r15), %ecx
addl $0xe, %ecx
leal 0xf(%r14,%r15), %edx
movslq %ecx, %rcx
movb %al, 0x150(%rsp,%rcx)
movslq %edx, %rdx
leaq 0x150(%rsp), %rdi
pushq $0x1
popq %rsi
movq %rbx, %rcx
callq 0x10c0
movq %rbx, %rdi
callq 0x10b0
testl %eax, %eax
je 0x1ea6
leaq 0x6fc(%rip), %rdi       # 0x2588
callq 0x1090
pushq $0x1
popq %rax
addq $0xc1c8, %rsp           # imm = 0xC1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%rsp), %rdi
callq 0x1050
movq %rbx, %rdi
callq 0x1050
jmp 0x15ae
movq 0x211c(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x237(%rip), %rdi       # 0x2105
jmp 0x1f1a
movq 0x2109(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x24d(%rip), %rdi       # 0x212e
jmp 0x1f32
movq 0x20f6(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x25e(%rip), %rdi       # 0x2152
jmp 0x1f1a
movq 0x20e3(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x274(%rip), %rdi       # 0x217b
jmp 0x1f32
movq 0x20d0(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x285(%rip), %rdi       # 0x219f
pushq $0x28
jmp 0x1faa
movq 0x20b8(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x296(%rip), %rdi       # 0x21c8
pushq $0x1f
jmp 0x1faa
movq 0x20a3(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0xd9(%rip), %rdi        # 0x2020
jmp 0x1f93
movq 0x2090(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0xee(%rip), %rdi        # 0x2048
jmp 0x1fa8
movq 0x207d(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0xfe(%rip), %rdi        # 0x206b
jmp 0x1f93
movq 0x206a(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x113(%rip), %rdi       # 0x2093
jmp 0x1fa8
movq 0x2057(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x123(%rip), %rdi       # 0x20b6
pushq $0x27
jmp 0x1faa
movq 0x2042(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x136(%rip), %rdi       # 0x20de
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
callq 0x10c0
jmp 0x1e91
movq 0x2021(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x23d(%rip), %rdi       # 0x2206
pushq $0x1a
jmp 0x1faa