	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sun4i_dma_prep_dma_cyclic
_sun4i_dma_prep_dma_cyclic:             ## @sun4i_dma_prep_dma_cyclic
	.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
	subq	$88, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, -104(%rbp)                 ## 8-byte Spill
	movl	%r8d, %ebx
	movq	%rcx, %r12
	movq	%rdx, %r13
	movq	%rsi, -80(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r15
	callq	_to_sun4i_dma_vchan
	movq	%rax, %r14
	movl	%ebx, -56(%rbp)                 ## 4-byte Spill
	movl	%ebx, %edi
	callq	_is_slave_direction
	testl	%eax, %eax
	je	LBB0_1
## %bb.4:
	cmpq	$0, 8(%r14)
	je	LBB0_6
## %bb.5:
	movq	%r15, %rdi
	callq	_chan2dev
	leaq	L_.str.1(%rip), %rsi
	jmp	LBB0_2
LBB0_1:
	movq	%r15, %rdi
	callq	_chan2dev
	leaq	L_.str(%rip), %rsi
LBB0_2:
	movl	%eax, %edi
	callq	_dev_err
LBB0_3:
	xorl	%eax, %eax
	addq	$88, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_6:
	movq	%r14, -64(%rbp)                 ## 8-byte Spill
	movq	%r13, -96(%rbp)                 ## 8-byte Spill
	movq	%r12, -48(%rbp)                 ## 8-byte Spill
	movq	%r15, -128(%rbp)                ## 8-byte Spill
	xorl	%eax, %eax
	callq	_generate_dma_contract
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	testq	%rax, %rax
	je	LBB0_3
## %bb.7:
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	movl	$1, (%rax)
	movq	_DMA_MEM_TO_DEV@GOTPCREL(%rip), %rcx
	movl	-56(%rbp), %eax                 ## 4-byte Reload
	cmpl	%eax, (%rcx)
	jne	LBB0_9
## %bb.8:
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	movq	24(%rbx), %r14
	movq	_SUN4I_NDMA_DRQ_TYPE_SDRAM@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_SUN4I_DMA_CFG_SRC_DRQ_TYPE
	movl	%eax, %r12d
	movl	4(%rbx), %edi
	callq	_SUN4I_DMA_CFG_DST_DRQ_TYPE
	movl	%eax, %r13d
	orl	%r12d, %r13d
	movq	_SUN4I_NDMA_ADDR_MODE_IO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_SUN4I_DMA_CFG_DST_ADDR_MODE
	orl	%r13d, %eax
	movl	%eax, -52(%rbp)                 ## 4-byte Spill
	movq	-80(%rbp), %r13                 ## 8-byte Reload
	jmp	LBB0_10
LBB0_9:
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	16(%rax), %r13
	movl	4(%rax), %edi
	callq	_SUN4I_DMA_CFG_SRC_DRQ_TYPE
	movl	%eax, %r14d
	movq	_SUN4I_NDMA_ADDR_MODE_IO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_SUN4I_DMA_CFG_SRC_ADDR_MODE
	movl	%eax, %r12d
	orl	%r14d, %r12d
	movq	_SUN4I_NDMA_DRQ_TYPE_SDRAM@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_SUN4I_DMA_CFG_DST_DRQ_TYPE
	orl	%r12d, %eax
	movl	%eax, -52(%rbp)                 ## 4-byte Spill
	movq	-80(%rbp), %r14                 ## 8-byte Reload
LBB0_10:
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movq	-96(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, %rdx
	orq	%rcx, %rdx
	shrq	$32, %rdx
	je	LBB0_11
## %bb.12:
	xorl	%edx, %edx
	divq	%rcx
	jmp	LBB0_13
LBB0_11:
                                        ## kill: def $eax killed $eax killed $rax
	xorl	%edx, %edx
	divl	%ecx
                                        ## kill: def $eax killed $eax def $rax
LBB0_13:
	movq	%rax, %rdi
	movl	$2, %esi
	callq	_DIV_ROUND_UP
	testl	%eax, %eax
	jle	LBB0_17
## %bb.14:
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	addq	$16, %rcx
	movq	%rcx, -120(%rbp)                ## 8-byte Spill
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
	leal	(%rbx,%rbx), %ecx
	movl	%ecx, -84(%rbp)                 ## 4-byte Spill
	addq	%rbx, %rbx
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
	addq	$8, %rcx
	movq	%rcx, -112(%rbp)                ## 8-byte Spill
	movl	%eax, %r15d
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	%r13, %rbx
	movslq	%r12d, %r13
	movq	-96(%rbp), %rdi                 ## 8-byte Reload
	subq	%r13, %rdi
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
	callq	_min
	addq	-80(%rbp), %r13                 ## 8-byte Folded Reload
	movl	-56(%rbp), %r9d                 ## 4-byte Reload
	movq	_DMA_MEM_TO_DEV@GOTPCREL(%rip), %rcx
	cmpl	%r9d, (%rcx)
	cmovneq	%r13, %r14
	cmovneq	%rbx, %r13
	movq	-128(%rbp), %rdi                ## 8-byte Reload
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	%eax, %ecx
	movq	-120(%rbp), %r8                 ## 8-byte Reload
	callq	_generate_ndma_promise
	testq	%rax, %rax
	je	LBB0_3
## %bb.16:                              ##   in Loop: Header=BB0_15 Depth=1
	movl	-52(%rbp), %ecx                 ## 4-byte Reload
	orl	%ecx, (%rax)
	addq	$4, %rax
	movq	%rax, %rdi
	movq	-112(%rbp), %rsi                ## 8-byte Reload
	callq	_list_add_tail
	addl	-84(%rbp), %r12d                ## 4-byte Folded Reload
	decq	%r15
	jne	LBB0_15
LBB0_17:
	movq	-72(%rbp), %rsi                 ## 8-byte Reload
	addq	$4, %rsi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movq	-104(%rbp), %rdx                ## 8-byte Reload
	addq	$88, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_vchan_tx_prep                  ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid DMA direction\n"

L_.str.1:                               ## @.str.1
	.asciz	"Cyclic transfers are only supported on Normal DMA\n"

	.comm	_DMA_MEM_TO_DEV,4,2             ## @DMA_MEM_TO_DEV
	.comm	_SUN4I_NDMA_DRQ_TYPE_SDRAM,4,2  ## @SUN4I_NDMA_DRQ_TYPE_SDRAM
	.comm	_SUN4I_NDMA_ADDR_MODE_IO,4,2    ## @SUN4I_NDMA_ADDR_MODE_IO
	.no_dead_strip	_sun4i_dma_prep_dma_cyclic
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sun4i_dma_prep_dma_cyclic
_sun4i_dma_prep_dma_cyclic:             ; @sun4i_dma_prep_dma_cyclic
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #144
	.cfi_def_cfa_offset 144
	stp	x28, x27, [sp, #48]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #64]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #80]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #96]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #112]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #128]            ; 16-byte Folded Spill
	add	x29, sp, #128
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x5
	mov	x21, x4
	mov	x27, x3
	stp	x2, x1, [sp, #32]               ; 16-byte Folded Spill
	mov	x20, x0
	bl	_to_sun4i_dma_vchan
	mov	x22, x0
	mov	x0, x21
	bl	_is_slave_direction
	cbz	w0, LBB0_3
; %bb.1:
	ldr	x8, [x22, #8]
	cbz	x8, LBB0_6
; %bb.2:
	mov	x0, x20
	bl	_chan2dev
Lloh0:
	adrp	x1, l_.str.1@PAGE
Lloh1:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_4
LBB0_3:
	mov	x0, x20
	bl	_chan2dev
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
LBB0_4:
	bl	_dev_err
LBB0_5:
	mov	x0, #0
	ldp	x29, x30, [sp, #128]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #112]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #96]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #80]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #64]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #144
	ret
LBB0_6:
	str	x22, [sp, #16]                  ; 8-byte Folded Spill
	str	x19, [sp]                       ; 8-byte Folded Spill
	bl	_generate_dma_contract
	str	x0, [sp, #8]                    ; 8-byte Folded Spill
	cbz	x0, LBB0_5
; %bb.7:
	mov	w8, #1
	ldp	x9, x22, [sp, #8]               ; 16-byte Folded Reload
	str	w8, [x9]
Lloh4:
	adrp	x8, _DMA_MEM_TO_DEV@GOTPAGE
Lloh5:
	ldr	x8, [x8, _DMA_MEM_TO_DEV@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	cmp	w8, w21
	b.ne	LBB0_9
; %bb.8:
	ldr	x26, [x22, #24]
Lloh7:
	adrp	x8, _SUN4I_NDMA_DRQ_TYPE_SDRAM@GOTPAGE
Lloh8:
	ldr	x8, [x8, _SUN4I_NDMA_DRQ_TYPE_SDRAM@GOTPAGEOFF]
Lloh9:
	ldr	w0, [x8]
	bl	_SUN4I_DMA_CFG_SRC_DRQ_TYPE
	mov	x19, x0
	ldr	w0, [x22, #4]
	bl	_SUN4I_DMA_CFG_DST_DRQ_TYPE
	orr	w19, w0, w19
Lloh10:
	adrp	x8, _SUN4I_NDMA_ADDR_MODE_IO@GOTPAGE
Lloh11:
	ldr	x8, [x8, _SUN4I_NDMA_ADDR_MODE_IO@GOTPAGEOFF]
Lloh12:
	ldr	w0, [x8]
	bl	_SUN4I_DMA_CFG_DST_ADDR_MODE
	orr	w8, w19, w0
	str	w8, [sp, #28]                   ; 4-byte Folded Spill
	ldr	x28, [sp, #40]                  ; 8-byte Folded Reload
	b	LBB0_10
LBB0_9:
	ldr	x28, [x22, #16]
	ldr	w0, [x22, #4]
	bl	_SUN4I_DMA_CFG_SRC_DRQ_TYPE
	mov	x19, x0
Lloh13:
	adrp	x8, _SUN4I_NDMA_ADDR_MODE_IO@GOTPAGE
Lloh14:
	ldr	x8, [x8, _SUN4I_NDMA_ADDR_MODE_IO@GOTPAGEOFF]
Lloh15:
	ldr	w0, [x8]
	bl	_SUN4I_DMA_CFG_SRC_ADDR_MODE
	orr	w19, w0, w19
Lloh16:
	adrp	x8, _SUN4I_NDMA_DRQ_TYPE_SDRAM@GOTPAGE
Lloh17:
	ldr	x8, [x8, _SUN4I_NDMA_DRQ_TYPE_SDRAM@GOTPAGEOFF]
Lloh18:
	ldr	w0, [x8]
	bl	_SUN4I_DMA_CFG_DST_DRQ_TYPE
	orr	w8, w19, w0
	str	w8, [sp, #28]                   ; 4-byte Folded Spill
	ldr	x26, [sp, #40]                  ; 8-byte Folded Reload
LBB0_10:
	ldr	x8, [sp, #32]                   ; 8-byte Folded Reload
	udiv	x0, x8, x27
	mov	w1, #2
	bl	_DIV_ROUND_UP
	cmp	w0, #1
	b.lt	LBB0_14
; %bb.11:
	mov	w22, #0
	ldr	x8, [sp, #16]                   ; 8-byte Folded Reload
	add	x25, x8, #16
	lsl	w8, w27, #1
	str	w8, [sp, #24]                   ; 4-byte Folded Spill
	lsl	x27, x27, #1
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	add	x19, x8, #8
	mov	w24, w0
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	sxtw	x23, w22
	ldr	x8, [sp, #32]                   ; 8-byte Folded Reload
	sub	x0, x8, x23
	mov	x1, x27
	bl	_min
	mov	x3, x0
Lloh19:
	adrp	x8, _DMA_MEM_TO_DEV@GOTPAGE
Lloh20:
	ldr	x8, [x8, _DMA_MEM_TO_DEV@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
	ldr	x9, [sp, #40]                   ; 8-byte Folded Reload
	add	x9, x23, x9
	cmp	w8, w21
	csel	x26, x26, x9, eq
	csel	x28, x9, x28, eq
	mov	x0, x20
	mov	x1, x28
	mov	x2, x26
	mov	x4, x25
	mov	x5, x21
	bl	_generate_ndma_promise
	cbz	x0, LBB0_5
; %bb.13:                               ;   in Loop: Header=BB0_12 Depth=1
	ldr	w8, [x0]
	ldr	w9, [sp, #28]                   ; 4-byte Folded Reload
	orr	w8, w8, w9
	str	w8, [x0], #4
	mov	x1, x19
	bl	_list_add_tail
	ldr	w8, [sp, #24]                   ; 4-byte Folded Reload
	add	w22, w22, w8
	subs	x24, x24, #1
	b.ne	LBB0_12
LBB0_14:
	ldp	x8, x0, [sp, #8]                ; 16-byte Folded Reload
	add	x1, x8, #4
	ldr	x2, [sp]                        ; 8-byte Folded Reload
	ldp	x29, x30, [sp, #128]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #112]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #96]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #80]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #64]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #144
	b	_vchan_tx_prep
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid DMA direction\n"

l_.str.1:                               ; @.str.1
	.asciz	"Cyclic transfers are only supported on Normal DMA\n"

	.comm	_DMA_MEM_TO_DEV,4,2             ; @DMA_MEM_TO_DEV
	.comm	_SUN4I_NDMA_DRQ_TYPE_SDRAM,4,2  ; @SUN4I_NDMA_DRQ_TYPE_SDRAM
	.comm	_SUN4I_NDMA_ADDR_MODE_IO,4,2    ; @SUN4I_NDMA_ADDR_MODE_IO
	.no_dead_strip	_sun4i_dma_prep_dma_cyclic
.subsections_via_symbols
