// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, 0x10(%rsp)
andl $0x0, 0x18(%rsp)
movq %rsi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
cmpl $0x2, %edi
jne 0x2597
movq 0x8(%r14), %rbx
leaq 0x2c41(%rip), %rsi      # 0x501e
movq %rbx, %rdi
callq 0x2060
testq %rax, %rax
je 0x23f6
leaq 0x10(%rsp), %rdi
callq 0x3cd2
jmp 0x2423
leaq 0x2c29(%rip), %rsi      # 0x5026
movq %rbx, %rdi
callq 0x2060
testq %rax, %rax
je 0x2416
leaq 0x10(%rsp), %rdi
callq 0x3b86
jmp 0x2423
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3984
pushq $0x1
popq %rbp
cmpl $0xb, %ebp
je 0x2579
xorl %eax, %eax
movl %ebp, 0xc(%rsp)
cmpl $0x3, %eax
je 0x2572
movl %eax, 0x8(%rsp)
pushq $0x2
popq %rbx
cmpl $0x401, %ebx            # imm = 0x401
jae 0x2567
movq %r14, %rbp
leaq 0x58(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
xorl %edi, %edi
callq 0x2150
movq %rax, %r14
movl 0x8(%rsp), %eax
cmpl $0x1, %eax
je 0x249e
testl %eax, %eax
jne 0x24be
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
leaq 0x50(%rsp), %r15
movq %r15, %rdx
callq 0x3fe4
leaq 0x2b8f(%rip), %r13      # 0x502b
jmp 0x24dc
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
leaq 0x50(%rsp), %r15
movq %r15, %rdx
callq 0x4391
leaq 0x2b73(%rip), %r13      # 0x502f
jmp 0x24dc
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl %ebx, %esi
leaq 0x50(%rsp), %r15
movq %r15, %rdx
callq 0x4214
leaq 0x2b5a(%rip), %r13      # 0x5036
xorl %edi, %edi
callq 0x2150
movq %rax, %rdi
movq %r14, %rsi
callq 0x20e0
movsd %xmm0, 0x40(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x2a32
movsd %xmm0, 0x48(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x2ac6
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x2be6
movaps %xmm0, %xmm2
cvttsd2si 0x40(%rsp), %r9d
movq %rbp, %r14
movq 0x8(%rbp), %rsi
leaq 0x2b08(%rip), %rdi      # 0x5041
movl 0xc(%rsp), %ebp
movl %ebp, %edx
movq %r13, %rcx
movl %ebx, %r8d
movsd 0x48(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
movb $0x3, %al
callq 0x2030
movq %r15, %rdi
callq 0x25e6
addl %ebx, %ebx
jmp 0x2445
movl 0x8(%rsp), %eax
incl %eax
jmp 0x2435
incl %ebp
jmp 0x2426
leaq 0x20(%rsp), %rdi
callq 0x2640
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2abf(%rip), %rdi      # 0x505d
callq 0x2200
movq (%r14), %rsi
leaq 0x2a57(%rip), %rdi      # 0x5004
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rdi
callq 0x21d0
movq %rax, %rbx
jmp 0x25d4
jmp 0x25c7
jmp 0x25c7
jmp 0x25c7
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x25e6
leaq 0x20(%rsp), %rdi
callq 0x2640
movq %rbx, %rdi
callq 0x2260