	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	xorl	%eax, %eax
	callq	_timer_read64
	movq	_mdebouncing@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jl	LBB0_20
## %bb.1:
	movq	_mlatest@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	movq	_MATRIX_ROWS@GOTPCREL(%rip), %r15
	movl	(%r15), %edx
	shll	$2, %edx
	xorl	%esi, %esi
	callq	_memset
	movq	_MATRIX_COLS@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jle	LBB0_2
## %bb.9:
	movq	_col_pins@GOTPCREL(%rip), %rax
	movq	(%rax), %r8
	movq	_PORT@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	(%rax), %r10
	movq	_col_ports@GOTPCREL(%rip), %rax
	movq	(%rax), %r9
	xorl	%r14d, %r14d
	movq	_PB@GOTPCREL(%rip), %r13
	jmp	LBB0_10
	.p2align	4, 0x90
LBB0_15:                                ##   in Loop: Header=BB0_10 Depth=1
	incq	%r14
	movq	_MATRIX_COLS@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	cmpq	%rax, %r14
	jge	LBB0_3
LBB0_10:                                ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_12 Depth 2
	movb	(%r8,%r14,4), %cl
	movl	$1, %eax
	shll	%cl, %eax
	movq	(%r9,%r14,8), %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movl	%eax, 8(%r10,%rcx,4)
	movl	$1, %edi
	callq	_wait_us
	movq	_PORT@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	(%rax), %r10
	movq	_PA@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	leaq	(%rax,%rax,2), %rcx
	movq	_row_masks@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movl	(%rdx,%rax,4), %esi
	andl	4(%r10,%rcx,4), %esi
	movl	%esi, -56(%rbp,%rax,4)
	movq	(%r13), %rax
	leaq	(%rax,%rax,2), %rcx
	movl	(%rdx,%rax,4), %edx
	andl	4(%r10,%rcx,4), %edx
	movl	%edx, -56(%rbp,%rax,4)
	movq	_col_pins@GOTPCREL(%rip), %rax
	movq	(%rax), %r8
	movb	(%r8,%r14,4), %cl
	movl	$1, %eax
	shll	%cl, %eax
	movq	_col_ports@GOTPCREL(%rip), %rcx
	movq	(%rcx), %r9
	movq	(%r9,%r14,8), %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movl	%eax, (%r10,%rcx,4)
	movl	(%r15), %edi
	testl	%edi, %edi
	jle	LBB0_15
## %bb.11:                              ##   in Loop: Header=BB0_10 Depth=1
	movl	$1, %edx
	movl	%r14d, %ecx
	shll	%cl, %edx
	movq	_row_ports@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	movq	_row_pins@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	movq	_mlatest@GOTPCREL(%rip), %rax
	movq	(%rax), %r11
	xorl	%ebx, %ebx
	jmp	LBB0_12
	.p2align	4, 0x90
LBB0_14:                                ##   in Loop: Header=BB0_12 Depth=2
	incq	%rbx
	movslq	%edi, %rax
	cmpq	%rax, %rbx
	jge	LBB0_15
LBB0_12:                                ##   Parent Loop BB0_10 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	(%rcx,%rbx,8), %rax
	movl	-56(%rbp,%rax,4), %eax
	movl	(%rsi,%rbx,4), %r12d
	btl	%r12d, %eax
	jae	LBB0_14
## %bb.13:                              ##   in Loop: Header=BB0_12 Depth=2
	orl	%edx, (%r11,%rbx,4)
	movl	(%r15), %edi
	jmp	LBB0_14
LBB0_2:
	movl	(%r15), %edi
LBB0_3:
	xorl	%eax, %eax
	testl	%edi, %edi
	jle	LBB0_19
## %bb.4:
	movq	_mlast@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	_mlatest@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movl	$1, %esi
	xorl	%edi, %edi
	.p2align	4, 0x90
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%rdx,%rdi,4), %ebx
	cmpl	%ebx, (%rcx,%rdi,4)
	cmovnel	%esi, %eax
	movl	%ebx, (%rcx,%rdi,4)
	incq	%rdi
	movslq	(%r15), %rbx
	cmpq	%rbx, %rdi
	jl	LBB0_5
## %bb.6:
	testl	%eax, %eax
	je	LBB0_7
## %bb.18:
	xorl	%eax, %eax
	callq	_timer_read64
	movq	_DEBOUNCE@GOTPCREL(%rip), %rcx
	addq	(%rcx), %rax
	jmp	LBB0_19
LBB0_7:
	testl	%ebx, %ebx
	jle	LBB0_8
## %bb.16:
	movq	_mlatest@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	movq	_mdebounced@GOTPCREL(%rip), %rax
	movq	(%rax), %rdx
	xorl	%eax, %eax
	xorl	%esi, %esi
	.p2align	4, 0x90
LBB0_17:                                ## =>This Inner Loop Header: Depth=1
	movl	(%rcx,%rsi,4), %edi
	movl	%edi, (%rdx,%rsi,4)
	incq	%rsi
	movslq	(%r15), %rdi
	cmpq	%rdi, %rsi
	jl	LBB0_17
	jmp	LBB0_19
LBB0_8:
	xorl	%eax, %eax
LBB0_19:
	movq	_mdebouncing@GOTPCREL(%rip), %rcx
	movq	%rax, (%rcx)
	xorl	%eax, %eax
	callq	_matrix_scan_quantum
LBB0_20:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_22
## %bb.21:
	movl	$1, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_22:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_mdebouncing,8,3                ## @mdebouncing
	.comm	_mlatest,8,3                    ## @mlatest
	.comm	_MATRIX_ROWS,4,2                ## @MATRIX_ROWS
	.comm	_MATRIX_COLS,4,2                ## @MATRIX_COLS
	.comm	_col_pins,8,3                   ## @col_pins
	.comm	_PORT,8,3                       ## @PORT
	.comm	_col_ports,8,3                  ## @col_ports
	.comm	_PA,8,3                         ## @PA
	.comm	_row_masks,8,3                  ## @row_masks
	.comm	_PB,8,3                         ## @PB
	.comm	_row_ports,8,3                  ## @row_ports
	.comm	_row_pins,8,3                   ## @row_pins
	.comm	_mlast,8,3                      ## @mlast
	.comm	_mdebounced,8,3                 ## @mdebounced
	.comm	_DEBOUNCE,8,3                   ## @DEBOUNCE
