	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function __c2port_write_flash_data
___c2port_write_flash_data:             ## @__c2port_write_flash_data
	.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
	movq	%rdx, %rbx
	movq	(%rdi), %rax
	movq	8(%rax), %rdx
	imulq	(%rax), %rdx
	movq	%rdx, %rax
	subq	%rbx, %rax
	cmpq	%rax, %rcx
	cmovbq	%rcx, %rax
	cmpq	$128, %rax
	movl	$128, %r12d
	cmovbq	%rax, %r12
	cmpq	%rbx, %rdx
	jbe	LBB0_17
## %bb.1:
	movq	%rsi, %r15
	movq	%rdi, %r14
	movq	_C2PORT_FPDAT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_c2port_write_ar
	movq	_C2PORT_BLOCK_WRITE@GOTPCREL(%rip), %rax
	movsbl	(%rax), %esi
	movq	%r14, %rdi
	callq	_c2port_write_dr
	movq	%r14, %rdi
	callq	_c2port_poll_in_busy
	testl	%eax, %eax
	js	LBB0_27
## %bb.2:
	movq	%r14, %rdi
	callq	_c2port_poll_out_ready
	testl	%eax, %eax
	js	LBB0_27
## %bb.3:
	leaq	-48(%rbp), %rsi
	movq	%r14, %rdi
	callq	_c2port_read_dr
	testl	%eax, %eax
	js	LBB0_27
## %bb.4:
	movq	-48(%rbp), %rax
	movq	_C2PORT_COMMAND_OK@GOTPCREL(%rip), %r13
	cmpq	(%r13), %rax
	jne	LBB0_22
## %bb.5:
	movl	%ebx, %eax
	shrl	$8, %eax
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_c2port_write_dr
	movq	%r14, %rdi
	callq	_c2port_poll_in_busy
	testl	%eax, %eax
	js	LBB0_27
## %bb.6:
	movsbl	%bl, %esi
	movq	%r14, %rdi
	callq	_c2port_write_dr
	movq	%r14, %rdi
	callq	_c2port_poll_in_busy
	testl	%eax, %eax
	js	LBB0_27
## %bb.7:
	movsbl	%r12b, %esi
	movq	%r14, %rdi
	callq	_c2port_write_dr
	movq	%r14, %rdi
	callq	_c2port_poll_in_busy
	testl	%eax, %eax
	js	LBB0_27
## %bb.8:
	movq	%r14, %rdi
	callq	_c2port_poll_out_ready
	testl	%eax, %eax
	js	LBB0_27
## %bb.9:
	leaq	-48(%rbp), %rsi
	movq	%r14, %rdi
	callq	_c2port_read_dr
	testl	%eax, %eax
	js	LBB0_27
## %bb.10:
	movq	-48(%rbp), %rax
	cmpq	(%r13), %rax
	jne	LBB0_22
## %bb.11:
	testq	%r12, %r12
	je	LBB0_16
## %bb.12:
	xorl	%ebx, %ebx
LBB0_13:                                ## =>This Inner Loop Header: Depth=1
	movsbl	(%r15,%rbx), %esi
	movq	%r14, %rdi
	callq	_c2port_write_dr
	testl	%eax, %eax
	js	LBB0_27
## %bb.14:                              ##   in Loop: Header=BB0_13 Depth=1
	movq	%r14, %rdi
	callq	_c2port_poll_in_busy
	testl	%eax, %eax
	js	LBB0_27
## %bb.15:                              ##   in Loop: Header=BB0_13 Depth=1
	incq	%rbx
	cmpq	%rbx, %r12
	jne	LBB0_13
LBB0_16:
	movq	%r14, %rdi
	callq	_c2port_poll_out_ready
	testl	%eax, %eax
	cmovsl	%eax, %r12d
	jmp	LBB0_28
LBB0_17:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_18:
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
	jmp	LBB0_28
LBB0_27:
	movl	%eax, %r12d
