LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_profiler.c
// Function: mctop_prof_stats_calc
void
mctop_prof_stats_calc(mctop_prof_t* prof, mctop_prof_stats_t* stats)
{
  qsort(prof->latencies, prof->size, sizeof(ticks), mctop_prof_comp_ticks);
  stats->num_vals = prof->size;
  
  stats->median = prof->latencies[prof->size >> 1];
  const size_t median2x = 2 * stats->median;
  size_t n_elems = 0;
  ticks sum = 0;
  for (size_t i = 0; i < stats->num_vals; i++)
    {
      if (likely(prof->latencies[i] < median2x))
	{
	  sum += prof->latencies[i];
	  n_elems++;
	}
    }

  const ticks avg = sum / n_elems;;
  stats->avg = avg;

  ticks sum_diff_sqr = 0;
  for (size_t i = 0; i < stats->num_vals; i++)
    {
      if (likely(prof->latencies[i] < median2x))
	{
	  ticks adiff = mctop_prof_abs_diff(prof->latencies[i], avg);
	  sum_diff_sqr += (adiff * adiff);
	}
    }
  stats->std_dev = sqrt(sum_diff_sqr / n_elems);
  stats->std_dev_perc = 100 * (1 - (avg - stats->std_dev) / avg);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x40(%rdi), %r14
movq (%rdi), %rsi
leaq 0x104(%rip), %rcx       # 0x53b7
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x20a0
movq (%r15), %rdi
movq %rdi, (%rbx)
movq %rdi, %rax
andq $-0x2, %rax
movq 0x40(%r15,%rax,4), %r8
movq %r8, 0x8(%rbx)
addq %r8, %r8
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
xorl %r9d, %r9d
cmpq %rdx, %rdi
je 0x52fc
movq (%r14,%rdx,8), %rsi
cmpq %r8, %rsi
cmovaeq %rcx, %rsi
adcq $0x0, %r9
addq %rsi, %rax
incq %rdx
jmp 0x52e0
xorl %esi, %esi
xorl %edx, %edx
divq %r9
movq %rax, %rcx
movq %rax, 0x10(%rbx)
xorl %eax, %eax
cmpq %rax, %rdi
je 0x5339
movq (%r14,%rax,8), %rdx
cmpq %r8, %rdx
jae 0x5334
movq %rcx, %r10
subq %rdx, %r10
negq %r10
movq %rcx, %r11
subq %rdx, %r11
cmovbq %r10, %r11
imulq %r11, %r11
addq %r11, %rsi
incq %rax
jmp 0x530c
movq %rsi, %rax
xorl %edx, %edx
divq %r9
movq %rax, %xmm0
movq 0x4d02(%rip), %xmm1     # 0xa050
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x4d06(%rip), %xmm2     # 0xa060
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
sqrtsd %xmm3, %xmm0
movsd %xmm0, 0x18(%rbx)
movq %rcx, %xmm3
punpckldq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
subpd %xmm2, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
addsd %xmm3, %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd 0x6418(%rip), %xmm0     # 0xb7b8
subsd %xmm2, %xmm0
mulsd 0x4c5c(%rip), %xmm0     # 0xa008
movsd %xmm0, 0x20(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_profiler.c
// Function: mctop_prof_stats_print
void
mctop_prof_stats_print(mctop_prof_stats_t* stats)
{
  printf("## mctop_prof stats #######\n");
  printf("# #Values       = %zu\n", stats->num_vals);
  printf("# Average       = %zu\n", stats->avg);
  printf("# Median        = %zu\n", stats->median);
  printf("# Std dev       = %.2f\n", stats->std_dev);
  printf("# Std dev%%      = %.2f%%\n", stats->std_dev_perc);
  printf("###########################\n");
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x6467(%rip), %rdi      # 0xb840
callq 0x2080
movq (%rbx), %rsi
leaq 0x63e0(%rip), %rdi      # 0xb7c8
xorl %eax, %eax
callq 0x2100
movq 0x10(%rbx), %rsi
leaq 0x63e5(%rip), %rdi      # 0xb7df
xorl %eax, %eax
callq 0x2100
movq 0x8(%rbx), %rsi
leaq 0x63ea(%rip), %rdi      # 0xb7f6
xorl %eax, %eax
callq 0x2100
movsd 0x18(%rbx), %xmm0
leaq 0x63ee(%rip), %rdi      # 0xb80d
movb $0x1, %al
callq 0x2100
movsd 0x20(%rbx), %xmm0
leaq 0x63f3(%rip), %rdi      # 0xb825
movb $0x1, %al
callq 0x2100
leaq 0x6623(%rip), %rdi      # 0xba63
popq %rbx
jmp 0x2080
nop
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/helper.c
// Function: get_num_hw_ctx
int
get_num_hw_ctx()
{
#ifdef __x86_64__
  cpu_set_t mask;
  CPU_ZERO(&mask);
#endif

  int nc = 0;
  while (1)
    {
      if (!mctop_set_cpu(NULL, nc))
  	{
  	  break;
  	}
#ifdef __x86_64__
      CPU_SET(nc, &mask);
#endif
      nc++;
    }

#ifdef __x86_64__
  sched_setaffinity(0, sizeof(cpu_set_t), &mask);
#elif defined(__sparc)
  processor_bind(P_LWPID, P_MYID, PBIND_NONE, NULL);
#endif
  
  return nc;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x88, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
xorl %ebx, %ebx
pushq $0x1
popq %r14
xorl %edi, %edi
movl %ebx, %esi
callq 0x841d
testl %eax, %eax
je 0x54b0
cmpq $0x3ff, %rbx            # imm = 0x3FF
ja 0x54ab
movq %r14, %rax
movl %ebx, %ecx
shlq %cl, %rax
movq %rbx, %rcx
shrq $0x6, %rcx
orq %rax, (%rsp,%rcx,8)
incq %rbx
jmp 0x5482
movq %rsp, %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x2130
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/helper.c
// Function: ll_random_traverse
ticks
ll_random_traverse(volatile uint64_t* list, const size_t reps)
{
  volatile ticks __s = getticks();
  for (size_t r = 0; r < reps; r++)
    {
      list = (uint64_t*) *list;
    }
  volatile ticks __e = getticks();
  assert(list != NULL);
  return (__e - __s) / reps;
}

// Assembly:
subq $0x18, %rsp
rdtsc
movl %eax, %eax
shlq $0x20, %rdx
orq %rax, %rdx
movq %rdx, 0x10(%rsp)
movq %rsi, %rax
subq $0x1, %rax
jb 0x5513
movq (%rdi), %rdi
jmp 0x5508
rdtsc
movl %eax, %eax
shlq $0x20, %rdx
orq %rax, %rdx
movq %rdx, 0x8(%rsp)
testq %rdi, %rdi
je 0x553c
movq 0x8(%rsp), %rax
subq 0x10(%rsp), %rax
xorl %edx, %edx
divq %rsi
addq $0x18, %rsp
retq
leaq 0x6325(%rip), %rdi      # 0xb868
leaq 0x632b(%rip), %rsi      # 0xb875
leaq 0x6331(%rip), %rcx      # 0xb882
pushq $0x41
popq %rdx
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/helper.c
// Function: ll_random_create
void
ll_random_create(volatile uint64_t* mem, const size_t size)
{
  const size_t size_cl = size / CACHE_LINE_SIZE;
  const size_t per_cl = CACHE_LINE_SIZE / sizeof(uint64_t);
  uint8_t* used = calloc_assert(size_cl, sizeof(uint8_t));
  unsigned long* seeds = seeds_create();
  seeds[0] = 0x0123456789ABCDLL;
  seeds[1] = 0xA023457689BAC0LL;
  seeds[2] = 0xB0245736F9BAC1LL;

  size_t idx = 0;
  size_t used_num = 0;
  while (used_num < size_cl - 1)
    {
      used[idx] = 1;
      used_num++;

      size_t nxt;
      do
	{
	  nxt = (marsaglia_rand(seeds) % size_cl);
	}
      while (used[nxt]);

      size_t nxt_8 = (nxt * per_cl);
      size_t idx_8 = (idx * per_cl);
      mem[idx_8] = (uint64_t) (mem + nxt_8);
      idx = nxt;
    }

  mem[idx * per_cl] = (volatile uint64_t) mem;
  /* mem[idx * per_cl] = 0; */

  free(seeds);
  free(used);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
shrq $0x6, %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2150
testq %rax, %rax
je 0x5615
movq %rax, %rdi
leaq -0x1(%r14), %rsi
movabsq $0x123456789abcd, %r10  # imm = 0x123456789ABCD
movabsq $0xa023457689bac0, %r8  # imm = 0xA023457689BAC0
movabsq $0xb0245736f9bac1, %rcx # imm = 0xB0245736F9BAC1
xorl %r9d, %r9d
xorl %r11d, %r11d
cmpq %rsi, %r9
je 0x5601
movb $0x1, (%rdi,%r11)
movq %r10, %rax
shlq $0x10, %rax
xorq %r10, %rax
movq %r8, %r10
movq %rcx, %r8
movq %rax, %rcx
shrq $0x5, %rcx
xorq %rax, %rcx
movq %r10, %rax
xorq %r8, %rax
xorq %rcx, %rax
addq %rcx, %rcx
xorq %rax, %rcx
movq %rcx, %rax
xorl %edx, %edx
divq %r14
cmpb $0x0, (%rdi,%rdx)
jne 0x55b0
incq %r9
movq %rdx, %rax
shlq $0x6, %rax
addq %rbx, %rax
shlq $0x6, %r11
movq %rax, (%rbx,%r11)
movq %rdx, %r11
jmp 0x55a6
shlq $0x6, %r11
movq %rbx, (%rbx,%r11)
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2030
leaq 0x6d2c(%rip), %rdi      # 0xc348
leaq 0x54dc(%rip), %rsi      # 0xaaff
leaq 0x550a(%rip), %rcx      # 0xab34
pushq $0x69
popq %rdx
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/helper.c
// Function: dvfs_scale_up
int
dvfs_scale_up(const size_t n_reps, const double ratio, double* dur)
{
  const double is_dvfs_ratio = 0.9;
  const uint max_tries = 16;
  uint tries = max_tries;

  clock_t s = clock();
  ticks times[2];
  times[0] = spin_time(n_reps);
  times[1] = spin_time(n_reps);
  ticks prev = times[1], last = prev;
  if (times[1] < (ratio * times[0]))
    {
      ticks cmp = prev;
      do
	{
	  cmp = prev;
	  last = spin_time(n_reps);
	  prev = last;
	}
      while (tries-- > 0 && last < (ratio * cmp));
    }
  clock_t e = clock();

  if (dur != NULL)
    {
      *dur = 1000.0 * (e - s) / (double) CLOCKS_PER_SEC;
    }
  return (last < (is_dvfs_ratio * times[0]));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movsd %xmm0, 0x8(%rsp)
movq %rdi, %r15
callq 0x20d0
movq %rax, %r14
movq %r15, %rdi
callq 0x5632
movq %rax, %r13
movq %r15, %rdi
callq 0x5632
movq %rax, %r12
movq %rax, %xmm0
movq 0x4987(%rip), %xmm2     # 0xa050
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x498b(%rip), %xmm3     # 0xa060
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movq %r13, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movapd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
mulsd 0x8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5779
pushq $-0x11
popq %rbp
movq %r15, %rdi
callq 0x5632
movq %rax, %r13
incl %ebp
je 0x577c
movq %r13, %xmm0
movq 0x491d(%rip), %xmm2     # 0xa050
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x4921(%rip), %xmm3     # 0xa060
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movq %r12, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd 0x8(%rsp), %xmm2
ucomisd %xmm1, %xmm2
movq %r13, %r12
ja 0x5717
jmp 0x577c
movq %r12, %r13
callq 0x20d0
testq %rbx, %rbx
je 0x57a2
subq %r14, %rax
cvtsi2sd %rax, %xmm0
mulsd 0x60ca(%rip), %xmm0     # 0xb860
divsd 0x487a(%rip), %xmm0     # 0xa018
movsd %xmm0, (%rbx)
movq %r13, %xmm0
punpckldq 0x48a1(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x48a9(%rip), %xmm0     # 0xa060
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movapd 0x10(%rsp), %xmm2
mulsd 0x485b(%rip), %xmm2     # 0xa028
addsd %xmm0, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm2
seta %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/barrier.c
// Function: barrier2_create
barrier2_t*
barrier2_create()
{
  barrier2_t* b = (barrier2_t*) malloc(sizeof(barrier2_t));
  assert(b);
  for (int i = 0; i < BARRIER2_NUM_BARRIER; i++)
    {
      b->val[i] = 0;
      b->eval[i] = 0;
    }
  return b;
}

// Assembly:
pushq %rax
movl $0x80, %edi
callq 0x21d0
testq %rax, %rax
je 0x5815
pushq $0x10
popq %rcx
xorl %edx, %edx
cmpq $0x20, %rcx
je 0x5813
movl %edx, -0x40(%rax,%rcx,4)
movl %edx, (%rax,%rcx,4)
incq %rcx
jmp 0x5801
popq %rcx
retq
leaq 0x60a5(%rip), %rdi      # 0xb8c1
leaq 0x60a0(%rip), %rsi      # 0xb8c3
leaq 0x60a7(%rip), %rcx      # 0xb8d1
pushq $0x7
popq %rdx
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/cdf.c
// Function: cdf_cluster_get_min_latency
uint64_t
cdf_cluster_get_min_latency(cdf_cluster_t* cc)
{
  uint64_t min_lat = cc->clusters[0].median;
  for (int i = 1; i < cc->n_clusters; i++)
    {
      if (min_lat == 0 || (cc->clusters[i].median < min_lat))
	{
	  min_lat = cc->clusters[i].median;
	}
    }
  return min_lat;
}

// Assembly:
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x20(%rdx), %rax
addq $0x48, %rdx
pushq $0x1
popq %rsi
cmpq %rsi, %rcx
jbe 0x5d55
movq (%rdx), %rdi
cmpq %rax, %rdi
movq %rax, %r8
cmovbq %rdi, %r8
testq %rax, %rax
cmoveq %rdi, %r8
incq %rsi
addq $0x28, %rdx
movq %r8, %rax
jmp 0x5d30
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/cdf.c
// Function: cdf_cluster_print
void
cdf_cluster_print(cdf_cluster_t* cc)
{
  printf("## CDF Clusters ##############################################\n");
  for (int i = 0; i < cc->n_clusters; i++)
    {
      printf("#### #%-3d : size %-5zu / range %-5zu - %-5zu / median: %-5zu #\n",
	     cc->clusters[i].idx, 
	     cc->clusters[i].size, 
	     cc->clusters[i].val_min, 
	     cc->clusters[i].val_max, 
	     cc->clusters[i].median);
    }
  printf("##############################################################\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x5c80(%rip), %rdi      # 0xba40
callq 0x2080
pushq $0x20
popq %r15
leaq 0x5bde(%rip), %r14      # 0xb9ae
xorl %r12d, %r12d
cmpq %r12, (%rbx)
jbe 0x5e07
movq 0x8(%rbx), %rax
movl -0x20(%rax,%r15), %esi
movq -0x18(%rax,%r15), %rdx
movq -0x10(%rax,%r15), %rcx
movq -0x8(%rax,%r15), %r8
movq (%rax,%r15), %r9
movq %r14, %rdi
xorl %eax, %eax
callq 0x2100
incq %r12
addq $0x28, %r15
jmp 0x5dd3
leaq 0x5929(%rip), %rdi      # 0xb737
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2080
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/cdf.c
// Function: cdf_cluster_value_to_cluster_median
inline uint64_t
cdf_cluster_value_to_cluster_median(cdf_cluster_t* cc, const uint64_t val)
{
  for (int i = 0; i < cc->n_clusters; i++)
    {
      if (val >= cc->clusters[i].val_min && val <= cc->clusters[i].val_max)
	{
	  return cc->clusters[i].median;
	}
    }

  fprintf(stderr, "[ERROR] Value %zu does not belong to cdf_cluster\n", val);
  return 0;
}

// Assembly:
pushq %rbx
movq %rsi, %rdx
movq (%rdi), %rcx
pushq $0x20
popq %rax
subq $0x1, %rcx
jb 0x5e4f
movq 0x8(%rdi), %rsi
cmpq %rdx, -0x10(%rsi,%rax)
ja 0x5e40
cmpq %rdx, -0x8(%rsi,%rax)
jae 0x5e46
addq $0x28, %rax
jmp 0x5e28
movq (%rsi,%rax), %rbx
movq %rbx, %rax
popq %rbx
retq
movq 0xa19a(%rip), %rax      # 0xfff0
movq (%rax), %rdi
leaq 0x5b8f(%rip), %rsi      # 0xb9ef
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2170
jmp 0x5e4a
nop
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_create
darray_t*
darray_create()
{
  darray_t* da = malloc_assert(sizeof(darray_t));
  da->n_elems = 0;
  da->size = DARRAY_MIN_SIZE;
  da->array = malloc_assert(DARRAY_MIN_SIZE * sizeof(uintptr_t));
  return da;
}

// Assembly:
pushq %rbx
pushq $0x18
popq %rdi
callq 0x5e95
movq %rax, %rbx
andq $0x0, (%rax)
movq $0x8, 0x8(%rax)
pushq $0x40
popq %rdi
callq 0x5e95
movq %rax, 0x10(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_add_double
void
darray_add_double(darray_t* da, double elem)
{
  DARRAY_RESIZE(da);
  uintptr_t* ptr = da->array + da->n_elems++;
  double* ptrd = (double*) ptr;
  *ptrd = elem;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rsi
cmpq 0x8(%rdi), %rsi
je 0x5fca
movq 0x10(%rbx), %rax
leaq 0x1(%rsi), %rcx
movq %rcx, (%rbx)
movsd %xmm0, (%rax,%rsi,8)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq (%rsi,%rsi), %r14
movq 0x10(%rbx), %rdi
shlq $0x4, %rsi
movsd %xmm0, (%rsp)
callq 0x5f78
movsd (%rsp), %xmm0
movq %rax, 0x10(%rbx)
movq %r14, 0x8(%rbx)
movq (%rbx), %rsi
jmp 0x5fb6
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_exists
inline int			
darray_exists(darray_t* da, uintptr_t elem)
{
  for (int i = 0; i < da->n_elems; i++)
    {
      if (unlikely(elem == da->array[i]))
	{
	  return 1;
	}
    }
  return 0;
}

// Assembly:
movq (%rdi), %rcx
xorl %eax, %eax
movq %rax, %rdx
cmpq %rax, %rcx
je 0x603a
movq 0x10(%rdi), %r8
leaq 0x1(%rdx), %rax
cmpq %rsi, (%r8,%rdx,8)
jne 0x6024
xorl %eax, %eax
cmpq %rdx, %rcx
seta %al
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_remove
int
darray_remove(darray_t* da, uintptr_t elem)
{
  for (int i = 0; i < da->n_elems; i++)
    {
      if (unlikely(elem == da->array[i]))
	{
	  da->n_elems--;
	  for (int j = i; j < da->n_elems; j++)
	    {
	      da->array[j] = da->array[j + 1];
	    }
	  return 1;
	}
    }
  return 0;
}

// Assembly:
movq (%rdi), %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x60e5
movq 0x10(%rdi), %rax
cmpq %rsi, (%rax,%rdx,8)
je 0x60c5
incq %rdx
jmp 0x60b1
leaq -0x1(%rcx), %r8
movq %r8, (%rdi)
movq %rdx, %rsi
cmpq %rsi, %r8
jbe 0x60e5
movq 0x8(%rax,%rsi,8), %r8
movq %r8, (%rax,%rsi,8)
incq %rsi
movq (%rdi), %r8
jmp 0x60cf
xorl %eax, %eax
cmpq %rdx, %rcx
seta %al
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_remove_all
uint
darray_remove_all(darray_t* da, darray_t* from)
{
  size_t n_removed = 0;
  DARRAY_FOR_EACH(from, i)
    {
      uintptr_t elem = DARRAY_GET_N(from, i);
      n_removed += darray_remove(da, elem);
    }

  return n_removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
xorl %ebp, %ebp
cmpq %r15, (%rbx)
jbe 0x611c
movq 0x10(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x60ac
addl %eax, %ebp
incq %r15
jmp 0x6100
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_pop
int
darray_pop(darray_t* da, uintptr_t* elem)
{
  if (unlikely(da->n_elems == 0))
    {
      return 0;
    }

  *elem = da->array[0];
  da->n_elems--;
  for (int i = 0; i < da->n_elems; i++)
    {
      da->array[i] = da->array[i + 1];
    }
  return 1;
}

// Assembly:
cmpq $0x0, (%rdi)
je 0x615d
movq 0x10(%rdi), %rcx
movq (%rcx), %rax
movq %rax, (%rsi)
movq (%rdi), %rdx
decq %rdx
movq %rdx, (%rdi)
xorl %esi, %esi
pushq $0x1
popq %rax
cmpq %rsi, %rdx
jbe 0x615f
movq 0x8(%rcx,%rsi,8), %rdx
movq %rdx, (%rcx,%rsi,8)
incq %rsi
movq (%rdi), %rdx
jmp 0x6147
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/darray.c
// Function: darray_exists_pos
inline int
darray_exists_pos(darray_t* da, uintptr_t elem, uint* pos)
{
  for (int i = 0; i < da->n_elems; i++)
    {
      if (unlikely(elem == da->array[i]))
	{
	  *pos = i;
	  return 1;
	}
    }
  return 0;
}

// Assembly:
movq (%rdi), %rcx
xorl %r8d, %r8d
cmpq %r8, %rcx
je 0x6194
movq 0x10(%rdi), %rax
cmpq %rsi, (%rax,%r8,8)
je 0x6191
incq %r8
jmp 0x617d
movl %r8d, (%rdx)
xorl %eax, %eax
cmpq %r8, %rcx
seta %al
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_infer_clustering
cdf_cluster_t*
mctop_infer_clustering(uint64_t** lat_table_norm, const size_t N)
{
  darray_t* clusters = darray_create();
  for (int x = 0; x < N; x++)
    {
      for (int y = 0; y < N; y++)
	{
	  darray_add_uniq(clusters, lat_table_norm[x][y]);
	}
    }

  int n_clusters = darray_get_num_elems(clusters);
  darray_sort(clusters);
  //printf("## Detected %2d clusters: ", n_clusters);
  /* darray_print(clusters); */

  cdf_cluster_t* cc = cdf_cluster_create_empty(n_clusters);
  cc->n_clusters = n_clusters;
  for (int c = 0; c < n_clusters; c++)
    {
      cc->clusters[c].idx = c;
      cc->clusters[c].median = darray_get_elem_n(clusters, c);
    }

  darray_free(clusters);
  return cc;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x5e6c
movq %rax, %rbx
cmpq %r14, %r12
je 0x6726
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x6721
movq (%r15,%r12,8), %rax
movq (%rax,%r13,8), %rsi
movq %rbx, %rdi
callq 0x5ff2
incq %r13
jmp 0x6707
incq %r12
jmp 0x66ff
movq %rbx, %rdi
callq 0x619d
movq %rax, %r15
movq %rbx, %rdi
callq 0x61cf
movl %r15d, %edi
callq 0x5d56
movq %rax, %r14
movslq %r15d, %r12
movq %r12, (%rax)
xorl %r13d, %r13d
testl %r12d, %r12d
cmovlel %r13d, %r12d
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x6781
movq 0x8(%r14), %rax
movl %r15d, (%rax,%r13)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x61a1
movq 0x8(%r14), %rcx
movq %rax, 0x20(%rcx,%r13)
incq %r15
addq $0x28, %r13
jmp 0x6757
movq %rbx, %rdi
callq 0x5f16
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_create
mctop_t*
mctop_create(uint n_sockets, cdf_cluster_t* cc, uint n_hwcs, const int is_smt)
{
  mctop_t* topo = calloc_assert(1, sizeof(mctop_t));
  topo->is_smt = is_smt;
  topo->has_mem = NO_MEMORY;

  topo->n_sockets = n_sockets;
  topo->sockets = calloc_assert(topo->n_sockets, sizeof(socket_t));

  topo->n_levels = cc->n_clusters;
  topo->latencies = malloc_assert(topo->n_levels * sizeof(uint));
  for (int i = 0; i < topo->n_levels; i++)
    {
      topo->latencies[i] = cc->clusters[i].median;
    }

  topo->n_hwcs = n_hwcs;
  topo->hwcs = calloc_assert(topo->n_hwcs, sizeof(hw_context_t));
  for (int i = 0; i < topo->n_hwcs; i++)
    {
      topo->hwcs[i].id = i;
      topo->hwcs[i].phy_id = i;
      topo->hwcs[i].level = 0;      
      topo->hwcs[i].type = is_smt ? HW_CONTEXT : CORE;
    }
  
  return topo;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %r12d
pushq $0x1
popq %rdi
movl $0x88, %esi
callq 0x785e
movq %rax, %rbx
movl %ebp, 0x28(%rax)
andl $0x0, 0x30(%rax)
movl %r12d, 0x18(%rax)
movl %r12d, %edi
movl $0xa8, %esi
callq 0x785e
movq %rax, 0x20(%rbx)
movq (%r15), %rax
movl %eax, (%rbx)
movl %eax, %r12d
leaq (,%r12,4), %rdi
callq 0x6856
movq %rax, 0x8(%rbx)
imulq $0xa, %r12, %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x680d
movq 0x8(%r15), %rsi
movl 0x20(%rsi,%rdx,4), %esi
movl %esi, (%rax)
addq $0xa, %rdx
addq $0x4, %rax
jmp 0x67f4
movl %r14d, 0x10(%rbx)
movl %r14d, %r14d
pushq $0x30
popq %rsi
movq %r14, %rdi
callq 0x785e
movq %rax, 0x40(%rbx)
xorl %ecx, %ecx
testl %ebp, %ebp
sete %cl
addq $0xc, %rax
xorl %edx, %edx
cmpq %rdx, %r14
je 0x684a
movl %edx, -0xc(%rax)
movl %edx, (%rax)
andl $0x0, -0x8(%rax)
movl %ecx, -0x4(%rax)
incq %rdx
addq $0x30, %rax
jmp 0x6830
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_hwc_group_create
hwc_group_t*
mctop_hwc_group_create(mctop_t* topo, uint n_hwcs, darray_t* hwc_ids, uint seq_id, uint lvl, uint lat, const int has_smt)
{
  hwc_group_t* group = calloc_assert(1, sizeof(hwc_group_t));
  group->id = mctop_create_id(seq_id, lvl);
  group->level = lvl;
  group->type = (has_smt && lvl == 1) ? CORE : HWC_GROUP;
  group->latency = lat;
  group->n_hwcs = n_hwcs;
  group->hwcs = (hw_context_t**) malloc_assert(group->n_hwcs * sizeof(hw_context_t*));
  group->topo = topo;

  darray_iter_t iter;
  darray_iter_init(&iter, hwc_ids);
  size_t elem, i = 0;
  while (darray_iter_next(&iter, &elem))
    {
      hw_context_t* hwc = mctop_get_hwc_n(topo, elem);
      group->hwcs[i++] = hwc;
      if (hwc->parent == NULL)
	{
	  hwc->parent = group;
	}
      else
	{
	  hwc_group_t* cur = hwc->parent;
	  while (cur->parent != NULL)
	    {
	      cur = cur->parent;
	    }
	  if (cur != group)
	    {
	      cur->parent = group;
	    }
	}
    }

  return group;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %ebp
movl %r8d, %r15d
movl %ecx, %r13d
movq %rdx, 0x8(%rsp)
movl %esi, %r12d
movq %rdi, %rbx
pushq $0x1
popq %rdi
movl $0xa8, %esi
callq 0x785e
movq %rax, %r14
imull $0x2710, %r15d, %eax    # imm = 0x2710
addl %r13d, %eax
movl %eax, (%r14)
movl %r15d, 0x4(%r14)
cmpl $0x0, 0x60(%rsp)
setne %al
cmpl $0x1, %r15d
sete %cl
andb %al, %cl
movzbl %cl, %eax
pushq $0x2
popq %rcx
subl %eax, %ecx
movl %ecx, 0x8(%r14)
movl %ebp, 0xc(%r14)
movl %r12d, 0x28(%r14)
movl %r12d, %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x30(%r14)
movq %rbx, 0x48(%r14)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x620e
xorl %r13d, %r13d
leaq 0x10(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x6217
testl %eax, %eax
je 0x696d
movl 0x10(%rsp), %ecx
movq 0x40(%rbx), %rax
imulq $0x30, %rcx, %rdx
leaq (%rax,%rdx), %rcx
movq 0x30(%r14), %rsi
movq %rcx, (%rsi,%r13,8)
incq %r13
movq 0x18(%rax,%rdx), %rcx
testq %rcx, %rcx
je 0x6961
movq %rcx, %rax
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
jne 0x694a
cmpq %r14, %rax
je 0x6916
addq $0x18, %rax
jmp 0x6968
addq %rdx, %rax
addq $0x18, %rax
movq %r14, (%rax)
jmp 0x6916
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_socket_create
socket_t*
mctop_socket_create(mctop_t* topo, 
		    uint n_hwcs, 
		    darray_t* hwc_ids, 
		    uint seq_id,
		    uint lvl, 
		    uint latency, 
		    uint64_t** mem_lat_table, 
		    const int is_smt)
{
  socket_t* socket = topo->sockets + seq_id;
  socket->id = mctop_create_id(seq_id, lvl);
  socket->level = lvl;
  socket->type = SOCKET;
  socket->latency = latency;
  socket->n_hwcs = n_hwcs;
  socket->hwcs = (hw_context_t**) malloc_assert(socket->n_hwcs * sizeof(hw_context_t*));
  socket->n_nodes = topo->n_sockets;
  socket->topo = topo;

  /* uint hwc_seq_id = seq_id * socket->n_hwcs; */

  darray_iter_t iter;
  darray_iter_init(&iter, hwc_ids);

  darray_t* pgroups = darray_create();
  size_t elem, i = 0;
  while (darray_iter_next(&iter, &elem))
    {
      hw_context_t* hwc = mctop_get_hwc_n(topo, elem);
      /* hwc->id = hwc_seq_id++; */
      socket->hwcs[i++] = hwc;
      hwc->socket = socket;

      hwc_group_t* cur = hwc->parent;
      while (cur && cur->parent != NULL && cur->parent != socket)
	{
	  cur = cur->parent;
	}
      if (cur != NULL)
	{
	  cur->parent = socket;
	  darray_add_uniq(pgroups, (uintptr_t) cur);
	}
      else
	{
	  hwc->parent = socket;
	}
    }
  darray_free(pgroups);


  return socket;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rdi, %r14
movq 0x20(%rdi), %r15
movl %ecx, %eax
imulq $0xa8, %rax, %r13
leaq (%r15,%r13), %rbx
imull $0x2710, %r8d, %eax     # imm = 0x2710
addl %ecx, %eax
movl %eax, (%r15,%r13)
movl %r8d, 0x4(%r15,%r13)
movl $0x3, 0x8(%r15,%r13)
movl %r9d, 0xc(%r15,%r13)
movl %esi, 0x28(%r15,%r13)
movl %esi, %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x30(%r15,%r13)
movl 0x18(%r14), %eax
movl %eax, 0x70(%r15,%r13)
movq %r14, 0x48(%r15,%r13)
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x620e
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x5e6c
movq %rax, %r12
movq %rsp, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x6217
testl %eax, %eax
je 0x6a63
movl (%rsp), %eax
movq 0x40(%r14), %rcx
imulq $0x30, %rax, %rdx
leaq (%rcx,%rdx), %rax
movq 0x30(%rbx), %rsi
movq %rax, (%rsi,%rbp,8)
incq %rbp
movq %rbx, 0x10(%rcx,%rdx)
movq 0x18(%rcx,%rdx), %rcx
testq %rcx, %rcx
je 0x6a5d
movq %rcx, %rsi
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x6a4f
cmpq %rbx, %rcx
jne 0x6a39
movq %rbx, 0x18(%rsi)
movq %r12, %rdi
callq 0x5ff2
jmp 0x6a06
movq %rbx, 0x18(%rax)
jmp 0x6a06
movq %r12, %rdi
callq 0x5f16
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_siblings_create
void
mctop_siblings_create(mctop_t* topo, uint socket_x_id, uint socket_y_id, uint* seq_id, uint lvl, uint latency)
{
  socket_t* socket_x = mctop_get_socket(topo, socket_x_id);
  socket_t* socket_y = mctop_get_socket(topo, socket_y_id);

  socket_x->siblings = realloc_assert(socket_x->siblings, (socket_x->n_siblings + 1) * sizeof(sibling_t*));
  socket_y->siblings = realloc_assert(socket_y->siblings, (socket_y->n_siblings + 1) * sizeof(sibling_t*));

  sibling_t* sibling = mctop_sibling_create((*seq_id)++, lvl, latency, socket_x, socket_y);
  socket_x->siblings[socket_x->n_siblings++] = sibling;
  socket_y->siblings[socket_y->n_siblings++] = sibling;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebp
movl %r8d, %r15d
movq %rcx, %r12
movl %edx, %ebx
movq %rdi, %r13
callq 0x7ed0
movq %rax, %r14
movq %r13, %rdi
movl %ebx, %esi
callq 0x7ed0
movq %rax, %rbx
movq 0x58(%r14), %rdi
movl 0x50(%r14), %esi
incl %esi
shlq $0x3, %rsi
callq 0x78cd
movq %rax, 0x58(%r14)
movq 0x58(%rbx), %rdi
movl 0x50(%rbx), %esi
incl %esi
shlq $0x3, %rsi
callq 0x78cd
movq %rax, 0x58(%rbx)
movl (%r12), %edi
leal 0x1(%rdi), %eax
movl %eax, (%r12)
movl %r15d, %esi
movl %ebp, %edx
movq %r14, %rcx
movq %rbx, %r8
callq 0x7888
movq 0x58(%r14), %rcx
movl 0x50(%r14), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x50(%r14)
movq %rax, (%rcx,%rdx,8)
movq 0x58(%rbx), %rcx
movl 0x50(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x50(%rbx)
movq %rax, (%rcx,%rdx,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_fix_n_hwcs_per_core_smt
void
mctop_fix_n_hwcs_per_core_smt(mctop_t* topo)
{
  if (topo->is_smt)
    {
      hwc_group_t* gs = mctop_get_first_gs_at_lvl(topo, 1);
      assert(gs->type == CORE);
      topo->n_hwcs_per_core = gs->n_children;
    }
  else
    {
      topo->n_hwcs_per_core = 1;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x28(%rdi)
je 0x6f14
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x7efa
cmpl $0x1, 0x8(%rax)
jne 0x6f1c
movl 0x3c(%rax), %eax
jmp 0x6f17
pushq $0x1
popq %rax
movl %eax, 0x2c(%rbx)
popq %rbx
retq
leaq 0x4eca(%rip), %rdi      # 0xbded
leaq 0x4ed4(%rip), %rsi      # 0xbdfe
leaq 0x4ee2(%rip), %rcx      # 0xbe13
movl $0x353, %edx            # imm = 0x353
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_mem_latencies_add
void
mctop_mem_latencies_add(mctop_t* topo, uint64_t** mem_lat_table)
{
  /* mem. latencies */
  if (mem_lat_table != NULL)
    {
      topo->has_mem = topo->has_mem | LATENCY;
      topo->node_to_socket = calloc_assert(topo->n_sockets, sizeof(uint));

      for (int s = 0; s < topo->n_sockets; s++)
	{
	  socket_t* socket = &topo->sockets[s];
	  uint hwc_use_id = 0;
	  uint min_avg = -1;
	  for (int i = 0; i < socket->n_hwcs; i++)
	    {
	      uint hwc_id = socket->hwcs[i]->id;
	      uint avg = 0;
	      for (int s = 0; s < topo->n_sockets; s++)
		{
		  avg += mem_lat_table[hwc_id][s];
		}
	      avg /= topo->n_sockets;
	      if (avg > 0 && avg < min_avg)
		{
		  min_avg = avg;
		  hwc_use_id = hwc_id;
		}
	    }

	  uint64_t* lats = mem_lat_table[hwc_use_id];
	  socket->mem_latencies = malloc_assert(topo->n_sockets * sizeof(uint));
	  uint min_lat = -1, local_node = 0;
	  for (int n = 0; n < topo->n_sockets; n++)
	    {
	      if (lats[n] < min_lat)
		{
		  local_node = n;
		  min_lat = lats[n];
		}
	      socket->mem_latencies[n] = lats[n];
	    }
	  socket->local_node = local_node;
	  topo->node_to_socket[socket->local_node] = s;
	}
    }
}

// Assembly:
testq %rsi, %rsi
je 0x7041
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
orb $0x1, 0x30(%rdi)
movl 0x18(%rdi), %edi
pushq $0x4
popq %rsi
callq 0x785e
movq %rax, 0x38(%r14)
xorl %r15d, %r15d
pushq $-0x1
popq %rbp
movl 0x18(%r14), %edi
cmpq %rdi, %r15
jae 0x7033
movq 0x20(%r14), %rax
imulq $0xa8, %r15, %rcx
leaq (%rax,%rcx), %r12
movl 0x28(%rax,%rcx), %esi
xorl %r8d, %r8d
xorl %r9d, %r9d
movl %ebp, %r10d
cmpq %rsi, %r8
je 0x6fdd
movq 0x30(%r12), %rax
movq (%rax,%r8,8), %rax
movl (%rax), %r11d
movq (%rbx,%r11,8), %rax
xorl %edx, %edx
xorl %ecx, %ecx
cmpq %rdx, %rdi
je 0x6fbd
addl (%rax,%rdx,8), %ecx
incq %rdx
jmp 0x6fb0
movl %ecx, %eax
xorl %edx, %edx
divl %edi
cmpl %ecx, %edi
setbe %cl
cmpl %r10d, %eax
setb %dl
testb %dl, %cl
cmovnel %r11d, %r9d
cmovnel %eax, %r10d
incq %r8
jmp 0x6f97
movl %r9d, %eax
movq (%rbx,%rax,8), %r13
shlq $0x2, %rdi
callq 0x6856
movq %rax, 0x78(%r12)
movl 0x18(%r14), %ecx
xorl %edx, %edx
movl %ebp, %edi
xorl %esi, %esi
cmpq %rdx, %rcx
je 0x701c
movq (%r13,%rdx,8), %r8
movl %edi, %r9d
cmpq %r9, %r8
cmovbl %r8d, %edi
cmovbl %edx, %esi
movl %r8d, (%rax,%rdx,4)
incq %rdx
jmp 0x6ffc
movl %esi, 0x6c(%r12)
movq 0x38(%r14), %rax
movl %esi, %ecx
movl %r15d, (%rax,%rcx,4)
incq %r15
jmp 0x6f6e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_sibling_create
sibling_t*
mctop_sibling_create(uint seq_id, uint lvl, uint latency, socket_t* left, socket_t* right)
{
  sibling_t* sibling = calloc_assert(1, sizeof(sibling_t));
  sibling->id = mctop_create_id(seq_id, lvl);
  sibling->level = lvl;
  sibling->latency = latency;
  sibling->left = left;
  sibling->right = right;
  return sibling;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %ebp
movl %esi, %r15d
movl %edi, %r12d
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x785e
imull $0x2710, %r15d, %ecx    # imm = 0x2710
addl %r12d, %ecx
movl %ecx, (%rax)
movl %r15d, 0x4(%rax)
movl %ebp, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rbx, 0x18(%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_cache_info_create
mctop_cache_info_t*
mctop_cache_info_create(const uint n_levels)
{
  mctop_cache_info_t* mci = malloc_assert(sizeof(mctop_cache_info_t));
  mci->n_levels = n_levels;
  mci->latencies = calloc_assert(n_levels, sizeof(uint64_t));
  mci->sizes_OS = calloc_assert(n_levels, sizeof(uint64_t));
  mci->sizes_estimated = calloc_assert(n_levels, sizeof(uint64_t));
  return mci;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edi, %ebx
pushq $0x20
popq %rdi
callq 0x6856
movq %rax, %r14
movl %ebx, (%rax)
movl %ebx, %ebx
pushq $0x8
popq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x785e
movq %rax, 0x8(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x785e
movq %rax, 0x10(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x785e
movq %rax, 0x18(%r14)
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_power_measurements_create
double***
mctop_power_measurements_create(const uint n_sockets)
{
  double*** pow_measurements = malloc_assert(MCTOP_POW_TYPE_NUM * sizeof(double**));
  for (uint i = 0; i < MCTOP_POW_TYPE_NUM; i++)
    {
      pow_measurements[i] = malloc_assert((n_sockets + 1) * sizeof(double*));
      for (uint s = 0; s <= n_sockets; s++)
	{
	  pow_measurements[i][s] = malloc_assert(MCTOP_POW_COMP_TYPE_NUM * sizeof(double));
	}
    }
  return pow_measurements;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
pushq $0x30
popq %rdi
callq 0x6856
movq %rax, (%rsp)
leal 0x1(%rbx), %r15d
shlq $0x3, %r15
xorl %ebp, %ebp
pushq $0x28
popq %r12
cmpq $0x6, %rbp
je 0x7d26
movq %r15, %rdi
callq 0x6856
movq %rax, %r13
movq (%rsp), %rax
movq %r13, (%rax,%rbp,8)
xorl %r14d, %r14d
cmpl %ebx, %r14d
ja 0x7d21
movq %r12, %rdi
callq 0x6856
movl %r14d, %ecx
movq %rax, (%r13,%rcx,8)
incl %r14d
jmp 0x7d07
incq %rbp
jmp 0x7ceb
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_power_measurements_free
void
mctop_power_measurements_free(double*** m, const uint n_sockets)
{
  for (uint i = 0; i < MCTOP_POW_TYPE_NUM; i++)
    {
      for (uint s = 0; s <= n_sockets; s++)
	{
	  free(m[i][s]);
	}
      free(m[i]);
    }
  free(m);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
xorl %r14d, %r14d
cmpq $0x6, %r14
je 0x7d75
xorl %r15d, %r15d
movq (%rbx,%r14,8), %rdi
cmpl %ebp, %r15d
ja 0x7d6b
movl %r15d, %eax
movq (%rdi,%rax,8), %rdi
callq 0x2030
incl %r15d
jmp 0x7d51
callq 0x2030
incq %r14
jmp 0x7d48
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_pow_info_add
void
mctop_pow_info_add(mctop_t* topo, double*** pm)
{
  for (int i = 0; i <= topo->n_sockets; i++)
    {
      mctop_pow_info_t* pi = malloc_assert(sizeof(mctop_pow_info_t));
      uint div = 1;
      if (i < topo->n_sockets)
	{
	  topo->sockets[i].pow_info = pi;
	}
      else
	{
	  topo->pow_info = pi;
	  div = topo->n_sockets;
	}
      uint type = 0;
      __copy_doubles(pi->idle, pm[type++][i], MCTOP_POW_COMP_TYPE_NUM, 1);
      __copy_doubles(pi->first_core, pm[type++][i], MCTOP_POW_COMP_TYPE_NUM, div);
      __copy_doubles(pi->second_core, pm[type++][i], MCTOP_POW_COMP_TYPE_NUM, div);
      __copy_doubles(pi->second_hwc_core, pm[type++][i], MCTOP_POW_COMP_TYPE_NUM, div);
      __copy_doubles(pi->all_cores, pm[type++][i], MCTOP_POW_COMP_TYPE_NUM, 1);
      __copy_doubles(pi->all_hwcs, pm[type++][i], MCTOP_POW_COMP_TYPE_NUM, 1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x80(%rdi), %rax
movq %rax, (%rsp)
movl 0x18(%rdi), %r12d
xorl %r13d, %r13d
movl %r12d, %eax
cmpq %rax, %r13
ja 0x7e9b
movl $0x120, %edi            # imm = 0x120
callq 0x6856
movq %rax, %r15
movl 0x18(%r14), %r12d
movq (%rsp), %rax
movl %r12d, %ebp
cmpq %r12, %r13
jae 0x7dea
movq 0x20(%r14), %rax
imulq $0xa8, %r13, %rcx
addq %rcx, %rax
addq $0xa0, %rax
pushq $0x1
popq %rbp
movq %r15, (%rax)
movq (%rbx), %rax
movq (%rax,%r13,8), %rax
xorl %ecx, %ecx
cmpq $0x5, %rcx
je 0x7e0c
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%r15,%rcx,8)
incq %rcx
jmp 0x7df6
leaq 0x30(%r15), %rdi
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rsi
movl %ebp, %edx
callq 0x7eaa
leaq 0x60(%r15), %rdi
movq 0x10(%rbx), %rax
movq (%rax,%r13,8), %rsi
movl %ebp, %edx
callq 0x7eaa
movq %r15, %rdi
addq $0x90, %rdi
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rsi
movl %ebp, %edx
callq 0x7eaa
movq 0x20(%rbx), %rax
movq (%rax,%r13,8), %rax
xorl %ecx, %ecx
cmpq $0x5, %rcx
je 0x7e6f
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0xc0(%r15,%rcx,8)
incq %rcx
jmp 0x7e55
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %rax
xorl %ecx, %ecx
cmpq $0x5, %rcx
je 0x7e93
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0xf0(%r15,%rcx,8)
incq %rcx
jmp 0x7e79
incq %r13
jmp 0x7daa
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_get_first_gs_at_lvl
inline hwc_gs_t*
mctop_get_first_gs_at_lvl(mctop_t* topo, const uint lvl)
{
  hwc_gs_t* cur = mctop_get_first_socket(topo);
  while (cur != NULL && cur->level != lvl)
    {
      cur = cur->children[0];
    }
  return cur;
}

// Assembly:
addq $0x20, %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x7f11
cmpl %esi, 0x4(%rax)
je 0x7f11
movq 0x40(%rax), %rdi
jmp 0x7efe
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_get_first_sibling_lvl
inline sibling_t*
mctop_get_first_sibling_lvl(mctop_t* topo, const uint lvl)
{
  for (int i = 0; i < topo->n_siblings; i++)
    {
      if (topo->siblings[i]->level == lvl)
	{
	  return topo->siblings[i];
	}
    }
  return NULL;
}

// Assembly:
movl 0x48(%rdi), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x7f2d
movq 0x50(%rdi), %rax
movq (%rax,%rdx,8), %rax
incq %rdx
cmpl %esi, 0x4(%rax)
jne 0x7f17
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_get_sibling_with_sockets
sibling_t*
mctop_get_sibling_with_sockets(mctop_t* topo, socket_t* s0, socket_t* s1)
{
  for (int i = 0; i < topo->n_siblings; i++)
    {
      sibling_t* sibling = topo->siblings[i];
      if (mctop_sibling_contains_sockets(sibling, s0, s1))
	{
	  return sibling;
	}
    }

  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl 0x48(%rdi), %r13d
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x7f92
movq 0x50(%r15), %rax
movq (%rax,%rbp,8), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7fa7
incq %rbp
testl %eax, %eax
je 0x7f6e
jmp 0x7f95
xorl %r12d, %r12d
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_get_cache_size_kb
size_t
mctop_get_cache_size_kb(mctop_t* topo, mctop_cache_level_t level)
{
  mctop_cache_info_t* mci = topo->cache;
  if (mci)
    {
      return mci->sizes_OS[level] ? mci->sizes_OS[level] : mci->sizes_estimated[level];
    }
  return 0;
}

// Assembly:
movq 0x58(%rdi), %rcx
testq %rcx, %rcx
je 0x7fe0
movq 0x10(%rcx), %rax
movl %esi, %edx
movq (%rax,%rdx,8), %rax
testq %rax, %rax
je 0x7fe3
retq
xorl %eax, %eax
retq
movq 0x18(%rcx), %rax
movq (%rax,%rdx,8), %rax
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_hwcid_fix_numa_node
int
mctop_hwcid_fix_numa_node(mctop_t* topo, const uint hwcid)
{
#ifdef __x86_64__
  /* printf("# HWID %-3u, SOCKET %-3u, numa_set_preferred(%u)\n", */
  /* 	     hwcid, hwc->socket->id, hwc->socket->local_node); */
  hw_context_t* hwc = &topo->hwcs[hwcid];
  const uint correct_node = hwc->socket->local_node;
  if (unlikely(hwc->local_node_wrong || correct_node != numa_preferred()))
    {
      numa_set_preferred(correct_node);
      return 1;
    }
#endif
  return 0;
}

// Assembly:
pushq %rbx
movq 0x40(%rdi), %rax
movl %esi, %ecx
imulq $0x30, %rcx, %rcx
movq 0x10(%rax,%rcx), %rdx
movl 0x6c(%rdx), %ebx
cmpl $0x0, 0x28(%rax,%rcx)
jne 0x8110
callq 0x22e0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %ebx
jne 0x8110
popq %rbx
retq
movl %ebx, %edi
callq 0x22a0
pushq $0x1
popq %rax
jmp 0x810e
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_hwcid_get_nth_hwc_in_socket
uint
mctop_hwcid_get_nth_hwc_in_socket(mctop_t* topo, const uint hwcid)
{
  socket_t* socket = mctop_hwcid_get_socket(topo, hwcid);
  hw_context_t* hwc_first = mctop_socket_get_first_hwc(socket);
  uint i = 0;
  while (hwc_first && hwc_first->id != hwcid)
    {
      i++;
      hwc_first = hwc_first->next;
    }

  return i;
}

// Assembly:
movq 0x40(%rdi), %rax
movl %esi, %ecx
imulq $0x30, %rcx, %rcx
movq 0x10(%rax,%rcx), %rax
movq 0x30(%rax), %rcx
xorl %eax, %eax
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x8182
cmpl %esi, (%rcx)
je 0x8182
incl %eax
addq $0x20, %rcx
jmp 0x816e
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_hwcid_get_nth_hwc_in_core
uint
mctop_hwcid_get_nth_hwc_in_core(mctop_t* topo, const uint hwcid)
{
  hw_context_t* hwc = &topo->hwcs[hwcid];
  if (hwc->type == CORE)
    {
      return 0;
    }
  hwc_gs_t* core = hwc->parent;
  for (int i = 0; i < core->n_hwcs; i++)
    {
      if (core->hwcs[i]->id == hwc->id)
	{
	  return i;
	}
    }
  assert(0);
}

// Assembly:
pushq %rax
movq 0x40(%rdi), %rcx
movl %esi, %eax
imulq $0x30, %rax, %rdx
xorl %eax, %eax
cmpl $0x1, 0x8(%rcx,%rdx)
jne 0x8199
popq %rcx
retq
addq %rdx, %rcx
movq 0x18(%rcx), %rdx
movl 0x28(%rdx), %esi
xorl %eax, %eax
cmpq %rax, %rsi
je 0x81bd
movq 0x30(%rdx), %rdi
movq (%rdi,%rax,8), %rdi
movl (%rdi), %edi
cmpl (%rcx), %edi
je 0x8197
incq %rax
jmp 0x81a5
leaq 0x2939(%rip), %rdi      # 0xaafd
leaq 0x3d78(%rip), %rsi      # 0xbf43
leaq 0x3d85(%rip), %rcx      # 0xbf57
movl $0x158, %edx            # imm = 0x158
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_hwcid_get_nth_core_in_socket
uint
mctop_hwcid_get_nth_core_in_socket(mctop_t* topo, const uint hwcid)
{
  hwc_gs_t* core = mctop_hwcid_get_core(topo, hwcid);
  hwc_gs_t* core_first = mctop_socket_get_first_gs_core(core->socket);
  uint i = 0;
  while (core_first && core->id != core_first->id)
    {
      i++;
      core_first = core_first->next;
    }

  return i;
}

// Assembly:
pushq %rbx
movq 0x40(%rdi), %rax
movl %esi, %ecx
imulq $0x30, %rcx, %rcx
leaq (%rax,%rcx), %rbx
cmpl $0x1, 0x8(%rax,%rcx)
je 0x81f6
movq 0x18(%rbx), %rbx
movq 0x10(%rbx), %rdi
callq 0x802d
movq %rax, %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x8217
movl (%rbx), %edx
cmpl (%rcx), %edx
je 0x8217
incl %eax
movq 0x20(%rcx), %rcx
jmp 0x8204
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_id_get_hwc_gs
hwc_gs_t*
mctop_id_get_hwc_gs(mctop_t* topo, const uint id)
{
  uint lvl = mctop_id_get_lvl(id);
  if (lvl > topo->n_levels)
    {
      return NULL;
    }
  hwc_gs_t* gs = NULL;
  if (lvl == 0)
    {
      gs = (hwc_gs_t*) &topo->hwcs[id];
    }
  else if (lvl == topo->socket_level)
    {
      gs = (hwc_gs_t*) &topo->sockets[mctop_id_no_lvl(id)];
    }
  else
    {
      hwc_gs_t* _gs = mctop_get_first_gs_at_lvl(topo, lvl);
      while (_gs != NULL)
	{
	  if (unlikely(_gs->id == id))
	    {
	      gs = _gs;
	      break;
	    }
	  _gs = _gs->next;
	}
    }

  return gs;
}

// Assembly:
pushq %rbx
movl %esi, %ebx
movl $0x2710, %ecx           # imm = 0x2710
movl %esi, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %esi
xorl %eax, %eax
cmpl (%rdi), %esi
ja 0x829e
cmpl $0x270f, %ebx           # imm = 0x270F
ja 0x8274
movl %ebx, %eax
imulq $0x30, %rax, %rax
addq 0x40(%rdi), %rax
jmp 0x829e
cmpl 0x14(%rdi), %esi
jne 0x8288
movl %edx, %eax
imulq $0xa8, %rax, %rax
addq 0x20(%rdi), %rax
jmp 0x829e
callq 0x7efa
testq %rax, %rax
je 0x829c
cmpl %ebx, (%rax)
je 0x829e
movq 0x20(%rax), %rax
jmp 0x828d
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop_control.c
// Function: mctop_ids_get_latency
uint
mctop_ids_get_latency(mctop_t* topo, const uint id0, const uint id1)
{
  hwc_gs_t* gs0 = mctop_id_get_hwc_gs(topo, id0);
  hwc_gs_t* gs1 = mctop_id_get_hwc_gs(topo, id1);
  if (gs0 == NULL || gs1 == NULL)
    {
      return 0;
    }

  while (gs0->level < gs1->level)
    {
      gs0 = gs0->parent;
    }
  while (gs1->level < gs0->level)
    {
      gs1 = gs1->parent;
    }

  if (unlikely(gs0->id == gs1->id))
    {
      if (gs0->level == 0)
	{
	  return 0;
	}
      else
	{
	  return gs0->latency;
	}
    }

  while (gs0->type != SOCKET && gs1->type != SOCKET)
    {
      gs0 = gs0->parent;
      gs1 = gs1->parent;
      if (gs0->id == gs1->id)
	{
	  return gs0->latency;
	}
    }


  sibling_t* sibling = mctop_get_sibling_with_sockets(topo, gs0, gs1);
  return sibling->latency;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rdi, %r14
callq 0x824a
movq %rax, %rbx
movq %r14, %rdi
movl %ebp, %esi
callq 0x824a
testq %rbx, %rbx
sete %dl
testq %rax, %rax
sete %sil
xorl %ecx, %ecx
orb %dl, %sil
jne 0x8320
movl 0x4(%rax), %esi
movl 0x4(%rbx), %edx
cmpl %esi, %edx
jae 0x82e6
movq 0x18(%rbx), %rbx
jmp 0x82d2
movq 0x18(%rax), %rax
movl 0x4(%rax), %esi
cmpl %edx, %esi
jb 0x82df
movl (%rbx), %esi
cmpl (%rax), %esi
je 0x8327
cmpl $0x3, 0x8(%rbx)
je 0x830f
cmpl $0x3, 0x8(%rax)
je 0x830f
movq 0x18(%rbx), %rbx
movq 0x18(%rax), %rax
movl (%rbx), %ecx
cmpl (%rax), %ecx
jne 0x82f0
movl 0xc(%rbx), %ecx
jmp 0x8320
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7f54
movl 0x8(%rax), %ecx
movl %ecx, %eax
popq %rbx
popq %r14
popq %rbp
retq
testl %edx, %edx
jne 0x830a
jmp 0x8320