	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_atmel_pmecc_correct_sector     ## -- Begin function atmel_pmecc_correct_sector
	.p2align	4, 0x90
_atmel_pmecc_correct_sector:            ## @atmel_pmecc_correct_sector
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rcx, -72(%rbp)                 ## 8-byte Spill
	movq	%rdx, -88(%rbp)                 ## 8-byte Spill
	movl	%esi, %r14d
	movq	%rdi, %rbx
	movq	8(%rdi), %r13
	callq	_get_sectorsize
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	movl	(%rbx), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movl	4(%rbx), %r15d
	movl	%r14d, %edi
	callq	_BIT
	testl	%r15d, %eax
	je	LBB0_1
## %bb.2:
	movq	%rbx, %rdi
	movl	%r14d, %esi
	callq	_atmel_pmecc_gen_syndrome
	movq	%rbx, %rdi
	callq	_atmel_pmecc_substitute
	movq	%rbx, %rdi
	callq	_atmel_pmecc_get_sigma
	movq	%rbx, %rdi
	callq	_atmel_pmecc_err_location
	movl	%eax, %ebx
	testl	%eax, %eax
	jle	LBB0_8
## %bb.3:
	movl	-48(%rbp), %eax                 ## 4-byte Reload
	addl	%eax, -44(%rbp)                 ## 4-byte Folded Spill
	cltq
	subq	%rax, -72(%rbp)                 ## 8-byte Folded Spill
	xorl	%r14d, %r14d
	movq	%r13, -80(%rbp)                 ## 8-byte Spill
	movl	%ebx, -52(%rbp)                 ## 4-byte Spill
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_4 Depth=1
	andl	$-8, %ecx
	negl	%ecx
	leal	(%rax,%rcx), %edi
	decl	%edi
	movl	%edi, -60(%rbp)                 ## 4-byte Spill
	movslq	%r15d, %rax
	movq	%rax, -96(%rbp)                 ## 8-byte Spill
	movl	(%r13), %ecx
	movl	%ecx, -56(%rbp)                 ## 4-byte Spill
	movl	(%rbx,%rax), %r13d
	callq	_BIT
	xorl	%r13d, %eax
	movl	-56(%rbp), %edi                 ## 4-byte Reload
	leaq	L_.str.3(%rip), %rsi
	movq	%r12, %rdx
	movl	%r15d, %ecx
	movl	%r13d, %r8d
	movq	-80(%rbp), %r13                 ## 8-byte Reload
	movl	%eax, %r9d
	xorl	%eax, %eax
	callq	_dev_dbg
	movl	-60(%rbp), %edi                 ## 4-byte Reload
	callq	_BIT
	movq	-96(%rbp), %rcx                 ## 8-byte Reload
	xorl	%eax, (%rbx,%rcx)
	incl	%r14d
	movl	-52(%rbp), %ebx                 ## 4-byte Reload
	cmpl	%r14d, %ebx
	je	LBB0_8
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movq	8(%r13), %rax
	movq	16(%r13), %rbx
	movl	(%rax), %edi
	movl	%r14d, %esi
	callq	_ATMEL_PMERRLOC_EL
	addq	%rax, %rbx
	movq	%rbx, %rdi
	callq	_readl_relaxed
                                        ## kill: def $eax killed $eax def $rax
	leal	-1(%rax), %edx
	leal	6(%rax), %ecx
	testl	%edx, %edx
	cmovnsl	%edx, %ecx
	movl	%ecx, %r15d
	sarl	$3, %r15d
	movq	-88(%rbp), %rbx                 ## 8-byte Reload
	leaq	L_.str(%rip), %r12
	cmpl	-48(%rbp), %r15d                ## 4-byte Folded Reload
	jl	LBB0_7
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	leaq	L_.str.1(%rip), %r12
	cmpl	-44(%rbp), %r15d                ## 4-byte Folded Reload
	jl	LBB0_7
## %bb.6:
	movl	(%r13), %edi
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	shll	$3, %ecx
	leaq	L_.str.2(%rip), %rsi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_8
LBB0_1:
	xorl	%ebx, %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$56, %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	"data"

L_.str.1:                               ## @.str.1
	.asciz	"ECC"

