// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
pushq %rax
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, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movl 0x8(%rdi), %r15d
cmpq %rax, %r14
je 0x3550
movl (%rbx), %edx
movl $0x1, %esi
xorl %edi, %edi
movq (%rax,%rdi,8), %rdi
cmpl %ebp, 0x4(%rdi)
jne 0x350b
cmpl %edx, 0x8(%rdi)
je 0x358e
movl %esi, %edi
incl %esi
cmpq %rdi, %rcx
ja 0x34f9
movl 0x18(%rbx), %edx
cmpq %rdx, %rcx
jb 0x355f
cmpq %rax, %r14
je 0x35ab
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %r15d, %edi
movq (%rax,%rsi,8), %r8
movl (%r8), %r8d
cmpl %edi, %r8d
cmovll %r8d, %edi
cmovlel %esi, %edx
incq %rsi
movl %esi, %r8d
cmpq %r8, %rcx
ja 0x352f
movslq %edx, %rdx
jmp 0x35b2
movl 0x18(%rbx), %esi
movq $-0x1, %rdx
cmpq %rsi, %rcx
jae 0x35b2
movl $0xc, %edi
callq 0x2190
movq %rax, (%rsp)
movl %r15d, (%rax)
movl (%rbx), %ecx
movl %ecx, 0x8(%rax)
movl %ebp, 0x4(%rax)
cmpq 0x90(%rbx), %r14
je 0x3593
movq %rax, (%r14)
addq $0x8, 0x88(%rbx)
jmp 0x35c1
movl %r15d, (%rdi)
jmp 0x35c1
leaq 0x80(%rbx), %rdi
movq %rsp, %rdx
movq %r14, %rsi
callq 0x44e6
movl 0x8(%rbx), %r15d
jmp 0x35c1
movq $-0x1, %rdx
movq (%rax,%rdx,8), %rax
movl %ebp, 0x4(%rax)
movl (%rbx), %ecx
movl %ecx, 0x8(%rax)
movl %r15d, (%rax)
incl %r15d
movl %r15d, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop