// File: /workspace/github_cpp_makefile_star2_O1/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 0x2150
movq %rax, %r12
leaq 0x3b5a(%rip), %rsi      # 0x6004
movl $0x3, %edx
movq %rbx, %rdi
callq 0x20d0
testl %eax, %eax
je 0x2500
leaq 0x3b46(%rip), %rsi      # 0x6008
movl $0x6, %edx
movq %rbx, %rdi
callq 0x20d0
testl %eax, %eax
je 0x2511
leaq 0x3b35(%rip), %rsi      # 0x600f
movl $0xa, %edx
movq %rbx, %rdi
callq 0x20d0
testl %eax, %eax
jne 0x25fa
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4a18
jmp 0x2520
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4780
jmp 0x2520
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4be4
xorl %edi, %edi
callq 0x2150
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
cvttsd2si %xmm0, %esi
leaq 0x3af8(%rip), %rdi      # 0x6035
xorl %eax, %eax
callq 0x2030
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2ec8
movsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2f68
movsd %xmm0, 0x8(%rsp)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x3102
movsd %xmm0, (%rsp)
leaq 0x3acd(%rip), %rdi      # 0x6050
movq %r14, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2030
leaq 0x3ae8(%rip), %rdi      # 0x6081
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
movb $0x2, %al
callq 0x2030
leaq 0x3b05(%rip), %rdi      # 0x60b7
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x25d6
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x25ed
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3a19(%rip), %rdi      # 0x601a
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
movl $0x1, %edi
callq 0x21e0
jmp 0x261b
jmp 0x261b
jmp 0x261b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x28c2
movq %rbx, %rdi
callq 0x2280