	.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)
	movq	_MATRIX_COLS@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	jle	LBB0_13
## %bb.1:
	movq	_TIMER_RAW@GOTPCREL(%rip), %r14
	xorl	%ebx, %ebx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_12:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
	incq	%rbx
	movq	_MATRIX_COLS@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rbx
	jge	LBB0_13
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_5 Depth 2
	movq	%rbx, %rdi
	callq	_SET_COL
	movq	_MATRIX_ROWS@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	jle	LBB0_3
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	$1, %r12d
	movl	%ebx, %ecx
	shll	%cl, %r12d
	movl	$-2, %r13d
	roll	%cl, %r13d
	xorl	%ebx, %ebx
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_5 Depth=2
	movl	$5, %edi
	callq	__delay_us
	xorl	%eax, %eax
	callq	_KEY_HYS_OFF
	xorl	%eax, %eax
	callq	_KEY_UNABLE
	movl	$75, %edi
	callq	__delay_us
	incq	%rbx
	movq	_MATRIX_ROWS@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rbx
	jge	LBB0_10
LBB0_5:                                 ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%rbx, %rdi
	callq	_SET_ROW
	movl	$2, %edi
	callq	__delay_us
	movq	_matrix_prev@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	testl	%r12d, (%rax,%rbx,4)
	je	LBB0_7
## %bb.6:                               ##   in Loop: Header=BB0_5 Depth=2
	xorl	%eax, %eax
	callq	_KEY_HYS_ON
LBB0_7:                                 ##   in Loop: Header=BB0_5 Depth=2
	movl	$10, %edi
	callq	__delay_us
	movq	(%r14), %r15
	xorl	%eax, %eax
	callq	_KEY_ENABLE
	movl	$2, %edi
	callq	__delay_us
	xorl	%eax, %eax
	callq	_KEY_STATE
	movq	_matrix@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rcx,%rbx,4), %edx
	movl	%edx, %esi
	orl	%r12d, %esi
	andl	%r13d, %edx
	testq	%rax, %rax
	cmovel	%esi, %edx
	movl	%edx, (%rcx,%rbx,4)
	movq	(%r14), %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_9
## %bb.8:                               ##   in Loop: Header=BB0_5 Depth=2
	movq	_matrix_prev@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%rbx,4), %eax
	movq	_matrix@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	%eax, (%rcx,%rbx,4)
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_3:                                 ##   in Loop: Header=BB0_2 Depth=1
	xorl	%ebx, %ebx
LBB0_10:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	_matrix@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%rbx,4), %eax
	movq	_matrix_prev@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpl	(%rcx,%rbx,4), %eax
	je	LBB0_12
## %bb.11:                              ##   in Loop: Header=BB0_2 Depth=1
	xorl	%eax, %eax
	callq	_timer_read32
	movq	_matrix_last_modified@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	jmp	LBB0_12
LBB0_13:
	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_COLS,8,3                ## @MATRIX_COLS
	.comm	_MATRIX_ROWS,8,3                ## @MATRIX_ROWS
	.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
.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:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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]
Lloh4:
	adrp	x8, _MATRIX_COLS@GOTPAGE
Lloh5:
	ldr	x8, [x8, _MATRIX_COLS@GOTPAGEOFF]
Lloh6:
	ldr	x8, [x8]
	cmp	x8, #1
	b.lt	LBB0_12
; %bb.1:
	mov	x19, #0
Lloh7:
	adrp	x25, _MATRIX_ROWS@GOTPAGE
Lloh8:
	ldr	x25, [x25, _MATRIX_ROWS@GOTPAGEOFF]
Lloh9:
	adrp	x27, _TIMER_RAW@GOTPAGE
Lloh10:
	ldr	x27, [x27, _TIMER_RAW@GOTPAGEOFF]
	mov	w24, #20
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	x19, [sp, #8]                   ; 8-byte Folded Reload
	add	x19, x19, #1
Lloh11:
	adrp	x8, _MATRIX_COLS@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MATRIX_COLS@GOTPAGEOFF]
Lloh13:
	ldr	x8, [x8]
	cmp	x19, x8
	b.ge	LBB0_12
LBB0_3:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_6 Depth 2
	mov	x0, x19
	bl	_SET_COL
	ldr	x8, [x25]
	cmp	x8, #1
	str	x19, [sp, #8]                   ; 8-byte Folded Spill
	mov	x20, #0
	b.lt	LBB0_10
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	w8, #1
	lsl	w19, w8, w19
	mvn	w28, w19
	b	LBB0_6
LBB0_5:                                 ;   in Loop: Header=BB0_6 Depth=2
	mov	w0, #5
	bl	__delay_us
	bl	_KEY_HYS_OFF
	bl	_KEY_UNABLE
	mov	w0, #75
	bl	__delay_us
	add	x20, x20, #1
	ldr	x8, [x25]
	cmp	x20, x8
	b.ge	LBB0_10
LBB0_6:                                 ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x20
	bl	_SET_ROW
	mov	w0, #2
	bl	__delay_us
	ldr	x8, [x22]
	ldr	w8, [x8, x20, lsl #2]
	tst	w8, w19
	b.eq	LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=2
	bl	_KEY_HYS_ON
LBB0_8:                                 ;   in Loop: Header=BB0_6 Depth=2
	mov	w0, #10
	bl	__delay_us
	ldr	x21, [x27]
	bl	_KEY_ENABLE
	mov	w0, #2
	bl	__delay_us
	bl	_KEY_STATE
	ldr	x8, [x23]
	lsl	x26, x20, #2
	ldr	w9, [x8, x26]
	orr	w10, w9, w19
	and	w9, w9, w28
	cmp	x0, #0
	csel	w9, w10, w9, eq
	str	w9, [x8, x26]
	ldr	x0, [x27]
	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, w24, w8
	cmp	w0, w8
	b.le	LBB0_5
; %bb.9:                                ;   in Loop: Header=BB0_6 Depth=2
	ldr	x8, [x22]
	ldr	w8, [x8, x26]
	ldr	x9, [x23]
	str	w8, [x9, x26]
	b	LBB0_5
LBB0_10:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x8, [x23]
	lsl	x9, x20, #2
	ldr	w8, [x8, x9]
	ldr	x10, [x22]
	ldr	w9, [x10, x9]
	cmp	w8, w9
	b.eq	LBB0_2
; %bb.11:                               ;   in Loop: Header=BB0_3 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_2
LBB0_12:
	bl	_matrix_scan_quantum
	mov	w0, #1
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotStr	Lloh17, Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_matrix_prev,8,3                ; @matrix_prev
	.comm	_matrix,8,3                     ; @matrix
	.comm	_MATRIX_COLS,8,3                ; @MATRIX_COLS
	.comm	_MATRIX_ROWS,8,3                ; @MATRIX_ROWS
	.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
.subsections_via_symbols
