	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtk_ecc_encode                 ## -- Begin function mtk_ecc_encode
	.p2align	4, 0x90
_mtk_ecc_encode:                        ## @mtk_ecc_encode
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %r12d
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movq	%rdi, %r13
	movl	(%rdi), %edi
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%rdx, %rsi
	movl	%r12d, %edx
	callq	_dma_map_single
	movl	%eax, %r15d
	movl	(%r13), %edi
	movl	%eax, %esi
	callq	_dma_mapping_error
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	(%r13), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
	jmp	LBB0_7
LBB0_2:
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	movl	%r12d, -44(%rbp)                ## 4-byte Spill
	movq	_ECC_ENCODE@GOTPCREL(%rip), %rax
	movq	%rax, %rbx
	movl	(%rax), %eax
	movl	%eax, 8(%r14)
	movl	%r15d, 4(%r14)
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	_mtk_ecc_enable
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movl	%eax, %r12d
	movl	(%r13), %edi
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	%r15d, %esi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	callq	_dma_unmap_single
	jmp	LBB0_7
LBB0_4:
	movl	(%rbx), %esi
	movq	%r13, %rdi
	callq	_mtk_ecc_wait_done
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_6
## %bb.5:
	movl	(%rbx), %esi
	movq	%r13, %rdi
	callq	_mtk_ecc_wait_idle
	movq	8(%r13), %rax
	movl	(%rax), %ebx
	imull	(%r14), %ebx
	addl	$7, %ebx
	sarl	$3, %ebx
	movl	4(%r13), %ecx
	movl	%ecx, -48(%rbp)                 ## 4-byte Spill
	movq	8(%rax), %rax
	movq	_ECC_ENCPAR00@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	(%rax,%rcx,8), %r14
	addq	16(%r13), %r14
	movl	%ebx, %edi
	movl	$4, %esi
	callq	_round_up
	movl	-48(%rbp), %edi                 ## 4-byte Reload
	movq	%r14, %rsi
	movl	%eax, %edx
	callq	___ioread32_copy
	movslq	-44(%rbp), %rax                 ## 4-byte Folded Reload
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	leaq	(%rcx,%rax,4), %rdi
	movl	4(%r13), %esi
	movl	%ebx, %edx
	callq	_memcpy
LBB0_6:
	movl	(%r13), %edi
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	%r15d, %esi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	callq	_dma_unmap_single
	movq	%r13, %rdi
	callq	_mtk_ecc_disable
LBB0_7:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_DMA_TO_DEVICE,4,2              ## @DMA_TO_DEVICE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"dma mapping error\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ECC_ENCODE,4,2                 ## @ECC_ENCODE
	.comm	_ECC_ENCPAR00,8,3               ## @ECC_ENCPAR00
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtk_ecc_encode                 ; -- Begin function mtk_ecc_encode
	.p2align	2
_mtk_ecc_encode:                        ; @mtk_ecc_encode
	.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	x19, x3
	mov	x23, x2
	mov	x24, x1
	mov	x20, x0
	ldr	w0, [x0]
Lloh0:
	adrp	x27, _DMA_TO_DEVICE@GOTPAGE
Lloh1:
	ldr	x27, [x27, _DMA_TO_DEVICE@GOTPAGEOFF]
	ldr	w3, [x27]
	mov	x1, x2
	mov	x2, x19
	bl	_dma_map_single
	mov	x21, x0
	ldr	w0, [x20]
	mov	x1, x21
	bl	_dma_mapping_error
	cbz	w0, LBB0_2
; %bb.1:
	ldr	w0, [x20]
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh4:
	adrp	x8, _EINVAL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_7
LBB0_2:
Lloh7:
	adrp	x25, _ECC_ENCODE@GOTPAGE
Lloh8:
	ldr	x25, [x25, _ECC_ENCODE@GOTPAGEOFF]
	ldr	w8, [x25]
	stp	w21, w8, [x24, #4]
	mov	x0, x20
	mov	x1, x24
	bl	_mtk_ecc_enable
	cbz	w0, LBB0_4
; %bb.3:
	mov	x22, x0
	ldr	w0, [x20]
	ldr	w3, [x27]
	mov	x1, x21
	mov	x2, x19
	bl	_dma_unmap_single
	b	LBB0_7
LBB0_4:
	ldr	w1, [x25]
	mov	x0, x20
	bl	_mtk_ecc_wait_done
	mov	x22, x0
	cbnz	w0, LBB0_6
; %bb.5:
	ldr	w1, [x25]
	mov	x0, x20
	bl	_mtk_ecc_wait_idle
	ldr	w8, [x24]
	ldp	x9, x10, [x20, #8]
	ldr	w11, [x9]
	orr	w12, wzr, #0x7
	madd	w8, w11, w8, w12
	asr	w24, w8, #3
	ldr	w25, [x20, #4]
	ldr	x8, [x9, #8]
Lloh9:
	adrp	x9, _ECC_ENCPAR00@GOTPAGE
Lloh10:
	ldr	x9, [x9, _ECC_ENCPAR00@GOTPAGEOFF]
Lloh11:
	ldr	x9, [x9]
	ldr	x8, [x8, x9, lsl #3]
	add	x26, x8, x10
	mov	x0, x24
	mov	w1, #4
	bl	_round_up
	mov	x2, x0
	mov	x0, x25
	mov	x1, x26
	bl	___ioread32_copy
	add	x0, x23, w19, sxtw #2
	ldr	w1, [x20, #4]
	mov	x2, x24
	bl	_memcpy
LBB0_6:
	ldr	w0, [x20]
	ldr	w3, [x27]
	mov	x1, x21
	mov	x2, x19
	bl	_dma_unmap_single
	mov	x0, x20
	bl	_mtk_ecc_disable
LBB0_7:
	mov	x0, x22
	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	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_DMA_TO_DEVICE,4,2              ; @DMA_TO_DEVICE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"dma mapping error\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ECC_ENCODE,4,2                 ; @ECC_ENCODE
	.comm	_ECC_ENCPAR00,8,3               ; @ECC_ENCPAR00
.subsections_via_symbols
