	.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	%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	_matrix_prev@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rax
	movq	_matrix@GOTPCREL(%rip), %rsi
	movq	(%rsi), %rcx
	movq	%rcx, (%rdx)
	movq	%rax, (%rsi)
	xorl	%eax, %eax
	callq	_KEY_POWER_STATE
	testq	%rax, %rax
	jne	LBB0_2
## %bb.1:
	xorl	%eax, %eax
	callq	_KEY_POWER_ON
LBB0_2:
	movq	_MATRIX_ROWS@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_17
## %bb.3:
	movq	_TIMER_RAW@GOTPCREL(%rip), %r12
	xorl	%r14d, %r14d
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_16:                                ##   in Loop: Header=BB0_4 Depth=1
	incq	%r14
	movq	_MATRIX_ROWS@GOTPCREL(%rip), %rax
	cmpq	(%rax), %r14
	jae	LBB0_17
LBB0_4:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_6 Depth 2
	movq	_MATRIX_COLS@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_14
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	xorl	%ebx, %ebx
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_13:                                ##   in Loop: Header=BB0_6 Depth=2
	movl	$5, %edi
	callq	__delay_us
	xorl	%eax, %eax
	callq	_KEY_PREV_OFF
	xorl	%eax, %eax
	callq	_KEY_UNABLE
	movl	$75, %edi
	callq	__delay_us
	incq	%rbx
	movq	_MATRIX_COLS@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rbx
	jae	LBB0_14
LBB0_6:                                 ##   Parent Loop BB0_4 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_KEY_SELECT
	movl	$5, %edi
	callq	__delay_us
	movq	_matrix_prev@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%r14,4), %eax
	movl	$1, %r13d
	movl	%ebx, %ecx
	shll	%cl, %r13d
	btl	%ebx, %eax
	jae	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=2
	xorl	%eax, %eax
	callq	_KEY_PREV_ON
LBB0_8:                                 ##   in Loop: Header=BB0_6 Depth=2
	movl	$10, %edi
	callq	__delay_us
	movq	(%r12), %r15
	xorl	%eax, %eax
	callq	_KEY_ENABLE
	movl	$5, %edi
	callq	__delay_us
	xorl	%eax, %eax
	callq	_KEY_STATE
	testq	%rax, %rax
	je	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_6 Depth=2
	notl	%r13d
	movq	_matrix@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	andl	%r13d, (%rax,%r14,4)
	jmp	LBB0_11
	.p2align	4, 0x90
LBB0_10:                                ##   in Loop: Header=BB0_6 Depth=2
	movq	_matrix@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	orl	%r13d, (%rax,%r14,4)
LBB0_11:                                ##   in Loop: Header=BB0_6 Depth=2
	movq	(%r12), %rdi
	movq	%r15, %rsi
	callq	_TIMER_DIFF_RAW
	movl	%eax, %ecx
	movl	$1000000, %eax                  ## imm = 0xF4240
	xorl	%edx, %edx
	movq	_TIMER_RAW_FREQ@GOTPCREL(%rip), %rsi
	idivl	(%rsi)
	movl	%eax, %esi
	movl	$20, %eax
	xorl	%edx, %edx
	idivl	%esi
	cmpl	%eax, %ecx
	jle	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_6 Depth=2
	movq	_matrix_prev@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%r14,4), %eax
	movq	_matrix@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	%eax, (%rcx,%r14,4)
	jmp	LBB0_13
	.p2align	4, 0x90
LBB0_14:                                ##   in Loop: Header=BB0_4 Depth=1
	movq	_matrix@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%r14,4), %eax
	movq	_matrix_prev@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpl	(%rcx,%r14,4), %eax
	je	LBB0_16
## %bb.15:                              ##   in Loop: Header=BB0_4 Depth=1
	xorl	%eax, %eax
	callq	_timer_read32
	movq	_matrix_last_modified@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	jmp	LBB0_16
LBB0_17:
	xorl	%eax, %eax
	callq	_KEY_POWER_STATE
	testq	%rax, %rax
	je	LBB0_22
## %bb.18:
	movq	_USB_DeviceState@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	_DEVICE_STATE_Suspended@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_20
## %bb.19:
	movq	_DEVICE_STATE_Unattached@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_22
LBB0_20:
	movq	_matrix_last_modified@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_timer_elapsed32
	movq	_MATRIX_POWER_SAVE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jle	LBB0_22
## %bb.21:
	xorl	%eax, %eax
	callq	_KEY_POWER_OFF
	xorl	%eax, %eax
	callq	_suspend_power_down
LBB0_22:
	xorl	%eax, %eax
	callq	_matrix_scan_quantum
	movl	$1, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_matrix_prev,8,3                ## @matrix_prev
	.comm	_matrix,8,3                     ## @matrix
	.comm	_MATRIX_ROWS,8,3                ## @MATRIX_ROWS
	.comm	_MATRIX_COLS,8,3                ## @MATRIX_COLS
	.comm	_TIMER_RAW,8,3                  ## @TIMER_RAW
	.comm	_TIMER_RAW_FREQ,4,2             ## @TIMER_RAW_FREQ
	.comm	_matrix_last_modified,4,2       ## @matrix_last_modified
	.comm	_USB_DeviceState,8,3            ## @USB_DeviceState
	.comm	_DEVICE_STATE_Suspended,8,3     ## @DEVICE_STATE_Suspended
	.comm	_DEVICE_STATE_Unattached,8,3    ## @DEVICE_STATE_Unattached
	.comm	_MATRIX_POWER_SAVE,8,3          ## @MATRIX_POWER_SAVE
.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	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
Lloh0:
	adrp	x22, _matrix_prev@GOTPAGE
Lloh1:
	ldr	x22, [x22, _matrix_prev@GOTPAGEOFF]
	ldr	x8, [x22]
Lloh2:
	adrp	x23, _matrix@GOTPAGE
Lloh3:
	ldr	x23, [x23, _matrix@GOTPAGEOFF]
	ldr	x9, [x23]
	str	x9, [x22]
	str	x8, [x23]
	bl	_KEY_POWER_STATE
	cbnz	x0, LBB0_2
; %bb.1:
	bl	_KEY_POWER_ON
LBB0_2:
Lloh4:
	adrp	x8, _MATRIX_ROWS@GOTPAGE
Lloh5:
	ldr	x8, [x8, _MATRIX_ROWS@GOTPAGEOFF]
Lloh6:
	ldr	x8, [x8]
	cbz	x8, LBB0_17
; %bb.3:
	mov	x19, #0
Lloh7:
	adrp	x25, _MATRIX_COLS@GOTPAGE
Lloh8:
	ldr	x25, [x25, _MATRIX_COLS@GOTPAGEOFF]
Lloh9:
	adrp	x28, _TIMER_RAW@GOTPAGE
Lloh10:
	ldr	x28, [x28, _TIMER_RAW@GOTPAGEOFF]
	mov	w27, #20
	b	LBB0_5
LBB0_4:                                 ;   in Loop: Header=BB0_5 Depth=1
	add	x19, x19, #1
Lloh11:
	adrp	x8, _MATRIX_ROWS@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MATRIX_ROWS@GOTPAGEOFF]
Lloh13:
	ldr	x8, [x8]
	cmp	x19, x8
	b.hs	LBB0_17
LBB0_5:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
	ldr	x8, [x25]
	lsl	x26, x19, #2
	cbz	x8, LBB0_15
; %bb.6:                                ;   in Loop: Header=BB0_5 Depth=1
	mov	x20, #0
	b	LBB0_8
LBB0_7:                                 ;   in Loop: Header=BB0_8 Depth=2
	mov	w0, #5
	bl	__delay_us
	bl	_KEY_PREV_OFF
	bl	_KEY_UNABLE
	mov	w0, #75
	bl	__delay_us
	add	x20, x20, #1
	ldr	x8, [x25]
	cmp	x20, x8
	b.hs	LBB0_15
LBB0_8:                                 ;   Parent Loop BB0_5 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x19
	mov	x1, x20
	bl	_KEY_SELECT
	mov	w0, #5
	bl	__delay_us
	ldr	x8, [x22]
	ldr	w8, [x8, x19, lsl #2]
	mov	w9, #1
	lsl	w24, w9, w20
	tst	w8, w24
	b.eq	LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=2
	bl	_KEY_PREV_ON
LBB0_10:                                ;   in Loop: Header=BB0_8 Depth=2
	mov	w0, #10
	bl	__delay_us
	ldr	x21, [x28]
	bl	_KEY_ENABLE
	mov	w0, #5
	bl	__delay_us
	bl	_KEY_STATE
	cbz	x0, LBB0_12
; %bb.11:                               ;   in Loop: Header=BB0_8 Depth=2
	ldr	x8, [x23]
	ldr	w9, [x8, x26]
	bic	w9, w9, w24
	b	LBB0_13
LBB0_12:                                ;   in Loop: Header=BB0_8 Depth=2
	ldr	x8, [x23]
	ldr	w9, [x8, x26]
	orr	w9, w9, w24
LBB0_13:                                ;   in Loop: Header=BB0_8 Depth=2
	str	w9, [x8, x26]
	ldr	x0, [x28]
	mov	x1, x21
	bl	_TIMER_DIFF_RAW
Lloh14:
	adrp	x8, _TIMER_RAW_FREQ@GOTPAGE
Lloh15:
	ldr	x8, [x8, _TIMER_RAW_FREQ@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	mov	w9, #16960
	movk	w9, #15, lsl #16
	sdiv	w8, w9, w8
	sdiv	w8, w27, w8
	cmp	w0, w8
	b.le	LBB0_7
; %bb.14:                               ;   in Loop: Header=BB0_8 Depth=2
	ldr	x8, [x22]
	ldr	w8, [x8, x26]
	ldr	x9, [x23]
	str	w8, [x9, x26]
	b	LBB0_7
LBB0_15:                                ;   in Loop: Header=BB0_5 Depth=1
	ldr	x8, [x23]
	ldr	w8, [x8, x26]
	ldr	x9, [x22]
	ldr	w9, [x9, x26]
	cmp	w8, w9
	b.eq	LBB0_4
; %bb.16:                               ;   in Loop: Header=BB0_5 Depth=1
	bl	_timer_read32
Lloh17:
	adrp	x8, _matrix_last_modified@GOTPAGE
Lloh18:
	ldr	x8, [x8, _matrix_last_modified@GOTPAGEOFF]
Lloh19:
	str	w0, [x8]
	b	LBB0_4
LBB0_17:
	bl	_KEY_POWER_STATE
	cbz	x0, LBB0_21
; %bb.18:
Lloh20:
	adrp	x8, _USB_DeviceState@GOTPAGE
Lloh21:
	ldr	x8, [x8, _USB_DeviceState@GOTPAGEOFF]
Lloh22:
	ldr	x8, [x8]
Lloh23:
	adrp	x9, _DEVICE_STATE_Suspended@GOTPAGE
Lloh24:
	ldr	x9, [x9, _DEVICE_STATE_Suspended@GOTPAGEOFF]
Lloh25:
	ldr	x9, [x9]
Lloh26:
	adrp	x10, _DEVICE_STATE_Unattached@GOTPAGE
Lloh27:
	ldr	x10, [x10, _DEVICE_STATE_Unattached@GOTPAGEOFF]
Lloh28:
	ldr	x10, [x10]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_21
; %bb.19:
Lloh29:
	adrp	x8, _matrix_last_modified@GOTPAGE
Lloh30:
	ldr	x8, [x8, _matrix_last_modified@GOTPAGEOFF]
Lloh31:
	ldr	w0, [x8]
	bl	_timer_elapsed32
Lloh32:
	adrp	x8, _MATRIX_POWER_SAVE@GOTPAGE
Lloh33:
	ldr	x8, [x8, _MATRIX_POWER_SAVE@GOTPAGEOFF]
Lloh34:
	ldr	x8, [x8]
	cmp	x0, x8
	b.le	LBB0_21
; %bb.20:
	bl	_KEY_POWER_OFF
	bl	_suspend_power_down
LBB0_21:
	bl	_matrix_scan_quantum
	mov	w0, #1
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotStr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.cfi_endproc
                                        ; -- End function
	.comm	_matrix_prev,8,3                ; @matrix_prev
	.comm	_matrix,8,3                     ; @matrix
	.comm	_MATRIX_ROWS,8,3                ; @MATRIX_ROWS
	.comm	_MATRIX_COLS,8,3                ; @MATRIX_COLS
	.comm	_TIMER_RAW,8,3                  ; @TIMER_RAW
	.comm	_TIMER_RAW_FREQ,4,2             ; @TIMER_RAW_FREQ
	.comm	_matrix_last_modified,4,2       ; @matrix_last_modified
	.comm	_USB_DeviceState,8,3            ; @USB_DeviceState
	.comm	_DEVICE_STATE_Suspended,8,3     ; @DEVICE_STATE_Suspended
	.comm	_DEVICE_STATE_Unattached,8,3    ; @DEVICE_STATE_Unattached
	.comm	_MATRIX_POWER_SAVE,8,3          ; @MATRIX_POWER_SAVE
.subsections_via_symbols
