// File: /workspace/github_cpp_makefile_star2_O1/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 $0x138, %rsp            # imm = 0x138
movl $0x10, -0x38(%rbp)
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x4080
movl %eax, 0x10be7(%rip)     # 0x15380
testl %eax, %eax
js 0x561e
xorps %xmm0, %xmm0
movups %xmm0, 0x10bdd(%rip)    # 0x15388
leaq 0x10bd6(%rip), %rsi     # 0x15388
movq $0x54a10002, 0x10bcb(%rip) # imm = 0x54A10002
movl %eax, %edi
movl $0x10, %edx
callq 0x4070
testl %eax, %eax
js 0x5627
leaq -0x80(%rbp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movw $0x2, (%rbx)
leaq 0xa86b(%rip), %rdi      # 0xf052
callq 0x42d0
movl %eax, 0x4(%rbx)
movw $0x51c3, 0x2(%rbx)      # imm = 0x51C3
leaq -0xf0(%rbp), %r14
leaq -0x64(%rbp), %r15
leaq -0x38(%rbp), %r12
movq 0x107c5(%rip), %r13     # 0x14fd0
movl 0x10b6f(%rip), %edi     # 0x15380
movl $0x67, %edx
movq %r14, %rsi
xorl %ecx, %ecx
movq %r15, %r8
movq %r12, %r9
callq 0x4250
cmpb $0x49, -0xf0(%rbp)
jne 0x480b
movq %rax, %rbx
movb -0xec(%rbp), %cl
movb -0xeb(%rbp), %al
xorb $0x1, %cl
movl %eax, %edx
xorb $0x61, %dl
orb %cl, %dl
jne 0x489e
incb %al
movb %al, -0xeb(%rbp)
movw $0x4f02, -0xcb(%rbp)    # imm = 0x4F02
movb $0x4b, -0xc9(%rbp)
movl $0x29, %edx
movq %r13, %rdi
leaq 0xa7eb(%rip), %rsi      # 0xf05c
callq 0x4330
movl -0x60(%rbp), %edi
callq 0x4120
testq %rax, %rax
je 0x48df
movq %rax, %r12
movq %rax, %rdi
callq 0x4110
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0x48f8
cmpl $0x66, %ebx
jne 0x480b
movslq 0x10aca(%rip), %rax     # 0x15378
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
testq %rax, %rax
jle 0x494e
movl -0x60(%rbp), %ecx
movq 0x10a91(%rip), %rdx     # 0x15358
addq $0x4, %rdx
xorl %esi, %esi
cmpl (%rdx), %ecx
je 0x494b
incq %rsi
addq $0x70, %rdx
cmpq %rsi, %rax
jne 0x48cd
jmp 0x494e
movq (%r13), %rax
movq -0x18(%rax), %rax
leaq (%rax,%r13), %rdi
movl 0x20(%r13,%rax), %esi
orl $0x1, %esi
callq 0x44a0
leaq -0x38(%rbp), %r12
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movw $0x54a1, -0x62(%rbp)    # imm = 0x54A1
movl 0x10a50(%rip), %edi     # 0x15380
movslq %ebx, %rdx
movq %r14, %rsi
xorl %ecx, %ecx
movq %r15, %r8
movl $0x10, %r9d
callq 0x4060
jmp 0x480b
movl %esi, %r8d
cmpl $-0x1, %r8d
je 0x52fc
movl $0xc, %ecx
leaq -0x160(%rbp), %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movzwl -0x8c(%rbp), %eax
movw %ax, -0xfc(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x100(%rbp)
movq 0x109cd(%rip), %rax     # 0x15358
movslq %r8d, %rcx
movq %rcx, -0x48(%rbp)
imulq $0x70, %rcx, %rbx
movb 0x7(%rax,%rbx), %cl
movb %cl, -0xff(%rbp)
movb 0x6(%rax,%rbx), %cl
movb %cl, -0xfe(%rbp)
movb 0x5(%rax,%rbx), %cl
movb %cl, -0xfd(%rbp)
movb 0x4(%rax,%rbx), %cl
movb %cl, -0xfc(%rbp)
movb -0xca(%rbp), %cl
movb -0xc9(%rbp), %dl
movl %ecx, %esi
xorb $0x1c, %sil
xorb $0x21, %dl
orb %dl, %sil
jne 0x4e39
movb -0xc8(%rbp), %sil
andb $-0x3, %sil
cmpb $-0x7f, %sil
jne 0x4e39
movb $0x0, -0x8a(%rbp)
cmpb $0x1, -0xc3(%rbp)
jne 0x4c9f
movzwl -0xc0(%rbp), %ecx
movw %cx, -0x30(%rbp)
movzwl -0xbe(%rbp), %ecx
rolw $0x8, %cx
movzwl %cx, %edi
movzbl -0xc7(%rbp), %esi
movl $0x1, 0x28(%rax,%rbx)
movl 0x68(%rax,%rbx), %ecx
cmpl %edi, %ecx
setne %dl
testl %ecx, %ecx
sete %cl
orb %dl, %cl
movl %esi, -0x34(%rbp)
movl %edi, -0x2c(%rbp)
jne 0x4adf
addq %rbx, %rax
movl $0x1, 0x60(%rax)
movl $0xc, %edx
movq %r13, %rdi
leaq 0xa798(%rip), %rsi      # 0xf1fa
movl %r8d, %r15d
callq 0x4330
movq 0x108ef(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x14, %edx
movq %rax, %rdi
leaq 0xa614(%rip), %rsi      # 0xf0b0
callq 0x4330
movq %r12, %rdi
movl -0x2c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movl %r15d, %r8d
movl -0x2c(%rbp), %edi
movl -0x34(%rbp), %esi
movq 0x10872(%rip), %rax     # 0x15358
movl 0x64(%rax,%rbx), %ecx
cmpl %edi, %ecx
setne %dl
testl %ecx, %ecx
sete %cl
orb %dl, %cl
jne 0x4b8f
addq %rbx, %rax
movl $0x0, 0x60(%rax)
movl $0xc, %edx
movq %r13, %rdi
leaq 0xa6e5(%rip), %rsi      # 0xf1fa
movl %r8d, %r15d
callq 0x4330
movq 0x1083c(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x13, %edx
movq %rax, %rdi
leaq 0xa576(%rip), %rsi      # 0xf0c5
callq 0x4330
movq %r12, %rdi
movl -0x2c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movl %r15d, %r8d
movl -0x34(%rbp), %esi
movzwl -0x30(%rbp), %eax
rolw $0x8, %ax
movzwl %ax, %r15d
movq 0x107b6(%rip), %rax     # 0x15358
cmpb 0x35(%rax,%rbx), %sil
movl %r15d, -0x3c(%rbp)
jne 0x5392
leaq (%rax,%rbx), %rcx
movl %r15d, 0x50(%rcx)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x38(%rax,%rbx)
movl %ecx, 0x30(%rax,%rbx)
movl $0xc, %edx
movq %r13, %rdi
leaq 0xa627(%rip), %rsi      # 0xf1fa
movl %r8d, -0x30(%rbp)
callq 0x4330
movq 0x1077d(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x1e, %edx
movq %rax, %rdi
leaq 0xa51d(%rip), %rsi      # 0xf12b
callq 0x4330
movq %r12, %rdi
movl %r15d, %esi
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0xa4ca(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl -0x2c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0x9, %edx
movq %rax, %rdi
leaq 0xa4f8(%rip), %rsi      # 0xf14a
callq 0x4330
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movl -0x30(%rbp), %r8d
movl $0x1, -0x54(%rbp)
leaq -0x38(%rbp), %r12
leaq -0x64(%rbp), %r15
cmpb $0x8, -0xc3(%rbp)
jne 0x4dde
movzwl -0xc0(%rbp), %eax
movzwl -0xbe(%rbp), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
rolw $0x8, %ax
movzwl %ax, %edx
movzbl -0xc7(%rbp), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl %edx, %eax
orl %ecx, %eax
movl $0x0, -0x2c(%rbp)
je 0x480b
movq 0x10667(%rip), %rax     # 0x15358
cmpl $0x0, 0x28(%rax,%rbx)
movl %edx, -0x3c(%rbp)
movl %ecx, -0x2c(%rbp)
je 0x480b
movl %edx, -0x4c(%rbp)
movl %ecx, -0x50(%rbp)
addq %rbx, %rax
movl -0x34(%rbp), %ecx
cmpb 0x35(%rax), %cl
jne 0x54d9
movl $0x0, 0x28(%rax)
movl 0x38(%rax), %ecx
movl %ecx, 0x3c(%rax)
movl $0xc, %edx
movq %r13, %rdi
leaq 0xa4c7(%rip), %rsi      # 0xf1fa
movl %r8d, -0x30(%rbp)
callq 0x4330
movq 0x1061d(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x1d, %edx
movq %rax, %rdi
leaq 0xa3e6(%rip), %rsi      # 0xf154
callq 0x4330
movq %r12, %rdi
movl -0x4c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0xa36a(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl -0x50(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
leaq -0x38(%rbp), %r12
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movl -0x30(%rbp), %r8d
movl -0x4c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpb $0x8, -0xc3(%rbp)
je 0x4df9
movq 0x1056a(%rip), %rax     # 0x15358
cmpl $0x0, 0x28(%rax,%rbx)
je 0x480b
movq 0x10558(%rip), %rax     # 0x15358
cmpl $0x0, 0x60(%rax,%rbx)
jne 0x480b
addq %rbx, %rax
movl $0x0, 0x18(%rax)
movq %r14, %rdi
movl $0x66, %esi
movl -0x2c(%rbp), %edx
movl %r8d, -0x30(%rbp)
movl %r8d, %ecx
movl -0x54(%rbp), %r8d
callq 0x5647
movl $0x0, -0x54(%rbp)
jmp 0x4e7c
andb $-0x11, %cl
orb %dl, %cl
jne 0x4ea3
cmpl $0x0, 0x60(%rax,%rbx)
jne 0x480b
addq %rbx, %rax
cmpl $0x0, 0x28(%rax)
je 0x480b
movl 0x38(%rax), %edx
movl $0x0, 0x18(%rax)
movq %r14, %rdi
movl $0x66, %esi
movl %edx, -0x2c(%rbp)
movl %r8d, -0x30(%rbp)
movl %r8d, %ecx
xorl %r8d, %r8d
callq 0x5647
movl 0x104fe(%rip), %edi     # 0x15380
movl $0x66, %edx
leaq -0x160(%rbp), %rsi
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
movl $0x10, %r9d
callq 0x4060
movl -0x30(%rbp), %r8d
cmpb $0x18, -0xc9(%rbp)
jne 0x5031
movzbl -0xc6(%rbp), %eax
cmpl $0xf, %eax
je 0x4ec5
cmpl $0x9, %eax
jne 0x5031
movq 0x1048c(%rip), %rax     # 0x15358
cmpl $0x0, 0x60(%rax,%rbx)
jne 0x5031
leaq (%rax,%rbx), %rcx
movzwl -0xc3(%rbp), %edx
movzwl -0xc1(%rbp), %esi
rolw $0x8, %si
movzwl %si, %esi
rolw $0x8, %dx
movzwl %dx, %r15d
movzbl -0xc7(%rbp), %edx
movl %edx, -0x34(%rbp)
movl %r15d, 0x50(%rcx)
movl %esi, -0x2c(%rbp)
movl %esi, 0x38(%rax,%rbx)
movl %esi, 0x30(%rax,%rbx)
movl $0x1, 0x28(%rax,%rbx)
movl $0xc, %edx
movq %r13, %rdi
leaq 0xa2d2(%rip), %rsi      # 0xf1fa
movl %r8d, -0x30(%rbp)
callq 0x4330
movq 0x10428(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x26, %edx
movq %rax, %rdi
leaq 0xa20f(%rip), %rsi      # 0xf172
callq 0x4330
movq %r12, %rdi
movl %r15d, -0x3c(%rbp)
movl %r15d, %esi
leaq -0x64(%rbp), %r15
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0xa16d(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl -0x2c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0x9, %edx
movq %rax, %rdi
leaq 0xa19b(%rip), %rsi      # 0xf14a
callq 0x4330
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
leaq -0x38(%rbp), %r12
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movq %r14, %rdi
movl $0x66, %esi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
xorl %r8d, %r8d
callq 0x5647
movl 0x10377(%rip), %edi     # 0x15380
movl $0x66, %edx
leaq -0x160(%rbp), %rsi
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
movl $0x10, %r9d
callq 0x4060
movl -0x30(%rbp), %r8d
movl $0x1, -0x54(%rbp)
cmpb $0x18, -0xc9(%rbp)
jne 0x51ac
cmpb $0x8, -0xc6(%rbp)
jne 0x51ac
movq 0x10306(%rip), %rax     # 0x15358
cmpl $0x0, 0x60(%rax,%rbx)
jne 0x51ac
leaq (%rax,%rbx), %rcx
movzwl -0xc3(%rbp), %edx
movzwl -0xc1(%rbp), %esi
rolw $0x8, %si
rolw $0x8, %dx
movzwl %si, %esi
movzwl %dx, %r15d
movl %r15d, 0x50(%rcx)
movl %esi, -0x2c(%rbp)
movl %esi, 0x38(%rax,%rbx)
movl %esi, 0x30(%rax,%rbx)
movl $0x0, 0x28(%rax,%rbx)
movl 0x38(%rcx), %eax
movl %eax, 0x3c(%rcx)
movl $0xc, %edx
movq %r13, %rdi
leaq 0xa150(%rip), %rsi      # 0xf1fa
movl %r8d, -0x30(%rbp)
callq 0x4330
movq 0x102a6(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x25, %edx
movq %rax, %rdi
leaq 0xa0b4(%rip), %rsi      # 0xf199
callq 0x4330
movq %r12, %rdi
movl %r15d, -0x3c(%rbp)
movl %r15d, %esi
leaq -0x64(%rbp), %r15
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0x9feb(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl -0x2c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0x9, %edx
movq %rax, %rdi
leaq 0xa019(%rip), %rsi      # 0xf14a
callq 0x4330
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
leaq -0x38(%rbp), %r12
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movq %r14, %rdi
movl $0x66, %esi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
xorl %r8d, %r8d
callq 0x5647
movl 0x101f5(%rip), %edi     # 0x15380
movl $0x66, %edx
leaq -0x160(%rbp), %rsi
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
movl $0x10, %r9d
callq 0x4060
movl -0x30(%rbp), %r8d
cmpb $0x18, -0xc9(%rbp)
jne 0x480b
cmpb $-0x64, -0xc8(%rbp)
jne 0x480b
cmpb $0xb, -0xc6(%rbp)
jne 0x480b
movq 0x1017e(%rip), %rax     # 0x15358
cmpl $0x0, 0x60(%rax,%rbx)
jne 0x480b
addq %rbx, %rax
cmpl $0x0, 0x28(%rax)
je 0x480b
movl 0x38(%rax), %ebx
movl $0x0, 0x18(%rax)
movl $0xc, %edx
movq %r13, %rdi
leaq 0x9fef(%rip), %rsi      # 0xf1fa
movl %r8d, -0x30(%rbp)
callq 0x4330
movq 0x10145(%rip), %rax     # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x23, %edx
movq %rax, %rdi
leaq 0x9f79(%rip), %rsi      # 0xf1bf
callq 0x4330
movq %r12, %rdi
movl -0x3c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0x9e92(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl %ebx, %esi
callq 0x44c0
movq %rax, %r12
movl $0x9, %edx
movq %rax, %rdi
leaq 0x9ec1(%rip), %rsi      # 0xf14a
callq 0x4330
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
leaq -0x38(%rbp), %r12
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movq %r14, %rdi
movl $0x66, %esi
movl %ebx, -0x2c(%rbp)
movl %ebx, %edx
movl -0x30(%rbp), %ecx
xorl %r8d, %r8d
callq 0x5647
movl 0x1009b(%rip), %edi     # 0x15380
movl $0x66, %edx
leaq -0x160(%rbp), %rsi
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
jmp 0x493b
movl $0x17, %edx
movq %r13, %rdi
leaq 0x9d7b(%rip), %rsi      # 0xf086
callq 0x4330
movl -0x60(%rbp), %edi
callq 0x4120
testq %rax, %rax
je 0x5338
movq %rax, %rbx
movq %rax, %rdi
callq 0x4110
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4330
jmp 0x5351
movq (%r13), %rax
movq -0x18(%rax), %rax
leaq (%rax,%r13), %rdi
movl 0x20(%r13,%rax), %esi
orl $0x1, %esi
callq 0x44a0
movl $0x11, %edx
movq %r13, %rdi
leaq 0x9d3e(%rip), %rsi      # 0xf09e
callq 0x4330
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
jmp 0x480b
cmpl $0x0, 0xffe3(%rip)      # 0x1537c
movl -0x2c(%rbp), %r15d
je 0x547c
movl $0xc, %edx
movq %r13, %rdi
leaq 0x9e48(%rip), %rsi      # 0xf1fa
callq 0x4330
movq 0xffa2(%rip), %rax      # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x20, %edx
movq %rax, %rdi
leaq 0x9cf0(%rip), %rsi      # 0xf0d9
callq 0x4330
movq %r12, %rdi
movl -0x3c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0x9cef(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl %r15d, %esi
callq 0x44c0
movq %rax, %r12
movl $0xe, %edx
movq %rax, %rdi
leaq 0x9cd8(%rip), %rsi      # 0xf105
callq 0x4330
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0x16, %edx
movq %rax, %rdi
leaq 0x9cc5(%rip), %rsi      # 0xf114
callq 0x4330
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movl 0xfefe(%rip), %edi      # 0x15380
movl $0x66, %edx
leaq -0x160(%rbp), %rsi
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
movl $0x10, %r9d
callq 0x4060
movq 0xfeb2(%rip), %rax      # 0x15358
movl $0x0, 0x28(%rax,%rbx)
testl %r15d, %r15d
leaq -0x38(%rbp), %r12
leaq -0x64(%rbp), %r15
jne 0x480b
addq %rbx, %rax
addq $0x28, %rax
movl $0x1, (%rax)
xorl %ecx, %ecx
movl %ecx, -0x10(%rax)
movl %ecx, 0x10(%rax)
jmp 0x480b
cmpl $0x0, 0xfe9c(%rip)      # 0x1537c
je 0x55c3
movl $0xc, %edx
movq %r13, %rdi
leaq 0x9d05(%rip), %rsi      # 0xf1fa
callq 0x4330
movq 0xfe5f(%rip), %rax      # 0x15360
movq -0x48(%rbp), %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r13, %rdi
callq 0x4330
movq %rax, %r12
movl $0x20, %edx
movq %rax, %rdi
leaq 0x9bad(%rip), %rsi      # 0xf0d9
callq 0x4330
movq %r12, %rdi
movl -0x4c(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0xa, %edx
movq %rax, %rdi
leaq 0x9bac(%rip), %rsi      # 0xf0fa
callq 0x4330
movq %r12, %rdi
movl -0x50(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0xe, %edx
movq %rax, %rdi
leaq 0x9b95(%rip), %rsi      # 0xf105
callq 0x4330
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x44c0
movq %rax, %r12
movl $0x16, %edx
movq %rax, %rdi
leaq 0x9b82(%rip), %rsi      # 0xf114
callq 0x4330
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %r12, %rdi
leaq -0x38(%rbp), %r12
callq 0x4040
movq %rax, %rdi
callq 0x41e0
movl 0xfdb7(%rip), %edi      # 0x15380
movl $0x66, %edx
leaq -0x160(%rbp), %rsi
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
movl $0x10, %r9d
callq 0x4060
movl -0x4c(%rbp), %esi
movl %esi, -0x3c(%rbp)
movl -0x50(%rbp), %edx
movl %edx, -0x2c(%rbp)
testl %edx, %edx
jne 0x480b
movq 0xfd57(%rip), %rax      # 0x15358
xorl %ecx, %ecx
movl %ecx, 0x28(%rax,%rbx)
movl %ecx, 0x18(%rax,%rbx)
movl 0x38(%rax,%rbx), %ecx
movl %ecx, 0x3c(%rax,%rbx)
movl %esi, -0x3c(%rbp)
movl %edx, -0x2c(%rbp)
jmp 0x480b
leaq 0x9a0b(%rip), %rdi      # 0xf030
jmp 0x562e
leaq 0x9a18(%rip), %rdi      # 0xf046
callq 0x4280
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq