	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_io_write                   ## -- Begin function ubi_io_write
	.p2align	4, 0x90
_ubi_io_write:                          ## @ubi_io_write
	.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	%r8d, %r15d
	movl	%ecx, %r12d
	movl	%edx, %r13d
	movq	%rsi, -56(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r14
	leaq	L_.str(%rip), %rdi
	movl	%r8d, %esi
	callq	_dbg_io
	xorl	%ebx, %ebx
	movl	$0, %edi
	testl	%r13d, %r13d
	js	LBB0_2
## %bb.1:
	xorl	%edi, %edi
	cmpl	%r13d, (%r14)
	setg	%dil
LBB0_2:
	callq	_ubi_assert
	testl	%r12d, %r12d
	js	LBB0_4
## %bb.3:
	leal	(%r15,%r12), %eax
	xorl	%ebx, %ebx
	cmpl	4(%r14), %eax
	setle	%bl
LBB0_4:
	movl	%ebx, %edi
	callq	_ubi_assert
	movl	%r12d, %eax
	cltd
	idivl	8(%r14)
	xorl	%edi, %edi
	testl	%edx, %edx
	sete	%dil
	callq	_ubi_assert
	testl	%r15d, %r15d
	jle	LBB0_5
## %bb.6:
	movl	%r15d, %eax
	cltd
	idivl	8(%r14)
	xorl	%edi, %edi
	testl	%edx, %edx
	sete	%dil
	jmp	LBB0_7
LBB0_5:
	xorl	%edi, %edi
LBB0_7:
	callq	_ubi_assert
	cmpq	$0, 24(%r14)
	je	LBB0_9
## %bb.8:
	leaq	L_.str.1(%rip), %rsi
	xorl	%r13d, %r13d
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	_ubi_err
	movq	_EROFS@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_21
LBB0_9:
	movq	%r14, %rdi
	movl	%r13d, %esi
	callq	_self_check_not_bad
	movl	%r13d, %ebx
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_21
## %bb.10:
	movq	%r14, %rdi
	movl	%ebx, %esi
	movl	%r12d, %edx
	movl	%r15d, %ecx
	callq	_ubi_self_check_all_ff
	movl	%eax, %r13d
	testl	%eax, %eax
	je	LBB0_11
LBB0_21:
	movl	%r13d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_11:
	cmpl	%r12d, 12(%r14)
	jle	LBB0_12
LBB0_14:
	movq	%r14, %rdi
	callq	_ubi_dbg_is_write_failure
	testq	%rax, %rax
	je	LBB0_16
## %bb.15:
	leaq	L_.str.2(%rip), %rsi
	xorl	%r13d, %r13d
	movq	%r14, %rdi
	movl	%r15d, %edx
	movl	%ebx, %ecx
	movl	%r12d, %r8d
	xorl	%eax, %eax
	callq	_ubi_err
	xorl	%eax, %eax
	callq	_dump_stack
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_21
LBB0_12:
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_self_check_peb_ec_hdr
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_21
## %bb.13:
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_self_check_peb_vid_hdr
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_21
	jmp	LBB0_14
LBB0_16:
	movl	4(%r14), %esi
	movl	%ebx, -44(%rbp)                 ## 4-byte Spill
	imull	%ebx, %esi
	addl	%r12d, %esi
	movl	16(%r14), %edi
	leaq	-64(%rbp), %rcx
	movl	%r15d, %edx
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %r8
	callq	_mtd_write
	movl	%eax, %r13d
	movq	-64(%rbp), %rax
	testl	%r13d, %r13d
	je	LBB0_18
## %bb.17:
	movq	%rax, (%rsp)
	leaq	L_.str.3(%rip), %rsi
	movq	%r14, %rdi
	movl	%r13d, %edx
	movl	%r15d, %ecx
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %r8d
	movl	%r12d, %r9d
	xorl	%eax, %eax
	callq	_ubi_err
	xorl	%eax, %eax
	callq	_dump_stack
	movq	%r14, %rdi
	movl	%ebx, %esi
	movl	%r12d, %edx
	movl	%r15d, %ecx
	callq	_ubi_dump_flash
	jmp	LBB0_21
LBB0_18:
	movslq	%r15d, %rcx
	xorl	%edi, %edi
	cmpq	%rcx, %rax
	sete	%dil
	callq	_ubi_assert
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %edx
	movl	%r12d, %ecx
	movl	%r15d, %r8d
	callq	_self_check_write
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_21
## %bb.19:
	addl	%r12d, %r15d
	movl	4(%r14), %ecx
	xorl	%r13d, %r13d
	subl	%r15d, %ecx
	je	LBB0_21
## %bb.20:
	movq	%r14, %rdi
	movl	%ebx, %esi
	movl	%r15d, %edx
	callq	_ubi_self_check_all_ff
	movl	%eax, %r13d
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"write %d bytes to PEB %d:%d"

L_.str.1:                               ## @.str.1
	.asciz	"read-only mode"

	.comm	_EROFS,4,2                      ## @EROFS
L_.str.2:                               ## @.str.2
	.asciz	"cannot write %d bytes to PEB %d:%d (emulated)"

	.comm	_EIO,4,2                        ## @EIO
L_.str.3:                               ## @.str.3
	.asciz	"error %d while writing %d bytes to PEB %d:%d, written %zd bytes"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_io_write                   ; -- Begin function ubi_io_write
	.p2align	2
_ubi_io_write:                          ; @ubi_io_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	mov	x21, x4
	mov	x22, x3
	mov	x20, x2
	mov	x23, x1
	mov	x19, x0
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x4
	bl	_dbg_io
	tbnz	w20, #31, LBB0_3
; %bb.1:
	ldr	w8, [x19]
	cmp	w8, w20
	cset	w0, gt
	bl	_ubi_assert
	tbnz	w22, #31, LBB0_4
LBB0_2:
	ldr	w8, [x19, #4]
	add	w9, w21, w22
	cmp	w9, w8
	cset	w0, le
	b	LBB0_5
LBB0_3:
	mov	w0, #0
	bl	_ubi_assert
	tbz	w22, #31, LBB0_2
LBB0_4:
	mov	w0, #0
LBB0_5:
	bl	_ubi_assert
	ldr	w8, [x19, #8]
	sdiv	w9, w22, w8
	msub	w8, w9, w8, w22
	cmp	w8, #0
	cset	w0, eq
	bl	_ubi_assert
	cmp	w21, #1
	b.lt	LBB0_7
; %bb.6:
	ldr	w8, [x19, #8]
	sdiv	w9, w21, w8
	msub	w8, w9, w8, w21
	cmp	w8, #0
	cset	w0, eq
	b	LBB0_8
LBB0_7:
	mov	w0, #0
LBB0_8:
	bl	_ubi_assert
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_11
; %bb.9:
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	bl	_ubi_err
Lloh4:
	adrp	x8, _EROFS@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EROFS@GOTPAGEOFF]
LBB0_10:
	ldr	w8, [x8]
	neg	w24, w8
	b	LBB0_13
LBB0_11:
	mov	x0, x19
	mov	x1, x20
	bl	_self_check_not_bad
	mov	x24, x0
	cbnz	w0, LBB0_13
; %bb.12:
	mov	x0, x19
	mov	x1, x20
	mov	x2, x22
	mov	x3, x21
	bl	_ubi_self_check_all_ff
	mov	x24, x0
	cbz	w0, LBB0_14
LBB0_13:
	mov	x0, x24
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_14:
	ldr	w8, [x19, #12]
	cmp	w8, w22
	b.le	LBB0_17
LBB0_15:
	mov	x0, x19
	bl	_ubi_dbg_is_write_failure
	cbz	x0, LBB0_19
; %bb.16:
	stp	x20, x22, [sp, #8]
	str	x21, [sp]
Lloh6:
	adrp	x1, l_.str.2@PAGE
Lloh7:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x19
	bl	_ubi_err
	bl	_dump_stack
Lloh8:
	adrp	x8, _EIO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
	b	LBB0_10
LBB0_17:
	mov	x0, x19
	mov	x1, x20
	bl	_self_check_peb_ec_hdr
	mov	x24, x0
	cbnz	w0, LBB0_13
; %bb.18:
	mov	x0, x19
	mov	x1, x20
	bl	_self_check_peb_vid_hdr
	mov	x24, x0
	cbnz	w0, LBB0_13
	b	LBB0_15
LBB0_19:
	ldr	w8, [x19, #4]
	madd	w1, w8, w20, w22
	ldr	w0, [x19, #16]
	add	x3, sp, #40
	mov	x2, x21
	mov	x4, x23
	bl	_mtd_write
	ldr	x8, [sp, #40]
	cbz	w0, LBB0_21
; %bb.20:
	mov	x24, x0
	str	x8, [sp, #32]
	mov	x8, x22
	mov	x9, x20
	stp	x9, x8, [sp, #16]
	mov	x8, x21
	stp	x24, x8, [sp]
Lloh10:
	adrp	x1, l_.str.3@PAGE
Lloh11:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x19
	bl	_ubi_err
	bl	_dump_stack
	mov	x0, x19
	mov	x1, x20
	mov	x2, x22
	mov	x3, x21
	bl	_ubi_dump_flash
	b	LBB0_13
LBB0_21:
	cmp	x8, w21, sxtw
	cset	w0, eq
	bl	_ubi_assert
	mov	x0, x19
	mov	x1, x23
	mov	x2, x20
	mov	x3, x22
	mov	x4, x21
	bl	_self_check_write
	mov	x24, x0
	cbnz	w0, LBB0_13
; %bb.22:
	ldr	w8, [x19, #4]
	add	w2, w21, w22
	subs	w3, w8, w2
	b.ne	LBB0_24
; %bb.23:
	mov	w24, #0
	b	LBB0_13
LBB0_24:
	mov	x0, x19
	mov	x1, x20
	bl	_ubi_self_check_all_ff
	mov	x24, x0
	b	LBB0_13
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpAdd	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"write %d bytes to PEB %d:%d"

l_.str.1:                               ; @.str.1
	.asciz	"read-only mode"

	.comm	_EROFS,4,2                      ; @EROFS
l_.str.2:                               ; @.str.2
	.asciz	"cannot write %d bytes to PEB %d:%d (emulated)"

	.comm	_EIO,4,2                        ; @EIO
l_.str.3:                               ; @.str.3
	.asciz	"error %d while writing %d bytes to PEB %d:%d, written %zd bytes"

.subsections_via_symbols
