// File: /workspace/github_c_makefile_star2_O1/LPD-EPFL[P]mctop/src/mctop.c
// Function: init_mem
void*
init_mem(void* param)
{
  const int tid = *(int*) param;
  numa_run_on_node(tid);
  node_mem[tid] = numa_alloc_onnode(test_mem_size, tid);
  assert(node_mem[tid] != NULL);
  volatile uint64_t* m = node_mem[tid];
  ll_random_create(m, test_mem_size);
  if (tid == 0 && test_num_sockets > 1)
    {
      ticks t1 = ll_random_traverse(node_mem[!tid], test_mem_reps);
      ticks t2 = ll_random_traverse(node_mem[!tid], test_mem_reps);
      ticks df = abs_sub(t1, t2);
      ticks avg = (t1 + t2) / 2;
      if (df > (0.2 * avg))
	{
	  printf("## Memory measurements inaccurate (try 1: %zu, 2: %zu) \n", t1, t2);

	  volatile uint64_t* m = numa_alloc_onnode(test_mem_size, !tid);
	  assert(m != NULL);
	  ll_random_create(m, test_mem_size);
	  ticks t1 = ll_random_traverse(node_mem[!tid], test_mem_reps);
	  numa_free((void*) m, test_mem_size);

	  m = numa_alloc_onnode(test_mem_size, !tid);
	  assert(m != NULL);
	  ll_random_create(m, test_mem_size);
	  ticks t2 = ll_random_traverse(node_mem[!tid], test_mem_reps);
	  numa_free((void*) m, test_mem_size);

	  ticks df = abs_sub(t1, t2);
	  ticks avg = (t1 + t2) / 2;
	  if (df < (0.2 * avg))
	    {
	      printf("## Will use on-demand memory allocation (try 1: %zu, 2: %zu) \n", t1, t2);
	      test_mem_on_demand = 1;
	    }
	}
    }
  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movslq (%rdi), %rbx
movl %ebx, %edi
callq 0x2220
movl $0x20000000, %edi       # imm = 0x20000000
movl %ebx, %esi
callq 0x21f0
movq 0xdee6(%rip), %rcx      # 0x112c8
movq %rax, (%rcx,%rbx,8)
movq 0xdedb(%rip), %rax      # 0x112c8
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x35c3
movl $0x20000000, %esi       # imm = 0x20000000
callq 0x5cac
testl %ebx, %ebx
jne 0x35b5
cmpl $0x2, 0xde15(%rip)      # 0x11228
jl 0x35b5
movq 0xdea8(%rip), %rax      # 0x112c8
movq 0x8(%rax), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x5c40
movq %rax, %rbx
movq 0xde90(%rip), %rax      # 0x112c8
movq 0x8(%rax), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x5c40
movq %rax, %rcx
subq %rbx, %rcx
negq %rcx
movq %rax, %rdx
subq %rbx, %rdx
cmovbq %rcx, %rdx
leaq (%rax,%rbx), %rcx
movq %rdx, %xmm0
punpckldq 0x7be6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
shrq %rcx
subpd 0x7beb(%rip), %xmm0     # 0xb060
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x7b8f(%rip), %xmm0     # 0xb020
ucomisd %xmm0, %xmm1
jbe 0x35b5
leaq 0x7dcc(%rip), %rdi      # 0xb26e
movq %rbx, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2100
movl $0x20000000, %edi       # imm = 0x20000000
movl $0x1, %esi
callq 0x21f0
testq %rax, %rax
je 0x35e2
movq %rax, %r14
movl $0x20000000, %esi       # imm = 0x20000000
movq %rax, %rdi
callq 0x5cac
movq 0xddea(%rip), %rax      # 0x112c8
movq 0x8(%rax), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x5c40
movq %rax, %rbx
movl $0x20000000, %esi       # imm = 0x20000000
movq %r14, %rdi
callq 0x20c0
movl $0x20000000, %edi       # imm = 0x20000000
movl $0x1, %esi
callq 0x21f0
testq %rax, %rax
je 0x3601
movq %rax, %r15
movl $0x20000000, %esi       # imm = 0x20000000
movq %rax, %rdi
callq 0x5cac
movq 0xdd9d(%rip), %rax      # 0x112c8
movq 0x8(%rax), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x5c40
movq %rax, %r14
subq %rbx, %rax
negq %rax
movq %r14, %r12
subq %rbx, %r12
cmovbq %rax, %r12
movl $0x20000000, %esi       # imm = 0x20000000
movq %r15, %rdi
callq 0x20c0
leaq (%r14,%rbx), %rax
movq %r12, %xmm0
punpckldq 0x7ae6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
shrq %rax
subpd 0x7aeb(%rip), %xmm0     # 0xb060
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x7a8f(%rip), %xmm0     # 0xb020
ucomisd %xmm1, %xmm0
jbe 0x35b5
leaq 0x7d09(%rip), %rdi      # 0xb2a7
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2100
movl $0x1, 0xdcf3(%rip)      # 0x112a8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x7c77(%rip), %rdi      # 0xb241
leaq 0x7c50(%rip), %rsi      # 0xb221
leaq 0x7c7f(%rip), %rcx      # 0xb257
movl $0x15d, %edx            # imm = 0x15D
callq 0x2110
leaq 0x9d5f(%rip), %rdi      # 0xd348
leaq 0x7c31(%rip), %rsi      # 0xb221
leaq 0x7c60(%rip), %rcx      # 0xb257
movl $0x16b, %edx            # imm = 0x16B
callq 0x2110
leaq 0x9d40(%rip), %rdi      # 0xd348
leaq 0x7c12(%rip), %rsi      # 0xb221
leaq 0x7c41(%rip), %rcx      # 0xb257
movl $0x171, %edx            # imm = 0x171
callq 0x2110