// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
addq $0x270, %rdi            # imm = 0x270
callq 0x10682
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, 0x20(%rsp)
pushq $0x50
popq %rdi
callq 0x5390
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0xdaee(%rip), %rax      # 0x1d9f0
movq %rax, (%r14)
andq $0x0, 0x18(%r14)
andl $0x0, 0x20(%r14)
movb $0x0, 0x24(%r14)
andl $0x0, 0x28(%r14)
leaq 0xf(%rsp), %rax
andq $0x0, 0x30(%r14)
movq %rax, 0x10(%rsp)
andl $0x0, 0x38(%r14)
movq %r14, 0x18(%rsp)
leaq 0x10(%r14), %r15
leaq 0xdb03(%rip), %rax      # 0x1da40
movq %rax, 0x10(%r14)
pushq $0x18
popq %rdi
callq 0x5390
movq %rax, %r12
movq %rax, %rdi
callq 0x106c4
movq %r12, 0x40(%r14)
movq %rbx, 0x48(%r14)
andq $0x0, 0x38(%rsp)
pushq $0x20
popq %rdi
callq 0x5390
leaq 0xdb27(%rip), %rcx      # 0x1da98
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
leaq 0x3b1(%rip), %rcx       # 0x10330
movq %rcx, 0x10(%rax)
andq $0x0, 0x18(%rax)
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x38(%rsp), %rdi
xorl %edx, %edx
callq 0x5310
movq %r14, %r13
addq $0x30, %r13
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xffb3
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x48(%rsp), %rbp
leaq 0x38(%rsp), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0xc810
movq %r12, %rdi
callq 0xc82a
leaq 0x10(%rsp), %rdi
andq $0x0, 0x8(%rdi)
callq 0x102ba
leaq 0x18(%rsp), %rdi
pxor %xmm0, %xmm0
movdqa %xmm0, -0x8(%rbp)
movdqa 0x20(%rsp), %xmm0
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movdqa %xmm0, -0x8(%rdi)
callq 0xc0d4
movq %rbp, %rdi
callq 0xc0d4
cmpq $0x0, 0x20(%rsp)
jne 0x100d3
pushq $0x40
popq %rdi
callq 0x5390
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0xda93(%rip), %rax      # 0x1dad8
movq %rax, (%r14)
andq $0x0, 0x18(%r14)
movq %r14, 0x18(%rsp)
andl $0x0, 0x20(%r14)
movb $0x0, 0x24(%r14)
andl $0x0, 0x28(%r14)
movq %r14, %r15
addq $0x10, %r15
leaq 0xdab9(%rip), %rax      # 0x1db28
movq %rax, 0x10(%r14)
pushq $0x18
popq %rdi
callq 0x5390
movq %rax, %r12
leaq 0x48(%rsp), %r13
movq %rax, %rdi
callq 0x106c4
movq %r12, 0x30(%r14)
movq %rbx, 0x38(%r14)
leaq 0x10(%rsp), %rdi
andq $0x0, 0x8(%rdi)
callq 0x1058e
leaq 0x18(%rsp), %rdi
pxor %xmm0, %xmm0
movdqa %xmm0, -0x8(%r13)
movdqa 0x20(%rsp), %xmm0
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movdqa %xmm0, -0x8(%rdi)
callq 0xc0d4
movq %r13, %rdi
callq 0xc0d4
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1072e
leaq 0x28(%rsp), %rdi
callq 0xc0d4
leaq 0x260(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x10696
leaq 0x18(%rsp), %rdi
callq 0xc0d4
cmpq $0x0, 0x238(%rbx)
setne %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0xc894
leaq 0x10(%rsp), %rdi
callq 0x1058e
jmp 0x101cc
jmp 0x1013d
movq %rax, %rbx
jmp 0x101cc
movq %rdx, %r12
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x10163
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x10163
movq %rdx, %r12
movq %rax, %rbx
addq $0x40, %r14
movq %r14, %rdi
callq 0x106e6
jmp 0x10177
movq %rdx, %r12
movq %rax, %rbx
movq %r15, %rdi
callq 0xc862
leaq 0x10(%rsp), %rdi
callq 0x102ba
jmp 0x10191
movq %rdx, %r12
movq %rax, %rbx
cmpl $0x1, %r12d
jne 0x101cc
movq %rbx, %rdi
callq 0x5140
leaq 0x10(%rax), %rbx
callq 0x51a0
leaq 0x40(%rsp), %rsi
movl $0xb, (%rsi)
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xc7e4
callq 0x54f0
movq %rax, %rbx
callq 0x55a0
leaq 0x28(%rsp), %rdi
callq 0xc0d4
movq %rbx, %rdi
callq 0x5610
movq %rax, %rdi
callq 0x7100