	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_nor_do_tx_rx
_mtk_nor_do_tx_rx:                      ## @mtk_nor_do_tx_rx
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
                                        ## kill: def $r9d killed $r9d def $r9
	movl	%ecx, %r12d
	movq	%rdi, %r13
	leal	(%r12,%r9), %edi
	incl	%edi
	movq	_MTK_NOR_MAX_SHIFT@GOTPCREL(%rip), %rax
	cmpl	(%rax), %edi
	jle	LBB0_2
## %bb.1:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_12
LBB0_2:
	movq	%rdx, %r15
	movq	%r8, -64(%rbp)                  ## 8-byte Spill
	movq	%r9, -72(%rbp)                  ## 8-byte Spill
	shll	$3, %edi
	movq	_MTK_NOR_CNT_REG@GOTPCREL(%rip), %rax
	movl	%esi, -48(%rbp)                 ## 4-byte Spill
	movq	(%rax), %rsi
	addq	(%r13), %rsi
	callq	_writeb
	movq	_MTK_NOR_MAX_RX_TX_SHIFT@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	leal	-1(%rbx), %edi
	movq	(%r13), %r14
	callq	_MTK_NOR_PRG_REG
	addq	%rax, %r14
	movl	-48(%rbp), %edi                 ## 4-byte Reload
	movq	%r14, %rsi
	callq	_writeb
	addl	$-2, %ebx
	testl	%r12d, %r12d
	jle	LBB0_5
## %bb.3:
	movl	%r12d, %eax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r12d, %r12d
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r15,%r12,4), %r14d
	movq	%r13, %r15
	movq	(%r13), %r13
	movl	%ebx, %edi
	callq	_MTK_NOR_PRG_REG
	addq	%rax, %r13
	movl	%r14d, %edi
	movq	%r13, %rsi
	movq	%r15, %r13
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	callq	_writeb
	incq	%r12
	decl	%ebx
	cmpq	%r12, -48(%rbp)                 ## 8-byte Folded Reload
	jne	LBB0_4
LBB0_5:
	testl	%ebx, %ebx
	movq	-72(%rbp), %r12                 ## 8-byte Reload
	js	LBB0_7
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r13), %r14
	movl	%ebx, %edi
	callq	_MTK_NOR_PRG_REG
	addq	%rax, %r14
	xorl	%edi, %edi
	movq	%r14, %rsi
	callq	_writeb
	addl	$-1, %ebx
	jb	LBB0_6
LBB0_7:
	movq	_MTK_NOR_PRG_CMD@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r13, %rdi
	callq	_mtk_nor_execute_cmd
                                        ## kill: def $eax killed $eax def $rax
	testl	%eax, %eax
	jne	LBB0_12
## %bb.8:
	testl	%r12d, %r12d
	jle	LBB0_11
## %bb.9:
	movq	%r13, -56(%rbp)                 ## 8-byte Spill
	movl	%r12d, %r13d
	shlq	$2, %r13
	decl	%r12d
	xorl	%ebx, %ebx
	movq	-64(%rbp), %r14                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	(%rax), %r15
	movl	%r12d, %edi
	callq	_MTK_NOR_SHREG
	addq	%rax, %r15
	movq	%r15, %rdi
	callq	_readb
	movl	%eax, (%r14,%rbx)
	addq	$4, %rbx
	decl	%r12d
	cmpq	%rbx, %r13
	jne	LBB0_10
LBB0_11:
	xorl	%eax, %eax
LBB0_12:
                                        ## kill: def $eax killed $eax killed $rax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_MTK_NOR_MAX_SHIFT,4,2          ## @MTK_NOR_MAX_SHIFT
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_MTK_NOR_CNT_REG,8,3            ## @MTK_NOR_CNT_REG
	.comm	_MTK_NOR_MAX_RX_TX_SHIFT,4,2    ## @MTK_NOR_MAX_RX_TX_SHIFT
	.comm	_MTK_NOR_PRG_CMD,4,2            ## @MTK_NOR_PRG_CMD
	.no_dead_strip	_mtk_nor_do_tx_rx
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_nor_do_tx_rx
_mtk_nor_do_tx_rx:                      ; @mtk_nor_do_tx_rx
	.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
	add	w8, w3, w5
	add	w8, w8, #1
Lloh0:
	adrp	x9, _MTK_NOR_MAX_SHIFT@GOTPAGE
Lloh1:
	ldr	x9, [x9, _MTK_NOR_MAX_SHIFT@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	cmp	w8, w9
	b.le	LBB0_2
; %bb.1:
Lloh3:
	adrp	x8, _EINVAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_12
LBB0_2:
	mov	x21, x5
	mov	x19, x4
	mov	x24, x3
	mov	x22, x2
	mov	x23, x1
	mov	x20, x0
	lsl	w0, w8, #3
	ldr	x8, [x20]
Lloh6:
	adrp	x9, _MTK_NOR_CNT_REG@GOTPAGE
Lloh7:
	ldr	x9, [x9, _MTK_NOR_CNT_REG@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	add	x1, x9, x8
	bl	_writeb
Lloh9:
	adrp	x8, _MTK_NOR_MAX_RX_TX_SHIFT@GOTPAGE
Lloh10:
	ldr	x8, [x8, _MTK_NOR_MAX_RX_TX_SHIFT@GOTPAGEOFF]
Lloh11:
	ldr	w25, [x8]
	sub	w0, w25, #1
	ldr	x26, [x20]
	bl	_MTK_NOR_PRG_REG
	add	x1, x0, x26
	mov	x0, x23
	bl	_writeb
	sub	w23, w25, #2
	cmp	w24, #1
	b.lt	LBB0_5
; %bb.3:
	mov	w25, w24
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w24, [x22], #4
	ldr	x26, [x20]
	mov	x0, x23
	bl	_MTK_NOR_PRG_REG
	add	x1, x0, x26
	mov	x0, x24
	bl	_writeb
	sub	w23, w23, #1
	subs	x25, x25, #1
	b.ne	LBB0_4
LBB0_5:
	tbnz	w23, #31, LBB0_7
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x22, [x20]
	mov	x0, x23
	bl	_MTK_NOR_PRG_REG
	add	x1, x0, x22
	mov	w0, #0
	bl	_writeb
	sub	w23, w23, #1
	cmn	w23, #1
	b.ne	LBB0_6
LBB0_7:
Lloh12:
	adrp	x8, _MTK_NOR_PRG_CMD@GOTPAGE
Lloh13:
	ldr	x8, [x8, _MTK_NOR_PRG_CMD@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_mtk_nor_execute_cmd
	cbnz	w0, LBB0_12
; %bb.8:
	subs	w22, w21, #1
	b.lt	LBB0_11
; %bb.9:
	mov	w21, w21
LBB0_10:                                ; =>This Inner Loop Header: Depth=1
	ldr	x23, [x20]
	mov	x0, x22
	bl	_MTK_NOR_SHREG
	add	x0, x0, x23
	bl	_readb
	str	w0, [x19], #4
	sub	w22, w22, #1
	sub	x21, x21, #1
	cbnz	x21, LBB0_10
LBB0_11:
	mov	w0, #0
LBB0_12:
	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 AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_MTK_NOR_MAX_SHIFT,4,2          ; @MTK_NOR_MAX_SHIFT
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_MTK_NOR_CNT_REG,8,3            ; @MTK_NOR_CNT_REG
	.comm	_MTK_NOR_MAX_RX_TX_SHIFT,4,2    ; @MTK_NOR_MAX_RX_TX_SHIFT
	.comm	_MTK_NOR_PRG_CMD,4,2            ; @MTK_NOR_PRG_CMD
	.no_dead_strip	_mtk_nor_do_tx_rx
.subsections_via_symbols