L_.str.2:                               ## @.str.2
	.asciz	"Invalid errpos value (%d, max is %d)\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.3:                               ## @.str.3
	.asciz	"Bit flip in %s area, byte %d: 0x%02x -> 0x%02x\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_atmel_pmecc_correct_sector     ; -- Begin function atmel_pmecc_correct_sector
	.p2align	2
_atmel_pmecc_correct_sector:            ; @atmel_pmecc_correct_sector
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.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	x23, x3
	str	x2, [sp, #48]                   ; 8-byte Folded Spill
	mov	x22, x1
	mov	x21, x0
	ldr	x26, [x0, #8]
	bl	_get_sectorsize
	str	w0, [sp, #60]                   ; 4-byte Folded Spill
	ldp	w24, w25, [x21]
	mov	x0, x22
	bl	_BIT
	tst	w0, w25
	b.eq	LBB0_7
; %bb.1:
	mov	x0, x21
	mov	x1, x22
	bl	_atmel_pmecc_gen_syndrome
	mov	x0, x21
	bl	_atmel_pmecc_substitute
	mov	x0, x21
	bl	_atmel_pmecc_get_sigma
	mov	x0, x21
	bl	_atmel_pmecc_err_location
	mov	x21, x0
	cmp	w0, #1
	b.lt	LBB0_8
; %bb.2:
	mov	w22, #0
	ldr	w8, [sp, #60]                   ; 4-byte Folded Reload
	add	w9, w24, w8
	str	w9, [sp, #44]                   ; 4-byte Folded Spill
	sub	x8, x23, w8, sxtw
	str	x8, [sp, #32]                   ; 8-byte Folded Spill
	b	LBB0_4
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	and	w9, w9, #0xfffffff8
	sub	w24, w8, w9
	sxtw	x19, w23
	ldr	w25, [x26]
	ldr	w20, [x28, x19]
	mov	x0, x24
	bl	_BIT
	eor	w8, w0, w20
	stp	x20, x8, [sp, #16]
	stp	x27, x23, [sp]
	mov	x0, x25
Lloh0:
	adrp	x1, l_.str.3@PAGE
Lloh1:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_dbg
	mov	x0, x24
	bl	_BIT
	ldr	w8, [x28, x19]
	eor	w8, w8, w0
	str	w8, [x28, x19]
	add	w22, w22, #1
	cmp	w21, w22
	b.eq	LBB0_8
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldp	x8, x23, [x26, #8]
	ldr	w0, [x8]
	mov	x1, x22
	bl	_ATMEL_PMERRLOC_EL
	add	x0, x0, x23
	bl	_readl_relaxed
	sub	w8, w0, #1
	add	w9, w8, #7
	cmp	w8, #0
	csel	w9, w9, w8, lt
	asr	w23, w9, #3
	ldr	x28, [sp, #48]                  ; 8-byte Folded Reload
Lloh2:
	adrp	x27, l_.str@PAGE
Lloh3:
	add	x27, x27, l_.str@PAGEOFF
	ldr	w10, [sp, #60]                  ; 4-byte Folded Reload
	cmp	w23, w10
	b.lt	LBB0_3
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x28, [sp, #32]                  ; 8-byte Folded Reload
Lloh4:
	adrp	x27, l_.str.1@PAGE
Lloh5:
	add	x27, x27, l_.str.1@PAGEOFF
	ldr	w10, [sp, #44]                  ; 4-byte Folded Reload
	cmp	w23, w10
	b.lt	LBB0_3
; %bb.6:
	ldr	w0, [x26]
	ldr	w9, [sp, #44]                   ; 4-byte Folded Reload
	lsl	w9, w9, #3
	stp	x8, x9, [sp]
Lloh6:
	adrp	x1, l_.str.2@PAGE
Lloh7:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_dbg
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_8
LBB0_7:
	mov	w21, #0
LBB0_8:
	mov	x0, x21
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"data"

l_.str.1:                               ; @.str.1
	.asciz	"ECC"

l_.str.2:                               ; @.str.2
	.asciz	"Invalid errpos value (%d, max is %d)\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.3:                               ; @.str.3
	.asciz	"Bit flip in %s area, byte %d: 0x%02x -> 0x%02x\n"

.subsections_via_symbols
