	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function elan_i2c_prepare_fw_update
_elan_i2c_prepare_fw_update:            ## @elan_i2c_prepare_fw_update
	.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	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
	leaq	-48(%rbp), %rsi
	callq	_elan_i2c_iap_get_mode
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.1:
	movl	-48(%rbp), %eax
	movq	_IAP_MODE@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_4
## %bb.2:
	movq	%r14, %rdi
	callq	_elan_i2c_iap_reset
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.3:
	movl	$30, %edi
	callq	_msleep
LBB0_4:
	movq	%r14, %rdi
	callq	_elan_i2c_set_flash_key
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.5:
	movl	-48(%rbp), %eax
	movq	_MAIN_MODE@GOTPCREL(%rip), %r15
	cmpl	(%r15), %eax
	movl	$100, %eax
	movl	$30, %edi
	cmovel	%eax, %edi
	callq	_msleep
	leaq	-48(%rbp), %rsi
	movq	%r14, %rdi
	callq	_elan_i2c_iap_get_mode
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.6:
	movl	-48(%rbp), %edx
	cmpl	(%r15), %edx
	jne	LBB0_8
## %bb.7:
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
LBB0_13:
	callq	_dev_err
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_14
LBB0_8:
	movq	%r14, %rdi
	callq	_elan_i2c_set_flash_key
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
## %bb.9:
	movl	$30, %edi
	callq	_msleep
	movq	_ETP_I2C_IAP_CMD@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-44(%rbp), %rdx
	movq	%r14, %rdi
	callq	_elan_i2c_read_cmd
	testl	%eax, %eax
	je	LBB0_11
## %bb.10:
	movl	%eax, %ebx
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdi
	movl	%eax, %edx
	callq	_dev_err
	jmp	LBB0_14
LBB0_11:
	leaq	-44(%rbp), %rdi
	callq	_le16_to_cpup
	movq	_ETP_I2C_IAP_PASSWORD@GOTPCREL(%rip), %rcx
	xorl	%ebx, %ebx
	cmpl	(%rcx), %eax
	jne	LBB0_12
LBB0_14:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-32(%rbp), %rax
	jne	LBB0_16
## %bb.15:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	leaq	L_.str.2(%rip), %rsi
	movq	%r14, %rdi
	movl	%eax, %edx
	jmp	LBB0_13
LBB0_16:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_IAP_MODE,4,2                   ## @IAP_MODE
	.comm	_MAIN_MODE,4,2                  ## @MAIN_MODE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"wrong mode: %d\n"

	.comm	_EIO,4,2                        ## @EIO
	.comm	_ETP_I2C_IAP_CMD,4,2            ## @ETP_I2C_IAP_CMD
L_.str.1:                               ## @.str.1
	.asciz	"cannot read iap password: %d\n"

	.comm	_ETP_I2C_IAP_PASSWORD,4,2       ## @ETP_I2C_IAP_PASSWORD
L_.str.2:                               ## @.str.2
	.asciz	"wrong iap password: 0x%X\n"

	.no_dead_strip	_elan_i2c_prepare_fw_update
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function elan_i2c_prepare_fw_update
_elan_i2c_prepare_fw_update:            ; @elan_i2c_prepare_fw_update
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	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
	mov	x19, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [sp, #24]
	add	x1, sp, #8
	bl	_elan_i2c_iap_get_mode
	mov	x20, x0
	cbnz	w0, LBB0_14
; %bb.1:
	ldr	w8, [sp, #8]
Lloh3:
	adrp	x9, _IAP_MODE@GOTPAGE
Lloh4:
	ldr	x9, [x9, _IAP_MODE@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_4
; %bb.2:
	mov	x0, x19
	bl	_elan_i2c_iap_reset
	mov	x20, x0
	cbnz	w0, LBB0_14
; %bb.3:
	mov	w0, #30
	bl	_msleep
LBB0_4:
	mov	x0, x19
	bl	_elan_i2c_set_flash_key
	mov	x20, x0
	cbnz	w0, LBB0_14
; %bb.5:
Lloh6:
	adrp	x21, _MAIN_MODE@GOTPAGE
Lloh7:
	ldr	x21, [x21, _MAIN_MODE@GOTPAGEOFF]
	ldr	w8, [sp, #8]
	ldr	w9, [x21]
	mov	w10, #30
	mov	w11, #100
	cmp	w8, w9
	csel	w0, w11, w10, eq
	bl	_msleep
	add	x1, sp, #8
	mov	x0, x19
	bl	_elan_i2c_iap_get_mode
	mov	x20, x0
	cbnz	w0, LBB0_14
; %bb.6:
	ldr	w2, [sp, #8]
	ldr	w8, [x21]
	cmp	w2, w8
	b.ne	LBB0_9
; %bb.7:
Lloh8:
	adrp	x1, l_.str@PAGE
Lloh9:
	add	x1, x1, l_.str@PAGEOFF
LBB0_8:
	mov	x0, x19
	bl	_dev_err
Lloh10:
	adrp	x8, _EIO@GOTPAGE
Lloh11:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_14
LBB0_9:
	mov	x0, x19
	bl	_elan_i2c_set_flash_key
	mov	x20, x0
	cbnz	w0, LBB0_14
; %bb.10:
	mov	w0, #30
	bl	_msleep
Lloh13:
	adrp	x8, _ETP_I2C_IAP_CMD@GOTPAGE
Lloh14:
	ldr	x8, [x8, _ETP_I2C_IAP_CMD@GOTPAGEOFF]
Lloh15:
	ldr	w1, [x8]
	add	x2, sp, #12
	mov	x0, x19
	bl	_elan_i2c_read_cmd
	cbz	w0, LBB0_12
; %bb.11:
	mov	x20, x0
Lloh16:
	adrp	x1, l_.str.1@PAGE
Lloh17:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	mov	x2, x20
	bl	_dev_err
	b	LBB0_14
LBB0_12:
	add	x0, sp, #12
	bl	_le16_to_cpup
Lloh18:
	adrp	x8, _ETP_I2C_IAP_PASSWORD@GOTPAGE
Lloh19:
	ldr	x8, [x8, _ETP_I2C_IAP_PASSWORD@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	cmp	w0, w8
	b.ne	LBB0_16
; %bb.13:
	mov	w20, #0
LBB0_14:
	ldr	x8, [sp, #24]
Lloh21:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh22:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh23:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_17
; %bb.15:
	mov	x0, x20
	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
	add	sp, sp, #80
	ret
LBB0_16:
	mov	x2, x0
Lloh24:
	adrp	x1, l_.str.2@PAGE
Lloh25:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_8
LBB0_17:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_IAP_MODE,4,2                   ; @IAP_MODE
	.comm	_MAIN_MODE,4,2                  ; @MAIN_MODE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"wrong mode: %d\n"

	.comm	_EIO,4,2                        ; @EIO
	.comm	_ETP_I2C_IAP_CMD,4,2            ; @ETP_I2C_IAP_CMD
l_.str.1:                               ; @.str.1
	.asciz	"cannot read iap password: %d\n"

	.comm	_ETP_I2C_IAP_PASSWORD,4,2       ; @ETP_I2C_IAP_PASSWORD
l_.str.2:                               ; @.str.2
	.asciz	"wrong iap password: 0x%X\n"

	.no_dead_strip	_elan_i2c_prepare_fw_update
.subsections_via_symbols
