// File: /workspace/github_cpp_makefile_star2_O3/pollo[P]graph-partitioning/graph_partitioning.cpp
// Function: main
int main(int argc, char** argv)
{
  Graph graph;

  if (argc != 4)
  {
    printf("Invalid number of parameters\n");
    printf("Usage: %s <dataset name> <heuristic names> <partitions number>\n",
           argv[0]);
    exit(1);
  }

  if (strncmp(argv[1],"slashdot",8) == 0)
    snap_loader(&graph, SLASHDOT_FILE);
  else if (strncmp(argv[1],"amazon",6) == 0) {
    snap_loader(&graph, AMAZON_FILE);
  }
  else if (strncmp(argv[1],"livejournal",11) == 0)
    snap_loader(&graph, LIVEJOURNAL_FILE);
  else if (strncmp(argv[1],"facebook",8) == 0)
    snap_loader(&graph, FACEBOOK_FILE);
  else if (strncmp(argv[1],"4elt",4) == 0)
    elt_loader(&graph);
  else if (strncmp(argv[1],"twitter",7) == 0)
    twitter_loader(&graph);
  else if (strncmp(argv[1],"pre.amazon",11) == 0) {
    preprocessed_loader(&graph, AMAZON_FILE);
  }
  else
  {
    printf("Invalid dataset name %s\n",argv[1]);
    exit(1);
  }

  int partitions_number = strtol(argv[3], NULL, 10);
  if (partitions_number < 1 || partitions_number > MAX_PARTITIONS)
  {
    printf("Invalid partition number %s\n",argv[3]);
    exit(1);
  }

  bool heuristics_valid = false;
  if (strstr(argv[2],"LDG") != NULL)
  {
    run_heuristic("LDG",partitions_number,argv[1],graph);
    heuristics_valid = true;
  }

  if (strstr(argv[2],"FENNEL") != NULL)
  {
    run_heuristic("FENNEL",partitions_number,argv[1],graph);
    heuristics_valid = true;
  }

  if (strstr(argv[2],"NNEIGHBORS") != NULL)
  {
    run_heuristic("NNEIGHBORS",partitions_number,argv[1],graph);
    heuristics_valid = true;
  }

  if (!heuristics_valid)
  {
    printf("Invalid heuristic name %s\n",argv[2]);
    exit(1);
  }

  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsp)
movq %rax, 0x28(%rsp)
cmpl $0x4, %edi
jne 0x286b
leaq 0x18(%rsp), %rbx
movq 0x8(%r14), %r15
leaq 0x3ab3(%rip), %rsi      # 0x6111
movl $0x8, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0x272e
leaq 0x3b35(%rip), %rsi      # 0x61af
movl $0x6, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0x2737
leaq 0x3ab8(%rip), %rsi      # 0x614e
movl $0xb, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0x2740
leaq 0x3ac5(%rip), %rsi      # 0x6177
movl $0x8, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0x2749
leaq 0x3ad0(%rip), %rsi      # 0x619e
movl $0x4, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0x284d
leaq 0x3ab9(%rip), %rsi      # 0x61a3
movl $0x7, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
je 0x285c
leaq 0x3aa5(%rip), %rsi      # 0x61ab
movl $0xb, %edx
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
jne 0x289f
leaq 0x3a15(%rip), %rsi      # 0x6137
leaq 0x8(%rsp), %rdi
callq 0x3dae
jmp 0x275a
leaq 0x39e5(%rip), %rsi      # 0x611a
jmp 0x2750
leaq 0x39f9(%rip), %rsi      # 0x6137
jmp 0x2750
leaq 0x3a13(%rip), %rsi      # 0x615a
jmp 0x2750
leaq 0x3a30(%rip), %rsi      # 0x6180
leaq 0x8(%rsp), %rdi
callq 0x3c90
movq 0x18(%r14), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x2200
movq %rax, %r15
movl $0xffffd8ef, %eax       # imm = 0xFFFFD8EF
leal (%r15,%rax), %ecx
cmpl %eax, %ecx
jbe 0x2883
movq 0x10(%r14), %r12
leaq 0x387b(%rip), %rsi      # 0x6004
movq %r12, %rdi
callq 0x2050
movq %rax, %r13
testq %rax, %rax
je 0x27b5
movq 0x8(%r14), %rdx
leaq 0x3860(%rip), %rdi      # 0x6004
leaq 0x8(%rsp), %rcx
movl %r15d, %esi
callq 0x245c
movq 0x10(%r14), %r12
leaq 0x384c(%rip), %rsi      # 0x6008
movq %r12, %rdi
callq 0x2050
testq %rax, %rax
je 0x27f8
movq 0x8(%r14), %rdx
leaq 0x3834(%rip), %rdi      # 0x6008
leaq 0x8(%rsp), %rcx
movl %r15d, %esi
callq 0x245c
movq 0x10(%r14), %rdi
leaq 0x3823(%rip), %rsi      # 0x600f
callq 0x2050
testq %rax, %rax
jne 0x280c
jmp 0x2824
leaq 0x3810(%rip), %rsi      # 0x600f
movq %r12, %rdi
callq 0x2050
testq %rax, %rax
je 0x283c
movq 0x8(%r14), %rdx
leaq 0x37f8(%rip), %rdi      # 0x600f
leaq 0x8(%rsp), %rcx
movl %r15d, %esi
callq 0x245c
movq %rbx, %rdi
callq 0x28f2
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
testq %r13, %r13
jne 0x2824
leaq 0x37d2(%rip), %rdi      # 0x601a
movq %r12, %rsi
jmp 0x288e
leaq 0x8(%rsp), %rdi
callq 0x3ec7
jmp 0x275a
leaq 0x8(%rsp), %rdi
callq 0x40a5
jmp 0x275a
leaq 0x397a(%rip), %rdi      # 0x61ec
callq 0x2220
movq (%r14), %rsi
leaq 0x3850(%rip), %rdi      # 0x60d1
jmp 0x288e
movq 0x18(%r14), %rsi
leaq 0x3941(%rip), %rdi      # 0x61cf
xorl %eax, %eax
callq 0x2030
movl $0x1, %edi
callq 0x21e0
leaq 0x3910(%rip), %rdi      # 0x61b6
movq %r15, %rsi
jmp 0x288e
jmp 0x28ad
movq %rax, %r14
movq %rbx, %rdi
callq 0x28f2
movq %r14, %rdi
callq 0x2280