	.file	"906808.c"
	.intel_syntax noprefix
	.text
	.globl	cria_filhos
	.type	cria_filhos, @function
cria_filhos:
.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	DWORD PTR -20[rbp], edi
	mov	DWORD PTR -8[rbp], 0
	mov	DWORD PTR -8[rbp], 0
	jmp	.L2
.L6:
	call	fork@PLT
	mov	DWORD PTR -4[rbp], eax
	cmp	DWORD PTR -4[rbp], 0
	jns	.L3
	mov	eax, -1
	jmp	.L4
.L3:
	cmp	DWORD PTR -4[rbp], 0
	jne	.L5
	mov	eax, DWORD PTR -8[rbp]
	add	eax, 1
	jmp	.L4
.L5:
	add	DWORD PTR -8[rbp], 1
.L2:
	mov	eax, DWORD PTR -8[rbp]
	cmp	eax, DWORD PTR -20[rbp]
	jl	.L6
	mov	eax, 0
.L4:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cria_filhos, .-cria_filhos
	.section	.rodata
.LC0:
	.string	"Ex03"
.LC1:
	.string	"Erro ao abrir o semaforo\n"
.LC2:
	.string	"/shmex03sp"
.LC3:
	.string	"In shm_open()"
.LC4:
	.string	"Erro ao criar filhos"
	.align 8
.LC5:
	.string	"%d - comecando a escrever na SHM \n"
	.align 8
.LC6:
	.string	"[%d]Sou o filho n. %d e com o processo n.%d"
	.align 8
.LC7:
	.string	"REMOVEDOR - comecando a apagar na SHM "
.LC8:
	.string	"%s \n"
.LC9:
	.string	"Erro no sem_close()\n"
