	.file	"848321.c"
	.intel_syntax noprefix
	.text
	.globl	mutex
	.bss
	.align 32
	.type	mutex, @object
	.size	mutex, 40
mutex:
	.zero	40
	.globl	NorthQueue
	.align 32
	.type	NorthQueue, @object
	.size	NorthQueue, 48
NorthQueue:
	.zero	48
	.globl	EastQueue
	.align 32
	.type	EastQueue, @object
	.size	EastQueue, 48
EastQueue:
	.zero	48
	.globl	SouthQueue
	.align 32
	.type	SouthQueue, @object
	.size	SouthQueue, 48
SouthQueue:
	.zero	48
	.globl	WestQueue
	.align 32
	.type	WestQueue, @object
	.size	WestQueue, 48
WestQueue:
	.zero	48
	.globl	NorthFirst
	.align 32
	.type	NorthFirst, @object
	.size	NorthFirst, 48
NorthFirst:
	.zero	48
	.globl	EastFirst
	.align 32
	.type	EastFirst, @object
	.size	EastFirst, 48
EastFirst:
	.zero	48
	.globl	SouthFirst
	.align 32
	.type	SouthFirst, @object
	.size	SouthFirst, 48
SouthFirst:
	.zero	48
	.globl	WestFirst
	.align 32
	.type	WestFirst, @object
	.size	WestFirst, 48
WestFirst:
	.zero	48
	.globl	total
	.align 4
	.type	total, @object
	.size	total, 4
total:
	.zero	4
	.globl	northBat
	.align 4
	.type	northBat, @object
	.size	northBat, 4
northBat:
	.zero	4
	.globl	southBat
	.align 4
	.type	southBat, @object
	.size	southBat, 4
southBat:
	.zero	4
	.globl	westBat
	.align 4
	.type	westBat, @object
	.size	westBat, 4
westBat:
	.zero	4
	.globl	eastBat
	.align 4
	.type	eastBat, @object
	.size	eastBat, 4
eastBat:
	.zero	4
	.globl	dir
	.data
	.align 16
	.type	dir, @object
	.size	dir, 24
dir:
	.string	"North"
	.string	"East"
	.zero	1
	.string	"South"
	.string	"West"
	.zero	1
	.globl	directions
	.bss
	.align 32
	.type	directions, @object
	.size	directions, 100
