	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function elan_i2c_write_fw_block
_elan_i2c_write_fw_block:               ## @elan_i2c_write_fw_block
	.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
	movl	%ecx, -64(%rbp)                 ## 4-byte Spill
	movl	%edx, -68(%rbp)                 ## 4-byte Spill
	movq	%rsi, %r13
	movq	%rdi, %r12
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	_ETP_FW_PAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	leal	4(%r14), %ebx
	shlq	$2, %rbx
	movq	%rbx, %rax
	callq	____chkstk_darwin
	addq	$15, %rax
	andq	$-16, %rax
	subq	%rax, %rsp
	movq	%rsp, %r15
	movq	_ETP_I2C_IAP_REG_L@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r15)
	movq	_ETP_I2C_IAP_REG_H@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 4(%r15)
	leaq	8(%r15), %rdi
	movq	%r13, %rsi
	movl	%r14d, %edx
	callq	_memcpy
	movq	_ETP_FW_PAGE_SIZE@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	leaq	(%r15,%rax,4), %rsi
	addq	$8, %rsi
	movl	-68(%rbp), %edi                 ## 4-byte Reload
	callq	_put_unaligned_le16
	movq	%r12, %rdi
	movq	%r15, %rsi
	movl	%ebx, %edx
	callq	_i2c_master_send
	movslq	%eax, %rcx
	cmpq	%rcx, %rbx
	jne	LBB0_1
## %bb.2:
	movl	$35, %edi
	callq	_msleep
	movq	_ETP_I2C_IAP_CTRL_CMD@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-60(%rbp), %rdx
	movq	%r12, %rdi
	callq	_elan_i2c_read_cmd
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movl	%eax, %ebx
	leaq	L_.str.1(%rip), %rsi
	movq	%r12, %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_7
LBB0_1:
	movq	_EIO@GOTPCREL(%rip), %rcx
	xorl	%ebx, %ebx
	subl	(%rcx), %ebx
	testl	%eax, %eax
	cmovsl	%eax, %ebx
	leaq	L_.str(%rip), %rsi
	movq	%r12, %rdi
	movl	-64(%rbp), %edx                 ## 4-byte Reload
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	_dev_err
LBB0_7:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_9
## %bb.8:
	movl	%ebx, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	leaq	-60(%rbp), %rdi
	callq	_le16_to_cpup
	movq	_ETP_FW_IAP_PAGE_ERR@GOTPCREL(%rip), %rcx
	movq	_ETP_FW_IAP_INTF_ERR@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	orl	(%rcx), %edx
	testl	%eax, %edx
	je	LBB0_5
## %bb.6:
	leaq	L_.str.2(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EIO@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_7
LBB0_5:
	xorl	%ebx, %ebx
	jmp	LBB0_7
LBB0_9:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_ETP_FW_PAGE_SIZE,4,2           ## @ETP_FW_PAGE_SIZE
	.comm	_ETP_I2C_IAP_REG_L,4,2          ## @ETP_I2C_IAP_REG_L
	.comm	_ETP_I2C_IAP_REG_H,4,2          ## @ETP_I2C_IAP_REG_H
	.comm	_EIO,4,2                        ## @EIO
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to write page %d: %d\n"

	.comm	_ETP_I2C_IAP_CTRL_CMD,4,2       ## @ETP_I2C_IAP_CTRL_CMD
L_.str.1:                               ## @.str.1
	.asciz	"Failed to read IAP write result: %d\n"

	.comm	_ETP_FW_IAP_PAGE_ERR,4,2        ## @ETP_FW_IAP_PAGE_ERR
	.comm	_ETP_FW_IAP_INTF_ERR,4,2        ## @ETP_FW_IAP_INTF_ERR
L_.str.2:                               ## @.str.2
	.asciz	"IAP reports failed write: %04hx\n"

	.no_dead_strip	_elan_i2c_write_fw_block
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function elan_i2c_write_fw_block
_elan_i2c_write_fw_block:               ; @elan_i2c_write_fw_block
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	sub	sp, sp, #32
	mov	x20, x3
	mov	x21, x2
	mov	x19, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-56]
Lloh3:
	adrp	x24, _ETP_FW_PAGE_SIZE@GOTPAGE
Lloh4:
	ldr	x24, [x24, _ETP_FW_PAGE_SIZE@GOTPAGEOFF]
	ldr	w2, [x24]
	add	w8, w2, #4
	lsl	x22, x8, #2
	mov	x9, x22
Lloh5:
	adrp	x16, ___chkstk_darwin@GOTPAGE
Lloh6:
	ldr	x16, [x16, ___chkstk_darwin@GOTPAGEOFF]
	blr	x16
	mov	x8, sp
	add	x9, x22, #15
	and	x9, x9, #0x7fffffff0
	sub	x23, x8, x9
	mov	sp, x23
Lloh7:
	adrp	x8, _ETP_I2C_IAP_REG_L@GOTPAGE
Lloh8:
	ldr	x8, [x8, _ETP_I2C_IAP_REG_L@GOTPAGEOFF]
Lloh9:
	ldr	w8, [x8]
Lloh10:
	adrp	x9, _ETP_I2C_IAP_REG_H@GOTPAGE
Lloh11:
	ldr	x9, [x9, _ETP_I2C_IAP_REG_H@GOTPAGEOFF]
Lloh12:
	ldr	w9, [x9]
	stp	w8, w9, [x23]
	add	x0, x23, #8
	bl	_memcpy
	ldrsw	x8, [x24]
	add	x8, x23, x8, lsl #2
	add	x1, x8, #8
	mov	x0, x21
	bl	_put_unaligned_le16
	mov	x0, x19
	mov	x1, x23
	mov	x2, x22
	bl	_i2c_master_send
	cmp	x22, w0, sxtw
	b.ne	LBB0_3
; %bb.1:
	mov	w0, #35
	bl	_msleep
Lloh13:
	adrp	x8, _ETP_I2C_IAP_CTRL_CMD@GOTPAGE
Lloh14:
	ldr	x8, [x8, _ETP_I2C_IAP_CTRL_CMD@GOTPAGEOFF]
Lloh15:
	ldr	w1, [x8]
	sub	x2, x29, #68
	mov	x0, x19
	bl	_elan_i2c_read_cmd
	cbz	w0, LBB0_6
; %bb.2:
	mov	x21, x0
Lloh16:
	adrp	x1, l_.str.1@PAGE
Lloh17:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	mov	x2, x21
	bl	_dev_err
	b	LBB0_4
LBB0_3:
Lloh18:
	adrp	x8, _EIO@GOTPAGE
Lloh19:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	cmp	w0, #0
	csneg	w21, w0, w8, lt
	str	x21, [sp, #-16]!
Lloh21:
	adrp	x1, l_.str@PAGE
Lloh22:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	mov	x2, x20
	bl	_dev_err
	add	sp, sp, #16
LBB0_4:
	ldur	x8, [x29, #-56]
Lloh23:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh24:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh25:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_9
; %bb.5:
	mov	x0, x21
	sub	sp, x29, #48
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_6:
	sub	x0, x29, #68
	bl	_le16_to_cpup
Lloh26:
	adrp	x8, _ETP_FW_IAP_PAGE_ERR@GOTPAGE
Lloh27:
	ldr	x8, [x8, _ETP_FW_IAP_PAGE_ERR@GOTPAGEOFF]
Lloh28:
	ldr	w8, [x8]
Lloh29:
	adrp	x9, _ETP_FW_IAP_INTF_ERR@GOTPAGE
Lloh30:
	ldr	x9, [x9, _ETP_FW_IAP_INTF_ERR@GOTPAGEOFF]
Lloh31:
	ldr	w9, [x9]
	orr	w8, w9, w8
	tst	w8, w0
	b.eq	LBB0_8
; %bb.7:
	mov	x2, x0
Lloh32:
	adrp	x1, l_.str.2@PAGE
Lloh33:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x19
	bl	_dev_err
Lloh34:
	adrp	x8, _EIO@GOTPAGE
Lloh35:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh36:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_4
LBB0_8:
	mov	w21, #0
	b	LBB0_4
LBB0_9:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpAdd	Lloh32, Lloh33
	.cfi_endproc
                                        ; -- End function
	.comm	_ETP_FW_PAGE_SIZE,4,2           ; @ETP_FW_PAGE_SIZE
	.comm	_ETP_I2C_IAP_REG_L,4,2          ; @ETP_I2C_IAP_REG_L
	.comm	_ETP_I2C_IAP_REG_H,4,2          ; @ETP_I2C_IAP_REG_H
	.comm	_EIO,4,2                        ; @EIO
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to write page %d: %d\n"

	.comm	_ETP_I2C_IAP_CTRL_CMD,4,2       ; @ETP_I2C_IAP_CTRL_CMD
l_.str.1:                               ; @.str.1
	.asciz	"Failed to read IAP write result: %d\n"

	.comm	_ETP_FW_IAP_PAGE_ERR,4,2        ; @ETP_FW_IAP_PAGE_ERR
	.comm	_ETP_FW_IAP_INTF_ERR,4,2        ; @ETP_FW_IAP_INTF_ERR
l_.str.2:                               ; @.str.2
	.asciz	"IAP reports failed write: %04hx\n"

	.no_dead_strip	_elan_i2c_write_fw_block
.subsections_via_symbols