.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	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [sp, #8]
	bl	_timer_read64
Lloh3:
	adrp	x8, _mdebouncing@GOTPAGE
Lloh4:
	ldr	x8, [x8, _mdebouncing@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	cmp	x0, x8
	b.lt	LBB0_20
; %bb.1:
Lloh6:
	adrp	x8, _mlatest@GOTPAGE
Lloh7:
	ldr	x8, [x8, _mlatest@GOTPAGEOFF]
Lloh8:
	ldr	x0, [x8]
Lloh9:
	adrp	x20, _MATRIX_ROWS@GOTPAGE
Lloh10:
	ldr	x20, [x20, _MATRIX_ROWS@GOTPAGEOFF]
	ldr	w8, [x20]
	lsl	w2, w8, #2
	mov	w1, #0
	bl	_memset
Lloh11:
	adrp	x8, _MATRIX_COLS@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MATRIX_COLS@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	cmp	w8, #0
	b.le	LBB0_9
; %bb.2:
	mov	x23, #0
Lloh14:
	adrp	x8, _col_pins@GOTPAGE
Lloh15:
	ldr	x8, [x8, _col_pins@GOTPAGEOFF]
Lloh16:
	ldr	x9, [x8]
Lloh17:
	adrp	x8, _PORT@GOTPAGE
Lloh18:
	ldr	x8, [x8, _PORT@GOTPAGEOFF]
Lloh19:
	ldr	x8, [x8]
	ldr	x8, [x8]
Lloh20:
	adrp	x10, _col_ports@GOTPAGE
Lloh21:
	ldr	x10, [x10, _col_ports@GOTPAGEOFF]
Lloh22:
	ldr	x10, [x10]
	mov	w27, #1
	mov	w28, #12
Lloh23:
	adrp	x19, _PA@GOTPAGE
Lloh24:
	ldr	x19, [x19, _PA@GOTPAGEOFF]
Lloh25:
	adrp	x21, _row_masks@GOTPAGE
Lloh26:
	ldr	x21, [x21, _row_masks@GOTPAGEOFF]
	mov	x22, sp
Lloh27:
	adrp	x24, _PB@GOTPAGE
Lloh28:
	ldr	x24, [x24, _PB@GOTPAGEOFF]
	b	LBB0_4
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x23, x23, #1
Lloh29:
	adrp	x12, _MATRIX_COLS@GOTPAGE
Lloh30:
	ldr	x12, [x12, _MATRIX_COLS@GOTPAGEOFF]
Lloh31:
	ldrsw	x12, [x12]
	cmp	x23, x12
	b.ge	LBB0_10
LBB0_4:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_7 Depth 2
	lsl	x25, x23, #2
	ldr	w9, [x9, x25]
	lsl	w9, w27, w9
	lsl	x26, x23, #3
	ldr	x10, [x10, x26]
	madd	x8, x10, x28, x8
	str	w9, [x8, #8]
	mov	w0, #1
	bl	_wait_us
Lloh32:
	adrp	x8, _PORT@GOTPAGE
Lloh33:
	ldr	x8, [x8, _PORT@GOTPAGEOFF]
Lloh34:
	ldr	x8, [x8]
	ldr	x8, [x8]
	ldr	x9, [x19]
	madd	x10, x9, x28, x8
	ldr	w10, [x10, #4]
	ldr	x11, [x21]
	lsl	x9, x9, #2
	ldr	w12, [x11, x9]
	and	w10, w12, w10
	str	w10, [x22, x9]
	ldr	x9, [x24]
	madd	x10, x9, x28, x8
	ldr	w10, [x10, #4]
	lsl	x9, x9, #2
	ldr	w11, [x11, x9]
	and	w10, w11, w10
	str	w10, [x22, x9]
Lloh35:
	adrp	x9, _col_pins@GOTPAGE
Lloh36:
	ldr	x9, [x9, _col_pins@GOTPAGEOFF]
Lloh37:
	ldr	x9, [x9]
	ldr	w11, [x9, x25]
Lloh38:
	adrp	x10, _col_ports@GOTPAGE
Lloh39:
	ldr	x10, [x10, _col_ports@GOTPAGEOFF]
Lloh40:
	ldr	x10, [x10]
	ldr	x12, [x10, x26]
	lsl	w11, w27, w11
	mul	x12, x12, x28
	str	w11, [x8, x12]
	ldr	w11, [x20]
	cmp	w11, #1
	b.lt	LBB0_3
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x12, #0
Lloh41:
	adrp	x13, _row_ports@GOTPAGE
Lloh42:
	ldr	x13, [x13, _row_ports@GOTPAGEOFF]
Lloh43:
	ldr	x13, [x13]
Lloh44:
	adrp	x14, _row_pins@GOTPAGE
Lloh45:
	ldr	x14, [x14, _row_pins@GOTPAGEOFF]
Lloh46:
	ldr	x14, [x14]
	lsl	w15, w27, w23
Lloh47:
	adrp	x16, _mlatest@GOTPAGE
Lloh48:
	ldr	x16, [x16, _mlatest@GOTPAGEOFF]
Lloh49:
	ldr	x16, [x16]
	b	LBB0_7
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=2
	add	x12, x12, #1
	cmp	x12, w11, sxtw
	b.ge	LBB0_3
LBB0_7:                                 ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	x17, [x13, x12, lsl #3]
	ldr	w17, [x22, x17, lsl #2]
	ldr	w0, [x14, x12, lsl #2]
	lsr	w17, w17, w0
	tbz	w17, #0, LBB0_6
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=2
	lsl	x11, x12, #2
	ldr	w17, [x16, x11]
	orr	w17, w17, w15
	str	w17, [x16, x11]
	ldr	w11, [x20]
	b	LBB0_6
LBB0_9:
	ldr	w11, [x20]
LBB0_10:
	cmp	w11, #1
	b.lt	LBB0_18
; %bb.11:
	mov	x9, #0
	mov	w8, #0
Lloh50:
	adrp	x10, _mlast@GOTPAGE
Lloh51:
	ldr	x10, [x10, _mlast@GOTPAGEOFF]
Lloh52:
	ldr	x10, [x10]
Lloh53:
	adrp	x11, _mlatest@GOTPAGE
Lloh54:
	ldr	x11, [x11, _mlatest@GOTPAGEOFF]
Lloh55:
	ldr	x11, [x11]
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	lsl	x12, x9, #2
	ldr	w13, [x10, x12]
	ldr	w14, [x11, x12]
	cmp	w13, w14
	csinc	w8, w8, wzr, eq
	str	w14, [x10, x12]
	add	x9, x9, #1
	ldrsw	x12, [x20]
	cmp	x9, x12
	b.lt	LBB0_12
; %bb.13:
	cbz	w8, LBB0_15
; %bb.14:
	bl	_timer_read64
Lloh56:
	adrp	x8, _DEBOUNCE@GOTPAGE
Lloh57:
	ldr	x8, [x8, _DEBOUNCE@GOTPAGEOFF]
Lloh58:
	ldr	x8, [x8]
	add	x8, x8, x0
	b	LBB0_19
LBB0_15:
	cmp	w12, #1
	b.lt	LBB0_18
; %bb.16:
	mov	x8, #0
Lloh59:
	adrp	x9, _mlatest@GOTPAGE
Lloh60:
	ldr	x9, [x9, _mlatest@GOTPAGEOFF]
Lloh61:
	ldr	x9, [x9]
Lloh62:
	adrp	x10, _mdebounced@GOTPAGE
Lloh63:
	ldr	x10, [x10, _mdebounced@GOTPAGEOFF]
Lloh64:
	ldr	x10, [x10]
LBB0_17:                                ; =>This Inner Loop Header: Depth=1
	lsl	x11, x8, #2
	ldr	w12, [x9, x11]
	str	w12, [x10, x11]
	add	x8, x8, #1
	ldrsw	x11, [x20]
	cmp	x8, x11
	b.lt	LBB0_17
LBB0_18:
	mov	x8, #0
LBB0_19:
Lloh65:
	adrp	x9, _mdebouncing@GOTPAGE
Lloh66:
	ldr	x9, [x9, _mdebouncing@GOTPAGEOFF]
Lloh67:
	str	x8, [x9]
	bl	_matrix_scan_quantum
LBB0_20:
	ldr	x8, [sp, #8]
Lloh68:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh69:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh70:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_22
; %bb.21:
	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
LBB0_22:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh27, Lloh28
	.loh AdrpLdrGot	Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpLdrGotLdr	Lloh44, Lloh45, Lloh46
	.loh AdrpLdrGotLdr	Lloh41, Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh53, Lloh54, Lloh55
	.loh AdrpLdrGotLdr	Lloh50, Lloh51, Lloh52
	.loh AdrpLdrGotLdr	Lloh56, Lloh57, Lloh58
	.loh AdrpLdrGotLdr	Lloh62, Lloh63, Lloh64
	.loh AdrpLdrGotLdr	Lloh59, Lloh60, Lloh61
	.loh AdrpLdrGotStr	Lloh65, Lloh66, Lloh67
	.loh AdrpLdrGotLdr	Lloh68, Lloh69, Lloh70
	.cfi_endproc
                                        ; -- End function
	.comm	_mdebouncing,8,3                ; @mdebouncing
	.comm	_mlatest,8,3                    ; @mlatest
	.comm	_MATRIX_ROWS,4,2                ; @MATRIX_ROWS
	.comm	_MATRIX_COLS,4,2                ; @MATRIX_COLS
	.comm	_col_pins,8,3                   ; @col_pins
	.comm	_PORT,8,3                       ; @PORT
	.comm	_col_ports,8,3                  ; @col_ports
	.comm	_PA,8,3                         ; @PA
	.comm	_row_masks,8,3                  ; @row_masks
	.comm	_PB,8,3                         ; @PB
	.comm	_row_ports,8,3                  ; @row_ports
	.comm	_row_pins,8,3                   ; @row_pins
	.comm	_mlast,8,3                      ; @mlast
	.comm	_mdebounced,8,3                 ; @mdebounced
	.comm	_DEBOUNCE,8,3                   ; @DEBOUNCE
.subsections_via_symbols
