// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
addq $0x270, %rdi            # imm = 0x270
callq 0x5540
testl %eax, %eax
jne 0x11472
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)
movl $0x50, %edi
callq 0x53d0
movq %rax, %r14
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%r14)
leaq 0xb7bf(%rip), %rax      # 0x1cb18
movq %rax, (%r14)
leaq 0x10(%r14), %r15
xorl %eax, %eax
movq %rax, 0x18(%r14)
movl %eax, 0x20(%r14)
movb $0x0, 0x24(%r14)
movl %eax, 0x28(%r14)
movq %rax, 0x30(%r14)
movl %eax, 0x38(%r14)
leaq 0xb7e6(%rip), %rax      # 0x1cb68
movq %rax, 0x10(%r14)
movl $0x18, %edi
callq 0x53d0
movq %rax, %r12
movq %rax, %rdi
callq 0x1191a
movq %r12, 0x40(%r14)
movq %rbx, 0x48(%r14)
movq $0x0, (%rsp)
movl $0x20, %edi
callq 0x53d0
leaq 0xb804(%rip), %rcx      # 0x1cbc0
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
leaq 0x2b8(%rip), %rcx       # 0x11682
movq %rcx, 0x10(%rax)
movq $0x0, 0x18(%rax)
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
movq %rsp, %rdi
xorl %edx, %edx
callq 0x5340
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x113f8
movq (%rdi), %rax
callq *0x8(%rax)
cmpq $0x0, 0x30(%r14)
jne 0x11479
movq %rsp, %rdi
movq (%rdi), %rax
movq %rax, 0x30(%r14)
leaq 0x20(%rsp), %rsi
movq %r15, (%rsi)
movq %r14, 0x8(%rsi)
callq 0x11990
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11429
callq 0xde06
movaps (%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
movq 0x268(%rbx), %rdi
movups %xmm0, 0x260(%rbx)
testq %rdi, %rdi
je 0x1145b
callq 0xde06
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1145b
callq 0xde06
cmpq $0x0, 0x238(%rbx)
setne %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl %eax, %edi
callq 0x5240
callq 0x50e0
movq %rax, %rbx
jmp 0x11509
movq %rdx, %r12
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x114a4
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x114a4
movq %rdx, %r12
movq %rax, %rbx
movq %r14, %rdi
addq $0x40, %rdi
callq 0x1193c
jmp 0x114b8
movq %rdx, %r12
movq %rax, %rbx
movq %r15, %rdi
callq 0xe52e
movq %r14, %rdi
callq 0x5390
jmp 0x114d0
movq %rdx, %r12
movq %rax, %rbx
cmpl $0x1, %r12d
jne 0x11509
movq %rbx, %rdi
callq 0x5150
leaq 0x10(%rax), %rbx
callq 0x51b0
movq %rsp, %rsi
movl $0xb, (%rsi)
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xe475
callq 0x5530
movq %rax, %rbx
callq 0x55e0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11518
callq 0xde06
movq %rbx, %rdi
callq 0x5650
movq %rax, %rdi
callq 0xde75