// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %edi
callq 0x21f0
movl -0xc(%rbp), %esi
movl $0x20000000, %edi       # imm = 0x20000000
callq 0x21c0
movq %rax, %rdx
movq 0x122c4(%rip), %rax     # 0x152d8
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x122b5(%rip), %rax     # 0x152d8
movslq -0xc(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x3030
jmp 0x304f
leaq 0xc3d0(%rip), %rdi      # 0xf407
leaq 0xc3a9(%rip), %rsi      # 0xf3e7
movl $0x15d, %edx            # imm = 0x15D
leaq 0xc3d3(%rip), %rcx      # 0xf41d
callq 0x20e0
movq 0x12282(%rip), %rax     # 0x152d8
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl $0x20000000, %esi       # imm = 0x20000000
callq 0x6f20
cmpl $0x0, -0xc(%rbp)
jne 0x330b
cmpl $0x1, 0x12187(%rip)     # 0x15208
jle 0x330b
movq 0x1224a(%rip), %rax     # 0x152d8
movl -0xc(%rbp), %ecx
testl %ecx, %ecx
sete %cl
movzbl %cl, %ecx
movq (%rax,%rcx,8), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
movq %rsi, -0x68(%rbp)
callq 0x6e70
movq -0x68(%rbp), %rsi
movq %rax, -0x20(%rbp)
movq 0x1221e(%rip), %rax     # 0x152d8
movl -0xc(%rbp), %ecx
testl %ecx, %ecx
sete %cl
movzbl %cl, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x6e70
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3320
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rcx
addq %rcx, %rax
shrq %rax
movq %rax, -0x38(%rbp)
movaps 0xbf54(%rip), %xmm3     # 0xf050
movq -0x30(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0xbf53(%rip), %xmm1     # 0xf060
subpd %xmm1, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movq -0x38(%rbp), %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm1, %xmm2
movaps %xmm2, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm1, %xmm2
movsd 0xbee4(%rip), %xmm1     # 0xf020
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x3309
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq 0xc2db(%rip), %rdi      # 0xf434
movb $0x0, %al
callq 0x20d0
cmpl $0x0, -0xc(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %esi
movl $0x20000000, %edi       # imm = 0x20000000
callq 0x21c0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3185
jmp 0x31a4
leaq 0xe39c(%rip), %rdi      # 0x11528
leaq 0xc254(%rip), %rsi      # 0xf3e7
movl $0x16b, %edx            # imm = 0x16B
leaq 0xc27e(%rip), %rcx      # 0xf41d
callq 0x20e0
movq -0x40(%rbp), %rdi
movl $0x20000000, %esi       # imm = 0x20000000
callq 0x6f20
movq 0x1211f(%rip), %rax     # 0x152d8
cmpl $0x0, -0xc(%rbp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x6e70
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movl $0x20000000, %esi       # imm = 0x20000000
callq 0x2090
cmpl $0x0, -0xc(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %esi
movl $0x20000000, %edi       # imm = 0x20000000
callq 0x21c0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3211
jmp 0x3230
leaq 0xe310(%rip), %rdi      # 0x11528
leaq 0xc1c8(%rip), %rsi      # 0xf3e7
movl $0x171, %edx            # imm = 0x171
leaq 0xc1f2(%rip), %rcx      # 0xf41d
callq 0x20e0
movq -0x40(%rbp), %rdi
movl $0x20000000, %esi       # imm = 0x20000000
movq %rsi, -0x70(%rbp)
callq 0x6f20
movq 0x1208f(%rip), %rax     # 0x152d8
movl -0xc(%rbp), %ecx
testl %ecx, %ecx
sete %cl
movzbl %cl, %ecx
movq (%rax,%rcx,8), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
callq 0x6e70
movq -0x70(%rbp), %rsi
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rdi
callq 0x2090
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3320
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
addq %rcx, %rax
shrq %rax
movq %rax, -0x60(%rbp)
movaps 0xbdb3(%rip), %xmm3     # 0xf050
movq -0x58(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xbdb2(%rip), %xmm0     # 0xf060
subpd %xmm0, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movq -0x60(%rbp), %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm0, %xmm2
movaps %xmm2, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm0, %xmm2
movsd 0xbd43(%rip), %xmm0     # 0xf020
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3307
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq 0xc177(%rip), %rdi      # 0xf46d
movb $0x0, %al
callq 0x20d0
movl $0x1, 0x11fb1(%rip)     # 0x152b8
jmp 0x3309
jmp 0x330b
xorl %eax, %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)