// File: /workspace/github_c_makefile_star2_O1/dpw[P]skinny-mutex/perf.c
// Function: contention
static void contention(struct test_results *res)
{
	struct contention_info info;
	struct contention_thread_info thread_infos[CONTENTION_THREAD_COUNT];
	pthread_t threads[CONTENTION_THREAD_COUNT];
	int i;

	for (i = 0; i < CONTENTION_MUTEX_COUNT; i++)
		assert(!mutex_init(&info.mutexes[i]));

	assert(!pthread_mutex_init(&info.ready_mutex, NULL));
	assert(!pthread_cond_init(&info.ready_cond, NULL));
	info.ready_count = 0;
	info.thread_reps = res->reps / CONTENTION_THREAD_COUNT;

	for (i = 0; i < CONTENTION_THREAD_COUNT; i++) {
		thread_infos[i].info = &info;
		thread_infos[i].thread_index = i;
		assert(!pthread_mutex_init(&thread_infos[i].start_mutex, NULL));
		assert(!pthread_mutex_lock(&thread_infos[i].start_mutex));
		assert(!pthread_create(&threads[i], NULL,
				       contention_thread, &thread_infos[i]));
	}

	assert(!pthread_mutex_lock(&info.ready_mutex));
	while (info.ready_count < CONTENTION_THREAD_COUNT)
		assert(!pthread_cond_wait(&info.ready_cond,
					  &info.ready_mutex));
	assert(!pthread_mutex_unlock(&info.ready_mutex));

	for (i = 0; i < CONTENTION_THREAD_COUNT; i++)
		assert(!pthread_mutex_unlock(&thread_infos[i].start_mutex));

	for (i = 0; i < CONTENTION_THREAD_COUNT; i++) {
		assert(!pthread_join(threads[i], NULL));
		assert(!pthread_mutex_destroy(&thread_infos[i].start_mutex));
	}

	for (i = 0; i < CONTENTION_MUTEX_COUNT; i++)
		assert(!mutex_destroy(&info.mutexes[i]));

	assert(!pthread_mutex_destroy(&info.ready_mutex));
	assert(!pthread_cond_destroy(&info.ready_cond));

	res->start = thread_infos[0].start;
	res->stop = thread_infos[0].stop;
	for (i = 1; i < CONTENTION_THREAD_COUNT; i++) {
		if (thread_infos[i].start < res->start)
			res->start = thread_infos[i].start;
		if (thread_infos[i].stop > res->stop)
			res->stop = thread_infos[i].stop;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x58(%rsp), %rdi
movaps %xmm0, -0x28(%rdi)
movaps %xmm0, -0x18(%rdi)
movq $0x0, -0x8(%rdi)
xorl %esi, %esi
callq 0x11a0
testl %eax, %eax
jne 0x1eb3
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x10f0
testl %eax, %eax
jne 0x1ed2
leaq 0x30(%rsp), %r14
movl $0x0, 0x80(%r14)
movq %rbx, 0x8(%rsp)
movl (%rbx), %eax
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x2, %ecx
movl %ecx, 0x84(%r14)
leaq 0x10(%rsp), %r12
leaq 0xc0(%rsp), %r13
xorl %ebx, %ebx
leaq 0x3ae(%rip), %rbp       # 0x1fc7
movq %r14, (%r13)
movl %ebx, 0x30(%r13)
leaq 0x8(%r13), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x11a0
testl %eax, %eax
jne 0x1e18
movq %r15, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x1df9
movq %r12, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x1140
testl %eax, %eax
jne 0x1dda
incq %rbx
addq $0x8, %r12
addq $0x48, %r13
cmpq $0x4, %rbx
jne 0x1c19
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x1ef1
leaq 0x80(%rsp), %r15
cmpl $0x3, 0xb0(%rsp)
jg 0x1cc5
movq %r15, %rdi
movq %r14, %rsi
callq 0x1060
testl %eax, %eax
je 0x1c8d
leaq 0x16f9(%rip), %rdi      # 0x33a6
leaq 0x14f7(%rip), %rsi      # 0x31ab
leaq 0x1593(%rip), %rcx      # 0x324e
movl $0xc8, %edx
callq 0x10c0
movq %r14, %rdi
callq 0x1100
testl %eax, %eax
jne 0x1f10
movl $0x8, %ebx
leaq (%rsp,%rbx), %rdi
addq $0xc0, %rdi
callq 0x1100
testl %eax, %eax
jne 0x1e37
addq $0x48, %rbx
cmpq $0x128, %rbx            # imm = 0x128
jne 0x1cda
leaq 0xc8(%rsp), %r12
xorl %ebx, %ebx
movq 0x10(%rsp,%rbx,8), %rdi
xorl %esi, %esi
callq 0x1180
testl %eax, %eax
jne 0x1e75
movq %r12, %rdi
callq 0x1090
testl %eax, %eax
jne 0x1e56
incq %rbx
addq $0x48, %r12
cmpq $0x4, %rbx
jne 0x1d09
xorl %eax, %eax
movq 0x8(%rsp), %rbx
cmpq $0x0, 0x30(%rsp,%rax,8)
jne 0x1e94
incq %rax
cmpq $0x5, %rax
jne 0x1d41
movq %r14, %rdi
callq 0x1090
testl %eax, %eax
jne 0x1f2f
movq %r15, %rdi
callq 0x1160
testl %eax, %eax
jne 0x1f4e
movq 0xf8(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x100(%rsp), %rdx
movq %rdx, 0x10(%rbx)
movl $0x88, %ecx
movq 0xb8(%rsp,%rcx), %rsi
cmpq %rax, %rsi
jge 0x1da7
movq %rsi, 0x8(%rbx)
movq %rsi, %rax
movq 0xc0(%rsp,%rcx), %rsi
cmpq %rdx, %rsi
jle 0x1dbb
movq %rsi, 0x10(%rbx)
movq %rsi, %rdx
addq $0x48, %rcx
cmpq $0x160, %rcx            # imm = 0x160
jne 0x1d93
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1556(%rip), %rdi      # 0x3337
leaq 0x13c3(%rip), %rsi      # 0x31ab
leaq 0x145f(%rip), %rcx      # 0x324e
movl $0xc2, %edx
callq 0x10c0
leaq 0x1505(%rip), %rdi      # 0x3305
leaq 0x13a4(%rip), %rsi      # 0x31ab
leaq 0x1440(%rip), %rcx      # 0x324e
movl $0xc0, %edx
callq 0x10c0
leaq 0x14ae(%rip), %rdi      # 0x32cd
leaq 0x1385(%rip), %rsi      # 0x31ab
leaq 0x1421(%rip), %rcx      # 0x324e
movl $0xbf, %edx
callq 0x10c0
leaq 0x15c9(%rip), %rdi      # 0x3407
leaq 0x1366(%rip), %rsi      # 0x31ab
leaq 0x1402(%rip), %rcx      # 0x324e
movl $0xcc, %edx
callq 0x10c0
leaq 0x15fe(%rip), %rdi      # 0x345b
leaq 0x1347(%rip), %rsi      # 0x31ab
leaq 0x13e3(%rip), %rcx      # 0x324e
movl $0xd0, %edx
callq 0x10c0
leaq 0x15bf(%rip), %rdi      # 0x343b
leaq 0x1328(%rip), %rsi      # 0x31ab
leaq 0x13c4(%rip), %rcx      # 0x324e
movl $0xcf, %edx
callq 0x10c0
leaq 0x15f5(%rip), %rdi      # 0x3490
leaq 0x1309(%rip), %rsi      # 0x31ab
leaq 0x13a5(%rip), %rcx      # 0x324e
movl $0xd4, %edx
callq 0x10c0
leaq 0x13bb(%rip), %rdi      # 0x3275
leaq 0x12ea(%rip), %rsi      # 0x31ab
leaq 0x1386(%rip), %rcx      # 0x324e
movl $0xb7, %edx
callq 0x10c0
leaq 0x13c9(%rip), %rdi      # 0x32a2
leaq 0x12cb(%rip), %rsi      # 0x31ab
leaq 0x1367(%rip), %rcx      # 0x324e
movl $0xb8, %edx
callq 0x10c0
leaq 0x1487(%rip), %rdi      # 0x337f
leaq 0x12ac(%rip), %rsi      # 0x31ab
leaq 0x1348(%rip), %rcx      # 0x324e
movl $0xc5, %edx
callq 0x10c0
leaq 0x14c7(%rip), %rdi      # 0x33de
leaq 0x128d(%rip), %rsi      # 0x31ab
leaq 0x1329(%rip), %rcx      # 0x324e
movl $0xc9, %edx
callq 0x10c0
leaq 0x157b(%rip), %rdi      # 0x34b1
leaq 0x126e(%rip), %rsi      # 0x31ab
leaq 0x130a(%rip), %rcx      # 0x324e
movl $0xd6, %edx
callq 0x10c0
leaq 0x1586(%rip), %rdi      # 0x34db
leaq 0x124f(%rip), %rsi      # 0x31ab
leaq 0x12eb(%rip), %rcx      # 0x324e
movl $0xd7, %edx
callq 0x10c0