	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_PERMacJoyInit                  ## -- Begin function PERMacJoyInit
	.p2align	4, 0x90
_PERMacJoyInit:                         ## @PERMacJoyInit
	.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
	movq	_initted@GOTPCREL(%rip), %r14
	xorl	%eax, %eax
	cmpl	$0, (%r14)
	jne	LBB0_11
## %bb.1:
	xorl	%eax, %eax
	callq	_joy_scan_joysticks
	movq	_joycount@GOTPCREL(%rip), %r15
	movl	%eax, (%r15)
	cmpl	$-1, %eax
	je	LBB0_2
## %bb.3:
	shll	$3, %eax
	movl	%eax, %edi
	callq	_malloc
	movq	_joys@GOTPCREL(%rip), %r12
	movq	%rax, (%r12)
	testq	%rax, %rax
	je	LBB0_2
## %bb.4:
	cmpl	$0, (%r15)
	jle	LBB0_10
## %bb.5:
	xorl	%ebx, %ebx
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=1
	incq	%rbx
	movslq	(%r15), %rax
	cmpq	%rax, %rbx
	jge	LBB0_10
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %edi
	callq	_joy_get_joystick
	movq	(%r12), %rcx
	movq	%rax, (%rcx,%rbx,8)
	movq	(%r12), %rax
	movq	(%rax,%rbx,8), %rdi
	testq	%rdi, %rdi
	je	LBB0_9
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	callq	_joy_open_joystick
	testl	%eax, %eax
	jne	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=1
	movq	(%r12), %rax
	movq	$0, (%rax,%rbx,8)
	jmp	LBB0_9
LBB0_2:
	movl	$0, (%r15)
	movl	$-1, %eax
	jmp	LBB0_11
LBB0_10:
	movl	$1, (%r14)
	xorl	%eax, %eax
LBB0_11:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_initted,4,2                    ## @initted
	.comm	_joycount,4,2                   ## @joycount
	.comm	_joys,8,3                       ## @joys
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_PERMacJoyInit                  ; -- Begin function PERMacJoyInit
	.p2align	2
_PERMacJoyInit:                         ; @PERMacJoyInit
	.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
Lloh0:
	adrp	x20, _initted@GOTPAGE
Lloh1:
	ldr	x20, [x20, _initted@GOTPAGEOFF]
	ldr	w8, [x20]
	cbz	w8, LBB0_3
; %bb.1:
	mov	w0, #0
LBB0_2:
	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
LBB0_3:
	bl	_joy_scan_joysticks
Lloh2:
	adrp	x21, _joycount@GOTPAGE
Lloh3:
	ldr	x21, [x21, _joycount@GOTPAGEOFF]
	str	w0, [x21]
	cmn	w0, #1
	b.eq	LBB0_12
; %bb.4:
	lsl	w0, w0, #3
	bl	_malloc
Lloh4:
	adrp	x22, _joys@GOTPAGE
Lloh5:
	ldr	x22, [x22, _joys@GOTPAGEOFF]
	str	x0, [x22]
	cbz	x0, LBB0_13
; %bb.5:
	ldr	w8, [x21]
	cmp	w8, #1
	b.lt	LBB0_11
; %bb.6:
	mov	x19, #0
	b	LBB0_8
LBB0_7:                                 ;   in Loop: Header=BB0_8 Depth=1
	add	x19, x19, #1
	ldrsw	x8, [x21]
	cmp	x19, x8
	b.ge	LBB0_11
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	bl	_joy_get_joystick
	ldr	x8, [x22]
	lsl	x9, x19, #3
	str	x0, [x8, x9]
	ldr	x8, [x22]
	ldr	x0, [x8, x9]
	cbz	x0, LBB0_7
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	bl	_joy_open_joystick
	cbnz	w0, LBB0_7
; %bb.10:                               ;   in Loop: Header=BB0_8 Depth=1
	ldr	x8, [x22]
	str	xzr, [x8, x19, lsl #3]
	b	LBB0_7
LBB0_11:
	mov	w0, #0
	mov	w8, #1
	str	w8, [x20]
	b	LBB0_2
LBB0_12:
	str	wzr, [x21]
	b	LBB0_2
LBB0_13:
	str	wzr, [x21]
	mov	w0, #-1
	b	LBB0_2
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh4, Lloh5
	.cfi_endproc
                                        ; -- End function
	.comm	_initted,4,2                    ; @initted
	.comm	_joycount,4,2                   ; @joycount
	.comm	_joys,8,3                       ; @joys
.subsections_via_symbols
