	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function s3cmci_prepare_dma
_s3cmci_prepare_dma:                    ## @s3cmci_prepare_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
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r15
	movq	%rdi, %r14
	movl	(%rsi), %eax
	movq	_MMC_DATA_WRITE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ebx
	andl	%eax, %ebx
	movq	_BOTH_DIR@GOTPCREL(%rip), %rcx
	notl	%eax
	xorl	%edi, %edi
	andl	(%rcx), %eax
	sete	%dil
	callq	_BUG_ON
	testl	%ebx, %ebx
	movq	_S3C2410_DMASRC_MEM@GOTPCREL(%rip), %rax
	cmoveq	_S3C2410_DMASRC_HW@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rbx
	cmoveq	_DMA_FROM_DEVICE@GOTPCREL(%rip), %rbx
	movq	%r14, %rdi
	callq	_s3cmci_dma_setup
	movl	4(%r14), %edi
	movq	_S3C2410_DMAOP_FLUSH@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_s3c2410_dma_ctrl
	movl	16(%r14), %edi
	callq	_mmc_dev
	movq	8(%r15), %rsi
	movq	%r15, -72(%rbp)                 ## 8-byte Spill
	movl	16(%r15), %edx
	movl	(%rbx), %ecx
	movl	%eax, %edi
	callq	_dma_map_sg
	testl	%eax, %eax
	je	LBB0_1
## %bb.3:
	movq	$0, 8(%r14)
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movl	%eax, (%r14)
	jle	LBB0_8
## %bb.4:
	movl	%eax, %eax
	shlq	$2, %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
	movq	-72(%rbp), %r15                 ## 8-byte Reload
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	_dbg_dma@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	8(%r15), %rdi
	addq	%r14, %rdi
	callq	_sg_dma_address
	movl	%eax, %r13d
	movq	8(%r15), %rdi
	addq	%r14, %rdi
	callq	_sg_dma_len
	movq	%r12, %rdi
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	leaq	L_.str(%rip), %rdx
	movl	%ebx, %ecx
	movl	%r13d, %r8d
	movl	%eax, %r9d
	callq	_dbg
	movl	4(%r12), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	8(%r15), %rdi
	addq	%r14, %rdi
	callq	_sg_dma_address
	movl	%eax, %r13d
	movq	8(%r15), %rdi
	addq	%r14, %rdi
	callq	_sg_dma_len
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movq	%r12, %rsi
	movl	%r13d, %edx
	movl	%eax, %ecx
	callq	_s3c2410_dma_enqueue
	testl	%eax, %eax
	jne	LBB0_7
## %bb.5:                               ##   in Loop: Header=BB0_6 Depth=1
	incl	%ebx
	addq	$4, %r14
	cmpq	%r14, -64(%rbp)                 ## 8-byte Folded Reload
	jne	LBB0_6
LBB0_8:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	4(%rax), %edi
	movq	_S3C2410_DMAOP_START@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_s3c2410_dma_ctrl
	xorl	%eax, %eax
	jmp	LBB0_9
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
LBB0_7:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	4(%rax), %edi
	movq	_S3C2410_DMAOP_FLUSH@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_s3c2410_dma_ctrl
	movq	_EBUSY@GOTPCREL(%rip), %rcx
LBB0_2:
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_9:
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MMC_DATA_WRITE,4,2             ## @MMC_DATA_WRITE
	.comm	_BOTH_DIR,4,2                   ## @BOTH_DIR
	.comm	_S3C2410_DMASRC_MEM,4,2         ## @S3C2410_DMASRC_MEM
	.comm	_S3C2410_DMASRC_HW,4,2          ## @S3C2410_DMASRC_HW
	.comm	_S3C2410_DMAOP_FLUSH,4,2        ## @S3C2410_DMAOP_FLUSH
	.comm	_DMA_TO_DEVICE,4,2              ## @DMA_TO_DEVICE
	.comm	_DMA_FROM_DEVICE,4,2            ## @DMA_FROM_DEVICE
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_dbg_dma,4,2                    ## @dbg_dma
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"enqueue %i: %08x@%u\n"

	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_S3C2410_DMAOP_START,4,2        ## @S3C2410_DMAOP_START
	.no_dead_strip	_s3cmci_prepare_dma
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function s3cmci_prepare_dma
_s3cmci_prepare_dma:                    ; @s3cmci_prepare_dma
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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	x20, x1
	mov	x19, x0
	ldr	w21, [x1]
Lloh0:
	adrp	x8, _MMC_DATA_WRITE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MMC_DATA_WRITE@GOTPAGEOFF]
Lloh2:
	ldr	w22, [x8]
Lloh3:
	adrp	x8, _BOTH_DIR@GOTPAGE
