// File: /workspace/github_c_makefile_star2_O1/dpw[P]skinny-mutex/perf.c
// Function: contention_thread
static void *contention_thread(void *v_thread_info)
{
	struct contention_thread_info *thread_info = v_thread_info;
	struct contention_info *info = thread_info->info;
	int i = thread_info->thread_index;
	int reps = info->thread_reps;
	int j;

	/* Lock our first mutex */
	assert(!mutex_lock(&info->mutexes[i]));

	/* Indicate that we are ready for the test. */
	assert(!pthread_mutex_lock(&info->ready_mutex));
	if (++info->ready_count == CONTENTION_THREAD_COUNT)
		assert(!pthread_cond_signal(&info->ready_cond));
	assert(!pthread_mutex_unlock(&info->ready_mutex));

	/* Line up to start */
	assert(!pthread_mutex_lock(&thread_info->start_mutex));
	assert(!pthread_mutex_unlock(&thread_info->start_mutex));

	thread_info->start = now_usecs();

	for (j = 1; j < reps; j++) {
		int next = (i + 1) % CONTENTION_MUTEX_COUNT;
		assert(!mutex_lock(&info->mutexes[next]));
		assert(!mutex_unlock(&info->mutexes[i]));
		i = next;
	}

	thread_info->stop = now_usecs();

	assert(!mutex_unlock(&info->mutexes[i]));
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r15
movslq 0x30(%rdi), %r12
movl 0x84(%r15), %ebp
movl $0x1, %ecx
xorl %eax, %eax
lock
cmpxchgq %rcx, (%r15,%r12,8)
jne 0x2111
leaq 0x28(%r15), %r14
movq %r14, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x212a
movl 0x80(%r15), %eax
incl %eax
movl %eax, 0x80(%r15)
cmpl $0x4, %eax
jne 0x2030
leaq 0x50(%r15), %rdi
callq 0x10d0
testl %eax, %eax
jne 0x21a6
movq %r14, %rdi
callq 0x1100
testl %eax, %eax
jne 0x2149
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x2168
movq %r14, %rdi
callq 0x1100
testl %eax, %eax
jne 0x2187
callq 0x1f81
movq %rbx, (%rsp)
movq %rax, 0x38(%rbx)
cmpl $0x2, %ebp
jl 0x20de
decl %ebp
xorl %r14d, %r14d
movl $0x1, %ebx
leal 0x1(%r12), %eax
movslq %eax, %r13
imulq $0x66666667, %r13, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x21, %rax
addl %ecx, %eax
leal (%rax,%rax,4), %eax
subl %eax, %r13d
movslq %r13d, %rcx
xorl %eax, %eax
lock
cmpxchgq %rbx, (%r15,%rcx,8)
jne 0x20c8
movslq %r12d, %rcx
movl $0x1, %eax
lock
cmpxchgq %r14, (%r15,%rcx,8)
jne 0x20d3
movl %r13d, %r12d
decl %ebp
jne 0x2080
jmp 0x20e1
leaq (%r15,%rcx,8), %rdi
callq 0x124d
jmp 0x20af
leaq (%r15,%rcx,8), %rdi
callq 0x1278
jmp 0x20bf
movl %r12d, %r13d
callq 0x1f81
movq (%rsp), %rcx
movq %rax, 0x40(%rcx)
movslq %r13d, %rcx
xorl %edx, %edx
movl $0x1, %eax
lock
cmpxchgq %rdx, (%r15,%rcx,8)
jne 0x211f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%r15,%r12,8), %rdi
callq 0x1222
jmp 0x1ff6
leaq (%r15,%rcx,8), %rdi
callq 0x12a3
jmp 0x2100
leaq 0x1411(%rip), %rdi      # 0x3542
leaq 0x1073(%rip), %rsi      # 0x31ab
leaq 0x13e3(%rip), %rcx      # 0x3522
movl $0x95, %edx
callq 0x10c0
leaq 0x1442(%rip), %rdi      # 0x3592
leaq 0x1054(%rip), %rsi      # 0x31ab
leaq 0x13c4(%rip), %rcx      # 0x3522
movl $0x98, %edx
callq 0x10c0
leaq 0x144d(%rip), %rdi      # 0x35bc
leaq 0x1035(%rip), %rsi      # 0x31ab
leaq 0x13a5(%rip), %rcx      # 0x3522
movl $0x9b, %edx
callq 0x10c0
leaq 0x145d(%rip), %rdi      # 0x35eb
leaq 0x1016(%rip), %rsi      # 0x31ab
leaq 0x1386(%rip), %rcx      # 0x3522
movl $0x9c, %edx
callq 0x10c0
leaq 0x13bd(%rip), %rdi      # 0x356a
leaq 0xff7(%rip), %rsi       # 0x31ab
leaq 0x1367(%rip), %rcx      # 0x3522
movl $0x97, %edx
callq 0x10c0