	.file	"125449.c"
	.intel_syntax noprefix
	.text
	.globl	threadParams
	.bss
	.align 8
	.type	threadParams, @object
	.size	threadParams, 8
threadParams:
	.zero	8
	.globl	threads
	.align 16
	.type	threads, @object
	.size	threads, 16
threads:
	.zero	16
	.globl	nrt_param
	.align 4
	.type	nrt_param, @object
	.size	nrt_param, 4
nrt_param:
	.zero	4
	.globl	rsrcA
	.align 32
	.type	rsrcA, @object
	.size	rsrcA, 40
rsrcA:
	.zero	40
	.globl	rsrcB
	.align 32
	.type	rsrcB, @object
	.size	rsrcB, 40
rsrcB:
	.zero	40
	.globl	rsrcACnt
	.align 4
	.type	rsrcACnt, @object
	.size	rsrcACnt, 4
rsrcACnt:
	.zero	4
	.globl	rsrcBCnt
	.align 4
	.type	rsrcBCnt, @object
	.size	rsrcBCnt, 4
rsrcBCnt:
	.zero	4
	.globl	noWait
	.align 4
	.type	noWait, @object
	.size	noWait, 4
noWait:
	.zero	4
	.section	.rodata
.LC0:
	.string	"Thread 1 started"
.LC1:
	.string	"Thread 2 started"
.LC2:
	.string	"Unknown thread started"
	.align 8
.LC3:
	.string	"THREAD 1 grabbing resource A @ %d sec and %d nsec\n"
.LC4:
	.string	"Thread 1 ERROR"
.LC5:
	.string	"Thread 1 GOT A"
.LC6:
	.string	"rsrcACnt=%d, rsrcBCnt=%d\n"
	.align 8
.LC7:
	.string	"THREAD 1 got A, trying for B @ %d sec and %d nsec\n"
	.align 8
.LC8:
	.string	"Thread 1 GOT B @ %d sec and %d nsec with rc=%d\n"
.LC9:
	.string	"Thread 1 TIMEOUT ERROR"
.LC10:
	.string	"THREAD 1 got A and B"
.LC11:
	.string	"THREAD 1 done"
	.align 8
.LC12:
	.string	"THREAD 2 grabbing resource B @ %d sec and %d nsec\n"
.LC13:
	.string	"Thread 2 ERROR"
.LC14:
	.string	"Thread 2 GOT B"
	.align 8
.LC15:
	.string	"THREAD 2 got B, trying for A @ %d sec and %d nsec\n"
	.align 8
.LC16:
	.string	"Thread 2 GOT A @ %d sec and %d nsec with rc=%d\n"
.LC17:
	.string	"Thread 2 TIMEOUT ERROR"
.LC18:
	.string	"THREAD 2 got B and A"
.LC19:
	.string	"THREAD 2 done"
	.text
	.globl	grabRsrcs
	.type	grabRsrcs, @function
grabRsrcs:
.LFB6:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 96
	mov	QWORD PTR -88[rbp], rdi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	mov	rax, QWORD PTR -88[rbp]
	mov	QWORD PTR -72[rbp], rax
	mov	rax, QWORD PTR -72[rbp]
	mov	eax, DWORD PTR [rax]
	mov	DWORD PTR -80[rbp], eax
	cmp	DWORD PTR -80[rbp], 1
	jne	.L2
	lea	rdi, .LC0[rip]
	call	puts@PLT
	jmp	.L3
.L2:
	cmp	DWORD PTR -80[rbp], 2
	jne	.L4
	lea	rdi, .LC1[rip]
	call	puts@PLT
	jmp	.L3
.L4:
	lea	rdi, .LC2[rip]
	call	puts@PLT
