	.file	"750815.c"
	.intel_syntax noprefix
	.text
	.globl	max_child
	.section	.rodata
	.align 4
	.type	max_child, @object
	.size	max_child, 4
max_child:
	.long	30
	.globl	p_psem
	.bss
	.align 8
	.type	p_psem, @object
	.size	p_psem, 8
p_psem:
	.zero	8
	.section	.rodata
.LC0:
	.string	"%s [counter]\n"
.LC1:
	.string	"/my_psem"
.LC2:
	.string	"FAIL: sem_open"
	.align 8
.LC3:
	.string	"[%d] Attach to an existed sem\n"
.LC4:
	.string	"[%d] Create new sem\n"
.LC5:
	.string	"[%d] sem_getvalue = %d\n"
	.align 8
.LC6:
	.string	"[%d] iteration(%d) : Atomically decrease\n"
.LC7:
	.string	"FAIL: fork() [%s:%d]\n"
.LC8:
	.string	"FAIL: sem_unlink"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	push	rbx
	sub	rsp, 56
	.cfi_offset 3, -24
	mov	DWORD PTR -52[rbp], edi
	mov	QWORD PTR -64[rbp], rsi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -24[rbp], rax
	xor	eax, eax
	cmp	DWORD PTR -52[rbp], 2
	je	.L2
	mov	rax, QWORD PTR -64[rbp]
	mov	rax, QWORD PTR [rax]
	mov	rsi, rax
	lea	rdi, .LC0[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edi, 1
	call	exit@PLT
.L2:
	mov	rax, QWORD PTR -64[rbp]
	add	rax, 8
	mov	rax, QWORD PTR [rax]
	mov	rdi, rax
	call	atoi@PLT
	mov	DWORD PTR -32[rbp], eax
	mov	eax, DWORD PTR -32[rbp]
	mov	ecx, eax
	mov	edx, 384
	mov	esi, 192
	lea	rdi, .LC1[rip]
	mov	eax, 0
	call	sem_open@PLT
	mov	QWORD PTR p_psem[rip], rax
	mov	rax, QWORD PTR p_psem[rip]
	test	rax, rax
	jne	.L3
	call	__errno_location@PLT
	mov	eax, DWORD PTR [rax]
	cmp	eax, 17
	je	.L4
	lea	rdi, .LC2[rip]
	call	perror@PLT
	mov	edi, 1
	call	exit@PLT
.L4:
	mov	esi, 0
	lea	rdi, .LC1[rip]
	mov	eax, 0
	call	sem_open@PLT
	mov	QWORD PTR p_psem[rip], rax
	call	getpid@PLT
	mov	esi, eax
	lea	rdi, .LC3[rip]
	mov	eax, 0
	call	printf@PLT
	jmp	.L5
.L3:
	call	getpid@PLT
	mov	esi, eax
	lea	rdi, .LC4[rip]
	mov	eax, 0
	call	printf@PLT
.L5:
	mov	rax, QWORD PTR p_psem[rip]
	lea	rdx, -44[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	sem_getvalue@PLT
	mov	ebx, DWORD PTR -44[rbp]
	call	getpid@PLT
	mov	edx, ebx
	mov	esi, eax
	lea	rdi, .LC5[rip]
	mov	eax, 0
	call	printf@PLT
	mov	DWORD PTR -36[rbp], 0
	jmp	.L6
.L9:
	call	getpid@PLT
	mov	ecx, eax
	mov	eax, DWORD PTR -36[rbp]
	mov	edx, eax
	mov	esi, ecx
	lea	rdi, .LC6[rip]
	mov	eax, 0
	call	printf@PLT
	mov	rax, QWORD PTR p_psem[rip]
	mov	rdi, rax
	call	sem_wait@PLT
	call	fork@PLT
	cmp	eax, -1
	je	.L7
	test	eax, eax
	jne	.L17
	mov	eax, DWORD PTR -36[rbp]
	mov	edi, eax
	call	process_child
	mov	rax, QWORD PTR p_psem[rip]
	mov	rdi, rax
	call	sem_post@PLT
	mov	edi, 0
	call	exit@PLT
.L7:
	mov	rax, QWORD PTR stderr[rip]
	mov	ecx, 51
	lea	rdx, __FUNCTION__.0[rip]
	lea	rsi, .LC7[rip]
	mov	rdi, rax
	mov	eax, 0
	call	fprintf@PLT
	mov	edi, 1
	call	exit@PLT
.L17:
	nop
	mov	edi, 10000
	call	usleep@PLT
	add	DWORD PTR -36[rbp], 1
.L6:
	mov	eax, 30
	cmp	DWORD PTR -36[rbp], eax
	jl	.L9
	mov	DWORD PTR -36[rbp], 0
	jmp	.L10
.L11:
	lea	rax, -40[rbp]
	mov	edx, 0
	mov	rsi, rax
	mov	edi, -1
	call	waitpid@PLT
	mov	DWORD PTR -28[rbp], eax
	add	DWORD PTR -36[rbp], 1
.L10:
	mov	eax, 30
	cmp	DWORD PTR -36[rbp], eax
	jl	.L11
	mov	rax, QWORD PTR p_psem[rip]
	lea	rdx, -44[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	sem_getvalue@PLT
	mov	ebx, DWORD PTR -44[rbp]
	call	getpid@PLT
	mov	edx, ebx
	mov	esi, eax
	lea	rdi, .LC5[rip]
	mov	eax, 0
	call	printf@PLT
	lea	rdi, .LC1[rip]
	call	sem_unlink@PLT
	cmp	eax, -1
	jne	.L12
	lea	rdi, .LC8[rip]
	call	perror@PLT
	mov	eax, 1
	jmp	.L14
.L12:
	mov	eax, 0
.L14:
	mov	rcx, QWORD PTR -24[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	mov	rbx, QWORD PTR -8[rbp]
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC9:
	.string	"\t[Child:%d] sleep(2)\n"
	.text
	.globl	process_child
	.type	process_child, @function
process_child:
.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
	cmp	DWORD PTR -4[rbp], 11
	jne	.L19
	call	abort@PLT
.L19:
	mov	eax, DWORD PTR -4[rbp]
	mov	esi, eax
	lea	rdi, .LC9[rip]
	mov	eax, 0
	call	printf@PLT
	mov	edi, 2
	call	sleep@PLT
	mov	eax, 0
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	process_child, .-process_child
	.section	.rodata
	.type	__FUNCTION__.0, @object
	.size	__FUNCTION__.0, 5
__FUNCTION__.0:
	.string	"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	"750815.c"
	.text
	.global	max_child
	.section	.rodata
	.align	2
	.type	max_child, %object
	.size	max_child, 4
max_child:
	.word	30
	.comm	p_psem,4,4
	.align	2
.LC0:
	.ascii	"%s [counter]\012\000"
	.align	2
.LC1:
	.ascii	"/my_psem\000"
	.align	2
.LC2:
	.ascii	"FAIL: sem_open\000"
	.align	2
.LC3:
	.ascii	"[%d] Attach to an existed sem\012\000"
	.align	2
.LC4:
	.ascii	"[%d] Create new sem\012\000"
	.align	2
.LC5:
	.ascii	"[%d] sem_getvalue = %d\012\000"
	.align	2
.LC6:
	.ascii	"[%d] iteration(%d) : Atomically decrease\012\000"
	.align	2
.LC7:
	.ascii	"FAIL: fork() [%s:%d]\012\000"
	.align	2
.LC8:
	.ascii	"FAIL: sem_unlink\000"
	.align	2
.LC9:
	.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, .L18
	ldr	r3, [r3]
	str	r3, [fp, #-8]
	mov	r3,#0
	ldr	r3, [fp, #-32]
	cmp	r3, #2
	beq	.L2
	ldr	r3, [fp, #-36]
	ldr	r3, [r3]
	mov	r1, r3
	ldr	r0, .L18+4
	bl	printf
	mov	r0, #1
	bl	exit
.L2:
	ldr	r3, [fp, #-36]
	add	r3, r3, #4
	ldr	r3, [r3]
	mov	r0, r3
	bl	atoi
	str	r0, [fp, #-16]
	ldr	r3, [fp, #-16]
	mov	r2, #384
	mov	r1, #192
	ldr	r0, .L18+8
	bl	sem_open
	mov	r3, r0
	ldr	r2, .L18+12
	str	r3, [r2]
	ldr	r3, .L18+12
	ldr	r3, [r3]
	cmp	r3, #0
	bne	.L3
	bl	__errno_location
	mov	r3, r0
	ldr	r3, [r3]
	cmp	r3, #17
	beq	.L4
	ldr	r0, .L18+16
	bl	perror
	mov	r0, #1
	bl	exit
.L4:
	mov	r1, #0
	ldr	r0, .L18+8
	bl	sem_open
	mov	r3, r0
	ldr	r2, .L18+12
	str	r3, [r2]
	bl	getpid
	mov	r3, r0
	mov	r1, r3
	ldr	r0, .L18+20
	bl	printf
	b	.L5
.L3:
	bl	getpid
	mov	r3, r0
	mov	r1, r3
	ldr	r0, .L18+24
	bl	printf
.L5:
	ldr	r3, .L18+12
	ldr	r3, [r3]
	sub	r2, fp, #28
	mov	r1, r2
	mov	r0, r3
	bl	sem_getvalue
	bl	getpid
	mov	r1, r0
	ldr	r3, [fp, #-28]
	mov	r2, r3
	ldr	r0, .L18+28
	bl	printf
	mov	r3, #0
	str	r3, [fp, #-20]
	b	.L6
.L9:
	bl	getpid
	mov	r3, r0
	ldr	r2, [fp, #-20]
	mov	r1, r3
	ldr	r0, .L18+32
	bl	printf
	ldr	r3, .L18+12
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_wait
	bl	fork
	mov	r3, r0
	cmn	r3, #1
	beq	.L7
	cmp	r3, #0
	bne	.L17
	ldr	r0, [fp, #-20]
	bl	process_child
	ldr	r3, .L18+12
	ldr	r3, [r3]
	mov	r0, r3
	bl	sem_post
	mov	r0, #0
	bl	exit
.L7:
	ldr	r3, .L18+36
	ldr	r0, [r3]
	mov	r3, #51
	ldr	r2, .L18+40
	ldr	r1, .L18+44
	bl	fprintf
	mov	r0, #1
	bl	exit
.L17:
	nop
	ldr	r0, .L18+48
	bl	usleep
	ldr	r3, [fp, #-20]
	add	r3, r3, #1
	str	r3, [fp, #-20]
.L6:
	mov	r2, #30
	ldr	r3, [fp, #-20]
	cmp	r3, r2
	blt	.L9
	mov	r3, #0
	str	r3, [fp, #-20]
	b	.L10
.L11:
	sub	r3, fp, #24
	mov	r2, #0
	mov	r1, r3
	mvn	r0, #0
	bl	waitpid
	str	r0, [fp, #-12]
	ldr	r3, [fp, #-20]
	add	r3, r3, #1
	str	r3, [fp, #-20]
.L10:
	mov	r2, #30
	ldr	r3, [fp, #-20]
	cmp	r3, r2
	blt	.L11
	ldr	r3, .L18+12
	ldr	r3, [r3]
	sub	r2, fp, #28
	mov	r1, r2
	mov	r0, r3
	bl	sem_getvalue
	bl	getpid
	mov	r1, r0
	ldr	r3, [fp, #-28]
	mov	r2, r3
	ldr	r0, .L18+28
	bl	printf
	ldr	r0, .L18+8
	bl	sem_unlink
	mov	r3, r0
	cmn	r3, #1
	bne	.L12
	ldr	r0, .L18+52
	bl	perror
	mov	r3, #1
	b	.L14
.L12:
	mov	r3, #0
.L14:
	ldr	r2, .L18
	ldr	r1, [r2]
	ldr	r2, [fp, #-8]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L15
	bl	__stack_chk_fail
.L15:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L19:
	.align	2
.L18:
	.word	.LC9
	.word	.LC0
	.word	.LC1
	.word	p_psem
	.word	.LC2
	.word	.LC3
	.word	.LC4
	.word	.LC5
	.word	.LC6
	.word	stderr
	.word	__FUNCTION__.6266
	.word	.LC7
	.word	10000
	.word	.LC8
	.size	main, .-main
	.section	.rodata
	.align	2
.LC10:
	.ascii	"\011[Child:%d] sleep(2)\012\000"
	.text
	.align	2
	.global	process_child
	.syntax unified
	.arm
	.fpu softvfp
	.type	process_child, %function
process_child:
	@ 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]
	cmp	r3, #11
	bne	.L21
	bl	abort
.L21:
	ldr	r1, [fp, #-8]
	ldr	r0, .L23
	bl	printf
	mov	r0, #2
	bl	sleep
	mov	r3, #0
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L24:
	.align	2
.L23:
	.word	.LC10
	.size	process_child, .-process_child
	.section	.rodata
	.align	2
	.type	__FUNCTION__.6266, %object
	.size	__FUNCTION__.6266, 5
__FUNCTION__.6266:
	.ascii	"main\000"
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
