// File: 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:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movl %esi, 0xac(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x2980
xorl %eax, %eax
movl %eax, %edi
callq 0x2150
movq %rax, 0x58(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0x9c17(%rip), %rsi      # 0xc004
movl $0x3, %edx
callq 0x20c0
cmpl $0x0, %eax
jne 0x2439
movq 0x98(%rsp), %rdi
movl 0xac(%rsp), %esi
leaq 0x60(%rsp), %rdx
callq 0x90e0
jmp 0x2417
jmp 0x24d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x29b0
jmp 0x25ef
movq 0xb0(%rsp), %rdi
leaq 0x9bc0(%rip), %rsi      # 0xc008
movl $0x6, %edx
callq 0x20c0
cmpl $0x0, %eax
jne 0x2474
movq 0x98(%rsp), %rdi
movl 0xac(%rsp), %esi
leaq 0x60(%rsp), %rdx
callq 0x9960
jmp 0x2472
jmp 0x24d3
movq 0xb0(%rsp), %rdi
leaq 0x9b8c(%rip), %rsi      # 0xc00f
movl $0xa, %edx
callq 0x20c0
cmpl $0x0, %eax
jne 0x24af
movq 0x98(%rsp), %rdi
movl 0xac(%rsp), %esi
leaq 0x60(%rsp), %rdx
callq 0x95d0
jmp 0x24ad
jmp 0x24d1
movq 0xb0(%rsp), %rsi
leaq 0x9b5c(%rip), %rdi      # 0xc01a
xorl %eax, %eax
callq 0x2030
jmp 0x24c7
movl $0x1, %edi
callq 0x21d0
jmp 0x24d3
jmp 0x24d5
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
movl %eax, %edi
callq 0x2150
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x20d0
movl 0x1c(%rsp), %eax
cvttsd2si %xmm0, %ecx
movl %ecx, 0x3c(%rsp)
movl 0x3c(%rsp), %esi
leaq 0x9b28(%rip), %rdi      # 0xc035
callq 0x2030
jmp 0x2514
movq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x37a0
movsd %xmm0, 0x10(%rsp)
jmp 0x252e
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x38e0
movsd %xmm0, 0x8(%rsp)
jmp 0x2554
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3c00
movsd %xmm0, (%rsp)
jmp 0x2579
movsd (%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0xa0(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movl 0xac(%rsp), %ecx
leaq 0x9aae(%rip), %rdi      # 0xc050
xorl %eax, %eax
callq 0x2030
jmp 0x25ab
movsd 0x30(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
leaq 0x9ac3(%rip), %rdi      # 0xc081
movb $0x2, %al
callq 0x2030
jmp 0x25c7
movsd 0x28(%rsp), %xmm0
leaq 0x9ae3(%rip), %rdi      # 0xc0b7
movb $0x1, %al
callq 0x2030
jmp 0x25dd
leaq 0x60(%rsp), %rdi
callq 0x29b0
addq $0xb8, %rsp
retq
movq 0x50(%rsp), %rdi
callq 0x2270
nopl (%rax)