	.file	"206362.c"
	.intel_syntax noprefix
	.text
	.globl	rwlock_init
	.type	rwlock_init, @function
rwlock_init:
.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, 16
	mov	QWORD PTR -8[rbp], rdi
	mov	rax, QWORD PTR -8[rbp]
	mov	DWORD PTR 64[rax], 0
	mov	rax, QWORD PTR -8[rbp]
	add	rax, 32
	mov	edx, 1
	mov	esi, 0
	mov	rdi, rax
	call	sem_init@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	edx, 1
	mov	esi, 0
	mov	rdi, rax
	call	sem_init@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	rwlock_init, .-rwlock_init
	.globl	rwlock_acquire_readlock
	.type	rwlock_acquire_readlock, @function
rwlock_acquire_readlock:
.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, 16
	mov	QWORD PTR -8[rbp], rdi
	mov	rax, QWORD PTR -8[rbp]
	add	rax, 32
	mov	rdi, rax
	call	sem_wait@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 64[rax]
	lea	edx, 1[rax]
	mov	rax, QWORD PTR -8[rbp]
	mov	DWORD PTR 64[rax], edx
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 64[rax]
	test	eax, eax
	jne	.L3
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	sem_wait@PLT
.L3:
	mov	rax, QWORD PTR -8[rbp]
	add	rax, 32
	mov	rdi, rax
	call	sem_post@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	rwlock_acquire_readlock, .-rwlock_acquire_readlock
	.globl	rwlock_release_readlock
	.type	rwlock_release_readlock, @function
rwlock_release_readlock:
.LFB8:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 16
	mov	QWORD PTR -8[rbp], rdi
	mov	rax, QWORD PTR -8[rbp]
	add	rax, 32
	mov	rdi, rax
	call	sem_wait@PLT
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 64[rax]
	lea	edx, -1[rax]
	mov	rax, QWORD PTR -8[rbp]
	mov	DWORD PTR 64[rax], edx
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR 64[rax]
	test	eax, eax
	jne	.L5
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	sem_post@PLT
.L5:
	mov	rax, QWORD PTR -8[rbp]
	add	rax, 32
	mov	rdi, rax
	call	sem_post@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	rwlock_release_readlock, .-rwlock_release_readlock
	.globl	rwlock_acquire_writelock
	.type	rwlock_acquire_writelock, @function
rwlock_acquire_writelock:
.LFB9:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 16
	mov	QWORD PTR -8[rbp], rdi
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	sem_wait@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	rwlock_acquire_writelock, .-rwlock_acquire_writelock
	.globl	rwlock_release_writelock
	.type	rwlock_release_writelock, @function
rwlock_release_writelock:
.LFB10:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 16
	mov	QWORD PTR -8[rbp], rdi
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	sem_post@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	rwlock_release_writelock, .-rwlock_release_writelock
	.globl	mutex
	.bss
	.align 32
	.type	mutex, @object
	.size	mutex, 72
mutex:
	.zero	72
	.globl	writes
	.align 4
	.type	writes, @object
	.size	writes, 4
writes:
	.zero	4
	.section	.rodata
.LC0:
	.string	"reading %d\n"
.LC1:
	.string	"finished reading %d -> %lld\n"
	.text
	.globl	reader
	.type	reader, @function
reader:
.LFB11:
	.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	DWORD PTR -4[rbp], 0
	jmp	.L9
