// File: /workspace/github_cpp_makefile_star2_O1/lrq3000[P]rfrb/./src/bufferedFileReader.cpp
// Function: Buffered_FileReader::reloadBuffer()
bool Buffered_FileReader::reloadBuffer()
{
	//Lambda function
	auto lambda = [&] () -> bool
	{
		HDD_Avail.lock();
		if (m_fs.is_open())
		{
			m_fs.read((char *)m_loadBuffer, m_bufferSize);
			m_loadedElements = m_fs.gcount();
		}
		HDD_Avail.unlock();
		m_localMtx.unlock();
		if (m_loadedElements == 0)
			return false;
		return true;
	};

	//Swap buffers
	m_localMtx.lock();
	char *tmp = m_loadBuffer;
	m_loadBuffer = m_workBuffer;
	m_workBuffer = tmp;
	m_globalAdress += m_elements;
	m_elements = m_loadedElements;

	//Reload buffer async
	m_threadSync = std::async(std::launch::async, lambda);
	if (m_elements == 0)
		return false;
	return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
addq $0x270, %rdi            # imm = 0x270
callq 0x5540
testl %eax, %eax
jne 0x11f43
movdqu 0x250(%rbx), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, 0x250(%rbx)
movq 0x238(%rbx), %rax
movq 0x240(%rbx), %rcx
addq %rax, 0x248(%rbx)
movq %rcx, 0x238(%rbx)
pxor %xmm0, %xmm0
movdqa %xmm0, (%rsp)
movl $0x50, %edi
callq 0x53d0
movq %rax, %r14
movabsq $0x100000001, %r13      # imm = 0x100000001
movq %r13, 0x8(%rax)
leaq 0xcc52(%rip), %rax      # 0x1e9e8
movq %rax, (%r14)
leaq 0x10(%r14), %r15
xorl %eax, %eax
movl %eax, 0x28(%r14)
movq %rax, 0x18(%r14)
movq %rax, 0x1d(%r14)
movq %rax, 0x30(%r14)
movl %eax, 0x38(%r14)
leaq 0xcc7e(%rip), %rax      # 0x1ea38
movq %rax, 0x10(%r14)
movl $0x18, %edi
callq 0x53d0
movq %rax, %r12
movq %rax, %rdi
callq 0x12596
movq %r12, 0x40(%r14)
movq %rbx, 0x48(%r14)
movq $0x0, 0x10(%rsp)
movl $0x20, %edi
callq 0x53d0
leaq 0xcc9b(%rip), %rcx      # 0x1ea90
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
leaq 0x37b(%rip), %rcx       # 0x1217e
movq %rcx, 0x10(%rax)
movq $0x0, 0x18(%rax)
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10(%rsp), %rdi
xorl %edx, %edx
callq 0x5340
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11e33
movq (%rdi), %rax
callq *0x8(%rax)
cmpq $0x0, 0x30(%r14)
jne 0x11f4a
movq 0x10(%rsp), %rax
movq %rax, 0x30(%r14)
movq %r15, (%rsp)
movq 0x8(%rsp), %rdi
movq %r14, 0x8(%rsp)
testq %rdi, %rdi
je 0x11e5f
callq 0xe634
cmpq $0x0, (%rsp)
jne 0x11eda
movl $0x40, %edi
callq 0x53d0
movq %rax, %r14
movq %r13, 0x8(%rax)
leaq 0xcc52(%rip), %rax      # 0x1ead0
movq %rax, (%r14)
movq %r14, %r15
addq $0x10, %r15
movl $0x0, 0x28(%r14)
xorl %eax, %eax
movq %rax, 0x18(%r14)
movq %rax, 0x1d(%r14)
leaq 0xcc7f(%rip), %rax      # 0x1eb20
movq %rax, 0x10(%r14)
movl $0x18, %edi
callq 0x53d0
movq %rax, %r12
movq %rax, %rdi
callq 0x12596
movq %r12, 0x30(%r14)
movq %rbx, 0x38(%r14)
movq %r15, (%rsp)
movq 0x8(%rsp), %rdi
movq %r14, 0x8(%rsp)
testq %rdi, %rdi
je 0x11eda
callq 0xe634
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0x1260c
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x11ef6
callq 0xe634
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x268(%rbx), %rdi
movups %xmm0, 0x260(%rbx)
testq %rdi, %rdi
je 0x11f1b
callq 0xe634
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x11f2a
callq 0xe634
cmpq $0x0, 0x238(%rbx)
setne %al
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl %eax, %edi
callq 0x5240
callq 0x50e0
movq %rax, %rbx
movq %r15, %rdi
callq 0xedca
movq %r14, %rdi
callq 0x5390
jmp 0x11fff
jmp 0x11f69
movq %rax, %rbx
jmp 0x11fff
movq %rdx, %r12
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11f87
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x28(%rsp)
jmp 0x11f98
movq %rdx, %r12
movq %rax, %rbx
movq %r14, %rdi
addq $0x40, %rdi
callq 0x125b8
jmp 0x11fac
movq %rdx, %r12
movq %rax, %rbx
movq %r15, %rdi
callq 0xed9c
movq %r14, %rdi
callq 0x5390
jmp 0x11fc4
movq %rdx, %r12
movq %rax, %rbx
cmpl $0x1, %r12d
jne 0x11fff
movq %rbx, %rdi
callq 0x5150
leaq 0x10(%rax), %rbx
callq 0x51b0
leaq 0x10(%rsp), %rsi
movl $0xb, (%rsi)
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xecdb
callq 0x5530
movq %rax, %rbx
callq 0x55e0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1200e
callq 0xe634
movq %rbx, %rdi
callq 0x5650
movq %rax, %rdi
callq 0xe6a3