// File: /workspace/github_c_makefile_star2_O3/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 0x401ea9
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 0x4021b3
callq 0x4021b8
movq 0xeb444(%rip), %rax     # 0x4ed310
movl 0x4(%rbx), %ecx
btq %rcx, %rax
jae 0x401edf
movl $0x1, %edi
callq 0x461e60
cmpl $0x0, 0xef43e(%rip)     # 0x4f1324
leaq 0xeb433(%rip), %r14     # 0x4ed320
jne 0x402009
movslq 0xef426(%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, 0xef321(%rip)     # 0x4f1324
je 0x401ef3
movq 0xeb300(%rip), %rax     # 0x4ed310
movl 0x4(%rbx), %ecx
btq %rcx, %rax
jae 0x402199
movl $0x1, %edi
callq 0x461e60
jmp 0x402199
movslq 0xef2ed(%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, 0xef184(%rip)     # 0x4f1324
jne 0x40202c
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
retq
callq 0x401191