LBB0_28:
	movl	%r12d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_22:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_18
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_C2PORT_FPDAT,4,2               ## @C2PORT_FPDAT
	.comm	_C2PORT_BLOCK_WRITE,1,0         ## @C2PORT_BLOCK_WRITE
	.comm	_C2PORT_COMMAND_OK,8,3          ## @C2PORT_COMMAND_OK
	.comm	_EBUSY,4,2                      ## @EBUSY
	.no_dead_strip	___c2port_write_flash_data
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function __c2port_write_flash_data
___c2port_write_flash_data:             ; @__c2port_write_flash_data
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.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
	ldr	x8, [x0]
	ldp	x9, x8, [x8]
	mul	x8, x8, x9
	subs	x9, x8, x2
	cmp	x3, x9
	csel	x9, x3, x9, lo
	mov	w10, #128
	cmp	x9, #128
	csel	x22, x9, x10, lo
	cmp	x8, x2
	b.ls	LBB0_17
; %bb.1:
	mov	x21, x2
	mov	x20, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _C2PORT_FPDAT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _C2PORT_FPDAT@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	bl	_c2port_write_ar
Lloh3:
	adrp	x8, _C2PORT_BLOCK_WRITE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _C2PORT_BLOCK_WRITE@GOTPAGEOFF]
Lloh5:
	ldrsb	w1, [x8]
	mov	x0, x19
	bl	_c2port_write_dr
	mov	x0, x19
	bl	_c2port_poll_in_busy
	tbnz	w0, #31, LBB0_19
; %bb.2:
	mov	x0, x19
	bl	_c2port_poll_out_ready
	tbnz	w0, #31, LBB0_19
; %bb.3:
	add	x1, sp, #8
	mov	x0, x19
	bl	_c2port_read_dr
	tbnz	w0, #31, LBB0_19
; %bb.4:
	ldr	x8, [sp, #8]
Lloh6:
	adrp	x23, _C2PORT_COMMAND_OK@GOTPAGE
Lloh7:
	ldr	x23, [x23, _C2PORT_COMMAND_OK@GOTPAGEOFF]
	ldr	x9, [x23]
	cmp	x8, x9
	b.ne	LBB0_20
; %bb.5:
	sbfx	w1, w21, #8, #8
	mov	x0, x19
	bl	_c2port_write_dr
	mov	x0, x19
	bl	_c2port_poll_in_busy
	tbnz	w0, #31, LBB0_19
; %bb.6:
	sxtb	w1, w21
	mov	x0, x19
	bl	_c2port_write_dr
	mov	x0, x19
	bl	_c2port_poll_in_busy
	tbnz	w0, #31, LBB0_19
; %bb.7:
	sxtb	w1, w22
	mov	x0, x19
	bl	_c2port_write_dr
	mov	x0, x19
	bl	_c2port_poll_in_busy
	tbnz	w0, #31, LBB0_19
; %bb.8:
	mov	x0, x19
	bl	_c2port_poll_out_ready
	tbnz	w0, #31, LBB0_19
; %bb.9:
	add	x1, sp, #8
	mov	x0, x19
	bl	_c2port_read_dr
	tbnz	w0, #31, LBB0_19
; %bb.10:
	ldr	x8, [sp, #8]
	ldr	x9, [x23]
	cmp	x8, x9
	b.ne	LBB0_20
; %bb.11:
	cbz	x22, LBB0_16
; %bb.12:
	mov	x21, x22
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	ldrsb	w1, [x20]
	mov	x0, x19
	bl	_c2port_write_dr
	tbnz	w0, #31, LBB0_19
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=1
	mov	x0, x19
	bl	_c2port_poll_in_busy
	tbnz	w0, #31, LBB0_19
; %bb.15:                               ;   in Loop: Header=BB0_13 Depth=1
	add	x20, x20, #1
	subs	x21, x21, #1
	b.ne	LBB0_13
LBB0_16:
	mov	x0, x19
	bl	_c2port_poll_out_ready
	cmp	w0, #0
	csel	w0, w0, w22, lt
	b	LBB0_19
LBB0_17:
Lloh8:
	adrp	x8, _EINVAL@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_18:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_19:
	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
	add	sp, sp, #80
	ret
LBB0_20:
Lloh10:
	adrp	x8, _EBUSY@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_18
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_C2PORT_FPDAT,4,2               ; @C2PORT_FPDAT
	.comm	_C2PORT_BLOCK_WRITE,1,0         ; @C2PORT_BLOCK_WRITE
	.comm	_C2PORT_COMMAND_OK,8,3          ; @C2PORT_COMMAND_OK
	.comm	_EBUSY,4,2                      ; @EBUSY
	.no_dead_strip	___c2port_write_flash_data
.subsections_via_symbols
