// File: /workspace/github_cpp_makefile_star2_O3/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
cmpb $0x4c, (%rbx)
jne 0x24b5
cmpb $0x44, 0x1(%rbx)
jne 0x24b5
cmpb $0x47, 0x2(%rbx)
jne 0x24b5
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4788
jmp 0x2509
leaq 0x3b4c(%rip), %rsi      # 0x6008
movl $0x6, %edx
movq %rbx, %rdi
callq 0x20d0
testl %eax, %eax
je 0x24fa
leaq 0x3b3b(%rip), %rsi      # 0x600f
movl $0xa, %edx
movq %rbx, %rdi
callq 0x20d0
testl %eax, %eax
jne 0x25e3
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4a2c
jmp 0x2509
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
callq 0x4bf8
xorl %edi, %edi
callq 0x2150
movq %rax, %rdi
movq %r12, %rsi
callq 0x20e0
cvttsd2si %xmm0, %esi
leaq 0x3b0f(%rip), %rdi      # 0x6035
xorl %eax, %eax
callq 0x2030
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2eb8
movsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x2f58
movsd %xmm0, 0x8(%rsp)
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
callq 0x30ec
movsd %xmm0, (%rsp)
leaq 0x3ae4(%rip), %rdi      # 0x6050
movq %r14, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2030
leaq 0x3aff(%rip), %rdi      # 0x6081
movsd 0x10(%rsp), %xmm0
movsd (%rsp), %xmm1
movb $0x2, %al
callq 0x2030
leaq 0x3b1c(%rip), %rdi      # 0x60b7
movsd 0x8(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x25bf
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x25d6
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3a30(%rip), %rdi      # 0x601a
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2030
movl $0x1, %edi
callq 0x21e0
jmp 0x2604
jmp 0x2604
jmp 0x2604
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x28c0
movq %rbx, %rdi
callq 0x2280