// File: /workspace/github_cpp_makefile_star2_O1/isabellab3[P]OS-Simulation/./OS.h
// Function: OperatingSystem::RequestMemoryOperation(int const&)
void RequestMemoryOperation(const int & address) {
            int page = address / page_size;
            
            int oldest_timestamp = timestamp;
            int index_of_oldest = -1;

            // Adds frames to the vector as needed until the vector is full (size is number_of_frames). Then replaces the least recently used frame
            // If the same process wants to access the same page, just update time stamp
            for (unsigned int i = 0; i < frames.size(); i++) {
                if ((frames[i]->page_ == page) && (frames[i]->pid_ == CPU)) {
                    frames[i]->timestamp_ = timestamp;
                    timestamp++;
                    return;
                }
            }

            // If there are empty frames, create a new frame in the vector
            if (frames.size() < number_of_frames) {
                Frame* new_frame = new Frame{};
                new_frame->timestamp_ = timestamp;
                new_frame->pid_ = CPU;
                new_frame->page_ = page;
                frames.push_back(new_frame);
            }

            // Replace the least recently used frame's data
            else {
                // Find the frame with the oldest(lowest) timestamp
                for (unsigned int i = 0; i < frames.size(); i++) {
                    if (frames[i]->timestamp_ <= oldest_timestamp) {
                        index_of_oldest = i;
                        oldest_timestamp = frames[i]->timestamp_;
                    }
                }
                frames[index_of_oldest]->page_ = page;
                frames[index_of_oldest]->pid_ = CPU;
                frames[index_of_oldest]->timestamp_ = timestamp;
            }
            timestamp++;
        }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl (%rsi), %eax
xorl %edx, %edx
divl 0x10(%rdi)
movl %eax, %ebp
movq 0x88(%rdi), %r14
movq 0x80(%rdi), %rax
movq %r14, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movl 0x8(%rdi), %ecx
cmpq %rax, %r14
je 0x3510
movl (%rbx), %esi
movl $0x1, %edi
xorl %r8d, %r8d
movq (%rax,%r8,8), %r8
cmpl %ebp, 0x4(%r8)
jne 0x3506
cmpl %esi, 0x8(%r8)
je 0x3585
movl %edi, %r8d
incl %edi
cmpq %r8, %rdx
ja 0x34f6
movl 0x18(%rbx), %esi
cmpq %rsi, %rdx
jae 0x3558
movl $0xc, %edi
callq 0x2190
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq %rax, 0x8(%rsp)
movl 0x8(%rbx), %ecx
movl %ecx, (%rax)
movl (%rbx), %ecx
movl %ecx, 0x8(%rax)
movl %ebp, 0x4(%rax)
cmpq 0x90(%rbx), %r14
je 0x358a
movq %rax, (%r14)
addq $0x8, 0x88(%rbx)
jmp 0x35b8
cmpq %rax, %r14
je 0x35a0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edi, %edi
movq (%rax,%rdi,8), %r8
movl (%r8), %r8d
cmpl %ecx, %r8d
cmovll %r8d, %ecx
cmovlel %edi, %esi
incq %rdi
movl %edi, %r8d
cmpq %r8, %rdx
ja 0x3564
movslq %esi, %rcx
jmp 0x35a7
movl %ecx, (%r8)
jmp 0x35bb
leaq 0x80(%rbx), %rdi
leaq 0x8(%rsp), %rdx
movq %r14, %rsi
callq 0x44ca
jmp 0x35b8
movq $-0x1, %rcx
movq (%rax,%rcx,8), %rax
movl %ebp, 0x4(%rax)
movl (%rbx), %ecx
movl %ecx, 0x8(%rax)
movl 0x8(%rbx), %ecx
movl %ecx, (%rax)
movl 0x8(%rbx), %ecx
incl %ecx
movl %ecx, 0x8(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop