	.file	"175143732.c"
	.intel_syntax noprefix
	.text
	.globl	PERM
	.section	.rodata
	.align 4
	.type	PERM, @object
	.size	PERM, 4
PERM:
	.long	511
	.globl	start_read
	.data
	.align 16
	.type	start_read, @object
	.size	start_read, 18
start_read:
	.value	3
	.value	0
	.value	0
	.value	1
	.value	0
	.value	0
	.value	0
	.value	1
	.value	0
	.globl	stop_read
	.align 2
	.type	stop_read, @object
	.size	stop_read, 6
stop_read:
	.value	0
	.value	-1
	.value	0
	.globl	start_write
	.align 16
	.type	start_write, @object
	.size	start_write, 30
start_write:
	.value	3
	.value	1
	.value	0
	.value	0
	.value	0
	.value	0
	.value	2
	.value	-1
	.value	0
	.value	1
	.value	1
	.value	0
	.value	3
	.value	-1
	.value	0
	.globl	stop_write
	.align 8
	.type	stop_write, @object
	.size	stop_write, 12
stop_write:
	.value	1
	.value	-1
	.value	0
	.value	2
	.value	1
	.value	0
	.section	.rodata
.LC0:
	.string	"Writer #%d ----> %d\n"
	.text
	.globl	writer
	.type	writer, @function
writer:
.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	DWORD PTR -4[rbp], edi
	mov	QWORD PTR -16[rbp], rsi
	mov	DWORD PTR -8[rbp], edx
	mov	edi, 15
	call	nice@PLT
