	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_matrix_scan                    ## -- Begin function matrix_scan
	.p2align	4, 0x90
_matrix_scan:                           ## @matrix_scan
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	xorl	%eax, %eax
	callq	_serial_recv
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_3
## %bb.1:
	movq	_last_activity@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_timer_elapsed
	movq	_SLEEP_TIMEOUT@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jle	LBB0_3
## %bb.2:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_palm_reset
	jmp	LBB0_16
LBB0_3:
	xorl	%eax, %eax
	callq	_timer_read
	movq	_last_activity@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	movq	_disconnect_counter@GOTPCREL(%rip), %rax
	movq	$0, (%rax)
	movl	%ebx, %edi
	callq	_debug_hex
	leaq	L_.str(%rip), %rdi
	callq	_debug
	cmpl	$250, %ebx
	je	LBB0_7
## %bb.4:
	cmpl	$253, %ebx
	jne	LBB0_8
## %bb.5:
	leaq	L_.str.1(%rip), %rdi
	jmp	LBB0_6
LBB0_7:
	leaq	L_.str.2(%rip), %rdi
LBB0_6:
	callq	_print
	xorl	%ebx, %ebx
	jmp	LBB0_16
LBB0_8:
	movl	%ebx, %edi
	callq	_KEYUP
	testq	%rax, %rax
	je	LBB0_13
## %bb.9:
	movq	_last_upKey@GOTPCREL(%rip), %r15
	cmpl	(%r15), %ebx
	jne	LBB0_11
## %bb.10:
	movl	$0, (%r15)
	xorl	%ebx, %ebx
	jmp	LBB0_16
LBB0_13:
	movl	%ebx, %edi
	callq	_ROW
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	_COL
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_matrix_is_on
	testq	%rax, %rax
	jne	LBB0_15
## %bb.14:
	movl	%ebx, %edi
	callq	_COL
	movl	$1, %r14d
	movl	%eax, %ecx
	shll	%cl, %r14d
	movq	_matrix@GOTPCREL(%rip), %rax
	movq	(%rax), %r15
	movl	%ebx, %edi
	callq	_ROW
	orl	%r14d, (%r15,%rax,4)
	jmp	LBB0_15
LBB0_11:
	movl	%ebx, %edi
	callq	_ROW
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	_COL
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_matrix_is_on
	testq	%rax, %rax
	je	LBB0_15
## %bb.12:
	movl	%ebx, %edi
	callq	_COL
	movl	$-2, %r14d
	movl	%eax, %ecx
	roll	%cl, %r14d
	movq	_matrix@GOTPCREL(%rip), %rax
	movq	(%rax), %r12
	movl	%ebx, %edi
	callq	_ROW
	andl	%r14d, (%r12,%rax,4)
	movl	%ebx, (%r15)
LBB0_15:
	xorl	%eax, %eax
	callq	_matrix_scan_quantum
LBB0_16:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_last_activity,4,2              ## @last_activity
	.comm	_SLEEP_TIMEOUT,8,3              ## @SLEEP_TIMEOUT
	.comm	_disconnect_counter,8,3         ## @disconnect_counter
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	" "

L_.str.1:                               ## @.str.1
	.asciz	"rstD "

L_.str.2:                               ## @.str.2
	.asciz	"rstA "

	.comm	_last_upKey,4,2                 ## @last_upKey
	.comm	_matrix,8,3                     ## @matrix
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_matrix_scan                    ; -- Begin function matrix_scan
	.p2align	2
_matrix_scan:                           ; @matrix_scan
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	bl	_serial_recv
	mov	x19, x0
Lloh0:
	adrp	x20, _last_activity@GOTPAGE
Lloh1:
	ldr	x20, [x20, _last_activity@GOTPAGEOFF]
	cbnz	w0, LBB0_3
; %bb.1:
	ldr	w0, [x20]
	bl	_timer_elapsed
Lloh2:
	adrp	x8, _SLEEP_TIMEOUT@GOTPAGE
