// File: /workspace/github_cpp_makefile_star2_O3/SaadBazaz[P]RIP-Protocol-Simulation/ProxyRouter.cpp
// Function: handlePacket(int const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void handlePacket(const int &client, string packet)
{
	auto vec = tokenizeData(packet, '&');
	// for (int i=0; i<vec.size(); i++){
	// 		std::cout<<vec[i]<<std::endl;
	// }


	if (vec[0] == "OK"){
		std::cout<<"Something good happened!"<<std::endl;
		return;
	}
	else if (vec[0] == "BAD"){
		std::cout<<"Oops, something went wrong..."<<std::endl;
		return;
	}


	switch (stoi(vec[0]))
	{
	case UPDATE:
	{
		// cout<<"In UPDATE..."<<endl;
		TableRow table_row(vec[3]);
		// cout<<"Made table_row..."<<endl;
		int index = findRowByFDAndID(client, table_row.identifier);

		if (index < 0)
		{

			// if match not found
			// remove all id = -1 values from table and add new table_row
			for (int i=0; i<table.size(); i++){
				if (table[i].identifier == -1){
					table.erase (table.begin() + i);
					i--;
				}
			} 

			table_row.fd = client;
			if (table_row.hop_count < 0)
			{
				table_row.hop_count = 0;
			}
			
			table.push_back(table_row);
			printTable();
			break;
		}


		if (table_row.identifier >= 0)
		{
			table[index].identifier = table_row.identifier;
		}

		// if (table_row.client_name >= 0){
		// 	table[index].client_name = table_row.client_name;
		// }

		if (table_row.status >= 0)
		{
			table[index].status = table_row.status;
		}

		if (table_row.hop_count >= 0)
		{
			table[index].hop_count = table_row.hop_count;
		}

		if (table_row.type != "")
		{
			table[index].type = table_row.type;
		}

		// if (table_row.in_use >= 0){
		table[index].in_use = table_row.in_use;
		// }

		if (table_row.send_port >= 0)
		{
			table[index].send_port = table_row.send_port;
		}

		if (table_row.receive_port >= 0)
		{
			table[index].receive_port = table_row.receive_port;
		}

		printTable();
		sendTableToAllRouters();

		break;
	}
	case ADD:
		break;

	case DELETE:
		break;

	case TABLE:{

		// auto index_vec = findAllRowsByFD(client);

		auto new_rows = deserialize(vec[3]);		


		// cout<<"New Rows - - - - - "<<endl;
		for (int i=0; i<new_rows.size(); i++){


			new_rows[i].fd = client;

			// cout<<new_rows[i].identifier<<endl;

		}
		// cout<<"- - - - - - - - - - "<<endl;



		// Clean useless data out of new_rows vector
		for (int i=0; i<table.size(); i++)
		{
			for (int j=0; j<new_rows.size(); j++){
				if (table[i] == new_rows[j] 
				or (table[i].fd == client and table[i].identifier == new_rows[j].identifier)
				or (table[i].identifier == new_rows[j].identifier and table[i].hop_count == 0)
				or (new_rows[j].hop_count >= 15)
				//  or new_rows[j].identifier == -1 or new_rows[j].identifier == port
				)

				{
					new_rows.erase(new_rows.begin() + j);
					j--;	
				}
			}
		}

		for (int j=0; j<new_rows.size(); j++){
			if (new_rows[j].identifier == -1 or new_rows[j].identifier == port){
				new_rows.erase(new_rows.begin() + j);
				j--;
			}
		}


		// cout<<"New Rows [CLEANED] - - - - - "<<endl;
		// for (int i=0; i<new_rows.size(); i++){
		// 	cout<<new_rows[i].identifier<<endl;
		// }
		// cout<<"- - - - - - - - - - "<<endl;



		// Add data from new_rows into table
		for (int i=0; i<new_rows.size(); i++){
				new_rows[i].hop_count ++;
				new_rows[i].fd = client;
				table.push_back(new_rows[i]);
		}

		// for (int i=0; i<new_rows.size(); i++){
		// 	if (new_rows[i].identifier != port)
		// 		table.push_back(new_rows[i]);
		// }

		printTable();
		sendTableToAllRouters(client);  //ignore this client when sending table to routers
		break;
	}

	case MESSAGE:
	{
        vector<string> Command = tokenizeData(vec[3],' ');
        if (Command[0]=="DNS")
        {
            if(Command[1]=="REQ"){
                while (Command[2].back() == '\n')
                {
                    Command[2].pop_back();
                }
                for (size_t i = 0; i < List.size(); i++)
                {
                    if (Command[2]==List[i].DomainName)
                    {
                        string Response = "DNS RES " + List[i].DomainName + " " + List[i].IPAddress;
                        string message = constructNewMessage(MESSAGE, port,stoi(vec[1]),(void*)Response.c_str());
                        cout << "Proxy Intervenes ...\n";

						if (vec.size() == 4){
							message += '&';
							message += to_string(port);
						}
						else {
							message += ',';
							message += to_string(port);			
						}

                        send(client, message.c_str(), strlen(message.c_str()), 0);
                        return;
                    }
                    
                }
                
            }
            else if (Command[1] == "RES"){
                cout << "Checking Response ... \n";
                int index = SearchDomain(Command[2],List);
                
                if (index < 0)
                {
                    Directory Entry ;
                    Entry.DomainName = Command[2] ;
                    for (size_t i = 0; i < 128; i++)
                    {
                        Entry.IPAddress[i] = Command[3][i];
                    }
                    List.push_back(Entry);
                    cout << "Saved the Entry in Cache ... \n";
                }
                else{
                    for (size_t i = 0; i < 128; i++)
                    {
                        List[index].IPAddress[i] = Command[3][i];
                    }
                }
                
            }
        }
        
		int index = findRowByID_MinHopCount(stoi(vec[2]));

		if (index < 0)
		{
			break;
		}

		if (vec.size() == 4){
			packet += '&';
			packet += to_string(port);
		}
		else {
			packet += ',';
			packet += to_string(port);			
		}
		// Forward packet to appropriate socket
		send(table[index].fd, packet.c_str(), strlen(packet.c_str()), 0);
		break;
	}
	default:
		break;
	}
	// if (vec[0] == UPDATE){
	// 	if ()

	// }
	// send(client, "OK", 2, 0); //Reply message to client
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, %r14
movq %rdi, (%rsp)
leaq 0x1b0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rsi), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x1a0(%rsp), %r15
movq %r15, %rdi
callq 0x71c6
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movl $0x26, %edx
callq 0x25cc
movq 0x1a0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c9a
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x2270
movq 0x30(%rsp), %rdi
leaq 0x445d(%rip), %rsi      # 0x8103
callq 0x20a0
testl %eax, %eax
je 0x3e9a
movq 0x30(%rsp), %rdi
leaq 0x4460(%rip), %rsi      # 0x811f
callq 0x20a0
testl %eax, %eax
je 0x3ea8
movq 0x30(%rsp), %rax
movq (%rax), %r12
callq 0x2040
movq %rax, %rbx
movl (%rax), %ebp
movl $0x0, (%rax)
leaq 0x80(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x2300
cmpq %r12, (%r13)
je 0x498b
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x499a
movl (%rbx), %ecx
cmpl $0x22, %ecx
je 0x499a
testl %ecx, %ecx
jne 0x3d23
movl %ebp, (%rbx)
cmpl $0x1, %eax
je 0x4050
cmpl $0x4, %eax
je 0x3f0a
cmpl $0x2, %eax
jne 0x3eee
movq 0x30(%rsp), %rax
leaq 0x190(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
addq %rsi, %rdx
leaq 0x180(%rsp), %rdi
callq 0x71c6
leaq 0x80(%rsp), %rdi
leaq 0x180(%rsp), %rsi
movl $0x2c, %edx
callq 0x68e4
movq 0x180(%rsp), %rdi
cmpq %r14, %rdi
je 0x3d9e
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x2270
movq (%rsp), %rax
movl (%rax), %ecx
movq 0x7485(%rip), %rax      # 0xb230
movq 0x7476(%rip), %rsi      # 0xb228
movq %rax, %rdi
subq %rsi, %rdi
je 0x3e42
movl 0x80(%rsp), %edx
sarq $0x6, %rdi
cmpq $0x1, %rdi
adcq $0x0, %rdi
leaq 0x4(%rsi), %r8
xorl %r14d, %r14d
cmpl %ecx, (%r8)
jne 0x3de7
cmpl %edx, -0x4(%r8)
je 0x452a
incq %r14
addq $0x40, %r8
cmpq %r14, %rdi
jne 0x3dd8
cmpq %rsi, %rax
je 0x3e42
xorl %ecx, %ecx
leaq 0x7427(%rip), %r14      # 0xb228
xorl %ebx, %ebx
shlq $0x6, %rcx
cmpl $-0x1, (%rsi,%rcx)
jne 0x3e28
addq %rcx, %rsi
movq %r14, %rdi
callq 0x78e6
decl %ebx
movq 0x740f(%rip), %rax      # 0xb230
movq 0x7400(%rip), %rsi      # 0xb228
incl %ebx
movslq %ebx, %rcx
movq %rax, %rdx
subq %rsi, %rdx
sarq $0x6, %rdx
cmpq %rcx, %rdx
ja 0x3e03
movq (%rsp), %rax
movl (%rax), %ecx
movl %ecx, 0x84(%rsp)
cmpl $0x0, 0x8c(%rsp)
jns 0x3e5e
movl $0x0, 0x8c(%rsp)
leaq 0x73c3(%rip), %rdi      # 0xb228
leaq 0x80(%rsp), %rsi
callq 0x6d68
callq 0x33da
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3eee
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x3eee
movl $0x18, %edx
leaq 0x4260(%rip), %rsi      # 0x8106
jmp 0x3eb4
movl $0x1d, %edx
leaq 0x426f(%rip), %rsi      # 0x8123
movq 0x7115(%rip), %rbx      # 0xafd0
movq %rbx, %rdi
callq 0x22b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0x70ef(%rip), %rdi      # 0xafd0
callq 0x2030
movq %rax, %rdi
callq 0x2190
leaq 0x30(%rsp), %rdi
callq 0x56e2
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x8(%rsp)
movq 0x30(%rsp), %rax
leaq 0x150(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
addq %rsi, %rdx
leaq 0x140(%rsp), %rdi
callq 0x71c6
leaq 0x68(%rsp), %rdi
leaq 0x140(%rsp), %rsi
movl $0x20, %edx
callq 0x25cc
movq 0x140(%rsp), %rdi
cmpq %r15, %rdi
je 0x3f6c
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x2270
movq 0x68(%rsp), %rdi
leaq 0x41c9(%rip), %rsi      # 0x8141
callq 0x20a0
testl %eax, %eax
je 0x4387
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rbx
movq 0x8(%rsp), %r15
movl (%r15), %ebp
movl $0x0, (%r15)
leaq 0x80(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x2300
cmpq %rbx, (%r12)
je 0x49a9
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
leaq -0x80000000(%rax), %rdx
cmpq %rcx, %rdx
jb 0x49b5
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x49b5
testl %ecx, %ecx
jne 0x3fec
movl %ebp, (%r15)
movl %eax, %edi
callq 0x35bf
testl %eax, %eax
js 0x451b
movl %eax, %ebx
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
cmpq $0x80, %rax
jne 0x4497
movq %r14, %rdi
movl $0x26, %esi
callq 0x2210
movl 0x721a(%rip), %esi      # 0xb240
leaq 0x80(%rsp), %rdi
callq 0x6e2c
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %r14, %rdi
callq 0x20b0
jmp 0x44cf
movq 0x30(%rsp), %rax
leaq 0x170(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
addq %rsi, %rdx
leaq 0x160(%rsp), %rdi
callq 0x71c6
leaq 0x80(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x2870
movq 0x160(%rsp), %rdi
cmpq %r14, %rdi
je 0x40ab
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x2270
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %rbp
movq %rbp, %rdx
subq %r14, %rdx
je 0x41cb
movq (%rsp), %rax
movl (%rax), %eax
sarq $0x6, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
leaq 0x3(%rdx), %rcx
andq $-0x4, %rcx
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0xc4(%r14), %rdx
movdqa 0x3f23(%rip), %xmm1     # 0x8020
movdqa 0x3f2b(%rip), %xmm2     # 0x8030
movdqa 0x3f33(%rip), %xmm3     # 0x8040
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x3f33(%rip), %xmm5     # 0x8050
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0x4158
movl %eax, -0xc0(%rdx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0x416a
movl %eax, -0x80(%rdx)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %esi
testb $0x1, %sil
je 0x41a5
movl %eax, -0x40(%rdx)
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0x41b2
movl %eax, (%rdx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x100, %rdx            # imm = 0x100
addq $-0x4, %rcx
jne 0x411d
movq 0x705e(%rip), %rax      # 0xb230
movq 0x704f(%rip), %rcx      # 0xb228
cmpq %rcx, %rax
je 0x42b7
xorl %ebx, %ebx
movq %rbp, %rdx
cmpq %r14, %rdx
je 0x429e
xorl %r12d, %r12d
movq %rbx, 0x8(%rsp)
shlq $0x6, %rbx
xorl %r15d, %r15d
movq 0x7022(%rip), %r13      # 0xb228
addq %rbx, %r13
shlq $0x6, %r12
addq %r14, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x26ec
testb %al, %al
jne 0x424a
movl (%r13), %eax
movl 0x4(%r13), %edx
movl (%r12), %ecx
movq (%rsp), %rsi
cmpl (%rsi), %edx
jne 0x4237
cmpl %ecx, %eax
je 0x424a
cmpl %ecx, %eax
jne 0x4242
cmpl $0x0, 0xc(%r13)
je 0x424a
cmpl $0xf, 0xc(%r12)
jl 0x426d
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x78e6
decl %r15d
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %rbp
incl %r15d
movslq %r15d, %r12
movq %rbp, %rax
subq %r14, %rax
sarq $0x6, %rax
cmpq %r12, %rax
ja 0x41ff
movq 0x6fa3(%rip), %rax      # 0xb230
movq 0x6f94(%rip), %rcx      # 0xb228
movq %rbp, %rdx
movq 0x8(%rsp), %rbx
jmp 0x42a1
movq %r14, %rdx
incq %rbx
movq %rax, %rsi
subq %rcx, %rsi
sarq $0x6, %rsi
cmpq %rbx, %rsi
ja 0x41e7
cmpq %r14, %rbp
je 0x4365
xorl %eax, %eax
leaq 0x80(%rsp), %r15
xorl %ebx, %ebx
shlq $0x6, %rax
movl (%r14,%rax), %ecx
cmpl $-0x1, %ecx
je 0x42e1
cmpl 0x6f61(%rip), %ecx      # 0xb240
jne 0x4301
addq %rax, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x78e6
decl %ebx
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %rbp
incl %ebx
movslq %ebx, %rax
movq %rbp, %rcx
subq %r14, %rcx
sarq $0x6, %rcx
cmpq %rax, %rcx
ja 0x42cc
cmpq %r14, %rbp
je 0x4365
xorl %ebx, %ebx
leaq 0x6f05(%rip), %r15      # 0xb228
xorl %r12d, %r12d
incl 0xc(%r14,%rbx)
leaq (%r14,%rbx), %rsi
movq (%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%r14,%rbx)
movq %r15, %rdi
callq 0x6d68
incq %r12
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %rax
subq %r14, %rax
sarq $0x6, %rax
addq $0x40, %rbx
cmpq %r12, %rax
ja 0x4326
callq 0x33da
movq (%rsp), %rax
movl (%rax), %edi
callq 0x3842
leaq 0x80(%rsp), %rdi
callq 0x6dce
jmp 0x3eee
movq 0x68(%rsp), %rdi
addq $0x20, %rdi
leaq 0x3dae(%rip), %rsi      # 0x8145
callq 0x20a0
movq 0x68(%rsp), %rdi
testl %eax, %eax
je 0x45f7
addq $0x20, %rdi
leaq 0x3db4(%rip), %rsi      # 0x8168
callq 0x20a0
testl %eax, %eax
jne 0x3f85
movq 0x6c08(%rip), %rdi      # 0xafd0
leaq 0x3d9d(%rip), %rsi      # 0x816c
movl $0x17, %edx
callq 0x22b0
movq 0x68(%rsp), %rax
leaq 0x130(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
addq %rsi, %rdx
leaq 0x120(%rsp), %rdi
callq 0x71c6
leaq 0x6e3e(%rip), %rsi      # 0xb248
leaq 0x1c0(%rsp), %rdi
callq 0x704c
leaq 0x120(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x3b1a
movl %eax, %ebx
leaq 0x1c0(%rsp), %rdi
callq 0x6ece
movq 0x120(%rsp), %rdi
cmpq %r12, %rdi
je 0x4458
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x2270
testl %ebx, %ebx
js 0x46ea
movl %ebx, %eax
shlq $0x5, %rax
leaq (%rax,%rax,4), %rax
xorl %ecx, %ecx
movq 0x68(%rsp), %rdx
movq 0x60(%rdx), %rdx
movb (%rdx,%rcx), %dl
movq 0x6dc9(%rip), %rsi      # 0xb248
addq %rax, %rsi
movb %dl, 0x20(%rcx,%rsi)
incq %rcx
cmpq $0x80, %rcx
jne 0x446c
jmp 0x3f85
movq %r14, %rdi
movl $0x2c, %esi
callq 0x2210
movl 0x6d96(%rip), %esi      # 0xb240
leaq 0x80(%rsp), %rdi
callq 0x6e2c
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %r14, %rdi
callq 0x20b0
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x44f0
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2270
movl %ebx, %eax
movq 0x6d2f(%rip), %rcx      # 0xb228
shlq $0x6, %rax
movl 0x4(%rcx,%rax), %ebx
movq (%r14), %r14
movq %r14, %rdi
callq 0x2110
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2120
leaq 0x68(%rsp), %rdi
callq 0x56e2
jmp 0x3eee
testq %r14, %r14
js 0x3df3
testl %edx, %edx
js 0x4541
movl %r14d, %eax
shlq $0x6, %rax
movl %edx, (%rsi,%rax)
movzwl 0x88(%rsp), %eax
testw %ax, %ax
js 0x455a
movl %r14d, %ecx
shlq $0x6, %rcx
movw %ax, 0x8(%rsi,%rcx)
movl 0x8c(%rsp), %eax
testl %eax, %eax
js 0x4570
movl %r14d, %ecx
shlq $0x6, %rcx
movl %eax, 0xc(%rsi,%rcx)
leaq 0x90(%rsp), %rbx
leaq 0x3b58(%rip), %rsi      # 0x80d7
movq %rbx, %rdi
callq 0x20a0
movl %r14d, %r14d
testl %eax, %eax
je 0x45ac
movq 0x6c93(%rip), %rax      # 0xb228
movq %r14, %rcx
shlq $0x6, %rcx
leaq (%rax,%rcx), %rdi
addq $0x10, %rdi
movq %rbx, %rsi
callq 0x2140
movb 0xb0(%rsp), %cl
movq 0x6c6e(%rip), %rdx      # 0xb228
shlq $0x6, %r14
leaq (%rdx,%r14), %rax
movb %cl, 0x30(%rdx,%r14)
movl 0xb4(%rsp), %ecx
testl %ecx, %ecx
js 0x45d5
movl %ecx, 0x34(%rax)
movl 0xb8(%rsp), %ecx
testl %ecx, %ecx
js 0x45e3
movl %ecx, 0x38(%rax)
callq 0x33da
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3842
jmp 0x3e77
movq 0x40(%rdi), %r12
movq 0x48(%rdi), %r13
cmpb $0xa, -0x1(%r12,%r13)
jne 0x4629
addq $0x40, %rdi
callq 0x22d0
movq 0x68(%rsp), %rax
leaq 0x40(%rax), %rdi
movq 0x40(%rax), %r12
movq 0x48(%rax), %r13
cmpb $0xa, -0x1(%r12,%r13)
je 0x460b
movq 0x6c20(%rip), %rax      # 0xb250
movq 0x6c11(%rip), %rbp      # 0xb248
subq %rbp, %rax
je 0x3f85
sarq $0x5, %rax
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %r15
cmpq $0x1, %r15
adcq $0x0, %r15
movq $-0x20, %rbx
cmpq 0x8(%rbp), %r13
jne 0x467f
testq %r13, %r13
je 0x4697
movq (%rbp), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x2280
testl %eax, %eax
je 0x4697
addq $-0xa0, %rbx
addq $0xa0, %rbp
decq %r15
jne 0x4661
jmp 0x3f85
leaq 0x3aab(%rip), %rsi      # 0x8149
leaq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x6fc4
leaq 0x3bbd(%rip), %rsi      # 0x826f
leaq 0x10(%rsp), %rdi
callq 0x23e0
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4791
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x479a
leaq 0x90(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
movq 0x68(%rsp), %rsi
addq $0x40, %rsi
leaq 0x80(%rsp), %rdi
callq 0x2140
movl $0x20, %eax
movq 0x68(%rsp), %rcx
movq 0x60(%rcx), %rdx
movb -0x20(%rdx,%rax), %dl
movb %dl, 0x80(%rsp,%rax)
incq %rax
cmpq $0xa0, %rax
jne 0x4725
leaq 0x6b02(%rip), %rdi      # 0xb248
leaq 0x80(%rsp), %rsi
callq 0x70e8
movq 0x6876(%rip), %rdi      # 0xafd0
leaq 0x3a23(%rip), %rsi      # 0x8184
movl $0x1e, %edx
callq 0x22b0
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x3f85
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x3f85
movdqu (%rcx), %xmm0
movdqu %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x48(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x6a8b(%rip), %rsi      # 0xb248
subq %rbx, %rsi
callq 0x23e0
leaq 0x90(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x47f6
movq %rdx, 0x80(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x90(%rsp)
jmp 0x4800
movdqu (%rcx), %xmm0
movdqu %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x88(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4832
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2270
leaq 0x20(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x484d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2270
movl 0x69ed(%rip), %ebp      # 0xb240
movq 0x30(%rsp), %rdi
addq $0x20, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x6f32
movq 0x80(%rsp), %r8
leaq 0x48(%rsp), %rdi
movl $0x4, %esi
movl %ebp, %edx
movl %eax, %ecx
callq 0x2a12
movq 0x6746(%rip), %rdi      # 0xafd0
leaq 0x38c1(%rip), %rsi      # 0x8152
movl $0x15, %edx
callq 0x22b0
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
cmpq $0x80, %rax
jne 0x48e2
leaq 0x48(%rsp), %rdi
movl $0x26, %esi
callq 0x2210
movl 0x697e(%rip), %esi      # 0xb240
leaq 0x10(%rsp), %rdi
callq 0x6e2c
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0x20b0
jmp 0x4915
leaq 0x48(%rsp), %rdi
movl $0x2c, %esi
callq 0x2210
movl 0x6949(%rip), %esi      # 0xb240
leaq 0x10(%rsp), %rdi
callq 0x6e2c
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0x20b0
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x492c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2270
movq (%rsp), %rax
movl (%rax), %ebx
movq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x2110
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2120
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4965
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2270
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x451b
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x451b
movq %rbx, %r14
leaq 0x395f(%rip), %rdi      # 0x82f4
callq 0x2160
movq %rbx, %r14
leaq 0x3950(%rip), %rdi      # 0x82f4
callq 0x2310
leaq 0x3944(%rip), %rdi      # 0x82f4
callq 0x2160
leaq 0x3938(%rip), %rdi      # 0x82f4
callq 0x2310
jmp 0x49c3
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x4a74
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x4a74
jmp 0x4a71
jmp 0x4a71
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a0f
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x4a0f
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4b55
movq 0x20(%rsp), %rsi
jmp 0x4abf
jmp 0x4b3c
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x6ece
jmp 0x4a45
movq %rax, %rbx
movq 0x120(%rsp), %rdi
cmpq %r12, %rdi
je 0x4b55
movq 0x130(%rsp), %rsi
jmp 0x4abf
jmp 0x4b3c
jmp 0x4b3c
jmp 0x4a6c
movq %rax, %rbx
jmp 0x4a8b
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a8b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2270
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
jne 0x4ab7
jmp 0x4b55
jmp 0x4a9f
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4b55
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x4b55
jmp 0x4b3c
jmp 0x4b3c
movq %rax, %rbx
movq 0x160(%rsp), %rdi
cmpq %r14, %rdi
je 0x4bd4
movq 0x170(%rsp), %rsi
jmp 0x4b81
movq %rax, %rbx
movq 0x140(%rsp), %rdi
cmpq %r15, %rdi
je 0x4bd4
movq 0x150(%rsp), %rsi
jmp 0x4b81
movq %rax, %rbx
movq 0x180(%rsp), %rdi
cmpq %r14, %rdi
je 0x4bd4
movq 0x190(%rsp), %rsi
jmp 0x4b81
jmp 0x4bbf
jmp 0x4bbf
jmp 0x4bbf
movq %rax, %rbx
jmp 0x4b55
movq %rax, %rbx
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x4b55
movq 0x8(%rsp), %rax
movl %ebp, (%rax)
leaq 0x68(%rsp), %rdi
callq 0x56e2
jmp 0x4bd4
jmp 0x4bc4
jmp 0x4b65
movq %rax, %rbx
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4bd4
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x4bd4
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x4bd4
movl %ebp, (%r14)
jmp 0x4bd4
jmp 0x4bc4
movq %rax, %rbx
movq 0x1a0(%rsp), %rdi
cmpq %r12, %rdi
je 0x4bde
movq 0x1b0(%rsp), %rsi
incq %rsi
callq 0x2270
jmp 0x4bde
jmp 0x4bc4
movq %rax, %rbx
jmp 0x4bd4
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x6dce
leaq 0x30(%rsp), %rdi
callq 0x56e2
movq %rbx, %rdi
callq 0x23a0