// File: /workspace/github_c_makefile_star2_O3/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
jge 0x25ac
leaq 0x2080(%rip), %rdi      # 0x4516
callq 0x2040
leaq 0x20ac(%rip), %rdi      # 0x454e
callq 0x2040
leaq 0x20da(%rip), %rdi      # 0x4588
callq 0x2040
leaq 0x2107(%rip), %rdi      # 0x45c1
callq 0x2040
leaq 0x2136(%rip), %rdi      # 0x45fc
callq 0x2040
leaq 0x2136(%rip), %rdi      # 0x4608
callq 0x2040
leaq 0x215f(%rip), %rdi      # 0x463d
callq 0x2040
leaq 0x2198(%rip), %rdi      # 0x4682
callq 0x2040
leaq 0x21c8(%rip), %rdi      # 0x46be
callq 0x2040
leaq 0x2202(%rip), %rdi      # 0x4704
callq 0x2040
leaq 0x223d(%rip), %rdi      # 0x474b
callq 0x2040
leaq 0x2274(%rip), %rdi      # 0x478e
callq 0x2040
leaq 0x22af(%rip), %rdi      # 0x47d5
callq 0x2040
leaq 0x22e5(%rip), %rdi      # 0x4817
callq 0x2040
leaq 0x231d(%rip), %rdi      # 0x485b
callq 0x2040
leaq 0x2318(%rip), %rdi      # 0x4862
callq 0x2040
leaq 0x233c(%rip), %rdi      # 0x4892
callq 0x2040
leaq 0x236f(%rip), %rdi      # 0x48d1
callq 0x2040
leaq 0x23a7(%rip), %rdi      # 0x4915
callq 0x2040
leaq 0x23d6(%rip), %rdi      # 0x4950
callq 0x2040
leaq 0x240b(%rip), %rdi      # 0x4991
callq 0x2040
leaq 0x243a(%rip), %rdi      # 0x49cc
callq 0x2040
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r15
movl %edi, %r12d
movq 0x8(%rsi), %rbx
cmpb $0x2d, (%rbx)
jne 0x25f0
cmpb $0x68, 0x1(%rbx)
jne 0x25cb
cmpb $0x0, 0x2(%rbx)
je 0x248f
leaq 0x1b35(%rip), %rsi      # 0x4107
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x248f
cmpb $0x71, 0x1(%rbx)
jne 0x2607
cmpb $0x0, 0x2(%rbx)
jne 0x2607
jmp 0x2620
leaq 0x1b10(%rip), %rsi      # 0x4107
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x248f
leaq 0x1b00(%rip), %rsi      # 0x410e
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2620
movb $0x1, %bl
xorl %ebp, %ebp
jmp 0x2625
movb $0x1, %bpl
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x3283
cmpl $0x2, %eax
je 0x2642
cmpl $0x1, %eax
jne 0x2659
leaq 0x1ec1(%rip), %rdi      # 0x44fe
jmp 0x2707
leaq 0x1e9e(%rip), %rdi      # 0x44e7
callq 0x2040
movl $0x2, %r14d
jmp 0x259a
movzbl %bpl, %r13d
leal 0x4(%r13), %ebp
cmpl %r12d, %ebp
jbe 0x26ac
incl %r13d
cmpl %r12d, %r13d
jae 0x26a3
movl %r13d, %eax
movq (%r15,%rax,8), %rbx
leaq 0x1a9a(%rip), %rsi      # 0x4116
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2833
leaq 0x1ae6(%rip), %rsi      # 0x4179
movq %rbx, %rdi
callq 0x2090
testl %eax, %eax
je 0x2acd
leaq 0x1cec(%rip), %rdi      # 0x4396
jmp 0x2707
movl %r13d, %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, %r14d
cmovael %ecx, %r14d
movq 0x18(%r15,%r13,8), %rdi
callq 0x20b0
cmpb $0x7, %r14b
jb 0x26f8
leaq 0x1c76(%rip), %rdi      # 0x436c
jmp 0x2707
movzbl %al, %ecx
cmpl $0x20, %ecx
jb 0x2717
leaq 0x1c40(%rip), %rdi      # 0x4347
callq 0x2040
movl $0x1, %r14d
jmp 0x259a
movl %eax, 0x1c(%rsp)
movl %ecx, 0xc(%rsp)
movzbl %r14b, %r14d
movq 0x8(%r15,%r13,8), %rdi
leaq 0x1ac6(%rip), %rsi      # 0x41f5
movq %rdi, 0x20(%rsp)
callq 0x2090
testl %eax, %eax
je 0x2d7f
movq %r14, 0x10(%rsp)
leaq 0x1ac2(%rip), %rsi      # 0x420f
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x2dca
leaq 0x1aae(%rip), %rsi      # 0x4217
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x2e09
leaq 0x1aa0(%rip), %rsi      # 0x4220
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x2e65
leaq 0x1ae1(%rip), %rsi      # 0x4278
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x2eae
leaq 0x1adc(%rip), %rsi      # 0x428a
movq %r14, %rdi
callq 0x2090
xorl %r14d, %r14d
testl %eax, %eax
jne 0x259a
addl $0x5, %r13d
cmpl %r12d, %r13d
ja 0x26a3
movl %ebp, %eax
movq (%r15,%rax,8), %r15
movq %r15, %rdi
callq 0x20b0
movl %eax, %r14d
leaq 0x1aad(%rip), %rsi      # 0x4293
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x314e
leaq 0x1a9c(%rip), %rsi      # 0x4299
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x314e
movzbl (%r15), %eax
cmpl $0x49, %eax
je 0x30ea
cmpl $0x69, %eax
jne 0x30f8
cmpb $0x6e, 0x1(%r15)
je 0x30f1
jmp 0x30f8
leaq 0x1c66(%rip), %rbx      # 0x44a0
movq %rbx, %rdi
callq 0x2040
leaq 0x1ba8(%rip), %r15      # 0x43f1
movq %r15, %rdi
callq 0x2040
leaq 0x1954(%rip), %r12      # 0x41ac
leaq 0x18bf(%rip), %r9       # 0x411e
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x18a5(%rip), %rdx      # 0x4125
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
movq %r12, %r9
callq 0x21cc
leaq 0x188e(%rip), %rdx      # 0x412c
leaq 0x1890(%rip), %r9       # 0x4135
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x187f(%rip), %rdx      # 0x413f
leaq 0x1881(%rip), %r9       # 0x4148
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x186b(%rip), %r9       # 0x414d
movl $0x1, %edi
movl $0x10, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
movl $0x1, %edi
movl $0xf, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
movq %r12, %r9
callq 0x21cc
leaq 0x1837(%rip), %rdx      # 0x4155
leaq 0x1839(%rip), %r9       # 0x415e
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1827(%rip), %rdx      # 0x4167
leaq 0x1829(%rip), %r9       # 0x4170
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
movl $0x3, %edi
movl $0x2, %esi
xorl %edx, %edx
movl $0x1, %ecx
movl $0x2, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x4, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x6, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x5, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0xa, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x7, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0xc, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0xb, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0xe, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0xd, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x12, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0xf, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x14, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x13, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x16, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x15, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x18, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x17, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x3, %edi
movl $0x1b, %esi
xorl %edx, %edx
movl $0x3, %ecx
movl $0x1a, %r8d
xorl %r9d, %r9d
callq 0x21cc
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
movl $0x3, %ecx
movl $0x19, %r8d
xorl %r9d, %r9d
jmp 0x2d65
leaq 0x18d6(%rip), %rbx      # 0x43aa
movq %rbx, %rdi
callq 0x2040
leaq 0x190e(%rip), %r15      # 0x43f1
movq %r15, %rdi
callq 0x2040
leaq 0x16ba(%rip), %r12      # 0x41ac
leaq 0x1688(%rip), %r9       # 0x4181
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xff, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x166e(%rip), %r9       # 0x4188
movl $0x6, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1657(%rip), %r9       # 0x4191
movl $0x6, %edi
movl $0x4, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1641(%rip), %rdx      # 0x419b
leaq 0x163e(%rip), %r9       # 0x419f
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x15b0(%rip), %rdx      # 0x412c
leaq 0x1625(%rip), %r9       # 0x41a8
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x1612(%rip), %rdx      # 0x41b0
leaq 0x1611(%rip), %r9       # 0x41b6
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x15fd(%rip), %rdx      # 0x41bd
leaq 0x15fd(%rip), %r9       # 0x41c4
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x15e9(%rip), %rdx      # 0x41cb
leaq 0x15e9(%rip), %r9       # 0x41d2
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x15d5(%rip), %rdx      # 0x41d9
leaq 0x15d5(%rip), %r9       # 0x41e0
xorl %edi, %edi
movl $0xff, %esi
xorl %ecx, %ecx
movl $0xff, %r8d
callq 0x21cc
leaq 0x15c1(%rip), %rdx      # 0x41e7
leaq 0x15c1(%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
movl $0x6, %edi
movl $0x1, %esi
xorl %edx, %edx
movl $0x1, %ecx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x1, %edi
movl $0x12, %esi
xorl %edx, %edx
movl $0x1, %ecx
movl $0x11, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x4, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0x4, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x4, %edi
movl $0x2, %esi
xorl %edx, %edx
movl $0x4, %ecx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x4, %edi
movl $0x4, %esi
xorl %edx, %edx
movl $0x4, %ecx
movl $0x5, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x4, %edi
movl $0x6, %esi
xorl %edx, %edx
movl $0x4, %ecx
movl $0x7, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x4, %edi
movl $0x8, %esi
xorl %edx, %edx
movl $0x4, %ecx
movl $0x9, %r8d
xorl %r9d, %r9d
callq 0x21cc
movl $0x4, %edi
movl $0xa, %esi
xorl %edx, %edx
movl $0x4, %ecx
movl $0xb, %r8d
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
movq %r15, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2040
jmp 0x259a
movq %r14, %r15
leal 0x41(%r14), %esi
leaq 0x1470(%rip), %rdi      # 0x41fd
xorl %r14d, %r14d
movl 0xc(%rsp), %ebx
movl %ebx, %edx
xorl %eax, %eax
callq 0x2070
leaq 0x4d2c(%rip), %rax      # 0x7ad0
movq (%rax), %rax
movl %r15d, %ecx
leaq 0x4d0d(%rip), %rdx      # 0x7abe
movzbl (%rdx,%rcx), %ecx
movl (%rax,%rcx), %eax
btl %ebx, %eax
jae 0x2e59
leaq 0x157a(%rip), %rdi      # 0x4342
jmp 0x2d75
movq 0x10(%rsp), %rbx
leal 0x41(%rbx), %esi
leaq 0x1424(%rip), %rdi      # 0x41fd
xorl %r14d, %r14d
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2070
movl %ebx, %edi
movl %ebp, %esi
callq 0x32f8
movzbl %al, %edx
movzbl 0x1c(%rsp), %esi
movl %ebx, %edi
callq 0x31bc
movq %rax, %rdi
jmp 0x2d75
movq 0x10(%rsp), %rbx
leal 0x41(%rbx), %esi
leaq 0x13e5(%rip), %rdi      # 0x41fd
xorl %r14d, %r14d
movl 0xc(%rsp), %ebp
movl %ebp, %edx
xorl %eax, %eax
callq 0x2070
movl %ebx, %edi
movl %ebp, %esi
callq 0x3356
cmpb $0x2, %al
je 0x2f43
movzbl %al, %eax
cmpl $0x1, %eax
je 0x2f37
testl %eax, %eax
jne 0x2f4f
leaq 0x14c2(%rip), %rdi      # 0x4316
jmp 0x2592
leaq 0x14de(%rip), %rdi      # 0x433e
jmp 0x2d75
addl $0x5, %r13d
cmpl %r12d, %r13d
ja 0x26a3
movl %ebp, %eax
movq (%r15,%rax,8), %r15
movq %r15, %rdi
callq 0x20b0
movl %eax, %r14d
movzbl (%r15), %eax
cmpl $0x55, %eax
je 0x2f5b
cmpl $0x75, %eax
movq 0x10(%rsp), %r12
jne 0x2f72
cmpb $0x70, 0x1(%r15)
je 0x2f67
jmp 0x2f72
addl $0x5, %r13d
cmpl %r12d, %r13d
ja 0x26a3
movl %ebp, %eax
movq (%r15,%rax,8), %r15
movq %r15, %rdi
callq 0x20b0
movl %eax, %r14d
leaq 0x13ae(%rip), %rsi      # 0x4281
movq %r15, %rdi
callq 0x2090
movb $0x1, %bpl
testl %eax, %eax
je 0x2ff6
leaq 0x1455(%rip), %rsi      # 0x4342
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
movq 0x10(%rsp), %r12
je 0x2ffb
leaq 0x137d(%rip), %rsi      # 0x4286
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2f2f
leaq 0x1422(%rip), %rsi      # 0x433e
movq %r15, %rdi
callq 0x2090
movl %r14d, %ebp
testl %eax, %eax
jne 0x2ffb
movb $0x2, %bpl
jmp 0x2ffb
leaq 0x13c7(%rip), %rdi      # 0x4305
jmp 0x2592
leaq 0x13a8(%rip), %rdi      # 0x42f2
jmp 0x2d75
leaq 0x13d8(%rip), %rdi      # 0x432e
jmp 0x2592
cmpb $0x50, 0x1(%r15)
movq 0x10(%rsp), %r12
jne 0x2f72
cmpb $0x0, 0x2(%r15)
je 0x3035
leaq 0x12b1(%rip), %rsi      # 0x422a
movq %r15, %rdi
callq 0x2090
movb $0x2, %bpl
testl %eax, %eax
je 0x3038
leaq 0x129c(%rip), %rsi      # 0x422f
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x3038
leaq 0x128a(%rip), %rsi      # 0x4234
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2ff2
leaq 0x127f(%rip), %rsi      # 0x423c
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2ff2
leaq 0x1275(%rip), %rsi      # 0x4245
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x2ff2
leaq 0x126a(%rip), %rsi      # 0x424d
movq %r15, %rdi
callq 0x2090
movl %r14d, %ebp
testl %eax, %eax
jne 0x3038
xorl %ebp, %ebp
jmp 0x3038
movq 0x10(%rsp), %r12
testb %bl, %bl
je 0x3099
leal 0x41(%r12), %esi
leaq 0x1247(%rip), %rdi      # 0x4256
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2070
testb %bpl, %bpl
je 0x308d
movzbl %bpl, %eax
cmpl $0x1, %eax
jne 0x30de
leaq 0x129f(%rip), %rdi      # 0x42d2
jmp 0x3094
movb $0x1, %bpl
movzbl %bpl, %r14d
testb %bl, %bl
je 0x3079
leal 0x41(%r12), %esi
leaq 0x120a(%rip), %rdi      # 0x4256
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2070
cmpb $0x2, %bpl
ja 0x306d
leaq 0x19c4(%rip), %rax      # 0x4a28
movslq (%rax,%r14,4), %rdi
addq %rax, %rdi
jmp 0x3074
leaq 0x12ba(%rip), %rdi      # 0x432e
callq 0x2040
movl %r12d, %edi
movl 0xc(%rsp), %esi
movl %r14d, %edx
callq 0x337c
jmp 0x2597
leaq 0x1244(%rip), %rdi      # 0x42d8
callq 0x2040
leaq 0x4a30(%rip), %rax      # 0x7ad0
movq (%rax), %rax
movl %r12d, %esi
leaq 0x4a11(%rip), %rdi      # 0x7abe
movl $0x1, %edx
movl 0x1c(%rsp), %ecx
shll %cl, %edx
movl $0xfffffffe, %r8d       # imm = 0xFFFFFFFE
roll %cl, %r8d
movzbl (%rdi,%rsi), %ecx
andl %r8d, (%rax,%rcx)
xorl %r14d, %r14d
testb $0x1, %bpl
je 0x259a
orl %edx, (%rax,%rcx)
jmp 0x259a
leaq 0x11f8(%rip), %rdi      # 0x42dd
jmp 0x2707
cmpb $0x4e, 0x1(%r15)
jne 0x30f8
cmpb $0x0, 0x2(%r15)
je 0x314e
leaq 0x11a0(%rip), %rsi      # 0x429f
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
movq 0x10(%rsp), %r12
je 0x3149
leaq 0x118f(%rip), %rsi      # 0x42a6
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x3149
leaq 0x1183(%rip), %rsi      # 0x42ad
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
je 0x3149
leaq 0x1174(%rip), %rsi      # 0x42b1
movq %r15, %rdi
callq 0x2090
testl %eax, %eax
jne 0x3156
movb $0x1, %r14b
jmp 0x3156
xorl %r14d, %r14d
movq 0x10(%rsp), %r12
movzbl %r14b, %r15d
testb %bl, %bl
je 0x31a8
leal 0x41(%r12), %esi
leaq 0x10ec(%rip), %rdi      # 0x4256
movl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x2070
cmpb $0x1, %r14b
je 0x3189
testl %r15d, %r15d
jne 0x3197
leaq 0x1144(%rip), %rdi      # 0x42cb
jmp 0x3190
leaq 0x1133(%rip), %rdi      # 0x42c3
callq 0x2040
jmp 0x31a8
leaq 0x1117(%rip), %rdi      # 0x42b5
movl %r15d, %esi
xorl %eax, %eax
callq 0x2070
movl %r12d, %edi
movl 0xc(%rsp), %esi
movl %r15d, %edx
callq 0x3322
jmp 0x2597