LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./Network.cpp
// Function: Network::PutWeights(std::vector<double, std::allocator<double>>&)
void Network::PutWeights(vector<double> &weights)
{
	int cWeight = 0;
	//for each layer
	for (int i = 0; i<m_layers.size()-1; ++i)
	{
		//for each neuron
		for (int j = 0; j<m_layers[i].size(); ++j)
		{
			//for each weight
			for (int k = 0; k<m_layers[i][j].m_outputWeights.size(); ++k)
			{
				m_layers[i][j].m_outputWeights[k].weight = weights[cWeight++];
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq (%rdi), %rcx
movq 0x8(%rdi), %rax
subq %rcx, %rax
movabsq $0x18, %rdi
cqto
idivq %rdi
decq %rax
xorl %edx, %edx
xorl %edi, %edi
cmpq %rax, %rdx
je 0x2c38
imulq $0x18, %rdx, %r9
movq (%rcx,%r9), %r8
movq 0x8(%rcx,%r9), %r9
subq %r8, %r9
sarq $0x6, %r9
xorl %r10d, %r10d
cmpq %r9, %r10
je 0x2c33
movq %r10, %rbx
shlq $0x6, %rbx
movq 0x10(%r8,%rbx), %r11
movq 0x18(%r8,%rbx), %rbx
subq %r11, %rbx
sarq $0x4, %rbx
movslq %edi, %r14
negq %rbx
shlq $0x3, %r14
addq (%rsi), %r14
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x2c2b
movsd (%r14,%r12), %xmm0
movsd %xmm0, (%r11,%r12,2)
decq %r15
addq $0x8, %r12
jmp 0x2c11
subl %r15d, %edi
incq %r10
jmp 0x2be1
incq %rdx
jmp 0x2bc5
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./stats.h
// Function: sum(std::vector<double, std::allocator<double>>)
double sum(vector<double> a)
{
	double s = 0;
	for (int i = 0; i < a.size(); i++)
	{
		s += a[i];
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x2c68
addsd (%rax,%rdx,8), %xmm0
incq %rdx
jmp 0x2c59
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./stats.h
// Function: sqsum(std::vector<double, std::allocator<double>>)
double sqsum(vector<double> a)
{
	double s = 0;
	for (int i = 0; i < a.size(); i++)
	{
		s += pow(a[i], 2);
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x2d09
movsd (%rax,%rdx,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rdx
jmp 0x2cf2
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./stats.h
// Function: operator-(std::vector<double, std::allocator<double>>, double)
vector<double> operator-(vector<double> a, double b)
{
	vector<double> retvect;
	for (int i = 0; i < a.size(); i++)
	{
		retvect.push_back(a[i] - b);
	}
	return retvect;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movsd %xmm0, -0x28(%rbp)
movq %rsi, %r14
movq %rdi, %rbx
andq $0x0, 0x10(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
xorl %r12d, %r12d
leaq -0x30(%rbp), %r15
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x2e53
movsd (%rax,%r12,8), %xmm0
subsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5a92
incq %r12
jmp 0x2e20
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x5c12
movq %r14, %rdi
callq 0x2280
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./stats.h
// Function: operator*(std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>)
vector<double> operator*(vector<double> a, vector<double> b)
{
	vector<double> retvect;
	for (int i = 0; i < a.size() ; i++)
	{
		retvect.push_back(a[i] * b[i]);
	}
	return retvect;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
andq $0x0, 0x10(%rdi)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rdi)
xorl %r13d, %r13d
leaq -0x30(%rbp), %r12
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x2ed8
movsd (%rax,%r13,8), %xmm0
movq (%r14), %rax
mulsd (%rax,%r13,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5a92
incq %r13
jmp 0x2ea1
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x5c12
movq %r14, %rdi
callq 0x2280
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/main.cpp
// Function: main
int main() {

  SFA sfa1((ro_VALS[0]),1);
  sfa1.Train();

  SFA sfa2((ro_VALS[1]),1);
  sfa2.Train();

  SFA sfa3((ro_VALS[2]),1);
  sfa3.Train();

  SFA sfa4((ro_VALS[3]),1);
  sfa4.Train();

  SFA sfa5((ro_VALS[4]),1);
  sfa5.Train();

  SFA sfa6((ro_VALS[5]),1);
  sfa6.Train();

  SFA sfa7((ro_VALS[6]),1);
  sfa7.Train();


//   sfa.TrainTwoInvariances();

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x15a8, %rsp           # imm = 0x15A8
movq 0x6042(%rip), %rax      # 0x9190
cvtsd2ss (%rax), %xmm0
leaq -0x15b0(%rbp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x345a
movq %rbx, %rdi
callq 0x3a72
movq 0x601d(%rip), %rax      # 0x9190
cvtsd2ss 0x8(%rax), %xmm0
leaq -0x1298(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x345a
leaq -0x1298(%rbp), %rdi
callq 0x3a72
movq 0x5ff6(%rip), %rax      # 0x9190
cvtsd2ss 0x10(%rax), %xmm0
leaq -0xf80(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x345a
leaq -0xf80(%rbp), %rdi
callq 0x3a72
movq 0x5fcf(%rip), %rax      # 0x9190
cvtsd2ss 0x18(%rax), %xmm0
leaq -0xc68(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x345a
leaq -0xc68(%rbp), %rdi
callq 0x3a72
movq 0x5fa8(%rip), %rax      # 0x9190
cvtsd2ss 0x20(%rax), %xmm0
leaq -0x950(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x345a
leaq -0x950(%rbp), %rdi
callq 0x3a72
movq 0x5f81(%rip), %rax      # 0x9190
cvtsd2ss 0x28(%rax), %xmm0
leaq -0x638(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x345a
leaq -0x638(%rbp), %rdi
callq 0x3a72
movq 0x5f5a(%rip), %rax      # 0x9190
cvtsd2ss 0x30(%rax), %xmm0
leaq -0x320(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0x345a
leaq -0x320(%rbp), %rdi
callq 0x3a72
leaq -0x320(%rbp), %rdi
callq 0x40e4
leaq -0x638(%rbp), %rdi
callq 0x40e4
leaq -0x950(%rbp), %rdi
callq 0x40e4
leaq -0xc68(%rbp), %rdi
callq 0x40e4
leaq -0xf80(%rbp), %rdi
callq 0x40e4
leaq -0x1298(%rbp), %rdi
callq 0x40e4
leaq -0x15b0(%rbp), %rdi
callq 0x40e4
xorl %eax, %eax
addq $0x15a8, %rsp           # imm = 0x15A8
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x320(%rbp), %rdi
callq 0x40e4
jmp 0x32cc
jmp 0x32c9
movq %rax, %rbx
leaq -0x638(%rbp), %rdi
callq 0x40e4
jmp 0x32df
jmp 0x32dc
movq %rax, %rbx
leaq -0x950(%rbp), %rdi
callq 0x40e4
jmp 0x32f2
jmp 0x32ef
movq %rax, %rbx
leaq -0xc68(%rbp), %rdi
callq 0x40e4
jmp 0x3305
jmp 0x3302
movq %rax, %rbx
leaq -0xf80(%rbp), %rdi
callq 0x40e4
leaq -0x1298(%rbp), %rdi
callq 0x40e4
leaq -0x15b0(%rbp), %rdi
callq 0x40e4
movq %rbx, %rdi
callq 0x2280
jmp 0x3333
movq %rax, %rbx
jmp 0x3311
jmp 0x333a
movq %rax, %rbx
jmp 0x331d
nop
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::GetSignalValue(int)
int GetSignalValue(int time) //gets value of signal at time
    {
        int j = round(51.0f + 50.0f*sin(M_PI/180.0f*double(time)*360.0f / ro));
        input_vector.clear();
        for(int i=1;i<=NUM_INPUT_NEURONS_X;i++)
        {
            if(i != j)
                input_vector.push_back(0.0f);
            else if(i == j)
                input_vector.push_back(1.0f);
        }
        return j;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cvtsi2sd %esi, %xmm0
mulsd 0x19cb(%rip), %xmm0     # 0x6040
mulsd 0x19cb(%rip), %xmm0     # 0x6048
divsd 0x1d0(%rdi), %xmm0
callq 0x2030
mulsd 0x1996(%rip), %xmm0     # 0x6028
addsd 0x19b6(%rip), %xmm0     # 0x6050
callq 0x2090
movq 0x108(%rbx), %rax
cmpq %rax, 0x110(%rbx)
je 0x46b6
movq %rax, 0x110(%rbx)
cvttsd2si %xmm0, %r14d
leaq 0x108(%rbx), %r15
pushq $0x1
popq %r13
leaq -0x30(%rbp), %r12
cmpl 0x1c0(%rbx), %r13d
ja 0x46fd
cmpl %r13d, %r14d
jne 0x46e8
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x30(%rbp)
jmp 0x46ed
andq $0x0, -0x30(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x5a92
incl %r13d
jmp 0x46ca
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::OscillateFeedForward(int, int)
void OscillateFeedForward(int signal_value, int time_step)
    {
        int sig_val = GetSignalValue(time_step);
        for(int neuron_index=0;neuron_index<NUM_INPUT_NEURONS_X;neuron_index++)
        {
            UpdateX(neuron_index);
        }
        V = getV(V,y,y_bar);
        U = getU(U,y,y_tilde);
        y = GetY(sig_val);
        y_bar = getYBar(y,y_bar);
        y_tilde = getYTilde(y,y_tilde);

        for(int neuron_index = 0;neuron_index<NUM_INPUT_NEURONS_X;neuron_index++)
        {
            Layer* inputLayer = &(getNetwork()->m_layers[0]);
            Neuron* thisNeuron = &(*inputLayer)[neuron_index];
            double dw = CalculateDelWeights(neuron_index);
            UpdateNeuron(thisNeuron,neuron_index);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl %edx, %esi
callq 0x4658
movl %eax, %r14d
xorl %r15d, %r15d
cmpl 0x1c0(%rbx), %r15d
jae 0x4744
movq %rbx, %rdi
movl %r15d, %esi
callq 0x4ddc
incl %r15d
jmp 0x472b
movsd 0x290(%rbx), %xmm0
movsd 0x70(%rbx), %xmm1
movsd 0x18ff(%rip), %xmm2     # 0x6058
subsd %xmm1, %xmm2
movapd %xmm0, %xmm3
subsd 0x158(%rbx), %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm3
movsd 0x168(%rbx), %xmm4
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, 0x168(%rbx)
subsd 0x150(%rbx), %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm2, %xmm0
mulsd 0x160(%rbx), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x160(%rbx)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4e3e
movsd %xmm0, 0x290(%rbx)
movsd 0x70(%rbx), %xmm1
movsd 0x78(%rbx), %xmm2
movsd 0x1886(%rip), %xmm4     # 0x6058
movapd %xmm4, %xmm3
subsd %xmm1, %xmm3
mulsd %xmm0, %xmm3
mulsd 0x158(%rbx), %xmm1
addsd %xmm3, %xmm1
movsd %xmm1, 0x158(%rbx)
movapd %xmm4, %xmm1
subsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
mulsd 0x150(%rbx), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x150(%rbx)
pushq $0x10
popq %r15
xorl %r14d, %r14d
movl 0x1c0(%rbx), %eax
cmpq %rax, %r14
jae 0x4857
movq (%rbx), %rax
movq (%rax), %rax
movq (%rax), %r12
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4e76
movq (%r12,%r15), %rax
movq 0xc0(%rbx), %rcx
movsd (%rcx,%r14,8), %xmm0
movsd %xmm0, 0x8(%rax)
incq %r14
addq $0x40, %r15
jmp 0x4819
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::GetCorrelationTrace(std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>, int)
double GetCorrelationTrace(vector<double> va, vector<double> vb,int t)
    {
        int time_step = t;
        int lambda_correlation = fmin(11*ro,time_step);
        vector<double> vector_y1;
        vector<double> vector_y2;
        vector_y1.clear();
        vector_y2.clear();


     //       cout<<va.size()<<endl;
     //       cout<<lambda_correlation<<endl;

        for(int i=vb.size()-lambda_correlation;i<vb.size();i++)
        {
            if(i>-1)
            {
             //   cout<<va[i]<<endl;
                vector_y1.push_back(va[i]);
                vector_y2.push_back(vb[i]);
            }
        }
        double val =  pearsoncoeff(va,vb);

  //      cout<<val<<endl;

        if(isnan(val))
            return 0;
        else
            return val;        
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movsd 0x1d0(%rdi), %xmm0
mulsd 0x17dc(%rip), %xmm0     # 0x6060
cvtsi2sd %ecx, %xmm1
movq %rdx, %rbx
minsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
movq %rsi, %r14
xorpd %xmm0, %xmm0
leaq -0x60(%rbp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq -0xb0(%rbp), %r12
movapd %xmm0, (%r12)
andq $0x0, 0x10(%r12)
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rsi
subq %rax, %rsi
shrq $0x3, %rsi
subl %edx, %esi
movslq %esi, %r13
leaq (,%r13,8), %r15
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r13, %rdx
jbe 0x4919
testq %r13, %r13
js 0x4910
movq (%r14), %rsi
addq %r15, %rsi
leaq -0x60(%rbp), %rdi
callq 0x3398
movq (%rbx), %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x3398
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
incq %r13
addq $0x8, %r15
jmp 0x48d8
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0x33cc
leaq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0x33cc
leaq -0x90(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2efd
movapd %xmm0, -0x40(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5c12
leaq -0x90(%rbp), %rdi
callq 0x5c12
movapd -0x40(%rbp), %xmm0
movapd %xmm0, %xmm1
cmpordsd %xmm0, %xmm1
andpd %xmm0, %xmm1
movapd %xmm1, -0x40(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x5c12
leaq -0x60(%rbp), %rdi
callq 0x5c12
movaps -0x40(%rbp), %xmm0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x5c12
jmp 0x49b1
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x5c12
jmp 0x49c4
jmp 0x49c1
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x5c12
leaq -0x60(%rbp), %rdi
callq 0x5c12
movq %rbx, %rdi
callq 0x2280
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::GetOutput(int)
double GetOutput(int signal_value)
    {
        resultUni.clear();
        feedforward(GenerateInputs(signal_value)); //feed input vector into sfa model
        getNetwork()->getResults(resultUni);
        return resultUni.back();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %edx
movq %rdi, %rbx
movq 0x258(%rdi), %rax
cmpq %rax, 0x260(%rdi)
je 0x4f23
movq %rax, 0x260(%rbx)
leaq -0x28(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4f90
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4f82
leaq 0x258(%rbx), %r14
leaq -0x28(%rbp), %rdi
callq 0x5c12
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2a4c
movq 0x260(%rbx), %rax
movsd -0x8(%rax), %xmm0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x28(%rbp), %rdi
callq 0x5c12
movq %rbx, %rdi
callq 0x2280
nop
// File: /workspace/github_cpp_makefile_star2_O2/godofecht[P]Slow-Feature-Analysis/./sfa.h
// Function: SFA::GenerateInputs(int)
vector<double> GenerateInputs(int number_to_encode)                    
    {
        vector<double> inputVector; //one hot encoding
        inputVector.clear();
        for(int neuron_index=1;neuron_index<=NUM_INPUT_NEURONS_X;neuron_index++)
        {   
            if(number_to_encode == (neuron_index))
            {
                inputVector.push_back(1.0f);
            }
            else
            {
                inputVector.push_back(0.0f);
            }                
        }
        return inputVector;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rdi)
movups %xmm0, (%rdi)
pushq $0x1
popq %r13
leaq -0x30(%rbp), %r12
cmpl 0x1c0(%r15), %r13d
ja 0x4ff8
cmpl %r13d, %r14d
jne 0x4fe3
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x30(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5a92
jmp 0x4ff3
andq $0x0, -0x30(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5a92
incl %r13d
jmp 0x4fba
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x500c
movq %rax, %r14
movq %rbx, %rdi
callq 0x5c12
movq %r14, %rdi
callq 0x2280
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::BufferManager(int)
BufferManager::BufferManager(int num_buffers) {
	this->numPages = num_buffers;
	this->pageSize = PAGE_SIZE;
	this->buffers = new Frame[num_buffers];
	for(int i=0;i<num_buffers;i++) {
		buffers[i].data = new char[this->pageSize];
		freeList.push_back(i);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq %rdi, 0x8(%rdi)
movq %rdi, (%rdi)
andq $0x0, 0x10(%rdi)
leaq 0x18(%rdi), %r14
movq %r14, 0x20(%rdi)
movq %r14, 0x18(%rdi)
andq $0x0, 0x28(%rdi)
movl %esi, %r15d
leaq 0x70(%rdi), %rax
movq %rax, 0x40(%rdi)
movq $0x1, 0x48(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
movl $0x3f800000, 0x60(%rdi) # imm = 0x3F800000
movups %xmm0, 0x68(%rdi)
movl %esi, 0x38(%rdi)
movl $0x1000, 0x3c(%rdi)     # imm = 0x1000
movslq %esi, %r12
pushq $0x18
popq %rcx
movq %r12, %rax
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
movq %r14, -0x38(%rbp)
callq 0x2030
testl %r15d, %r15d
je 0x24b2
imulq $0x18, %r12, %rcx
xorl %edx, %edx
orq $-0x1, 0x4(%rax,%rdx)
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x24a3
movq %rax, 0x30(%rbx)
xorl %r14d, %r14d
pushq $-0x1
popq %r13
leaq -0x2c(%rbp), %r12
movl %r14d, -0x2c(%rbp)
cmpl %r15d, %r14d
jge 0x24ff
movl 0x3c(%rbx), %eax
testl %eax, %eax
cmovsl %r13d, %eax
movslq %eax, %rdi
callq 0x2030
movq 0x30(%rbx), %rcx
movslq %r14d, %rdx
imulq $0x18, %rdx, %rdx
movq %rax, 0x10(%rcx,%rdx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2de0
movl -0x2c(%rbp), %r14d
incl %r14d
jmp 0x24c1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2510
movq %rax, %r15
leaq 0x40(%rbx), %rdi
callq 0x2e92
movq -0x38(%rbp), %rdi
callq 0x2f42
movq %rbx, %rdi
callq 0x2f42
movq %r15, %rdi
callq 0x2240
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::~BufferManager()
BufferManager::~BufferManager() {
	//free up allocated memory
	for(int i=0;i<this->numPages;i++) 
		delete buffers[i].data;
	delete this->buffers;
	freeList.clear();
	usedList.clear();
	hashTable.clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0x10
popq %r14
xorl %r15d, %r15d
movslq 0x38(%rbx), %rax
movq 0x30(%rbx), %rdi
cmpq %rax, %r15
jge 0x2569
movq (%rdi,%r14), %rdi
callq 0x2160
incq %r15
addq $0x18, %r14
jmp 0x254a
callq 0x2160
movq %rbx, %rdi
callq 0x2df0
leaq 0x18(%rbx), %r14
movq %r14, %rdi
callq 0x2df0
leaq 0x40(%rbx), %r15
movq %r15, %rdi
callq 0x2eb8
movq %r15, %rdi
callq 0x2e92
movq %r14, %rdi
callq 0x2f42
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2f42
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::GetPage(PageDescriptor)
char* BufferManager::GetPage(PageDescriptor pd) {
	auto slot = hashTable.find(pd);
	if(slot!=hashTable.end()) {
		//already in buffer 
		int slotNo = slot->second;
		// no need to read the page
		// to establish replacement policy, make page MRU 
		usedList.remove(slotNo); 
		usedList.push_front(slotNo); // put at front
		return buffers[slotNo].data;
	}
	else {
		// page not in buffers
		// find a suitable slot to load it
		int slotNo = FindSlot();
		if(slotNo==-1) throw NoBufferSpaceException (); //error no free slot could be obtained 
		// read data to the slot 
		bool _read_res = ReadPage(pd,buffers[slotNo].data);
		if(!_read_res) // read failed 
			throw BufferManagerException("BufferManagerException : Read request failed");
		// insert into hashTable the corresponding slot
		hashTable.insert(make_pair(pd,slotNo));
		// initialize the rest of Frame elements
		InitializeBuffer(pd,slotNo);
		return buffers[slotNo].data;
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
leaq -0x28(%rbp), %rax
movq %rsi, (%rax)
leaq 0x40(%rdi), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x308c
testq %rax, %rax
je 0x2613
movl 0x10(%rax), %eax
leaq -0x38(%rbp), %r14
movl %eax, (%r14)
leaq 0x18(%rbx), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e12
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e74
movq 0x30(%rbx), %rax
movslq (%r14), %rcx
imulq $0x18, %rcx, %rcx
movq 0x10(%rax,%rcx), %rax
jmp 0x2672
movq %rbx, %rdi
callq 0x26ce
cmpl $-0x1, %eax
je 0x267f
movl %eax, %r15d
movq -0x28(%rbp), %rsi
movq 0x30(%rbx), %rax
movslq %r15d, %rcx
imulq $0x18, %rcx, %r12
movq 0x10(%rax,%r12), %rdx
movq %rbx, %rdi
callq 0x27ae
testb %al, %al
je 0x269a
movq -0x28(%rbp), %rax
leaq -0x38(%rbp), %rsi
movq %rax, (%rsi)
movl %r15d, 0x8(%rsi)
movq %r14, %rdi
callq 0x316c
movq -0x28(%rbp), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x2800
movq 0x30(%rbx), %rax
movq 0x10(%rax,%r12), %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x20e0
leaq 0x5622(%rip), %rcx      # 0x7cb0
movq %rcx, (%rax)
leaq 0x55d8(%rip), %rsi      # 0x7c70
jmp 0x26be
pushq $0x10
popq %rdi
callq 0x20e0
leaq 0x562f(%rip), %rcx      # 0x7cd8
movq %rcx, (%rax)
leaq 0x296a(%rip), %rcx      # 0x501d
movq %rcx, 0x8(%rax)
leaq 0x55ca(%rip), %rsi      # 0x7c88
movq 0x591b(%rip), %rdx      # 0x7fe0
movq %rax, %rdi
callq 0x2220
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::FindSlot()
int BufferManager::FindSlot() {
	// if free slot available
	if(!freeList.empty()) {
		int slot = freeList.front();
		freeList.pop_front();
		usedList.push_front(slot);
		return slot;
	}
	else {
		// since used list has MRU in front 
		// start search for a unpinned page from last 
		for(auto slot = usedList.rbegin();slot!=usedList.rend();slot++) {
			if(!buffers[*slot].pinned) {
				// page will be replaced
				// if dirty write to the file
				if(buffers[*slot].dirty) {
					int _res = WritePage(buffers[*slot].pageDescriptor,buffers[*slot].data);
					if(_res<0) continue;
					buffers[*slot].dirty=false;
				}
				//remove from hash table , and usedList
				hashTable.erase(buffers[*slot].pageDescriptor);
				// move the slot to MRU (front of used list)
				int slot_val = *slot;
				usedList.remove(slot_val);
				usedList.push_front(slot_val);
				return slot_val;
			}
		}
	}
	return -1; // no slot available
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rax
cmpq %rdi, %rax
je 0x270c
movl 0x10(%rax), %eax
leaq -0x20(%rbp), %r14
movl %eax, (%r14)
movq %rbx, %rdi
callq 0x2e84
addq $0x18, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e74
movl (%r14), %eax
jmp 0x27a2
leaq 0x18(%rbx), %r14
movq 0x18(%rbx), %rsi
movq 0x30(%rbx), %rcx
pushq $-0x1
popq %rax
movq %r14, %r8
cmpq %rsi, %r8
je 0x27a2
movq %r8, %r15
movq 0x8(%r8), %r8
movslq 0x10(%r8), %rdx
imulq $0x18, %rdx, %rdi
cmpb $0x0, 0x1(%rcx,%rdi)
jne 0x271e
cmpb $0x1, (%rcx,%rdi)
jne 0x2765
movq 0x4(%rcx,%rdi), %rsi
movq 0x10(%rcx,%rdi), %rdx
movq %rbx, %rdi
callq 0x2acc
movq 0x30(%rbx), %rcx
movq 0x8(%r15), %rax
movslq 0x10(%rax), %rdx
imulq $0x18, %rdx, %rax
movb $0x0, (%rcx,%rax)
addq $0x40, %rbx
imulq $0x18, %rdx, %rax
leaq (%rcx,%rax), %rsi
addq $0x4, %rsi
movq %rbx, %rdi
callq 0x34d6
movq 0x8(%r15), %rax
movl 0x10(%rax), %eax
leaq -0x1c(%rbp), %rbx
movl %eax, (%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e12
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e74
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::ReadPage(PageDescriptor, char*)
bool BufferManager::ReadPage(PageDescriptor pd,char *dest) {
	// calculate file offset
	long offset = pd.pagenum*(long)pageSize + FILE_HDR_SIZE;
	lseek(pd.fd,offset,0); // seek to location
	int count = -1;
	count = read(pd.fd, dest, pageSize);
	if(count != pageSize) //read failed
		return false;
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
sarq $0x20, %rsi
movslq 0x3c(%rdi), %rax
imulq %rax, %rsi
addq $0x1000, %rsi           # imm = 0x1000
movl %r14d, %edi
xorl %edx, %edx
callq 0x2260
movslq 0x3c(%r15), %rdx
movl %r14d, %edi
movq %rbx, %rsi
callq 0x21c0
cmpl %eax, 0x3c(%r15)
sete %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::AllocatePage(PageDescriptor)
char* BufferManager::AllocatePage(PageDescriptor pd) {
	auto slot = hashTable.find(pd);
	if(slot!=hashTable.end()) {
		// error page already in buffers
		throw BufferManagerException("BufferManagerException : Page to be allocated already in buffer");
	}
	else {
		// page not in buffers
		// find a suitable slot to load it
		int slotNo = FindSlot();
		if (slotNo==-1) throw NoBufferSpaceException(); //error no free slot could be obtained 
		// insert into hashTable the corresponding slot
		hashTable.insert(make_pair(pd,slotNo));
		// initialize the rest of Frame elements
		InitializeBuffer(pd,slotNo);
		return buffers[slotNo].data;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x20(%rbp), %rax
movq %rsi, (%rax)
leaq 0x40(%rdi), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x308c
testq %rax, %rax
jne 0x2898
movq %rbx, %rdi
callq 0x26ce
cmpl $-0x1, %eax
je 0x28be
movl %eax, %r15d
movq -0x20(%rbp), %rax
leaq -0x30(%rbp), %rsi
movq %rax, (%rsi)
movl %r15d, 0x8(%rsi)
movq %r14, %rdi
callq 0x316c
movq -0x20(%rbp), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x2800
movq 0x30(%rbx), %rax
movslq %r15d, %rcx
imulq $0x18, %rcx, %rcx
movq 0x10(%rax,%rcx), %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20e0
leaq 0x5431(%rip), %rcx      # 0x7cd8
movq %rcx, (%rax)
leaq 0x2799(%rip), %rcx      # 0x504a
movq %rcx, 0x8(%rax)
leaq 0x53cc(%rip), %rsi      # 0x7c88
jmp 0x28d7
pushq $0x8
popq %rdi
callq 0x20e0
leaq 0x53e3(%rip), %rcx      # 0x7cb0
movq %rcx, (%rax)
leaq 0x5399(%rip), %rsi      # 0x7c70
movq 0x5702(%rip), %rdx      # 0x7fe0
movq %rax, %rdi
callq 0x2220
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::MarkDirty(PageDescriptor)
bool BufferManager::MarkDirty(PageDescriptor pd) {
	auto slot = hashTable.find(pd);
	if(slot==hashTable.end()) {
		//error page not in buffers
		return false;
	}
	int slotNo = slot->second;
	if(!buffers[slotNo].pinned) {
		//error page unpinned
		return false;
	}
	// set page dirty
	buffers[slotNo].dirty=true;
	//make this page MRU in buffers
	usedList.remove(slotNo); 
	usedList.push_front(slotNo); // put at front	
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x28(%rbp), %rax
movq %rsi, (%rax)
addq $0x40, %rdi
movq %rax, %rsi
callq 0x308c
testq %rax, %rax
je 0x294e
movslq 0x10(%rax), %rcx
movl %ecx, -0x1c(%rbp)
movq 0x30(%rbx), %rax
imulq $0x18, %rcx, %rcx
movb 0x1(%rax,%rcx), %r14b
cmpb $0x1, %r14b
jne 0x2951
addq %rcx, %rax
movb $0x1, (%rax)
addq $0x18, %rbx
leaq -0x1c(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2e12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2e74
jmp 0x2951
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::UnpinPage(PageDescriptor)
bool BufferManager::UnpinPage(PageDescriptor pd) {
	auto slot = hashTable.find(pd); //find slot 
	if(slot==hashTable.end()) {
		//error page not in buffers
		return false;
	}
	int slotNo = slot->second;
	if(!buffers[slotNo].pinned) {
		//error page unpinned
		return false;
	}
	buffers[slotNo].pinned = false; //set unpinned
	// set page as MRU
	usedList.remove(slotNo); 
	usedList.push_front(slotNo); // put at front
	return true;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq -0x28(%rbp), %rax
movq %rsi, (%rax)
addq $0x40, %rdi
movq %rax, %rsi
callq 0x308c
testq %rax, %rax
je 0x29cb
movslq 0x10(%rax), %rcx
movl %ecx, -0x1c(%rbp)
movq 0x30(%rbx), %rax
imulq $0x18, %rcx, %rcx
movb 0x1(%rax,%rcx), %r14b
cmpb $0x1, %r14b
jne 0x29ce
addq %rcx, %rax
incq %rax
movb $0x0, (%rax)
addq $0x18, %rbx
leaq -0x1c(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2e12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2e74
jmp 0x29ce
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::FlushPages(int)
bool BufferManager::FlushPages(int fd) {
	// do a linear scan for all pages belonging to this file
	for(int i=0;i<numPages;i++) {
		if(find(usedList.begin(),usedList.end(),i)==usedList.end()) continue; // skip free slots
		if(buffers[i].pageDescriptor.fd != fd) continue;
		//write back page if dirty
		if(buffers[i].dirty) {
			bool _res = WritePage(PageDescriptor(fd,buffers[i].pageDescriptor.pagenum),buffers[i].data);
			if(!_res) return false;
			buffers[i].dirty = false;
		}
		//remove slot from hashTable and usedList and add to free list
		hashTable.erase(PageDescriptor(fd,buffers[i].pageDescriptor.pagenum));
		usedList.remove(i);
		freeList.push_front(i);
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x18(%rdi), %r15
movl %esi, %eax
movq %rax, -0x40(%rbp)
leaq 0x40(%rdi), %rax
movq %rax, -0x48(%rbp)
xorl %r12d, %r12d
movl %r12d, -0x2c(%rbp)
movl 0x38(%r14), %r13d
cmpl %r13d, %r12d
jge 0x2ab7
movq (%r15), %rdi
movq %r15, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x34bc
movl -0x2c(%rbp), %edx
cmpq %r15, %rax
je 0x2aad
movslq %edx, %rcx
movq 0x30(%r14), %rax
imulq $0x18, %rcx, %rsi
cmpl %ebx, 0x4(%rax,%rsi)
jne 0x2aad
leaq (%rax,%rsi), %rdi
cmpb $0x1, (%rdi)
jne 0x2a75
movq 0x10(%rax,%rsi), %rdx
movl 0x8(%rdi), %esi
shlq $0x20, %rsi
addq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x2acc
testb %al, %al
je 0x2ab7
movq 0x30(%r14), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rdx
movb $0x0, (%rax,%rdx)
imulq $0x18, %rcx, %rcx
movl 0x8(%rax,%rcx), %eax
movl %ebx, -0x34(%rbp)
movl %eax, -0x30(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x34d6
movq %r15, %rdi
leaq -0x2c(%rbp), %r12
movq %r12, %rsi
callq 0x2e12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2e74
movl -0x2c(%rbp), %edx
incl %edx
movl %edx, %r12d
jmp 0x2a07
cmpl %r13d, %r12d
setge %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::WritePage(PageDescriptor, char*)
bool BufferManager::WritePage(PageDescriptor pd,char *src) {
	// calculate file offset
	long offset = pd.pagenum*(long)pageSize + FILE_HDR_SIZE;
	lseek(pd.fd,offset,0); // seek to location
	if(write(pd.fd,src,pageSize)!=pageSize) //write failed
		return false;
	return true;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
sarq $0x20, %rsi
movslq 0x3c(%rdi), %rax
imulq %rax, %rsi
addq $0x1000, %rsi           # imm = 0x1000
movl %r14d, %edi
xorl %edx, %edx
callq 0x2260
movslq 0x3c(%r15), %rdx
movl %r14d, %edi
movq %rbx, %rsi
callq 0x2080
movslq 0x3c(%r15), %rcx
cmpq %rcx, %rax
sete %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::FlushPage(PageDescriptor)
bool BufferManager::FlushPage(PageDescriptor pd) {
	// do a linear scan to find the corresponding page 
	for(int i=0;i<numPages;i++) {
		if(find(usedList.begin(),usedList.end(),i)==usedList.end()) continue; // skip free slots
		if(!(buffers[i].pageDescriptor== pd)) continue;
		//write back page if dirty
		if(buffers[i].dirty) {
			bool _res = WritePage(pd,buffers[i].data);
			if(!_res) return false;
			buffers[i].dirty = false;
		}
		//remove slot from hashTable and usedList and add to free list
		hashTable.erase(pd);
		usedList.remove(i);
		freeList.push_front(i);
		break; // only once instance 
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movq %rsi, -0x40(%rbp)
leaq 0x18(%rdi), %r15
movq %rsi, %rax
shrq $0x20, %rax
movq %rax, -0x38(%rbp)
xorl %ecx, %ecx
leaq -0x2c(%rbp), %r13
movl %ecx, -0x2c(%rbp)
movb $0x1, %r14b
cmpl 0x38(%rbx), %ecx
jge 0x2beb
movq (%r15), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x34bc
movslq -0x2c(%rbp), %rcx
cmpq %r15, %rax
je 0x2b8f
movq 0x30(%rbx), %rax
imulq $0x18, %rcx, %rdx
cmpl %r12d, 0x4(%rax,%rdx)
jne 0x2b8f
movq -0x38(%rbp), %rsi
cmpl %esi, 0x8(%rax,%rdx)
je 0x2b93
incl %ecx
jmp 0x2b50
cmpb $0x1, (%rax,%rdx)
jne 0x2bbf
addq %rdx, %rax
movq 0x10(%rax), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2acc
testb %al, %al
je 0x2be8
movq 0x30(%rbx), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
movb $0x0, (%rax,%rcx)
leaq 0x40(%rbx), %rdi
leaq -0x40(%rbp), %rsi
callq 0x34d6
leaq -0x2c(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2e12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2e74
jmp 0x2beb
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::PrintBuffer()
void BufferManager::PrintBuffer() {
	cout << "Buffer contains " << numPages << " pages of size "
      << pageSize <<".\n";
   cout << "Contents in order from most recently used to "
      << "least recently used.\n";

    for(auto slot:usedList) {
    	cout << slot << " :: \n";
      	cout << "  fd = " << buffers[slot].pageDescriptor.fd << "\n";
      	cout << "  pageNum = " << buffers[slot].pageDescriptor.pagenum << "\n";
      	cout << "  Dirty = " << buffers[slot].dirty << "\n";
      	cout << "  pinned = " << buffers[slot].pinned << "\n";
      
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x53ba(%rip), %r14      # 0x7fd0
leaq 0x246d(%rip), %rsi      # 0x508a
movq %r14, %rdi
callq 0x2170
movl 0x38(%rbx), %esi
movq %rax, %rdi
callq 0x2230
leaq 0x2464(%rip), %rsi      # 0x509b
movq %rax, %rdi
callq 0x2170
movl 0x3c(%rbx), %esi
movq %rax, %rdi
callq 0x2230
leaq 0x249b(%rip), %rsi      # 0x50ec
movq %rax, %rdi
callq 0x2170
leaq 0x244b(%rip), %rsi      # 0x50ab
movq %r14, %rdi
callq 0x2170
leaq 0x246a(%rip), %rsi      # 0x50d9
movq %rax, %rdi
callq 0x2170
leaq 0x18(%rbx), %r15
leaq 0x2471(%rip), %r13      # 0x50f3
movq %r15, -0x30(%rbp)
movq (%r15), %r15
cmpq -0x30(%rbp), %r15
je 0x2d67
movslq 0x10(%r15), %r12
movq %r14, %rdi
movl %r12d, %esi
callq 0x2230
movq %rax, %rdi
leaq 0x2443(%rip), %rsi      # 0x50ef
callq 0x2170
movq %r14, %rdi
leaq 0x243a(%rip), %rsi      # 0x50f5
callq 0x2170
movq 0x30(%rbx), %rcx
imulq $0x18, %r12, %r12
movl 0x4(%rcx,%r12), %esi
movq %rax, %rdi
callq 0x2230
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %r14, %rdi
leaq 0x2413(%rip), %rsi      # 0x50fd
callq 0x2170
movq 0x30(%rbx), %rcx
movl 0x8(%rcx,%r12), %esi
movq %rax, %rdi
callq 0x2230
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %r14, %rdi
leaq 0x23f5(%rip), %rsi      # 0x510a
callq 0x2170
movq 0x30(%rbx), %rcx
movzbl (%rcx,%r12), %esi
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %r14, %rdi
leaq 0x23d5(%rip), %rsi      # 0x5115
callq 0x2170
movq 0x30(%rbx), %rcx
movzbl 0x1(%rcx,%r12), %esi
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
jmp 0x2c86
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/buffer_manager.cpp
// Function: BufferManager::ClearBuffer()
void BufferManager::ClearBuffer() {
	while(!usedList.empty()) {
		int slot = usedList.front();
		usedList.pop_front(); // remove front usedList
		hashTable.erase(buffers[slot].pageDescriptor); //remove from hash table
		freeList.push_front(slot); // add to free list
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x18(%rdi), %r14
leaq 0x40(%rdi), %r15
leaq -0x24(%rbp), %r12
movq (%r14), %rax
cmpq %r14, %rax
je 0x2dd3
movl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movq %r14, %rdi
callq 0x2e84
movq 0x30(%rbx), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %rsi
addq $0x4, %rsi
movq %r15, %rdi
callq 0x34d6
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2e74
jmp 0x2d94
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::FileHandler()
FileHandler::FileHandler() {
	isOpen = false;
	hdrChanged = false;
	unix_file_desc = -1;
	bufferManager = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
andw $0x0, 0x10(%rdi)
orl $-0x1, 0x14(%rdi)
andq $0x0, (%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::NextPage(int)
PageHandler FileHandler::NextPage(int page_number) {
	PageHandler pageHandle;
	if(!checkPageValid(page_number) && page_number!=-1) { //allow -1
		// return invalid page
		throw InvalidPageException();
	}
	// start searching for next valid(used) page 
	page_number = page_number + 1;
	for(;page_number<=hdr.totalPages;page_number++) { // MR: page_number <= totalpages to ensure that it runs this at least once if file contains only one page
		pageHandle = PageAt(page_number);
		// if page retrieved without error, stop checking further
		if(pageHandle.GetPageNum()!=-1) break;
	}
	return pageHandle;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
orl $-0x1, (%rdi)
andq $0x0, 0x8(%rdi)
movl %edx, %r14d
movq %rsi, %r15
testl %edx, %edx
setns %al
cmpl %edx, 0xc(%rsi)
setg %cl
cmpl $-0x1, %edx
je 0x3709
andb 0x10(%r15), %al
andb %cl, %al
je 0x3733
cmpl 0xc(%r15), %r14d
jge 0x3725
incl %r14d
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x37f8
cmpl $-0x1, (%rbx)
je 0x3709
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x20e0
leaq 0x4606(%rip), %rcx      # 0x7d48
movq %rcx, (%rax)
leaq 0x45a4(%rip), %rsi      # 0x7cf0
movq 0x488d(%rip), %rdx      # 0x7fe0
movq %rax, %rdi
callq 0x2220
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::PrevPage(int)
PageHandler FileHandler::PrevPage(int page_number) {
	if(!checkPageValid(page_number) && page_number!=hdr.totalPages) { //allow totalPages (call from LastPage)
		// return invalid page
		throw InvalidPageException();
	}
	// start searching for prev valid(used) page 
	page_number = page_number - 1;
	PageHandler pageHandle;
	for(;page_number>=0;page_number--) {
		pageHandle = PageAt(page_number);
		// if page retrieved without error, stop checking further
		if(pageHandle.GetPageNum()!=-1) break;
	}
	return pageHandle;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
testl %edx, %edx
setns %al
andb 0x10(%rsi), %al
cmpl %edx, 0xc(%rsi)
setg %cl
sete %dl
andb %al, %cl
orb %dl, %cl
je 0x37d0
movq %rsi, %r15
movq %rdi, %r14
orl $-0x1, (%rdi)
andq $0x0, 0x8(%rdi)
testl %ebx, %ebx
jle 0x37c2
decl %ebx
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x37f8
cmpl $-0x1, (%r14)
je 0x37a9
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x20e0
leaq 0x4569(%rip), %rcx      # 0x7d48
movq %rcx, (%rax)
leaq 0x4507(%rip), %rsi      # 0x7cf0
movq 0x47f0(%rip), %rdx      # 0x7fe0
movq %rax, %rdi
callq 0x2220
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::PageAt(int)
PageHandler FileHandler::PageAt(int page_number) {
	PageHandler pageHandle;
	if(!checkPageValid(page_number)) {
		// return invalid page
		throw InvalidPageException();
	}
	// get page from bufferManager
 
	char *page_in_buffer = bufferManager->GetPage(PageDescriptor(this->unix_file_desc,page_number));	
	// get page header
	PageHdr *page_hdr = (PageHdr*) page_in_buffer;
	// if slot is not free
	// set page number 
	// and set page data to point to starting position of data part in page obtained from buffer manager
	if (page_hdr->nextFreePage==NOT_FREE) {
		pageHandle.pageNum = page_number;
		pageHandle.data = page_in_buffer+sizeof(PageHdr);
	}
	else {
		// unpin page according to redbase logic
		UnpinPage(page_number);
	}
	return pageHandle;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
orl $-0x1, (%rdi)
andq $0x0, 0x8(%rdi)
testl %edx, %edx
js 0x3864
movq %rsi, %r15
cmpb $0x0, 0x10(%rsi)
je 0x3864
movl %edx, %r14d
cmpl %edx, 0xc(%r15)
jle 0x3864
movq %rdi, %rbx
movq (%r15), %rdi
movl 0x14(%r15), %eax
movq %r14, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
callq 0x25b0
cmpl $-0x2, (%rax)
jne 0x384b
movl %r14d, (%rbx)
addq $0x4, %rax
movq %rax, 0x8(%rbx)
jmp 0x3856
movq %r15, %rdi
movl %r14d, %esi
callq 0x38a2
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x20e0
leaq 0x44d5(%rip), %rcx      # 0x7d48
movq %rcx, (%rax)
leaq 0x4473(%rip), %rsi      # 0x7cf0
movq 0x475c(%rip), %rdx      # 0x7fe0
movq %rax, %rdi
callq 0x2220
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::NewPage()
PageHandler FileHandler::NewPage() {
	int page_number ; // new page number
	char *page_buffer ; //to store page read from buffer manager
	PageHandler pageHandle;
	//if free list not empty 
	if(hdr.firstFreePage!= END_FREE) {
		// first free page number will be the new page number 
		page_number = hdr.firstFreePage;
		//contents of page are read using the buffer manager
		page_buffer = bufferManager->GetPage(PageDescriptor(this->unix_file_desc,page_number));
		// update the head of free page list for file	
		hdr.firstFreePage = ((PageHdr*)page_buffer)->nextFreePage;
	}
	else { // free pages
		page_number = hdr.totalPages; // new page will be added at the end of file
		page_buffer = bufferManager->AllocatePage(PageDescriptor(this->unix_file_desc,page_number)); //allocate and load the page in buffer manager
		//increase number of pages by one
		hdr.totalPages++;
	}
	//mark file header is changed
	this->hdrChanged = true;
	// mark the new page as used
    ((PageHdr *)page_buffer)->nextFreePage = NOT_FREE;
    //overwrite page contents
    memset(page_buffer+sizeof(PageHdr),0,PAGE_CONTENT_SIZE);
    //mark the page dirty due to next pointer of free list changed
    MarkDirty(page_number);
    pageHandle.pageNum = page_number;
    pageHandle.data = page_buffer+sizeof(PageHdr);
 
    return pageHandle;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0x8(%rsi), %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %r15
je 0x38fc
movq (%r14), %rdi
movl 0x14(%r14), %eax
movq %r15, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
callq 0x25b0
movq %rax, %r12
movl (%rax), %eax
movl %eax, 0x8(%r14)
jmp 0x391d
movl 0xc(%r14), %r15d
movq (%r14), %rdi
movl 0x14(%r14), %eax
movq %r15, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
callq 0x281c
movq %rax, %r12
incl 0xc(%r14)
movb $0x1, 0x11(%r14)
movl $0xfffffffe, (%r12)     # imm = 0xFFFFFFFE
addq $0x4, %r12
movl $0xffc, %edx            # imm = 0xFFC
movq %r12, %rdi
xorl %esi, %esi
callq 0x2100
movq %r14, %rdi
movl %r15d, %esi
callq 0x395c
movl %r15d, (%rbx)
movq %r12, 0x8(%rbx)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::DisposePage(int)
bool FileHandler::DisposePage(int page_number) {

	if(!checkPageValid(page_number)) return false; // invalid request
	// read the page from the buffer manager 
	char *page_buffer;
	page_buffer = bufferManager->GetPage(PageDescriptor(this->unix_file_desc,page_number));
	PageHdr * page_header = (PageHdr*) page_buffer;
	// if already free - 
	if (page_header->nextFreePage!=NOT_FREE) {
		UnpinPage(page_number); // since page read into buffer manager
		return false;
	}
	// update the head of free list by adding this page at the head
	page_header->nextFreePage = hdr.firstFreePage;
	hdr.firstFreePage = page_number;
	this->hdrChanged = true;
	// mark the page as dirty and then unpin it 
	MarkDirty(page_number);
	UnpinPage(page_number);
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
xorl %r15d, %r15d
testl %esi, %esi
js 0x39da
movq %rdi, %r14
cmpb $0x0, 0x10(%rdi)
je 0x39da
movl %esi, %ebx
cmpl %esi, 0xc(%r14)
jle 0x39da
movq (%r14), %rdi
movl 0x14(%r14), %eax
movq %rbx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
callq 0x25b0
cmpl $-0x2, (%rax)
sete %r15b
jne 0x39d0
movl 0x8(%r14), %ecx
movl %ecx, (%rax)
movl %ebx, 0x8(%r14)
movb $0x1, 0x11(%r14)
movq %r14, %rdi
movl %ebx, %esi
callq 0x395c
movq %r14, %rdi
movl %ebx, %esi
callq 0x38a2
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::FlushPages()
bool FileHandler::FlushPages() {
	if(this->hdrChanged) {
		lseek(this->unix_file_desc,0,0); // seek file pointer to start
		int _wr_res = write(this->unix_file_desc,(char *)&hdr,sizeof(FileHdr));
		if(_wr_res<0) return false; //write error
		this->hdrChanged =false;
	}
	return bufferManager->FlushPages(this->unix_file_desc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x1, 0x11(%rdi)
jne 0x3a1a
movl 0x14(%rbx), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2260
movl 0x14(%rbx), %edi
leaq 0x8(%rbx), %rsi
pushq $0x8
popq %rdx
callq 0x2080
testl %eax, %eax
js 0x3a2b
movb $0x0, 0x11(%rbx)
movq (%rbx), %rdi
movl 0x14(%rbx), %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x29dc
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/akgupta007[P]DBMS-query-processing-Algotihms/file_manager.cpp
// Function: FileHandler::FlushPage(int)
bool FileHandler::FlushPage(int page_number) {
	if(this->hdrChanged) {
		lseek(this->unix_file_desc,0,0); // seek file pointer to start
		int _wr_res = write(this->unix_file_desc,(char *)&hdr,sizeof(FileHdr));
		if(_wr_res<0) return false; //write error
		this->hdrChanged =false;
	}
	return bufferManager->FlushPage(PageDescriptor(this->unix_file_desc,page_number));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
cmpb $0x1, 0x11(%rdi)
jne 0x3a6c
movl 0x14(%r14), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2260
movl 0x14(%r14), %edi
leaq 0x8(%r14), %rsi
pushq $0x8
popq %rdx
callq 0x2080
testl %eax, %eax
js 0x3a86
movb $0x0, 0x11(%r14)
movq (%r14), %rdi
movl 0x14(%r14), %eax
shlq $0x20, %rbx
orq %rax, %rbx
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x2b20
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop