	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function d40_free_dma
_d40_free_dma:                          ## @d40_free_dma
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	movl	40(%rdi), %edi
	callq	_D40_TYPE_TO_EVENT
	movl	%eax, %r12d
	movq	24(%rbx), %r15
	movq	%rbx, %rdi
	callq	_d40_term_all
	testq	%r15, %r15
	je	LBB0_1
## %bb.3:
	movq	(%r15), %rax
	movq	_D40_ALLOC_FREE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_6
## %bb.4:
	cmpq	%rax, 8(%r15)
	jne	LBB0_6
## %bb.5:
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_2
LBB0_6:
	movq	32(%rbx), %rax
	movq	_DMA_MEM_TO_DEV@GOTPCREL(%rip), %rcx
	xorl	%r13d, %r13d
	cmpq	(%rcx), %rax
	je	LBB0_10
## %bb.7:
	movq	_DMA_MEM_TO_MEM@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_10
## %bb.8:
	movq	_DMA_DEV_TO_MEM@GOTPCREL(%rip), %rcx
	movl	$1, %r13d
	cmpq	(%rcx), %rax
	jne	LBB0_9
LBB0_10:
	movq	16(%rbx), %rax
	movl	(%rax), %edi
	callq	_pm_runtime_get_sync
	movq	_D40_DMA_STOP@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_d40_channel_execute_command
	movl	%eax, %r14d
	testl	%eax, %eax
	je	LBB0_12
## %bb.11:
	leaq	L_.str.3(%rip), %rsi
	movq	%rbx, %rdi
	callq	_chan_err
	jmp	LBB0_15
LBB0_1:
	leaq	L_.str(%rip), %rsi
	jmp	LBB0_2
LBB0_12:
	movq	%rbx, %rdi
	callq	_chan_is_logical
	xorl	%ecx, %ecx
	testq	%rax, %rax
	cmovel	%ecx, %r12d
	movq	%r15, %rdi
	movl	%r13d, %esi
	movl	%r12d, %edx
	callq	_d40_alloc_mask_free
	movq	%rbx, %rdi
	callq	_chan_is_logical
	addq	$16, %r15
	xorl	%ecx, %ecx
	testq	%rax, %rax
	setne	%cl
	movq	16(%rbx), %rax
	cmovneq	%rbx, %r15
	movq	8(%rax,%rcx,8), %rax
	movq	(%r15), %rcx
	movq	$0, (%rax,%rcx,8)
	cmpl	$0, 8(%rbx)
	je	LBB0_14
## %bb.13:
	movq	16(%rbx), %rax
	movl	(%rax), %edi
	callq	_pm_runtime_mark_last_busy
	movq	16(%rbx), %rax
	movl	(%rax), %edi
	callq	_pm_runtime_put_autosuspend
LBB0_14:
	movq	$0, 8(%rbx)
	movq	$0, 24(%rbx)
LBB0_15:
	movq	16(%rbx), %rax
	movl	(%rax), %edi
	callq	_pm_runtime_mark_last_busy
	movq	16(%rbx), %rax
	movl	(%rax), %edi
	callq	_pm_runtime_put_autosuspend
	jmp	LBB0_16
LBB0_9:
	leaq	L_.str.2(%rip), %rsi
LBB0_2:
	movq	%rbx, %rdi
	callq	_chan_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
LBB0_16:
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"phy == null\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_D40_ALLOC_FREE,8,3             ## @D40_ALLOC_FREE
L_.str.1:                               ## @.str.1
	.asciz	"channel already free\n"

	.comm	_DMA_MEM_TO_DEV,8,3             ## @DMA_MEM_TO_DEV
	.comm	_DMA_MEM_TO_MEM,8,3             ## @DMA_MEM_TO_MEM
	.comm	_DMA_DEV_TO_MEM,8,3             ## @DMA_DEV_TO_MEM
L_.str.2:                               ## @.str.2
	.asciz	"Unknown direction\n"

	.comm	_D40_DMA_STOP,4,2               ## @D40_DMA_STOP
