	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_PERMacJoyHandleEvents          ## -- Begin function PERMacJoyHandleEvents
	.p2align	4, 0x90
_PERMacJoyHandleEvents:                 ## @PERMacJoyHandleEvents
	.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	_joycount@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jle	LBB0_31
## %bb.1:
	xorl	%ecx, %ecx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_30:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	incq	%rcx
	movq	_joycount@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	cmpq	%rax, %rcx
	jge	LBB0_31
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_5 Depth 2
                                        ##     Child Loop BB0_13 Depth 2
                                        ##     Child Loop BB0_21 Depth 2
                                        ##       Child Loop BB0_23 Depth 3
	movq	_joys@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rcx, -56(%rbp)                 ## 8-byte Spill
	movq	(%rax,%rcx,8), %r12
	testq	%r12, %r12
	je	LBB0_30
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	cmpl	$0, (%r12)
	movq	%r12, -48(%rbp)                 ## 8-byte Spill
	jle	LBB0_11
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	%eax, %r13d
	shll	$24, %r13d
	xorl	%r14d, %r14d
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_5 Depth=2
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movq	32(%rax), %rax
LBB0_8:                                 ##   in Loop: Header=BB0_5 Depth=2
	movl	(%rax,%r14,8), %esi
	testl	%esi, %esi
	js	LBB0_9
LBB0_16:                                ##   in Loop: Header=BB0_5 Depth=2
	movl	%r13d, %ebx
	orl	%r14d, %ebx
	movq	_AXIS_POSITIVE_VALUE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	orl	%ebx, %edi
	callq	_PerKeyUp
LBB0_17:                                ##   in Loop: Header=BB0_5 Depth=2
	movq	_AXIS_NEGATIVE_VALUE@GOTPCREL(%rip), %rax
	orl	(%rax), %ebx
	movl	%ebx, %edi
	callq	_PerKeyUp
LBB0_18:                                ##   in Loop: Header=BB0_5 Depth=2
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	incq	%r14
	movslq	(%r12), %rax
	cmpq	%rax, %r14
	jge	LBB0_11
LBB0_5:                                 ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	32(%r12), %rax
	movl	(%rax,%r14,8), %edi
	movl	4(%rax,%r14,8), %esi
	callq	_MIDDLE
	movl	%eax, %r15d
	movq	%r12, %rdi
	movl	%r14d, %esi
	callq	_joy_read_axis
	movl	%eax, %ebx
	movq	32(%r12), %rax
	movl	4(%rax,%r14,8), %esi
	testl	%esi, %esi
	jle	LBB0_8
## %bb.6:                               ##   in Loop: Header=BB0_5 Depth=2
	movl	%r15d, %edi
	callq	_MIDDLE
	cmpl	%eax, %ebx
	jle	LBB0_7
## %bb.15:                              ##   in Loop: Header=BB0_5 Depth=2
	movl	%r13d, %ebx
	orl	%r14d, %ebx
	movq	_AXIS_POSITIVE_VALUE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	orl	%ebx, %edi
	callq	_PerKeyDown
	jmp	LBB0_17
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_5 Depth=2
	movl	%r15d, %edi
	callq	_MIDDLE
	cmpl	%eax, %ebx
	jge	LBB0_16
## %bb.10:                              ##   in Loop: Header=BB0_5 Depth=2
	movl	%r13d, %ebx
	orl	%r14d, %ebx
	movq	_AXIS_POSITIVE_VALUE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	orl	%ebx, %edi
	callq	_PerKeyUp
	movq	_AXIS_NEGATIVE_VALUE@GOTPCREL(%rip), %rax
	orl	(%rax), %ebx
	movl	%ebx, %edi
	callq	_PerKeyDown
	jmp	LBB0_18
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_2 Depth=1
	cmpl	$0, 4(%r12)
	jle	LBB0_19
## %bb.12:                              ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	%eax, %r14d
	shll	$24, %r14d
	movl	$1, %ebx
	jmp	LBB0_13
	.p2align	4, 0x90
LBB0_25:                                ##   in Loop: Header=BB0_13 Depth=2
	callq	_PerKeyUp
LBB0_26:                                ##   in Loop: Header=BB0_13 Depth=2
	leaq	1(%rbx), %rax
	movslq	4(%r12), %rcx
	cmpq	%rcx, %rbx
	movq	%rax, %rbx
	jge	LBB0_19
LBB0_13:                                ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%r12, %rdi
	movl	%ebx, %esi
	callq	_joy_read_button
	movq	24(%r12), %rcx
	movl	%r14d, %edi
	orl	%ebx, %edi
	cmpl	(%rcx,%rbx,4), %eax
	jle	LBB0_25
## %bb.14:                              ##   in Loop: Header=BB0_13 Depth=2
	callq	_PerKeyDown
	jmp	LBB0_26
	.p2align	4, 0x90
LBB0_19:                                ##   in Loop: Header=BB0_2 Depth=1
	cmpl	$0, 8(%r12)
	jle	LBB0_30
## %bb.20:                              ##   in Loop: Header=BB0_2 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
                                        ## kill: def $eax killed $eax killed $rax
	shll	$24, %eax
	movl	%eax, -60(%rbp)                 ## 4-byte Spill
	movq	16(%r12), %rax
	xorl	%ebx, %ebx
	jmp	LBB0_21
	.p2align	4, 0x90
LBB0_29:                                ##   in Loop: Header=BB0_21 Depth=2
	incq	%rbx
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	movslq	8(%r12), %rcx
	cmpq	%rcx, %rbx
	jge	LBB0_30
LBB0_21:                                ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Loop Header: Depth=2
                                        ##       Child Loop BB0_23 Depth 3
	leaq	(%rax,%rbx,8), %rsi
	movq	%r12, %rdi
	callq	_joy_read_element
	movq	%r12, %rcx
	movl	%eax, %r12d
	movq	16(%rcx), %rax
	movl	(%rax,%rbx,8), %r14d
	cmpl	4(%rax,%rbx,8), %r14d
	jge	LBB0_29
## %bb.22:                              ##   in Loop: Header=BB0_21 Depth=2
	movl	-60(%rbp), %eax                 ## 4-byte Reload
	orl	%ebx, %eax
	movl	%r12d, %r15d
	shll	$8, %r15d
	movl	%eax, -64(%rbp)                 ## 4-byte Spill
	orl	%eax, %r15d
	movl	%r14d, %r13d
	shll	$8, %r13d
	jmp	LBB0_23
	.p2align	4, 0x90
LBB0_27:                                ##   in Loop: Header=BB0_23 Depth=3
	movl	-64(%rbp), %eax                 ## 4-byte Reload
	orl	%r13d, %eax
	orl	%edi, %eax
	movl	%eax, %edi
	callq	_PerKeyUp
LBB0_28:                                ##   in Loop: Header=BB0_23 Depth=3
	incl	%r14d
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movq	16(%rax), %rax
	addl	$256, %r13d                     ## imm = 0x100
	cmpl	4(%rax,%rbx,8), %r14d
	jge	LBB0_29
LBB0_23:                                ##   Parent Loop BB0_2 Depth=1
                                        ##     Parent Loop BB0_21 Depth=2
                                        ## =>    This Inner Loop Header: Depth=3
	movq	_HAT_VALUE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	cmpl	%r14d, %r12d
	jne	LBB0_27
## %bb.24:                              ##   in Loop: Header=BB0_23 Depth=3
	orl	%r15d, %edi
	callq	_PerKeyDown
	jmp	LBB0_28
LBB0_31:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_YabauseExec
	negq	%rax
	sbbl	%ebx, %ebx
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_joycount,4,2                   ## @joycount
	.comm	_joys,8,3                       ## @joys
	.comm	_AXIS_POSITIVE_VALUE,4,2        ## @AXIS_POSITIVE_VALUE
	.comm	_AXIS_NEGATIVE_VALUE,4,2        ## @AXIS_NEGATIVE_VALUE
	.comm	_HAT_VALUE,4,2                  ## @HAT_VALUE
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_PERMacJoyHandleEvents          ; -- Begin function PERMacJoyHandleEvents
	.p2align	2
_PERMacJoyHandleEvents:                 ; @PERMacJoyHandleEvents
	.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, _joycount@GOTPAGE
