// File: /workspace/github_cpp_makefile_star2_O3/ankit-1517[P]dbms_rTree/sample_run.cpp
// Function: main
int main() {
	FileManager fm;

	// Create a brand new file
	FileHandler fh = fm.CreateFile("temp.txt");
	cout << "File created " << endl;

	// Create a new page
	PageHandler ph = fh.NewPage ();
	char *data = ph.GetData ();

	// Store an integer at the very first location
	int num = 5;
	memcpy (&data[0], &num, sizeof(int));

	// Store an integer at the second location
	num = 1000;
	memcpy (&data[4], &num, sizeof(int));

	// Flush the page
	fh.FlushPages ();
	cout << "Data written and flushed" << endl;

	// Close the file
	fm.CloseFile(fh);

	// Reopen the same file, but for reading this time
	fh = fm.OpenFile ("temp.txt");
	cout << "File opened" << endl;

	// Get the very first page and its data
	ph = fh.FirstPage ();
	data = ph.GetData ();

	// Output the first integer
	memcpy (&num, &data[0], sizeof(int));
	cout << "First number: " << num << endl;

	// Output the second integer
	memcpy (&num, &data[4], sizeof(int));
	cout << "Second number: " << num << endl;;

	// Close the file and destory it
	fm.CloseFile (fh);
	fm.DestroyFile ("temp.txt");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
leaq -0x18(%rbp), %rbx
movq %rbx, %rdi
callq 0x3a2e
leaq 0x656(%rip), %rdx       # 0x43a8
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x3ad8
movq 0x326b(%rip), %rbx      # 0x6fd0
leaq 0x645(%rip), %rsi       # 0x43b1
movl $0xd, %edx
movq %rbx, %rdi
callq 0x2170
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x3239(%rip), %rdi      # 0x6fd0
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3842
leaq -0x50(%rbp), %rdi
callq 0x35b8
movabsq $0x3e800000005, %rcx    # imm = 0x3E800000005
movq %rcx, (%rax)
leaq -0x40(%rbp), %rdi
callq 0x3984
movq 0x31f9(%rip), %rbx      # 0x6fd0
leaq 0x5e1(%rip), %rsi       # 0x43bf
movl $0x18, %edx
movq %rbx, %rdi
callq 0x2170
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x31c7(%rip), %rdi      # 0x6fd0
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3c5c
leaq 0x57e(%rip), %rdx       # 0x43a8
leaq -0x70(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3b94
movups -0x70(%rbp), %xmm0
movups -0x60(%rbp), %xmm1
movaps %xmm1, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movq 0x3182(%rip), %rbx      # 0x6fd0
leaq 0x583(%rip), %rsi       # 0x43d8
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2170
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x3150(%rip), %rdi      # 0x6fd0
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3622
movups -0x70(%rbp), %xmm0
leaq -0x50(%rbp), %rdi
movaps %xmm0, (%rdi)
callq 0x35b8
movq %rax, %rbx
movl (%rax), %r14d
movq 0x3119(%rip), %rdi      # 0x6fd0
leaq 0x526(%rip), %rsi       # 0x43e4
movl $0xe, %edx
callq 0x2170
movq 0x3101(%rip), %rdi      # 0x6fd0
movl %r14d, %esi
callq 0x2200
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20f0
movl 0x4(%rbx), %ebx
movq 0x30c5(%rip), %rdi      # 0x6fd0
leaq 0x4e1(%rip), %rsi       # 0x43f3
movl $0xf, %edx
callq 0x2170
movq 0x30ad(%rip), %rdi      # 0x6fd0
movl %ebx, %esi
callq 0x2200
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3c5c
leaq 0x440(%rip), %rsi       # 0x43a8
leaq -0x18(%rbp), %rdi
callq 0x3c48
leaq -0x18(%rbp), %rdi
callq 0x3aaa
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x3f8f
jmp 0x3f8f
jmp 0x3f8f
jmp 0x3f8f
jmp 0x3f8f
movq %rax, %rbx
leaq -0x18(%rbp), %rdi
callq 0x3aaa
movq %rbx, %rdi
callq 0x2210