// File: /workspace/github_c_makefile_star2_O0/fmadio[P]pcap_flow/main.c
// Function: ReadPCAP
static PCAPPacket_t* ReadPCAP(PCAPFile_t* PCAP)
{
	int ret;
	PCAPPacket_t* Pkt = (PCAPPacket_t*)PCAP->PacketBuffer;
	ret = fread(Pkt, 1, sizeof(PCAPPacket_t), PCAP->F);
	if (ret != sizeof(PCAPPacket_t))
	{
		fprintf(stderr, "header read failed. expect:%li got:%i errno:%i %s\n", sizeof(PCAPPacket_t), ret, errno, strerror(errno));
		fprintf(stderr, "errno: %i\n", ferror(PCAP->F));
		return NULL;
	}

	if (PCAP->ReadPos + sizeof(PCAPPacket_t) + Pkt->LengthCapture > PCAP->Length)
	{
		fprintf(stderr, "read overflow %lli %li %i > %lli\n", 
				PCAP->ReadPos,
				sizeof(PCAPPacket_t),
				Pkt->LengthCapture,
				PCAP->Length
		);	
		return NULL; 
	}

	ret = fread(Pkt+1, 1, Pkt->LengthCapture, PCAP->F);
	if (ret != Pkt->LengthCapture)
	{
		fprintf(stderr, "payload read failed. expect:%li got:%i errno:%i %s\n", sizeof(PCAPPacket_t), ret, errno, strerror(errno));
		fprintf(stderr, "errno: %i\n", ferror(PCAP->F));
		return NULL;
	}

	PCAP->ReadPos += Pkt->LengthCapture;
	return Pkt;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq 0xc0(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rax
movq 0x88(%rax), %rcx
movl $0x1, %esi
movl $0x10, %edx
callq 0x10a0
movl %eax, 0x44(%rsp)
movslq 0x44(%rsp), %rax
cmpq $0x10, %rax
je 0x7912
movq 0x8774(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x28(%rsp)
callq 0x1040
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
callq 0x1040
movl (%rax), %edi
callq 0x1240
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %ecx
movl 0x2c(%rsp), %r8d
movq %rax, %r9
leaq 0x6027(%rip), %rsi      # 0xd8ea
movl $0x10, %edx
movb $0x0, %al
callq 0x1150
movq 0x8722(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x48(%rsp), %rax
movq 0x88(%rax), %rdi
callq 0x1090
movq 0x30(%rsp), %rdi
movl %eax, %edx
leaq 0x6020(%rip), %rsi      # 0xd91d
movb $0x0, %al
callq 0x1150
movq $0x0, 0x50(%rsp)
jmp 0x7a7f
movq 0x48(%rsp), %rax
movq 0xb0(%rax), %rax
addq $0x10, %rax
movq 0x38(%rsp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
movq 0x48(%rsp), %rcx
cmpq 0x98(%rcx), %rax
jbe 0x7987
movq 0x86b6(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0x48(%rsp), %rax
movq 0xb0(%rax), %rdx
movq 0x38(%rsp), %rax
movl 0x8(%rax), %r8d
movq 0x48(%rsp), %rax
movq 0x98(%rax), %r9
leaq 0x5fbb(%rip), %rsi      # 0xd928
movl $0x10, %ecx
movb $0x0, %al
callq 0x1150
movq $0x0, 0x50(%rsp)
jmp 0x7a7f
movq 0x38(%rsp), %rdi
addq $0x10, %rdi
movq 0x38(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movq 0x48(%rsp), %rax
movq 0x88(%rax), %rcx
movl $0x1, %esi
callq 0x10a0
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl 0x8(%rcx), %eax
je 0x7a58
movq 0x862b(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x10(%rsp)
callq 0x1040
movl (%rax), %eax
movl %eax, 0x14(%rsp)
callq 0x1040
movl (%rax), %edi
callq 0x1240
movq 0x8(%rsp), %rdi
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %r8d
movq %rax, %r9
leaq 0x5f3e(%rip), %rsi      # 0xd94a
movl $0x10, %edx
movb $0x0, %al
callq 0x1150
movq 0x85d9(%rip), %rax      # 0xfff8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rax
movq 0x88(%rax), %rdi
callq 0x1090
movq 0x18(%rsp), %rdi
movl %eax, %edx
leaq 0x5ed7(%rip), %rsi      # 0xd91d
movb $0x0, %al
callq 0x1150
movq $0x0, 0x50(%rsp)
jmp 0x7a7f
movq 0x38(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, %ecx
movq 0x48(%rsp), %rax
addq 0xb0(%rax), %rcx
movq %rcx, 0xb0(%rax)
movq 0x38(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopl (%rax)