// File: /workspace/github_cpp_makefile_star2_O1/AbraaoHonorio[P]Page-Replacement-Algorithms/PageReplacement.cpp
// Function: PageReplacement::otm()
void PageReplacement::otm(void)
{
	/* initializing */
	pageFaults_m = 0;
	myQueue.clear();


	/*inserting the value to queue*/
	for (int i = 0; i<sizeRam_m; i++)
	{
		if (std::find(myQueue.begin(), myQueue.end(), myPages[i]) != myQueue.end())
				;
        else
        {
            pageFaults_m++;
		    myQueue.push_back(myPages[i]);
        }
	}


	if (!myPages.empty() && !myQueue.empty())
	{
		for (unsigned int i = sizeRam_m; i < myPages.size(); i++)
		{

			if (std::find(myQueue.begin(), myQueue.end(), myPages[i]) != myQueue.end())
				;
			else
			{
				int index = findIndex(myQueue, myPages, i);
				myQueue[index] = myPages[i]; //	replacing in accordance with index
				pageFaults_m++;
			}
		}
	}
	else
	{
		std::cout << " The Queue have empty or sizeRam is null " << std::endl;
	}

	std::cout << " OTM  " << pageFaults_m << " " << std::endl; //output
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movl $0x0, 0x8(%rdi)
movq 0x10(%rdi), %rax
cmpq %rax, 0x18(%rdi)
je 0x1710
movq %rax, 0x18(%rbx)
leaq 0x10(%rbx), %r14
movl 0xc(%rbx), %r15d
testl %r15d, %r15d
jle 0x1776
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %r12, %rdx
callq 0x1f14
movq 0x18(%rbx), %rsi
cmpq %rsi, %rax
jne 0x1766
incl 0x8(%rbx)
movq 0x28(%rbx), %rdx
addq %r12, %rdx
cmpq 0x20(%rbx), %rsi
je 0x175e
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rbx)
jmp 0x1766
movq %r14, %rdi
callq 0x1fae
incq %r13
movslq 0xc(%rbx), %r15
addq $0x4, %r12
cmpq %r15, %r13
jl 0x1723
movq 0x28(%rbx), %rax
cmpq 0x30(%rbx), %rax
je 0x185f
movq 0x10(%rbx), %rax
cmpq 0x18(%rbx), %rax
je 0x185f
movq %r14, 0x10(%rsp)
movl %r15d, %ebp
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbp, %rcx
jbe 0x18a1
leaq 0x28(%rbx), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x30(%rsp), %r13
leaq 0x18(%rsp), %r12
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
leaq (%rax,%rbp,4), %rdx
callq 0x1f14
cmpq 0x18(%rbx), %rax
jne 0x183f
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x1e1a
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x1e1a
movq %r12, %rsi
movq %r13, %r14
movq %r13, %rdi
movl %r15d, %edx
callq 0x15d5
movl %eax, %r13d
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1819
callq 0x10f0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1828
callq 0x10f0
movq 0x10(%rbx), %rax
movq 0x28(%rbx), %rcx
movl (%rcx,%rbp,4), %ecx
movslq %r13d, %rdx
movl %ecx, (%rax,%rdx,4)
incl 0x8(%rbx)
movq %r14, %r13
incl %r15d
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq %r15, %rbp
cmpq %r15, %rcx
ja 0x17c5
jmp 0x18a1
movq 0x3772(%rip), %r14      # 0x4fd8
leaq 0x17d3(%rip), %rsi      # 0x3040
movl $0x29, %edx
movq %r14, %rdi
callq 0x1120
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x1100
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq 0x3730(%rip), %r14      # 0x4fd8
leaq 0x17c4(%rip), %rsi      # 0x3073
movl $0x6, %edx
movq %r14, %rdi
callq 0x1120
movl 0x8(%rbx), %esi
movq %r14, %rdi
callq 0x1160
movq %rax, %rbx
leaq 0x17a7(%rip), %rsi      # 0x3078
movl $0x1, %edx
movq %rax, %rdi
callq 0x1120
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1100
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x192b
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x192b
callq 0x10f0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x193a
callq 0x10f0
movq %rbx, %rdi
callq 0x1170