// File: /workspace/github_c_makefile_star2_O3/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 0x1e8f
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x10f0
testl %eax, %eax
jne 0x1eae
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       # 0x1fa3
movq %r14, (%r13)
movl %ebx, 0x30(%r13)
leaq 0x8(%r13), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x11a0
testl %eax, %eax
jne 0x1df4
movq %r15, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x1dd5
movq %r12, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x1140
testl %eax, %eax
jne 0x1db6
incq %rbx
addq $0x8, %r12
addq $0x48, %r13
cmpq $0x4, %rbx
jne 0x1bf5
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x11b0
testl %eax, %eax
jne 0x1ecd
leaq 0x80(%rsp), %r15
cmpl $0x3, 0xb0(%rsp)
jg 0x1ca1
movq %r15, %rdi
movq %r14, %rsi
callq 0x1060
testl %eax, %eax
je 0x1c69
leaq 0x171d(%rip), %rdi      # 0x33a6
leaq 0x151b(%rip), %rsi      # 0x31ab
leaq 0x15b7(%rip), %rcx      # 0x324e
movl $0xc8, %edx
callq 0x10c0
movq %r14, %rdi
callq 0x1100
testl %eax, %eax
jne 0x1eec
movl $0x8, %ebx
leaq (%rsp,%rbx), %rdi
addq $0xc0, %rdi
callq 0x1100
testl %eax, %eax
jne 0x1e13
addq $0x48, %rbx
cmpq $0x128, %rbx            # imm = 0x128
jne 0x1cb6
leaq 0xc8(%rsp), %r12
xorl %ebx, %ebx
movq 0x10(%rsp,%rbx,8), %rdi
xorl %esi, %esi
callq 0x1180
testl %eax, %eax
jne 0x1e51
movq %r12, %rdi
callq 0x1090
testl %eax, %eax
jne 0x1e32
incq %rbx
addq $0x48, %r12
cmpq $0x4, %rbx
jne 0x1ce5
xorl %eax, %eax
movq 0x8(%rsp), %rbx
cmpq $0x0, 0x30(%rsp,%rax,8)
jne 0x1e70
incq %rax
cmpq $0x5, %rax
jne 0x1d1d
movq %r14, %rdi
callq 0x1090
testl %eax, %eax
jne 0x1f0b
movq %r15, %rdi
callq 0x1160
testl %eax, %eax
jne 0x1f2a
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 0x1d83
movq %rsi, 0x8(%rbx)
movq %rsi, %rax
movq 0xc0(%rsp,%rcx), %rsi
cmpq %rdx, %rsi
jle 0x1d97
movq %rsi, 0x10(%rbx)
movq %rsi, %rdx
addq $0x48, %rcx
cmpq $0x160, %rcx            # imm = 0x160
jne 0x1d6f
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x157a(%rip), %rdi      # 0x3337
leaq 0x13e7(%rip), %rsi      # 0x31ab
leaq 0x1483(%rip), %rcx      # 0x324e
movl $0xc2, %edx
callq 0x10c0
leaq 0x1529(%rip), %rdi      # 0x3305
leaq 0x13c8(%rip), %rsi      # 0x31ab
leaq 0x1464(%rip), %rcx      # 0x324e
movl $0xc0, %edx
callq 0x10c0
leaq 0x14d2(%rip), %rdi      # 0x32cd
leaq 0x13a9(%rip), %rsi      # 0x31ab
leaq 0x1445(%rip), %rcx      # 0x324e
movl $0xbf, %edx
callq 0x10c0
leaq 0x15ed(%rip), %rdi      # 0x3407
leaq 0x138a(%rip), %rsi      # 0x31ab
leaq 0x1426(%rip), %rcx      # 0x324e
movl $0xcc, %edx
callq 0x10c0
leaq 0x1622(%rip), %rdi      # 0x345b
leaq 0x136b(%rip), %rsi      # 0x31ab
leaq 0x1407(%rip), %rcx      # 0x324e
movl $0xd0, %edx
callq 0x10c0
leaq 0x15e3(%rip), %rdi      # 0x343b
leaq 0x134c(%rip), %rsi      # 0x31ab
leaq 0x13e8(%rip), %rcx      # 0x324e
movl $0xcf, %edx
callq 0x10c0
leaq 0x1619(%rip), %rdi      # 0x3490
leaq 0x132d(%rip), %rsi      # 0x31ab
leaq 0x13c9(%rip), %rcx      # 0x324e
movl $0xd4, %edx
callq 0x10c0
leaq 0x13df(%rip), %rdi      # 0x3275
leaq 0x130e(%rip), %rsi      # 0x31ab
leaq 0x13aa(%rip), %rcx      # 0x324e
movl $0xb7, %edx
callq 0x10c0
leaq 0x13ed(%rip), %rdi      # 0x32a2
leaq 0x12ef(%rip), %rsi      # 0x31ab
leaq 0x138b(%rip), %rcx      # 0x324e
movl $0xb8, %edx
callq 0x10c0
leaq 0x14ab(%rip), %rdi      # 0x337f
leaq 0x12d0(%rip), %rsi      # 0x31ab
leaq 0x136c(%rip), %rcx      # 0x324e
movl $0xc5, %edx
callq 0x10c0
leaq 0x14eb(%rip), %rdi      # 0x33de
leaq 0x12b1(%rip), %rsi      # 0x31ab
leaq 0x134d(%rip), %rcx      # 0x324e
movl $0xc9, %edx
callq 0x10c0
leaq 0x159f(%rip), %rdi      # 0x34b1
leaq 0x1292(%rip), %rsi      # 0x31ab
leaq 0x132e(%rip), %rcx      # 0x324e
movl $0xd6, %edx
callq 0x10c0
leaq 0x15aa(%rip), %rdi      # 0x34db
leaq 0x1273(%rip), %rsi      # 0x31ab
leaq 0x130f(%rip), %rcx      # 0x324e
movl $0xd7, %edx
callq 0x10c0