.L3:
	lea	rax, -64[rbp]
	mov	rsi, rax
	mov	edi, 0
	call	clock_gettime@PLT
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 2
	mov	QWORD PTR -48[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	QWORD PTR -40[rbp], rax
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 3
	mov	QWORD PTR -32[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	QWORD PTR -24[rbp], rax
	cmp	DWORD PTR -80[rbp], 1
	jne	.L5
	mov	rax, QWORD PTR -56[rbp]
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	esi, eax
	lea	rdi, .LC3[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_lock@PLT
	mov	DWORD PTR -76[rbp], eax
	cmp	DWORD PTR -76[rbp], 0
	je	.L6
	lea	rdi, .LC4[rip]
	call	puts@PLT
	mov	edi, 0
	call	pthread_exit@PLT
.L6:
	lea	rdi, .LC5[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcACnt[rip]
	add	eax, 1
	mov	DWORD PTR rsrcACnt[rip], eax
	mov	edx, DWORD PTR rsrcBCnt[rip]
	mov	eax, DWORD PTR rsrcACnt[rip]
	mov	esi, eax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR noWait[rip]
	test	eax, eax
	jne	.L7
	mov	edi, 1000000
	mov	eax, 0
	call	usleep@PLT
.L7:
	lea	rax, -64[rbp]
	mov	rsi, rax
	mov	edi, 0
	call	clock_gettime@PLT
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 3
	mov	QWORD PTR -32[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	QWORD PTR -24[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	esi, eax
	lea	rdi, .LC7[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rax, -32[rbp]
	mov	rsi, rax
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_timedlock@PLT
	mov	DWORD PTR -76[rbp], eax
	cmp	DWORD PTR -76[rbp], 0
	jne	.L8
	lea	rax, -64[rbp]
	mov	rsi, rax
	mov	edi, 0
	call	clock_gettime@PLT
	mov	rax, QWORD PTR -56[rbp]
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	esi, eax
	mov	eax, DWORD PTR -76[rbp]
	mov	ecx, eax
	lea	rdi, .LC8[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR rsrcBCnt[rip]
	add	eax, 1
	mov	DWORD PTR rsrcBCnt[rip], eax
	mov	edx, DWORD PTR rsrcBCnt[rip]
	mov	eax, DWORD PTR rsrcACnt[rip]
	mov	esi, eax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, .LC10[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcBCnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcBCnt[rip], eax
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_unlock@PLT
	mov	eax, DWORD PTR rsrcACnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcACnt[rip], eax
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_unlock@PLT
	lea	rdi, .LC11[rip]
	call	puts@PLT
	jmp	.L11
.L8:
	cmp	DWORD PTR -76[rbp], 110
	jne	.L10
	lea	rdi, .LC9[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcACnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcACnt[rip], eax
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_unlock@PLT
	mov	edi, 0
	call	pthread_exit@PLT
.L10:
	lea	rdi, .LC4[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcACnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcACnt[rip], eax
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_unlock@PLT
	mov	edi, 0
	call	pthread_exit@PLT
.L5:
	mov	rax, QWORD PTR -56[rbp]
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	esi, eax
	lea	rdi, .LC12[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_lock@PLT
	mov	DWORD PTR -76[rbp], eax
	cmp	DWORD PTR -76[rbp], 0
	je	.L12
	lea	rdi, .LC13[rip]
	call	puts@PLT
	mov	edi, 0
	call	pthread_exit@PLT
.L12:
	lea	rdi, .LC14[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcBCnt[rip]
	add	eax, 1
	mov	DWORD PTR rsrcBCnt[rip], eax
	mov	edx, DWORD PTR rsrcBCnt[rip]
	mov	eax, DWORD PTR rsrcACnt[rip]
	mov	esi, eax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR noWait[rip]
	test	eax, eax
	jne	.L13
	mov	edi, 1000000
	mov	eax, 0
	call	usleep@PLT
.L13:
	lea	rax, -64[rbp]
	mov	rsi, rax
	mov	edi, 0
	call	clock_gettime@PLT
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 2
	mov	QWORD PTR -48[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	QWORD PTR -40[rbp], rax
	mov	rax, QWORD PTR -56[rbp]
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	esi, eax
	lea	rdi, .LC15[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rax, -48[rbp]
	mov	rsi, rax
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_timedlock@PLT
	mov	DWORD PTR -76[rbp], eax
	cmp	DWORD PTR -76[rbp], 0
	jne	.L14
	lea	rax, -64[rbp]
	mov	rsi, rax
	mov	edi, 0
	call	clock_gettime@PLT
	mov	rax, QWORD PTR -56[rbp]
	mov	edx, eax
	mov	rax, QWORD PTR -64[rbp]
	mov	esi, eax
	mov	eax, DWORD PTR -76[rbp]
	mov	ecx, eax
	lea	rdi, .LC16[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR rsrcACnt[rip]
	add	eax, 1
	mov	DWORD PTR rsrcACnt[rip], eax
	mov	edx, DWORD PTR rsrcBCnt[rip]
	mov	eax, DWORD PTR rsrcACnt[rip]
	mov	esi, eax
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, .LC18[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcACnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcACnt[rip], eax
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_unlock@PLT
	mov	eax, DWORD PTR rsrcBCnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcBCnt[rip], eax
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_unlock@PLT
	lea	rdi, .LC19[rip]
	call	puts@PLT
	jmp	.L11
.L14:
	cmp	DWORD PTR -76[rbp], 110
	jne	.L16
	lea	rdi, .LC17[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcBCnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcBCnt[rip], eax
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_unlock@PLT
	mov	edi, 0
	call	pthread_exit@PLT
.L16:
	lea	rdi, .LC13[rip]
	call	puts@PLT
	mov	eax, DWORD PTR rsrcBCnt[rip]
	sub	eax, 1
	mov	DWORD PTR rsrcBCnt[rip], eax
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_unlock@PLT
	mov	edi, 0
	call	pthread_exit@PLT
.L11:
	mov	edi, 0
	call	pthread_exit@PLT
	.cfi_endproc
.LFE6:
	.size	grabRsrcs, .-grabRsrcs
	.section	.rodata
	.align 8
.LC20:
	.string	"Will set up unsafe deadlock scenario"
.LC21:
	.string	"safe"
.LC22:
	.string	"race"
	.align 8
.LC23:
	.string	"Usage: deadlock [safe|race|unsafe]"
.LC24:
	.string	"Creating thread %d\n"
	.align 8
.LC25:
	.string	"ERROR; pthread_create() rc is %d\n"
.LC26:
	.string	"Thread 1 joined to main"
.LC27:
	.string	"Thread 1"
	.align 8
.LC28:
	.string	"will try to join both CS threads unless they deadlock"
.LC29:
	.string	"Thread 2 joined to main"
.LC30:
	.string	"Thread 2"
.LC31:
	.string	"mutex A destroy"
.LC32:
	.string	"mutex B destroy"
.LC33:
	.string	"All done"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 32
	mov	DWORD PTR -20[rbp], edi
	mov	QWORD PTR -32[rbp], rsi
	mov	DWORD PTR -8[rbp], 0
	mov	DWORD PTR rsrcACnt[rip], 0
	mov	DWORD PTR rsrcBCnt[rip], 0
	mov	DWORD PTR noWait[rip], 0
	cmp	DWORD PTR -20[rbp], 1
	jg	.L19
	lea	rdi, .LC20[rip]
	call	puts@PLT
	jmp	.L20
.L19:
	cmp	DWORD PTR -20[rbp], 2
	jne	.L21
	mov	rax, QWORD PTR -32[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	mov	edx, 4
	mov	rsi, rax
	lea	rdi, .LC21[rip]
	call	strncmp@PLT
	test	eax, eax
	jne	.L22
	mov	DWORD PTR -8[rbp], 1
	jmp	.L20
.L22:
	mov	rax, QWORD PTR -32[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	mov	edx, 4
	mov	rsi, rax
	lea	rdi, .LC22[rip]
	call	strncmp@PLT
	test	eax, eax
	jne	.L23
	mov	DWORD PTR noWait[rip], 1
	jmp	.L20
.L23:
	lea	rdi, .LC20[rip]
	call	puts@PLT
	jmp	.L20
.L21:
	lea	rdi, .LC23[rip]
	call	puts@PLT
.L20:
	mov	esi, 0
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_init@PLT
	mov	esi, 0
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_init@PLT
	mov	esi, 1
	lea	rdi, .LC24[rip]
	mov	eax, 0
	call	printf@PLT
	mov	DWORD PTR threadParams[rip+4], 1
	lea	rcx, threadParams[rip+4]
	lea	rdx, grabRsrcs[rip]
	mov	esi, 0
	lea	rdi, threads[rip]
	call	pthread_create@PLT
	mov	DWORD PTR -4[rbp], eax
	cmp	DWORD PTR -4[rbp], 0
	je	.L24
	mov	eax, DWORD PTR -4[rbp]
	mov	esi, eax
	lea	rdi, .LC25[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edi, 0
	call	perror@PLT
	mov	edi, -1
	call	exit@PLT
.L24:
	cmp	DWORD PTR -8[rbp], 0
	je	.L25
	mov	rax, QWORD PTR threads[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	test	eax, eax
	jne	.L26
	lea	rdi, .LC26[rip]
	call	puts@PLT
	jmp	.L25
.L26:
	lea	rdi, .LC27[rip]
	call	perror@PLT
.L25:
	mov	esi, 2
	lea	rdi, .LC24[rip]
	mov	eax, 0
	call	printf@PLT
	mov	DWORD PTR threadParams[rip+8], 2
	lea	rcx, threadParams[rip+8]
	lea	rdx, grabRsrcs[rip]
	mov	esi, 0
	lea	rdi, threads[rip+8]
	call	pthread_create@PLT
	mov	DWORD PTR -4[rbp], eax
	cmp	DWORD PTR -4[rbp], 0
	je	.L27
	mov	eax, DWORD PTR -4[rbp]
	mov	esi, eax
	lea	rdi, .LC25[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edi, 0
	call	perror@PLT
	mov	edi, -1
	call	exit@PLT
.L27:
	lea	rdi, .LC28[rip]
	call	puts@PLT
	cmp	DWORD PTR -8[rbp], 0
	jne	.L28
	mov	rax, QWORD PTR threads[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	test	eax, eax
	jne	.L29
	lea	rdi, .LC26[rip]
	call	puts@PLT
	jmp	.L28
.L29:
	lea	rdi, .LC27[rip]
	call	perror@PLT
.L28:
	mov	rax, QWORD PTR threads[rip+8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	test	eax, eax
	jne	.L30
	lea	rdi, .LC29[rip]
	call	puts@PLT
	jmp	.L31
.L30:
	lea	rdi, .LC30[rip]
	call	perror@PLT
.L31:
	lea	rdi, rsrcA[rip]
	call	pthread_mutex_destroy@PLT
	test	eax, eax
	je	.L32
	lea	rdi, .LC31[rip]
	call	perror@PLT
.L32:
	lea	rdi, rsrcB[rip]
	call	pthread_mutex_destroy@PLT
	test	eax, eax
	je	.L33
	lea	rdi, .LC32[rip]
	call	perror@PLT
.L33:
	lea	rdi, .LC33[rip]
	call	puts@PLT
	mov	edi, 0
	call	exit@PLT
	.cfi_endproc
.LFE7:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 6
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"125449.c"
	.text
	.comm	threadParams,8,4
	.comm	threads,8,4
	.comm	nrt_param,4,4
	.comm	rsrcA,24,4
	.comm	rsrcB,24,4
	.global	rsrcACnt
	.bss
	.align	2
	.type	rsrcACnt, %object
	.size	rsrcACnt, 4
rsrcACnt:
	.space	4
	.global	rsrcBCnt
	.align	2
	.type	rsrcBCnt, %object
	.size	rsrcBCnt, 4
rsrcBCnt:
	.space	4
	.global	noWait
	.align	2
	.type	noWait, %object
	.size	noWait, 4
noWait:
	.space	4
	.section	.rodata
	.align	2
.LC0:
	.ascii	"Thread 1 started\000"
	.align	2
.LC1:
	.ascii	"Thread 2 started\000"
	.align	2
.LC2:
	.ascii	"Unknown thread started\000"
	.align	2
.LC3:
	.ascii	"THREAD 1 grabbing resource A @ %d sec and %d nsec\012"
	.ascii	"\000"
	.align	2
.LC4:
	.ascii	"Thread 1 ERROR\000"
	.align	2
.LC5:
	.ascii	"Thread 1 GOT A\000"
	.align	2
.LC6:
	.ascii	"rsrcACnt=%d, rsrcBCnt=%d\012\000"
	.align	2
.LC7:
	.ascii	"THREAD 1 got A, trying for B @ %d sec and %d nsec\012"
	.ascii	"\000"
	.align	2
.LC8:
	.ascii	"Thread 1 GOT B @ %d sec and %d nsec with rc=%d\012\000"
	.align	2
.LC9:
	.ascii	"Thread 1 TIMEOUT ERROR\000"
	.align	2
.LC10:
	.ascii	"THREAD 1 got A and B\000"
	.align	2
.LC11:
	.ascii	"THREAD 1 done\000"
	.align	2
.LC12:
	.ascii	"THREAD 2 grabbing resource B @ %d sec and %d nsec\012"
	.ascii	"\000"
	.align	2
.LC13:
	.ascii	"Thread 2 ERROR\000"
	.align	2
.LC14:
	.ascii	"Thread 2 GOT B\000"
	.align	2
.LC15:
	.ascii	"THREAD 2 got B, trying for A @ %d sec and %d nsec\012"
	.ascii	"\000"
	.align	2
.LC16:
	.ascii	"Thread 2 GOT A @ %d sec and %d nsec with rc=%d\012\000"
	.align	2
.LC17:
	.ascii	"Thread 2 TIMEOUT ERROR\000"
	.align	2
.LC18:
	.ascii	"THREAD 2 got B and A\000"
	.align	2
.LC19:
	.ascii	"THREAD 2 done\000"
	.align	2
.LC20:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	grabRsrcs
	.syntax unified
	.arm
	.fpu softvfp
	.type	grabRsrcs, %function
grabRsrcs:
	@ args = 0, pretend = 0, frame = 48
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #48
	str	r0, [fp, #-48]
	ldr	r3, .L18
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	ldr	r3, [fp, #-48]
	str	r3, [fp, #-44]
	ldr	r3, [fp, #-44]
	ldr	r3, [r3]
	str	r3, [fp, #-40]
	ldr	r3, [fp, #-40]
	cmp	r3, #1
	bne	.L2
	ldr	r0, .L18+4
	bl	puts
	b	.L3
.L2:
	ldr	r3, [fp, #-40]
	cmp	r3, #2
	bne	.L4
	ldr	r0, .L18+8
	bl	puts
	b	.L3
.L4:
	ldr	r0, .L18+12
	bl	puts
.L3:
	sub	r3, fp, #32
	mov	r1, r3
	mov	r0, #0
	bl	clock_gettime
	ldr	r3, [fp, #-32]
	add	r3, r3, #2
	str	r3, [fp, #-24]
	ldr	r3, [fp, #-28]
	str	r3, [fp, #-20]
	ldr	r3, [fp, #-32]
	add	r3, r3, #3
	str	r3, [fp, #-16]
	ldr	r3, [fp, #-28]
	str	r3, [fp, #-12]
	ldr	r3, [fp, #-40]
	cmp	r3, #1
	bne	.L5
	ldr	r3, [fp, #-32]
	ldr	r2, [fp, #-28]
	mov	r1, r3
	ldr	r0, .L18+16
	bl	printf
	ldr	r0, .L18+20
	bl	pthread_mutex_lock
	str	r0, [fp, #-36]
	ldr	r3, [fp, #-36]
	cmp	r3, #0
	beq	.L6
	ldr	r0, .L18+24
	bl	puts
	mov	r0, #0
	bl	pthread_exit
.L6:
	ldr	r0, .L18+28
	bl	puts
	ldr	r3, .L18+32
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L18+32
	str	r3, [r2]
	ldr	r3, .L18+32
	ldr	r3, [r3]
	ldr	r2, .L18+36
	ldr	r2, [r2]
	mov	r1, r3
	ldr	r0, .L18+40
	bl	printf
	ldr	r3, .L18+44
	ldr	r3, [r3]
	cmp	r3, #0
	bne	.L7
	ldr	r0, .L18+48
	bl	usleep
.L7:
	sub	r3, fp, #32
	mov	r1, r3
	mov	r0, #0
	bl	clock_gettime
	ldr	r3, [fp, #-32]
	add	r3, r3, #3
	str	r3, [fp, #-16]
	ldr	r3, [fp, #-28]
	str	r3, [fp, #-12]
	ldr	r3, [fp, #-32]
	ldr	r2, [fp, #-28]
	mov	r1, r3
	ldr	r0, .L18+52
	bl	printf
	sub	r3, fp, #16
	mov	r1, r3
	ldr	r0, .L18+56
	bl	pthread_mutex_timedlock
	str	r0, [fp, #-36]
	ldr	r3, [fp, #-36]
	cmp	r3, #0
	bne	.L8
	sub	r3, fp, #32
	mov	r1, r3
	mov	r0, #0
	bl	clock_gettime
	ldr	r1, [fp, #-32]
	ldr	r2, [fp, #-28]
	ldr	r3, [fp, #-36]
	ldr	r0, .L18+60
	bl	printf
	ldr	r3, .L18+36
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L18+36
	str	r3, [r2]
	ldr	r3, .L18+32
	ldr	r3, [r3]
	ldr	r2, .L18+36
	ldr	r2, [r2]
	mov	r1, r3
	ldr	r0, .L18+40
	bl	printf
	ldr	r0, .L18+64
	bl	puts
	ldr	r3, .L18+36
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+36
	str	r3, [r2]
	ldr	r0, .L18+56
	bl	pthread_mutex_unlock
	ldr	r3, .L18+32
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+32
	str	r3, [r2]
	ldr	r0, .L18+20
	bl	pthread_mutex_unlock
	ldr	r0, .L18+68
	bl	puts
	b	.L11
.L8:
	ldr	r3, [fp, #-36]
	cmp	r3, #110
	bne	.L10
	ldr	r0, .L18+72
	bl	puts
	ldr	r3, .L18+32
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+32
	str	r3, [r2]
	ldr	r0, .L18+20
	bl	pthread_mutex_unlock
	mov	r0, #0
	bl	pthread_exit
.L10:
	ldr	r0, .L18+24
	bl	puts
	ldr	r3, .L18+32
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+32
	str	r3, [r2]
	ldr	r0, .L18+20
	bl	pthread_mutex_unlock
	mov	r0, #0
	bl	pthread_exit
.L5:
	ldr	r3, [fp, #-32]
	ldr	r2, [fp, #-28]
	mov	r1, r3
	ldr	r0, .L18+76
	bl	printf
	ldr	r0, .L18+56
	bl	pthread_mutex_lock
	str	r0, [fp, #-36]
	ldr	r3, [fp, #-36]
	cmp	r3, #0
	beq	.L12
	ldr	r0, .L18+80
	bl	puts
	mov	r0, #0
	bl	pthread_exit
.L12:
	ldr	r0, .L18+84
	bl	puts
	ldr	r3, .L18+36
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L18+36
	str	r3, [r2]
	ldr	r3, .L18+32
	ldr	r3, [r3]
	ldr	r2, .L18+36
	ldr	r2, [r2]
	mov	r1, r3
	ldr	r0, .L18+40
	bl	printf
	ldr	r3, .L18+44
	ldr	r3, [r3]
	cmp	r3, #0
	bne	.L13
	ldr	r0, .L18+48
	bl	usleep
.L13:
	sub	r3, fp, #32
	mov	r1, r3
	mov	r0, #0
	bl	clock_gettime
	ldr	r3, [fp, #-32]
	add	r3, r3, #2
	str	r3, [fp, #-24]
	ldr	r3, [fp, #-28]
	str	r3, [fp, #-20]
	ldr	r3, [fp, #-32]
	ldr	r2, [fp, #-28]
	mov	r1, r3
	ldr	r0, .L18+88
	bl	printf
	sub	r3, fp, #24
	mov	r1, r3
	ldr	r0, .L18+20
	bl	pthread_mutex_timedlock
	str	r0, [fp, #-36]
	ldr	r3, [fp, #-36]
	cmp	r3, #0
	bne	.L14
	sub	r3, fp, #32
	mov	r1, r3
	mov	r0, #0
	bl	clock_gettime
	ldr	r1, [fp, #-32]
	ldr	r2, [fp, #-28]
	ldr	r3, [fp, #-36]
	ldr	r0, .L18+92
	bl	printf
	ldr	r3, .L18+32
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L18+32
	str	r3, [r2]
	ldr	r3, .L18+32
	ldr	r3, [r3]
	ldr	r2, .L18+36
	ldr	r2, [r2]
	mov	r1, r3
	ldr	r0, .L18+40
	bl	printf
	ldr	r0, .L18+96
	bl	puts
	ldr	r3, .L18+32
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+32
	str	r3, [r2]
	ldr	r0, .L18+20
	bl	pthread_mutex_unlock
	ldr	r3, .L18+36
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+36
	str	r3, [r2]
	ldr	r0, .L18+56
	bl	pthread_mutex_unlock
	ldr	r0, .L18+100
	bl	puts
	b	.L11
.L14:
	ldr	r3, [fp, #-36]
	cmp	r3, #110
	bne	.L16
	ldr	r0, .L18+104
	bl	puts
	ldr	r3, .L18+36
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+36
	str	r3, [r2]
	ldr	r0, .L18+56
	bl	pthread_mutex_unlock
	mov	r0, #0
	bl	pthread_exit
.L16:
	ldr	r0, .L18+80
	bl	puts
	ldr	r3, .L18+36
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L18+36
	str	r3, [r2]
	ldr	r0, .L18+56
	bl	pthread_mutex_unlock
	mov	r0, #0
	bl	pthread_exit
.L11:
	mov	r0, #0
	bl	pthread_exit
.L19:
	.align	2
.L18:
	.word	.LC20
	.word	.LC0
	.word	.LC1
	.word	.LC2
	.word	.LC3
	.word	rsrcA
	.word	.LC4
	.word	.LC5
	.word	rsrcACnt
	.word	rsrcBCnt
	.word	.LC6
	.word	noWait
	.word	1000000
	.word	.LC7
	.word	rsrcB
	.word	.LC8
	.word	.LC10
	.word	.LC11
	.word	.LC9
	.word	.LC12
	.word	.LC13
	.word	.LC14
	.word	.LC15
	.word	.LC16
	.word	.LC18
	.word	.LC19
	.word	.LC17
	.size	grabRsrcs, .-grabRsrcs
	.section	.rodata
	.align	2
.LC21:
	.ascii	"Will set up unsafe deadlock scenario\000"
	.align	2
.LC22:
	.ascii	"safe\000"
	.align	2
.LC23:
	.ascii	"race\000"
	.align	2
.LC24:
	.ascii	"Usage: deadlock [safe|race|unsafe]\000"
	.align	2
.LC25:
	.ascii	"Creating thread %d\012\000"
	.align	2
.LC26:
	.ascii	"ERROR; pthread_create() rc is %d\012\000"
	.align	2
.LC27:
	.ascii	"Thread 1 joined to main\000"
	.align	2
.LC28:
	.ascii	"Thread 1\000"
	.align	2
.LC29:
	.ascii	"will try to join both CS threads unless they deadlo"
	.ascii	"ck\000"
	.align	2
.LC30:
	.ascii	"Thread 2 joined to main\000"
	.align	2
.LC31:
	.ascii	"Thread 2\000"
	.align	2
.LC32:
	.ascii	"mutex A destroy\000"
	.align	2
.LC33:
	.ascii	"mutex B destroy\000"
	.align	2
.LC34:
	.ascii	"All done\000"
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #16
	str	r0, [fp, #-16]
	str	r1, [fp, #-20]
	mov	r3, #0
	str	r3, [fp, #-12]
	ldr	r3, .L36
	mov	r2, #0
	str	r2, [r3]
	ldr	r3, .L36+4
	mov	r2, #0
	str	r2, [r3]
	ldr	r3, .L36+8
	mov	r2, #0
	str	r2, [r3]
	ldr	r3, [fp, #-16]
	cmp	r3, #1
	bgt	.L21
	ldr	r0, .L36+12
	bl	puts
	b	.L22
.L21:
	ldr	r3, [fp, #-16]
	cmp	r3, #2
	bne	.L23
	ldr	r3, [fp, #-20]
	add	r3, r3, #4
	ldr	r3, [r3]
	mov	r2, #4
	mov	r1, r3
	ldr	r0, .L36+16
	bl	strncmp
	mov	r3, r0
	cmp	r3, #0
	bne	.L24
	mov	r3, #1
	str	r3, [fp, #-12]
	b	.L22
.L24:
	ldr	r3, [fp, #-20]
	add	r3, r3, #4
	ldr	r3, [r3]
	mov	r2, #4
	mov	r1, r3
	ldr	r0, .L36+20
	bl	strncmp
	mov	r3, r0
	cmp	r3, #0
	bne	.L25
	ldr	r3, .L36+8
	mov	r2, #1
	str	r2, [r3]
	b	.L22
.L25:
	ldr	r0, .L36+12
	bl	puts
	b	.L22
.L23:
	ldr	r0, .L36+24
	bl	puts
.L22:
	mov	r1, #0
	ldr	r0, .L36+28
	bl	pthread_mutex_init
	mov	r1, #0
	ldr	r0, .L36+32
	bl	pthread_mutex_init
	mov	r1, #1
	ldr	r0, .L36+36
	bl	printf
	ldr	r3, .L36+40
	mov	r2, #1
	str	r2, [r3, #4]
	ldr	r3, .L36+44
	ldr	r2, .L36+48
	mov	r1, #0
	ldr	r0, .L36+52
	bl	pthread_create
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	beq	.L26
	ldr	r1, [fp, #-8]
	ldr	r0, .L36+56
	bl	printf
	mov	r0, #0
	bl	perror
	mvn	r0, #0
	bl	exit
.L26:
	ldr	r3, [fp, #-12]
	cmp	r3, #0
	beq	.L27
	ldr	r3, .L36+52
	ldr	r3, [r3]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	mov	r3, r0
	cmp	r3, #0
	bne	.L28
	ldr	r0, .L36+60
	bl	puts
	b	.L27
.L28:
	ldr	r0, .L36+64
	bl	perror
.L27:
	mov	r1, #2
	ldr	r0, .L36+36
	bl	printf
	ldr	r3, .L36+40
	mov	r2, #2
	str	r2, [r3, #8]
	ldr	r3, .L36+68
	ldr	r2, .L36+48
	mov	r1, #0
	ldr	r0, .L36+72
	bl	pthread_create
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	beq	.L29
	ldr	r1, [fp, #-8]
	ldr	r0, .L36+56
	bl	printf
	mov	r0, #0
	bl	perror
	mvn	r0, #0
	bl	exit
.L29:
	ldr	r0, .L36+76
	bl	puts
	ldr	r3, [fp, #-12]
	cmp	r3, #0
	bne	.L30
	ldr	r3, .L36+52
	ldr	r3, [r3]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	mov	r3, r0
	cmp	r3, #0
	bne	.L31
	ldr	r0, .L36+60
	bl	puts
	b	.L30
.L31:
	ldr	r0, .L36+64
	bl	perror
.L30:
	ldr	r3, .L36+52
	ldr	r3, [r3, #4]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	mov	r3, r0
	cmp	r3, #0
	bne	.L32
	ldr	r0, .L36+80
	bl	puts
	b	.L33
.L32:
	ldr	r0, .L36+84
	bl	perror
.L33:
	ldr	r0, .L36+28
	bl	pthread_mutex_destroy
	mov	r3, r0
	cmp	r3, #0
	beq	.L34
	ldr	r0, .L36+88
	bl	perror
.L34:
	ldr	r0, .L36+32
	bl	pthread_mutex_destroy
	mov	r3, r0
	cmp	r3, #0
	beq	.L35
	ldr	r0, .L36+92
	bl	perror
.L35:
	ldr	r0, .L36+96
	bl	puts
	mov	r0, #0
	bl	exit
.L37:
	.align	2
.L36:
	.word	rsrcACnt
	.word	rsrcBCnt
	.word	noWait
	.word	.LC21
	.word	.LC22
	.word	.LC23
	.word	.LC24
	.word	rsrcA
	.word	rsrcB
	.word	.LC25
	.word	threadParams
	.word	threadParams+4
	.word	grabRsrcs
	.word	threads
	.word	.LC26
	.word	.LC27
	.word	.LC28
	.word	threadParams+8
	.word	threads+4
	.word	.LC29
	.word	.LC30
	.word	.LC31
	.word	.LC32
	.word	.LC33
	.word	.LC34
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
