// File: /workspace/github_c_makefile_star2_O2/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 0x401d91
pushq $0x1
popq %rax
shlq %cl, %rax
shrl $0x6, %ecx
orq %rax, (%rsp,%rcx,8)
movq %rsp, %rdx
movl $0x80, %esi
xorl %edi, %edi
callq 0x4637a0
testl %eax, %eax
jne 0x40208f
callq 0x4020a3
movq 0xeb55c(%rip), %rax     # 0x4ed310
movl 0x4(%rbx), %ecx
btq %rcx, %rax
jae 0x401dc5
pushq $0x1
popq %rdi
callq 0x461d60
leaq 0xeb554(%rip), %r14     # 0x4ed320
cmpl $0x0, 0xef551(%rip)     # 0x4f1324
jne 0x401ee7
movslq 0xef540(%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)
jmp 0x401dcc
movq 0xeb422(%rip), %rax     # 0x4ed310
movl 0x4(%rbx), %ecx
btq %rcx, %rax
jae 0x402075
pushq $0x1
popq %rdi
callq 0x461d60
jmp 0x402075
movslq 0xef411(%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, 0xef2a8(%rip)     # 0x4f1324
jne 0x401f08
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
retq
leaq 0xb5257(%rip), %rdi     # 0x4b72ed
callq 0x410b20
pushq $0x1
popq %rdi
callq 0x40b480