// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/fairness.c
// Function: worker
static void *worker(void *_args) {
  per_thread_t *args = _args;

  // move to our target cpu
  cpu_set_t cpu;
  CPU_ZERO(&cpu);
  CPU_SET(args->x.cpu, &cpu);
  if (sched_setaffinity(0, sizeof(cpu), &cpu)) {
    perror("sched_setaffinity");
    exit(1);
  }

  wait_for_startup();

  if (delay_mask & (1u << args->x.cpu)) {
    sleep(1);
  }
  while (!relaxed) {
    atomic_t *target = &(global_counter.x[global_counter.sweep_id].count);
    x50(__sync_fetch_and_add(target, 1););
    __sync_fetch_and_add(&args->x.count, 50);
  }
  if (delay_mask & (1u << args->x.cpu)) {
    sleep(1);
  }
  while (relaxed) {
    atomic_t *target = &(global_counter.x[global_counter.sweep_id].count);
    x50(__sync_fetch_and_add(target, 1); cpu_relax(););
    __sync_fetch_and_add(&args->x.count, 50);
  }
  return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
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)
movl 0x4(%rdi), %ecx
cmpq $0x3ff, %rcx            # imm = 0x3FF
ja 0x401e8a
movl $0x1, %eax
shlq %cl, %rax
shrl $0x6, %ecx
orq %rax, (%rsp,%rcx,8)
movq %rsp, %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x4638a0
testl %eax, %eax
jne 0x402194
callq 0x402199
movq 0xeb463(%rip), %rax     # 0x4ed310
movl 0x4(%rbx), %ecx
btq %rcx, %rax
jae 0x401ec0
movl $0x1, %edi
callq 0x461e60
cmpl $0x0, 0xef45d(%rip)     # 0x4f1324
leaq 0xeb452(%rip), %r14     # 0x4ed320
jne 0x401fea
movslq 0xef445(%rip), %rax     # 0x4f1320
shlq $0x6, %rax
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
incl (%rax,%r14)
lock
addl $0x32, (%rbx)
cmpl $0x0, 0xef340(%rip)     # 0x4f1324
je 0x401ed4
movq 0xeb31f(%rip), %rax     # 0x4ed310
movl 0x4(%rbx), %ecx
btq %rcx, %rax
jae 0x40217a
movl $0x1, %edi
callq 0x461e60
jmp 0x40217a
movslq 0xef30c(%rip), %rax     # 0x4f1320
shlq $0x6, %rax
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
incl (%rax,%r14)
pause
lock
addl $0x32, (%rbx)
cmpl $0x0, 0xef1a3(%rip)     # 0x4f1324
jne 0x40200d
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
retq
callq 0x401191