// File: /workspace/github_cpp_makefile_star2_O1/DavidNKraemer[P]convex-hull/main.cpp
// Function: main
int main(int argc, char *argv[]) {
  if (argc < 2) {
    std::cerr << "You must pass in the testing file\n";
    return EXIT_FAILURE;
  }
  std::string test_points_dir = "./tests/";
  std::string filename = argv[1];

  std::string results_dir = "./results/";

  CvHullBase *method = nullptr;

  // split method
  if (argc > 3) {
    // if you have other method, handle here
    // since currently we only have graham scan
    method = new GrahamScan();
  }
  else
    method = new GrahamScan();

  std::vector<Point2D> pc;
  std::vector<Point2D> ch;

  //
  // Estimate the size of pc and ch by using reserve!

  std::cout << "Fetching point cloud from [" 
    << test_points_dir + filename << "]" << std::endl;

  try {
    loadtxt(test_points_dir + filename, pc);
  } 

  catch (std::string err) {
    std::cerr << err << std::endl << "Aborting program." << std::endl;
    return 1;
  }

  compute_cvhull(pc, ch, *method);
  try {
    write2txt(results_dir + filename, ch);
  } 

  catch (std::string err) {
    std::cerr << err << std::endl << "Aborting program." << std::endl;
    return 1;
  }

  std::cout << "The result has been written to [" 
    << results_dir + filename << "]" << std::endl;

  if (method)
    delete method;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc0, %rsp
cmpl $0x1, %edi
jg 0x286e
movq 0x379d(%rip), %rdi      # 0x5ff0
leaq 0x17d5(%rip), %rsi      # 0x402f
movl $0x22, %edx
callq 0x21c0
movl $0x1, %ebx
jmp 0x2b4b
movq %rsi, %rbx
leaq 0xb0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x17ce(%rip), %rsi      # 0x4052
leaq 0x17cf(%rip), %rdx      # 0x405a
leaq 0xa0(%rsp), %rdi
callq 0x325a
movq 0x8(%rbx), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x2ed2
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x179c(%rip), %rsi      # 0x405b
leaq 0x179f(%rip), %rdx      # 0x4065
leaq 0x60(%rsp), %rdi
callq 0x325a
movl $0x8, %edi
callq 0x21a0
movq %rax, %rbx
leaq 0x346c(%rip), %rax      # 0x5d50
addq $0x10, %rax
movq %rax, (%rbx)
xorl %eax, %eax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq 0x36c5(%rip), %rdi      # 0x5fd0
leaq 0x1754(%rip), %rsi      # 0x4066
movl $0x1b, %edx
callq 0x21c0
movq %rsp, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x2f0f
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x368c(%rip), %rdi      # 0x5fd0
callq 0x21c0
movq %rax, %r14
leaq 0x172f(%rip), %rsi      # 0x4082
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x10(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x29a2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rsp, %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x2f0f
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x241c
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x29dd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq (%rbx), %rax
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq *(%rax)
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x2f0f
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x261c
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2a27
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x35a2(%rip), %rdi      # 0x5fd0
leaq 0x1661(%rip), %rsi      # 0x4096
movl $0x20, %edx
callq 0x21c0
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x2f0f
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x356c(%rip), %rdi      # 0x5fd0
callq 0x21c0
movq %rax, %r14
leaq 0x160f(%rip), %rsi      # 0x4082
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2abd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
xorl %ebx, %ebx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2adf
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2af6
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x2b0d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b2e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2b4b
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21b0
movl %ebx, %eax
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x2d37
movq %rdx, %r14
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2b87
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x2b87
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x2d68
movq %rbx, %rdi
callq 0x21d0
movq %rsp, %rdi
movq %r13, (%rdi)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x2f74
movq %rbx, %rdi
callq 0x20c0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x342a(%rip), %rdi      # 0x5ff0
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x14a7(%rip), %rsi      # 0x4084
movl $0x11, %edx
movq %rax, %rdi
callq 0x21c0
movq %rbx, %rdi
callq 0x20e0
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2c08
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
callq 0x2240
jmp 0x2ce4
jmp 0x2d37
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2c30
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
callq 0x2240
jmp 0x2d68
movq %rdx, %r14
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2c5e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x2c5e
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0x2d68
movq %rbx, %rdi
callq 0x21d0
movq %rsp, %rdi
movq %r13, (%rdi)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x2f74
movq %rbx, %rdi
callq 0x20c0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x3353(%rip), %rdi      # 0x5ff0
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0x13d0(%rip), %rsi      # 0x4084
movl $0x11, %edx
movq %rax, %rdi
callq 0x21c0
movq %rbx, %rdi
callq 0x20e0
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2cdf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
callq 0x2240
movl $0x1, %ebx
jmp 0x2ac8
jmp 0x2d37
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x2d09
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
callq 0x2240
jmp 0x2d68
movq %rax, %rdi
callq 0x2f69
jmp 0x2d37
movq %rax, %rbx
jmp 0x2d96
movq %rax, %rbx
jmp 0x2dad
movq %rax, %rbx
jmp 0x2dce
movq %rax, %rbx
jmp 0x2deb
movq %rax, %rbx
jmp 0x2d68
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
jne 0x2d5b
jmp 0x2d68
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2d68
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2d7f
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2d96
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x2dad
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2dce
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21b0
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2deb
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2270
nop