.L10:
	lea	rdi, mutex[rip]
	call	rwlock_acquire_readlock
	mov	eax, DWORD PTR writes[rip]
	mov	DWORD PTR -8[rbp], eax
	mov	eax, DWORD PTR writes[rip]
	mov	esi, eax
	lea	rdi, .LC0[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, mutex[rip]
	call	rwlock_release_readlock
	add	DWORD PTR -4[rbp], 1
.L9:
	cmp	DWORD PTR -4[rbp], 999
	jle	.L10
	mov	rdx, QWORD PTR -24[rbp]
	mov	eax, DWORD PTR -8[rbp]
	mov	esi, eax
	lea	rdi, .LC1[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, 0
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	reader, .-reader
	.section	.rodata
.LC2:
	.string	"writing %d\n"
.LC3:
	.string	"finished writing %d -> %lld\n"
	.text
	.globl	writer
	.type	writer, @function
writer:
.LFB12:
	.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	DWORD PTR -4[rbp], 0
	jmp	.L13
.L14:
	lea	rdi, mutex[rip]
	call	rwlock_acquire_writelock
	mov	eax, DWORD PTR writes[rip]
	lea	edx, 1[rax]
	mov	DWORD PTR writes[rip], edx
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, mutex[rip]
	call	rwlock_release_writelock
	add	DWORD PTR -4[rbp], 1
.L13:
	cmp	DWORD PTR -4[rbp], 999
	jle	.L14
	mov	rdx, QWORD PTR -24[rbp]
	mov	eax, DWORD PTR writes[rip]
	mov	esi, eax
	lea	rdi, .LC3[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, 0
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	writer, .-writer
	.globl	main
	.type	main, @function
main:
.LFB13:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 64
	mov	DWORD PTR -52[rbp], edi
	mov	QWORD PTR -64[rbp], rsi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	lea	rdi, mutex[rip]
	call	rwlock_init
	mov	DWORD PTR -40[rbp], 0
	jmp	.L17
.L20:
	mov	eax, DWORD PTR -40[rbp]
	and	eax, 1
	test	eax, eax
	jne	.L18
	lea	rdx, -32[rbp]
	mov	eax, DWORD PTR -40[rbp]
	cdqe
	sal	rax, 3
	add	rax, rdx
	mov	ecx, 0
	lea	rdx, reader[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	jmp	.L19
.L18:
	lea	rdx, -32[rbp]
	mov	eax, DWORD PTR -40[rbp]
	cdqe
	sal	rax, 3
	add	rax, rdx
	mov	ecx, 0
	lea	rdx, writer[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
.L19:
	add	DWORD PTR -40[rbp], 1
.L17:
	cmp	DWORD PTR -40[rbp], 1
	jle	.L20
	mov	DWORD PTR -36[rbp], 0
	jmp	.L21
.L22:
	mov	eax, DWORD PTR -36[rbp]
	cdqe
	mov	rax, QWORD PTR -32[rbp+rax*8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	add	DWORD PTR -36[rbp], 1
.L21:
	cmp	DWORD PTR -36[rbp], 1
	jle	.L22
	mov	eax, 0
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE13:
	.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	"206362.c"
	.text
	.align	2
	.global	rwlock_init
	.syntax unified
	.arm
	.fpu softvfp
	.type	rwlock_init, %function
rwlock_init:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	mov	r2, #0
	str	r2, [r3, #32]
	ldr	r3, [fp, #-8]
	add	r3, r3, #16
	mov	r2, #1
	mov	r1, #0
	mov	r0, r3
	bl	sem_init
	ldr	r3, [fp, #-8]
	mov	r2, #1
	mov	r1, #0
	mov	r0, r3
	bl	sem_init
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	rwlock_init, .-rwlock_init
	.align	2
	.global	rwlock_acquire_readlock
	.syntax unified
	.arm
	.fpu softvfp
	.type	rwlock_acquire_readlock, %function
rwlock_acquire_readlock:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	add	r3, r3, #16
	mov	r0, r3
	bl	sem_wait
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #32]
	add	r2, r3, #1
	ldr	r3, [fp, #-8]
	str	r2, [r3, #32]
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #32]
	cmp	r3, #0
	bne	.L3
	ldr	r3, [fp, #-8]
	mov	r0, r3
	bl	sem_wait
.L3:
	ldr	r3, [fp, #-8]
	add	r3, r3, #16
	mov	r0, r3
	bl	sem_post
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	rwlock_acquire_readlock, .-rwlock_acquire_readlock
	.align	2
	.global	rwlock_release_readlock
	.syntax unified
	.arm
	.fpu softvfp
	.type	rwlock_release_readlock, %function
rwlock_release_readlock:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	add	r3, r3, #16
	mov	r0, r3
	bl	sem_wait
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #32]
	sub	r2, r3, #1
	ldr	r3, [fp, #-8]
	str	r2, [r3, #32]
	ldr	r3, [fp, #-8]
	ldr	r3, [r3, #32]
	cmp	r3, #0
	bne	.L5
	ldr	r3, [fp, #-8]
	mov	r0, r3
	bl	sem_post
.L5:
	ldr	r3, [fp, #-8]
	add	r3, r3, #16
	mov	r0, r3
	bl	sem_post
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	rwlock_release_readlock, .-rwlock_release_readlock
	.align	2
	.global	rwlock_acquire_writelock
	.syntax unified
	.arm
	.fpu softvfp
	.type	rwlock_acquire_writelock, %function
rwlock_acquire_writelock:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	mov	r0, r3
	bl	sem_wait
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	rwlock_acquire_writelock, .-rwlock_acquire_writelock
	.align	2
	.global	rwlock_release_writelock
	.syntax unified
	.arm
	.fpu softvfp
	.type	rwlock_release_writelock, %function
rwlock_release_writelock:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r3, [fp, #-8]
	mov	r0, r3
	bl	sem_post
	nop
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	rwlock_release_writelock, .-rwlock_release_writelock
	.comm	mutex,36,4
	.comm	writes,4,4
	.section	.rodata
	.align	2
.LC0:
	.ascii	"reading %d\012\000"
	.align	2
.LC1:
	.ascii	"finished reading %d -> %lld\012\000"
	.text
	.align	2
	.global	reader
	.syntax unified
	.arm
	.fpu softvfp
	.type	reader, %function
reader:
	@ 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]
	mov	r3, #0
	str	r3, [fp, #-8]
	b	.L9
.L10:
	ldr	r0, .L12
	bl	rwlock_acquire_readlock
	ldr	r3, .L12+4
	ldr	r3, [r3]
	str	r3, [fp, #-12]
	ldr	r3, .L12+4
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L12+8
	bl	printf
	ldr	r0, .L12
	bl	rwlock_release_readlock
	ldr	r3, [fp, #-8]
	add	r3, r3, #1
	str	r3, [fp, #-8]
.L9:
	ldr	r3, [fp, #-8]
	cmp	r3, #1000
	blt	.L10
	ldr	r3, [fp, #-16]
	mov	r2, r3
	asr	r3, r2, #31
	ldr	r1, [fp, #-12]
	ldr	r0, .L12+12
	bl	printf
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L13:
	.align	2
.L12:
	.word	mutex
	.word	writes
	.word	.LC0
	.word	.LC1
	.size	reader, .-reader
	.section	.rodata
	.align	2
.LC2:
	.ascii	"writing %d\012\000"
	.align	2
.LC3:
	.ascii	"finished writing %d -> %lld\012\000"
	.text
	.align	2
	.global	writer
	.syntax unified
	.arm
	.fpu softvfp
	.type	writer, %function
writer:
	@ 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]
	mov	r3, #0
	str	r3, [fp, #-8]
	b	.L15
.L16:
	ldr	r0, .L18
	bl	rwlock_acquire_writelock
	ldr	r3, .L18+4
	ldr	r3, [r3]
	add	r2, r3, #1
	ldr	r1, .L18+4
	str	r2, [r1]
	mov	r1, r3
	ldr	r0, .L18+8
	bl	printf
	ldr	r0, .L18
	bl	rwlock_release_writelock
	ldr	r3, [fp, #-8]
	add	r3, r3, #1
	str	r3, [fp, #-8]
.L15:
	ldr	r3, [fp, #-8]
	cmp	r3, #1000
	blt	.L16
	ldr	r3, .L18+4
	ldr	r1, [r3]
	ldr	r3, [fp, #-16]
	mov	r2, r3
	asr	r3, r2, #31
	ldr	r0, .L18+12
	bl	printf
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L19:
	.align	2
.L18:
	.word	mutex
	.word	writes
	.word	.LC2
	.word	.LC3
	.size	writer, .-writer
	.section	.rodata
	.align	2
.LC4:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 32
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #32
	str	r0, [fp, #-32]
	str	r1, [fp, #-36]
	ldr	r3, .L29
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	ldr	r0, .L29+4
	bl	rwlock_init
	mov	r3, #0
	str	r3, [fp, #-24]
	b	.L21
.L24:
	ldr	r3, [fp, #-24]
	and	r3, r3, #1
	cmp	r3, #0
	bne	.L22
	sub	r2, fp, #16
	ldr	r3, [fp, #-24]
	lsl	r3, r3, #2
	add	r0, r2, r3
	mov	r3, #0
	ldr	r2, .L29+8
	mov	r1, #0
	bl	pthread_create
	b	.L23
.L22:
	sub	r2, fp, #16
	ldr	r3, [fp, #-24]
	lsl	r3, r3, #2
	add	r0, r2, r3
	mov	r3, #0
	ldr	r2, .L29+12
	mov	r1, #0
	bl	pthread_create
.L23:
	ldr	r3, [fp, #-24]
	add	r3, r3, #1
	str	r3, [fp, #-24]
.L21:
	ldr	r3, [fp, #-24]
	cmp	r3, #1
	ble	.L24
	mov	r3, #0
	str	r3, [fp, #-20]
	b	.L25
.L26:
	ldr	r3, [fp, #-20]
	lsl	r3, r3, #2
	sub	r2, fp, #4
	add	r3, r2, r3
	ldr	r3, [r3, #-12]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	ldr	r3, [fp, #-20]
	add	r3, r3, #1
	str	r3, [fp, #-20]
.L25:
	ldr	r3, [fp, #-20]
	cmp	r3, #1
	ble	.L26
	mov	r3, #0
	ldr	r2, .L29
	ldr	r1, [r2]
	ldr	r2, [fp, #-8]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L28
	bl	__stack_chk_fail
.L28:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L30:
	.align	2
.L29:
	.word	.LC4
	.word	mutex
	.word	reader
	.word	writer
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
