// File: lrq3000[P]rfrb/./src/bufferedFileReader.cpp
// Function: Buffered_FileReader::Buffered_FileReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long)
Buffered_FileReader::Buffered_FileReader(std::string path, size_t size) : m_path(path), m_bufferSize(size)
{
	m_fs.open(m_path.c_str(), std::ifstream::in | std::ifstream::binary);

	if (!(m_fs))
	{
		std::cerr << "ERROR FileReader::FileReader - Couldnt open file: " << path << std::endl;
		exit(EXIT_FAILURE);
	}
	//Get filesize
	m_fs.seekg(0,m_fs.end);
	m_fileSize = m_fs.tellg();
	m_fs.seekg(0,m_fs.beg);

	m_loadBuffer = new char[m_bufferSize];
	m_workBuffer = new char[m_bufferSize];

	m_elements = m_loadedElements = 0;
	m_globalAdress = 0;
	reloadBuffer();
}

// Assembly:
subq $0xb8, %rsp
movq %rsi, 0x70(%rsp)
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movq 0xb0(%rsp), %rdi
movq %rdi, 0x68(%rsp)
movq %rdi, %rax
movq %rax, 0x60(%rsp)
callq 0x64c0
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
addq $0x210, %rdi            # imm = 0x210
movq %rdi, 0x78(%rsp)
callq 0x6190
jmp 0x30f2b
movq 0x60(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq %rax, 0x230(%rdi)
addq $0x260, %rdi            # imm = 0x260
movq %rdi, 0x40(%rsp)
callq 0x33c80
movq 0x60(%rsp), %rdi
addq $0x270, %rdi            # imm = 0x270
callq 0x33c90
movq 0x60(%rsp), %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
addq $0x210, %rdi            # imm = 0x210
callq 0x6180
movq %rax, 0x50(%rsp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x33ca0
movl %eax, 0x5c(%rsp)
jmp 0x30f94
movl 0x5c(%rsp), %edx
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x6280
jmp 0x30fa9
movq 0x60(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x61b0
movb %al, 0x3f(%rsp)
jmp 0x30fc3
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x30fd0
jmp 0x31063
movq 0x23019(%rip), %rdi     # 0x53ff0
leaq 0xadd3(%rip), %rsi      # 0x3bdb1
callq 0x6420
movq %rax, 0x30(%rsp)
jmp 0x30fea
movq 0x70(%rsp), %rsi
movq 0x30(%rsp), %rdi
callq 0x6390
movq %rax, 0x28(%rsp)
jmp 0x31000
movq 0x28(%rsp), %rdi
movq 0x22f64(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0x31013
movl $0x1, %edi
callq 0x6500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0x31153
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
callq 0x30a70
movq 0x78(%rsp), %rdi
callq 0x6260
jmp 0x31153
movq 0x60(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x6590
jmp 0x31078
movq 0x60(%rsp), %rdi
callq 0x6730
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x3108e
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq %rax, 0x88(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x33cc0
movq %rax, 0x10(%rsp)
jmp 0x310bc
movq 0x60(%rsp), %rdi
movq 0x10(%rsp), %rax
movq %rax, 0x208(%rdi)
xorl %edx, %edx
movl %edx, %esi
callq 0x6590
jmp 0x310d8
movq 0x60(%rsp), %rax
movq 0x230(%rax), %rdi
callq 0x6030
movq %rax, 0x8(%rsp)
jmp 0x310f0
movq 0x60(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x250(%rax)
movq 0x230(%rax), %rdi
callq 0x6030
movq %rax, (%rsp)
jmp 0x31113
movq 0x60(%rsp), %rdi
movq (%rsp), %rax
movq %rax, 0x258(%rdi)
movq $0x0, 0x240(%rdi)
movq $0x0, 0x238(%rdi)
movq $0x0, 0x248(%rdi)
callq 0x31170
jmp 0x3114b
addq $0xb8, %rsp
retq
movq 0x68(%rsp), %rdi
callq 0x6110
movq 0x98(%rsp), %rdi
callq 0x6750
nopw (%rax,%rax)