	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ns_nand_write_buf
_ns_nand_write_buf:                     ## @ns_nand_write_buf
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	(%rdi), %rax
	movq	(%rax), %rbx
	movl	(%rbx), %edi
	movq	_STATE_DATAIN_MASK@GOTPCREL(%rip), %rax
	testl	%edi, (%rax)
	je	LBB0_1
## %bb.2:
	movq	8(%rbx), %rdi
	movslq	%edx, %r14
	leaq	(%rdi,%r14), %rax
	cmpq	16(%rbx), %rax
	jle	LBB0_5
## %bb.3:
	leaq	L_.str.1(%rip), %rdi
	xorl	%eax, %eax
	callq	_NS_ERR
	jmp	LBB0_4
LBB0_1:
	callq	_get_state_name
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_NS_ERR
LBB0_4:
	movq	%rbx, %rdi
	callq	_NS_STATUS_FAILED
	movq	%rbx, %rdi
	movl	%eax, %esi
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_switch_to_ready_state          ## TAILCALL
LBB0_5:
	addq	24(%rbx), %rdi
	movl	%r14d, %edx
	callq	_memcpy
	addq	8(%rbx), %r14
	movq	%r14, 8(%rbx)
	cmpq	16(%rbx), %r14
	jne	LBB0_6
## %bb.7:
	leaq	L_.str.2(%rip), %rdi
	movq	%r14, %rsi
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_NS_DBG                         ## TAILCALL
LBB0_6:
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_STATE_DATAIN_MASK,4,2          ## @STATE_DATAIN_MASK
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"write_buf: data input isn't expected, state is %s, switch to STATE_READY\n"

L_.str.1:                               ## @.str.1
	.asciz	"write_buf: too many input bytes\n"

L_.str.2:                               ## @.str.2
	.asciz	"write_buf: %d bytes were written\n"

	.no_dead_strip	_ns_nand_write_buf
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ns_nand_write_buf
_ns_nand_write_buf:                     ; @ns_nand_write_buf
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
                                        ; kill: def $w2 killed $w2 def $x2
	ldr	x8, [x0]
	ldr	x19, [x8]
	ldr	w0, [x19]
Lloh0:
	adrp	x8, _STATE_DATAIN_MASK@GOTPAGE
Lloh1:
	ldr	x8, [x8, _STATE_DATAIN_MASK@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_3
; %bb.1:
	sxtw	x20, w2
	ldp	x8, x9, [x19, #8]
	add	x10, x8, x20
	cmp	x10, x9
	b.le	LBB0_5
; %bb.2:
Lloh3:
	adrp	x0, l_.str.1@PAGE
Lloh4:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_4
LBB0_3:
	bl	_get_state_name
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
LBB0_4:
	bl	_NS_ERR
	mov	x0, x19
	bl	_NS_STATUS_FAILED
	mov	x1, x0
	mov	x0, x19
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	b	_switch_to_ready_state
LBB0_5:
	ldr	x9, [x19, #24]
	add	x0, x9, x8
                                        ; kill: def $w2 killed $w2 killed $x2
	bl	_memcpy
	ldp	x8, x9, [x19, #8]
	add	x1, x8, x20
	cmp	x1, x9
	str	x1, [x19, #8]
	b.ne	LBB0_7
; %bb.6:
Lloh7:
	adrp	x0, l_.str.2@PAGE
Lloh8:
	add	x0, x0, l_.str.2@PAGEOFF
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	b	_NS_DBG
LBB0_7:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_STATE_DATAIN_MASK,4,2          ; @STATE_DATAIN_MASK
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"write_buf: data input isn't expected, state is %s, switch to STATE_READY\n"

l_.str.1:                               ; @.str.1
	.asciz	"write_buf: too many input bytes\n"

l_.str.2:                               ; @.str.2
	.asciz	"write_buf: %d bytes were written\n"

	.no_dead_strip	_ns_nand_write_buf
.subsections_via_symbols
