// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x26d0
cmpl $0x0, %eax
jne 0x27f1
jmp 0x2810
leaq 0xd3d(%rip), %rdi       # 0x3535
leaq 0x9c0(%rip), %rsi       # 0x31bf
movl $0x92, %edx
leaq 0xd49(%rip), %rcx       # 0x3554
callq 0x10c0
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
callq 0x11b0
cmpl $0x0, %eax
jne 0x2824
jmp 0x2843
leaq 0xd49(%rip), %rdi       # 0x3574
leaq 0x98d(%rip), %rsi       # 0x31bf
movl $0x95, %edx
leaq 0xd16(%rip), %rcx       # 0x3554
callq 0x10c0
movq -0x18(%rbp), %rcx
movl 0x80(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x80(%rcx)
cmpl $0x4, %eax
jne 0x2890
movq -0x18(%rbp), %rdi
addq $0x50, %rdi
callq 0x10d0
cmpl $0x0, %eax
jne 0x286f
jmp 0x288e
leaq 0xd26(%rip), %rdi       # 0x359c
leaq 0x942(%rip), %rsi       # 0x31bf
movl $0x97, %edx
leaq 0xccb(%rip), %rcx       # 0x3554
callq 0x10c0
jmp 0x2890
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
callq 0x1100
cmpl $0x0, %eax
jne 0x28a4
jmp 0x28c3
leaq 0xd19(%rip), %rdi       # 0x35c4
leaq 0x90d(%rip), %rsi       # 0x31bf
movl $0x98, %edx
leaq 0xc96(%rip), %rcx       # 0x3554
callq 0x10c0
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x11b0
cmpl $0x0, %eax
jne 0x28d7
jmp 0x28f6
leaq 0xd10(%rip), %rdi       # 0x35ee
leaq 0x8da(%rip), %rsi       # 0x31bf
movl $0x9b, %edx
leaq 0xc63(%rip), %rcx       # 0x3554
callq 0x10c0
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x1100
cmpl $0x0, %eax
jne 0x290a
jmp 0x2929
leaq 0xd0c(%rip), %rdi       # 0x361d
leaq 0x8a7(%rip), %rsi       # 0x31bf
movl $0x9c, %edx
leaq 0xc30(%rip), %rcx       # 0x3554
callq 0x10c0
callq 0x2680
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x29e5
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl $0x5, %ecx
cltd
idivl %ecx
movl %edx, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x26d0
cmpl $0x0, %eax
jne 0x2978
jmp 0x2997
leaq 0xccf(%rip), %rdi       # 0x364e
leaq 0x839(%rip), %rsi       # 0x31bf
movl $0xa2, %edx
leaq 0xbc2(%rip), %rcx       # 0x3554
callq 0x10c0
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x2720
cmpl $0x0, %eax
jne 0x29b2
jmp 0x29d1
leaq 0xcb7(%rip), %rdi       # 0x3670
leaq 0x7ff(%rip), %rsi       # 0x31bf
movl $0xa3, %edx
leaq 0xb88(%rip), %rcx       # 0x3554
callq 0x10c0
movl -0x28(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2940
callq 0x2680
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x2720
cmpl $0x0, %eax
jne 0x2a10
jmp 0x2a2f
leaq 0xc59(%rip), %rdi       # 0x3670
leaq 0x7a1(%rip), %rsi       # 0x31bf
movl $0xa9, %edx
leaq 0xb2a(%rip), %rcx       # 0x3554
callq 0x10c0
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq