	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_nor_write
_mtk_nor_write:                         ## @mtk_nor_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
	movq	%rcx, %r12
	movq	%rdx, %r14
	movq	%rsi, %r13
	movq	(%rdi), %r15
	movq	%r15, %rdi
	callq	_mtk_nor_write_buffer_enable
	testl	%eax, %eax
	js	LBB0_3
## %bb.1:
	movq	_SFLASH_WRBUF_SIZE@GOTPCREL(%rip), %rcx
	cmpq	%r14, (%rcx)
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movq	%r15, -48(%rbp)                 ## 8-byte Spill
	jbe	LBB0_5
## %bb.2:
	xorl	%r14d, %r14d
	jmp	LBB0_9
LBB0_3:
	movl	%eax, %ebx
	movl	(%r15), %edi
	leaq	L_.str(%rip), %rsi
	jmp	LBB0_4
LBB0_5:
	xorl	%r14d, %r14d
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	%rcx, %r15
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movq	%r13, %rsi
	movq	%r12, %rdx
	callq	_mtk_nor_write_buffer
	testl	%eax, %eax
	js	LBB0_7
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=1
	movq	%r15, %rcx
	movq	(%r15), %rax
	addq	%rax, %r13
	leaq	(%r12,%rax,4), %r12
	addq	%rax, %r14
	addq	%r14, %rax
	cmpq	-56(%rbp), %rax                 ## 8-byte Folded Reload
	jbe	LBB0_6
LBB0_9:
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	movq	%r15, %rdi
	callq	_mtk_nor_write_buffer_disable
	testl	%eax, %eax
	js	LBB0_10
## %bb.11:
	movq	%r15, %rbx
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	cmpq	%r15, %r14
	jae	LBB0_14
## %bb.12:
	movl	%r15d, %edx
	subl	%r14d, %edx
	movq	%rbx, %rdi
	movq	%r13, %rsi
	movq	%r12, %rcx
	callq	_mtk_nor_write_single_byte
	testl	%eax, %eax
	js	LBB0_13
LBB0_14:
	movq	%r15, %rax
	jmp	LBB0_15
LBB0_10:
	movl	%eax, %ebx
	movl	(%r15), %edi
	leaq	L_.str.2(%rip), %rsi
LBB0_4:
	callq	_dev_warn
	movl	%ebx, %eax
	jmp	LBB0_15
LBB0_7:
	movl	%eax, %ebx
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
	callq	_dev_err
	movl	%ebx, %eax
	jmp	LBB0_15
LBB0_13:
	movl	%eax, %r14d
	movl	(%rbx), %edi
	leaq	L_.str.3(%rip), %rsi
	callq	_dev_err
	movl	%r14d, %eax
LBB0_15:
                                        ## kill: def $eax killed $eax killed $rax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"write buffer enable failed!\n"

	.comm	_SFLASH_WRBUF_SIZE,8,3          ## @SFLASH_WRBUF_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"write buffer failed!\n"

L_.str.2:                               ## @.str.2
	.asciz	"write buffer disable failed!\n"

L_.str.3:                               ## @.str.3
	.asciz	"write single byte failed!\n"

	.no_dead_strip	_mtk_nor_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_nor_write
_mtk_nor_write:                         ; @mtk_nor_write
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x21, x3
	mov	x19, x2
	mov	x22, x1
	ldr	x20, [x0]
	mov	x0, x20
	bl	_mtk_nor_write_buffer_enable
	tbnz	w0, #31, LBB0_3
; %bb.1:
Lloh0:
	adrp	x25, _SFLASH_WRBUF_SIZE@GOTPAGE
Lloh1:
	ldr	x25, [x25, _SFLASH_WRBUF_SIZE@GOTPAGEOFF]
	ldr	x8, [x25]
	cmp	x8, x19
	b.ls	LBB0_4
; %bb.2:
	mov	x24, #0
	b	LBB0_7
LBB0_3:
	mov	x23, x0
	ldr	w0, [x20]
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_12
LBB0_4:
	mov	x24, #0
LBB0_5:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x20
	mov	x1, x22
	mov	x2, x21
	bl	_mtk_nor_write_buffer
	tbnz	w0, #31, LBB0_13
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	ldr	x8, [x25]
	add	x22, x8, x22
	add	x21, x21, x8, lsl #2
	add	x24, x8, x24
	add	x8, x8, x24
	cmp	x8, x19
	b.ls	LBB0_5
LBB0_7:
	mov	x0, x20
	bl	_mtk_nor_write_buffer_disable
	tbnz	w0, #31, LBB0_11
; %bb.8:
	cmp	x24, x19
	b.hs	LBB0_15
; %bb.9:
	sub	w2, w19, w24
	mov	x0, x20
	mov	x1, x22
	mov	x3, x21
	bl	_mtk_nor_write_single_byte
	tbz	w0, #31, LBB0_15
; %bb.10:
	mov	x21, x0
	ldr	w0, [x20]
Lloh4:
	adrp	x1, l_.str.3@PAGE
Lloh5:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_err
	mov	x19, x21
	b	LBB0_15
LBB0_11:
	mov	x23, x0
	ldr	w0, [x20]
Lloh6:
	adrp	x1, l_.str.2@PAGE
Lloh7:
	add	x1, x1, l_.str.2@PAGEOFF
LBB0_12:
	bl	_dev_warn
	b	LBB0_14
LBB0_13:
	mov	x23, x0
	ldr	w0, [x20]
Lloh8:
	adrp	x1, l_.str.1@PAGE
Lloh9:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
LBB0_14:
	mov	x19, x23
LBB0_15:
	mov	x0, x19
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"write buffer enable failed!\n"

	.comm	_SFLASH_WRBUF_SIZE,8,3          ; @SFLASH_WRBUF_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"write buffer failed!\n"

l_.str.2:                               ; @.str.2
	.asciz	"write buffer disable failed!\n"

l_.str.3:                               ; @.str.3
	.asciz	"write single byte failed!\n"

	.no_dead_strip	_mtk_nor_write
.subsections_via_symbols
