// File: /workspace/github_c_makefile_star2_O2/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), %r12
movslq 0x30(%rdi), %r14
movl 0x84(%r12), %ebp
leaq (%r12,%r14,8), %rdi
callq 0x1e56
testl %eax, %eax
jne 0x1fd2
leaq 0x28(%r12), %r15
movq %r15, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x1ff1
movl 0x80(%r12), %eax
incl %eax
movl %eax, 0x80(%r12)
cmpl $0x4, %eax
jne 0x1ee8
leaq 0x50(%r12), %rdi
callq 0x10d0
testl %eax, %eax
jne 0x208c
movq %r15, %rdi
callq 0x1100
testl %eax, %eax
jne 0x2010
leaq 0x8(%rbx), %r15
movq %r15, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x202f
movq %r15, %rdi
callq 0x1100
testl %eax, %eax
jne 0x204e
callq 0x1e12
movq %rbx, (%rsp)
movq %rax, 0x38(%rbx)
xorl %r15d, %r15d
pushq $0x5
popq %r13
incl %r15d
movslq %r14d, %rbx
cmpl %ebp, %r15d
jge 0x1f84
incl %r14d
movl %r14d, %eax
cltd
idivl %r13d
movl %edx, %r14d
movslq %edx, %rax
leaq (%r12,%rax,8), %rdi
callq 0x1e56
testl %eax, %eax
jne 0x1fb3
leaq (%r12,%rbx,8), %rdi
callq 0x1e69
testl %eax, %eax
je 0x1f30
leaq 0x16d2(%rip), %rdi      # 0x363e
leaq 0x1238(%rip), %rsi      # 0x31ab
leaq 0x15a8(%rip), %rcx      # 0x3522
movl $0xa3, %edx
callq 0x10c0
callq 0x1e12
movq (%rsp), %rcx
movq %rax, 0x40(%rcx)
leaq (%r12,%rbx,8), %rdi
callq 0x1e69
testl %eax, %eax
jne 0x206d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1662(%rip), %rdi      # 0x361c
leaq 0x11ea(%rip), %rsi      # 0x31ab
leaq 0x155a(%rip), %rcx      # 0x3522
movl $0xa2, %edx
callq 0x10c0
leaq 0x152a(%rip), %rdi      # 0x3503
leaq 0x11cb(%rip), %rsi      # 0x31ab
leaq 0x153b(%rip), %rcx      # 0x3522
movl $0x92, %edx
callq 0x10c0
leaq 0x154a(%rip), %rdi      # 0x3542
leaq 0x11ac(%rip), %rsi      # 0x31ab
leaq 0x151c(%rip), %rcx      # 0x3522
movl $0x95, %edx
callq 0x10c0
leaq 0x157b(%rip), %rdi      # 0x3592
leaq 0x118d(%rip), %rsi      # 0x31ab
leaq 0x14fd(%rip), %rcx      # 0x3522
movl $0x98, %edx
callq 0x10c0
leaq 0x1586(%rip), %rdi      # 0x35bc
leaq 0x116e(%rip), %rsi      # 0x31ab
leaq 0x14de(%rip), %rcx      # 0x3522
movl $0x9b, %edx
callq 0x10c0
leaq 0x1596(%rip), %rdi      # 0x35eb
leaq 0x114f(%rip), %rsi      # 0x31ab
leaq 0x14bf(%rip), %rcx      # 0x3522
movl $0x9c, %edx
callq 0x10c0
leaq 0x15ca(%rip), %rdi      # 0x363e
leaq 0x1130(%rip), %rsi      # 0x31ab
leaq 0x14a0(%rip), %rcx      # 0x3522
movl $0xa9, %edx
callq 0x10c0
leaq 0x14d7(%rip), %rdi      # 0x356a
leaq 0x1111(%rip), %rsi      # 0x31ab
leaq 0x1481(%rip), %rcx      # 0x3522
movl $0x97, %edx
callq 0x10c0