// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x4010a8
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
shrq $0x3, %rax
cmpq $0x80, %rax
jae 0x402193
movq -0x98(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %eax
shlq %cl, %rax
movq -0x98(%rbp), %rcx
shrq $0x6, %rcx
orq -0x90(%rbp,%rcx,8), %rax
movq %rax, -0x90(%rbp,%rcx,8)
movq %rax, -0xb8(%rbp)
jmp 0x40219e
xorl %eax, %eax
movq %rax, -0xb8(%rbp)
jmp 0x40219e
movq -0xb8(%rbp), %rax
movq %rax, -0xa0(%rbp)
xorl %edi, %edi
movl $0x80, %esi
leaq -0x90(%rbp), %rdx
callq 0x463d60
cmpl $0x0, %eax
je 0x4021da
leaq 0xb61ed(%rip), %rdi     # 0x4b83b8
callq 0x411250
movl $0x1, %edi
callq 0x40bbb0
callq 0x4027a0
movq 0xec12a(%rip), %rax     # 0x4ee310
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
movl %ecx, %ecx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x40220b
movl $0x1, %edi
callq 0x462320
jmp 0x40220d
movl 0xf0111(%rip), %eax     # 0x4f2324
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x402224
jmp 0x402441
leaq 0xec0f5(%rip), %rax     # 0x4ee320
movslq 0xf00ee(%rip), %rcx     # 0x4f2320
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0xa8(%rbp), %rax
lock
incl (%rax)
movq -0x10(%rbp), %rax
lock
addl $0x32, (%rax)
jmp 0x40220d
movq 0xebec8(%rip), %rax     # 0x4ee310
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
movl %ecx, %ecx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x40246d
movl $0x1, %edi
callq 0x462320
jmp 0x40246f
movl 0xefeaf(%rip), %eax     # 0x4f2324
cmpl $0x0, %eax
je 0x402795
leaq 0xebe9b(%rip), %rax     # 0x4ee320
movslq 0xefe94(%rip), %rcx     # 0x4f2320
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0xb0(%rbp), %rax
lock
incl (%rax)
callq 0x402830
movq -0x10(%rbp), %rax
lock
addl $0x32, (%rax)
jmp 0x40246f
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbp
retq