// File: /workspace/github_c_makefile_star2_O2/fmadio[P]pcap_flow/tcpstream.c
// Function: fTCPStream_PacketAdd
void fTCPStream_PacketAdd(TCPStream_t* S, u64 TS, TCPHeader_t* TCP, s32 Length, u8* Payload, PCAPPacket_t* Pkt)
{
	// raw PCAP output only 
	if (g_OutputPCAP)
	{
		// closed so re-open
		if (!S->File)
		{
			S->File = fFile_Open(S->Path, NULL); 
			if (S->File == NULL)
			{
				fprintf(stderr, "failed to open output file [%s]\n", S->Path);
			}
		}
		fFile_Write(S->File, Pkt, sizeof(PCAPPacket_t) + Pkt->LengthCapture, true);
		return;
	}

	// if length is invalid then drop the packet
	if (Length < 0)
	{
		printf("ERROR: TCP Packet Length Negative!?: %s %s : %i\n", FormatTS(TS), S->Path, Length);
		return;
	}

	//printf("tcp len: %i %08x %08x\n", Length, swap32(TCP->SeqNo), swap32(TCP->AckNo));
	u32 WindowSize 	= swap16( TCP->Window) * S->WindowScale;
	u32 SeqNo 		= swap32( TCP->SeqNo );
	u32 AckNo 		= swap32( TCP->AckNo );

	// last packet TS	
	S->LastTS 		= TS; 

	u32 Flag 		= StreamTCPFlag(TCP->Flags); 
	if (TCP_FLAG_SYN(TCP->Flags))
	{
		if (g_Verbose) printf("[%s] [%s] got syn\n", FormatTS(TS), S->Path);
		S->SeqNo = SeqNo + 1;

		fProfile_Start(9, "TCP PktAdd release");

		// release all reassembly buffer data . assumption is this is now a new tcp stream
		for (int i=0; i < S->BufferListPos; i++)
		{
			TCPBuffer_t* Buffer = S->BufferList[i];

			free(Buffer->Payload);
			Buffer->Payload = NULL;

			free(Buffer);

			s_TCPBufferMemoryTotal  -= sizeof(TCPBuffer_t) + Length;
			s_TCPBufferPacketTotal 	-= 1;
		}
		S->BufferListPos = 0;

		fProfile_Stop(9);

		// parse options
		u32 OLen = (4*swap16(TCP->Flags) >> 12) - 20;
		u8* Option = (u8*)(TCP + 1);
		for (int o=0; o < OLen; o++)
		{
			// end of options
			if (Option[o] == 0) break;

			// nop
			if (Option[o] == 1) continue;

			// MSS
			if ((Option[o+0] == 2) && (Option[o+1] == 4))
			{
				u32 MSS = ((u32)Option[o+2]<< 8) | (u32)Option[o+3];
				if (g_Verbose) printf("TCP MSS: %i\n", MSS);
				o+= 2;
			}
			// Window Scale 
			if ((Option[o+0] == 3) && (Option[o+1] == 3))
			{
				u32 Scale = Option[o+2];
				if (g_Verbose) printf("TCP WindowScale: %i\n", Scale);
				o+= 1;
				S->WindowScale = Scale;
			}
			// Selective Ack 
			if ((Option[o+0] == 4) && (Option[o+1] == 2))
			{
				if (g_Verbose) printf("TCP SelAck\n");
			}
			//printf("tcp offset: [%4i] %02x\n", o, Option[o]);
		}

		// indicate stream reset
		if (g_EnableTCPHeader)
		{
			TCPOutputHeader_t Header;
			Header.TS 		= TS;
			Header.Length 	= 0;
			Header.StreamID	= S->FlowID;
			Header.SeqNo	= 0; 
			Header.AckNo	= 0; 
			Header.Window	= 0; 
			Header.Flag		= Flag | TCPHEADER_FLAG_RESET; 
			Header.CRC		= 0;
			Header.CRC		+= Header.TS;
			Header.CRC		+= Header.Length;
			Header.CRC		+= Header.StreamID;
			Header.CRC		+= Header.SeqNo;
			Header.CRC		+= Header.AckNo;
			Header.CRC		+= Header.Window;
			Header.CRC		+= Header.Flag;

			fTCPStream_OutputHeader(S, &Header);
		}
	}

	if (Length == 0)
	{
		// usuall ack with no payload	
		if (g_EnableTCPHeader)
		{
			TCPOutputHeader_t Header;
			Header.TS 		= TS;
			Header.Length 	= Length;
			Header.StreamID	= S->FlowID;
			Header.SeqNo	= SeqNo; 
			Header.AckNo	= AckNo; 
			Header.Window	= WindowSize; 
			Header.Flag		= Flag; 
			Header.CRC		= 0;
			Header.CRC		+= Header.TS;
			Header.CRC		+= Header.Length;
			Header.CRC		+= Header.StreamID;
			Header.CRC		+= Header.SeqNo;
			Header.CRC		+= Header.AckNo;
			Header.CRC		+= Header.Window;
			Header.CRC		+= Header.Flag;

			fTCPStream_OutputHeader(S, &Header);
		}
	}
	else
	{
		s32 dSeqNo = SeqNo - S->SeqNo;
		if (dSeqNo == 0)
		{
			fTCPStream_OutputPayload(S, TS, Length, Payload, Flag, SeqNo, AckNo, WindowSize);
			if (S->BufferListPos > 0)
			{
				if (g_Verbose) printf("[%s] [%s] resend hit Seq:%08x : %i\n", FormatTS(TS), S->Path, SeqNo, S->BufferListPos);

				// check for reassembly
				fTCPStream_Reassembly(S, TS, Flag);
			}
		}
		else
		{
			fProfile_Start(7, "TCP PktAdd OOO");

			// reassembly packet thats not aligned but close to the current seq no
			s32 dRemain = (SeqNo + Length) - S->SeqNo;
			if ((SeqNo < S->SeqNo) && (dRemain > 0) && (dRemain < 8*1024))
			{
				if (g_Verbose) 
				{
					printf("[%s] [%s] unaligned seq resend: %i [%llx:%llx]\n",
						FormatTS(TS),
						S->Path,
						dRemain,
						S->WritePos,
						S->WritePos + dRemain
					   );
				}

				s32 PayloadOffset = S->SeqNo - SeqNo; 
				if (PayloadOffset <= 0)
				{
					printf("[%s] [%s] ERROR: TCP OOO reassembly PayloadOffset:%i SeqNo:%08x %08x dRemain:%i Length:%i\n", FormatTS(TS), S->Path, PayloadOffset, S->SeqNo, SeqNo, dRemain, Length);
				}
				else
				{
					fTCPStream_OutputPayload(S, TS, dRemain, Payload + PayloadOffset, Flag | TCPHEADER_FLAG_REASSEMBLE, S->SeqNo, 0, 0);

					// check re-assembly buffer 
					fTCPStream_Reassembly(S, TS, Flag);
				}
			}

			// stop processing if too many gaps 
			else if (S->BufferListPos < S->BufferListMax)
			{
				TCPBuffer_t* B = (TCPBuffer_t*)malloc( sizeof(TCPBuffer_t) );
				assert(B != NULL);

				s_TCPBufferMemoryTotal  += sizeof(TCPBuffer_t) + Length;
				s_TCPBufferPacketTotal 	+= 1;
				g_TotalMemory 			+= sizeof(TCPBuffer_t) + Length;
				g_TotalMemoryTCP 		+= sizeof(TCPBuffer_t) + Length;

				memset(B, 0, sizeof(TCPBuffer_t));
				if (Length >= MAX_TCPSEGMENT)
				{
					printf("TCP length overflow: %i %i\n", Length,  MAX_TCPSEGMENT);
					return;
				}
				//assert(Length < MAX_TCPSEGMENT);

				B->TS 		= TS;
				B->SeqNo 	= SeqNo;
				B->Length 	= Length;
				B->Payload	= malloc( Length );

				assert(B->Payload != NULL);
				memcpy(B->Payload, Payload, Length);

				S->BufferList[ S->BufferListPos++ ] = B;	

				if (g_Verbose)
				{
					printf("[%s] [%s] tcp gap Seq:%08x PktSeq:%08x delta %i OOPkts:%i SEnd:%08x\n", 
						FormatTS(TS), 
						S->Path, 
						S->SeqNo, 
						SeqNo, 
						dSeqNo,
						S->BufferListPos,
						SeqNo + Length);
					printf("[%s] TCP Buffer: %lliMB %.fK Pkts\n", FormatTS(TS), s_TCPBufferMemoryTotal / kMB(1), s_TCPBufferPacketTotal / 1e3 ); 
				}

				// special case when capture begins mid-stream
				if (S->SeqNo == 0)
				{
					if (g_Verbose) printf("[%s] %s midstream start Len:%i\n", FormatTS(TS), S->Path, Length); 
					S->SeqNo = swap32(TCP->SeqNo) + Length;
				}
			}
			else
			{
				// no space for re-assembly so drop it
				S->PktDrop++;
			}

			// number of packets out of order
			S->PktOOO++;;

			fProfile_Stop(7);
		}
	}

	// toatl number of packets
	S->PktTotal++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %r13d
movq %rdi, %rcx
leaq 0xba60(%rip), %rax      # 0xd214
cmpl $0x0, (%rax)
je 0x180a
movq %r9, %r12
movq 0x8(%rcx), %rdi
testq %rdi, %rdi
jne 0x17e9
leaq 0x2028(%rcx), %r14
movq %r14, %rdi
xorl %esi, %esi
movq %rcx, %rbx
callq 0x6e34
movq %rax, %rdi
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x1e86
movl 0x8(%r12), %edx
addl $0x10, %edx
pushq $0x1
popq %rcx
movq %r12, %rsi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6ec0
movq %rsi, %r15
testl %r13d, %r13d
js 0x1938
movq %r8, 0x30(%rsp)
movzwl 0xe(%rdx), %eax
rolw $0x8, %ax
movzwl %ax, %eax
imull 0x2448(%rcx), %eax
movq %rax, (%rsp)
movl 0x4(%rdx), %r12d
movl 0x8(%rdx), %ebx
bswapl %r12d
movq %r15, 0x2430(%rcx)
movzwl 0xc(%rdx), %eax
movl %eax, %esi
shrl $0x8, %esi
btl $0x9, %eax
movq %rsi, 0x18(%rsp)
movzwl %si, %ebp
movq %rdx, 0x10(%rsp)
jae 0x1ae4
movq %rbp, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movq %r13, 0x20(%rsp)
leaq 0xb980(%rip), %rax      # 0xd1f8
cmpl $0x0, (%rax)
je 0x18a3
movq %r15, %rdi
movq %rcx, %rbx
callq 0x1f5d
leaq 0x2028(%rbx), %rdx
leaq 0x68e3(%rip), %rdi      # 0x8179
movq %rax, %rsi
xorl %eax, %eax
callq 0x10f0
movq %rbx, %rcx
movq %r15, 0x28(%rsp)
movq %r12, 0x8(%rsp)
leal 0x1(%r12), %eax
movl %eax, 0x18(%rcx)
rdtsc
shlq $0x20, %rdx
movl %eax, %eax
orq %rdx, %rax
movq %rcx, %r13
leaq 0xc4e6(%rip), %rcx      # 0xddb0
movq %rax, 0x48(%rcx)
leaq 0x68b7(%rip), %rax      # 0x818c
leaq 0xc7d4(%rip), %rcx      # 0xe0b0
movq %rax, 0x48(%rcx)
movq 0xa8b9(%rip), %rbp      # 0xc1a0
movq 0xa8ba(%rip), %r14      # 0xc1a8
movq 0x20(%rsp), %rax
leal 0x18(%rax), %r15d
decq %r14
subq %r15, %rbp
xorl %ebx, %ebx
movl 0x1c(%r13), %eax
cmpq %rax, %rbx
jae 0x196f
movq 0x28(%r13,%rbx,8), %r12
movq 0x10(%r12), %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %rbp, 0xa87a(%rip)      # 0xc1a0
movq %r14, 0xa87b(%rip)      # 0xc1a8
incq %rbx
decq %r14
subq %r15, %rbp
jmp 0x18ff
movq %r15, %rdi
movq %rcx, %rbx
callq 0x1f5d
addq $0x2028, %rbx           # imm = 0x2028
leaq 0x67f7(%rip), %rdi      # 0x8148
movq %rax, %rsi
movq %rbx, %rdx
movl %r13d, %ecx
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
movq %r13, %r14
andl $0x0, 0x1c(%r13)
pushq $0x9
popq %rdi
callq 0x1670
movq 0x10(%rsp), %rdx
movzwl 0xc(%rdx), %r12d
shrl $0x2, %r12d
andl $0x3f, %r12d
addl $-0x14, %r12d
xorl %ebp, %ebp
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r13
cmpl %r12d, %ebp
jae 0x1a84
movslq %ebp, %rax
movzbl 0x14(%rdx,%rax), %ecx
cmpl $0x1, %ecx
je 0x1a7d
cmpl $0x2, %ecx
je 0x19c9
testl %ecx, %ecx
jne 0x1a08
jmp 0x1a84
cmpb $0x4, 0x15(%rdx,%rax)
jne 0x1a08
movslq %ebp, %rbp
addq $0x2, %rbp
leaq 0xb81a(%rip), %rcx      # 0xd1f8
cmpl $0x0, (%rcx)
je 0x1a05
movzbl 0x14(%rdx,%rbp), %ecx
shll $0x8, %ecx
movzbl 0x17(%rdx,%rax), %esi
orl %ecx, %esi
leaq 0x67a6(%rip), %rdi      # 0x819f
xorl %eax, %eax
callq 0x10f0
movq 0x10(%rsp), %rdx
movq %rbp, %rax
movb 0x14(%rdx,%rax), %cl
cmpb $0x3, %cl
jne 0x1a54
movslq %ebp, %rbx
cmpb $0x3, 0x15(%rdx,%rbx)
jne 0x1a7d
movzbl 0x16(%rdx,%rax), %ebp
leaq 0xb7d1(%rip), %rax      # 0xd1f8
cmpl $0x0, (%rax)
je 0x1a41
leaq 0x6779(%rip), %rdi      # 0x81ac
movl %ebp, %esi
xorl %eax, %eax
callq 0x10f0
movq 0x10(%rsp), %rdx
incq %rbx
movl %ebp, 0x2448(%r14)
movb 0x14(%rdx,%rbx), %cl
movq %rbx, %rax
movl %ebx, %ebp
cmpb $0x4, %cl
jne 0x1a7d
cmpb $0x2, 0x15(%rdx,%rax)
jne 0x1a7d
leaq 0xb791(%rip), %rax      # 0xd1f8
cmpl $0x0, (%rax)
je 0x1a7d
leaq 0x6bb5(%rip), %rdi      # 0x8628
callq 0x1090
movq 0x10(%rsp), %rdx
incl %ebp
jmp 0x19a1
leaq 0xb771(%rip), %rax      # 0xd1fc
cmpl $0x0, (%rax)
movq %r14, %rcx
movq 0x8(%rsp), %r12
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %rbp
je 0x1ae4
leaq 0x48(%rsp), %rsi
movq %r15, (%rsi)
andw $0x0, 0x8(%rsi)
movl 0x10(%rcx), %eax
movw %ax, 0xa(%rsi)
andq $0x0, 0xc(%rsi)
andl $0x0, 0x14(%rsi)
leal 0x8000(%rbp), %ecx
movw %cx, 0x18(%rsi)
leal (%r15,%rbp), %ecx
addl $0x8000, %ecx           # imm = 0x8000
addl %eax, %ecx
movw %cx, 0x1a(%rsi)
movq %r14, %rdi
callq 0x1549
movq %r14, %rcx
bswapl %ebx
testl %r13d, %r13d
je 0x1b7d
movl %r12d, %ebp
subl 0x18(%rcx), %ebp
jne 0x1bd4
movq %rbx, %rax
movq %rcx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %rcx, %rbx
movq 0x30(%rsp), %rcx
movq 0x18(%rsp), %r14
movl %r14d, %r8d
movl %r12d, %r9d
pushq (%rsp)
pushq %rax
callq 0x1698
movq %rbx, %rcx
addq $0x10, %rsp
cmpl $0x0, 0x1c(%rbx)
je 0x1ef2
leaq 0xb6bd(%rip), %rax      # 0xd1f8
cmpl $0x0, (%rax)
je 0x1b6a
movq %r15, %rdi
callq 0x1f5d
leaq 0x2028(%rbx), %rdx
movl 0x1c(%rbx), %r8d
leaq 0x6667(%rip), %rdi      # 0x81c1
movq %rax, %rsi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x10f0
movq %rbx, %rcx
movq %rcx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x202e
jmp 0x1eef
leaq 0xb678(%rip), %rax      # 0xd1fc
cmpl $0x0, (%rax)
je 0x1ef2
leaq 0x48(%rsp), %rsi
movq %r15, (%rsi)
andw $0x0, 0x8(%rsi)
movl 0x10(%rcx), %eax
movw %ax, 0xa(%rsi)
movl %r12d, 0xc(%rsi)
movl %ebx, 0x10(%rsi)
movq (%rsp), %rdx
movl %edx, 0x14(%rsi)
movw %bp, 0x18(%rsi)
addl %r12d, %r15d
addl %edx, %r15d
addl %ebp, %ebx
addl %r15d, %ebx
addl %eax, %ebx
movw %bx, 0x1a(%rsi)
movq %rcx, %rdi
movq %rcx, %rbx
callq 0x1549
jmp 0x1eef
rdtsc
shlq $0x20, %rdx
movl %eax, %eax
orq %rdx, %rax
movq %rcx, %rbx
leaq 0xc1c7(%rip), %rcx      # 0xddb0
movq %rax, 0x38(%rcx)
leaq 0x65f1(%rip), %rax      # 0x81e5
leaq 0xc4b5(%rip), %rcx      # 0xe0b0
movq %rax, 0x38(%rcx)
leal (%r12,%r13), %edx
movl 0x18(%rbx), %r9d
movq %r12, %rax
movl %edx, %r12d
subl %r9d, %r12d
movq %rax, 0x8(%rsp)
cmpl %r9d, %eax
setae %al
leal -0x1(%r12), %ecx
cmpl $0x1fff, %ecx           # imm = 0x1FFF
setae %cl
orb %al, %cl
movq 0x30(%rsp), %r14
jne 0x1cc9
leaq 0xb5bb(%rip), %rax      # 0xd1f8
cmpl $0x0, (%rax)
je 0x1c76
movq %r15, %rdi
callq 0x1f5d
leaq 0x2028(%rbx), %rdx
movq 0x2440(%rbx), %r8
movl %r12d, %r9d
addq %r8, %r9
leaq 0x658f(%rip), %rdi      # 0x81f4
movq %rax, %rsi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x10f0
movl 0x18(%rbx), %r9d
movl %r9d, %ebp
movq 0x8(%rsp), %r14
subl %r14d, %ebp
testl %ebp, %ebp
jle 0x1eaa
movq %rbx, %rdi
movl %ebp, %eax
movq 0x30(%rsp), %rcx
addq %rax, %rcx
movq 0x18(%rsp), %r14
leal 0x4000(%r14), %r8d
movq %r15, %rsi
movl %r12d, %edx
pushq $0x0
pushq $0x0
callq 0x1698
popq %rax
popq %rcx
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x202e
movq %rbx, %rcx
jmp 0x1ede
movl 0x1c(%rbx), %eax
cmpl 0x20(%rbx), %eax
movq %rbx, %rcx
jae 0x1e7e
movq %rax, 0x18(%rsp)
movq %rdx, 0x28(%rsp)
movl %r9d, 0x20(%rsp)
movq %rcx, (%rsp)
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x1140
testq %rax, %rax
je 0x1f1f
movq %rax, %r12
movl %r13d, %edi
leaq 0x18(%rdi), %rax
addq %rax, 0xa490(%rip)      # 0xc1a0
incq 0xa491(%rip)            # 0xc1a8
leaq 0xb4ca(%rip), %rcx      # 0xd1e8
addq %rax, (%rcx)
leaq 0xb4c8(%rip), %rcx      # 0xd1f0
addq %rax, (%rcx)
cmpl $0xfffff, %r13d         # imm = 0xFFFFF
jg 0x1f07
movq %r15, (%r12)
movq 0x8(%rsp), %rax
movl %eax, 0x8(%r12)
movl %r13d, 0xc(%r12)
movq %rdi, %rbx
callq 0x11b0
movq %rax, 0x10(%r12)
testq %rax, %rax
je 0x1f3e
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1190
movq 0x18(%rsp), %rbx
leal 0x1(%rbx), %eax
movq (%rsp), %rcx
movl %eax, 0x1c(%rcx)
movq %r12, 0x28(%rcx,%rbx,8)
leaq 0xb46e(%rip), %r12      # 0xd1f8
cmpl $0x0, (%r12)
movl 0x20(%rsp), %ebx
je 0x1e32
movq %r15, %rdi
callq 0x1f5d
movq (%rsp), %rcx
leaq 0x2028(%rcx), %rdx
movq (%rsp), %rcx
movl 0x18(%rcx), %ecx
movq (%rsp), %rsi
movl 0x1c(%rsi), %r10d
leaq 0x654e(%rip), %rdi      # 0x8310
movq %rax, %rsi
movq 0x8(%rsp), %r8
movl %ebp, %r9d
xorl %eax, %eax
pushq 0x28(%rsp)
pushq %r10
callq 0x10f0
popq %rcx
popq %rdx
movq %r15, %rdi
callq 0x1f5d
movq 0xa3b5(%rip), %rdx      # 0xc1a0
movsd 0xa3b5(%rip), %xmm1     # 0xc1a8
unpcklps 0x6226(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
shrq $0x14, %rdx
subpd 0x622a(%rip), %xmm1     # 0x8030
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x6226(%rip), %xmm0     # 0x8040
leaq 0x6534(%rip), %rdi      # 0x8355
movq %rax, %rsi
movb $0x1, %al
callq 0x10f0
movq (%rsp), %rcx
movl 0x18(%rcx), %ebx
testl %ebx, %ebx
jne 0x1ede
cmpl $0x0, (%r12)
je 0x1e6c
movq %r15, %rdi
callq 0x1f5d
movq (%rsp), %rcx
leaq 0x2028(%rcx), %rdx
leaq 0x651d(%rip), %rdi      # 0x8378
movq %rax, %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x10f0
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
bswapl %eax
addl %r13d, %eax
movl %eax, 0x18(%rcx)
jmp 0x1ede
incl 0x2450(%rcx)
jmp 0x1ede
movq 0xa16b(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x6290(%rip), %rsi      # 0x8127
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
movq 0x8(%rbx), %rdi
jmp 0x17e9
movq %r15, %rdi
callq 0x1f5d
leaq 0x2028(%rbx), %rdx
movl 0x18(%rbx), %r8d
leaq 0x6360(%rip), %rdi      # 0x8224
movq %rax, %rsi
movl %ebp, %ecx
movl %r14d, %r9d
xorl %eax, %eax
pushq %r13
pushq %r12
callq 0x10f0
movq %rbx, %rcx
addq $0x10, %rsp
incl 0x2454(%rcx)
pushq $0x7
popq %rdi
movq %rcx, %rbx
callq 0x1670
movq %rbx, %rcx
incl 0x2458(%rcx)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x63d3(%rip), %rdi      # 0x82e1
movl %r13d, %esi
movl $0x100000, %edx         # imm = 0x100000
xorl %eax, %eax
callq 0x10f0
jmp 0x1ef8
leaq 0x6359(%rip), %rdi      # 0x827f
leaq 0x613f(%rip), %rsi      # 0x806c
leaq 0x6355(%rip), %rcx      # 0x8289
movl $0x257, %edx            # imm = 0x257
callq 0x1110
leaq 0x63b8(%rip), %rdi      # 0x82fd
leaq 0x6120(%rip), %rsi      # 0x806c
leaq 0x6336(%rip), %rcx      # 0x8289
movl $0x26b, %edx            # imm = 0x26B
callq 0x1110