	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function opalflash_write
_opalflash_write:                       ## @opalflash_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	%ecx, %ebx
	movq	%rdx, %r15
	movq	16(%rdi), %rax
	movl	(%rax), %ecx
	movl	%esi, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	LBB0_12
## %bb.1:
	movl	%ebx, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	LBB0_2
LBB0_12:
	movq	_EIO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_13:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_2:
	movl	%esi, %r14d
	movq	%rdi, %r12
	cmpq	$0, 8(%rdi)
	je	LBB0_4
## %bb.3:
	movq	%r12, %rdi
	movl	%r14d, %esi
	movl	%ebx, %edx
	callq	_opalflash_erase
	testl	%eax, %eax
	jne	LBB0_13
LBB0_4:
	movq	%r12, -56(%rbp)                 ## 8-byte Spill
	xorl	%eax, %eax
	callq	_opal_alloc_async_token
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movl	$0, %r12d
	testl	%ebx, %ebx
	jle	LBB0_11
	.p2align	4, 0x90
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movq	_PAGE_SIZE@GOTPCREL(%rip), %r12
	movq	(%r12), %rsi
	movl	%ebx, -48(%rbp)                 ## 4-byte Spill
	movl	%ebx, %edi
	callq	_MIN
	movq	(%r12), %rsi
	movq	_PAGE_MASK@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	andl	%r15d, %ecx
	movslq	%ecx, %rcx
	subq	%rcx, %rsi
	movl	%eax, %edi
	callq	_MIN
	movl	%eax, %r13d
	movq	_OPAL_FLASH_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %r12d
	movq	%r15, %rdi
	callq	_vtophys
	movl	%ebx, %edi
	movl	%r12d, %esi
	movl	%r14d, %edx
	movl	%eax, %ecx
	movl	%r13d, %r8d
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %r9d
	callq	_opal_call
	movl	%eax, %r12d
	movq	_OPAL_ASYNC_COMPLETION@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r12d
	jne	LBB0_6
## %bb.7:                               ##   in Loop: Header=BB0_5 Depth=1
	leaq	-64(%rbp), %rdi
	movl	$8, %esi
	movl	%ebx, %edx
	callq	_opal_wait_completion
	movl	%eax, %r12d
	movq	_OPAL_SUCCESS@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpl	%eax, %r12d
	jne	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_5 Depth=1
	movq	-64(%rbp), %rcx
	movl	%r12d, %eax
	movl	4(%rcx), %r12d
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_6:                                 ##   in Loop: Header=BB0_5 Depth=1
	movq	_OPAL_SUCCESS@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_9:                                 ##   in Loop: Header=BB0_5 Depth=1
	cmpl	%eax, %r12d
	jne	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_5 Depth=1
	addl	%r13d, %r14d
	movslq	%r13d, %rax
	addq	%rax, %r15
	movl	-48(%rbp), %ebx                 ## 4-byte Reload
	subl	%r13d, %ebx
	jg	LBB0_5
LBB0_11:
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	callq	_opal_free_async_token
	movq	_OPAL_SUCCESS@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r12d
	movl	$0, %eax
	jne	LBB0_12
	jmp	LBB0_13
	.cfi_endproc
                                        ## -- End function
	.comm	_EIO,4,2                        ## @EIO
	.comm	_PAGE_SIZE,8,3                  ## @PAGE_SIZE
	.comm	_PAGE_MASK,4,2                  ## @PAGE_MASK
	.comm	_OPAL_FLASH_WRITE,4,2           ## @OPAL_FLASH_WRITE
	.comm	_OPAL_ASYNC_COMPLETION,4,2      ## @OPAL_ASYNC_COMPLETION
	.comm	_OPAL_SUCCESS,4,2               ## @OPAL_SUCCESS
	.no_dead_strip	_opalflash_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function opalflash_write
