// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl $0x1, %edi
movl $0x88, %esi
callq 0xaf30
movq %rax, -0x20(%rbp)
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x30(%rax)
movl -0x4(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x20(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %edi
movl $0xa8, %esi
callq 0xaf30
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x93f0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x9325
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x92e7
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
movl $0x30, %esi
callq 0xaf30
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x93df
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x28(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x28(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movl -0x18(%rbp), %edx
movl $0x1, %ecx
xorl %eax, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x28(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x9354
movq -0x20(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)