.LC10:
	.string	"Erro no sem_unlink()\n"
	.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, 80
	mov	DWORD PTR -68[rbp], edi
	mov	QWORD PTR -80[rbp], rsi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	mov	DWORD PTR -52[rbp], 4004
	lea	rax, -32[rbp]
	mov	rdi, rax
	call	time@PLT
	mov	edi, eax
	call	srand@PLT
	mov	ecx, 1
	mov	edx, 420
	mov	esi, 192
	lea	rdi, .LC0[rip]
	mov	eax, 0
	call	sem_open@PLT
	mov	QWORD PTR -24[rbp], rax
	cmp	QWORD PTR -24[rbp], 0
	jne	.L8
	lea	rdi, .LC1[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L8:
	mov	edx, 384
	mov	esi, 194
	lea	rdi, .LC2[rip]
	call	shm_open@PLT
	mov	DWORD PTR -48[rbp], eax
	cmp	DWORD PTR -48[rbp], 0
	jns	.L9
	lea	rdi, .LC3[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L9:
	mov	eax, DWORD PTR -52[rbp]
	movsx	rdx, eax
	mov	eax, DWORD PTR -48[rbp]
	mov	rsi, rdx
	mov	edi, eax
	call	ftruncate@PLT
	mov	eax, DWORD PTR -52[rbp]
	cdqe
	mov	edx, DWORD PTR -48[rbp]
	mov	r9d, 0
	mov	r8d, edx
	mov	ecx, 1
	mov	edx, 3
	mov	rsi, rax
	mov	edi, 0
	call	mmap@PLT
	mov	QWORD PTR -16[rbp], rax
	mov	rax, QWORD PTR -16[rbp]
	mov	DWORD PTR 4000[rax], 0
	mov	edi, 50
	call	cria_filhos
	mov	DWORD PTR -44[rbp], eax
	cmp	DWORD PTR -44[rbp], 0
	jns	.L10
	lea	rdi, .LC4[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edi, 2
	call	exit@PLT
.L10:
	cmp	DWORD PTR -44[rbp], 0
	jle	.L11
	mov	rax, QWORD PTR -24[rbp]
	mov	rdi, rax
	call	sem_wait@PLT
	mov	eax, DWORD PTR -44[rbp]
	mov	esi, eax
	lea	rdi, .LC5[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR 4000[rax]
	mov	DWORD PTR -36[rbp], eax
	call	getpid@PLT
	mov	ecx, eax
	mov	eax, DWORD PTR -36[rbp]
	movsx	rdx, eax
	mov	rax, rdx
	sal	rax, 2
	add	rax, rdx
	sal	rax, 4
	mov	rdx, QWORD PTR -16[rbp]
	lea	rdi, [rax+rdx]
	mov	edx, DWORD PTR -44[rbp]
	mov	eax, DWORD PTR -36[rbp]
	mov	r8d, ecx
	mov	ecx, edx
	mov	edx, eax
	lea	rsi, .LC6[rip]
	mov	eax, 0
	call	sprintf@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR 4000[rax]
	lea	edx, 1[rax]
	mov	rax, QWORD PTR -16[rbp]
	mov	DWORD PTR 4000[rax], edx
	mov	edi, 0
	call	sleep@PLT
	mov	rax, QWORD PTR -24[rbp]
	mov	rdi, rax
	call	sem_post@PLT
	mov	edi, 1
	call	exit@PLT
.L11:
	call	fork@PLT
	mov	DWORD PTR -44[rbp], eax
	cmp	DWORD PTR -44[rbp], 0
	jne	.L12
	mov	rax, QWORD PTR -24[rbp]
	mov	rdi, rax
	call	sem_wait@PLT
	lea	rdi, .LC7[rip]
	call	puts@PLT
	mov	rax, QWORD PTR -16[rbp]
	mov	eax, DWORD PTR 4000[rax]
	lea	edx, -1[rax]
	mov	rax, QWORD PTR -16[rbp]
	mov	DWORD PTR 4000[rax], edx
	mov	rax, QWORD PTR -24[rbp]
	mov	rdi, rax
	call	sem_post@PLT
	mov	edi, 1
	call	exit@PLT
.L12:
	mov	DWORD PTR -56[rbp], 0
	jmp	.L13
.L14:
	mov	edi, 0
	call	wait@PLT
	add	DWORD PTR -56[rbp], 1
.L13:
	cmp	DWORD PTR -56[rbp], 50
	jle	.L14
	mov	DWORD PTR -56[rbp], 0
	jmp	.L15
.L16:
	mov	eax, DWORD PTR -56[rbp]
	movsx	rdx, eax
	mov	rax, rdx
	sal	rax, 2
	add	rax, rdx
	sal	rax, 4
	mov	rdx, QWORD PTR -16[rbp]
	add	rax, rdx
	mov	rsi, rax
	lea	rdi, .LC8[rip]
	mov	eax, 0
	call	printf@PLT
	add	DWORD PTR -56[rbp], 1
.L15:
	cmp	DWORD PTR -56[rbp], 49
	jle	.L16
	mov	rax, QWORD PTR -24[rbp]
	mov	rdi, rax
	call	sem_close@PLT
	cmp	eax, -1
	jne	.L17
	lea	rdi, .LC9[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L17:
	lea	rdi, .LC0[rip]
	call	sem_unlink@PLT
	cmp	eax, -1
	jne	.L18
	lea	rdi, .LC10[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L18:
	mov	eax, DWORD PTR -52[rbp]
	movsx	rdx, eax
	mov	rax, QWORD PTR -16[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	munmap@PLT
	mov	DWORD PTR -40[rbp], eax
	cmp	DWORD PTR -40[rbp], 0
	jns	.L19
	mov	edi, 1
	call	exit@PLT
.L19:
	mov	eax, DWORD PTR -48[rbp]
	mov	edi, eax
	call	close@PLT
	cmp	DWORD PTR -40[rbp], 0
	jns	.L20
	mov	edi, 1
	call	exit@PLT
.L20:
	lea	rdi, .LC2[rip]
	call	shm_unlink@PLT
	mov	DWORD PTR -40[rbp], eax
	cmp	DWORD PTR -40[rbp], 0
	jns	.L21
	mov	edi, 1
	call	exit@PLT
.L21:
	mov	eax, 0
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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	"906808.c"
	.text
	.align	2
	.global	cria_filhos
	.syntax unified
	.arm
	.fpu softvfp
	.type	cria_filhos, %function
cria_filhos:
	@ 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, #-12]
	mov	r3, #0
	str	r3, [fp, #-12]
	b	.L2
.L6:
	bl	fork
	mov	r3, r0
	str	r3, [fp, #-8]
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	bge	.L3
	mvn	r3, #0
	b	.L4
.L3:
	ldr	r3, [fp, #-8]
	cmp	r3, #0
	bne	.L5
	ldr	r3, [fp, #-12]
	add	r3, r3, #1
	b	.L4
.L5:
	ldr	r3, [fp, #-12]
	add	r3, r3, #1
	str	r3, [fp, #-12]
.L2:
	ldr	r2, [fp, #-12]
	ldr	r3, [fp, #-16]
	cmp	r2, r3
	blt	.L6
	mov	r3, #0
.L4:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
	.size	cria_filhos, .-cria_filhos
	.section	.rodata
	.align	2
.LC0:
	.ascii	"Ex03\000"
	.align	2
.LC1:
	.ascii	"Erro ao abrir o semaforo\012\000"
	.align	2
.LC2:
	.ascii	"/shmex03sp\000"
	.align	2
.LC3:
	.ascii	"In shm_open()\000"
	.align	2
.LC4:
	.ascii	"Erro ao criar filhos\000"
	.align	2
.LC5:
	.ascii	"%d - comecando a escrever na SHM \012\000"
	.align	2
.LC6:
	.ascii	"[%d]Sou o filho n. %d e com o processo n.%d\000"
	.align	2
.LC7:
	.ascii	"REMOVEDOR - comecando a apagar na SHM \000"
	.align	2
.LC8:
	.ascii	"%s \012\000"
	.align	2
.LC9:
	.ascii	"Erro no sem_close()\012\000"
	.align	2
.LC10:
	.ascii	"Erro no sem_unlink()\012\000"
	.align	2
.LC11:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	main
	.syntax unified
	.arm
	.fpu softvfp
	.type	main, %function
main:
	@ args = 0, pretend = 0, frame = 48
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, fp, lr}
	add	fp, sp, #8
	sub	sp, sp, #60
	str	r0, [fp, #-56]
	str	r1, [fp, #-60]
	ldr	r3, .L24
	ldr	r3, [r3]
	str	r3, [fp, #-16]
	mov	r3,#0
	ldr	r3, .L24+4
	str	r3, [fp, #-44]
	sub	r3, fp, #52
	mov	r0, r3
	bl	time
	mov	r3, r0
	mov	r0, r3
	bl	srand
	mov	r3, #1
	mov	r2, #420
	mov	r1, #192
	ldr	r0, .L24+8
	bl	sem_open
	str	r0, [fp, #-40]
	ldr	r3, [fp, #-40]
	cmp	r3, #0
	bne	.L8
	ldr	r0, .L24+12
	bl	perror
	mov	r0, #1
	bl	exit
.L8:
	mov	r2, #384
	mov	r1, #194
	ldr	r0, .L24+16
	bl	shm_open
	str	r0, [fp, #-36]
	ldr	r3, [fp, #-36]
	cmp	r3, #0
	bge	.L9
	ldr	r0, .L24+20
	bl	perror
	mov	r0, #1
	bl	exit
.L9:
	ldr	r1, [fp, #-44]
	ldr	r0, [fp, #-36]
	bl	ftruncate
	ldr	r1, [fp, #-44]
	mov	r3, #0
	str	r3, [sp, #4]
	ldr	r3, [fp, #-36]
	str	r3, [sp]
	mov	r3, #1
	mov	r2, #3
	mov	r0, #0
	bl	mmap
	str	r0, [fp, #-32]
	ldr	r3, [fp, #-32]
	mov	r2, #0
	str	r2, [r3, #4000]
	mov	r0, #50
	bl	cria_filhos
	str	r0, [fp, #-28]
	ldr	r3, [fp, #-28]
	cmp	r3, #0
	bge	.L10
	ldr	r0, .L24+24
	bl	printf
	mov	r0, #2
	bl	exit
.L10:
	ldr	r3, [fp, #-28]
	cmp	r3, #0
	ble	.L11
	ldr	r0, [fp, #-40]
	bl	sem_wait
	ldr	r1, [fp, #-28]
	ldr	r0, .L24+28
	bl	printf
	ldr	r3, [fp, #-32]
	ldr	r3, [r3, #4000]
	str	r3, [fp, #-20]
	ldr	r2, [fp, #-20]
	mov	r3, r2
	lsl	r3, r3, #2
	add	r3, r3, r2
	lsl	r3, r3, #4
	ldr	r2, [fp, #-32]
	add	r4, r2, r3
	bl	getpid
	mov	r3, r0
	str	r3, [sp]
	ldr	r3, [fp, #-28]
	ldr	r2, [fp, #-20]
	ldr	r1, .L24+32
	mov	r0, r4
	bl	sprintf
	ldr	r3, [fp, #-32]
	ldr	r3, [r3, #4000]
	add	r2, r3, #1
	ldr	r3, [fp, #-32]
	str	r2, [r3, #4000]
	mov	r0, #0
	bl	sleep
	ldr	r0, [fp, #-40]
	bl	sem_post
	mov	r0, #1
	bl	exit
.L11:
	bl	fork
	mov	r3, r0
	str	r3, [fp, #-28]
	ldr	r3, [fp, #-28]
	cmp	r3, #0
	bne	.L12
	ldr	r0, [fp, #-40]
	bl	sem_wait
	ldr	r0, .L24+36
	bl	puts
	ldr	r3, [fp, #-32]
	ldr	r3, [r3, #4000]
	sub	r2, r3, #1
	ldr	r3, [fp, #-32]
	str	r2, [r3, #4000]
	ldr	r0, [fp, #-40]
	bl	sem_post
	mov	r0, #1
	bl	exit
.L12:
	mov	r3, #0
	str	r3, [fp, #-48]
	b	.L13
.L14:
	mov	r0, #0
	bl	wait
	ldr	r3, [fp, #-48]
	add	r3, r3, #1
	str	r3, [fp, #-48]
.L13:
	ldr	r3, [fp, #-48]
	cmp	r3, #50
	ble	.L14
	mov	r3, #0
	str	r3, [fp, #-48]
	b	.L15
.L16:
	ldr	r2, [fp, #-48]
	mov	r3, r2
	lsl	r3, r3, #2
	add	r3, r3, r2
	lsl	r3, r3, #4
	ldr	r2, [fp, #-32]
	add	r3, r2, r3
	mov	r1, r3
	ldr	r0, .L24+40
	bl	printf
	ldr	r3, [fp, #-48]
	add	r3, r3, #1
	str	r3, [fp, #-48]
.L15:
	ldr	r3, [fp, #-48]
	cmp	r3, #49
	ble	.L16
	ldr	r0, [fp, #-40]
	bl	sem_close
	mov	r3, r0
	cmn	r3, #1
	bne	.L17
	ldr	r0, .L24+44
	bl	perror
	mov	r0, #1
	bl	exit
.L17:
	ldr	r0, .L24+8
	bl	sem_unlink
	mov	r3, r0
	cmn	r3, #1
	bne	.L18
	ldr	r0, .L24+48
	bl	perror
	mov	r0, #1
	bl	exit
.L18:
	ldr	r3, [fp, #-44]
	mov	r1, r3
	ldr	r0, [fp, #-32]
	bl	munmap
	str	r0, [fp, #-24]
	ldr	r3, [fp, #-24]
	cmp	r3, #0
	bge	.L19
	mov	r0, #1
	bl	exit
.L19:
	ldr	r0, [fp, #-36]
	bl	close
	ldr	r3, [fp, #-24]
	cmp	r3, #0
	bge	.L20
	mov	r0, #1
	bl	exit
.L20:
	ldr	r0, .L24+16
	bl	shm_unlink
	str	r0, [fp, #-24]
	ldr	r3, [fp, #-24]
	cmp	r3, #0
	bge	.L21
	mov	r0, #1
	bl	exit
.L21:
	mov	r3, #0
	ldr	r2, .L24
	ldr	r1, [r2]
	ldr	r2, [fp, #-16]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L23
	bl	__stack_chk_fail
.L23:
	mov	r0, r3
	sub	sp, fp, #8
	@ sp needed
	pop	{r4, fp, pc}
.L25:
	.align	2
.L24:
	.word	.LC11
	.word	4004
	.word	.LC0
	.word	.LC1
	.word	.LC2
	.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