directions:
	.zero	100
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	push	r15
	push	r14
	push	r13
	push	r12
	push	rbx
	sub	rsp, 152
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	mov	DWORD PTR -132[rbp], edi
	mov	QWORD PTR -144[rbp], rsi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -56[rbp], rax
	xor	eax, eax
	mov	rax, rsp
	mov	QWORD PTR -184[rbp], rax
	mov	rax, QWORD PTR -144[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, directions[rip]
	call	strcpy@PLT
	lea	rdi, directions[rip]
	call	strlen@PLT
	mov	rdx, rax
	sub	rdx, 1
	mov	QWORD PTR -112[rbp], rdx
	mov	QWORD PTR -160[rbp], rax
	mov	QWORD PTR -152[rbp], 0
	mov	QWORD PTR -176[rbp], rax
	mov	QWORD PTR -168[rbp], 0
	lea	rdx, 0[0+rax*8]
	mov	eax, 16
	sub	rax, 1
	add	rax, rdx
	mov	ebx, 16
	mov	edx, 0
	div	rbx
	imul	rax, rax, 16
	mov	rcx, rax
	and	rcx, -4096
	mov	rdx, rsp
	sub	rdx, rcx
.L2:
	cmp	rsp, rdx
	je	.L3
	sub	rsp, 4096
	or	QWORD PTR 4088[rsp], 0
	jmp	.L2
.L3:
	mov	rdx, rax
	and	edx, 4095
	sub	rsp, rdx
	mov	rdx, rax
	and	edx, 4095
	test	rdx, rdx
	je	.L4
	and	eax, 4095
	sub	rax, 8
	add	rax, rsp
	or	QWORD PTR [rax], 0
.L4:
	mov	rax, rsp
	add	rax, 7
	shr	rax, 3
	sal	rax, 3
	mov	QWORD PTR -104[rbp], rax
	lea	rdi, directions[rip]
	call	strlen@PLT
	mov	rcx, rax
	mov	rax, rcx
	sub	rax, 1
	mov	QWORD PTR -96[rbp], rax
	mov	r14, rcx
	mov	r15d, 0
	imul	rdx, r15, 96
	imul	rax, r14, 0
	lea	rsi, [rdx+rax]
	mov	eax, 96
	mul	r14
	add	rsi, rdx
	mov	rdx, rsi
	mov	rax, rcx
	add	rax, rax
	add	rax, rcx
	sal	rax, 2
	mov	r12, rcx
	mov	r13d, 0
	imul	rdx, r13, 96
	imul	rax, r12, 0
	lea	rsi, [rdx+rax]
	mov	eax, 96
	mul	r12
	add	rsi, rdx
	mov	rdx, rsi
	mov	rax, rcx
	add	rax, rax
	add	rax, rcx
	sal	rax, 2
	mov	rdx, rax
	mov	eax, 16
	sub	rax, 1
	add	rax, rdx
	mov	ebx, 16
	mov	edx, 0
	div	rbx
	imul	rax, rax, 16
	mov	rcx, rax
	and	rcx, -4096
	mov	rdx, rsp
	sub	rdx, rcx
.L5:
	cmp	rsp, rdx
	je	.L6
	sub	rsp, 4096
	or	QWORD PTR 4088[rsp], 0
	jmp	.L5
.L6:
	mov	rdx, rax
	and	edx, 4095
	sub	rsp, rdx
	mov	rdx, rax
	and	edx, 4095
	test	rdx, rdx
	je	.L7
	and	eax, 4095
	sub	rax, 8
	add	rax, rsp
	or	QWORD PTR [rax], 0
.L7:
	mov	rax, rsp
	add	rax, 3
	shr	rax, 2
	sal	rax, 2
	mov	QWORD PTR -88[rbp], rax
	mov	DWORD PTR -116[rbp], 0
	jmp	.L8
.L13:
	mov	eax, DWORD PTR -116[rbp]
	add	eax, 1
	mov	DWORD PTR -68[rbp], eax
	mov	eax, DWORD PTR -116[rbp]
	cdqe
	lea	rdx, directions[rip]
	movzx	eax, BYTE PTR [rax+rdx]
	cmp	al, 110
	jne	.L9
	mov	DWORD PTR -64[rbp], 0
.L9:
	mov	eax, DWORD PTR -116[rbp]
	cdqe
	lea	rdx, directions[rip]
	movzx	eax, BYTE PTR [rax+rdx]
	cmp	al, 101
	jne	.L10
	mov	DWORD PTR -64[rbp], 1
.L10:
	mov	eax, DWORD PTR -116[rbp]
	cdqe
	lea	rdx, directions[rip]
	movzx	eax, BYTE PTR [rax+rdx]
	cmp	al, 115
	jne	.L11
	mov	DWORD PTR -64[rbp], 2
.L11:
	mov	eax, DWORD PTR -116[rbp]
	cdqe
	lea	rdx, directions[rip]
	movzx	eax, BYTE PTR [rax+rdx]
	cmp	al, 119
	jne	.L12
	mov	DWORD PTR -64[rbp], 3
.L12:
	mov	eax, DWORD PTR -64[rbp]
	add	eax, 3
	cdq
	shr	edx, 30
	add	eax, edx
	and	eax, 3
	sub	eax, edx
	mov	DWORD PTR -60[rbp], eax
	mov	rcx, QWORD PTR -88[rbp]
	mov	eax, DWORD PTR -116[rbp]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	sal	rax, 2
	add	rax, rcx
	mov	rdx, QWORD PTR -68[rbp]
	mov	QWORD PTR [rax], rdx
	mov	edx, DWORD PTR -60[rbp]
	mov	DWORD PTR 8[rax], edx
	add	DWORD PTR -116[rbp], 1
.L8:
	mov	eax, DWORD PTR -116[rbp]
	movsx	rbx, eax
	lea	rdi, directions[rip]
	call	strlen@PLT
	cmp	rbx, rax
	jb	.L13
	mov	DWORD PTR -120[rbp], 0
	jmp	.L14
.L15:
	mov	eax, DWORD PTR -120[rbp]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	sal	rax, 2
	mov	rdx, QWORD PTR -88[rbp]
	add	rax, rdx
	mov	QWORD PTR -80[rbp], rax
	mov	eax, DWORD PTR -120[rbp]
	cdqe
	lea	rdx, 0[0+rax*8]
	mov	rax, QWORD PTR -104[rbp]
	lea	rdi, [rdx+rax]
	mov	rax, QWORD PTR -80[rbp]
	mov	rcx, rax
	lea	rdx, BatStart[rip]
	mov	esi, 0
	call	pthread_create@PLT
	add	DWORD PTR -120[rbp], 1
.L14:
	mov	eax, DWORD PTR -120[rbp]
	movsx	rbx, eax
	lea	rdi, directions[rip]
	call	strlen@PLT
	cmp	rbx, rax
	jb	.L15
	mov	DWORD PTR -124[rbp], 0
	jmp	.L16
.L17:
	mov	rax, QWORD PTR -104[rbp]
	mov	edx, DWORD PTR -124[rbp]
	movsx	rdx, edx
	mov	rax, QWORD PTR [rax+rdx*8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	add	DWORD PTR -124[rbp], 1
.L16:
	mov	eax, DWORD PTR -124[rbp]
	movsx	rbx, eax
	lea	rdi, directions[rip]
	call	strlen@PLT
	cmp	rbx, rax
	jb	.L17
	mov	eax, 0
	mov	rsp, QWORD PTR -184[rbp]
	mov	rbx, QWORD PTR -56[rbp]
	sub	rbx, QWORD PTR fs:40
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	lea	rsp, -40[rbp]
	pop	rbx
	pop	r12
	pop	r13
	pop	r14
	pop	r15
	pop	rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	BatStart
	.type	BatStart, @function
BatStart:
.LFB1:
	.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	QWORD PTR -24[rbp], rdi
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR -8[rbp], rax
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	check
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	doRest
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	BatStart, .-BatStart
	.globl	doRest
	.type	doRest, @function
doRest:
.LFB2:
	.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	QWORD PTR -24[rbp], rdi
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR -8[rbp], rax
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	arrive
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	cross
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	leave
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	doRest, .-doRest
	.section	.rodata
	.align 8
.LC0:
	.string	"BAT %i from %s arrives at crossing\n"
	.text
	.globl	arrive
	.type	arrive, @function
arrive:
.LFB3:
	.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	QWORD PTR -24[rbp], rdi
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR -8[rbp], rax
	lea	rdi, mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	test	eax, eax
	jne	.L23
	mov	eax, DWORD PTR northBat[rip]
	add	eax, 1
	mov	DWORD PTR northBat[rip], eax
	mov	eax, DWORD PTR northBat[rip]
	cmp	eax, 1
	jle	.L23
	lea	rsi, mutex[rip]
	lea	rdi, NorthQueue[rip]
	call	pthread_cond_wait@PLT
.L23:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 1
	jne	.L24
	mov	eax, DWORD PTR eastBat[rip]
	add	eax, 1
	mov	DWORD PTR eastBat[rip], eax
	mov	eax, DWORD PTR eastBat[rip]
	cmp	eax, 1
	jle	.L24
	lea	rsi, mutex[rip]
	lea	rdi, EastQueue[rip]
	call	pthread_cond_wait@PLT
.L24:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 2
	jne	.L25
	mov	eax, DWORD PTR southBat[rip]
	add	eax, 1
	mov	DWORD PTR southBat[rip], eax
	mov	eax, DWORD PTR southBat[rip]
	cmp	eax, 1
	jle	.L25
	lea	rsi, mutex[rip]
	lea	rdi, SouthQueue[rip]
	call	pthread_cond_wait@PLT
.L25:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 3
	jne	.L26
	mov	eax, DWORD PTR westBat[rip]
	add	eax, 1
	mov	DWORD PTR westBat[rip], eax
	mov	eax, DWORD PTR westBat[rip]
	cmp	eax, 1
	jle	.L26
	lea	rsi, mutex[rip]
	lea	rdi, WestQueue[rip]
	call	pthread_cond_wait@PLT
.L26:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	add	rax, rax
	lea	rdx, dir[rip]
	add	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC0[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR total[rip]
	add	eax, 1
	mov	DWORD PTR total[rip], eax
	lea	rdi, mutex[rip]
	call	pthread_mutex_unlock@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	arrive, .-arrive
	.section	.rodata
.LC1:
	.string	"BAT %i from %s crosses\n"
	.text
	.globl	cross
	.type	cross, @function
cross:
.LFB4:
	.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	QWORD PTR -24[rbp], rdi
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR -8[rbp], rax
	lea	rdi, mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	add	rax, rax
	lea	rdx, dir[rip]
	add	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC1[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 8[rax]
	test	eax, eax
	jne	.L28
	mov	eax, DWORD PTR northBat[rip]
	test	eax, eax
	jle	.L28
	lea	rsi, mutex[rip]
	lea	rdi, NorthFirst[rip]
	call	pthread_cond_wait@PLT
.L28:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 8[rax]
	cmp	eax, 1
	jne	.L29
	mov	eax, DWORD PTR eastBat[rip]
	test	eax, eax
	jle	.L29
	lea	rsi, mutex[rip]
	lea	rdi, EastFirst[rip]
	call	pthread_cond_wait@PLT
.L29:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 8[rax]
	cmp	eax, 2
	jne	.L30
	mov	eax, DWORD PTR southBat[rip]
	test	eax, eax
	jle	.L30
	lea	rsi, mutex[rip]
	lea	rdi, SouthFirst[rip]
	call	pthread_cond_wait@PLT
.L30:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 8[rax]
	cmp	eax, 3
	jne	.L31
	mov	eax, DWORD PTR eastBat[rip]
	test	eax, eax
	jle	.L31
	lea	rsi, mutex[rip]
	lea	rdi, WestFirst[rip]
	call	pthread_cond_wait@PLT
.L31:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	test	eax, eax
	jne	.L32
	mov	eax, DWORD PTR northBat[rip]
	sub	eax, 1
	mov	DWORD PTR northBat[rip], eax
	mov	edi, 1
	call	sleep@PLT
	lea	rdi, NorthQueue[rip]
	call	pthread_cond_signal@PLT
.L32:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 1
	jne	.L33
	mov	eax, DWORD PTR eastBat[rip]
	sub	eax, 1
	mov	DWORD PTR eastBat[rip], eax
	mov	edi, 1
	call	sleep@PLT
	lea	rdi, EastQueue[rip]
	call	pthread_cond_signal@PLT
.L33:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 2
	jne	.L34
	mov	eax, DWORD PTR southBat[rip]
	sub	eax, 1
	mov	DWORD PTR southBat[rip], eax
	mov	edi, 1
	call	sleep@PLT
	lea	rdi, SouthQueue[rip]
	call	pthread_cond_signal@PLT
.L34:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 3
	jne	.L35
	mov	eax, DWORD PTR westBat[rip]
	sub	eax, 1
	mov	DWORD PTR westBat[rip], eax
	mov	edi, 1
	call	sleep@PLT
	lea	rdi, WestQueue[rip]
	call	pthread_cond_signal@PLT
.L35:
	mov	eax, DWORD PTR total[rip]
	sub	eax, 1
	mov	DWORD PTR total[rip], eax
	lea	rdi, mutex[rip]
	call	pthread_mutex_unlock@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	cross, .-cross
	.section	.rodata
	.align 8
.LC2:
	.string	"BAT %i from %s leaving crossing\n"
	.text
	.globl	leave
	.type	leave, @function
leave:
.LFB5:
	.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	QWORD PTR -24[rbp], rdi
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR -8[rbp], rax
	lea	rdi, mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	test	eax, eax
	jne	.L37
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	add	rax, rax
	lea	rdx, dir[rip]
	add	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, NorthFirst[rip]
	call	pthread_cond_signal@PLT
.L37:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 1
	jne	.L38
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	add	rax, rax
	lea	rdx, dir[rip]
	add	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, EastFirst[rip]
	call	pthread_cond_signal@PLT
.L38:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 2
	jne	.L39
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	add	rax, rax
	lea	rdx, dir[rip]
	add	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, SouthFirst[rip]
	call	pthread_cond_signal@PLT
.L39:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 3
	jne	.L40
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	movsx	rdx, eax
	mov	rax, rdx
	add	rax, rax
	add	rax, rdx
	add	rax, rax
	lea	rdx, dir[rip]
	add	rdx, rax
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, WestFirst[rip]
	call	pthread_cond_signal@PLT
.L40:
	lea	rdi, mutex[rip]
	call	pthread_mutex_unlock@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE5:
	.size	leave, .-leave
	.section	.rodata
	.align 8
.LC3:
	.string	"DEADLOCK: BAT jam detected, signalling North to go"
	.align 8
.LC4:
	.string	"DEADLOCK: BAT jam detected, signalling East to go"
	.align 8
.LC5:
	.string	"DEADLOCK: BAT jam detected, signalling South to go"
	.align 8
.LC6:
	.string	"DEADLOCK: BAT jam detected, signalling West to go"
	.text
	.globl	check
	.type	check, @function
check:
.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, 32
	mov	QWORD PTR -24[rbp], rdi
	mov	rax, QWORD PTR -24[rbp]
	mov	QWORD PTR -8[rbp], rax
	lea	rdi, mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	eax, DWORD PTR total[rip]
	cmp	eax, 4
	jne	.L42
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	test	eax, eax
	jne	.L43
	lea	rdi, .LC3[rip]
	call	puts@PLT
	lea	rdi, NorthFirst[rip]
	call	pthread_cond_signal@PLT
.L43:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 1
	jne	.L44
	lea	rdi, .LC4[rip]
	call	puts@PLT
	lea	rdi, EastFirst[rip]
	call	pthread_cond_signal@PLT
.L44:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 2
	jne	.L45
	lea	rdi, .LC5[rip]
	call	puts@PLT
	lea	rdi, SouthFirst[rip]
	call	pthread_cond_signal@PLT
.L45:
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 4[rax]
	cmp	eax, 3
	jne	.L42
	lea	rdi, .LC6[rip]
	call	puts@PLT
	lea	rdi, WestFirst[rip]
	call	pthread_cond_signal@PLT
.L42:
	lea	rdi, mutex[rip]
	call	pthread_mutex_unlock@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	check, .-check
	.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	"848321.c"
	.text
	.comm	mutex,24,4
	.comm	NorthQueue,48,8
	.comm	EastQueue,48,8
	.comm	SouthQueue,48,8
	.comm	WestQueue,48,8
	.comm	NorthFirst,48,8
	.comm	EastFirst,48,8
	.comm	SouthFirst,48,8
	.comm	WestFirst,48,8
	.global	total
	.bss
	.align	2
	.type	total, %object
	.size	total, 4
total:
	.space	4
	.global	northBat
	.align	2
	.type	northBat, %object
	.size	northBat, 4
northBat:
	.space	4
	.global	southBat
	.align	2
	.type	southBat, %object
	.size	southBat, 4
southBat:
	.space	4
	.global	westBat
	.align	2
	.type	westBat, %object
	.size	westBat, 4
westBat:
	.space	4
	.global	eastBat
	.align	2
	.type	eastBat, %object
	.size	eastBat, 4
eastBat:
	.space	4
	.global	dir
	.data
	.align	2
	.type	dir, %object
	.size	dir, 24
dir:
	.ascii	"North\000"
	.ascii	"East\000"
	.space	1
	.ascii	"South\000"
	.ascii	"West\000"
	.space	1
	.comm	directions,100,4
	.section	.rodata
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 56
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, fp, lr}
	add	fp, sp, #24
	sub	sp, sp, #60
	str	r0, [fp, #-80]
	str	r1, [fp, #-84]
	ldr	r3, .L14
	ldr	r3, [r3]
	str	r3, [fp, #-32]
	mov	r3,#0
	mov	r3, sp
	mov	r8, r3
	ldr	r3, [fp, #-84]
	add	r3, r3, #4
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L14+4
	bl	strcpy
	ldr	r0, .L14+4
	bl	strlen
	mov	ip, r0
	mov	r3, ip
	sub	r3, r3, #1
	str	r3, [fp, #-64]
	mov	r0, ip
	mov	r1, #0
	mov	r2, #0
	mov	r3, #0
	lsl	r3, r1, #5
	orr	r3, r3, r0, lsr #27
	lsl	r2, r0, #5
	mov	r0, ip
	mov	r1, #0
	mov	r2, #0
	mov	r3, #0
	lsl	r3, r1, #5
	orr	r3, r3, r0, lsr #27
	lsl	r2, r0, #5
	lsl	r3, ip, #2
	add	r3, r3, #7
	lsr	r3, r3, #3
	lsl	r3, r3, #3
	sub	sp, sp, r3
	mov	r3, sp
	add	r3, r3, #3
	lsr	r3, r3, #2
	lsl	r3, r3, #2
	str	r3, [fp, #-60]
	ldr	r0, .L14+4
	bl	strlen
	mov	ip, r0
	mov	r3, ip
	sub	r3, r3, #1
	str	r3, [fp, #-56]
	mov	r0, ip
	mov	r1, #0
	mov	r2, r0
	mov	r3, r1
	adds	r6, r2, r2
	adc	r7, r3, r3
	mov	r2, r6
	mov	r3, r7
	adds	r2, r2, r0
	adc	r3, r3, r1
	mov	r0, #0
	mov	r1, #0
	lsl	r1, r3, #5
	orr	r1, r1, r2, lsr #27
	lsl	r0, r2, #5
	mov	r2, r0
	mov	r3, r1
	mov	r3, ip
	lsl	r3, r3, #1
	add	r3, r3, ip
	lsl	r3, r3, #2
	mov	r0, ip
	mov	r1, #0
	mov	r2, r0
	mov	r3, r1
	adds	r4, r2, r2
	adc	r5, r3, r3
	mov	r2, r4
	mov	r3, r5
	adds	r2, r2, r0
	adc	r3, r3, r1
	mov	r0, #0
	mov	r1, #0
	lsl	r1, r3, #5
	orr	r1, r1, r2, lsr #27
	lsl	r0, r2, #5
	mov	r2, r0
	mov	r3, r1
	mov	r3, ip
	lsl	r3, r3, #1
	add	r3, r3, ip
	lsl	r3, r3, #2
	add	r3, r3, #7
	lsr	r3, r3, #3
	lsl	r3, r3, #3
	sub	sp, sp, r3
	mov	r3, sp
	add	r3, r3, #3
	lsr	r3, r3, #2
	lsl	r3, r3, #2
	str	r3, [fp, #-52]
	mov	r3, #0
	str	r3, [fp, #-68]
	b	.L2
.L7:
	ldr	r3, [fp, #-68]
	add	r3, r3, #1
	str	r3, [fp, #-44]
	ldr	r2, .L14+4
	ldr	r3, [fp, #-68]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	cmp	r3, #110
	bne	.L3
	mov	r3, #0
	str	r3, [fp, #-40]
.L3:
	ldr	r2, .L14+4
	ldr	r3, [fp, #-68]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	cmp	r3, #101
	bne	.L4
	mov	r3, #1
	str	r3, [fp, #-40]
.L4:
	ldr	r2, .L14+4
	ldr	r3, [fp, #-68]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	cmp	r3, #115
	bne	.L5
	mov	r3, #2
	str	r3, [fp, #-40]
.L5:
	ldr	r2, .L14+4
	ldr	r3, [fp, #-68]
	add	r3, r2, r3
	ldrb	r3, [r3]	@ zero_extendqisi2
	cmp	r3, #119
	bne	.L6
	mov	r3, #3
	str	r3, [fp, #-40]
.L6:
	ldr	r3, [fp, #-40]
	add	r3, r3, #3
	rsbs	r2, r3, #0
	and	r3, r3, #3
	and	r2, r2, #3
	rsbpl	r3, r2, #0
	str	r3, [fp, #-36]
	ldr	r1, [fp, #-52]
	ldr	r2, [fp, #-68]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #2
	add	r3, r1, r3
	mov	ip, r3
	sub	r3, fp, #44
	ldm	r3, {r0, r1, r2}
	stm	ip, {r0, r1, r2}
	ldr	r3, [fp, #-68]
	add	r3, r3, #1
	str	r3, [fp, #-68]
.L2:
	ldr	r0, .L14+4
	bl	strlen
	mov	r2, r0
	ldr	r3, [fp, #-68]
	cmp	r2, r3
	bhi	.L7
	mov	r3, #0
	str	r3, [fp, #-72]
	b	.L8
.L9:
	ldr	r2, [fp, #-72]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #2
	ldr	r2, [fp, #-52]
	add	r3, r2, r3
	str	r3, [fp, #-48]
	ldr	r3, [fp, #-72]
	lsl	r3, r3, #2
	ldr	r2, [fp, #-60]
	add	r0, r2, r3
	ldr	r3, [fp, #-48]
	ldr	r2, .L14+8
	mov	r1, #0
	bl	pthread_create
	ldr	r3, [fp, #-72]
	add	r3, r3, #1
	str	r3, [fp, #-72]
.L8:
	ldr	r0, .L14+4
	bl	strlen
	mov	r2, r0
	ldr	r3, [fp, #-72]
	cmp	r2, r3
	bhi	.L9
	mov	r3, #0
	str	r3, [fp, #-76]
	b	.L10
.L11:
	ldr	r3, [fp, #-60]
	ldr	r2, [fp, #-76]
	ldr	r3, [r3, r2, lsl #2]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	ldr	r3, [fp, #-76]
	add	r3, r3, #1
	str	r3, [fp, #-76]
.L10:
	ldr	r0, .L14+4
	bl	strlen
	mov	r2, r0
	ldr	r3, [fp, #-76]
	cmp	r2, r3
	bhi	.L11
	mov	r3, #0
	mov	sp, r8
	ldr	r2, .L14
	ldr	r1, [r2]
	ldr	r2, [fp, #-32]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L13
	bl	__stack_chk_fail
.L13:
	mov	r0, r3
	sub	sp, fp, #24
	@ sp needed
	pop	{r4, r5, r6, r7, r8, fp, pc}
.L15:
	.align	2
.L14:
	.word	.LC0
	.word	directions
	.word	BatStart
	.size	main, .-main
	.align	2
	.global	BatStart
	.syntax unified
	.arm
	.fpu softvfp
	.type	BatStart, %function
BatStart:
	@ 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]
	ldr	r3, [fp, #-16]
	str	r3, [fp, #-8]
	ldr	r0, [fp, #-8]
	bl	check
	ldr	r0, [fp, #-8]
	bl	doRest
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	BatStart, .-BatStart
	.align	2
	.global	doRest
	.syntax unified
	.arm
	.fpu softvfp
	.type	doRest, %function
doRest:
	@ 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]
	ldr	r3, [fp, #-16]
	str	r3, [fp, #-8]
	ldr	r0, [fp, #-8]
	bl	arrive
	ldr	r0, [fp, #-8]
	bl	cross
	ldr	r0, [fp, #-8]
	bl	leave
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	doRest, .-doRest
	.section	.rodata
	.align	2
.LC1:
	.ascii	"BAT %i from %s arrives at crossing\012\000"
	.text
	.align	2
	.global	arrive
	.syntax unified
	.arm
	.fpu softvfp
	.type	arrive, %function
arrive:
	@ 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]
	ldr	r3, [fp, #-16]
	str	r3, [fp, #-8]
	ldr	r0, .L23
	bl	pthread_mutex_lock
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #0
	bne	.L19
	ldr	r3, .L23+4
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L23+4
	str	r3, [r2]
	ldr	r3, .L23+4
	ldr	r3, [r3]
	cmp	r3, #1
	ble	.L19
	ldr	r1, .L23
	ldr	r0, .L23+8
	bl	pthread_cond_wait
.L19:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #1
	bne	.L20
	ldr	r3, .L23+12
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L23+12
	str	r3, [r2]
	ldr	r3, .L23+12
	ldr	r3, [r3]
	cmp	r3, #1
	ble	.L20
	ldr	r1, .L23
	ldr	r0, .L23+16
	bl	pthread_cond_wait
.L20:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #2
	bne	.L21
	ldr	r3, .L23+20
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L23+20
	str	r3, [r2]
	ldr	r3, .L23+20
	ldr	r3, [r3]
	cmp	r3, #1
	ble	.L21
	ldr	r1, .L23
	ldr	r0, .L23+24
	bl	pthread_cond_wait
.L21:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #3
	bne	.L22
	ldr	r3, .L23+28
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L23+28
	str	r3, [r2]
	ldr	r3, .L23+28
	ldr	r3, [r3]
	cmp	r3, #1
	ble	.L22
	ldr	r1, .L23
	ldr	r0, .L23+32
	bl	pthread_cond_wait
.L22:
	ldr	r3, [fp, #-8]
	ldr	r1, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3, #4]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #1
	ldr	r2, .L23+36
	add	r3, r3, r2
	mov	r2, r3
	ldr	r0, .L23+40
	bl	printf
	ldr	r3, .L23+44
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L23+44
	str	r3, [r2]
	ldr	r0, .L23
	bl	pthread_mutex_unlock
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L24:
	.align	2
.L23:
	.word	mutex
	.word	northBat
	.word	NorthQueue
	.word	eastBat
	.word	EastQueue
	.word	southBat
	.word	SouthQueue
	.word	westBat
	.word	WestQueue
	.word	dir
	.word	.LC1
	.word	total
	.size	arrive, .-arrive
	.section	.rodata
	.align	2
.LC2:
	.ascii	"BAT %i from %s crosses\012\000"
	.text
	.align	2
	.global	cross
	.syntax unified
	.arm
	.fpu softvfp
	.type	cross, %function
cross:
	@ 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]
	ldr	r3, [fp, #-16]
	str	r3, [fp, #-8]
	ldr	r0, .L34
	bl	pthread_mutex_lock
	ldr	r3, [fp, #-8]
	ldr	r1, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3, #4]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #1
	ldr	r2, .L34+4
	add	r3, r3, r2
	mov	r2, r3
	ldr	r0, .L34+8
	bl	printf
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	cmp	r3, #0
	bne	.L26
	ldr	r3, .L34+12
	ldr	r3, [r3]
	cmp	r3, #0
	ble	.L26
	ldr	r1, .L34
	ldr	r0, .L34+16
	bl	pthread_cond_wait
.L26:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	cmp	r3, #1
	bne	.L27
	ldr	r3, .L34+20
	ldr	r3, [r3]
	cmp	r3, #0
	ble	.L27
	ldr	r1, .L34
	ldr	r0, .L34+24
	bl	pthread_cond_wait
.L27:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	cmp	r3, #2
	bne	.L28
	ldr	r3, .L34+28
	ldr	r3, [r3]
	cmp	r3, #0
	ble	.L28
	ldr	r1, .L34
	ldr	r0, .L34+32
	bl	pthread_cond_wait
.L28:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #8]
	cmp	r3, #3
	bne	.L29
	ldr	r3, .L34+20
	ldr	r3, [r3]
	cmp	r3, #0
	ble	.L29
	ldr	r1, .L34
	ldr	r0, .L34+36
	bl	pthread_cond_wait
.L29:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #0
	bne	.L30
	ldr	r3, .L34+12
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L34+12
	str	r3, [r2]
	mov	r0, #1
	bl	sleep
	ldr	r0, .L34+40
	bl	pthread_cond_signal
.L30:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #1
	bne	.L31
	ldr	r3, .L34+20
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L34+20
	str	r3, [r2]
	mov	r0, #1
	bl	sleep
	ldr	r0, .L34+44
	bl	pthread_cond_signal
.L31:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #2
	bne	.L32
	ldr	r3, .L34+28
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L34+28
	str	r3, [r2]
	mov	r0, #1
	bl	sleep
	ldr	r0, .L34+48
	bl	pthread_cond_signal
.L32:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #3
	bne	.L33
	ldr	r3, .L34+52
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L34+52
	str	r3, [r2]
	mov	r0, #1
	bl	sleep
	ldr	r0, .L34+56
	bl	pthread_cond_signal
.L33:
	ldr	r3, .L34+60
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L34+60
	str	r3, [r2]
	ldr	r0, .L34
	bl	pthread_mutex_unlock
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L35:
	.align	2
.L34:
	.word	mutex
	.word	dir
	.word	.LC2
	.word	northBat
	.word	NorthFirst
	.word	eastBat
	.word	EastFirst
	.word	southBat
	.word	SouthFirst
	.word	WestFirst
	.word	NorthQueue
	.word	EastQueue
	.word	SouthQueue
	.word	westBat
	.word	WestQueue
	.word	total
	.size	cross, .-cross
	.section	.rodata
	.align	2
.LC3:
	.ascii	"BAT %i from %s leaving crossing\012\000"
	.text
	.align	2
	.global	leave
	.syntax unified
	.arm
	.fpu softvfp
	.type	leave, %function
leave:
	@ 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]
	ldr	r3, [fp, #-16]
	str	r3, [fp, #-8]
	ldr	r0, .L41
	bl	pthread_mutex_lock
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #0
	bne	.L37
	ldr	r3, [fp, #-8]
	ldr	r1, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3, #4]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #1
	ldr	r2, .L41+4
	add	r3, r3, r2
	mov	r2, r3
	ldr	r0, .L41+8
	bl	printf
	ldr	r0, .L41+12
	bl	pthread_cond_signal
.L37:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #1
	bne	.L38
	ldr	r3, [fp, #-8]
	ldr	r1, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3, #4]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #1
	ldr	r2, .L41+4
	add	r3, r3, r2
	mov	r2, r3
	ldr	r0, .L41+8
	bl	printf
	ldr	r0, .L41+16
	bl	pthread_cond_signal
.L38:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #2
	bne	.L39
	ldr	r3, [fp, #-8]
	ldr	r1, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3, #4]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #1
	ldr	r2, .L41+4
	add	r3, r3, r2
	mov	r2, r3
	ldr	r0, .L41+8
	bl	printf
	ldr	r0, .L41+20
	bl	pthread_cond_signal
.L39:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #3
	bne	.L40
	ldr	r3, [fp, #-8]
	ldr	r1, [r3]
	ldr	r3, [fp, #-8]
	ldr	r2, [r3, #4]
	mov	r3, r2
	lsl	r3, r3, #1
	add	r3, r3, r2
	lsl	r3, r3, #1
	ldr	r2, .L41+4
	add	r3, r3, r2
	mov	r2, r3
	ldr	r0, .L41+8
	bl	printf
	ldr	r0, .L41+24
	bl	pthread_cond_signal
.L40:
	ldr	r0, .L41
	bl	pthread_mutex_unlock
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L42:
	.align	2
.L41:
	.word	mutex
	.word	dir
	.word	.LC3
	.word	NorthFirst
	.word	EastFirst
	.word	SouthFirst
	.word	WestFirst
	.size	leave, .-leave
	.section	.rodata
	.align	2
.LC4:
	.ascii	"DEADLOCK: BAT jam detected, signalling North to go\000"
	.align	2
.LC5:
	.ascii	"DEADLOCK: BAT jam detected, signalling East to go\000"
	.align	2
.LC6:
	.ascii	"DEADLOCK: BAT jam detected, signalling South to go\000"
	.align	2
.LC7:
	.ascii	"DEADLOCK: BAT jam detected, signalling West to go\000"
	.text
	.align	2
	.global	check
	.syntax unified
	.arm
	.fpu softvfp
	.type	check, %function
check:
	@ 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]
	ldr	r3, [fp, #-16]
	str	r3, [fp, #-8]
	ldr	r0, .L48
	bl	pthread_mutex_lock
	ldr	r3, .L48+4
	ldr	r3, [r3]
	cmp	r3, #4
	bne	.L44
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #0
	bne	.L45
	ldr	r0, .L48+8
	bl	puts
	ldr	r0, .L48+12
	bl	pthread_cond_signal
.L45:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #1
	bne	.L46
	ldr	r0, .L48+16
	bl	puts
	ldr	r0, .L48+20
	bl	pthread_cond_signal
.L46:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #2
	bne	.L47
	ldr	r0, .L48+24
	bl	puts
	ldr	r0, .L48+28
	bl	pthread_cond_signal
.L47:
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #4]
	cmp	r3, #3
	bne	.L44
	ldr	r0, .L48+32
	bl	puts
	ldr	r0, .L48+36
	bl	pthread_cond_signal
.L44:
	ldr	r0, .L48
	bl	pthread_mutex_unlock
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L49:
	.align	2
.L48:
	.word	mutex
	.word	total
	.word	.LC4
	.word	NorthFirst
	.word	.LC5
	.word	EastFirst
	.word	.LC6
	.word	SouthFirst
	.word	.LC7
	.word	WestFirst
	.size	check, .-check
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
