	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function elants_i2c_fw_update
_elants_i2c_fw_update:                  ## @elants_i2c_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	%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	%rdi, %r15
	movq	16(%rdi), %r14
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	12(%r15), %edx
	leaq	L_.str(%rip), %rsi
	callq	_kasprintf
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %rbx
	leaq	4(%r14), %r12
	leaq	L_.str.1(%rip), %rsi
	movq	%r12, %rdi
	movq	%rax, %rdx
	callq	_dev_info
	leaq	-48(%rbp), %rdi
	movq	%rbx, %rsi
	movq	%r12, %rdx
	callq	_request_firmware
	movl	%eax, %r13d
	movq	%rbx, %rdi
	callq	_kfree
	testl	%r13d, %r13d
	je	LBB0_4
## %bb.3:
	leaq	L_.str.2(%rip), %rsi
	movq	%r12, %rdi
	movl	%r13d, %edx
	callq	_dev_err
	jmp	LBB0_15
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	jmp	LBB0_15
LBB0_4:
	movq	-48(%rbp), %rax
	movl	(%rax), %ecx
	movq	_ELAN_FW_PAGESIZE@GOTPCREL(%rip), %rsi
	movl	%ecx, %eax
	cltd
	idivl	(%rsi)
	testl	%edx, %edx
	je	LBB0_6
## %bb.5:
	leaq	L_.str.3(%rip), %rsi
	movq	%r12, %rdi
	movl	%ecx, %edx
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	jmp	LBB0_14
LBB0_6:
	movl	(%r14), %edi
	callq	_disable_irq
	movq	-48(%rbp), %rsi
	movq	(%r15), %rax
	movq	_ELAN_IAP_RECOVERY@GOTPCREL(%rip), %rbx
	xorl	%edx, %edx
	cmpq	(%rbx), %rax
	sete	%dl
	movq	%r14, %rdi
	callq	_elants_i2c_do_update_firmware
	testl	%eax, %eax
	je	LBB0_8
## %bb.7:
	movl	%eax, %r13d
	leaq	L_.str.4(%rip), %rsi
	jmp	LBB0_11
LBB0_8:
	movq	%r15, %rdi
	callq	_elants_i2c_initialize
	testl	%eax, %eax
	je	LBB0_9
## %bb.10:
	movl	%eax, %r13d
	leaq	L_.str.5(%rip), %rsi
LBB0_11:
	movq	%r12, %rdi
	movl	%r13d, %edx
	callq	_dev_err
LBB0_12:
	movq	(%rbx), %rax
	movq	%rax, (%r15)
	movq	_ELAN_STATE_NORMAL@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 8(%r15)
	movl	(%r14), %edi
	callq	_enable_irq
	movl	$100, %edi
	callq	_msleep
	testl	%r13d, %r13d
	jne	LBB0_14
## %bb.13:
	movq	%r15, %rdi
	callq	_elants_i2c_calibrate
	xorl	%r13d, %r13d
LBB0_14:
	movq	-48(%rbp), %rdi
	callq	_release_firmware
LBB0_15:
	movl	%r13d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	xorl	%r13d, %r13d
	movq	_ELAN_IAP_OPERATIONAL@GOTPCREL(%rip), %rbx
	jmp	LBB0_12
	.cfi_endproc
                                        ## -- End function
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"elants_i2c_%04x.bin"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
L_.str.1:                               ## @.str.1
	.asciz	"requesting fw name = %s\n"

L_.str.2:                               ## @.str.2
	.asciz	"failed to request firmware: %d\n"

	.comm	_ELAN_FW_PAGESIZE,4,2           ## @ELAN_FW_PAGESIZE
L_.str.3:                               ## @.str.3
	.asciz	"invalid firmware length: %zu\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ELAN_IAP_RECOVERY,8,3          ## @ELAN_IAP_RECOVERY
L_.str.4:                               ## @.str.4
	.asciz	"firmware update failed: %d\n"

L_.str.5:                               ## @.str.5
	.asciz	"failed to initialize device after firmware update: %d\n"

	.comm	_ELAN_IAP_OPERATIONAL,8,3       ## @ELAN_IAP_OPERATIONAL
	.comm	_ELAN_STATE_NORMAL,4,2          ## @ELAN_STATE_NORMAL
	.no_dead_strip	_elants_i2c_fw_update
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function elants_i2c_fw_update
_elants_i2c_fw_update:                  ; @elants_i2c_fw_update
	.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
	mov	x19, x0
	ldr	x20, [x0, #16]
Lloh0:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	ldr	w2, [x19, #12]
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	bl	_kasprintf
	cbz	x0, LBB0_3
; %bb.1:
	mov	x23, x0
	add	x22, x20, #4
Lloh5:
	adrp	x1, l_.str.1@PAGE
Lloh6:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x22
	mov	x2, x23
	bl	_dev_info
	add	x0, sp, #8
	mov	x1, x23
	mov	x2, x22
	bl	_request_firmware
	mov	x21, x0
	mov	x0, x23
	bl	_kfree
	cbz	w21, LBB0_4
; %bb.2:
Lloh7:
	adrp	x1, l_.str.2@PAGE
Lloh8:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x22
	mov	x2, x21
	bl	_dev_err
	b	LBB0_14
LBB0_3:
Lloh9:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_14
LBB0_4:
	ldr	x8, [sp, #8]
	ldr	w2, [x8]
Lloh12:
	adrp	x8, _ELAN_FW_PAGESIZE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _ELAN_FW_PAGESIZE@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	sdiv	w9, w2, w8
	msub	w8, w9, w8, w2
	cbz	w8, LBB0_6
; %bb.5:
Lloh15:
	adrp	x1, l_.str.3@PAGE
Lloh16:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x22
	bl	_dev_err
Lloh17:
	adrp	x8, _EINVAL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_13
LBB0_6:
	ldr	w0, [x20]
	bl	_disable_irq
	ldr	x1, [sp, #8]
	ldr	x8, [x19]
Lloh20:
	adrp	x9, _ELAN_IAP_RECOVERY@GOTPAGE
Lloh21:
	ldr	x9, [x9, _ELAN_IAP_RECOVERY@GOTPAGEOFF]
Lloh22:
	ldr	x9, [x9]
	cmp	x8, x9
	cset	w2, eq
	mov	x0, x20
	bl	_elants_i2c_do_update_firmware
	cbz	w0, LBB0_8
; %bb.7:
	mov	x21, x0
Lloh23:
	adrp	x1, l_.str.4@PAGE
Lloh24:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_10
LBB0_8:
	mov	x0, x19
	bl	_elants_i2c_initialize
	mov	x21, x0
	cbz	w0, LBB0_15
; %bb.9:
Lloh25:
	adrp	x1, l_.str.5@PAGE
Lloh26:
	add	x1, x1, l_.str.5@PAGEOFF
LBB0_10:
	mov	x0, x22
	mov	x2, x21
	bl	_dev_err
Lloh27:
	adrp	x8, _ELAN_IAP_RECOVERY@GOTPAGE
Lloh28:
	ldr	x8, [x8, _ELAN_IAP_RECOVERY@GOTPAGEOFF]
LBB0_11:
	ldr	x8, [x8]
	str	x8, [x19]
Lloh29:
	adrp	x8, _ELAN_STATE_NORMAL@GOTPAGE
Lloh30:
	ldr	x8, [x8, _ELAN_STATE_NORMAL@GOTPAGEOFF]
Lloh31:
	ldr	w8, [x8]
	str	w8, [x19, #8]
	ldr	w0, [x20]
	bl	_enable_irq
	mov	w0, #100
	bl	_msleep
	cbnz	w21, LBB0_13
; %bb.12:
	mov	x0, x19
	bl	_elants_i2c_calibrate
LBB0_13:
	ldr	x0, [sp, #8]
	bl	_release_firmware
LBB0_14:
	mov	x0, x21
	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_15:
Lloh32:
	adrp	x8, _ELAN_IAP_OPERATIONAL@GOTPAGE
Lloh33:
	ldr	x8, [x8, _ELAN_IAP_OPERATIONAL@GOTPAGEOFF]
	b	LBB0_11
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh32, Lloh33
	.cfi_endproc
                                        ; -- End function
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"elants_i2c_%04x.bin"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
l_.str.1:                               ; @.str.1
	.asciz	"requesting fw name = %s\n"

l_.str.2:                               ; @.str.2
	.asciz	"failed to request firmware: %d\n"

	.comm	_ELAN_FW_PAGESIZE,4,2           ; @ELAN_FW_PAGESIZE
l_.str.3:                               ; @.str.3
	.asciz	"invalid firmware length: %zu\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ELAN_IAP_RECOVERY,8,3          ; @ELAN_IAP_RECOVERY
l_.str.4:                               ; @.str.4
	.asciz	"firmware update failed: %d\n"

l_.str.5:                               ; @.str.5
	.asciz	"failed to initialize device after firmware update: %d\n"

	.comm	_ELAN_IAP_OPERATIONAL,8,3       ; @ELAN_IAP_OPERATIONAL
	.comm	_ELAN_STATE_NORMAL,4,2          ; @ELAN_STATE_NORMAL
	.no_dead_strip	_elants_i2c_fw_update
.subsections_via_symbols
