	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sm_write_block
_sm_write_block:                        ## @sm_write_block
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%r8d, %r14d
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movl	%edx, %ebx
	movq	%rsi, -56(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r13
	movq	%r9, -104(%rbp)
	movq	_SM_OOB_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	-72(%rbp), %r15
	movq	%r15, %rdi
	movl	$255, %esi
	callq	_memset
	movq	%r15, %rdi
	movl	%r14d, -80(%rbp)                ## 4-byte Spill
	movl	%r14d, %esi
	callq	_sm_write_lba
	movb	$1, %r14b
	movl	%ebx, -84(%rbp)                 ## 4-byte Spill
	movq	%r13, -96(%rbp)                 ## 8-byte Spill
LBB0_1:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_4 Depth 2
	cmpq	$0, 16(%r13)
	jne	LBB0_13
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	cmpl	$0, (%r13)
	jle	LBB0_15
## %bb.3:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	%r14d, -76(%rbp)                ## 4-byte Spill
	movq	_SM_SECTOR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	xorl	%r15d, %r15d
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_4:                                 ##   Parent Loop BB0_1 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movl	$255, -72(%rbp)
	movl	%r15d, %eax
	cltd
	idivl	%ecx
	movl	%eax, %edi
	leaq	-104(%rbp), %rsi
	callq	_test_bit
	testq	%rax, %rax
	je	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=2
	movl	%r15d, %eax
	cltd
	movq	_SM_SECTOR_SIZE@GOTPCREL(%rip), %rcx
	idivl	(%rcx)
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	movl	-80(%rbp), %edx                 ## 4-byte Reload
	movl	%ebx, %ecx
	callq	_sm_printk
	movl	$0, -72(%rbp)
LBB0_6:                                 ##   in Loop: Header=BB0_4 Depth=2
	cmpq	$0, 8(%r13)
	movslq	%r15d, %r12
	je	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_4 Depth=2
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%r12,4), %r14
	movq	_SM_SMALL_PAGE@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movl	-64(%rbp), %r13d
	movq	_CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_IS_ENABLED
	movq	%r14, %rdi
	movl	%ebx, %esi
	movl	%r13d, %edx
	movl	%eax, %ecx
	callq	___nand_calculate_ecc
	movq	_SM_SMALL_PAGE@GOTPCREL(%rip), %rax
	movslq	(%rax), %rbx
	leaq	(%r14,%rbx,4), %r14
	movl	-68(%rbp), %r13d
	movq	_CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_IS_ENABLED
	movq	%r14, %rdi
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movl	%ebx, %esi
	movl	-84(%rbp), %ebx                 ## 4-byte Reload
	movl	%r13d, %edx
	movq	-96(%rbp), %r13                 ## 8-byte Reload
	movl	%eax, %ecx
	callq	___nand_calculate_ecc
LBB0_8:                                 ##   in Loop: Header=BB0_4 Depth=2
	leaq	(%r14,%r12,4), %r8
	movq	%r13, %rdi
	movl	%ebx, %esi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	movl	%r15d, %ecx
	leaq	-72(%rbp), %r9
	callq	_sm_write_sector
	testl	%eax, %eax
	jne	LBB0_9
## %bb.14:                              ##   in Loop: Header=BB0_4 Depth=2
	movq	_SM_SECTOR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	addl	%ecx, %r15d
	cmpl	(%r13), %r15d
	jl	LBB0_4
	jmp	LBB0_15
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_1 Depth=1
	testb	$1, -76(%rbp)                   ## 1-byte Folded Reload
	je	LBB0_12
## %bb.10:                              ##   in Loop: Header=BB0_1 Depth=1
	xorl	%r14d, %r14d
	movq	%r13, %rdi
	movl	%ebx, %esi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	xorl	%ecx, %ecx
	callq	_sm_erase_block
	testq	%rax, %rax
	je	LBB0_1
## %bb.11:
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %r14d
	jmp	LBB0_16
LBB0_15:
	xorl	%r14d, %r14d
LBB0_16:
	movl	%r14d, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	movq	%r13, %rdi
	movl	%ebx, %esi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	callq	_sm_mark_block_bad
