// File: /workspace/github_cpp_makefile_star2_O2/rthoelen[P]NXCore_Icom/main.cc
// Function: listen_thread(void*)
void *listen_thread(void *thread_id)
{
        struct sockaddr_in remaddr;     /* remote address */
        socklen_t addrlen = sizeof(remaddr);            /* length of addresses */
        int recvlen;                    /* # bytes received */
        unsigned char buf[105];     /* receive buffer */
        unsigned char tempbuf[105];     /* receive buffer for test port packet */
	struct hostent *he;
	int rpt_id;
	int strt_packet;

	struct sockaddr_in tport;
	int GID, UID, RAN;
	int i;

        /* create UDP socket for repeaters */

        if ((socket_00 = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
                perror("cannot create socket\n");
                return 0;
        }


        /* bind the socket to any valid IP address and a specific port */


        memset((char *)&myaddr_00, 0, sizeof(myaddr_00));
        myaddr_00.sin_family = AF_INET;
//	myaddr_00.sin_addr.s_addr = inet_addr("10.44.0.1");
        myaddr_00.sin_addr.s_addr = htonl(INADDR_ANY);
        myaddr_00.sin_port = htons(41300);

        if (bind(socket_00, (struct sockaddr *)&myaddr_00, sizeof(myaddr_00)) < 0) {
                perror("bind failed");
                return 0;
        }

	// Add a debug port
	memset((char *)&tport, 0, sizeof(tport));
	tport.sin_family = AF_INET;
	tport.sin_addr.s_addr = inet_addr("127.0.0.1");
	tport.sin_port = htons(50001);

        /* now loop, receiving data and printing what we received */
        for (;;) {

		recvlen = recvfrom(socket_00, buf, 103, 0, (struct sockaddr *)&remaddr, &addrlen);	

		// Look for I in Icom 
		if (buf[0] != 0x49)
			continue;


		// Linkup to connect Icom repeater
		if ((buf[4] == 0x01) && (buf[5] == 0x61))
		{
			buf[5]++;
			buf[37] = 0x02;
			buf[38] = 0x4f;
			buf[39] = 0x4b;
			std::cout << "Sending connect string to Repeater at IP:" << inet_ntoa(remaddr.sin_addr) << std::endl;
			
        		remaddr.sin_port = htons(41300);
			sendto(socket_00, buf, recvlen, 0, (struct sockaddr *)&remaddr,
		 		sizeof(remaddr));
			continue;
		}

	
		// Don't know what these are, but probably don't matter
		// if ((buf[38] == 0x00) && (buf[39] == 0x21))
	//		continue;
	
		if (recvlen != 102)
			continue;

		rpt_id = get_repeater_id(&remaddr);
		if (rpt_id == -1)
		{
			std::cout << "Unauthorized repeater, " << inet_ntoa(remaddr.sin_addr) << ", dropping packet" << std::endl;
			continue;  // Throw out packet, not in our list
		}

		memcpy(tempbuf,buf,102);

		tempbuf[97] = (repeater[rpt_id].rpt_addr_00.sin_addr.s_addr) >> 24;
                tempbuf[98] = ((repeater[rpt_id].rpt_addr_00.sin_addr.s_addr) >> 16) & 0xff;
                tempbuf[99] = ((repeater[rpt_id].rpt_addr_00.sin_addr.s_addr) >> 8) & 0xff;
                tempbuf[100] = (repeater[rpt_id].rpt_addr_00.sin_addr.s_addr) & 0xff;

                if ((buf[38] == 0x1c) && (buf[39] == 0x21) && ((buf[40] == 0x81)||(buf[40] == 0x83))) {
                        buf[recvlen] = 0;


			if(buf[45] == (char)1) // Beginning of packets
			{
				GID = (buf[50] << 8) + buf[51];
				UID = (buf[48] << 8) + buf[49];
				RAN = buf[41];

				repeater[rpt_id].rx_activity = 1;

				if ((repeater[rpt_id].tg_network_off == GID) && (repeater[rpt_id].tg_network_off != 0))
				{
					repeater[rpt_id].disable = 1;
					std::cout << "Repeater  ->" << r_list[rpt_id]
						<< "disabled due to TG: " << GID << std::endl;
				}

				if ((repeater[rpt_id].tg_network_on == GID) && (repeater[rpt_id].tg_network_on != 0))
				{
					repeater[rpt_id].disable = 0;
					std::cout << "Repeater  ->" << r_list[rpt_id]
						<< "enabled due to TG: " << GID << std::endl;
				}	

                                if (RAN != repeater[rpt_id].rx_ran)
                                {
					if(debug)
                                        	std::cout << "Repeater  ->" << r_list[rpt_id]
                                                	<< "<-  not passing start from UID: " << UID
                                                	<< " from TG: " << GID
                                                	<< " because RAN: " << RAN
                                                	<< " isn't the receive RAN" << std::endl;

					sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 				sizeof(tport));

					repeater[rpt_id].rx_activity = 0;

					// Handle special case of alternate RAN for local communications
					// and block network activity
					if (GID == 0)
                                        {
                                                repeater[rpt_id].rx_activity = 1;
                                                repeater[rpt_id].time_since_rx = 0;
                                                repeater[rpt_id].active_tg = GID;
                                        }

                                        continue;
                                }

				repeater[rpt_id].uid = UID;
				repeater[rpt_id].active_tg = GID;
				repeater[rpt_id].busy_tg = GID;
				strt_packet=1;
				std::cout << "Repeater  ->" << r_list[rpt_id]
					<< "<-  receiving start from UID: " << UID
					<< " from TG: " << GID 
					<< " on RAN: " << RAN << std::endl;
			}
		
			if(buf[45] == (char)8) // End, sent shutdown on 64001	
			{
				GID = (buf[50] << 8) + buf[51];
				UID = (buf[48] << 8) + buf[49];
				RAN = buf[41];


				if ((UID == 0) && (GID == 0))
					continue;

				if (repeater[rpt_id].rx_activity == 0)
					continue;

                                if (RAN != repeater[rpt_id].rx_ran)
                                {
					if(debug)
                                        	std::cout << "Repeater  ->" << r_list[rpt_id]
                                                	<< "<-  not passing start from UID: " << UID
                                                	<< " from TG: " << GID
                                                	<< " because RAN: " << RAN
                                                	<< " isn't the receive RAN" << std::endl;

					sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 				sizeof(tport));

					// Handle special case of alternate RAN for local communications
					// and block network activity
                                	if (GID == 0)
                                	{ 
						repeater[rpt_id].rx_activity = 0;
						repeater[rpt_id].time_since_rx = 0;
						repeater[rpt_id].last_tg = repeater[rpt_id].active_tg;
					}

					continue;
		
                                }
				repeater[rpt_id].rx_activity = 0;    // Activity on channel is over
				repeater[rpt_id].last_tg = repeater[rpt_id].active_tg;
 
				std::cout << "Repeater  ->" << r_list[rpt_id] << "<-  receiving stop from UID: " << UID << " from TG: " << GID << std::endl;	
			}	
				
			if((buf[45] != 8)&&(repeater[rpt_id].rx_activity == 0))
				continue;

			if(repeater[rpt_id].disable)
				continue;

			repeater[rpt_id].time_since_rx = 0;
			// send packet to repeaters
			snd_packet(buf, recvlen, GID, rpt_id, strt_packet);
			strt_packet = 0;
			sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 		sizeof(tport));
				
		}
               else
		if (((buf[38] == 0x00)||(buf[38] == 0x10)) && (buf[39] == 0x21)) { 


			if(repeater[rpt_id].disable)
				continue;
			
			if (repeater[rpt_id].rx_activity == 0)
				continue;

			GID = repeater[rpt_id].active_tg;

			repeater[rpt_id].time_since_rx = 0;

			// send packet to repeaters that can receive it
			snd_packet(buf, recvlen, GID, rpt_id, 0);

			sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 		sizeof(tport));
		}

	       // Code for group call + SDM
	       //
	       // start packet
	       if ((buf[39]==0x18)&&((buf[42]==0x0f)||(buf[42]==0x09))&&(repeater[rpt_id].disable==0))
	       {

			GID = (buf[47] << 8) + buf[48];
			UID = (buf[45] << 8) + buf[46];
			RAN = buf[41];
			repeater[rpt_id].uid = UID;
			repeater[rpt_id].active_tg = GID;
			repeater[rpt_id].busy_tg = GID;
			repeater[rpt_id].rx_activity = 1;
			strt_packet=1;
			std::cout << "Repeater  ->" << r_list[rpt_id]
				<< "<-  receiving message start from UID: " << UID
				<< " from TG: " << GID 
				<< " on RAN: " << RAN << std::endl;

			// send packet to repeaters that can receive it
			snd_packet(buf, recvlen, GID, rpt_id, 0);

			sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 		sizeof(tport));
	       }


	       // stop packet for group SDM
		
	       if ((buf[39]==0x18)&&(buf[42]==0x08)&&(repeater[rpt_id].disable==0))
	       {

			GID = (buf[47] << 8) + buf[48];
			UID = (buf[45] << 8) + buf[46];
			repeater[rpt_id].uid = UID;
			repeater[rpt_id].active_tg = GID;
			repeater[rpt_id].busy_tg = GID;

			repeater[rpt_id].rx_activity = 0;    // Activity on channel is over
			repeater[rpt_id].last_tg = repeater[rpt_id].active_tg;

			std::cout << "Repeater  ->" << r_list[rpt_id]
				<< "<-  receiving message stop from UID: " << UID
				<< " from TG: " << GID 
				<< " on RAN: " << RAN << std::endl;


			// send packet to repeaters that can receive it
			snd_packet(buf, recvlen, GID, rpt_id, 0);

			sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 		sizeof(tport));

	       }

	       // datagram

		if ((buf[39] == 0x18)&&(buf[40]==0x9c)&&(buf[42]==0x0b)) { 

			if(repeater[rpt_id].disable)
				continue;
			
			if (repeater[rpt_id].rx_activity == 0)
				continue;

			GID = repeater[rpt_id].active_tg;

			repeater[rpt_id].time_since_rx = 0;

			std::cout << "Repeater  ->" << r_list[rpt_id]
				<< "<-  sending message data from UID: " << UID
				<< " from TG: " << GID 
				<< " on RAN: " << RAN << std::endl;



			// send packet to repeaters that can receive it
			snd_packet(buf, recvlen, GID, rpt_id, 0);

			sendto(socket_00, tempbuf, recvlen, 0, (struct sockaddr *)&tport,
		 		sizeof(tport));


		}

	}
        	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl $0x10, -0x4c(%rbp)
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x4080
movl %eax, 0xfc1b(%rip)      # 0x14380
testl %eax, %eax
js 0x5267
andq $0x0, 0xfc1b(%rip)      # 0x14390
leaq 0xfc0c(%rip), %rsi      # 0x14388
movq $0x54a10002, 0xfc01(%rip) # imm = 0x54A10002
pushq $0x10
popq %rdx
movl %eax, %edi
callq 0x4060
testl %eax, %eax
js 0x5270
leaq -0x5c(%rbp), %rbx
andq $0x0, 0x8(%rbx)
movw $0x2, (%rbx)
leaq 0x8888(%rip), %rdi      # 0xd036
callq 0x42d0
movl %eax, 0x4(%rbx)
movw $0x51c3, 0x2(%rbx)      # imm = 0x51C3
leaq -0xd0(%rbp), %r14
leaq -0xe0(%rbp), %r12
movl 0xfbb0(%rip), %edi      # 0x14380
movq %r14, %rsi
pushq $0x67
popq %rdx
xorl %ecx, %ecx
movq %r12, %r8
leaq -0x4c(%rbp), %r9
callq 0x4230
cmpb $0x49, -0xd0(%rbp)
jne 0x47ca
movq %rax, %rbx
cmpb $0x1, -0xcc(%rbp)
jne 0x4875
cmpb $0x61, -0xcb(%rbp)
jne 0x4875
movb $0x62, -0xcb(%rbp)
movw $0x4f02, -0xab(%rbp)    # imm = 0x4F02
movb $0x4b, -0xa9(%rbp)
movq 0xf7b0(%rip), %rdi      # 0x13fd0
leaq 0x8819(%rip), %rsi      # 0xd040
callq 0x42b0
movq %rax, %r15
movl -0xdc(%rbp), %edi
callq 0x4100
movq %r15, %rdi
movq %rax, %rsi
callq 0x42b0
movq %rax, %rdi
callq 0x4130
movw $0x54a1, -0xde(%rbp)    # imm = 0x54A1
movl 0xfb24(%rip), %edi      # 0x14380
movslq %ebx, %rdx
movq %r14, %rsi
xorl %ecx, %ecx
movq %r12, %r8
pushq $0x10
popq %r9
callq 0x4050
jmp 0x47ca
cmpl $0x66, %ebx
jne 0x47ca
movq %r12, %rdi
callq 0x46fc
cmpl $-0x1, %eax
je 0x4c08
movl %eax, %ebx
pushq $0x66
popq %rcx
leaq -0x150(%rbp), %rdi
movq %r14, %rsi
rep  movsb (%rsi), %es:(%rdi)
movq 0xfab1(%rip), %rax      # 0x14358
movslq %ebx, %r13
imulq $0x70, %r13, %r15
movb 0x7(%rax,%r15), %cl
movb %cl, -0xef(%rbp)
movb 0x6(%rax,%r15), %cl
movb %cl, -0xee(%rbp)
movb 0x5(%rax,%r15), %cl
movb %cl, -0xed(%rbp)
movb 0x4(%rax,%r15), %cl
movb %cl, -0xec(%rbp)
movb -0xaa(%rbp), %cl
movb -0xa9(%rbp), %dl
movl %ecx, %esi
xorb $0x1c, %sil
xorb $0x21, %dl
orb %dl, %sil
jne 0x4c50
movb -0xa8(%rbp), %cl
andb $-0x3, %cl
cmpb $-0x7f, %cl
jne 0x4cfc
movb $0x0, -0x6a(%rbp)
movb -0xa3(%rbp), %cl
cmpb $0x1, %cl
jne 0x4af2
movl %ebx, -0x38(%rbp)
movzwl -0xa0(%rbp), %ecx
movw %cx, -0x30(%rbp)
movzwl -0x9e(%rbp), %ecx
rolw $0x8, %cx
movzwl %cx, %ebx
movzbl -0xa7(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movl $0x1, 0x28(%rax,%r15)
movl 0x68(%rax,%r15), %ecx
cmpl %ebx, %ecx
setne %dl
testl %ecx, %ecx
sete %cl
orb %dl, %cl
movq %r13, -0x40(%rbp)
jne 0x49be
addq %r15, %rax
movl $0x1, 0x60(%rax)
movq 0xf65c(%rip), %rdi      # 0x13fd0
leaq 0x8863(%rip), %rsi      # 0xd1de
callq 0x42b0
shlq $0x5, %r13
addq 0xf9d5(%rip), %r13      # 0x14360
movq %rax, %rdi
movq %r13, %rsi
callq 0x4290
movq %rax, %rdi
leaq 0x86f4(%rip), %rsi      # 0xd094
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movq 0xf99a(%rip), %rax      # 0x14358
movl 0x64(%rax,%r15), %ecx
cmpl %ebx, %ecx
setne %dl
testl %ecx, %ecx
sete %cl
orb %dl, %cl
movl %ebx, -0x2c(%rbp)
jne 0x4a2d
addq %r15, %rax
andl $0x0, 0x60(%rax)
movq 0xf5ee(%rip), %rdi      # 0x13fd0
leaq 0x87f5(%rip), %rsi      # 0xd1de
callq 0x42b0
movq -0x40(%rbp), %rsi
shlq $0x5, %rsi
addq 0xf963(%rip), %rsi      # 0x14360
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x869a(%rip), %rsi      # 0xd0a9
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movq 0xf92b(%rip), %rax      # 0x14358
movl -0x34(%rbp), %ecx
movzwl -0x30(%rbp), %edx
rolw $0x8, %dx
movzwl %dx, %r13d
cmpb 0x35(%rax,%r15), %cl
movl %r13d, -0x30(%rbp)
jne 0x4e84
leaq (%rax,%r15), %rcx
movl %r13d, 0x50(%rcx)
movl -0x2c(%rbp), %ebx
movl %ebx, 0x38(%rax,%r15)
movl %ebx, 0x30(%rax,%r15)
movq 0xf569(%rip), %rdi      # 0x13fd0
leaq 0x8770(%rip), %rsi      # 0xd1de
callq 0x42b0
movq -0x40(%rbp), %rsi
shlq $0x5, %rsi
addq 0xf8de(%rip), %rsi      # 0x14360
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x867b(%rip), %rsi      # 0xd10f
callq 0x42b0
movq %rax, %rdi
movl %r13d, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x8630(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x8667(%rip), %rsi      # 0xd12e
callq 0x42b0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movq -0x40(%rbp), %r13
movb -0xa3(%rbp), %cl
pushq $0x1
popq %rax
movl %eax, -0x48(%rbp)
movl -0x38(%rbp), %ebx
cmpb $0x8, %cl
jne 0x4c90
movzwl -0xa0(%rbp), %eax
movzwl -0x9e(%rbp), %ecx
rolw $0x8, %cx
movzwl %cx, %edx
rolw $0x8, %ax
movzwl %ax, %ecx
movzbl -0xa7(%rbp), %eax
movl %eax, -0x34(%rbp)
movl %ecx, %eax
orl %edx, %eax
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
je 0x47ca
movq 0xf818(%rip), %rax      # 0x14358
cmpl $0x0, 0x28(%rax,%r15)
movl %ecx, -0x30(%rbp)
movl %edx, -0x2c(%rbp)
je 0x47ca
movl %edx, -0x44(%rbp)
movl %ecx, -0x38(%rbp)
addq %r15, %rax
movl -0x34(%rbp), %ecx
cmpb 0x35(%rax), %cl
jne 0x516b
andl $0x0, 0x28(%rax)
movl 0x38(%rax), %ecx
movl %ecx, 0x3c(%rax)
movq %r13, -0x40(%rbp)
movq 0xf454(%rip), %rdi      # 0x13fd0
leaq 0x865b(%rip), %rsi      # 0xd1de
callq 0x42b0
movq -0x40(%rbp), %rsi
shlq $0x5, %rsi
addq 0xf7c9(%rip), %rsi      # 0x14360
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x858f(%rip), %rsi      # 0xd138
callq 0x42b0
movq %rax, %rdi
movl -0x38(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x851b(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl -0x44(%rbp), %r13d
movl %r13d, %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movl %r13d, %edx
movl -0x38(%rbp), %ecx
movq -0x40(%rbp), %r13
cmpb $0x8, -0xa3(%rbp)
movq 0xf761(%rip), %rax      # 0x14358
movl %edx, -0x2c(%rbp)
movl %ecx, -0x30(%rbp)
jne 0x4c9d
jmp 0x4caf
movq 0xf3c1(%rip), %rdi      # 0x13fd0
leaq 0x8454(%rip), %rsi      # 0xd06a
callq 0x42b0
movq %rax, %rbx
movl -0xdc(%rbp), %edi
callq 0x4100
movq %rbx, %rdi
movq %rax, %rsi
callq 0x42b0
movq %rax, %rdi
leaq 0x8444(%rip), %rsi      # 0xd082
callq 0x42b0
movq %rax, %rdi
callq 0x4130
jmp 0x47ca
andb $-0x11, %cl
orb %dl, %cl
jne 0x4cfc
cmpl $0x0, 0x60(%rax,%r15)
jne 0x47ca
addq %r15, %rax
cmpl $0x0, 0x28(%rax)
je 0x47ca
movl 0x38(%rax), %edx
andl $0x0, 0x18(%rax)
movq %r14, %rdi
pushq $0x66
popq %rsi
movl %edx, -0x2c(%rbp)
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x5290
jmp 0x4cdd
movq 0xf6c1(%rip), %rax      # 0x14358
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
cmpl $0x0, 0x28(%rax,%r15)
movl %ecx, -0x30(%rbp)
movl %edx, -0x2c(%rbp)
je 0x47ca
cmpl $0x0, 0x60(%rax,%r15)
jne 0x47ca
addq %r15, %rax
andl $0x0, 0x18(%rax)
movq %r14, %rdi
pushq $0x66
popq %rsi
movl -0x2c(%rbp), %edx
movl %ebx, %ecx
movl -0x48(%rbp), %r8d
callq 0x5290
movl $0x0, -0x48(%rbp)
movl 0xf69d(%rip), %edi      # 0x14380
leaq -0x150(%rbp), %rsi
pushq $0x66
popq %rdx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
pushq $0x10
popq %r9
callq 0x4050
movb -0xa9(%rbp), %cl
movb -0xa6(%rbp), %al
cmpb $0x18, %cl
jne 0x5074
movzbl %al, %edx
cmpl $0xf, %edx
je 0x4d24
movb $0x18, %cl
cmpl $0x9, %edx
jne 0x4e54
movq 0xf62d(%rip), %rdx      # 0x14358
movb $0x18, %cl
cmpl $0x0, 0x60(%rdx,%r15)
jne 0x5074
leaq (%rdx,%r15), %rax
movzwl -0xa3(%rbp), %ecx
movzwl -0xa1(%rbp), %esi
rolw $0x8, %si
movzwl %si, %esi
rolw $0x8, %cx
movl %ebx, -0x38(%rbp)
movzwl %cx, %ebx
movzbl -0xa7(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movl %ebx, 0x50(%rax)
movl %esi, -0x2c(%rbp)
movl %esi, 0x38(%rdx,%r15)
movl %esi, 0x30(%rdx,%r15)
movl $0x1, 0x28(%rdx,%r15)
movq %r13, -0x40(%rbp)
movq 0xf246(%rip), %rdi      # 0x13fd0
leaq 0x844d(%rip), %rsi      # 0xd1de
callq 0x42b0
movq -0x40(%rbp), %rsi
shlq $0x5, %rsi
addq 0xf5bb(%rip), %rsi      # 0x14360
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x839f(%rip), %rsi      # 0xd156
callq 0x42b0
movq %rax, %rdi
movl %ebx, -0x30(%rbp)
movl %ebx, %esi
movl -0x38(%rbp), %ebx
callq 0x44b0
movq %rax, %rdi
leaq 0x8308(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl -0x2c(%rbp), %r13d
movl %r13d, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x833a(%rip), %rsi      # 0xd12e
callq 0x42b0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movq %r14, %rdi
pushq $0x66
popq %rsi
movl %r13d, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x5290
movl 0xf55b(%rip), %edi      # 0x14380
leaq -0x150(%rbp), %rsi
pushq $0x66
popq %rdx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
pushq $0x10
popq %r9
callq 0x4050
movq -0x40(%rbp), %r13
movb -0xa9(%rbp), %cl
movb -0xa6(%rbp), %al
pushq $0x1
popq %rdx
movl %edx, -0x48(%rbp)
movl %ecx, %edx
xorb $0x18, %dl
movl %eax, %esi
xorb $0x8, %sil
orb %dl, %sil
jne 0x5074
movq 0xf4e9(%rip), %rax      # 0x14358
cmpl $0x0, 0x60(%rax,%r15)
je 0x4f77
movb $0x18, %cl
movb $0x8, %al
jmp 0x5074
cmpl $0x0, 0xf4f1(%rip)      # 0x1437c
movl -0x2c(%rbp), %ebx
je 0x4f22
movq 0xf135(%rip), %rdi      # 0x13fd0
leaq 0x833c(%rip), %rsi      # 0xd1de
callq 0x42b0
movq -0x40(%rbp), %rsi
shlq $0x5, %rsi
addq 0xf4aa(%rip), %rsi      # 0x14360
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x81f5(%rip), %rsi      # 0xd0bd
callq 0x42b0
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x81fc(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x81ee(%rip), %rsi      # 0xd0e9
callq 0x42b0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x81e3(%rip), %rsi      # 0xd0f8
callq 0x42b0
movq %rax, %rdi
callq 0x4130
movl 0xf458(%rip), %edi      # 0x14380
leaq -0x150(%rbp), %rsi
pushq $0x66
popq %rdx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
pushq $0x10
popq %r9
callq 0x4050
movq 0xf410(%rip), %rax      # 0x14358
andl $0x0, 0x28(%rax,%r15)
testl %ebx, %ebx
jne 0x47ca
addq %r15, %rax
addq $0x28, %rax
movl $0x1, (%rax)
andl $0x0, -0x10(%rax)
andl $0x0, 0x10(%rax)
movl $0x0, -0x2c(%rbp)
jmp 0x47ca
leaq (%rax,%r15), %rcx
movzwl -0xa1(%rbp), %edx
rolw $0x8, %dx
movzwl -0xa3(%rbp), %esi
movl %ebx, -0x38(%rbp)
movzwl %dx, %ebx
rolw $0x8, %si
movzwl %si, %edx
movl %edx, -0x30(%rbp)
movl %edx, 0x50(%rcx)
movl %ebx, 0x38(%rax,%r15)
movl %ebx, 0x30(%rax,%r15)
andl $0x0, 0x28(%rax,%r15)
movl %ebx, 0x3c(%rcx)
movq 0xf016(%rip), %rdi      # 0x13fd0
leaq 0x821d(%rip), %rsi      # 0xd1de
callq 0x42b0
movq %r13, %rsi
shlq $0x5, %rsi
addq 0xf38c(%rip), %rsi      # 0x14360
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x8197(%rip), %rsi      # 0xd17d
callq 0x42b0
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x80de(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x8115(%rip), %rsi      # 0xd12e
callq 0x42b0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movq %r14, %rdi
pushq $0x66
popq %rsi
movl %ebx, -0x2c(%rbp)
movl %ebx, %edx
movl -0x38(%rbp), %ebx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x5290
movl 0xf331(%rip), %edi      # 0x14380
leaq -0x150(%rbp), %rsi
pushq $0x66
popq %rdx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
pushq $0x10
popq %r9
callq 0x4050
movb -0xa9(%rbp), %cl
movb -0xa6(%rbp), %al
cmpb $0x18, %cl
jne 0x47ca
cmpb $-0x64, -0xa8(%rbp)
jne 0x47ca
cmpb $0xb, %al
jne 0x47ca
movq 0xf2bf(%rip), %rax      # 0x14358
cmpl $0x0, 0x60(%rax,%r15)
jne 0x47ca
addq %r15, %rax
cmpl $0x0, 0x28(%rax)
je 0x47ca
movl %ebx, %r15d
movl 0x38(%rax), %ebx
andl $0x0, 0x18(%rax)
movq 0xef0d(%rip), %rdi      # 0x13fd0
leaq 0x8114(%rip), %rsi      # 0xd1de
callq 0x42b0
shlq $0x5, %r13
addq 0xf286(%rip), %r13      # 0x14360
movq %rax, %rdi
movq %r13, %rsi
callq 0x4290
movq %rax, %rdi
leaq 0x80b4(%rip), %rsi      # 0xd1a3
callq 0x42b0
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x7fd5(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x800c(%rip), %rsi      # 0xd12e
callq 0x42b0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
callq 0x4130
movq %r14, %rdi
pushq $0x66
popq %rsi
movl %ebx, -0x2c(%rbp)
movl %ebx, %edx
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x5290
movl 0xf22a(%rip), %edi      # 0x14380
leaq -0x150(%rbp), %rsi
pushq $0x66
popq %rdx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
jmp 0x4867
cmpl $0x0, 0xf20a(%rip)      # 0x1437c
movl -0x38(%rbp), %ebx
je 0x520b
movq 0xee4e(%rip), %rdi      # 0x13fd0
leaq 0x8055(%rip), %rsi      # 0xd1de
callq 0x42b0
shlq $0x5, %r13
addq 0xf1c7(%rip), %r13      # 0x14360
movq %rax, %rdi
movq %r13, %rsi
movl -0x38(%rbp), %ebx
callq 0x4290
movq %rax, %rdi
leaq 0x7f0c(%rip), %rsi      # 0xd0bd
callq 0x42b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x7f14(%rip), %rsi      # 0xd0de
callq 0x42b0
movq %rax, %rdi
movl -0x44(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x7f05(%rip), %rsi      # 0xd0e9
callq 0x42b0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x44b0
movq %rax, %rdi
leaq 0x7efa(%rip), %rsi      # 0xd0f8
callq 0x42b0
movq %rax, %rdi
callq 0x4130
movl 0xf16f(%rip), %edi      # 0x14380
leaq -0x150(%rbp), %rsi
pushq $0x66
popq %rdx
xorl %ecx, %ecx
leaq -0x5c(%rbp), %r8
pushq $0x10
popq %r9
callq 0x4050
movl %ebx, -0x30(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x2c(%rbp)
testl %eax, %eax
jne 0x47ca
movq 0xf116(%rip), %rax      # 0x14358
andl $0x0, 0x28(%rax,%r15)
andl $0x0, 0x18(%rax,%r15)
movl 0x38(%rax,%r15), %ecx
movl %ecx, 0x3c(%rax,%r15)
movl %ebx, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x47ca
leaq 0x7da6(%rip), %rdi      # 0xd014
jmp 0x5277
leaq 0x7db3(%rip), %rdi      # 0xd02a
callq 0x4260
xorl %eax, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq