	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mip4_flash_fw
_mip4_flash_fw:                         ## @mip4_flash_fw
	.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
	movl	%ecx, %ebx
	movl	%edx, %r13d
	movq	%rsi, -64(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r12
	movq	24(%rdi), %r15
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	%r12, %rdi
	callq	_mip4_bl_enter
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	%eax, %r14d
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdi
	movl	%eax, %edx
	callq	_dev_err
	jmp	LBB0_13
LBB0_2:
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	leaq	-44(%rbp), %rsi
	movq	%r12, %rdi
	callq	_mip4_bl_get_address
	movl	%eax, %r14d
	testl	%eax, %eax
	je	LBB0_5
LBB0_3:
	movl	%r14d, %r15d
	leaq	L_.str.3(%rip), %rsi
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	_dev_dbg
	movq	%r12, %rdi
	callq	_mip4_bl_exit
	testl	%eax, %eax
	je	LBB0_11
## %bb.4:
	movl	%eax, %ebx
	leaq	L_.str.4(%rip), %rsi
	movq	%r14, %rdi
	movl	%eax, %edx
	callq	_dev_err
	movl	%r15d, %r14d
	testl	%r15d, %r15d
	cmovel	%ebx, %r14d
	jmp	LBB0_12
LBB0_5:
	movq	_MIP4_BL_PAGE_SIZE@GOTPCREL(%rip), %r15
	movq	(%r15), %rdx
	movq	_MIP4_BL_PACKET_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	leaq	L_.str.2(%rip), %rsi
	xorl	%r14d, %r14d
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_dev_dbg
	testl	%r13d, %r13d
	jle	LBB0_3
## %bb.6:
	addl	%ebx, %r13d
	movq	(%r15), %rcx
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movl	%r13d, %r14d
	movslq	%ebx, %rsi
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%rsi,4), %r13
	movl	-44(%rbp), %r8d
	movq	%r12, %rdi
                                        ## kill: def $esi killed $esi killed $rsi
	movq	%r13, %rdx
	callq	_mip4_bl_program_page
	testl	%eax, %eax
	jne	LBB0_15
## %bb.8:                               ##   in Loop: Header=BB0_7 Depth=1
	movq	(%r15), %rcx
	movl	-44(%rbp), %r8d
	movq	%r12, %rdi
	movl	%ebx, %esi
	movq	%r13, %rdx
	callq	_mip4_bl_verify_page
	testl	%eax, %eax
	jne	LBB0_15
## %bb.9:                               ##   in Loop: Header=BB0_7 Depth=1
	movq	(%r15), %rcx
	addl	%ecx, %ebx
	movl	%r14d, %r13d
	cmpl	%r14d, %ebx
	jl	LBB0_7
## %bb.10:
	xorl	%r14d, %r14d
	jmp	LBB0_3
LBB0_11:
	movl	%r15d, %r14d
LBB0_12:
	movq	%r12, %rdi
	callq	_mip4_power_off
	movq	%r12, %rdi
	callq	_mip4_power_on
	movq	%r12, %rdi
	callq	_mip4_query_device
	movq	_ABS_MT_POSITION_X@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	4(%r12), %edi
	movl	16(%r12), %ecx
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	_input_set_abs_params
	movq	_ABS_MT_POSITION_Y@GOTPCREL(%rip), %r13
	movl	(%r13), %esi
	movl	4(%r12), %edi
	movl	12(%r12), %ecx
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	_input_set_abs_params
	movq	_ABS_X@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movl	4(%r12), %edi
	movl	16(%r12), %ecx
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	_input_set_abs_params
	movq	_ABS_Y@GOTPCREL(%rip), %r15
	movl	(%r15), %esi
	movl	4(%r12), %edi
	movl	12(%r12), %ecx
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	_input_set_abs_params
	movq	_ABS_MT_POSITION_X@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	4(%r12), %edi
	movl	8(%r12), %edx
	callq	_input_abs_set_res
	movl	(%r12), %edx
	movl	4(%r12), %edi
	movl	(%r13), %esi
	callq	_input_abs_set_res
	movl	(%rbx), %esi
	movl	4(%r12), %edi
	movl	8(%r12), %edx
	callq	_input_abs_set_res
	movl	(%r12), %edx
	movl	4(%r12), %edi
	movl	(%r15), %esi
	callq	_input_abs_set_res
LBB0_13:
	movl	%r14d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_15:
	movl	%eax, %r14d
	jmp	LBB0_3
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Entering bootloader mode\n"

L_.str.1:                               ## @.str.1
	.asciz	"Failed to enter bootloader mode: %d\n"

L_.str.2:                               ## @.str.2
	.asciz	"Program & Verify, page size: %d, packet size: %d\n"

	.comm	_MIP4_BL_PAGE_SIZE,8,3          ## @MIP4_BL_PAGE_SIZE
	.comm	_MIP4_BL_PACKET_SIZE,4,2        ## @MIP4_BL_PACKET_SIZE
L_.str.3:                               ## @.str.3
	.asciz	"Exiting bootloader mode\n"

L_.str.4:                               ## @.str.4
	.asciz	"Failed to exit bootloader mode: %d\n"

	.comm	_ABS_MT_POSITION_X,4,2          ## @ABS_MT_POSITION_X
	.comm	_ABS_MT_POSITION_Y,4,2          ## @ABS_MT_POSITION_Y
	.comm	_ABS_X,4,2                      ## @ABS_X
	.comm	_ABS_Y,4,2                      ## @ABS_Y
	.no_dead_strip	_mip4_flash_fw
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mip4_flash_fw
_mip4_flash_fw:                         ; @mip4_flash_fw
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x22, x3
	mov	x24, x2
	mov	x23, x1
	mov	x19, x0
	ldr	x21, [x0, #24]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x21
	bl	_dev_dbg
	mov	x0, x19
	bl	_mip4_bl_enter
	cbz	w0, LBB0_2
; %bb.1:
	mov	x20, x0
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x21
	mov	x2, x20
	bl	_dev_err
	b	LBB0_13
LBB0_2:
	add	x1, sp, #28
	mov	x0, x19
	bl	_mip4_bl_get_address
	mov	x20, x0
	cbnz	w0, LBB0_10
; %bb.3:
Lloh4:
	adrp	x25, _MIP4_BL_PAGE_SIZE@GOTPAGE
Lloh5:
	ldr	x25, [x25, _MIP4_BL_PAGE_SIZE@GOTPAGEOFF]
	ldr	x8, [x25]
Lloh6:
	adrp	x9, _MIP4_BL_PACKET_SIZE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _MIP4_BL_PACKET_SIZE@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	stp	x8, x9, [sp]
Lloh9:
	adrp	x1, l_.str.2@PAGE
Lloh10:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x21
	bl	_dev_dbg
	cmp	w24, #1
	b.lt	LBB0_8
; %bb.4:
	add	w26, w22, w24
	ldr	x3, [x25]
LBB0_5:                                 ; =>This Inner Loop Header: Depth=1
	add	x24, x23, w22, sxtw #2
	ldr	w4, [sp, #28]
	mov	x0, x19
	mov	x1, x22
	mov	x2, x24
	bl	_mip4_bl_program_page
	cbnz	w0, LBB0_9
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	ldr	x3, [x25]
	ldr	w4, [sp, #28]
	mov	x0, x19
	mov	x1, x22
	mov	x2, x24
	bl	_mip4_bl_verify_page
	cbnz	w0, LBB0_9
; %bb.7:                                ;   in Loop: Header=BB0_5 Depth=1
	ldr	x3, [x25]
	add	w22, w22, w3
	cmp	w22, w26
	b.lt	LBB0_5
LBB0_8:
	mov	w20, #0
	b	LBB0_10
LBB0_9:
	mov	x20, x0
LBB0_10:
Lloh11:
	adrp	x1, l_.str.3@PAGE
Lloh12:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x21
	bl	_dev_dbg
	mov	x0, x19
	bl	_mip4_bl_exit
	cbz	w0, LBB0_12
; %bb.11:
	mov	x22, x0
Lloh13:
	adrp	x1, l_.str.4@PAGE
Lloh14:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x21
	mov	x2, x22
	bl	_dev_err
	cmp	w20, #0
	csel	w20, w22, w20, eq
LBB0_12:
	mov	x0, x19
	bl	_mip4_power_off
	mov	x0, x19
	bl	_mip4_power_on
	mov	x0, x19
	bl	_mip4_query_device
	ldr	w0, [x19, #4]
Lloh15:
	adrp	x21, _ABS_MT_POSITION_X@GOTPAGE
Lloh16:
	ldr	x21, [x21, _ABS_MT_POSITION_X@GOTPAGEOFF]
	ldr	w1, [x21]
	ldr	w3, [x19, #16]
	mov	w2, #0
	mov	w4, #0
	mov	w5, #0
	bl	_input_set_abs_params
	ldr	w0, [x19, #4]
Lloh17:
	adrp	x22, _ABS_MT_POSITION_Y@GOTPAGE
Lloh18:
	ldr	x22, [x22, _ABS_MT_POSITION_Y@GOTPAGEOFF]
	ldr	w1, [x22]
	ldr	w3, [x19, #12]
	mov	w2, #0
	mov	w4, #0
	mov	w5, #0
	bl	_input_set_abs_params
	ldr	w0, [x19, #4]
Lloh19:
	adrp	x23, _ABS_X@GOTPAGE
Lloh20:
	ldr	x23, [x23, _ABS_X@GOTPAGEOFF]
	ldr	w1, [x23]
	ldr	w3, [x19, #16]
	mov	w2, #0
	mov	w4, #0
	mov	w5, #0
	bl	_input_set_abs_params
	ldr	w0, [x19, #4]
Lloh21:
	adrp	x24, _ABS_Y@GOTPAGE
Lloh22:
	ldr	x24, [x24, _ABS_Y@GOTPAGEOFF]
	ldr	w1, [x24]
	ldr	w3, [x19, #12]
	mov	w2, #0
	mov	w4, #0
	mov	w5, #0
	bl	_input_set_abs_params
	ldr	w1, [x21]
	ldp	w0, w2, [x19, #4]
	bl	_input_abs_set_res
	ldr	w1, [x22]
	ldp	w2, w0, [x19]
	bl	_input_abs_set_res
	ldr	w1, [x23]
	ldp	w0, w2, [x19, #4]
	bl	_input_abs_set_res
	ldr	w1, [x24]
	ldp	w2, w0, [x19]
	bl	_input_abs_set_res
LBB0_13:
	mov	x0, x20
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh15, Lloh16
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Entering bootloader mode\n"

l_.str.1:                               ; @.str.1
	.asciz	"Failed to enter bootloader mode: %d\n"

l_.str.2:                               ; @.str.2
	.asciz	"Program & Verify, page size: %d, packet size: %d\n"

	.comm	_MIP4_BL_PAGE_SIZE,8,3          ; @MIP4_BL_PAGE_SIZE
	.comm	_MIP4_BL_PACKET_SIZE,4,2        ; @MIP4_BL_PACKET_SIZE
l_.str.3:                               ; @.str.3
	.asciz	"Exiting bootloader mode\n"

l_.str.4:                               ; @.str.4
	.asciz	"Failed to exit bootloader mode: %d\n"

	.comm	_ABS_MT_POSITION_X,4,2          ; @ABS_MT_POSITION_X
	.comm	_ABS_MT_POSITION_Y,4,2          ; @ABS_MT_POSITION_Y
	.comm	_ABS_X,4,2                      ; @ABS_X
	.comm	_ABS_Y,4,2                      ; @ABS_Y
	.no_dead_strip	_mip4_flash_fw
.subsections_via_symbols