Lloh1:
	ldr	x8, [x8, _joycount@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w8, #1
	b.lt	LBB0_32
; %bb.1:
	mov	x9, #0
Lloh3:
	adrp	x26, _AXIS_POSITIVE_VALUE@GOTPAGE
Lloh4:
	ldr	x26, [x26, _AXIS_POSITIVE_VALUE@GOTPAGEOFF]
Lloh5:
	adrp	x24, _AXIS_NEGATIVE_VALUE@GOTPAGE
Lloh6:
	ldr	x24, [x24, _AXIS_NEGATIVE_VALUE@GOTPAGEOFF]
Lloh7:
	adrp	x28, _HAT_VALUE@GOTPAGE
Lloh8:
	ldr	x28, [x28, _HAT_VALUE@GOTPAGEOFF]
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	x9, [sp]                        ; 8-byte Folded Reload
	add	x9, x9, #1
Lloh9:
	adrp	x8, _joycount@GOTPAGE
Lloh10:
	ldr	x8, [x8, _joycount@GOTPAGEOFF]
Lloh11:
	ldrsw	x8, [x8]
	cmp	x9, x8
	b.ge	LBB0_32
LBB0_3:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_11 Depth 2
                                        ;     Child Loop BB0_20 Depth 2
                                        ;     Child Loop BB0_26 Depth 2
                                        ;       Child Loop BB0_30 Depth 3
Lloh12:
	adrp	x8, _joys@GOTPAGE
Lloh13:
	ldr	x8, [x8, _joys@GOTPAGEOFF]
Lloh14:
	ldr	x8, [x8]
	str	x9, [sp]                        ; 8-byte Folded Spill
	ldr	x19, [x8, x9, lsl #3]
	cbz	x19, LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_16
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x25, #0
	mov	x20, #0
	ldr	x8, [sp]                        ; 8-byte Folded Reload
	lsl	w23, w8, #24
	b	LBB0_11
LBB0_6:                                 ;   in Loop: Header=BB0_11 Depth=2
	ldr	x8, [x19, #32]
LBB0_7:                                 ;   in Loop: Header=BB0_11 Depth=2
	ldr	w1, [x8, x25]
	tbnz	w1, #31, LBB0_14
LBB0_8:                                 ;   in Loop: Header=BB0_11 Depth=2
	ldr	w8, [x26]
	orr	w21, w23, w20
	orr	w0, w21, w8
	bl	_PerKeyUp
LBB0_9:                                 ;   in Loop: Header=BB0_11 Depth=2
	ldr	w8, [x24]
	orr	w0, w21, w8
	bl	_PerKeyUp
LBB0_10:                                ;   in Loop: Header=BB0_11 Depth=2
	add	x20, x20, #1
	ldrsw	x8, [x19]
	add	x25, x25, #8
	cmp	x20, x8
	b.ge	LBB0_16
LBB0_11:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	x8, [x19, #32]
	add	x8, x8, x25
	ldp	w0, w1, [x8]
	bl	_MIDDLE
	mov	x21, x0
	mov	x0, x19
	mov	x1, x20
	bl	_joy_read_axis
	mov	x22, x0
	ldr	x8, [x19, #32]
	add	x9, x8, x25
	ldr	w1, [x9, #4]
	cmp	w1, #1
	b.lt	LBB0_7
; %bb.12:                               ;   in Loop: Header=BB0_11 Depth=2
	mov	x0, x21
	bl	_MIDDLE
	cmp	w22, w0
	b.le	LBB0_6
; %bb.13:                               ;   in Loop: Header=BB0_11 Depth=2
	ldr	w8, [x26]
	orr	w21, w23, w20
	orr	w0, w21, w8
	bl	_PerKeyDown
	b	LBB0_9
LBB0_14:                                ;   in Loop: Header=BB0_11 Depth=2
	mov	x0, x21
	bl	_MIDDLE
	cmp	w22, w0
	b.ge	LBB0_8
; %bb.15:                               ;   in Loop: Header=BB0_11 Depth=2
	ldr	w8, [x26]
	orr	w21, w23, w20
	orr	w0, w21, w8
	bl	_PerKeyUp
	ldr	w8, [x24]
	orr	w0, w21, w8
	bl	_PerKeyDown
	b	LBB0_10
LBB0_16:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w8, [x19, #4]
	cmp	w8, #1
	b.lt	LBB0_22
; %bb.17:                               ;   in Loop: Header=BB0_3 Depth=1
	ldr	x8, [sp]                        ; 8-byte Folded Reload
	lsl	w21, w8, #24
	mov	w20, #1
	b	LBB0_20
LBB0_18:                                ;   in Loop: Header=BB0_20 Depth=2
	bl	_PerKeyUp
LBB0_19:                                ;   in Loop: Header=BB0_20 Depth=2
	add	x8, x20, #1
	ldrsw	x9, [x19, #4]
	cmp	x20, x9
	mov	x20, x8
	b.ge	LBB0_22
LBB0_20:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x19
	mov	x1, x20
	bl	_joy_read_button
	mov	x8, x0
	ldr	x9, [x19, #24]
	ldr	w9, [x9, x20, lsl #2]
	orr	w0, w21, w20
	cmp	w8, w9
	b.le	LBB0_18
; %bb.21:                               ;   in Loop: Header=BB0_20 Depth=2
	bl	_PerKeyDown
	b	LBB0_19
LBB0_22:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w8, [x19, #8]
	cmp	w8, #1
	b.lt	LBB0_2
; %bb.23:                               ;   in Loop: Header=BB0_3 Depth=1
	mov	x21, #0
	ldr	x8, [sp]                        ; 8-byte Folded Reload
	lsl	w8, w8, #24
	str	w8, [sp, #12]                   ; 4-byte Folded Spill
	ldr	x8, [x19, #16]
	b	LBB0_26
LBB0_24:                                ;   in Loop: Header=BB0_26 Depth=2
	mov	x26, x24
	mov	x24, x22
LBB0_25:                                ;   in Loop: Header=BB0_26 Depth=2
	add	x21, x21, #1
	ldrsw	x9, [x19, #8]
	cmp	x21, x9
	b.ge	LBB0_2
LBB0_26:                                ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_30 Depth 3
	lsl	x23, x21, #3
	add	x1, x8, x23
	mov	x0, x19
	bl	_joy_read_element
	ldr	x8, [x19, #16]
	add	x9, x8, x23
	ldp	w23, w9, [x9]
	cmp	w23, w9
	b.ge	LBB0_25
; %bb.27:                               ;   in Loop: Header=BB0_26 Depth=2
	mov	x20, x0
	mov	x22, x24
	mov	x24, x26
	ldr	w8, [sp, #12]                   ; 4-byte Folded Reload
	orr	w25, w8, w21
	orr	w26, w25, w0, lsl #8
	lsl	w27, w23, #8
	b	LBB0_30
LBB0_28:                                ;   in Loop: Header=BB0_30 Depth=3
	orr	w9, w25, w27
	orr	w0, w9, w8
	bl	_PerKeyUp
LBB0_29:                                ;   in Loop: Header=BB0_30 Depth=3
	add	w23, w23, #1
	ldr	x8, [x19, #16]
	add	x9, x8, x21, lsl #3
	ldr	w9, [x9, #4]
	add	w27, w27, #256
	cmp	w23, w9
	b.ge	LBB0_24
LBB0_30:                                ;   Parent Loop BB0_3 Depth=1
                                        ;     Parent Loop BB0_26 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	ldr	w8, [x28]
	cmp	w20, w23
	b.ne	LBB0_28
; %bb.31:                               ;   in Loop: Header=BB0_30 Depth=3
	orr	w0, w26, w8
	bl	_PerKeyDown
	b	LBB0_29
LBB0_32:
	bl	_YabauseExec
	cmp	x0, #0
	csetm	w0, ne
	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	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_joycount,4,2                   ; @joycount
	.comm	_joys,8,3                       ; @joys
	.comm	_AXIS_POSITIVE_VALUE,4,2        ; @AXIS_POSITIVE_VALUE
	.comm	_AXIS_NEGATIVE_VALUE,4,2        ; @AXIS_NEGATIVE_VALUE
	.comm	_HAT_VALUE,4,2                  ; @HAT_VALUE
.subsections_via_symbols
