	.file	"261399.c"
	.intel_syntax noprefix
	.text
	.globl	wrt
	.bss
	.align 32
	.type	wrt, @object
	.size	wrt, 40
wrt:
	.zero	40
	.globl	mutex
	.align 32
	.type	mutex, @object
	.size	mutex, 40
mutex:
	.zero	40
	.globl	shared_value
	.align 4
	.type	shared_value, @object
	.size	shared_value, 4
shared_value:
	.zero	4
	.globl	active_reader
	.align 4
	.type	active_reader, @object
	.size	active_reader, 4
active_reader:
	.zero	4
	.section	.rodata
	.align 8
.LC0:
	.string	"Writer %d modified count to %d\n\n"
	.text
	.globl	writers
	.type	writers, @function
writers:
.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
	lea	rdi, wrt[rip]
	call	pthread_mutex_lock@PLT
	mov	eax, DWORD PTR shared_value[rip]
	add	eax, eax
	mov	DWORD PTR shared_value[rip], eax
	mov	edx, DWORD PTR shared_value[rip]
	mov	rax, QWORD PTR -8[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC0[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, wrt[rip]
	call	pthread_mutex_unlock@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	writers, .-writers
	.section	.rodata
.LC1:
	.string	"Reader %d: is waiting....\n\n"
.LC2:
	.string	"Reader %d: is reading......\n\n"
	.align 8
.LC3:
	.string	"Reader %d: read shared variable as %d\n\n"
	.align 8
.LC4:
	.string	"Number of readers currently present = %d\n\n"
	.text
	.globl	readers
	.type	readers, @function
readers:
.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	QWORD PTR -24[rbp], rdi
	lea	rdi, mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	eax, DWORD PTR active_reader[rip]
	add	eax, 1
	mov	DWORD PTR active_reader[rip], eax
	mov	eax, DWORD PTR active_reader[rip]
	cmp	eax, 1
	jne	.L3
	lea	rdi, wrt[rip]
	call	pthread_mutex_lock@PLT
.L3:
	lea	rdi, mutex[rip]
	call	pthread_mutex_unlock@PLT
	call	rand@PLT
	mov	edx, eax
	movsx	rax, edx
	imul	rax, rax, 1717986919
	shr	rax, 32
	sar	eax, 3
	mov	ecx, edx
	sar	ecx, 31
	sub	eax, ecx
	mov	DWORD PTR -4[rbp], eax
	mov	ecx, DWORD PTR -4[rbp]
	mov	eax, ecx
	sal	eax, 2
	add	eax, ecx
	sal	eax, 2
	sub	edx, eax
	mov	DWORD PTR -4[rbp], edx
	mov	rax, QWORD PTR -24[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC1[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR -4[rbp]
	mov	edi, eax
	call	sleep@PLT
	mov	rax, QWORD PTR -24[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edx, DWORD PTR shared_value[rip]
	mov	rax, QWORD PTR -24[rbp]
	mov	eax, DWORD PTR [rax]
	mov	esi, eax
	lea	rdi, .LC3[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR active_reader[rip]
	mov	esi, eax
	lea	rdi, .LC4[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, mutex[rip]
	call	pthread_mutex_lock@PLT
	mov	eax, DWORD PTR active_reader[rip]
	sub	eax, 1
	mov	DWORD PTR active_reader[rip], eax
	mov	eax, DWORD PTR active_reader[rip]
	test	eax, eax
	jne	.L4
	lea	rdi, wrt[rip]
	call	pthread_mutex_unlock@PLT
.L4:
	lea	rdi, mutex[rip]
	call	pthread_mutex_unlock@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	readers, .-readers
	.section	.rodata
.LC5:
	.string	"Enter the share value: "
.LC6:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.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, 144
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	lea	rdi, .LC5[rip]
	call	puts@PLT
	lea	rsi, shared_value[rip]
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	__isoc99_scanf@PLT
	mov	esi, 0
	lea	rdi, mutex[rip]
	call	pthread_mutex_init@PLT
	mov	esi, 0
	lea	rdi, wrt[rip]
	call	pthread_mutex_init@PLT
	mov	DWORD PTR -128[rbp], 1
	mov	DWORD PTR -124[rbp], 2
	mov	DWORD PTR -120[rbp], 3
	mov	DWORD PTR -116[rbp], 4
	mov	DWORD PTR -112[rbp], 5
	mov	DWORD PTR -144[rbp], 0
	jmp	.L6
.L7:
	lea	rdx, -128[rbp]
	mov	eax, DWORD PTR -144[rbp]
	cdqe
	sal	rax, 2
	add	rdx, rax
	lea	rcx, -96[rbp]
	mov	eax, DWORD PTR -144[rbp]
	cdqe
	sal	rax, 3
	add	rax, rcx
	mov	rcx, rdx
	lea	rdx, readers[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	add	DWORD PTR -144[rbp], 1
.L6:
	cmp	DWORD PTR -144[rbp], 4
	jle	.L7
	mov	DWORD PTR -140[rbp], 0
	jmp	.L8
.L9:
	lea	rdx, -128[rbp]
	mov	eax, DWORD PTR -140[rbp]
	cdqe
	sal	rax, 2
	add	rdx, rax
	lea	rcx, -48[rbp]
	mov	eax, DWORD PTR -140[rbp]
	cdqe
	sal	rax, 3
	add	rax, rcx
	mov	rcx, rdx
	lea	rdx, writers[rip]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_create@PLT
	add	DWORD PTR -140[rbp], 1
.L8:
	cmp	DWORD PTR -140[rbp], 4
	jle	.L9
	mov	DWORD PTR -136[rbp], 0
	jmp	.L10
.L11:
	mov	eax, DWORD PTR -136[rbp]
	cdqe
	mov	rax, QWORD PTR -96[rbp+rax*8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	add	DWORD PTR -136[rbp], 1
.L10:
	cmp	DWORD PTR -136[rbp], 4
	jle	.L11
	mov	DWORD PTR -132[rbp], 0
	jmp	.L12
.L13:
	mov	eax, DWORD PTR -132[rbp]
	cdqe
	mov	rax, QWORD PTR -48[rbp+rax*8]
	mov	esi, 0
	mov	rdi, rax
	call	pthread_join@PLT
	add	DWORD PTR -132[rbp], 1
.L12:
	cmp	DWORD PTR -132[rbp], 4
	jle	.L13
	lea	rdi, mutex[rip]
	call	pthread_mutex_destroy@PLT
	lea	rdi, wrt[rip]
	call	pthread_mutex_destroy@PLT
	mov	eax, 0
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	"261399.c"
	.text
	.comm	wrt,24,4
	.comm	mutex,24,4
	.comm	shared_value,4,4
	.global	active_reader
	.bss
	.align	2
	.type	active_reader, %object
	.size	active_reader, 4
active_reader:
	.space	4
	.section	.rodata
	.align	2
.LC1:
	.ascii	"Writer %d modified count to %d\012\012\000"
	.text
	.align	2
	.global	writers
	.syntax unified
	.arm
	.fpu softvfp
	.type	writers, %function
writers:
	@ 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	r0, .L2
	bl	pthread_mutex_lock
	ldr	r3, .L2+4
	ldr	r3, [r3]
	lsl	r3, r3, #1
	ldr	r2, .L2+4
	str	r3, [r2]
	ldr	r3, [fp, #-8]
	ldr	r3, [r3]
	ldr	r2, .L2+4
	ldr	r2, [r2]
	mov	r1, r3
	ldr	r0, .L2+8
	bl	printf
	ldr	r0, .L2
	bl	pthread_mutex_unlock
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L3:
	.align	2
.L2:
	.word	wrt
	.word	shared_value
	.word	.LC1
	.size	writers, .-writers
	.section	.rodata
	.align	2
.LC2:
	.ascii	"Reader %d: is waiting....\012\012\000"
	.align	2
.LC3:
	.ascii	"Reader %d: is reading......\012\012\000"
	.align	2
.LC4:
	.ascii	"Reader %d: read shared variable as %d\012\012\000"
	.align	2
.LC5:
	.ascii	"Number of readers currently present = %d\012\012\000"
	.text
	.align	2
	.global	readers
	.syntax unified
	.arm
	.fpu softvfp
	.type	readers, %function
readers:
	@ 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	r0, .L7
	bl	pthread_mutex_lock
	ldr	r3, .L7+4
	ldr	r3, [r3]
	add	r3, r3, #1
	ldr	r2, .L7+4
	str	r3, [r2]
	ldr	r3, .L7+4
	ldr	r3, [r3]
	cmp	r3, #1
	bne	.L5
	ldr	r0, .L7+8
	bl	pthread_mutex_lock
.L5:
	ldr	r0, .L7
	bl	pthread_mutex_unlock
	bl	rand
	mov	r2, r0
	ldr	r3, .L7+12
	smull	r1, r3, r2, r3
	asr	r1, r3, #3
	asr	r3, r2, #31
	sub	r1, r1, r3
	mov	r3, r1
	lsl	r3, r3, #2
	add	r3, r3, r1
	lsl	r3, r3, #2
	sub	r3, r2, r3
	str	r3, [fp, #-8]
	ldr	r3, [fp, #-16]
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L7+16
	bl	printf
	ldr	r3, [fp, #-8]
	mov	r0, r3
	bl	sleep
	ldr	r3, [fp, #-16]
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L7+20
	bl	printf
	ldr	r3, [fp, #-16]
	ldr	r3, [r3]
	ldr	r2, .L7+24
	ldr	r2, [r2]
	mov	r1, r3
	ldr	r0, .L7+28
	bl	printf
	ldr	r3, .L7+4
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L7+32
	bl	printf
	ldr	r0, .L7
	bl	pthread_mutex_lock
	ldr	r3, .L7+4
	ldr	r3, [r3]
	sub	r3, r3, #1
	ldr	r2, .L7+4
	str	r3, [r2]
	ldr	r3, .L7+4
	ldr	r3, [r3]
	cmp	r3, #0
	bne	.L6
	ldr	r0, .L7+8
	bl	pthread_mutex_unlock
.L6:
	ldr	r0, .L7
	bl	pthread_mutex_unlock
	nop
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L8:
	.align	2
.L7:
	.word	mutex
	.word	active_reader
	.word	wrt
	.word	1717986919
	.word	.LC2
	.word	.LC3
	.word	shared_value
	.word	.LC4
	.word	.LC5
	.size	readers, .-readers
	.section	.rodata
	.align	2
.LC6:
	.ascii	"Enter the share value: \000"
	.align	2
.LC7:
	.ascii	"%d\000"
	.align	2
.LC0:
	.word	1
	.word	2
	.word	3
	.word	4
	.word	5
	.align	2
.LC8:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 80
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #80
	ldr	r3, .L20
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	ldr	r0, .L20+4
	bl	puts
	ldr	r1, .L20+8
	ldr	r0, .L20+12
	bl	__isoc99_scanf
	mov	r1, #0
	ldr	r0, .L20+16
	bl	pthread_mutex_init
	mov	r1, #0
	ldr	r0, .L20+20
	bl	pthread_mutex_init
	ldr	r3, .L20+24
	sub	ip, fp, #28
	mov	lr, r3
	ldmia	lr!, {r0, r1, r2, r3}
	stmia	ip!, {r0, r1, r2, r3}
	ldr	r3, [lr]
	str	r3, [ip]
	mov	r3, #0
	str	r3, [fp, #-84]
	b	.L10
.L11:
	sub	r2, fp, #68
	ldr	r3, [fp, #-84]
	lsl	r3, r3, #2
	add	r0, r2, r3
	sub	r2, fp, #28
	ldr	r3, [fp, #-84]
	lsl	r3, r3, #2
	add	r3, r2, r3
	ldr	r2, .L20+28
	mov	r1, #0
	bl	pthread_create
	ldr	r3, [fp, #-84]
	add	r3, r3, #1
	str	r3, [fp, #-84]
.L10:
	ldr	r3, [fp, #-84]
	cmp	r3, #4
	ble	.L11
	mov	r3, #0
	str	r3, [fp, #-80]
	b	.L12
.L13:
	sub	r2, fp, #48
	ldr	r3, [fp, #-80]
	lsl	r3, r3, #2
	add	r0, r2, r3
	sub	r2, fp, #28
	ldr	r3, [fp, #-80]
	lsl	r3, r3, #2
	add	r3, r2, r3
	ldr	r2, .L20+32
	mov	r1, #0
	bl	pthread_create
	ldr	r3, [fp, #-80]
	add	r3, r3, #1
	str	r3, [fp, #-80]
.L12:
	ldr	r3, [fp, #-80]
	cmp	r3, #4
	ble	.L13
	mov	r3, #0
	str	r3, [fp, #-76]
	b	.L14
.L15:
	ldr	r3, [fp, #-76]
	lsl	r3, r3, #2
	sub	r2, fp, #4
	add	r3, r2, r3
	ldr	r3, [r3, #-64]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	ldr	r3, [fp, #-76]
	add	r3, r3, #1
	str	r3, [fp, #-76]
.L14:
	ldr	r3, [fp, #-76]
	cmp	r3, #4
	ble	.L15
	mov	r3, #0
	str	r3, [fp, #-72]
	b	.L16
.L17:
	ldr	r3, [fp, #-72]
	lsl	r3, r3, #2
	sub	r2, fp, #4
	add	r3, r2, r3
	ldr	r3, [r3, #-44]
	mov	r1, #0
	mov	r0, r3
	bl	pthread_join
	ldr	r3, [fp, #-72]
	add	r3, r3, #1
	str	r3, [fp, #-72]
.L16:
	ldr	r3, [fp, #-72]
	cmp	r3, #4
	ble	.L17
	ldr	r0, .L20+16
	bl	pthread_mutex_destroy
	ldr	r0, .L20+20
	bl	pthread_mutex_destroy
	mov	r3, #0
	ldr	r2, .L20
	ldr	r1, [r2]
	ldr	r2, [fp, #-8]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L19
	bl	__stack_chk_fail
.L19:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L21:
	.align	2
.L20:
	.word	.LC8
	.word	.LC6
	.word	shared_value
	.word	.LC7
	.word	mutex
	.word	wrt
	.word	.LC0
	.word	readers
	.word	writers
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