.L2:
	mov	eax, DWORD PTR -4[rbp]
	mov	edx, 5
	lea	rsi, start_write[rip]
	mov	edi, eax
	call	semop@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR [rax]
	lea	edx, 1[rax]
	mov	rax, QWORD PTR -16[rbp]
	mov	DWORD PTR [rax], edx
	mov	rax, QWORD PTR -16[rbp]
	mov	edx, DWORD PTR [rax]
	mov	eax, DWORD PTR -8[rbp]
	mov	esi, eax
	lea	rdi, .LC0[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR -4[rbp]
	mov	edx, 2
	lea	rsi, stop_write[rip]
	mov	edi, eax
	call	semop@PLT
	call	rand@PLT
	movsx	rdx, eax
	imul	rdx, rdx, 1717986919
	shr	rdx, 32
	sar	edx
	mov	ecx, eax
	sar	ecx, 31
	sub	edx, ecx
	mov	ecx, edx
	sal	ecx, 2
	add	ecx, edx
	sub	eax, ecx
	mov	edx, eax
	mov	eax, edx
	mov	edi, eax
	call	sleep@PLT
	jmp	.L2
	.cfi_endproc
.LFE6:
	.size	writer, .-writer
	.section	.rodata
.LC1:
	.string	"\tReader #%d <---- %d\n"
	.text
	.globl	reader
	.type	reader, @function
reader:
.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	DWORD PTR -4[rbp], edi
	mov	QWORD PTR -16[rbp], rsi
	mov	DWORD PTR -8[rbp], edx
.L4:
	mov	eax, DWORD PTR -4[rbp]
	mov	edx, 3
	lea	rsi, start_read[rip]
	mov	edi, eax
	call	semop@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	edx, DWORD PTR [rax]
	mov	eax, DWORD PTR -8[rbp]
	mov	esi, eax
	lea	rdi, .LC1[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, DWORD PTR -4[rbp]
	mov	edx, 1
	lea	rsi, stop_read[rip]
	mov	edi, eax
	call	semop@PLT
	call	rand@PLT
	movsx	rdx, eax
	imul	rdx, rdx, 1431655766
	shr	rdx, 32
	mov	ecx, eax
	sar	ecx, 31
	sub	edx, ecx
	mov	ecx, edx
	add	ecx, ecx
	add	ecx, edx
	sub	eax, ecx
	mov	edx, eax
	mov	eax, edx
	mov	edi, eax
	call	sleep@PLT
	jmp	.L4
	.cfi_endproc
.LFE7:
	.size	reader, .-reader
	.section	.rodata
.LC2:
	.string	"Parent pid: %d\n"
	.align 8
.LC3:
	.string	"!!! Unable to create a shared area.\n"
.LC4:
	.string	"!!! Can't attach memory"
	.align 8
.LC5:
	.string	"!!! Unable to create a semaphore.\n"
	.align 8
.LC6:
	.string	"!!! Can't set control semaphors."
.LC7:
	.string	"Writer's fork error.\n"
.LC8:
	.string	"Reader's fork error.\n"
	.align 8
.LC9:
	.string	"!!! Can't detach shared memory"
.LC10:
	.string	"!!! Can't free memory!"
	.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, 48
	mov	edi, 0
	call	time@PLT
	mov	edi, eax
	call	srand@PLT
	call	getpid@PLT
	mov	DWORD PTR -32[rbp], eax
	mov	eax, DWORD PTR -32[rbp]
	mov	esi, eax
	lea	rdi, .LC2[rip]
	mov	eax, 0
	call	printf@PLT
	mov	eax, 511
	or	ah, 2
	mov	edx, eax
	mov	esi, 4
	mov	edi, 0
	call	shmget@PLT
	mov	DWORD PTR -28[rbp], eax
	cmp	DWORD PTR -28[rbp], -1
	jne	.L6
	lea	rdi, .LC3[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L6:
	mov	eax, DWORD PTR -28[rbp]
	mov	edx, 0
	mov	esi, 0
	mov	edi, eax
	call	shmat@PLT
	mov	QWORD PTR -16[rbp], rax
	cmp	QWORD PTR -16[rbp], -1
	jne	.L7
	lea	rdi, .LC4[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L7:
	mov	rax, QWORD PTR -16[rbp]
	mov	DWORD PTR [rax], 0
	mov	eax, 511
	or	ah, 2
	mov	edx, eax
	mov	esi, 4
	mov	edi, 0
	call	semget@PLT
	mov	DWORD PTR -24[rbp], eax
	cmp	DWORD PTR -24[rbp], -1
	jne	.L8
	lea	rdi, .LC5[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L8:
	mov	eax, DWORD PTR -24[rbp]
	mov	ecx, 1
	mov	edx, 16
	mov	esi, 2
	mov	edi, eax
	mov	eax, 0
	call	semctl@PLT
	mov	DWORD PTR -20[rbp], eax
	cmp	DWORD PTR -20[rbp], -1
	jne	.L9
	lea	rdi, .LC6[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L9:
	mov	DWORD PTR -48[rbp], -1
	mov	DWORD PTR -44[rbp], 0
	jmp	.L10
.L14:
	call	fork@PLT
	mov	DWORD PTR -48[rbp], eax
	cmp	DWORD PTR -48[rbp], -1
	jne	.L11
	lea	rdi, .LC7[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L11:
	cmp	DWORD PTR -48[rbp], 0
	jne	.L12
	mov	edx, DWORD PTR -44[rbp]
	mov	rcx, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR -24[rbp]
	mov	rsi, rcx
	mov	edi, eax
	call	writer
.L12:
	add	DWORD PTR -44[rbp], 1
.L10:
	cmp	DWORD PTR -44[rbp], 1
	jg	.L13
	cmp	DWORD PTR -48[rbp], 0
	jne	.L14
.L13:
	mov	DWORD PTR -40[rbp], 0
	jmp	.L15
.L19:
	call	fork@PLT
	mov	DWORD PTR -48[rbp], eax
	cmp	DWORD PTR -48[rbp], -1
	jne	.L16
	lea	rdi, .LC8[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L16:
	cmp	DWORD PTR -48[rbp], 0
	jne	.L17
	mov	edx, DWORD PTR -40[rbp]
	mov	rcx, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR -24[rbp]
	mov	rsi, rcx
	mov	edi, eax
	call	reader
.L17:
	add	DWORD PTR -40[rbp], 1
.L15:
	cmp	DWORD PTR -40[rbp], 3
	jg	.L18
	cmp	DWORD PTR -48[rbp], 0
	jne	.L19
.L18:
	mov	rax, QWORD PTR -16[rbp]
	mov	rdi, rax
	call	shmdt@PLT
	cmp	eax, -1
	jne	.L20
	lea	rdi, .LC9[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L20:
	cmp	DWORD PTR -48[rbp], 0
	je	.L21
	mov	DWORD PTR -36[rbp], 0
	jmp	.L22
.L23:
	mov	rax, QWORD PTR -8[rbp]
	mov	rdi, rax
	call	wait@PLT
	add	DWORD PTR -36[rbp], 1
.L22:
	cmp	DWORD PTR -36[rbp], 5
	jle	.L23
	mov	eax, DWORD PTR -28[rbp]
	mov	edx, 0
	mov	esi, 0
	mov	edi, eax
	call	shmctl@PLT
	cmp	eax, -1
	jne	.L21
	lea	rdi, .LC10[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L21:
	mov	eax, 0
	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	"175143732.c"
	.text
	.global	PERM
	.section	.rodata
	.align	2
	.type	PERM, %object
	.size	PERM, 4
PERM:
	.word	511
	.global	start_read
	.data
	.align	2
	.type	start_read, %object
	.size	start_read, 18
start_read:
	.short	3
	.short	0
	.short	0
	.short	1
	.short	0
	.short	0
	.short	0
	.short	1
	.short	0
	.global	stop_read
	.align	2
	.type	stop_read, %object
	.size	stop_read, 6
stop_read:
	.short	0
	.short	-1
	.short	0
	.global	start_write
	.align	2
	.type	start_write, %object
	.size	start_write, 30
start_write:
	.short	3
	.short	1
	.short	0
	.short	0
	.short	0
	.short	0
	.short	2
	.short	-1
	.short	0
	.short	1
	.short	1
	.short	0
	.short	3
	.short	-1
	.short	0
	.global	stop_write
	.align	2
	.type	stop_write, %object
	.size	stop_write, 12
stop_write:
	.short	1
	.short	-1
	.short	0
	.short	2
	.short	1
	.short	0
	.section	.rodata
	.align	2
.LC0:
	.ascii	"Writer #%d ----> %d\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, #-8]
	str	r1, [fp, #-12]
	str	r2, [fp, #-16]
	mov	r0, #15
	bl	nice
.L2:
	mov	r2, #5
	ldr	r1, .L3
	ldr	r0, [fp, #-8]
	bl	semop
	ldr	r3, [fp, #-12]
	ldr	r3, [r3]
	add	r2, r3, #1
	ldr	r3, [fp, #-12]
	str	r2, [r3]
	ldr	r3, [fp, #-12]
	ldr	r3, [r3]
	mov	r2, r3
	ldr	r1, [fp, #-16]
	ldr	r0, .L3+4
	bl	printf
	mov	r2, #2
	ldr	r1, .L3+8
	ldr	r0, [fp, #-8]
	bl	semop
	bl	rand
	mov	r2, r0
	ldr	r3, .L3+12
	smull	r1, r3, r2, r3
	asr	r1, r3, #1
	asr	r3, r2, #31
	sub	r1, r1, r3
	mov	r3, r1
	lsl	r3, r3, #2
	add	r3, r3, r1
	sub	r1, r2, r3
	mov	r3, r1
	mov	r0, r3
	bl	sleep
	b	.L2
.L4:
	.align	2
.L3:
	.word	start_write
	.word	.LC0
	.word	stop_write
	.word	1717986919
	.size	writer, .-writer
	.section	.rodata
	.align	2
.LC1:
	.ascii	"\011Reader #%d <---- %d\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, #-8]
	str	r1, [fp, #-12]
	str	r2, [fp, #-16]
.L6:
	mov	r2, #3
	ldr	r1, .L7
	ldr	r0, [fp, #-8]
	bl	semop
	ldr	r3, [fp, #-12]
	ldr	r3, [r3]
	mov	r2, r3
	ldr	r1, [fp, #-16]
	ldr	r0, .L7+4
	bl	printf
	mov	r2, #1
	ldr	r1, .L7+8
	ldr	r0, [fp, #-8]
	bl	semop
	bl	rand
	mov	r2, r0
	ldr	r3, .L7+12
	smull	r0, r1, r3, r2
	asr	r3, r2, #31
	sub	r1, r1, r3
	mov	r3, r1
	lsl	r3, r3, #1
	add	r3, r3, r1
	sub	r1, r2, r3
	mov	r3, r1
	mov	r0, r3
	bl	sleep
	b	.L6
.L8:
	.align	2
.L7:
	.word	start_read
	.word	.LC1
	.word	stop_read
	.word	1431655766
	.size	reader, .-reader
	.section	.rodata
	.align	2
.LC2:
	.ascii	"Parent pid: %d\012\000"
	.align	2
.LC3:
	.ascii	"!!! Unable to create a shared area.\012\000"
	.align	2
.LC4:
	.ascii	"!!! Can't attach memory\000"
	.align	2
.LC5:
	.ascii	"!!! Unable to create a semaphore.\012\000"
	.align	2
.LC6:
	.ascii	"!!! Can't set control semaphors.\000"
	.align	2
.LC7:
	.ascii	"Writer's fork error.\012\000"
	.align	2
.LC8:
	.ascii	"Reader's fork error.\012\000"
	.align	2
.LC9:
	.ascii	"!!! Can't detach shared memory\000"
	.align	2
.LC10:
	.ascii	"!!! Can't free memory!\000"
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 40
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #40
	mov	r0, #0
	bl	time
	mov	r3, r0
	mov	r0, r3
	bl	srand
	bl	getpid
	str	r0, [fp, #-28]
	ldr	r1, [fp, #-28]
	ldr	r0, .L29
	bl	printf
	ldr	r3, .L29+4
	orr	r3, r3, #512
	mov	r2, r3
	mov	r1, #4
	mov	r0, #0
	bl	shmget
	str	r0, [fp, #-24]
	ldr	r3, [fp, #-24]
	cmn	r3, #1
	bne	.L10
	ldr	r0, .L29+8
	bl	perror
	mov	r0, #1
	bl	exit
.L10:
	mov	r2, #0
	mov	r1, #0
	ldr	r0, [fp, #-24]
	bl	shmat
	str	r0, [fp, #-20]
	ldr	r3, [fp, #-20]
	cmn	r3, #1
	bne	.L11
	ldr	r0, .L29+12
	bl	perror
	mov	r0, #1
	bl	exit
.L11:
	ldr	r3, [fp, #-20]
	mov	r2, #0
	str	r2, [r3]
	ldr	r3, .L29+4
	orr	r3, r3, #512
	mov	r2, r3
	mov	r1, #4
	mov	r0, #0
	bl	semget
	str	r0, [fp, #-16]
	ldr	r3, [fp, #-16]
	cmn	r3, #1
	bne	.L12
	ldr	r0, .L29+16
	bl	perror
	mov	r0, #1
	bl	exit
.L12:
	mov	r3, #1
	mov	r2, #16
	mov	r1, #2
	ldr	r0, [fp, #-16]
	bl	semctl
	str	r0, [fp, #-12]
	ldr	r3, [fp, #-12]
	cmn	r3, #1
	bne	.L13
	ldr	r0, .L29+20
	bl	perror
	mov	r0, #1
	bl	exit
.L13:
	mvn	r3, #0
	str	r3, [fp, #-44]
	mov	r3, #0
	str	r3, [fp, #-40]
	b	.L14
.L18:
	bl	fork
	mov	r3, r0
	str	r3, [fp, #-44]
	ldr	r3, [fp, #-44]
	cmn	r3, #1
	bne	.L15
	ldr	r0, .L29+24
	bl	perror
	mov	r0, #1
	bl	exit
.L15:
	ldr	r3, [fp, #-44]
	cmp	r3, #0
	bne	.L16
	ldr	r2, [fp, #-40]
	ldr	r1, [fp, #-20]
	ldr	r0, [fp, #-16]
	bl	writer
.L16:
	ldr	r3, [fp, #-40]
	add	r3, r3, #1
	str	r3, [fp, #-40]
.L14:
	ldr	r3, [fp, #-40]
	cmp	r3, #1
	bgt	.L17
	ldr	r3, [fp, #-44]
	cmp	r3, #0
	bne	.L18
.L17:
	mov	r3, #0
	str	r3, [fp, #-36]
	b	.L19
.L23:
	bl	fork
	mov	r3, r0
	str	r3, [fp, #-44]
	ldr	r3, [fp, #-44]
	cmn	r3, #1
	bne	.L20
	ldr	r0, .L29+28
	bl	perror
	mov	r0, #1
	bl	exit
.L20:
	ldr	r3, [fp, #-44]
	cmp	r3, #0
	bne	.L21
	ldr	r2, [fp, #-36]
	ldr	r1, [fp, #-20]
	ldr	r0, [fp, #-16]
	bl	reader
.L21:
	ldr	r3, [fp, #-36]
	add	r3, r3, #1
	str	r3, [fp, #-36]
.L19:
	ldr	r3, [fp, #-36]
	cmp	r3, #3
	bgt	.L22
	ldr	r3, [fp, #-44]
	cmp	r3, #0
	bne	.L23
.L22:
	ldr	r0, [fp, #-20]
	bl	shmdt
	mov	r3, r0
	cmn	r3, #1
	bne	.L24
	ldr	r0, .L29+32
	bl	perror
	mov	r0, #1
	bl	exit
.L24:
	ldr	r3, [fp, #-44]
	cmp	r3, #0
	beq	.L25
	mov	r3, #0
	str	r3, [fp, #-32]
	b	.L26
.L27:
	ldr	r0, [fp, #-8]
	bl	wait
	ldr	r3, [fp, #-32]
	add	r3, r3, #1
	str	r3, [fp, #-32]
.L26:
	ldr	r3, [fp, #-32]
	cmp	r3, #5
	ble	.L27
	mov	r2, #0
	mov	r1, #0
	ldr	r0, [fp, #-24]
	bl	shmctl
	mov	r3, r0
	cmn	r3, #1
	bne	.L25
	ldr	r0, .L29+36
	bl	perror
	mov	r0, #1
	bl	exit
.L25:
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L30:
	.align	2
.L29:
	.word	.LC2
	.word	511
	.word	.LC3
	.word	.LC4
	.word	.LC5
	.word	.LC6
	.word	.LC7
	.word	.LC8
	.word	.LC9
	.word	.LC10
	.size	main, .-main
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
