// File: /workspace/github_cpp_makefile_star2_O1/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 0x3a6e
leaq 0x1606(%rip), %rdx      # 0x53a8
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x3b20
movq 0x421b(%rip), %rbx      # 0x7fd0
leaq 0x15f5(%rip), %rsi      # 0x53b1
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 0x41e9(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3876
leaq -0x50(%rbp), %rdi
callq 0x35ec
movabsq $0x3e800000005, %rcx    # imm = 0x3E800000005
movq %rcx, (%rax)
leaq -0x40(%rbp), %rdi
callq 0x39c4
movq 0x41a9(%rip), %rbx      # 0x7fd0
leaq 0x1591(%rip), %rsi      # 0x53bf
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 0x4177(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3cac
leaq 0x152e(%rip), %rdx      # 0x53a8
leaq -0x70(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3bde
movups -0x70(%rbp), %xmm0
movups -0x60(%rbp), %xmm1
movaps %xmm1, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movq 0x4132(%rip), %rbx      # 0x7fd0
leaq 0x1533(%rip), %rsi      # 0x53d8
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 0x4100(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3656
movups -0x70(%rbp), %xmm0
leaq -0x50(%rbp), %rdi
movaps %xmm0, (%rdi)
callq 0x35ec
movq %rax, %rbx
movl (%rax), %r14d
movq 0x40c9(%rip), %rdi      # 0x7fd0
leaq 0x14d6(%rip), %rsi      # 0x53e4
movl $0xe, %edx
callq 0x2170
movq 0x40b1(%rip), %rdi      # 0x7fd0
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 0x4075(%rip), %rdi      # 0x7fd0
leaq 0x1491(%rip), %rsi      # 0x53f3
movl $0xf, %edx
callq 0x2170
movq 0x405d(%rip), %rdi      # 0x7fd0
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 0x3cac
leaq 0x13f0(%rip), %rsi      # 0x53a8
leaq -0x18(%rbp), %rdi
callq 0x3c98
leaq -0x18(%rbp), %rdi
callq 0x3aea
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x3fdf
jmp 0x3fdf
jmp 0x3fdf
jmp 0x3fdf
jmp 0x3fdf
movq %rax, %rbx
leaq -0x18(%rbp), %rdi
callq 0x3aea
movq %rbx, %rdi
callq 0x2210