LBB0_13:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
	jmp	LBB0_16
	.cfi_endproc
                                        ## -- End function
	.comm	_SM_OOB_SIZE,4,2                ## @SM_OOB_SIZE
	.comm	_EIO,4,2                        ## @EIO
	.comm	_SM_SECTOR_SIZE,4,2             ## @SM_SECTOR_SIZE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"sector %d of block at LBA %d of zone %d couldn't be read, marking it as invalid"

	.comm	_SM_SMALL_PAGE,4,2              ## @SM_SMALL_PAGE
	.comm	_CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC,4,2 ## @CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC
	.no_dead_strip	_sm_write_block
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sm_write_block
_sm_write_block:                        ; @sm_write_block
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #144
	.cfi_def_cfa_offset 144
	stp	x28, x27, [sp, #48]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #64]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #80]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #96]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #112]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #128]            ; 16-byte Folded Spill
	add	x29, sp, #128
	.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	x21, x4
	str	w3, [sp, #20]                   ; 4-byte Folded Spill
	mov	x19, x2
	mov	x20, x1
	mov	x22, x0
	str	x5, [sp, #40]
Lloh0:
	adrp	x8, _SM_OOB_SIZE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SM_OOB_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
	add	x0, sp, #24
	mov	w1, #255
	bl	_memset
	add	x0, sp, #24
	str	w21, [sp, #16]                  ; 4-byte Folded Spill
	mov	x1, x21
	bl	_sm_write_lba
	mov	w9, #1
Lloh3:
	adrp	x24, _SM_SECTOR_SIZE@GOTPAGE
Lloh4:
	ldr	x24, [x24, _SM_SECTOR_SIZE@GOTPAGEOFF]
Lloh5:
	adrp	x23, _SM_SMALL_PAGE@GOTPAGE
Lloh6:
	ldr	x23, [x23, _SM_SMALL_PAGE@GOTPAGEOFF]
LBB0_1:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	ldr	x8, [x22, #16]
	cbnz	x8, LBB0_15
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	ldr	w8, [x22]
	cmp	w8, #1
	b.lt	LBB0_12
; %bb.3:                                ;   in Loop: Header=BB0_1 Depth=1
	str	w9, [sp, #12]                   ; 4-byte Folded Spill
	mov	w25, #0
	ldr	w8, [x24]
LBB0_4:                                 ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	w9, #255
	str	w9, [sp, #24]
	sdiv	w0, w25, w8
	add	x1, sp, #40
	bl	_test_bit
	cbz	x0, LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=2
	ldr	w8, [x24]
	sdiv	w1, w25, w8
Lloh7:
	adrp	x0, l_.str@PAGE
Lloh8:
	add	x0, x0, l_.str@PAGEOFF
	ldr	w2, [sp, #16]                   ; 4-byte Folded Reload
	mov	x3, x19
	bl	_sm_printk
	str	wzr, [sp, #24]
LBB0_6:                                 ;   in Loop: Header=BB0_4 Depth=2
	ldr	x8, [x22, #8]
	sxtw	x21, w25
	cbz	x8, LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=2
	add	x26, x20, x21, lsl #2
	ldr	w27, [x23]
	ldr	w28, [sp, #32]
Lloh9:
	adrp	x8, _CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC@GOTPAGE
Lloh10:
	ldr	x8, [x8, _CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC@GOTPAGEOFF]
Lloh11:
	ldr	w0, [x8]
	bl	_IS_ENABLED
	mov	x3, x0
	mov	x0, x26
	mov	x1, x27
	mov	x2, x28
	bl	___nand_calculate_ecc
	ldrsw	x27, [x23]
	add	x26, x26, x27, lsl #2
	ldr	w28, [sp, #28]
Lloh12:
	adrp	x8, _CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC@GOTPAGE
Lloh13:
	ldr	x8, [x8, _CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
	bl	_IS_ENABLED
	mov	x3, x0
	mov	x0, x26
	mov	x1, x27
	mov	x2, x28
	bl	___nand_calculate_ecc
LBB0_8:                                 ;   in Loop: Header=BB0_4 Depth=2
	add	x4, x20, x21, lsl #2
	add	x5, sp, #24
	mov	x0, x22
	mov	x1, x19
	ldr	w2, [sp, #20]                   ; 4-byte Folded Reload
	mov	x3, x25
	bl	_sm_write_sector
	cbnz	w0, LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_4 Depth=2
	ldr	w8, [x24]
	ldr	w9, [x22]
	add	w25, w8, w25
	cmp	w25, w9
	b.lt	LBB0_4
	b	LBB0_12
LBB0_10:                                ;   in Loop: Header=BB0_1 Depth=1
	ldr	w8, [sp, #12]                   ; 4-byte Folded Reload
	tbz	w8, #0, LBB0_14
; %bb.11:                               ;   in Loop: Header=BB0_1 Depth=1
	mov	x0, x22
	mov	x1, x19
	ldr	w2, [sp, #20]                   ; 4-byte Folded Reload
	mov	w3, #0
	bl	_sm_erase_block
	mov	w9, #0
	cbz	x0, LBB0_1
	b	LBB0_15
LBB0_12:
	mov	w0, #0
LBB0_13:
	ldp	x29, x30, [sp, #128]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #112]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #96]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #80]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #64]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #144
	ret
LBB0_14:
	mov	x0, x22
	mov	x1, x19
	ldr	w2, [sp, #20]                   ; 4-byte Folded Reload
	bl	_sm_mark_block_bad
LBB0_15:
Lloh15:
	adrp	x8, _EIO@GOTPAGE
Lloh16:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_13
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_SM_OOB_SIZE,4,2                ; @SM_OOB_SIZE
	.comm	_EIO,4,2                        ; @EIO
	.comm	_SM_SECTOR_SIZE,4,2             ; @SM_SECTOR_SIZE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"sector %d of block at LBA %d of zone %d couldn't be read, marking it as invalid"

	.comm	_SM_SMALL_PAGE,4,2              ; @SM_SMALL_PAGE
	.comm	_CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC,4,2 ; @CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC
	.no_dead_strip	_sm_write_block
.subsections_via_symbols
