// File: /workspace/github_c_makefile_star2_O0/LPD-EPFL[P]mctop/src/mctop.c
// Function: is_smt
void*
is_smt(void* param)
{
  tld_t* tld = (tld_t*) param;
  const int tid = tld->id;
  const int hwc = tld->hw_context;
  barrier2_t* barrier2 = tld->barrier2;
  pthread_barrier_t* barrier = tld->barrier;

  mctop_set_cpu(NULL, hwc);
  spin_time(test_num_smt_reps >> 8);
  barrier2_cross_explicit(barrier2, tid, 0);

  const int n_smt = 5;
  int is_smt_n = 0;
  for (int i = 0; i < 5; i++)
    {
      barrier2_cross_explicit(barrier2, tid, 2);
      ticks times[2];
      if (tid == 0)
	{
	  times[0] = spin_time(test_num_smt_reps);
	  pthread_barrier_wait(barrier);
	}
      else
	{
	  pthread_barrier_wait(barrier);
	}

      pthread_barrier_wait(barrier);
      barrier2_cross_explicit(barrier2, tid, 1);
      times[1] = spin_time(test_num_smt_reps);
      if (tid == 0)
	{
	  is_smt_n += (times[0] < (times[1] * test_smt_ratio));
	}
    }

  if (tid == 0)
    {
      int* smt = malloc_assert(sizeof(smt));
      *smt = (is_smt_n > (n_smt - is_smt_n));
      return smt;
    }
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x20(%rbp), %esi
xorl %eax, %eax
movl %eax, %edi
callq 0xc9b0
movl $0x9896, %edi           # imm = 0x9896
callq 0x70f0
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7500
movl $0x5, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
cmpl $0x5, -0x3c(%rbp)
jge 0x34b8
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl $0x2, %edx
callq 0x7500
cmpl $0x0, -0x1c(%rbp)
jne 0x3414
movl $0x989680, %edi         # imm = 0x989680
callq 0x70f0
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2060
jmp 0x341d
movq -0x30(%rbp), %rdi
callq 0x2060
movq -0x30(%rbp), %rdi
callq 0x2060
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl $0x1, %edx
callq 0x7500
movl $0x989680, %edi         # imm = 0x989680
callq 0x70f0
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x34a8
movq -0x50(%rbp), %xmm1
movaps 0xbbf9(%rip), %xmm3     # 0xf050
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xbbfd(%rip), %xmm2     # 0xf060
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x48(%rbp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movsd 0xbb96(%rip), %xmm2     # 0xf028
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x34aa
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x33da
cmpl $0x0, -0x1c(%rbp)
jne 0x34f1
movl $0x8, %edi
callq 0x2da0
movq %rax, -0x58(%rbp)
movl -0x38(%rbp), %eax
movl $0x5, %ecx
subl -0x38(%rbp), %ecx
cmpl %ecx, %eax
setg %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x34f9
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)