// File: sanaa-khan[P]mini-linux-shell/gbsh.cpp
// Function: executeProgram(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>)
void executeProgram(vector<string> tokens) {

	bool outputRedirection = false, inputRedirection = false;

	for (int i = 0; i < tokens.size(); i++) { // detecting if output/input redirection required

		if (tokens[i].size() == 1) {

			if (tokens[i][0] == '>')
				outputRedirection = true;

			else if (tokens[i][0] == '<')
				inputRedirection = true;
		}
	}

	string cmd = tokens[0];
	int noOfArguments = 0;
	string outputFile, inputFile;
	char** arg;

	if (!inputRedirection and outputRedirection) { 
		for (int i = 1; i < tokens.size(); i++) {
			if (tokens[i].size() == 1 and tokens[i][0] == '>') {
				if (i == tokens.size() - 1) {
					cout << "\033[1;31m" << "Error: ";
					cout << "\033[0;38m" << "Output file not provided.\n";
					return;
				}

				else {
					outputFile = tokens[i + 1];
					break;
				}
			}

			else {
				noOfArguments++;
			}
		}

		arg = new char*[noOfArguments + 2];
		arg[0] = new char[20];

		strcpy(arg[0], cmd.c_str());
		arg[noOfArguments + 1] = nullptr;

		for (int i = 1; i <= noOfArguments; i++) {
			arg[i] = new char[20];
			strcpy(arg[i], tokens[i].c_str());
		}

		int file_desc = open(outputFile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0777);
		output = dup(1);

		close(1);
		dup(file_desc);
		close(file_desc);

		oRedirect = true;
	}

	else if (inputRedirection and outputRedirection) {
		int i;
		for (i = 1; i < tokens.size(); i++) {
			if (tokens[i].size() == 1 and tokens[i][0] == '<') {
				if (i == tokens.size() - 1) {
					cout << "\033[1;31m" << "Error: ";
					cout << "\033[0;38m" << "Input file not provided.\n";
					return;
				}

				else {
					i++;
					inputFile = tokens[i];
					i++;
					break;
				}
			}

			else {
				noOfArguments++;
			}
		}

		for (i = 1; i < tokens.size(); i++) {
			if (tokens[i].size() == 1 and tokens[i][0] == '>') {
				if (i == tokens.size() - 1) {
					cout << "\033[1;31m" << "Error: ";
					cout << "\033[0;38m" << "Output file not provided.\n";
					return;
				}

				else {
					outputFile = tokens[i + 1];
					break;
				}
			}
		}

		arg = new char*[noOfArguments + 2];
		arg[0] = new char[20];

		strcpy(arg[0], cmd.c_str());
		arg[noOfArguments + 1] = nullptr;

		for (int j = 1; j <= noOfArguments; j++) {
			arg[j] = new char[20];
			strcpy(arg[j], tokens[j].c_str());
		}

		int file_desc = open(outputFile.c_str(), O_WRONLY | O_CREAT |  O_TRUNC, 0777);
		output = dup(1);

		close(1);
		dup(file_desc);
		close(file_desc);
		
		oRedirect = true;

		int file_desc2 = open(inputFile.c_str(), O_WRONLY | 0777);
		input = dup(0);

		close(0);
		dup(file_desc2);
		close(file_desc2);

		iRedirect = true;
	}

	else if (!inputRedirection and !outputRedirection) {
		noOfArguments = tokens.size() - 1;
		char* arg[noOfArguments + 2];

		for (int i = 0; i <= noOfArguments; i++)
			arg[i] = new char[20];
			
		strcpy(arg[0], cmd.c_str());

		int i;
		for (i = 1; i <= noOfArguments; i++) {
			strcpy(arg[i], tokens[i].c_str());
		}

		arg[i] = NULL;
	}

	if (cmd == "top") {
		char path[50];
		getcwd(path, 50);

		chdir("/usr/bin");
		execl("top", "top", NULL);
		chdir(path);
	}

	else if (cmd == "man") {
		char path[50];
		getcwd(path, 50);

		chdir("/usr/bin");

		if (tokens.size() > 1)
			execl("man", "man", tokens[1].c_str(), NULL);
		else
			execl("man", "man", NULL);

		chdir(path);
	}

	else if (cmd == "ps") {
		char path[50];
		getcwd(path, 50);

		chdir("/usr/bin");

		if (tokens.size() > 1)
			execl("ps", "ps", tokens[1].c_str(), NULL);
		else
			execl("ps", "ps", NULL);

		chdir(path);
	}

	else {
		if (execvp(arg[0], arg) < 0) {
			cout << "\033[1;31m" << "Error: ";
			cout << "\033[0;38m" << "'" << arg[0] << "' not found.\n";
			
			for (int i = 0; i < noOfArguments + 2; i++)
				delete []arg[i];

			exit(0);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x190(%rbp)
movq %rdi, -0x8(%rbp)
movb $0x0, -0x9(%rbp)
movb $0x0, -0xa(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x190(%rbp), %rdi
movslq -0x10(%rbp), %rax
movq %rax, -0x198(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x198(%rbp), %rax
cmpq %rcx, %rax
jae 0x4783
movq -0x190(%rbp), %rdi
movslq -0x10(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x2120
cmpq $0x1, %rax
jne 0x4773
movq -0x190(%rbp), %rdi
movslq -0x10(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2340
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x4747
movb $0x1, -0x9(%rbp)
jmp 0x4771
movq -0x190(%rbp), %rdi
movslq -0x10(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2340
movsbl (%rax), %eax
cmpl $0x3c, %eax
jne 0x476f
movb $0x1, -0xa(%rbp)
jmp 0x4771
jmp 0x4773
jmp 0x4775
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x46d5
movq -0x190(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5760
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x20c0
movl $0x0, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2260
leaq -0x78(%rbp), %rdi
callq 0x2260
testb $0x1, -0xa(%rbp)
jne 0x4b1a
testb $0x1, -0x9(%rbp)
je 0x4b1a
movl $0x1, -0x84(%rbp)
movq -0x190(%rbp), %rdi
movslq -0x84(%rbp), %rax
movq %rax, -0x1a0(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x1a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x497d
movq -0x190(%rbp), %rdi
movslq -0x84(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x2120
cmpq $0x1, %rax
jne 0x495e
movq -0x190(%rbp), %rdi
movslq -0x84(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2340
movq %rax, -0x1a8(%rbp)
jmp 0x4850
movq -0x1a8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x495e
movq -0x190(%rbp), %rdi
movslq -0x84(%rbp), %rax
movq %rax, -0x1b0(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x1b0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x4937
movq 0x572d(%rip), %rdi      # 0x9fc8
leaq 0x27c3(%rip), %rsi      # 0x7065
callq 0x21b0
movq %rax, -0x1b8(%rbp)
jmp 0x48b0
movq -0x1b8(%rbp), %rdi
leaq 0x27af(%rip), %rsi      # 0x706d
callq 0x21b0
jmp 0x48c5
movq 0x56fc(%rip), %rdi      # 0x9fc8
leaq 0x27a2(%rip), %rsi      # 0x7075
callq 0x21b0
movq %rax, -0x1c0(%rbp)
jmp 0x48e1
movq -0x1c0(%rbp), %rdi
leaq 0x278e(%rip), %rsi      # 0x707d
callq 0x21b0
jmp 0x48f6
movl $0x1, -0x98(%rbp)
jmp 0x5480
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2100
leaq -0x58(%rbp), %rdi
callq 0x2100
leaq -0x30(%rbp), %rdi
callq 0x2100
jmp 0x54a0
movq -0x190(%rbp), %rdi
movl -0x84(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x5760
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x2040
jmp 0x495c
jmp 0x497d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4969
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x47d6
movl -0x34(%rbp), %eax
addl $0x2, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x1c8(%rbp)
jmp 0x49a9
movq -0x1c8(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x14, %edi
callq 0x2030
movq %rax, -0x1d0(%rbp)
jmp 0x49c7
movq -0x1d0(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, (%rax)
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x20b0
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x21a0
movq -0x80(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x1, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x4aa2
movl $0x14, %edi
callq 0x2030
movq %rax, -0x1e0(%rbp)
jmp 0x4a38
movq -0x190(%rbp), %rdi
movq -0x1e0(%rbp), %rdx
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1e8(%rbp)
movslq -0x9c(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x20b0
movq -0x1e8(%rbp), %rdi
movq %rax, %rsi
callq 0x21a0
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x4a1a
leaq -0x58(%rbp), %rdi
callq 0x20b0
movq %rax, %rdi
xorl %eax, %eax
movl $0x241, %esi            # imm = 0x241
movl $0x1ff, %edx            # imm = 0x1FF
callq 0x2130
movl %eax, -0x1ec(%rbp)
jmp 0x4ac7
movl -0x1ec(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl $0x1, %edi
movl %edi, -0x1f0(%rbp)
callq 0x22c0
movl -0x1f0(%rbp), %edi
movl %eax, 0x56d9(%rip)      # 0xa1c8
callq 0x2330
jmp 0x4af6
movl -0xa0(%rbp), %edi
callq 0x22c0
movl -0xa0(%rbp), %edi
callq 0x2330
jmp 0x4b0e
movb $0x1, 0x56bb(%rip)      # 0xa1d0
jmp 0x519c
testb $0x1, -0xa(%rbp)
je 0x503c
testb $0x1, -0x9(%rbp)
je 0x503c
movl $0x1, -0xa4(%rbp)
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rax
movq %rax, -0x1f8(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x1f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x4cc2
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x2120
cmpq $0x1, %rax
jne 0x4ca3
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2340
movq %rax, -0x200(%rbp)
jmp 0x4bb2
movq -0x200(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3c, %eax
jne 0x4ca3
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rax
movq %rax, -0x208(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x208(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x4c63
movq 0x53cf(%rip), %rdi      # 0x9fc8
leaq 0x2465(%rip), %rsi      # 0x7065
callq 0x21b0
movq %rax, -0x210(%rbp)
jmp 0x4c0e
movq -0x210(%rbp), %rdi
leaq 0x2451(%rip), %rsi      # 0x706d
callq 0x21b0
jmp 0x4c23
movq 0x539e(%rip), %rdi      # 0x9fc8
leaq 0x2444(%rip), %rsi      # 0x7075
callq 0x21b0
movq %rax, -0x218(%rbp)
jmp 0x4c3f
movq -0x218(%rbp), %rdi
leaq 0x251e(%rip), %rsi      # 0x716b
callq 0x21b0
jmp 0x4c54
movl $0x1, -0x98(%rbp)
jmp 0x5480
movq -0x190(%rbp), %rdi
movl -0xa4(%rbp), %eax
incl %eax
movl %eax, -0xa4(%rbp)
movslq -0xa4(%rbp), %rsi
callq 0x5760
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x2040
jmp 0x4c92
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x4cc2
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4cae
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x4b38
movl $0x1, -0xa4(%rbp)
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rax
movq %rax, -0x220(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x220(%rbp), %rax
cmpq %rcx, %rax
jae 0x4e34
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x2120
cmpq $0x1, %rax
jne 0x4e1e
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2340
movq %rax, -0x228(%rbp)
jmp 0x4d46
movq -0x228(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x4e1e
movq -0x190(%rbp), %rdi
movslq -0xa4(%rbp), %rax
movq %rax, -0x230(%rbp)
callq 0x5780
movq %rax, %rcx
movq -0x230(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x4df7
movq 0x523b(%rip), %rdi      # 0x9fc8
leaq 0x22d1(%rip), %rsi      # 0x7065
callq 0x21b0
movq %rax, -0x238(%rbp)
jmp 0x4da2
movq -0x238(%rbp), %rdi
leaq 0x22bd(%rip), %rsi      # 0x706d
callq 0x21b0
jmp 0x4db7
movq 0x520a(%rip), %rdi      # 0x9fc8
leaq 0x22b0(%rip), %rsi      # 0x7075
callq 0x21b0
movq %rax, -0x240(%rbp)
jmp 0x4dd3
movq -0x240(%rbp), %rdi
leaq 0x229c(%rip), %rsi      # 0x707d
callq 0x21b0
jmp 0x4de8
movl $0x1, -0x98(%rbp)
jmp 0x5480
movq -0x190(%rbp), %rdi
movl -0xa4(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x5760
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x2040
jmp 0x4e1c
jmp 0x4e34
jmp 0x4e20
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x4ccc
movl -0x34(%rbp), %eax
addl $0x2, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x248(%rbp)
jmp 0x4e60
movq -0x248(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x14, %edi
callq 0x2030
movq %rax, -0x250(%rbp)
jmp 0x4e7e
movq -0x250(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, (%rax)
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x258(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x20b0
movq -0x258(%rbp), %rdi
movq %rax, %rsi
callq 0x21a0
movq -0x80(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x1, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x4f59
movl $0x14, %edi
callq 0x2030
movq %rax, -0x260(%rbp)
jmp 0x4eef
movq -0x190(%rbp), %rdi
movq -0x260(%rbp), %rdx
movq -0x80(%rbp), %rax
movslq -0xa8(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x80(%rbp), %rax
movslq -0xa8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x268(%rbp)
movslq -0xa8(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x20b0
movq -0x268(%rbp), %rdi
movq %rax, %rsi
callq 0x21a0
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x4ed1
leaq -0x58(%rbp), %rdi
callq 0x20b0
movq %rax, %rdi
xorl %eax, %eax
movl $0x241, %esi            # imm = 0x241
movl $0x1ff, %edx            # imm = 0x1FF
callq 0x2130
movl %eax, -0x26c(%rbp)
jmp 0x4f7e
movl -0x26c(%rbp), %eax
movl %eax, -0xac(%rbp)
movl $0x1, %edi
movl %edi, -0x270(%rbp)
callq 0x22c0
movl -0x270(%rbp), %edi
movl %eax, 0x5222(%rip)      # 0xa1c8
callq 0x2330
jmp 0x4fad
movl -0xac(%rbp), %edi
callq 0x22c0
movl -0xac(%rbp), %edi
callq 0x2330
jmp 0x4fc5
movb $0x1, 0x5204(%rip)      # 0xa1d0
leaq -0x78(%rbp), %rdi
callq 0x20b0
movq %rax, %rdi
xorl %eax, %eax
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x2130
movl %eax, -0x274(%rbp)
jmp 0x4fec
movl -0x274(%rbp), %eax
movl %eax, -0xb0(%rbp)
xorl %edi, %edi
movl %edi, -0x278(%rbp)
callq 0x22c0
movl -0x278(%rbp), %edi
movl %eax, 0x51bb(%rip)      # 0xa1cc
callq 0x2330
jmp 0x5018
movl -0xb0(%rbp), %edi
callq 0x22c0
movl -0xb0(%rbp), %edi
callq 0x2330
jmp 0x5030
movb $0x1, 0x519a(%rip)      # 0xa1d1
jmp 0x519a
testb $0x1, -0xa(%rbp)
jne 0x5198
testb $0x1, -0x9(%rbp)
jne 0x5198
movq -0x190(%rbp), %rdi
callq 0x5780
decl %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
addl $0x2, %eax
movq %rsp, %rcx
movq %rcx, -0xb8(%rbp)
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x280(%rbp)
movq %rcx, %rsp
movq %rax, -0xc0(%rbp)
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x50e6
movl $0x14, %edi
callq 0x2030
movq %rax, -0x288(%rbp)
jmp 0x50bc
movq -0x280(%rbp), %rax
movq -0x288(%rbp), %rdx
movslq -0xc4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x509e
movq -0x280(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x290(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x20b0
movq -0x290(%rbp), %rdi
movq %rax, %rsi
callq 0x21a0
movl $0x1, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x5178
movq -0x190(%rbp), %rdi
movq -0x280(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x298(%rbp)
movslq -0xc8(%rbp), %rsi
callq 0x5760
movq %rax, %rdi
callq 0x20b0
movq -0x298(%rbp), %rdi
movq %rax, %rsi
callq 0x21a0
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x5119
movq -0x280(%rbp), %rax
movslq -0xc8(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0xb8(%rbp), %rax
movq %rax, %rsp
jmp 0x519a
jmp 0x519c
leaq 0x1fe2(%rip), %rsi      # 0x7185
leaq -0x30(%rbp), %rdi
callq 0x54b0
movb %al, -0x299(%rbp)
jmp 0x51b4
movb -0x299(%rbp), %al
testb $0x1, %al
jne 0x51c0
jmp 0x5203
leaq -0x100(%rbp), %rdi
movl $0x32, %esi
callq 0x20d0
leaq 0x1fb1(%rip), %rdi      # 0x7189
callq 0x2280
leaq 0x1fa1(%rip), %rsi      # 0x7185
xorl %eax, %eax
movl %eax, %edx
movq %rsi, %rdi
movb $0x0, %al
callq 0x2220
leaq -0x100(%rbp), %rdi
callq 0x2280
jmp 0x5476
leaq 0x1f88(%rip), %rsi      # 0x7192
leaq -0x30(%rbp), %rdi
callq 0x54b0
movb %al, -0x29a(%rbp)
jmp 0x521b
movb -0x29a(%rbp), %al
testb $0x1, %al
jne 0x522a
jmp 0x52b2
leaq -0x140(%rbp), %rdi
movl $0x32, %esi
callq 0x20d0
leaq 0x1f47(%rip), %rdi      # 0x7189
callq 0x2280
movq -0x190(%rbp), %rdi
callq 0x5780
cmpq $0x1, %rax
jbe 0x528c
movq -0x190(%rbp), %rdi
movl $0x1, %esi
callq 0x5760
movq %rax, %rdi
callq 0x20b0
movq %rax, %rdx
leaq 0x1f16(%rip), %rsi      # 0x7192
xorl %eax, %eax
movl %eax, %ecx
movq %rsi, %rdi
movb $0x0, %al
callq 0x2220
jmp 0x52a1
leaq 0x1eff(%rip), %rsi      # 0x7192
xorl %eax, %eax
movl %eax, %edx
movq %rsi, %rdi
movb $0x0, %al
callq 0x2220
leaq -0x140(%rbp), %rdi
callq 0x2280
jmp 0x5474
leaq 0x1edd(%rip), %rsi      # 0x7196
leaq -0x30(%rbp), %rdi
callq 0x54b0
movb %al, -0x29b(%rbp)
jmp 0x52ca
movb -0x29b(%rbp), %al
testb $0x1, %al
jne 0x52d9
jmp 0x5361
leaq -0x180(%rbp), %rdi
movl $0x32, %esi
callq 0x20d0
leaq 0x1e98(%rip), %rdi      # 0x7189
callq 0x2280
movq -0x190(%rbp), %rdi
callq 0x5780
cmpq $0x1, %rax
jbe 0x533b
movq -0x190(%rbp), %rdi
movl $0x1, %esi
callq 0x5760
movq %rax, %rdi
callq 0x20b0
movq %rax, %rdx
leaq 0x1e6b(%rip), %rsi      # 0x7196
xorl %eax, %eax
movl %eax, %ecx
movq %rsi, %rdi
movb $0x0, %al
callq 0x2220
jmp 0x5350
leaq 0x1e54(%rip), %rsi      # 0x7196
xorl %eax, %eax
movl %eax, %edx
movq %rsi, %rdi
movb $0x0, %al
callq 0x2220
leaq -0x180(%rbp), %rdi
callq 0x2280
jmp 0x5472
movq -0x80(%rbp), %rax
movq (%rax), %rdi
movq -0x80(%rbp), %rsi
callq 0x2140
cmpl $0x0, %eax
jge 0x5470
movq 0x4c47(%rip), %rdi      # 0x9fc8
leaq 0x1cdd(%rip), %rsi      # 0x7065
callq 0x21b0
movq %rax, -0x2a8(%rbp)
jmp 0x5396
movq -0x2a8(%rbp), %rdi
leaq 0x1cc9(%rip), %rsi      # 0x706d
callq 0x21b0
jmp 0x53ab
movq 0x4c16(%rip), %rdi      # 0x9fc8
leaq 0x1cbc(%rip), %rsi      # 0x7075
callq 0x21b0
movq %rax, -0x2b0(%rbp)
jmp 0x53c7
movq -0x2b0(%rbp), %rdi
leaq 0x1d5a(%rip), %rsi      # 0x712f
callq 0x21b0
movq %rax, -0x2b8(%rbp)
jmp 0x53e3
movq -0x2b8(%rbp), %rdi
movq -0x80(%rbp), %rax
movq (%rax), %rsi
callq 0x21b0
movq %rax, -0x2c0(%rbp)
jmp 0x53ff
movq -0x2c0(%rbp), %rdi
leaq 0x1d8c(%rip), %rsi      # 0x7199
callq 0x21b0
jmp 0x5414
movl $0x0, -0x184(%rbp)
movl -0x184(%rbp), %eax
movl -0x34(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jge 0x5469
movq -0x80(%rbp), %rax
movslq -0x184(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x2c8(%rbp)
cmpq $0x0, %rax
je 0x5456
movq -0x2c8(%rbp), %rdi
callq 0x2230
jmp 0x5458
movl -0x184(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x184(%rbp)
jmp 0x541e
xorl %edi, %edi
callq 0x2200
jmp 0x5472
jmp 0x5474
jmp 0x5476
movl $0x0, -0x98(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2100
leaq -0x58(%rbp), %rdi
callq 0x2100
leaq -0x30(%rbp), %rdi
callq 0x2100
movq %rbp, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x2320
nopl (%rax)