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

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

  if (strstr(argv[1],"twitter") != NULL)
    twitter_loader(&graph);
  else if (strstr(argv[1],"4elt") != NULL)
    elt_loader(&graph);
  else
    snap_loader(&graph, argv[1]);

  //printf("Dataset;Experiment #;Heuristic;K;Edge cut;"           
  //       "Communication Volume; Normalized Maximum Load;Runtime\n");
  for (int experiment = 1; experiment<=N_EXPERIMENTS; experiment++)
  {
    for (int heuristic = 0; heuristic<3; heuristic++)
    {
      for (int partitions_number = 2;
           partitions_number<=1024;
           partitions_number *= 2)
      {
        Partition partition;
        time_t start = time(0);
        const char* h_name;

        if (heuristic == 0)
        {
          linear_deterministic_greedy(graph,
                                      partitions_number,
                                      &partition);
          h_name = "LDG";
        }
        else if (heuristic == 1)
        {
          fennel(graph,
                 partitions_number,
                 &partition);
          h_name = "FENNEL";
        }
        else
        {
          non_neighbors_greedy(graph,
                               partitions_number,
                               &partition);
          h_name = "NNEIGHBORS";
        }
        time_t end = time(0);
        int time = difftime(end, start);

        double fraction_edges_cut = graph.get_fraction_edges_cut(partition);
        double communication_volume = graph.get_communication_volume(partition);
        double maximum_load = graph.get_normalized_maximum_load(partition);

        printf("%s;%d;%s;%d;%lf;%lf;%lf;%d\n",
               argv[1], experiment, h_name, partitions_number,
               fraction_edges_cut, communication_volume, maximum_load, time);

      }
    }
  }


  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r15
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rsp)
movq %rax, 0x30(%rsp)
cmpl $0x2, %edi
jne 0x266b
movq 0x8(%r15), %rbx
leaq 0x2b8d(%rip), %rsi      # 0x501e
movq %rbx, %rdi
callq 0x2050
testq %rax, %rax
je 0x24aa
leaq 0x10(%rsp), %rdi
callq 0x3e8d
jmp 0x24d7
leaq 0x2b75(%rip), %rsi      # 0x5026
movq %rbx, %rdi
callq 0x2050
testq %rax, %rax
je 0x24ca
leaq 0x10(%rsp), %rdi
callq 0x3caf
jmp 0x24d7
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3a78
movl $0x1, 0x8(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl $0x2, %ebx
leaq 0x58(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
xorl %edi, %edi
callq 0x2140
movq %rax, %r14
movl 0xc(%rsp), %eax
cmpl $0x1, %eax
je 0x2534
testl %eax, %eax
jne 0x2554
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
leaq 0x50(%rsp), %rbp
movq %rbp, %rdx
callq 0x4570
leaq 0x2af9(%rip), %r13      # 0x502b
jmp 0x2572
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
leaq 0x50(%rsp), %rbp
movq %rbp, %rdx
callq 0x49d4
leaq 0x2add(%rip), %r13      # 0x502f
jmp 0x2572
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
leaq 0x50(%rsp), %rbp
movq %rbp, %rdx
callq 0x4808
leaq 0x2ac4(%rip), %r13      # 0x5036
xorl %edi, %edi
callq 0x2140
movq %rax, %rdi
movq %r14, %rsi
callq 0x20d0
movsd %xmm0, 0x40(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2cb8
movsd %xmm0, 0x48(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2d58
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2ef2
movaps %xmm0, %xmm2
cvttsd2si 0x40(%rsp), %r9d
movq 0x8(%r15), %rsi
leaq 0x2a75(%rip), %rdi      # 0x5041
movl 0x8(%rsp), %edx
movq %r13, %rcx
movl %ebx, %r8d
movsd 0x48(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movb $0x3, %al
callq 0x2030
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x2603
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x261a
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
leal (%rbx,%rbx), %eax
cmpl $0x201, %ebx            # imm = 0x201
movl %eax, %ebx
jb 0x24ea
movl 0xc(%rsp), %eax
incl %eax
cmpl $0x3, %eax
jne 0x24e1
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl $0xb, %eax
jne 0x24df
leaq 0x20(%rsp), %rdi
callq 0x26e4
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29eb(%rip), %rdi      # 0x505d
callq 0x2200
movq (%r15), %rsi
leaq 0x2983(%rip), %rdi      # 0x5004
xorl %eax, %eax
callq 0x2030
movl $0x1, %edi
callq 0x21d0
movq %rax, %rbx
jmp 0x26d1
jmp 0x269d
jmp 0x269d
jmp 0x269d
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x26ba
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x26d1
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq 0x20(%rsp), %rdi
callq 0x26e4
movq %rbx, %rdi
callq 0x2260
nop