	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_scan_erase_peb             ## -- Begin function ubi_scan_erase_peb
	.p2align	4, 0x90
_ubi_scan_erase_peb:                    ## @ubi_scan_erase_peb
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %ebx
	movl	%edx, %r14d
	movslq	%ecx, %rax
	movq	_UBI_MAX_ERASECOUNTER@GOTPCREL(%rip), %rcx
	cmpq	%rax, (%rcx)
	jle	LBB0_1
## %bb.2:
	movq	%rdi, %r12
	movl	(%rdi), %edi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_kzalloc
	testq	%rax, %rax
	je	LBB0_3
## %bb.5:
	movq	%rax, %r15
	movl	%ebx, %edi
	callq	_cpu_to_be64
	movl	%eax, (%r15)
	movq	%r12, %rdi
	movl	%r14d, %esi
	xorl	%edx, %edx
	callq	_ubi_io_sync_erase
	testl	%eax, %eax
	js	LBB0_7
## %bb.6:
	movq	%r12, %rdi
	movl	%r14d, %esi
	movq	%r15, %rdx
	callq	_ubi_io_write_ec_hdr
LBB0_7:
	movl	%eax, %ebx
	movq	%r15, %rdi
	callq	_kfree
	jmp	LBB0_8
LBB0_1:
	leaq	L_.str(%rip), %rdi
	movl	%r14d, %esi
	movl	%ebx, %edx
	callq	_ubi_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_4
LBB0_3:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
LBB0_4:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_8:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_UBI_MAX_ERASECOUNTER,8,3       ## @UBI_MAX_ERASECOUNTER
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"erase counter overflow at PEB %d, EC %d"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_scan_erase_peb             ; -- Begin function ubi_scan_erase_peb
	.p2align	2
_ubi_scan_erase_peb:                    ; @ubi_scan_erase_peb
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x22, x3
	mov	x19, x2
Lloh0:
	adrp	x8, _UBI_MAX_ERASECOUNTER@GOTPAGE
Lloh1:
	ldr	x8, [x8, _UBI_MAX_ERASECOUNTER@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	cmp	x8, w3, sxtw
	b.le	LBB0_5
; %bb.1:
	mov	x20, x0
	ldr	w0, [x0]
Lloh3:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	bl	_kzalloc
	cbz	x0, LBB0_6
; %bb.2:
	mov	x21, x0
	mov	x0, x22
	bl	_cpu_to_be64
	str	w0, [x21]
	mov	x0, x20
	mov	x1, x19
	mov	w2, #0
	bl	_ubi_io_sync_erase
	tbnz	w0, #31, LBB0_4
; %bb.3:
	mov	x0, x20
	mov	x1, x19
	mov	x2, x21
	bl	_ubi_io_write_ec_hdr
LBB0_4:
	mov	x22, x0
	mov	x0, x21
	bl	_kfree
	b	LBB0_8
LBB0_5:
Lloh6:
	adrp	x0, l_.str@PAGE
Lloh7:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x19
	mov	x2, x22
	bl	_ubi_err
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_7
LBB0_6:
Lloh10:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh11:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
LBB0_7:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_8:
	mov	x0, x22
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_UBI_MAX_ERASECOUNTER,8,3       ; @UBI_MAX_ERASECOUNTER
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"erase counter overflow at PEB %d, EC %d"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
.subsections_via_symbols
