	.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	$24, %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, %r12d
	movl	%edx, %r13d
	movq	%rsi, -48(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r15
	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, (%r15)
	setg	%dil
LBB0_2:
	callq	_ubi_assert
	testl	%r12d, %r12d
	js	LBB0_4
## %bb.3:
	leal	(%r14,%r12), %eax
	xorl	%ebx, %ebx
	cmpl	4(%r15), %eax
	setle	%bl
LBB0_4:
	movl	%ebx, %edi
	callq	_ubi_assert
	movl	%r12d, %eax
	cltd
	idivl	8(%r15)
	xorl	%edi, %edi
	testl	%edx, %edx
	sete	%dil
	callq	_ubi_assert
	testl	%r14d, %r14d
	jle	LBB0_5
## %bb.6:
	movl	%r14d, %eax
	cltd
	idivl	8(%r15)
	xorl	%edi, %edi
	testl	%edx, %edx
	sete	%dil
	jmp	LBB0_7
LBB0_5:
	xorl	%edi, %edi
LBB0_7:
	callq	_ubi_assert
	cmpq	$0, 24(%r15)
	je	LBB0_9
## %bb.8:
	leaq	L_.str.1(%rip), %rdi
	xorl	%r13d, %r13d
	xorl	%eax, %eax
	callq	_ubi_err
	movq	_EROFS@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_20
LBB0_9:
	movq	%r15, %rdi
	movl	%r13d, %esi
	callq	_paranoid_check_not_bad
	testl	%eax, %eax
	jne	LBB0_10
## %bb.11:
	movq	%r15, %rdi
	movl	%r13d, %esi
	movl	%r12d, %edx
	movl	%r14d, %ecx
	callq	_ubi_dbg_check_all_ff
	testl	%eax, %eax
	je	LBB0_12
LBB0_10:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%r13d, %r13d
	subl	(%rcx), %r13d
	testl	%eax, %eax
	cmovlel	%eax, %r13d
LBB0_20:
	movl	%r13d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	cmpl	%r12d, 12(%r15)
	jle	LBB0_13
LBB0_15:
	movl	%r13d, %ebx
	xorl	%r13d, %r13d
	xorl	%eax, %eax
	callq	_ubi_dbg_is_write_failure
	testq	%rax, %rax
	je	LBB0_17
## %bb.16:
	leaq	L_.str.2(%rip), %rdi
	movl	%r14d, %esi
	movl	%ebx, %edx
	movl	%r12d, %ecx
	callq	_dbg_err
	xorl	%eax, %eax
	callq	_ubi_dbg_dump_stack
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_20
LBB0_13:
	movq	%r15, %rdi
	movl	%r13d, %esi
	callq	_paranoid_check_peb_ec_hdr
	testl	%eax, %eax
	jne	LBB0_10
## %bb.14:
	movq	%r15, %rdi
	movl	%r13d, %esi
	callq	_paranoid_check_peb_vid_hdr
	testl	%eax, %eax
	jne	LBB0_10
	jmp	LBB0_15
LBB0_17:
	movl	4(%r15), %esi
	imull	%ebx, %esi
	addl	%r12d, %esi
	movq	16(%r15), %rdi
	leaq	-56(%rbp), %rcx
	movl	%r14d, %edx
	movq	-48(%rbp), %r8                  ## 8-byte Reload
	callq	*(%rdi)
	movq	-56(%rbp), %r9
	testl	%eax, %eax
	je	LBB0_19
## %bb.18:
	movl	%eax, %r13d
	leaq	L_.str.3(%rip), %rdi
	movl	%eax, %esi
	movl	%r14d, %edx
	movl	%ebx, %ecx
	movl	%r12d, %r8d
	xorl	%eax, %eax
	callq	_ubi_err
	xorl	%eax, %eax
	callq	_ubi_dbg_dump_stack
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	%r12d, %edx
	movl	%r14d, %ecx
	callq	_ubi_dbg_dump_flash
	jmp	LBB0_20
LBB0_19:
	movslq	%r14d, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r9
	sete	%dil
	callq	_ubi_assert
	xorl	%r13d, %r13d
	jmp	LBB0_20
	.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
	.comm	_EINVAL,4,2                     ## @EINVAL
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	x19, x4
	mov	x20, x3
	mov	x21, x2
	mov	x23, x1
	mov	x22, x0
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x4
	bl	_dbg_io
	tbnz	w21, #31, LBB0_3
; %bb.1:
	ldr	w8, [x22]
	cmp	w8, w21
	cset	w0, gt
	bl	_ubi_assert
	tbnz	w20, #31, LBB0_4
LBB0_2:
	ldr	w8, [x22, #4]
	add	w9, w19, w20
	cmp	w9, w8
	cset	w0, le
	b	LBB0_5
LBB0_3:
	mov	w0, #0
	bl	_ubi_assert
	tbz	w20, #31, LBB0_2
LBB0_4:
	mov	w0, #0
LBB0_5:
	bl	_ubi_assert
	ldr	w8, [x22, #8]
	sdiv	w9, w20, w8
	msub	w8, w9, w8, w20
	cmp	w8, #0
	cset	w0, eq
	bl	_ubi_assert
	cmp	w19, #1
	b.lt	LBB0_7
; %bb.6:
	ldr	w8, [x22, #8]
	sdiv	w9, w19, w8
	msub	w8, w9, w8, w19
	cmp	w8, #0
	cset	w0, eq
	b	LBB0_8
LBB0_7:
	mov	w0, #0
LBB0_8:
	bl	_ubi_assert
	ldr	x8, [x22, #24]
	cbz	x8, LBB0_11
; %bb.9:
Lloh2:
	adrp	x0, l_.str.1@PAGE
Lloh3:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_ubi_err
Lloh4:
	adrp	x8, _EROFS@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EROFS@GOTPAGEOFF]
LBB0_10:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_14
LBB0_11:
	mov	x0, x22
	mov	x1, x21
	bl	_paranoid_check_not_bad
	cbnz	w0, LBB0_13
; %bb.12:
	mov	x0, x22
	mov	x1, x21
	mov	x2, x20
	mov	x3, x19
	bl	_ubi_dbg_check_all_ff
	cbz	w0, LBB0_15
LBB0_13:
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	cmp	w0, #0
	csneg	w23, w0, w8, le
LBB0_14:
	mov	x0, x23
	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_15:
	ldr	w8, [x22, #12]
	cmp	w8, w20
	b.le	LBB0_18
LBB0_16:
	bl	_ubi_dbg_is_write_failure
	cbz	x0, LBB0_20
; %bb.17:
Lloh9:
	adrp	x0, l_.str.2@PAGE
Lloh10:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x19
	mov	x2, x21
	mov	x3, x20
	bl	_dbg_err
	bl	_ubi_dbg_dump_stack
Lloh11:
	adrp	x8, _EIO@GOTPAGE
Lloh12:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
	b	LBB0_10
LBB0_18:
	mov	x0, x22
	mov	x1, x21
	bl	_paranoid_check_peb_ec_hdr
	cbnz	w0, LBB0_13
; %bb.19:
	mov	x0, x22
	mov	x1, x21
	bl	_paranoid_check_peb_vid_hdr
	cbnz	w0, LBB0_13
	b	LBB0_16
LBB0_20:
	ldr	w8, [x22, #4]
	madd	w1, w8, w21, w20
	ldr	x0, [x22, #16]
	ldr	x8, [x0]
	add	x3, sp, #40
	mov	x2, x19
	mov	x4, x23
	blr	x8
	mov	x23, x0
	ldr	x8, [sp, #40]
	cbz	w0, LBB0_22
; %bb.21:
	stp	x20, x8, [sp, #24]
	stp	x19, x21, [sp, #8]
	str	x23, [sp]
Lloh13:
	adrp	x0, l_.str.3@PAGE
Lloh14:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_ubi_err
	bl	_ubi_dbg_dump_stack
	mov	x0, x22
	mov	x1, x21
	mov	x2, x20
	mov	x3, x19
	bl	_ubi_dbg_dump_flash
	b	LBB0_14
LBB0_22:
	cmp	x8, w19, sxtw
	cset	w0, eq
	bl	_ubi_assert
	b	LBB0_14
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh13, Lloh14
	.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
	.comm	_EINVAL,4,2                     ; @EINVAL
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
