	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_elantech_detect                ## -- Begin function elantech_detect
	.p2align	4, 0x90
_elantech_detect:                       ## @elantech_detect
	.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	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r14d
	movq	%rdi, %r15
	leaq	16(%rdi), %rbx
	movq	_PSMOUSE_CMD_RESET_DIS@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_ps2_command
	movq	_PSMOUSE_CMD_DISABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_ps2_command
	testq	%rax, %rax
	jne	LBB0_5
## %bb.1:
	movq	_PSMOUSE_CMD_SETSCALE11@GOTPCREL(%rip), %r12
	movl	(%r12), %edx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_ps2_command
	testq	%rax, %rax
	jne	LBB0_5
## %bb.2:
	movl	(%r12), %edx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_ps2_command
	testq	%rax, %rax
	jne	LBB0_5
## %bb.3:
	movl	(%r12), %edx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_ps2_command
	testq	%rax, %rax
	jne	LBB0_5
## %bb.4:
	movq	_PSMOUSE_CMD_GETINFO@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	-35(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_ps2_command
	testq	%rax, %rax
	je	LBB0_9
LBB0_5:
	leaq	L_.str(%rip), %rsi
LBB0_6:
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_psmouse_dbg
LBB0_7:
	movl	$-1, %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	movzbl	-35(%rbp), %edx
	movb	-34(%rbp), %al
	movzbl	-33(%rbp), %r8d
	cmpl	$60, %edx
	jne	LBB0_15
## %bb.10:
	cmpb	$3, %al
	jne	LBB0_15
## %bb.11:
	cmpb	$-56, %r8b
	je	LBB0_13
## %bb.12:
	testb	%r8b, %r8b
	jne	LBB0_15
LBB0_13:
	movq	_ETP_FW_VERSION_QUERY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-35(%rbp), %rdx
	movq	%r15, %rdi
	callq	_synaptics_send_cmd
	testq	%rax, %rax
	je	LBB0_16
## %bb.14:
	leaq	L_.str.2(%rip), %rsi
	jmp	LBB0_6
LBB0_15:
	movzbl	%al, %ecx
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_psmouse_dbg
	jmp	LBB0_7
LBB0_16:
	movzbl	-35(%rbp), %edx
	movzbl	-34(%rbp), %ecx
	movzbl	-33(%rbp), %r8d
	leaq	L_.str.3(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_psmouse_dbg
	leaq	-35(%rbp), %rdi
	callq	_elantech_is_signature_valid
	testl	%eax, %eax
	je	LBB0_19
## %bb.17:
	testl	%r14d, %r14d
	je	LBB0_8
## %bb.18:
	leaq	L_.str.5(%rip), %rax
	movq	%rax, (%r15)
	leaq	L_.str.6(%rip), %rax
	movq	%rax, 8(%r15)
	jmp	LBB0_8
LBB0_19:
	leaq	L_.str.4(%rip), %rsi
	jmp	LBB0_6
	.cfi_endproc
                                        ## -- End function
	.comm	_PSMOUSE_CMD_RESET_DIS,4,2      ## @PSMOUSE_CMD_RESET_DIS
	.comm	_PSMOUSE_CMD_DISABLE,4,2        ## @PSMOUSE_CMD_DISABLE
	.comm	_PSMOUSE_CMD_SETSCALE11,4,2     ## @PSMOUSE_CMD_SETSCALE11
	.comm	_PSMOUSE_CMD_GETINFO,4,2        ## @PSMOUSE_CMD_GETINFO
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"sending Elantech magic knock failed.\n"

L_.str.1:                               ## @.str.1
	.asciz	"unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n"

	.comm	_ETP_FW_VERSION_QUERY,4,2       ## @ETP_FW_VERSION_QUERY
L_.str.2:                               ## @.str.2
	.asciz	"failed to query firmware version.\n"

L_.str.3:                               ## @.str.3
	.asciz	"Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n"

L_.str.4:                               ## @.str.4
	.asciz	"Probably not a real Elantech touchpad. Aborting.\n"

L_.str.5:                               ## @.str.5
	.asciz	"Elantech"

L_.str.6:                               ## @.str.6
	.asciz	"Touchpad"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_elantech_detect                ; -- Begin function elantech_detect
	.p2align	2
_elantech_detect:                       ; @elantech_detect
	.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	x20, x1
	mov	x19, x0
	add	x21, x0, #16
Lloh0:
	adrp	x8, _PSMOUSE_CMD_RESET_DIS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _PSMOUSE_CMD_RESET_DIS@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
	mov	x0, x21
	mov	x1, #0
	bl	_ps2_command
Lloh3:
	adrp	x8, _PSMOUSE_CMD_DISABLE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _PSMOUSE_CMD_DISABLE@GOTPAGEOFF]
Lloh5:
	ldr	w2, [x8]
	mov	x0, x21
	mov	x1, #0
	bl	_ps2_command
	cbnz	x0, LBB0_5
; %bb.1:
Lloh6:
	adrp	x22, _PSMOUSE_CMD_SETSCALE11@GOTPAGE
Lloh7:
	ldr	x22, [x22, _PSMOUSE_CMD_SETSCALE11@GOTPAGEOFF]
	ldr	w2, [x22]
	mov	x0, x21
	mov	x1, #0
	bl	_ps2_command
	cbnz	x0, LBB0_5
; %bb.2:
	ldr	w2, [x22]
	mov	x0, x21
	mov	x1, #0
	bl	_ps2_command
	cbnz	x0, LBB0_5
; %bb.3:
	ldr	w2, [x22]
	mov	x0, x21
	mov	x1, #0
	bl	_ps2_command
	cbnz	x0, LBB0_5
; %bb.4:
Lloh8:
	adrp	x8, _PSMOUSE_CMD_GETINFO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _PSMOUSE_CMD_GETINFO@GOTPAGEOFF]