Lloh3:
	ldr	x8, [x8, _SLEEP_TIMEOUT@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	cmp	x0, x8
	b.le	LBB0_3
; %bb.2:
	bl	_palm_reset
	mov	w19, #0
	b	LBB0_16
LBB0_3:
	bl	_timer_read
	str	w0, [x20]
Lloh5:
	adrp	x8, _disconnect_counter@GOTPAGE
Lloh6:
	ldr	x8, [x8, _disconnect_counter@GOTPAGEOFF]
Lloh7:
	str	xzr, [x8]
	mov	x0, x19
	bl	_debug_hex
Lloh8:
	adrp	x0, l_.str@PAGE
Lloh9:
	add	x0, x0, l_.str@PAGEOFF
	bl	_debug
	cmp	w19, #250
	b.eq	LBB0_6
; %bb.4:
	cmp	w19, #253
	b.ne	LBB0_8
; %bb.5:
Lloh10:
	adrp	x0, l_.str.1@PAGE
Lloh11:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_7
LBB0_6:
Lloh12:
	adrp	x0, l_.str.2@PAGE
Lloh13:
	add	x0, x0, l_.str.2@PAGEOFF
LBB0_7:
	bl	_print
	mov	w19, #0
	b	LBB0_16
LBB0_8:
	mov	x0, x19
	bl	_KEYUP
	cbz	x0, LBB0_11
; %bb.9:
Lloh14:
	adrp	x21, _last_upKey@GOTPAGE
Lloh15:
	ldr	x21, [x21, _last_upKey@GOTPAGEOFF]
	ldr	w8, [x21]
	cmp	w19, w8
	b.ne	LBB0_13
; %bb.10:
	mov	w19, #0
	str	wzr, [x21]
	b	LBB0_16
LBB0_11:
	mov	x0, x19
	bl	_ROW
	mov	x20, x0
	mov	x0, x19
	bl	_COL
	mov	x1, x0
	mov	x0, x20
	bl	_matrix_is_on
	cbnz	x0, LBB0_15
; %bb.12:
	mov	x0, x19
	bl	_COL
	mov	w8, #1
	lsl	w20, w8, w0
Lloh16:
	adrp	x8, _matrix@GOTPAGE
Lloh17:
	ldr	x8, [x8, _matrix@GOTPAGEOFF]
Lloh18:
	ldr	x21, [x8]
	mov	x0, x19
	bl	_ROW
	lsl	x8, x0, #2
	ldr	w9, [x21, x8]
	orr	w9, w9, w20
	str	w9, [x21, x8]
	b	LBB0_15
LBB0_13:
	mov	x0, x19
	bl	_ROW
	mov	x20, x0
	mov	x0, x19
	bl	_COL
	mov	x1, x0
	mov	x0, x20
	bl	_matrix_is_on
	cbz	x0, LBB0_15
; %bb.14:
	mov	x0, x19
	bl	_COL
	mov	w8, #1
	lsl	w20, w8, w0
Lloh19:
	adrp	x8, _matrix@GOTPAGE
Lloh20:
	ldr	x8, [x8, _matrix@GOTPAGEOFF]
Lloh21:
	ldr	x22, [x8]
	mov	x0, x19
	bl	_ROW
	lsl	x8, x0, #2
	ldr	w9, [x22, x8]
	bic	w9, w9, w20
	str	w9, [x22, x8]
	str	w19, [x21]
LBB0_15:
	bl	_matrix_scan_quantum
LBB0_16:
	mov	x0, x19
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotStr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_last_activity,4,2              ; @last_activity
	.comm	_SLEEP_TIMEOUT,8,3              ; @SLEEP_TIMEOUT
	.comm	_disconnect_counter,8,3         ; @disconnect_counter
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	" "

l_.str.1:                               ; @.str.1
	.asciz	"rstD "

l_.str.2:                               ; @.str.2
	.asciz	"rstA "

	.comm	_last_upKey,4,2                 ; @last_upKey
	.comm	_matrix,8,3                     ; @matrix
.subsections_via_symbols
