// File: /workspace/github_cpp_makefile_star2_O2/yiboyang[P]VirtualMemory/PageTable.cpp
// Function: PageTable::PageTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
PageTable::PageTable(const string& pageReplacementPolicy, const string& backingStorePath) : bs(backingStorePath) {
	if (!(pageReplacementPolicy == "FIFO" || pageReplacementPolicy == "LRU"))
		throw invalid_argument("Page replacement policy must be FIFO or LRU");
	else
		this->pageReplacementPolicy = pageReplacementPolicy;

	// initialize all page entries such that they all point to frame # -1 with dirty bit set to false
	for (int i = 0; i < NUM_LOGICAL_MEM_FRAMES; i++)
		pt[i] = make_pair(-1, false);

	// initialize free frames set; at first all frames are free
	for (int j = 0; j < NUM_PHYSICAL_MEM_FRAMES; j++)
		fs.insert(fs.end(), j);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %rax
andl $0x0, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
andl $0x0, 0x38(%rdi)
movq %rsi, %r15
andq $0x0, 0x40(%rdi)
leaq 0x30(%rdi), %r14
leaq 0x38(%rdi), %r13
movq %r13, 0x48(%rdi)
movq %r13, 0x50(%rdi)
andq $0x0, 0x58(%rdi)
leaq 0x70(%rdi), %rax
movq %rax, 0x60(%rdi)
andq $0x0, 0x68(%rdi)
leaq 0x60(%rdi), %rax
movq %rax, -0x38(%rbp)
movb $0x0, 0x70(%rdi)
leaq 0x80(%rdi), %r12
movq %r12, 0x88(%rdi)
movq %r12, 0x80(%rdi)
andq $0x0, 0x90(%rdi)
leaq -0x68(%rbp), %rdi
movq %rdx, %rsi
callq 0x22e0
leaq 0x98(%rbx), %rdi
leaq -0x68(%rbp), %rsi
movq %rdi, -0x48(%rbp)
callq 0x30d4
leaq -0x68(%rbp), %rdi
callq 0x2110
leaq 0x3a8(%rbx), %rdi
movq %rdi, -0x40(%rbp)
callq 0x3160
xorl %eax, %eax
movb %al, 0x3f0(%rbx)
andl $0x0, 0x3f4(%rbx)
movb %al, 0x3f8(%rbx)
leaq 0x2367(%rip), %rsi      # 0x5005
movq %r15, %rdi
callq 0x3191
testb %al, %al
jne 0x2cbd
leaq 0x2381(%rip), %rsi      # 0x5032
movq %r15, %rdi
callq 0x3191
testb %al, %al
je 0x2d24
movq -0x38(%rbp), %rdi
movq %r15, %rsi
callq 0x2170
xorl %eax, %eax
leaq -0x2c(%rbp), %r15
movl %eax, -0x2c(%rbp)
cmpl $0x100, %eax            # imm = 0x100
jge 0x2cf2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31a2
orl $-0x1, (%rax)
movb $0x0, 0x4(%rax)
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x2ccf
xorl %eax, %eax
leaq -0x2c(%rbp), %r15
movl %eax, -0x2c(%rbp)
cmpl $0x40, %eax
jge 0x2d15
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3648
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x2cf8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x2140
movq %rax, %r13
leaq 0x22d4(%rip), %rsi      # 0x500a
movq %rax, %rdi
callq 0x23a0
movq 0x528b(%rip), %rsi      # 0x7fd0
movq 0x5274(%rip), %rdx      # 0x7fc0
movq %r13, %rdi
callq 0x2360
movq %rax, %r15
movq %r13, %rdi
callq 0x21c0
jmp 0x2d7b
movq %rax, %r15
leaq -0x68(%rbp), %rdi
callq 0x2110
jmp 0x2d8d
movq %rax, %r15
jmp 0x2d8d
jmp 0x2d78
jmp 0x2d78
movq %rax, %r15
movq -0x40(%rbp), %rdi
callq 0x31f4
movq -0x48(%rbp), %rdi
callq 0x3214
movq %r12, %rdi
callq 0x276a
movq -0x38(%rbp), %rdi
callq 0x2110
movq %r14, %rdi
callq 0x32f2
movq %rbx, %rdi
callq 0x3348
movq %r15, %rdi
callq 0x2380