// File: /workspace/github_c_makefile_star2_O2/WereCatf[P]Gonzales/gonzales.c
// Function: main
int main(int argc, char* argv[])
{
	uint8_t port, pin, value, quiet;

	if(argc <= 1 || strcmp(argv[1], "-h")==0 || strcmp(argv[1], "--help")==0){
		printf("Chippy Gonzales is a tool for directly manipulating the\n");
		printf("GPIO hardware-registers, including pull-ups/-downs, muxes\n");
		printf("and pin-states. This tool is only intended for those who\n");
		printf("know what they are doing and you can very much mess things\n");
		printf("with this.\n\n");
		printf("YOU ASSUME ALL RESPONSIBILITY FOR USE OF THIS TOOL.\n\n");
		printf("The tool accepts the following commands: readPin, readPull, readMux,\n");
		printf("writePin, writePull, writeMux, header1 and header2. All the\n");
		printf("read-commands follow the same format, ie. `gonzales command port pin`\n");
		printf("where port is a number ranging from 0 to 6 or a character from a to g,\n");
		printf("and pin is 0 to 31. Port 0 corresponds to port A, port 1 to port B\n");
		printf("and so on, and if given as a character, the character can be lowercase\n");
		printf("or uppercase. Example: `gonzales readPin d 25` to read pin PD25.\n\n");
		printf("The format for the write-commands is the same, except for the value\n");
		printf("given:\n");
		printf("`writePin [port] [pin] [low/LOW/high/HIGH/0/1]`\n");
		printf("`writeMux [port] [pin] [in/input/INPUT/out/output/OUTPUT/0-6]`\n");
		printf("  -- 0 means INPUT, 1 means OUTPUT and the rest depends on the pin,\n");
		printf("  and the command takes no human-readable input for those.\n");
		printf("`writePull [port] [pin] [up/UP/down/DOWN/disable/DISABLE/0/1/2]`\n");
		printf("  -- 0 means disable, 1 means pull-up, 2 means pull-down.\n\n");
		printf("The commands `header1` and `header2` do not take any parameters.\n");
		return 0;
	}

	quiet=0;
	if(strcmp(argv[1], "-q")==0 || strcmp(argv[1], "--quiet")==0) quiet=1;

	int error=initGpio();
	if(error==1){
		printf("Error opening /dev/mem!\n");
		return 1;
	} else if(error==2){
		printf("Error mmapping memory!\n");
		return 2;
	}

	if(argc < (4+quiet)){
		if(argc > (1+quiet) && strcmp(argv[1+quiet], "header1")==0){
			printf("      Mux  │ Pull │  Function   J13    Function  │ Pull │  Mux\n");
			printf("      ─────┼──────┼──────────────────────────────┼──────┼─────\n");
			printPair(0, 255, "GND", 0, 255, "CHG-IN");
			printPair(0, 255, "5V Out", 0, 255, "GND");
			printPair(0, 255, "3.3V Out", 0, 255, "Tempsense");
			printPair(0, 255, "1.8V Out", 0, 255, "BAT+");
			printPair(1, 16, NULL, 0, 255, "PWR-BTN");
			printPair(1, 15, NULL, 0, 255, "GND");
			printPair(0, 255, "Touch-X1", 0, 255, "Touch-X2");
			printPair(0, 255, "Touch-Y1", 0, 255, "Touch-Y2");
			printPair(3, 2, NULL, 1, 2, NULL);
			printPair(3, 4, NULL, 3, 3, NULL);
			printPair(3, 6, NULL, 3, 5, NULL);
			printPair(3, 10, NULL, 3, 7, NULL);
			printPair(3, 12, NULL, 3, 11, NULL);
			printPair(3, 14, NULL, 3, 13, NULL);
			printPair(3, 18, NULL, 3, 15, NULL);
			printPair(3, 20, NULL, 3, 19, NULL);
			printPair(3, 22, NULL, 3, 21, NULL);
			printPair(3, 24, NULL, 3, 23, NULL);
			printPair(3, 27, NULL, 3, 26, NULL);
			printPair(0, 255, "GND", 3, 25, NULL);
			printf("      ─────┼──────┼──────────────────────────────┼──────┼─────\n");
			printf("      Mux  │ Pull │  Function   J13    Function  │ Pull │  Mux\n");
			return 0;
		} else
		if(argc > (1+quiet) && strcmp(argv[1+quiet], "header2")==0){
			printf("      Mux  │ Pull │  Function   J14    Function  │ Pull │  Mux\n");
			printf("      ─────┼──────┼──────────────────────────────┼──────┼─────\n");
			printPair(0, 255, "GND", 0, 255, "5V-Out");
			printPair(6, 3, NULL, 0, 255, "Hphone-L");
			printPair(6, 4, NULL, 0, 255, "Hp-common");
			printPair(0, 255, "FEL", 0, 255, "Hphone-R");
			printPair(0, 255, "3.3V Out", 0, 255, "Mic-GND");
			printPair(0, 255, "LRADC", 0, 255, "Mic-in");
			printPair(0, 255, "XIO-P0", 0, 255, "XIO-P1");
			printPair(0, 255, "XIO-P2", 0, 255, "XIO-P3");
			printPair(0, 255, "XIO-P4", 0, 255, "XIO-P5");
			printPair(0, 255, "XIO-P6", 0, 255, "XIO-P7");
			printPair(0, 255, "GND", 0, 255, "GND");
			printPair(6, 1, NULL, 1, 3, NULL);
			printPair(1, 18, NULL, 1, 17, NULL);
			printPair(4, 0, NULL, 4, 1, NULL);
			printPair(4, 2, NULL, 4, 3, NULL);
			printPair(4, 4, NULL, 4, 5, NULL);
			printPair(4, 6, NULL, 4, 7, NULL);
			printPair(4, 8, NULL, 4, 9, NULL);
			printPair(4, 10, NULL, 4, 11, NULL);
			printPair(0, 255, "GND", 0, 255, "GND");
			printf("      ─────┼──────┼──────────────────────────────┼──────┼─────\n");
			printf("      Mux  │ Pull │  Function   J14    Function  │ Pull │  Mux\n");
			return 0;
		}
		printf("Too few parameters!\n");
		return 1;
	}

	port = 255;
	if(*argv[2+quiet] >= 'a' && *argv[2+quiet] <= 'g') port = *argv[2+quiet] - 'a';
	if(*argv[2+quiet] >= 'A' && *argv[2+quiet] <= 'G') port = *argv[2+quiet] - 'A';
	if(*argv[2+quiet] >= '0' && *argv[2+quiet] <= '6') port = *argv[2+quiet] - '0';

	pin = atoi(argv[3+quiet]);
	if(port > 6){
		printf("Port must be in the range of 0-6, or a-g!\n");
		return 1;
	}
	if(pin > 31){
		printf("Pin must be in the range of 0 to 31!\n");
		return 1;
	}

	if(strcmp(argv[1+quiet], "readPin")==0){
		printf("Port %c, pin %d: ", port+'A', pin);
		if(readPin(port, pin)) printf("HIGH\n");
		else printf("LOW\n");
	}
	else if(strcmp(argv[1+quiet], "readMux")==0){
		printf("Port %c, pin %d: ", port+'A', pin);
		value=readMux(port, pin);
		printf("%s\n", muxToString(port, pin, value));
	}
	else if(strcmp(argv[1+quiet], "readPull")==0){
		printf("Port %c, pin %d: ", port+'A', pin);
		switch(readPull(port, pin)){
			case 0:
				printf("pull-up/-down disabled.\n");
				break;
			case 1:
				printf("pull-up enabled.\n");
				break;
			case 2:
				printf("pull-down enabled.\n");
				break;
			default:
				printf("unknown status.\n");
				break;
		}
	}
	else if(strcmp(argv[1+quiet], "writePull")==0){
		if(argc < (5+quiet)){
			printf("Too few parameters!\n");
			return 1;
		}
		value = atoi(argv[4+quiet]);
		if(strcmp(argv[4+quiet], "up")==0 || strcmp(argv[4+quiet], "UP")==0) value=1;
		else if(strcmp(argv[4+quiet], "down")==0 || strcmp(argv[4+quiet], "DOWN")==0) value=2;
		else if(strcmp(argv[4+quiet], "disable")==0 || strcmp(argv[4+quiet], "disabled")==0
			|| strcmp(argv[4+quiet], "DISABLE")==0 || strcmp(argv[4+quiet], "DISABLED")==0) value=0;
		if(!quiet){
			printf("New setting for port %c, pin %d: ", port+'A', pin);
			switch(value){
				case 0:
					printf("pull-up/-down disabled.\n");
					break;
				case 1:
					printf("pull-up enabled.\n");
					break;
				case 2:
					printf("pull-down enabled.\n");
					break;
				default:
					printf("unknown status.\n");
					break;
			}
		}
		writePull(port, pin, value);
	}
	else if(strcmp(argv[1+quiet], "writePin")==0){
		if(argc < (5+quiet)){
			printf("Too few parameters!\n");
			return 1;
		}
		value = atoi(argv[4+quiet]);
		if(strcmp(argv[4+quiet], "high")==0 || strcmp(argv[4+quiet], "HIGH")==0) value=1;
		else if(strcmp(argv[4+quiet], "low")==0 || strcmp(argv[4+quiet], "LOW")==0) value=2;
		if(!quiet){
			printf("New setting for port %c, pin %d: ", port+'A', pin);
			switch(value){
				case 0:
					printf("LOW.\n");
					break;
				case 1:
					printf("HIGH.\n");
					break;
				default:
					printf("unknown value given.\n");
					return 1;
					break;
			}
		}
		writePin(port, pin, value);
	}
	else if(strcmp(argv[1+quiet], "writeMux")==0){
		if(argc < (5+quiet)){
			printf("Too few parameters!\n");
			return 1;
		}
		value = atoi(argv[4+quiet]);
		if(strcmp(argv[4+quiet], "input")==0 || strcmp(argv[4+quiet], "INPUT")==0
			|| strcmp(argv[4+quiet], "in")==0 || strcmp(argv[4+quiet], "IN")==0) value=0;
		else if(strcmp(argv[4+quiet], "output")==0 || strcmp(argv[4+quiet], "OUTPUT")==0
				|| strcmp(argv[4+quiet], "out")==0 || strcmp(argv[4+quiet], "OUT")==0) value=1;
		if(!quiet){
			printf("New setting for port %c, pin %d: ", port+'A', pin);
			switch(value){
				case 0:
					printf("INPUT.\n");
					break;
				case 1:
					printf("OUTPUT.\n");
					break;
				default:
					printf("altmux 0x%x.\n", value);
					break;
			}
		}
		writeMux(port, pin, value);
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x2, %edi
jl 0x24ef
movq %rsi, %r15
movl %edi, %r12d
movq 0x8(%rsi), %rbx
movb (%rbx), %bpl
cmpb $0x2d, %bpl
jne 0x24a5
cmpb $0x68, 0x1(%rbx)
jne 0x24a5
cmpb $0x0, 0x2(%rbx)
je 0x24ef
leaq 0x1c5b(%rip), %rsi      # 0x4107
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x24ef
cmpb $0x2d, %bpl
jne 0x24ce
cmpb $0x71, 0x1(%rbx)
jne 0x24ce
cmpb $0x0, 0x2(%rbx)
je 0x25fe
leaq 0x1c39(%rip), %rsi      # 0x410e
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x25fe
movb $0x1, %r13b
xorl %ebx, %ebx
jmp 0x2603
leaq 0x2020(%rip), %rdi      # 0x4516
callq 0x2040
leaq 0x204c(%rip), %rdi      # 0x454e
callq 0x2040
leaq 0x207a(%rip), %rdi      # 0x4588
callq 0x2040
leaq 0x20a7(%rip), %rdi      # 0x45c1
callq 0x2040
leaq 0x20d6(%rip), %rdi      # 0x45fc
callq 0x2040
leaq 0x20d6(%rip), %rdi      # 0x4608
callq 0x2040
leaq 0x20ff(%rip), %rdi      # 0x463d
callq 0x2040
leaq 0x2138(%rip), %rdi      # 0x4682
callq 0x2040
leaq 0x2168(%rip), %rdi      # 0x46be
callq 0x2040
leaq 0x21a2(%rip), %rdi      # 0x4704
callq 0x2040
leaq 0x21dd(%rip), %rdi      # 0x474b
callq 0x2040
leaq 0x2214(%rip), %rdi      # 0x478e
callq 0x2040
leaq 0x224f(%rip), %rdi      # 0x47d5
callq 0x2040
leaq 0x2285(%rip), %rdi      # 0x4817
callq 0x2040
leaq 0x22bd(%rip), %rdi      # 0x485b
callq 0x2040
leaq 0x22b8(%rip), %rdi      # 0x4862
callq 0x2040
leaq 0x22dc(%rip), %rdi      # 0x4892
callq 0x2040
leaq 0x230f(%rip), %rdi      # 0x48d1
callq 0x2040
leaq 0x2347(%rip), %rdi      # 0x4915
callq 0x2040
leaq 0x2376(%rip), %rdi      # 0x4950
callq 0x2040
leaq 0x23ab(%rip), %rdi      # 0x4991
callq 0x2040
leaq 0x23da(%rip), %rdi      # 0x49cc
callq 0x2040
xorl %ebx, %ebx
jmp 0x26ef
movb $0x1, %bl
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3194
cmpl $0x2, %eax
je 0x2620
cmpl $0x1, %eax
jne 0x2633
leaq 0x1ee3(%rip), %rdi      # 0x44fe
jmp 0x26e7
leaq 0x1ec0(%rip), %rdi      # 0x44e7
callq 0x2040
pushq $0x2
jmp 0x26ee
movzbl %bl, %r14d
leal 0x4(%r14), %ebp
cmpl %r12d, %ebp
jbe 0x2686
incl %r14d
cmpl %r12d, %r14d
jae 0x267d
movl %r14d, %eax
movq (%r15,%rax,8), %rbx
leaq 0x1ac0(%rip), %rsi      # 0x4116
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x281a
leaq 0x1b0c(%rip), %rsi      # 0x4179
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2a52
leaq 0x1d12(%rip), %rdi      # 0x4396
jmp 0x26e7
movl %r13d, 0x1c(%rsp)
movl %r14d, %eax
movq 0x10(%r15,%rax,8), %rax
movb (%rax), %al
leal -0x61(%rax), %ecx
cmpb $0x7, %cl
movzbl %cl, %ecx
movl $0xff, %edx
cmovbl %ecx, %edx
leal -0x41(%rax), %ecx
cmpb $0x7, %cl
movzbl %cl, %ecx
cmovael %edx, %ecx
addb $-0x30, %al
cmpb $0x7, %al
movzbl %al, %ebx
cmovael %ecx, %ebx
movq 0x18(%r15,%r14,8), %rdi
callq 0x20b0
cmpb $0x7, %bl
jb 0x26d4
leaq 0x1c9a(%rip), %rdi      # 0x436c
jmp 0x26e7
movl %eax, %r13d
movzbl %r13b, %eax
cmpl $0x20, %eax
jb 0x2700
leaq 0x1c60(%rip), %rdi      # 0x4347
callq 0x2040
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, 0xc(%rsp)
movzbl %bl, %ebx
movq 0x8(%r15,%r14,8), %rdi
leaq 0x1ae2(%rip), %rsi      # 0x41f5
movq %rdi, 0x20(%rsp)
callq 0x2090
testl %eax, %eax
je 0x2cb8
movq %rbx, 0x10(%rsp)
leaq 0x1ade(%rip), %rsi      # 0x420f
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2d04
leaq 0x1aca(%rip), %rsi      # 0x4217
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2d44
leaq 0x1abc(%rip), %rsi      # 0x4220
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2da1
leaq 0x1afd(%rip), %rsi      # 0x4278
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
movl 0x1c(%rsp), %r13d
je 0x2dee
leaq 0x1af3(%rip), %rsi      # 0x428a
movq %rbx, %rdi
callq 0x2090
xorl %ebx, %ebx
testl %eax, %eax
jne 0x26ef
addl $0x5, %r14d
cmpl %r12d, %r14d
ja 0x267d
movl %ebp, %eax
movq (%r15,%rax,8), %r15
movq %r15, %rdi
callq 0x20b0
movl %eax, %ebx
leaq 0x1ac6(%rip), %rsi      # 0x4293
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f38
leaq 0x1ab5(%rip), %rsi      # 0x4299
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f38
movzbl (%r15), %eax
cmpl $0x49, %eax
je 0x3001
cmpl $0x69, %eax
jne 0x3013
cmpb $0x6e, 0x1(%r15)
je 0x3008
jmp 0x3013
leaq 0x1c7f(%rip), %rdi      # 0x44a0
callq 0x2040
leaq 0x1bc4(%rip), %r15      # 0x43f1
movq %r15, %rdi
callq 0x2040
leaq 0x1970(%rip), %r12      # 0x41ac
leaq 0x18db(%rip), %r9       # 0x411e
xorl %ebx, %ebx
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x18c2(%rip), %rdx      # 0x4125
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
movq %r12, %r9
callq 0x21cc
leaq 0x18ab(%rip), %rdx      # 0x412c
leaq 0x18ad(%rip), %r9       # 0x4135
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x189c(%rip), %rdx      # 0x413f
leaq 0x189e(%rip), %r9       # 0x4148
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1888(%rip), %r9       # 0x414d
pushq $0x1
popq %r14
pushq $0x10
popq %rsi
movl %r14d, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
pushq $0xf
popq %r13
movl %r14d, %edi
movl %r13d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %r12, %r9
callq 0x21cc
leaq 0x1854(%rip), %rdx      # 0x4155
leaq 0x1856(%rip), %r9       # 0x415e
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1844(%rip), %rdx      # 0x4167
leaq 0x1846(%rip), %r9       # 0x4170
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
pushq $0x3
popq %rbp
pushq $0x2
popq %rsi
movl %ebp, %edi
xorl %edx, %edx
movl %r14d, %ecx
movl %esi, %r8d
xorl %r9d, %r9d
callq 0x21cc
pushq $0x4
popq %rsi
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x21cc
pushq $0x6
popq %rsi
pushq $0x5
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0xa
popq %rsi
pushq $0x7
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0xc
popq %rsi
pushq $0xb
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0xe
popq %rsi
pushq $0xd
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x12
popq %rsi
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0x21cc
pushq $0x14
popq %rsi
pushq $0x13
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x16
popq %rsi
pushq $0x15
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x18
popq %rsi
pushq $0x17
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x1b
popq %rsi
pushq $0x1a
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x19
popq %r8
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
movq %r15, %rdi
callq 0x2040
leaq 0x1a53(%rip), %rdi      # 0x44a0
jmp 0x2e88
leaq 0x1951(%rip), %rdi      # 0x43aa
callq 0x2040
leaq 0x198c(%rip), %rdi      # 0x43f1
callq 0x2040
leaq 0x173b(%rip), %r12      # 0x41ac
leaq 0x1709(%rip), %r9       # 0x4181
xorl %ebx, %ebx
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x16f0(%rip), %r9       # 0x4188
pushq $0x6
popq %r13
pushq $0x3
popq %r14
movl %r13d, %edi
movl %r14d, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x16d5(%rip), %r9       # 0x4191
pushq $0x4
popq %rbp
movl %r13d, %edi
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x16c1(%rip), %rdx      # 0x419b
leaq 0x16be(%rip), %r9       # 0x419f
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1630(%rip), %rdx      # 0x412c
leaq 0x16a5(%rip), %r9       # 0x41a8
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1692(%rip), %rdx      # 0x41b0
leaq 0x1691(%rip), %r9       # 0x41b6
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x167d(%rip), %rdx      # 0x41bd
leaq 0x167d(%rip), %r9       # 0x41c4
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1669(%rip), %rdx      # 0x41cb
leaq 0x1669(%rip), %r9       # 0x41d2
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1655(%rip), %rdx      # 0x41d9
leaq 0x1655(%rip), %r9       # 0x41e0
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1641(%rip), %rdx      # 0x41e7
leaq 0x1641(%rip), %r9       # 0x41ee
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %r12, %r9
callq 0x21cc
pushq $0x1
popq %r15
movl %r13d, %edi
movl %r15d, %esi
xorl %edx, %edx
movl %r15d, %ecx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0x21cc
pushq $0x12
popq %rsi
pushq $0x11
popq %r8
movl %r15d, %edi
xorl %edx, %edx
movl %r15d, %ecx
xorl %r9d, %r9d
callq 0x21cc
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0x21cc
pushq $0x2
popq %rsi
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0x21cc
pushq $0x5
popq %r8
movl %ebp, %edi
movl %ebp, %esi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x7
popq %r8
movl %ebp, %edi
movl %r13d, %esi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0x8
popq %rsi
pushq $0x9
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
pushq $0xa
popq %rsi
pushq $0xb
popq %r8
movl %ebp, %edi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r9d, %r9d
callq 0x21cc
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %r12, %r9
callq 0x21cc
leaq 0x174a(%rip), %rdi      # 0x43f1
callq 0x2040
leaq 0x16f7(%rip), %rdi      # 0x43aa
jmp 0x2e88
movq %rbx, %r14
leal 0x41(%rbx), %esi
leaq 0x1538(%rip), %rdi      # 0x41fd
xorl %ebx, %ebx
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2070
leaq 0x4df5(%rip), %rax      # 0x7ad0
movq (%rax), %rax
movl %r14d, %ecx
leaq 0x4dd6(%rip), %rdx      # 0x7abe
movzbl (%rdx,%rcx), %ecx
movl (%rax,%rcx), %eax
btl %ebp, %eax
jae 0x2d95
leaq 0x1643(%rip), %rdi      # 0x4342
jmp 0x2e88
movq 0x10(%rsp), %r14
leal 0x41(%r14), %esi
leaq 0x14e9(%rip), %rdi      # 0x41fd
xorl %ebx, %ebx
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2070
movl %r14d, %edi
movl %ebp, %esi
callq 0x3200
movzbl %al, %edx
movzbl %r13b, %esi
movl %r14d, %edi
callq 0x30e0
movq %rax, %rdi
jmp 0x2e88
movq 0x10(%rsp), %r14
leal 0x41(%r14), %esi
leaq 0x14a9(%rip), %rdi      # 0x41fd
xorl %ebx, %ebx
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2070
movl %r14d, %edi
movl %ebp, %esi
callq 0x3254
cmpb $0x2, %al
je 0x2e81
movzbl %al, %eax
cmpl $0x1, %eax
je 0x2e75
testl %eax, %eax
jne 0x2e92
leaq 0x1586(%rip), %rdi      # 0x4316
jmp 0x25f2
leaq 0x15a2(%rip), %rdi      # 0x433e
jmp 0x2e88
addl $0x5, %r14d
cmpl %r12d, %r14d
movl 0x1c(%rsp), %r12d
ja 0x267d
movl %ebp, %eax
movq (%r15,%rax,8), %r15
movq %r15, %rdi
callq 0x20b0
movl %eax, %ebx
movzbl (%r15), %eax
cmpl $0x55, %eax
je 0x2e9e
cmpl $0x75, %eax
movq 0x10(%rsp), %r14
jne 0x2eb5
cmpb $0x70, 0x1(%r15)
je 0x2eaa
jmp 0x2eb5
addl $0x5, %r14d
cmpl %r12d, %r14d
ja 0x267d
movl %ebp, %eax
movq (%r15,%rax,8), %r15
movq %r15, %rdi
callq 0x20b0
movl %eax, %ebx
leaq 0x146f(%rip), %rsi      # 0x4281
movq %r15, %rdi
callq 0x2090
movb $0x1, %bpl
testl %eax, %eax
je 0x2f44
leaq 0x1516(%rip), %rsi      # 0x4342
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
movq 0x10(%rsp), %r14
je 0x2f49
leaq 0x143e(%rip), %rsi      # 0x4286
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2e6d
leaq 0x14e3(%rip), %rsi      # 0x433e
movq %r15, %rdi
callq 0x2090
movl %ebx, %ebp
testl %eax, %eax
jne 0x2f49
movb $0x2, %bpl
jmp 0x2f49
leaq 0x1489(%rip), %rdi      # 0x4305
jmp 0x25f2
leaq 0x146a(%rip), %rdi      # 0x42f2
callq 0x2040
jmp 0x26ef
leaq 0x1495(%rip), %rdi      # 0x432e
jmp 0x25f2
cmpb $0x50, 0x1(%r15)
movq 0x10(%rsp), %r14
jne 0x2eb5
cmpb $0x0, 0x2(%r15)
je 0x2f7f
leaq 0x136e(%rip), %rsi      # 0x422a
movq %r15, %rdi
callq 0x2090
movb $0x2, %bpl
testl %eax, %eax
je 0x2f82
leaq 0x1359(%rip), %rsi      # 0x422f
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f82
leaq 0x1347(%rip), %rsi      # 0x4234
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f34
leaq 0x133c(%rip), %rsi      # 0x423c
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f34
leaq 0x1332(%rip), %rsi      # 0x4245
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f34
leaq 0x1327(%rip), %rsi      # 0x424d
movq %r15, %rdi
callq 0x2090
movl %ebx, %ebp
testl %eax, %eax
jne 0x2f82
xorl %ebp, %ebp
jmp 0x2f82
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
jmp 0x306b
movq 0x10(%rsp), %r14
movzbl %bpl, %ebx
testb %r13b, %r13b
je 0x2fe2
leal 0x41(%r14), %esi
leaq 0x12f5(%rip), %rdi      # 0x4256
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2070
testb %bpl, %bpl
je 0x2fd6
cmpl $0x1, %ebx
jne 0x2ff5
leaq 0x1355(%rip), %rdi      # 0x42d2
jmp 0x2fdd
movb $0x1, %bpl
movzbl %bpl, %ebx
testb %r12b, %r12b
je 0x2fc3
leal 0x41(%r14), %esi
leaq 0x12c0(%rip), %rdi      # 0x4256
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2070
cmpb $0x2, %bpl
ja 0x2fb7
leaq 0x1a7a(%rip), %rax      # 0x4a28
movslq (%rax,%rbx,4), %rdi
addq %rax, %rdi
jmp 0x2fbe
leaq 0x1370(%rip), %rdi      # 0x432e
callq 0x2040
movl %r14d, %edi
movl 0xc(%rsp), %esi
movl %ebx, %edx
callq 0x3276
jmp 0x25f7
leaq 0x12fb(%rip), %rdi      # 0x42d8
callq 0x2040
movl %r14d, %edi
movl 0xc(%rsp), %esi
movl %ebx, %edx
callq 0x3345
jmp 0x25f7
leaq 0x12e1(%rip), %rdi      # 0x42dd
jmp 0x26e7
cmpb $0x4e, 0x1(%r15)
jne 0x3013
cmpb $0x0, 0x2(%r15)
je 0x30d0
leaq 0x1285(%rip), %rsi      # 0x429f
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
movq 0x10(%rsp), %r14
movl 0x1c(%rsp), %r13d
je 0x3069
leaq 0x126f(%rip), %rsi      # 0x42a6
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x3069
leaq 0x1263(%rip), %rsi      # 0x42ad
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x3069
leaq 0x1254(%rip), %rsi      # 0x42b1
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
jne 0x306b
movb $0x1, %bl
movzbl %bl, %r15d
testb %r13b, %r13b
je 0x30bc
leal 0x41(%r14), %esi
leaq 0x11d7(%rip), %rdi      # 0x4256
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2070
cmpb $0x1, %bl
je 0x309d
testl %r15d, %r15d
jne 0x30ab
leaq 0x1230(%rip), %rdi      # 0x42cb
jmp 0x30a4
leaq 0x121f(%rip), %rdi      # 0x42c3
callq 0x2040
jmp 0x30bc
leaq 0x1203(%rip), %rdi      # 0x42b5
movl %r15d, %esi
xorl %eax, %eax
callq 0x2070
movl %r14d, %edi
movl 0xc(%rsp), %esi
movl %r15d, %edx
callq 0x3226
jmp 0x25f7
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
movl 0x1c(%rsp), %r13d
jmp 0x306b
nop