	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function doc_read_page_prepare
_doc_read_page_prepare:                 ## @doc_read_page_prepare
	.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
	pushq	%rax
	.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
	movl	%esi, %ebx
	movq	%rdi, %r15
	leaq	L_.str(%rip), %rdi
	callq	_doc_dbg
	movq	_DOC_LAYOUT_WEAR_OFFSET@GOTPCREL(%rip), %rax
	cmpl	%r14d, (%rax)
	setle	%cl
	jle	LBB0_3
## %bb.1:
	movq	_DOC_LAYOUT_PAGE_OOB_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%eax, %eax
	cmpl	%r14d, %eax
	jge	LBB0_3
## %bb.2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	jmp	LBB0_7
LBB0_3:
	movb	%cl, -41(%rbp)                  ## 1-byte Spill
	movl	(%r15), %esi
	movq	%r15, %rdi
	callq	_doc_set_device_id
	movq	%r15, %rdi
	callq	_doc_reset_seq
	testl	%eax, %eax
	jne	LBB0_6
## %bb.4:
	xorl	%r8d, %r8d
	movb	-41(%rbp), %al                  ## 1-byte Reload
	movb	%al, %r8b
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	%r13d, %edx
	movl	%r12d, %ecx
	movl	%r14d, %r9d
	callq	_doc_read_seek
	testl	%eax, %eax
	je	LBB0_5
LBB0_6:
	movq	_DOC_DATAEND@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%ebx, %ebx
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	_doc_writeb
	movq	%r15, %rdi
	movl	$2, %esi
	callq	_doc_delay
	movq	_EIO@GOTPCREL(%rip), %rax
LBB0_7:
	subl	(%rax), %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	movq	_DOC_CMD_READ_ALL_PLANES@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_doc_flash_command
	movq	%r15, %rdi
	movl	$2, %esi
	callq	_doc_delay
	movq	%r15, %rdi
	callq	_doc_wait_ready
	movq	_DOC_CMD_SET_ADDR_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_doc_flash_command
	movq	%r15, %rdi
	movl	$1, %esi
	callq	_doc_delay
	movq	_DOC_LAYOUT_PAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%eax, %eax
	xorl	%ebx, %ebx
	cmpl	%r14d, %eax
	cmovgl	%ebx, %eax
	subl	%eax, %r14d
	sarl	$2, %r14d
	movq	%r15, %rdi
	movl	%r14d, %esi
	callq	_doc_flash_address
	movq	%r15, %rdi
	movl	$1, %esi
	callq	_doc_delay
	movq	%r15, %rdi
	callq	_doc_wait_ready
	movq	_DOC_CMD_READ_FLASH@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_doc_flash_command
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"doc_read_page_prepare(blocks=(%d,%d), page=%d, ofsInPage=%d)\n"

	.comm	_DOC_LAYOUT_WEAR_OFFSET,4,2     ## @DOC_LAYOUT_WEAR_OFFSET
	.comm	_DOC_LAYOUT_PAGE_OOB_SIZE,4,2   ## @DOC_LAYOUT_PAGE_OOB_SIZE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_DOC_CMD_READ_ALL_PLANES,4,2    ## @DOC_CMD_READ_ALL_PLANES
	.comm	_DOC_CMD_SET_ADDR_READ,4,2      ## @DOC_CMD_SET_ADDR_READ
	.comm	_DOC_LAYOUT_PAGE_SIZE,4,2       ## @DOC_LAYOUT_PAGE_SIZE
	.comm	_DOC_CMD_READ_FLASH,4,2         ## @DOC_CMD_READ_FLASH
	.comm	_DOC_DATAEND,4,2                ## @DOC_DATAEND
	.comm	_EIO,4,2                        ## @EIO
	.no_dead_strip	_doc_read_page_prepare
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function doc_read_page_prepare
_doc_read_page_prepare:                 ; @doc_read_page_prepare
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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	x20, x4
	mov	x21, x3
	mov	x22, x2
	mov	x23, x1
	mov	x19, x0
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_doc_dbg
Lloh2:
	adrp	x8, _DOC_LAYOUT_WEAR_OFFSET@GOTPAGE