Lloh4:
	ldr	x8, [x8, _BOTH_DIR@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	bics	wzr, w8, w21
	cset	w0, eq
	bl	_BUG_ON
Lloh6:
	adrp	x8, _S3C2410_DMASRC_MEM@GOTPAGE
Lloh7:
	ldr	x8, [x8, _S3C2410_DMASRC_MEM@GOTPAGEOFF]
Lloh8:
	adrp	x9, _S3C2410_DMASRC_HW@GOTPAGE
Lloh9:
	ldr	x9, [x9, _S3C2410_DMASRC_HW@GOTPAGEOFF]
	tst	w22, w21
	csel	x8, x9, x8, eq
	ldr	w1, [x8]
Lloh10:
	adrp	x8, _DMA_TO_DEVICE@GOTPAGE
Lloh11:
	ldr	x8, [x8, _DMA_TO_DEVICE@GOTPAGEOFF]
Lloh12:
	adrp	x9, _DMA_FROM_DEVICE@GOTPAGE
Lloh13:
	ldr	x9, [x9, _DMA_FROM_DEVICE@GOTPAGEOFF]
	csel	x21, x9, x8, eq
	mov	x0, x19
	bl	_s3cmci_dma_setup
	ldr	w0, [x19, #4]
Lloh14:
	adrp	x25, _S3C2410_DMAOP_FLUSH@GOTPAGE
Lloh15:
	ldr	x25, [x25, _S3C2410_DMAOP_FLUSH@GOTPAGEOFF]
	ldr	w1, [x25]
	bl	_s3c2410_dma_ctrl
	ldr	w0, [x19, #16]
	bl	_mmc_dev
	ldr	x1, [x20, #8]
	ldr	w2, [x20, #16]
	ldr	w3, [x21]
	bl	_dma_map_sg
	cbz	w0, LBB0_6
; %bb.1:
	str	xzr, [x19, #8]
	str	w0, [x19]
	cmp	w0, #1
	b.lt	LBB0_5
; %bb.2:
	mov	x26, #0
	mov	w21, #0
	mov	w8, w0
	lsl	x27, x8, #2
Lloh16:
	adrp	x28, _dbg_dma@GOTPAGE
Lloh17:
	ldr	x28, [x28, _dbg_dma@GOTPAGEOFF]
Lloh18:
	adrp	x22, l_.str@PAGE
Lloh19:
	add	x22, x22, l_.str@PAGEOFF
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w23, [x28]
	ldr	x8, [x20, #8]
	add	x0, x8, x26
	bl	_sg_dma_address
	mov	x24, x0
	ldr	x8, [x20, #8]
	add	x0, x8, x26
	bl	_sg_dma_len
	mov	x5, x0
	mov	x0, x19
	mov	x1, x23
	mov	x2, x22
	mov	x3, x21
	mov	x4, x24
	bl	_dbg
	ldr	w23, [x19, #4]
	ldr	x8, [x20, #8]
	add	x0, x8, x26
	bl	_sg_dma_address
	mov	x24, x0
	ldr	x8, [x20, #8]
	add	x0, x8, x26
	bl	_sg_dma_len
	mov	x3, x0
	mov	x0, x23
	mov	x1, x19
	mov	x2, x24
	bl	_s3c2410_dma_enqueue
	cbnz	w0, LBB0_7
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	add	w21, w21, #1
	add	x26, x26, #4
	cmp	x27, x26
	b.ne	LBB0_3
LBB0_5:
	ldr	w0, [x19, #4]
Lloh20:
	adrp	x8, _S3C2410_DMAOP_START@GOTPAGE
Lloh21:
	ldr	x8, [x8, _S3C2410_DMAOP_START@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	bl	_s3c2410_dma_ctrl
	mov	w0, #0
	b	LBB0_9
LBB0_6:
Lloh23:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh24:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_8
LBB0_7:
	ldr	w0, [x19, #4]
	ldr	w1, [x25]
	bl	_s3c2410_dma_ctrl
Lloh25:
	adrp	x8, _EBUSY@GOTPAGE
Lloh26:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
LBB0_8:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_9:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_MMC_DATA_WRITE,4,2             ; @MMC_DATA_WRITE
	.comm	_BOTH_DIR,4,2                   ; @BOTH_DIR
	.comm	_S3C2410_DMASRC_MEM,4,2         ; @S3C2410_DMASRC_MEM
	.comm	_S3C2410_DMASRC_HW,4,2          ; @S3C2410_DMASRC_HW
	.comm	_S3C2410_DMAOP_FLUSH,4,2        ; @S3C2410_DMAOP_FLUSH
	.comm	_DMA_TO_DEVICE,4,2              ; @DMA_TO_DEVICE
	.comm	_DMA_FROM_DEVICE,4,2            ; @DMA_FROM_DEVICE
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_dbg_dma,4,2                    ; @dbg_dma
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"enqueue %i: %08x@%u\n"

	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_S3C2410_DMAOP_START,4,2        ; @S3C2410_DMAOP_START
	.no_dead_strip	_s3cmci_prepare_dma
.subsections_via_symbols