Lloh10:
	ldr	w2, [x8]
	add	x1, sp, #29
	mov	x0, x21
	bl	_ps2_command
	cbz	x0, LBB0_8
LBB0_5:
Lloh11:
	adrp	x1, l_.str@PAGE
Lloh12:
	add	x1, x1, l_.str@PAGEOFF
LBB0_6:
	mov	x0, x19
	bl	_psmouse_dbg
	mov	w0, #-1
LBB0_7:
	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_8:
	ldrb	w8, [sp, #29]
	ldrb	w9, [sp, #30]
	ldrb	w10, [sp, #31]
	cmp	w8, #60
	b.ne	LBB0_14
; %bb.9:
	cmp	w9, #3
	b.ne	LBB0_14
; %bb.10:
	cbz	w10, LBB0_12
; %bb.11:
	cmp	w10, #200
	b.ne	LBB0_14
LBB0_12:
Lloh13:
	adrp	x8, _ETP_FW_VERSION_QUERY@GOTPAGE
Lloh14:
	ldr	x8, [x8, _ETP_FW_VERSION_QUERY@GOTPAGEOFF]
Lloh15:
	ldr	w1, [x8]
	add	x2, sp, #29
	mov	x0, x19
	bl	_synaptics_send_cmd
	cbz	x0, LBB0_15
; %bb.13:
Lloh16:
	adrp	x1, l_.str.2@PAGE
Lloh17:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_6
LBB0_14:
	stp	x9, x10, [sp, #8]
	str	x8, [sp]
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_6
LBB0_15:
	ldrb	w8, [sp, #29]
	ldrb	w9, [sp, #30]
	ldrb	w10, [sp, #31]
	stp	x9, x10, [sp, #8]
	str	x8, [sp]
Lloh20:
	adrp	x1, l_.str.3@PAGE
Lloh21:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x19
	bl	_psmouse_dbg
	add	x0, sp, #29
	bl	_elantech_is_signature_valid
	cbz	w0, LBB0_18
; %bb.16:
	mov	w0, #0
	cbz	w20, LBB0_7
; %bb.17:
Lloh22:
	adrp	x8, l_.str.5@PAGE
Lloh23:
	add	x8, x8, l_.str.5@PAGEOFF
Lloh24:
	adrp	x9, l_.str.6@PAGE
Lloh25:
	add	x9, x9, l_.str.6@PAGEOFF
	stp	x8, x9, [x19]
	b	LBB0_7
LBB0_18:
Lloh26:
	adrp	x1, l_.str.4@PAGE
Lloh27:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_6
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpAdd	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.comm	_PSMOUSE_CMD_RESET_DIS,4,2      ; @PSMOUSE_CMD_RESET_DIS
	.comm	_PSMOUSE_CMD_DISABLE,4,2        ; @PSMOUSE_CMD_DISABLE
	.comm	_PSMOUSE_CMD_SETSCALE11,4,2     ; @PSMOUSE_CMD_SETSCALE11
	.comm	_PSMOUSE_CMD_GETINFO,4,2        ; @PSMOUSE_CMD_GETINFO
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"sending Elantech magic knock failed.\n"

l_.str.1:                               ; @.str.1
	.asciz	"unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n"

	.comm	_ETP_FW_VERSION_QUERY,4,2       ; @ETP_FW_VERSION_QUERY
l_.str.2:                               ; @.str.2
	.asciz	"failed to query firmware version.\n"

l_.str.3:                               ; @.str.3
	.asciz	"Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n"

l_.str.4:                               ; @.str.4
	.asciz	"Probably not a real Elantech touchpad. Aborting.\n"

l_.str.5:                               ; @.str.5
	.asciz	"Elantech"

l_.str.6:                               ; @.str.6
	.asciz	"Touchpad"

.subsections_via_symbols