Lloh3:
	ldr	x8, [x8, _DOC_LAYOUT_WEAR_OFFSET@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	cmp	w8, w20
	cset	w24, le
	b.le	LBB0_3
; %bb.1:
Lloh5:
	adrp	x8, _DOC_LAYOUT_PAGE_OOB_SIZE@GOTPAGE
Lloh6:
	ldr	x8, [x8, _DOC_LAYOUT_PAGE_OOB_SIZE@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	cmp	w20, w8, lsl #1
	b.le	LBB0_3
; %bb.2:
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_6
LBB0_3:
	ldr	w1, [x19]
	mov	x0, x19
	bl	_doc_set_device_id
	mov	x0, x19
	bl	_doc_reset_seq
	cbnz	w0, LBB0_5
; %bb.4:
	mov	x0, x19
	mov	x1, x23
	mov	x2, x22
	mov	x3, x21
	mov	x4, x24
	mov	x5, x20
	bl	_doc_read_seek
	cbz	w0, LBB0_8
LBB0_5:
Lloh10:
	adrp	x8, _DOC_DATAEND@GOTPAGE
Lloh11:
	ldr	x8, [x8, _DOC_DATAEND@GOTPAGEOFF]
Lloh12:
	ldr	w2, [x8]
	mov	x0, x19
	mov	w1, #0
	bl	_doc_writeb
	mov	x0, x19
	mov	w1, #2
	bl	_doc_delay
Lloh13:
	adrp	x8, _EIO@GOTPAGE
Lloh14:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
LBB0_6:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_7:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_8:
Lloh15:
	adrp	x8, _DOC_CMD_READ_ALL_PLANES@GOTPAGE
Lloh16:
	ldr	x8, [x8, _DOC_CMD_READ_ALL_PLANES@GOTPAGEOFF]
Lloh17:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_doc_flash_command
	mov	x0, x19
	mov	w1, #2
	bl	_doc_delay
	mov	x0, x19
	bl	_doc_wait_ready
Lloh18:
	adrp	x8, _DOC_CMD_SET_ADDR_READ@GOTPAGE
Lloh19:
	ldr	x8, [x8, _DOC_CMD_SET_ADDR_READ@GOTPAGEOFF]
Lloh20:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_doc_flash_command
	mov	x0, x19
	mov	w1, #1
	bl	_doc_delay
Lloh21:
	adrp	x8, _DOC_LAYOUT_PAGE_SIZE@GOTPAGE
Lloh22:
	ldr	x8, [x8, _DOC_LAYOUT_PAGE_SIZE@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
	lsl	w8, w8, #1
	cmp	w8, w20
	csel	w8, wzr, w8, gt
	sub	w8, w20, w8
	asr	w1, w8, #2
	mov	x0, x19
	bl	_doc_flash_address
	mov	x0, x19
	mov	w1, #1
	bl	_doc_delay
	mov	x0, x19
	bl	_doc_wait_ready
Lloh24:
	adrp	x8, _DOC_CMD_READ_FLASH@GOTPAGE
Lloh25:
	ldr	x8, [x8, _DOC_CMD_READ_FLASH@GOTPAGEOFF]
Lloh26:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_doc_flash_command
	mov	w0, #0
	b	LBB0_7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"doc_read_page_prepare(blocks=(%d,%d), page=%d, ofsInPage=%d)\n"

	.comm	_DOC_LAYOUT_WEAR_OFFSET,4,2     ; @DOC_LAYOUT_WEAR_OFFSET
	.comm	_DOC_LAYOUT_PAGE_OOB_SIZE,4,2   ; @DOC_LAYOUT_PAGE_OOB_SIZE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_DOC_CMD_READ_ALL_PLANES,4,2    ; @DOC_CMD_READ_ALL_PLANES
	.comm	_DOC_CMD_SET_ADDR_READ,4,2      ; @DOC_CMD_SET_ADDR_READ
	.comm	_DOC_LAYOUT_PAGE_SIZE,4,2       ; @DOC_LAYOUT_PAGE_SIZE
	.comm	_DOC_CMD_READ_FLASH,4,2         ; @DOC_CMD_READ_FLASH
	.comm	_DOC_DATAEND,4,2                ; @DOC_DATAEND
	.comm	_EIO,4,2                        ; @EIO
	.no_dead_strip	_doc_read_page_prepare
.subsections_via_symbols
