// File: /workspace/github_cpp_makefile_star2_O2/pollo[P]graph-partitioning/graph_partitioning.cpp
// Function: run_heuristic(char const*, int, char const*, Graph const&)
void run_heuristic(const char* heuristic_name,
                   int partitions_number,
                   const char* dataset,
                   const Graph& graph)
{
  Partition partition;

  time_t start = time(0);
  if (strncmp(heuristic_name,"LDG",3) == 0)
  {
    linear_deterministic_greedy(graph,
				partitions_number,
                                &partition);
  }
  else if (strncmp(heuristic_name,"FENNEL",6) == 0)
  {
    fennel(graph,
           partitions_number,
           &partition);
  }
  else if (strncmp(heuristic_name,"NNEIGHBORS",10) == 0)
  {
    non_neighbors_greedy(graph,
                         partitions_number,
                         &partition);
  }
  else
  {
    printf("Invalid heuristic name %s\n",heuristic_name);
    exit(1);
  }

  time_t end = time(0);
  int time = difftime(end, start);
  printf("Partitioned in %d seconds\n",time);

  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("Dataset %s with heuristic %s and %d partitions:\n",
         dataset,
         heuristic_name,
         partitions_number);
  printf("Fraction edges cut = %f\nNormalized maximum load = %f\n",
         fraction_edges_cut,
         maximum_load);
  printf("Communication volume %f\n\n",
         communication_volume);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rcx, %r15
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x40(%rsp)
movupd %xmm0, 0x30(%rsp)
movupd %xmm0, 0x20(%rsp)
xorl %edi, %edi
callq 0x2160
movq %rax, %r12
cmpb $0x4c, (%rbx)
jne 0x23f5
cmpb $0x44, 0x1(%rbx)
jne 0x23f5
cmpb $0x47, 0x2(%rbx)
jne 0x23f5
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x41ac
jmp 0x2445
leaq 0x2c0c(%rip), %rsi      # 0x5008
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x20e0
testl %eax, %eax
je 0x2436
leaq 0x2bfd(%rip), %rsi      # 0x500f
pushq $0xa
popq %rdx
movq %rbx, %rdi
callq 0x20e0
testl %eax, %eax
jne 0x24fb
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x43dc
jmp 0x2445
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4559
xorl %edi, %edi
callq 0x2160
movq %rax, %rdi
movq %r12, %rsi
callq 0x20f0
cvttsd2si %xmm0, %esi
leaq 0x2bd3(%rip), %rdi      # 0x5035
xorl %eax, %eax
callq 0x2030
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2bfa
movsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2c8e
movsd %xmm0, 0x8(%rsp)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2dae
movsd %xmm0, (%rsp)
leaq 0x2ba8(%rip), %rdi      # 0x5050
movq %r14, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2030
leaq 0x2bc3(%rip), %rdi      # 0x5081
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
movb $0x2, %al
callq 0x2030
leaq 0x2be0(%rip), %rdi      # 0x50b7
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
leaq 0x18(%rsp), %rdi
callq 0x27ae
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b18(%rip), %rdi      # 0x501a
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
pushq $0x1
popq %rdi
callq 0x21e0
jmp 0x251a
jmp 0x251a
jmp 0x251a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x27ae
movq %rbx, %rdi
callq 0x2280