_opalflash_write:                       ; @opalflash_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	ldr	x8, [x0, #16]
	ldr	w8, [x8]
	sdiv	w9, w1, w8
	msub	w9, w9, w8, w1
	cbnz	w9, LBB0_2
; %bb.1:
	mov	x19, x3
	sdiv	w9, w3, w8
	msub	w8, w9, w8, w3
	cbz	w8, LBB0_4
LBB0_2:
Lloh0:
	adrp	x8, _EIO@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
LBB0_3:
	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
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_4:
	mov	x20, x2
	mov	x21, x1
	mov	x22, x0
	ldr	x8, [x0, #8]
	cbz	x8, LBB0_6
; %bb.5:
	mov	x0, x22
	mov	x1, x21
	mov	x2, x19
	bl	_opalflash_erase
	cbnz	w0, LBB0_3
LBB0_6:
	bl	_opal_alloc_async_token
	mov	x23, x0
	cmp	w19, #1
	b.lt	LBB0_14
; %bb.7:
Lloh3:
	adrp	x28, _PAGE_SIZE@GOTPAGE
Lloh4:
	ldr	x28, [x28, _PAGE_SIZE@GOTPAGEOFF]
Lloh5:
	adrp	x27, _OPAL_ASYNC_COMPLETION@GOTPAGE
Lloh6:
	ldr	x27, [x27, _OPAL_ASYNC_COMPLETION@GOTPAGEOFF]
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x1, [x28]
	mov	x0, x19
	bl	_MIN
	ldr	x8, [x28]
Lloh7:
	adrp	x9, _PAGE_MASK@GOTPAGE
Lloh8:
	ldr	x9, [x9, _PAGE_MASK@GOTPAGEOFF]
Lloh9:
	ldr	w9, [x9]
	and	w9, w9, w20
	sub	x1, x8, w9, sxtw
	bl	_MIN
	mov	x24, x0
Lloh10:
	adrp	x8, _OPAL_FLASH_WRITE@GOTPAGE
Lloh11:
	ldr	x8, [x8, _OPAL_FLASH_WRITE@GOTPAGEOFF]
Lloh12:
	ldr	w25, [x8]
	ldr	w26, [x22]
	mov	x0, x20
	bl	_vtophys
	mov	x3, x0
	mov	x0, x25
	mov	x1, x26
	mov	x2, x21
	mov	x4, x24
	mov	x5, x23
	bl	_opal_call
	ldr	w8, [x27]
	cmp	w0, w8
	b.ne	LBB0_11
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	add	x0, sp, #8
	mov	w1, #8
	mov	x2, x23
	bl	_opal_wait_completion
	mov	x25, x0
Lloh13:
	adrp	x8, _OPAL_SUCCESS@GOTPAGE
Lloh14:
	ldr	x8, [x8, _OPAL_SUCCESS@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	cmp	w0, w8
	b.ne	LBB0_12
; %bb.10:                               ;   in Loop: Header=BB0_8 Depth=1
	ldr	x9, [sp, #8]
	mov	x8, x25
	ldr	w25, [x9, #4]
	b	LBB0_12
LBB0_11:                                ;   in Loop: Header=BB0_8 Depth=1
	mov	x25, x0
Lloh16:
	adrp	x8, _OPAL_SUCCESS@GOTPAGE
Lloh17:
	ldr	x8, [x8, _OPAL_SUCCESS@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
LBB0_12:                                ;   in Loop: Header=BB0_8 Depth=1
	cmp	w25, w8
	b.ne	LBB0_15
; %bb.13:                               ;   in Loop: Header=BB0_8 Depth=1
	sub	w19, w19, w24
	add	w21, w24, w21
	add	x20, x20, w24, sxtw
	cmp	w19, #0
	b.gt	LBB0_8
	b	LBB0_15
LBB0_14:
	mov	w25, #0
LBB0_15:
	mov	x0, x23
	bl	_opal_free_async_token
Lloh19:
	adrp	x8, _OPAL_SUCCESS@GOTPAGE
Lloh20:
	ldr	x8, [x8, _OPAL_SUCCESS@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
Lloh22:
	adrp	x9, _EIO@GOTPAGE
Lloh23:
	ldr	x9, [x9, _EIO@GOTPAGEOFF]
Lloh24:
	ldr	w9, [x9]
	cmp	w25, w8
	csel	w0, wzr, w9, eq
	b	LBB0_3
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_EIO,4,2                        ; @EIO
	.comm	_PAGE_SIZE,8,3                  ; @PAGE_SIZE
	.comm	_PAGE_MASK,4,2                  ; @PAGE_MASK
	.comm	_OPAL_FLASH_WRITE,4,2           ; @OPAL_FLASH_WRITE
	.comm	_OPAL_ASYNC_COMPLETION,4,2      ; @OPAL_ASYNC_COMPLETION
	.comm	_OPAL_SUCCESS,4,2               ; @OPAL_SUCCESS
	.no_dead_strip	_opalflash_write
.subsections_via_symbols