L_.str.3:                               ## @.str.3
	.asciz	"stop failed\n"

	.no_dead_strip	_d40_free_dma
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function d40_free_dma
_d40_free_dma:                          ; @d40_free_dma
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x19, x0
	ldr	w0, [x0, #40]
	bl	_D40_TYPE_TO_EVENT
	mov	x22, x0
	ldr	x21, [x19, #24]
	mov	x0, x19
	bl	_d40_term_all
	cbz	x21, LBB0_6
; %bb.1:
	ldr	x8, [x21]
Lloh0:
	adrp	x9, _D40_ALLOC_FREE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _D40_ALLOC_FREE@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_4
; %bb.2:
	ldr	x9, [x21, #8]
	cmp	x9, x8
	b.ne	LBB0_4
; %bb.3:
Lloh3:
	adrp	x1, l_.str.1@PAGE
Lloh4:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_16
LBB0_4:
	ldr	x8, [x19, #32]
Lloh5:
	adrp	x9, _DMA_MEM_TO_DEV@GOTPAGE
Lloh6:
	ldr	x9, [x9, _DMA_MEM_TO_DEV@GOTPAGEOFF]
Lloh7:
	ldr	x9, [x9]
Lloh8:
	adrp	x10, _DMA_MEM_TO_MEM@GOTPAGE
Lloh9:
	ldr	x10, [x10, _DMA_MEM_TO_MEM@GOTPAGEOFF]
Lloh10:
	ldr	x10, [x10]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_7
; %bb.5:
	mov	w23, #0
	b	LBB0_9
LBB0_6:
Lloh11:
	adrp	x1, l_.str@PAGE
Lloh12:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_16
LBB0_7:
Lloh13:
	adrp	x9, _DMA_DEV_TO_MEM@GOTPAGE
Lloh14:
	ldr	x9, [x9, _DMA_DEV_TO_MEM@GOTPAGEOFF]
Lloh15:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_15
; %bb.8:
	mov	w23, #1
LBB0_9:
	ldr	x8, [x19, #16]
	ldr	w0, [x8]
	bl	_pm_runtime_get_sync
Lloh16:
	adrp	x8, _D40_DMA_STOP@GOTPAGE
Lloh17:
	ldr	x8, [x8, _D40_DMA_STOP@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_d40_channel_execute_command
	mov	x20, x0
	cbz	w0, LBB0_11
; %bb.10:
Lloh19:
	adrp	x1, l_.str.3@PAGE
Lloh20:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x19
	bl	_chan_err
	b	LBB0_14
LBB0_11:
	mov	x0, x19
	bl	_chan_is_logical
	cmp	x0, #0
	csel	w2, wzr, w22, eq
	mov	x0, x21
	mov	x1, x23
	bl	_d40_alloc_mask_free
	mov	x0, x19
	bl	_chan_is_logical
	ldr	x8, [x19, #16]
	add	x9, x21, #16
	cmp	x0, #0
	csel	x9, x9, x19, eq
	mov	w10, #16
	mov	w11, #8
	csel	x10, x11, x10, eq
	ldr	x8, [x8, x10]
	ldr	x9, [x9]
	str	xzr, [x8, x9, lsl #3]
	ldr	w8, [x19, #8]
	cbz	w8, LBB0_13
; %bb.12:
	ldr	x8, [x19, #16]
	ldr	w0, [x8]
	bl	_pm_runtime_mark_last_busy
	ldr	x8, [x19, #16]
	ldr	w0, [x8]
	bl	_pm_runtime_put_autosuspend
LBB0_13:
	str	xzr, [x19, #24]
	str	xzr, [x19, #8]
LBB0_14:
	ldr	x8, [x19, #16]
	ldr	w0, [x8]
	bl	_pm_runtime_mark_last_busy
	ldr	x8, [x19, #16]
	ldr	w0, [x8]
	bl	_pm_runtime_put_autosuspend
	b	LBB0_17
LBB0_15:
Lloh21:
	adrp	x1, l_.str.2@PAGE
Lloh22:
	add	x1, x1, l_.str.2@PAGEOFF
LBB0_16:
	mov	x0, x19
	bl	_chan_err
Lloh23:
	adrp	x8, _EINVAL@GOTPAGE
Lloh24:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh25:
	ldr	w8, [x8]
	neg	w20, w8
LBB0_17:
	mov	x0, x20
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"phy == null\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_D40_ALLOC_FREE,8,3             ; @D40_ALLOC_FREE
l_.str.1:                               ; @.str.1
	.asciz	"channel already free\n"

	.comm	_DMA_MEM_TO_DEV,8,3             ; @DMA_MEM_TO_DEV
	.comm	_DMA_MEM_TO_MEM,8,3             ; @DMA_MEM_TO_MEM
	.comm	_DMA_DEV_TO_MEM,8,3             ; @DMA_DEV_TO_MEM
l_.str.2:                               ; @.str.2
	.asciz	"Unknown direction\n"

	.comm	_D40_DMA_STOP,4,2               ; @D40_DMA_STOP
l_.str.3:                               ; @.str.3
	.asciz	"stop failed\n"

	.no_dead_strip	_d40_free_dma
.subsections_via_symbols
