	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function chap_Cleanup
_chap_Cleanup:                          ## @chap_Cleanup
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	%rdi, %rbx
	cmpq	$0, 40(%rdi)
	je	LBB0_11
## %bb.1:
	movl	%esi, %r14d
	movl	24(%rbx), %edi
	callq	_close
	movl	$-1, 24(%rbx)
	testl	%r14d, %r14d
	je	LBB0_3
## %bb.2:
	movq	40(%rbx), %rdi
	movq	_SIGTERM@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_kill
LBB0_3:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 32(%rbx)
	leaq	-20(%rbp), %rdi
	callq	_wait
	cmpl	$-1, %eax
	je	LBB0_4
## %bb.5:
	movl	-20(%rbp), %edi
	callq	_WIFSIGNALED
	testq	%rax, %rax
	je	LBB0_7
## %bb.6:
	movq	_LogWARN@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	movl	-20(%rbp), %edi
	callq	_WTERMSIG
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_10
LBB0_4:
	movq	_LogERROR@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	movq	_errno@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_strerror
	leaq	L_.str(%rip), %rsi
	jmp	LBB0_10
LBB0_7:
	movl	-20(%rbp), %edi
	callq	_WIFEXITED
	testq	%rax, %rax
	je	LBB0_11
## %bb.8:
	movl	-20(%rbp), %edi
	callq	_WEXITSTATUS
	testq	%rax, %rax
	je	LBB0_11
## %bb.9:
	movq	_LogERROR@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	movl	-20(%rbp), %edi
	callq	_WEXITSTATUS
	leaq	L_.str.2(%rip), %rsi
LBB0_10:
	movl	%r14d, %edi
	movq	%rax, %rdx
	callq	_log_Printf
LBB0_11:
	movq	16(%rbx), %rax
	movb	$0, (%rax)
	movq	8(%rbx), %rax
	movb	$0, (%rax)
	movq	$0, (%rbx)
	addq	$16, %rsp
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SIGTERM,4,2                    ## @SIGTERM
	.comm	_LogERROR,4,2                   ## @LogERROR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Chap: wait: %s\n"

	.comm	_errno,4,2                      ## @errno
	.comm	_LogWARN,4,2                    ## @LogWARN
L_.str.1:                               ## @.str.1
	.asciz	"Chap: Child received signal %d\n"

L_.str.2:                               ## @.str.2
	.asciz	"Chap: Child exited %d\n"

	.no_dead_strip	_chap_Cleanup
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function chap_Cleanup
_chap_Cleanup:                          ; @chap_Cleanup
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	ldr	x8, [x0, #40]
	cbz	x8, LBB0_11
; %bb.1:
	mov	x20, x1
	ldr	w0, [x19, #24]
	bl	_close
	mov	w8, #-1
	str	w8, [x19, #24]
	cbz	w20, LBB0_3
; %bb.2:
	ldr	x0, [x19, #40]
Lloh0:
	adrp	x8, _SIGTERM@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SIGTERM@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	bl	_kill
LBB0_3:
	stp	xzr, xzr, [x19, #32]
	add	x0, sp, #12
	bl	_wait
	cmn	w0, #1
	b.eq	LBB0_6
; %bb.4:
	ldr	w0, [sp, #12]
	bl	_WIFSIGNALED
	cbz	x0, LBB0_7
; %bb.5:
Lloh3:
	adrp	x8, _LogWARN@GOTPAGE
Lloh4:
	ldr	x8, [x8, _LogWARN@GOTPAGEOFF]
Lloh5:
	ldr	w20, [x8]
	ldr	w0, [sp, #12]
	bl	_WTERMSIG
	mov	x2, x0
Lloh6:
	adrp	x1, l_.str.1@PAGE
Lloh7:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_10
LBB0_6:
Lloh8:
	adrp	x8, _LogERROR@GOTPAGE
Lloh9:
	ldr	x8, [x8, _LogERROR@GOTPAGEOFF]
Lloh10:
	ldr	w20, [x8]
Lloh11:
	adrp	x8, _errno@GOTPAGE
Lloh12:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh13:
	ldr	w0, [x8]
	bl	_strerror
	mov	x2, x0
Lloh14:
	adrp	x1, l_.str@PAGE
Lloh15:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_10
LBB0_7:
	ldr	w0, [sp, #12]
	bl	_WIFEXITED
	cbz	x0, LBB0_11
; %bb.8:
	ldr	w0, [sp, #12]
	bl	_WEXITSTATUS
	cbz	x0, LBB0_11
; %bb.9:
Lloh16:
	adrp	x8, _LogERROR@GOTPAGE
Lloh17:
	ldr	x8, [x8, _LogERROR@GOTPAGEOFF]
Lloh18:
	ldr	w20, [x8]
	ldr	w0, [sp, #12]
	bl	_WEXITSTATUS
	mov	x2, x0
Lloh19:
	adrp	x1, l_.str.2@PAGE
Lloh20:
	add	x1, x1, l_.str.2@PAGEOFF
LBB0_10:
	mov	x0, x20
	bl	_log_Printf
LBB0_11:
	ldr	x8, [x19, #16]
	strb	wzr, [x8]
	ldr	x8, [x19, #8]
	strb	wzr, [x8]
	str	xzr, [x19]
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.cfi_endproc
                                        ; -- End function
	.comm	_SIGTERM,4,2                    ; @SIGTERM
	.comm	_LogERROR,4,2                   ; @LogERROR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Chap: wait: %s\n"

	.comm	_errno,4,2                      ; @errno
	.comm	_LogWARN,4,2                    ; @LogWARN
l_.str.1:                               ; @.str.1
	.asciz	"Chap: Child received signal %d\n"

l_.str.2:                               ; @.str.2
	.asciz	"Chap: Child exited %d\n"

	.no_dead_strip	_chap_Cleanup
.subsections_via_symbols
