// File: 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
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x10(%rbp)
movl $0x10, -0x24(%rbp)
movl $0x2, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x50f0
movl %eax, 0x23a56(%rip)     # 0x294a0
cmpl $0x0, %eax
jge 0x5a68
leaq 0x165ce(%rip), %rdi     # 0x1c024
callq 0x5370
movq $0x0, -0x8(%rbp)
jmp 0x6b95
leaq 0x23a39(%rip), %rdi     # 0x294a8
xorl %esi, %esi
movl $0x10, %edx
callq 0x5200
movw $0x2, 0x23a24(%rip)     # 0x294a8
xorl %edi, %edi
callq 0x5320
movl %eax, 0x23a1b(%rip)     # 0x294ac
movl $0xa154, %edi           # imm = 0xA154
callq 0x5080
movw %ax, 0x23a08(%rip)      # 0x294aa
movl 0x239f8(%rip), %edi     # 0x294a0
leaq 0x239f9(%rip), %rsi     # 0x294a8
movl $0x10, %edx
callq 0x50a0
cmpl $0x0, %eax
jge 0x5ad7
leaq 0x16575(%rip), %rdi     # 0x1c03a
callq 0x5370
movq $0x0, -0x8(%rbp)
jmp 0x6b95
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x5200
movw $0x2, -0x130(%rbp)
leaq 0x1654c(%rip), %rdi     # 0x1c046
callq 0x5410
movl %eax, -0x12c(%rbp)
movl $0xc351, %edi           # imm = 0xC351
callq 0x5080
movw %ax, -0x12e(%rbp)
movl 0x23984(%rip), %edi     # 0x294a0
leaq -0xa0(%rbp), %rsi
movl $0x67, %edx
xorl %ecx, %ecx
leaq -0x20(%rbp), %r8
leaq -0x24(%rbp), %r9
callq 0x5330
movl %eax, -0x28(%rbp)
movzbl -0xa0(%rbp), %eax
cmpl $0x49, %eax
je 0x5b48
jmp 0x5b16
movzbl -0x9c(%rbp), %eax
cmpl $0x1, %eax
jne 0x5c03
movzbl -0x9b(%rbp), %eax
cmpl $0x61, %eax
jne 0x5c03
movb -0x9b(%rbp), %al
addb $0x1, %al
movb %al, -0x9b(%rbp)
movb $0x2, -0x7b(%rbp)
movb $0x4f, -0x7a(%rbp)
movb $0x4b, -0x79(%rbp)
movq 0x23447(%rip), %rdi     # 0x28fd0
leaq 0x164c0(%rip), %rsi     # 0x1c050
callq 0x53f0
movq %rax, -0x150(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x144(%rbp)
movl -0x144(%rbp), %edi
callq 0x51a0
movq -0x150(%rbp), %rdi
movq %rax, %rsi
callq 0x53f0
movq %rax, %rdi
movq 0x233ef(%rip), %rsi     # 0x28fb8
callq 0x5450
movl $0xa154, %edi           # imm = 0xA154
callq 0x5080
movw %ax, -0x1e(%rbp)
movl 0x238be(%rip), %edi     # 0x294a0
leaq -0xa0(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x20(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
jmp 0x5b16
cmpl $0x66, -0x28(%rbp)
je 0x5c0e
jmp 0x5b16
leaq -0x20(%rbp), %rdi
callq 0x59c0
movl %eax, -0x11c(%rbp)
cmpl $-0x1, -0x11c(%rbp)
jne 0x5c86
movq 0x233a3(%rip), %rdi     # 0x28fd0
leaq 0x16446(%rip), %rsi     # 0x1c07a
callq 0x53f0
movq %rax, -0x158(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x148(%rbp)
movl -0x148(%rbp), %edi
callq 0x51a0
movq -0x158(%rbp), %rdi
movq %rax, %rsi
callq 0x53f0
movq %rax, %rdi
leaq 0x16425(%rip), %rsi     # 0x1c092
callq 0x53f0
movq %rax, %rdi
movq 0x2333c(%rip), %rsi     # 0x28fb8
callq 0x5450
jmp 0x5b16
leaq -0x110(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x66, %edx
callq 0x5360
movq 0x237d3(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
shrl $0x18, %eax
movb %al, -0xaf(%rbp)
movq 0x237b2(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, -0xae(%rbp)
movq 0x2378c(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, -0xad(%rbp)
movq 0x23766(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
andl $0xff, %eax
movb %al, -0xac(%rbp)
movzbl -0x7a(%rbp), %eax
cmpl $0x1c, %eax
jne 0x6565
movzbl -0x79(%rbp), %eax
cmpl $0x21, %eax
jne 0x6565
movzbl -0x78(%rbp), %eax
cmpl $0x81, %eax
je 0x5d62
movzbl -0x78(%rbp), %eax
cmpl $0x83, %eax
jne 0x6565
movslq -0x28(%rbp), %rax
movb $0x0, -0xa0(%rbp,%rax)
movzbl -0x73(%rbp), %eax
cmpl $0x1, %eax
jne 0x61e5
movzbl -0x6e(%rbp), %eax
shll $0x8, %eax
movzbl -0x6d(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x134(%rbp)
movzbl -0x70(%rbp), %eax
shll $0x8, %eax
movzbl -0x6f(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x138(%rbp)
movzbl -0x77(%rbp), %eax
movl %eax, -0x13c(%rbp)
movq 0x236c6(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x28(%rax)
movq 0x236aa(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x68(%rax), %eax
cmpl -0x134(%rbp), %eax
jne 0x5e8e
movq 0x23686(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x68(%rax)
je 0x5e8e
movq 0x23667(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x60(%rax)
movq 0x231a3(%rip), %rdi     # 0x28fd0
leaq 0x163ba(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x160(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x23632(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x16238(%rip), %rsi     # 0x1c0a4
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x2312f(%rip), %rsi     # 0x28fb8
callq 0x5450
movq 0x235e3(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x64(%rax), %eax
cmpl -0x134(%rbp), %eax
jne 0x5f55
movq 0x235bf(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x64(%rax)
je 0x5f55
movq 0x235a0(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x60(%rax)
movq 0x230dc(%rip), %rdi     # 0x28fd0
leaq 0x162f3(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x168(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x2356b(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x168(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x16186(%rip), %rsi     # 0x1c0b9
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x23068(%rip), %rsi     # 0x28fb8
callq 0x5450
movl -0x13c(%rbp), %eax
movq 0x23516(%rip), %rcx     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movzbl 0x35(%rcx), %ecx
cmpl %ecx, %eax
je 0x60df
cmpl $0x0, 0x23519(%rip)     # 0x2949c
je 0x603a
movq 0x23040(%rip), %rdi     # 0x28fd0
leaq 0x16257(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x170(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x234cf(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x170(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x160fe(%rip), %rsi     # 0x1c0cd
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x16102(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x160f0(%rip), %rsi     # 0x1c0f9
callq 0x53f0
movq %rax, %rdi
movl -0x13c(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x160e2(%rip), %rsi     # 0x1c108
callq 0x53f0
movq %rax, %rdi
movq 0x22f83(%rip), %rsi     # 0x28fb8
callq 0x5450
movl 0x23460(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
movq 0x23412(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
cmpl $0x0, -0x134(%rbp)
jne 0x60da
movq 0x233ed(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x28(%rax)
movq 0x233d1(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movl -0x134(%rbp), %ecx
movq 0x233af(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x38(%rax)
jmp 0x5b16
movl -0x138(%rbp), %ecx
movq 0x2338c(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movl -0x134(%rbp), %ecx
movq 0x2336e(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x38(%rax)
movl -0x134(%rbp), %ecx
movq 0x23350(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movl $0x1, -0x120(%rbp)
movq 0x22e86(%rip), %rdi     # 0x28fd0
leaq 0x1609d(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x178(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x23315(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x178(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x15f96(%rip), %rsi     # 0x1c11f
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15f48(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15f7b(%rip), %rsi     # 0x1c13e
callq 0x53f0
movq %rax, %rdi
movl -0x13c(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x22dd8(%rip), %rsi     # 0x28fb8
callq 0x5450
movzbl -0x73(%rbp), %eax
cmpl $0x8, %eax
jne 0x64aa
movzbl -0x6e(%rbp), %eax
shll $0x8, %eax
movzbl -0x6d(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x134(%rbp)
movzbl -0x70(%rbp), %eax
shll $0x8, %eax
movzbl -0x6f(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x138(%rbp)
movzbl -0x77(%rbp), %eax
movl %eax, -0x13c(%rbp)
cmpl $0x0, -0x138(%rbp)
jne 0x6239
cmpl $0x0, -0x134(%rbp)
jne 0x6239
jmp 0x5b16
movq 0x23238(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x28(%rax)
jne 0x6259
jmp 0x5b16
movl -0x13c(%rbp), %eax
movq 0x23212(%rip), %rcx     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rcx
movzbl 0x35(%rcx), %ecx
cmpl %ecx, %eax
je 0x63d9
cmpl $0x0, 0x23215(%rip)     # 0x2949c
je 0x633e
movq 0x22d3c(%rip), %rdi     # 0x28fd0
leaq 0x15f53(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x180(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x231cb(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x180(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x15dfa(%rip), %rsi     # 0x1c0cd
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15dfe(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15dec(%rip), %rsi     # 0x1c0f9
callq 0x53f0
movq %rax, %rdi
movl -0x13c(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15dde(%rip), %rsi     # 0x1c108
callq 0x53f0
movq %rax, %rdi
movq 0x22c7f(%rip), %rsi     # 0x28fb8
callq 0x5450
movl 0x2315c(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
cmpl $0x0, -0x134(%rbp)
jne 0x63d4
movq 0x23105(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq 0x230e9(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movq 0x230cd(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %ecx
movq 0x230b5(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x3c(%rax)
jmp 0x5b16
movq 0x23098(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq 0x2307c(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %ecx
movq 0x23064(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x3c(%rax)
movq 0x22ba4(%rip), %rdi     # 0x28fd0
leaq 0x15dbb(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x188(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x23033(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x188(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x15cdd(%rip), %rsi     # 0x1c148
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15c66(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x22b13(%rip), %rsi     # 0x28fb8
callq 0x5450
movzbl -0x73(%rbp), %eax
cmpl $0x8, %eax
je 0x64d3
movq 0x22fbe(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x28(%rax)
jne 0x64d3
jmp 0x5b16
movq 0x22f9e(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x60(%rax)
je 0x64f3
jmp 0x5b16
movq 0x22f7e(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
leaq -0xa0(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x134(%rbp), %edx
movl -0x11c(%rbp), %ecx
movl -0x120(%rbp), %r8d
callq 0x6bb0
movl $0x0, -0x120(%rbp)
movl 0x22f5f(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
jmp 0x6647
movzbl -0x7a(%rbp), %eax
cmpl $0x0, %eax
je 0x657b
movzbl -0x7a(%rbp), %eax
cmpl $0x10, %eax
jne 0x6645
movzbl -0x79(%rbp), %eax
cmpl $0x21, %eax
jne 0x6645
movq 0x22ee9(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x60(%rax)
je 0x65a8
jmp 0x5b16
movq 0x22ec9(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x28(%rax)
jne 0x65c8
jmp 0x5b16
movq 0x22ea9(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %eax
movl %eax, -0x134(%rbp)
movq 0x22e8b(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
leaq -0xa0(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x134(%rbp), %edx
movl -0x11c(%rbp), %ecx
xorl %r8d, %r8d
callq 0x6bb0
movl 0x22e7a(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
jmp 0x6647
movzbl -0x79(%rbp), %eax
cmpl $0x18, %eax
jne 0x681e
movzbl -0x76(%rbp), %eax
cmpl $0xf, %eax
je 0x666a
movzbl -0x76(%rbp), %eax
cmpl $0x9, %eax
jne 0x681e
movq 0x22e07(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x60(%rax)
jne 0x681e
movzbl -0x71(%rbp), %eax
shll $0x8, %eax
movzbl -0x70(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x134(%rbp)
movzbl -0x73(%rbp), %eax
shll $0x8, %eax
movzbl -0x72(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x138(%rbp)
movzbl -0x77(%rbp), %eax
movl %eax, -0x13c(%rbp)
movl -0x138(%rbp), %ecx
movq 0x22db2(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movl -0x134(%rbp), %ecx
movq 0x22d94(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x38(%rax)
movl -0x134(%rbp), %ecx
movq 0x22d76(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movq 0x22d5e(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x28(%rax)
movl $0x1, -0x120(%rbp)
movq 0x22890(%rip), %rdi     # 0x28fd0
leaq 0x15aa7(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x190(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x22d1f(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x190(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x159e7(%rip), %rsi     # 0x1c166
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15952(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15985(%rip), %rsi     # 0x1c13e
callq 0x53f0
movq %rax, %rdi
movl -0x13c(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x227e2(%rip), %rsi     # 0x28fb8
callq 0x5450
leaq -0xa0(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x134(%rbp), %edx
movl -0x11c(%rbp), %ecx
xorl %r8d, %r8d
callq 0x6bb0
movl 0x22ca1(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
movzbl -0x79(%rbp), %eax
cmpl $0x18, %eax
jne 0x6a08
movzbl -0x76(%rbp), %eax
cmpl $0x8, %eax
jne 0x6a08
movq 0x22c39(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x60(%rax)
jne 0x6a08
movzbl -0x71(%rbp), %eax
shll $0x8, %eax
movzbl -0x70(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x134(%rbp)
movzbl -0x73(%rbp), %eax
shll $0x8, %eax
movzbl -0x72(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x138(%rbp)
movl -0x138(%rbp), %ecx
movq 0x22bee(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movl -0x134(%rbp), %ecx
movq 0x22bd0(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x38(%rax)
movl -0x134(%rbp), %ecx
movq 0x22bb2(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movq 0x22b9a(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq 0x22b7e(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %ecx
movq 0x22b66(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rdx
imulq $0x70, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x3c(%rax)
movq 0x226a6(%rip), %rdi     # 0x28fd0
leaq 0x158bd(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x198(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x22b35(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x198(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x15824(%rip), %rsi     # 0x1c18d
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15768(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x1579b(%rip), %rsi     # 0x1c13e
callq 0x53f0
movq %rax, %rdi
movl -0x13c(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x225f8(%rip), %rsi     # 0x28fb8
callq 0x5450
leaq -0xa0(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x134(%rbp), %edx
movl -0x11c(%rbp), %ecx
xorl %r8d, %r8d
callq 0x6bb0
movl 0x22ab7(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
movzbl -0x79(%rbp), %eax
cmpl $0x18, %eax
jne 0x6b90
movzbl -0x78(%rbp), %eax
cmpl $0x9c, %eax
jne 0x6b90
movzbl -0x76(%rbp), %eax
cmpl $0xb, %eax
jne 0x6b90
movq 0x22a40(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x60(%rax)
je 0x6a51
jmp 0x5b16
movq 0x22a20(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x28(%rax)
jne 0x6a71
jmp 0x5b16
movq 0x22a00(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %eax
movl %eax, -0x134(%rbp)
movq 0x229e2(%rip), %rax     # 0x29478
movslq -0x11c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movq 0x2251e(%rip), %rdi     # 0x28fd0
leaq 0x15735(%rip), %rsi     # 0x1c1ee
callq 0x53f0
movq %rax, -0x1a0(%rbp)
movslq -0x11c(%rbp), %rsi
leaq 0x229ad(%rip), %rdi     # 0x29480
callq 0x9020
movq -0x1a0(%rbp), %rdi
movq %rax, %rsi
callq 0x53b0
movq %rax, %rdi
leaq 0x156c2(%rip), %rsi     # 0x1c1b3
callq 0x53f0
movq %rax, %rdi
movl -0x138(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x155e0(%rip), %rsi     # 0x1c0ee
callq 0x53f0
movq %rax, %rdi
movl -0x134(%rbp), %esi
callq 0x5680
movq %rax, %rdi
leaq 0x15613(%rip), %rsi     # 0x1c13e
callq 0x53f0
movq %rax, %rdi
movl -0x13c(%rbp), %esi
callq 0x5680
movq %rax, %rdi
movq 0x22470(%rip), %rsi     # 0x28fb8
callq 0x5450
leaq -0xa0(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x134(%rbp), %edx
movl -0x11c(%rbp), %ecx
xorl %r8d, %r8d
callq 0x6bb0
movl 0x2292f(%rip), %edi     # 0x294a0
leaq -0x110(%rbp), %rsi
movslq -0x28(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x130(%rbp), %r8
movl $0x10, %r9d
callq 0x5090
jmp 0x5b16
movq -0x8(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopw %cs:(%rax,%rax)