	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_nanddev_markbad                ## -- Begin function nanddev_markbad
	.p2align	4, 0x90
_nanddev_markbad:                       ## @nanddev_markbad
	.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
	movq	%rsi, %r15
	movq	%rdi, %rbx
	callq	_nanddev_to_mtd
	movq	%rax, %r14
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_nanddev_isbad
	xorl	%r12d, %r12d
	testq	%rax, %rax
	je	LBB0_1
LBB0_8:
	movl	%r12d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_1:
	movq	(%rbx), %rax
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	*(%rax)
	movl	%eax, %r12d
	testl	%eax, %eax
	je	LBB0_3
## %bb.2:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_nanddev_pos_to_offs
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	movl	%r12d, %edx
	callq	_pr_warn
LBB0_3:
	movq	%rbx, %rdi
	callq	_nanddev_bbt_is_initialized
	testl	%eax, %eax
	je	LBB0_6
## %bb.4:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_nanddev_bbt_pos_to_entry
	movq	_NAND_BBT_BLOCK_WORN@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_nanddev_bbt_set_block_status
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_8
## %bb.5:
	movq	%rbx, %rdi
	callq	_nanddev_bbt_update
	movl	%eax, %r12d
LBB0_6:
	testl	%r12d, %r12d
	jne	LBB0_8
## %bb.7:
	incl	(%r14)
	xorl	%r12d, %r12d
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"failed to write BBM to block @%llx (err = %d)\n"

	.comm	_NAND_BBT_BLOCK_WORN,4,2        ## @NAND_BBT_BLOCK_WORN
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_nanddev_markbad                ; -- Begin function nanddev_markbad
	.p2align	2
_nanddev_markbad:                       ; @nanddev_markbad
	.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	x21, x1
	mov	x20, x0
	bl	_nanddev_to_mtd
	mov	x19, x0
	mov	x0, x20
	mov	x1, x21
	bl	_nanddev_isbad
	cbz	x0, LBB0_3
; %bb.1:
	mov	w22, #0
LBB0_2:
	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
LBB0_3:
	ldr	x8, [x20]
	ldr	x8, [x8]
	mov	x0, x20
	mov	x1, x21
	blr	x8
	mov	x22, x0
	cbz	w0, LBB0_5
; %bb.4:
	mov	x0, x20
	mov	x1, x21
	bl	_nanddev_pos_to_offs
	mov	x1, x0
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	mov	x2, x22
	bl	_pr_warn
LBB0_5:
	mov	x0, x20
	bl	_nanddev_bbt_is_initialized
	cbz	w0, LBB0_8
; %bb.6:
	mov	x0, x20
	mov	x1, x21
	bl	_nanddev_bbt_pos_to_entry
	mov	x1, x0
Lloh2:
	adrp	x8, _NAND_BBT_BLOCK_WORN@GOTPAGE
Lloh3:
	ldr	x8, [x8, _NAND_BBT_BLOCK_WORN@GOTPAGEOFF]
Lloh4:
	ldr	w2, [x8]
	mov	x0, x20
	bl	_nanddev_bbt_set_block_status
	mov	x22, x0
	cbnz	w0, LBB0_2
; %bb.7:
	mov	x0, x20
	bl	_nanddev_bbt_update
	mov	x22, x0
LBB0_8:
	cbnz	w22, LBB0_2
; %bb.9:
	ldr	w8, [x19]
	add	w8, w8, #1
	str	w8, [x19]
	b	LBB0_2
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"failed to write BBM to block @%llx (err = %d)\n"

	.comm	_NAND_BBT_BLOCK_WORN,4,2        ; @NAND_BBT_BLOCK_WORN
.subsections_via_symbols
