// File: /workspace/github_c_makefile_star2_O0/fmadio[P]pcap_flow/fFile.c
// Function: fFile_Write
void fFile_Write(struct fFile_t* F, void* Buffer, u32 Length, bool IsPayload)
{
	// should never write with a null file handle
	assert(F != NULL);

	// need to create a file 
	if (F->IsBuffer)
	{
		if (F->BufferPos + Length > F->BufferMax)
		{
			F->File = fopen(F->Path, "a");
			assert(F->File != NULL);

			fwrite(F->Buffer, 1, F->BufferPos, F->File);
			F->TotalByte	+= F->BufferPos;

			F->IsBuffer 	= false;
			F->BufferPos	= 0;

			s_TotalFileActive++;
		}
	}

	// buffer it
	if (F->IsBuffer)
	{
		memcpy(F->Buffer + F->BufferPos, Buffer, Length);
		F->BufferPos += Length;
	}
	else
	{
		assert(F->File != NULL);

		fwrite(Buffer, 1, Length, F->File);
		if (s_ForceFlush) fflush(F->File);
		F->TotalByte	+= Length; 
	}

	// if this is payload
	if (IsPayload) F->TotalPayload += Length;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl %edx, 0x4(%rsp)
movl %ecx, (%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xb91f
jmp 0xb93e
leaq 0x1ef4(%rip), %rdi      # 0xd81a
leaq 0x220a(%rip), %rsi      # 0xdb37
movl $0x5d, %edx
leaq 0x2206(%rip), %rcx      # 0xdb3f
callq 0x1100
movq 0x10(%rsp), %rax
cmpl $0x0, 0x408(%rax)
je 0xba45
movq 0x10(%rsp), %rax
movq 0x418(%rax), %rax
movl 0x4(%rsp), %ecx
addq %rcx, %rax
movq 0x10(%rsp), %rcx
cmpq 0x420(%rcx), %rax
jbe 0xba43
movq 0x10(%rsp), %rdi
leaq 0x21f4(%rip), %rsi      # 0xdb75
callq 0x11e0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x400(%rax)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x400(%rax)
je 0xb9a6
jmp 0xb9c5
leaq 0x21ca(%rip), %rdi      # 0xdb77
leaq 0x2183(%rip), %rsi      # 0xdb37
movl $0x65, %edx
leaq 0x217f(%rip), %rcx      # 0xdb3f
callq 0x1100
movq 0x10(%rsp), %rax
movq 0x410(%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x418(%rax), %rdx
movq 0x10(%rsp), %rax
movq 0x400(%rax), %rcx
movl $0x1, %esi
callq 0x1220
movq 0x10(%rsp), %rax
movq 0x418(%rax), %rcx
movq 0x10(%rsp), %rax
addq 0x428(%rax), %rcx
movq %rcx, 0x428(%rax)
movq 0x10(%rsp), %rax
movl $0x0, 0x408(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x418(%rax)
movq 0x6780(%rip), %rax      # 0x121b8
addq $0x1, %rax
movq %rax, 0x6775(%rip)      # 0x121b8
jmp 0xba45
movq 0x10(%rsp), %rax
cmpl $0x0, 0x408(%rax)
je 0xba99
movq 0x10(%rsp), %rax
movq 0x410(%rax), %rdi
movq 0x10(%rsp), %rax
addq 0x418(%rax), %rdi
movq 0x8(%rsp), %rsi
movl 0x4(%rsp), %eax
movl %eax, %edx
callq 0x1170
movl 0x4(%rsp), %eax
movl %eax, %ecx
movq 0x10(%rsp), %rax
addq 0x418(%rax), %rcx
movq %rcx, 0x418(%rax)
jmp 0xbb1d
movq 0x10(%rsp), %rax
cmpq $0x0, 0x400(%rax)
je 0xbaaa
jmp 0xbac9
leaq 0x20c6(%rip), %rdi      # 0xdb77
leaq 0x207f(%rip), %rsi      # 0xdb37
movl $0x79, %edx
leaq 0x207b(%rip), %rcx      # 0xdb3f
callq 0x1100
movq 0x8(%rsp), %rdi
movl 0x4(%rsp), %eax
movl %eax, %edx
movq 0x10(%rsp), %rax
movq 0x400(%rax), %rcx
movl $0x1, %esi
callq 0x1220
cmpl $0x0, 0x66cf(%rip)      # 0x121c0
je 0xbb04
movq 0x10(%rsp), %rax
movq 0x400(%rax), %rdi
callq 0x11a0
movl 0x4(%rsp), %eax
movl %eax, %ecx
movq 0x10(%rsp), %rax
addq 0x428(%rax), %rcx
movq %rcx, 0x428(%rax)
cmpl $0x0, (%rsp)
je 0xbb3c
movl 0x4(%rsp), %eax
movl %eax, %ecx
movq 0x10(%rsp), %rax
addq 0x430(%rax), %rcx
movq %rcx, 0x430(%rax)
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)