	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function nor_erase_prepare
_nor_erase_prepare:                     ## @nor_erase_prepare
	.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
	movl	%esi, %r15d
	movq	%rdi, %r14
	movq	$0, -48(%rbp)
	movl	(%rdi), %r12d
	imull	%esi, %r12d
	leaq	-72(%rbp), %rdx
	xorl	%ecx, %ecx
	callq	_ubi_io_read_ec_hdr
	movq	_UBI_IO_BAD_HDR_EBADMSG@GOTPCREL(%rip), %rsi
	movq	_UBI_IO_BAD_HDR@GOTPCREL(%rip), %rdx
	movq	_UBI_IO_FF@GOTPCREL(%rip), %rcx
	cmpl	(%rsi), %eax
	je	LBB0_4
## %bb.1:
	cmpl	(%rdx), %eax
	je	LBB0_4
## %bb.2:
	cmpl	(%rcx), %eax
	je	LBB0_4
## %bb.3:
	movl	4(%r14), %edi
	leaq	-80(%rbp), %rcx
	leaq	-48(%rbp), %r8
	movl	%r12d, %esi
	movl	$4, %edx
	callq	_mtd_write
	testl	%eax, %eax
	jne	LBB0_8
LBB0_4:
	leaq	-64(%rbp), %r13
	leaq	-56(%rbp), %rbx
	movq	%r14, %rdi
	movq	%r13, %rsi
	movq	%rbx, %rdx
	callq	_ubi_init_vid_buf
	movq	%r13, %rdi
	callq	_ubi_get_vid_hdr
	xorl	%edi, %edi
	cmpq	%rax, %rbx
	sete	%dil
	callq	_ubi_assert
	movq	%r14, %rdi
	movl	%r15d, %esi
	movq	%r13, %rdx
	xorl	%ecx, %ecx
	callq	_ubi_io_read_vid_hdr
	movq	_UBI_IO_BAD_HDR_EBADMSG@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	je	LBB0_11
## %bb.5:
	movq	_UBI_IO_BAD_HDR@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	je	LBB0_11
## %bb.6:
	movq	_UBI_IO_FF@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	movl	$0, %ebx
	je	LBB0_9
## %bb.7:
	addl	8(%r14), %r12d
	movl	4(%r14), %edi
	leaq	-80(%rbp), %rcx
	leaq	-48(%rbp), %r8
	movl	%r12d, %esi
	movl	$4, %edx
	callq	_mtd_write
	testl	%eax, %eax
	je	LBB0_9
LBB0_8:
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
	movl	%r15d, %edx
	movl	%eax, %ecx
	callq	_ubi_err
	movl	(%r14), %ecx
	xorl	%ebx, %ebx
	movq	%r14, %rdi
	movl	%r15d, %esi
	xorl	%edx, %edx
	callq	_ubi_dump_flash
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_9
LBB0_11:
	xorl	%ebx, %ebx
LBB0_9:
	movl	%ebx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_UBI_IO_BAD_HDR_EBADMSG,4,2     ## @UBI_IO_BAD_HDR_EBADMSG
	.comm	_UBI_IO_BAD_HDR,4,2             ## @UBI_IO_BAD_HDR
	.comm	_UBI_IO_FF,4,2                  ## @UBI_IO_FF
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cannot invalidate PEB %d, write returned %d"

	.comm	_EIO,4,2                        ## @EIO
	.no_dead_strip	_nor_erase_prepare
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function nor_erase_prepare
_nor_erase_prepare:                     ; @nor_erase_prepare
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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
	mov	x19, x1
	mov	x20, x0
	str	xzr, [sp, #32]
	ldr	w8, [x0]
	mul	w21, w8, w1
	add	x2, sp, #24
	mov	w3, #0
	bl	_ubi_io_read_ec_hdr
Lloh0:
	adrp	x22, _UBI_IO_BAD_HDR_EBADMSG@GOTPAGE
Lloh1:
	ldr	x22, [x22, _UBI_IO_BAD_HDR_EBADMSG@GOTPAGEOFF]
	ldr	w8, [x22]
Lloh2:
	adrp	x23, _UBI_IO_BAD_HDR@GOTPAGE
Lloh3:
	ldr	x23, [x23, _UBI_IO_BAD_HDR@GOTPAGEOFF]
	ldr	w9, [x23]
Lloh4:
	adrp	x24, _UBI_IO_FF@GOTPAGE
Lloh5:
	ldr	x24, [x24, _UBI_IO_FF@GOTPAGEOFF]
	ldr	w10, [x24]
	cmp	w0, w8
	ccmp	w0, w9, #4, ne
	ccmp	w0, w10, #4, ne
	b.eq	LBB0_2
; %bb.1:
	ldr	w0, [x20, #4]
	add	x3, sp, #40
	add	x4, sp, #32
	mov	x1, x21
	mov	w2, #4
	bl	_mtd_write
	mov	x3, x0
	cbnz	w0, LBB0_4
LBB0_2:
	add	x25, sp, #8
	add	x1, sp, #16
	add	x2, sp, #8
	mov	x0, x20
	bl	_ubi_init_vid_buf
	add	x0, sp, #16
	bl	_ubi_get_vid_hdr
	cmp	x25, x0
	cset	w0, eq
	bl	_ubi_assert
	add	x2, sp, #16
	mov	x0, x20
	mov	x1, x19
	mov	w3, #0
	bl	_ubi_io_read_vid_hdr
	mov	x8, x0
	mov	w0, #0
	ldr	w9, [x22]
	ldr	w10, [x23]
	ldr	w11, [x24]
	cmp	w8, w9
	ccmp	w8, w10, #4, ne
	ccmp	w8, w11, #4, ne
	b.eq	LBB0_5
; %bb.3:
	ldp	w0, w8, [x20, #4]
	add	w1, w21, w8
	add	x3, sp, #40
	add	x4, sp, #32
	mov	w2, #4
	bl	_mtd_write
	mov	x3, x0
	cbz	w0, LBB0_5
LBB0_4:
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	mov	x2, x19
	bl	_ubi_err
	ldr	w3, [x20]
	mov	x0, x20
	mov	x1, x19
	mov	w2, #0
	bl	_ubi_dump_flash
Lloh8:
	adrp	x8, _EIO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_5:
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_UBI_IO_BAD_HDR_EBADMSG,4,2     ; @UBI_IO_BAD_HDR_EBADMSG
	.comm	_UBI_IO_BAD_HDR,4,2             ; @UBI_IO_BAD_HDR
	.comm	_UBI_IO_FF,4,2                  ; @UBI_IO_FF
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cannot invalidate PEB %d, write returned %d"

	.comm	_EIO,4,2                        ; @EIO
	.no_dead_strip	_nor_erase_prepare
.subsections_via_symbols
