	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function joy_read_device
_joy_read_device:                       ## @joy_read_device
	.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
	subq	$32, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edi, %r14d
	movl	$0, -36(%rbp)
	movq	_kCFAllocatorDefault@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_kNilOptions@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	leaq	-36(%rbp), %rsi
	callq	_IORegistryEntryCreateCFProperties
	movq	_KERN_SUCCESS@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
## %bb.1:
	movl	-36(%rbp), %ebx
	movq	_kIOHIDPrimaryUsagePageKey@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_CFSTR
	movl	%ebx, %edi
	movl	%eax, %esi
	callq	_CFDictionaryGetValue
	testq	%rax, %rax
	je	LBB0_12
## %bb.2:
	movq	_kCFNumberSInt32Type@GOTPCREL(%rip), %r15
	movl	(%r15), %esi
	leaq	-56(%rbp), %rdx
	movl	%eax, %edi
	callq	_CFNumberGetValue
	testl	%eax, %eax
	je	LBB0_12
## %bb.3:
	movq	-56(%rbp), %rax
	movq	_kHIDPage_GenericDesktop@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
## %bb.4:
	movl	-36(%rbp), %ebx
	movq	_kIOHIDPrimaryUsageKey@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_CFSTR
	movl	%ebx, %edi
	movl	%eax, %esi
	callq	_CFDictionaryGetValue
	testq	%rax, %rax
	je	LBB0_12
## %bb.5:
	movl	(%r15), %esi
	leaq	-48(%rbp), %rdx
	movl	%eax, %edi
	callq	_CFNumberGetValue
	testl	%eax, %eax
	je	LBB0_12
## %bb.6:
	movq	-48(%rbp), %rax
	movq	_kHIDUsage_GD_GamePad@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_8
## %bb.7:
	movq	_kHIDUsage_GD_Joystick@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
LBB0_8:
	movq	_joys@GOTPCREL(%rip), %r12
	movq	(%r12), %rdi
	movq	_joy_count@GOTPCREL(%rip), %r15
	movl	(%r15), %eax
	leal	(%rax,%rax,2), %eax
	leal	12(,%rax,4), %esi
	callq	_realloc
	testq	%rax, %rax
	je	LBB0_12
## %bb.9:
	movq	%rax, (%r12)
	movslq	(%r15), %rcx
	leaq	(%rcx,%rcx,2), %rcx
	leaq	(%rax,%rcx,4), %rdi
	xorl	%esi, %esi
	movl	$12, %edx
	callq	_memset
	movl	-36(%rbp), %ebx
	movq	_kIOHIDProductKey@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_CFSTR
	movl	%ebx, %edi
	movl	%eax, %esi
	callq	_CFDictionaryGetValue
	movq	(%r12), %rcx
	movslq	(%r15), %rdx
	leaq	(%rdx,%rdx,2), %rdx
	movl	8(%rcx,%rdx,4), %esi
	movq	_kCFStringEncodingUTF8@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%eax, %edi
	movl	$256, %edx                      ## imm = 0x100
	callq	_CFStringGetCString
	testl	%eax, %eax
	je	LBB0_12
## %bb.10:
	movslq	(%r15), %rax
	leaq	(%rax,%rax,2), %rsi
	shlq	$2, %rsi
	addq	(%r12), %rsi
	movl	%r14d, %edi
	callq	_joy_create_interface
	testl	%eax, %eax
	je	LBB0_12
## %bb.11:
	movl	-36(%rbp), %edi
	movslq	(%r15), %rax
	leaq	(%rax,%rax,2), %rsi
	shlq	$2, %rsi
	addq	(%r12), %rsi
	callq	_joy_find_elements
	movq	(%r12), %rax
	movslq	(%r15), %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movl	(%rax,%rcx,4), %esi
	movl	4(%rax,%rcx,4), %edi
	movq	_joy_cmp_buttons@GOTPCREL(%rip), %rcx
	movl	$4, %edx
	callq	_qsort
	incl	(%r15)
LBB0_12:
	movl	-36(%rbp), %edi
	callq	_CFRelease
	addq	$32, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_kCFAllocatorDefault,4,2        ## @kCFAllocatorDefault
	.comm	_kNilOptions,4,2                ## @kNilOptions
	.comm	_KERN_SUCCESS,8,3               ## @KERN_SUCCESS
	.comm	_kIOHIDPrimaryUsagePageKey,4,2  ## @kIOHIDPrimaryUsagePageKey
	.comm	_kCFNumberSInt32Type,4,2        ## @kCFNumberSInt32Type
	.comm	_kHIDPage_GenericDesktop,8,3    ## @kHIDPage_GenericDesktop
	.comm	_kIOHIDPrimaryUsageKey,4,2      ## @kIOHIDPrimaryUsageKey
	.comm	_kHIDUsage_GD_GamePad,8,3       ## @kHIDUsage_GD_GamePad
	.comm	_kHIDUsage_GD_Joystick,8,3      ## @kHIDUsage_GD_Joystick
	.comm	_joys,8,3                       ## @joys
	.comm	_joy_count,4,2                  ## @joy_count
	.comm	_kIOHIDProductKey,4,2           ## @kIOHIDProductKey
	.comm	_kCFStringEncodingUTF8,4,2      ## @kCFStringEncodingUTF8
	.comm	_joy_cmp_buttons,4,2            ## @joy_cmp_buttons
	.no_dead_strip	_joy_read_device
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function joy_read_device
_joy_read_device:                       ; @joy_read_device
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	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
	mov	x19, x0
	str	wzr, [sp, #28]
Lloh0:
	adrp	x8, _kCFAllocatorDefault@GOTPAGE
Lloh1:
	ldr	x8, [x8, _kCFAllocatorDefault@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
Lloh3:
	adrp	x8, _kNilOptions@GOTPAGE
Lloh4:
	ldr	x8, [x8, _kNilOptions@GOTPAGEOFF]
Lloh5:
	ldr	w3, [x8]
	add	x1, sp, #28
	bl	_IORegistryEntryCreateCFProperties
Lloh6:
	adrp	x8, _KERN_SUCCESS@GOTPAGE
Lloh7:
	ldr	x8, [x8, _KERN_SUCCESS@GOTPAGEOFF]
Lloh8:
	ldr	x8, [x8]
	cmp	x0, x8
	b.ne	LBB0_12
; %bb.1:
	ldr	w20, [sp, #28]
Lloh9:
	adrp	x8, _kIOHIDPrimaryUsagePageKey@GOTPAGE
Lloh10:
	ldr	x8, [x8, _kIOHIDPrimaryUsagePageKey@GOTPAGEOFF]
Lloh11:
	ldr	w0, [x8]
	bl	_CFSTR
	mov	x1, x0
	mov	x0, x20
	bl	_CFDictionaryGetValue
	cbz	x0, LBB0_12
; %bb.2:
Lloh12:
	adrp	x21, _kCFNumberSInt32Type@GOTPAGE
Lloh13:
	ldr	x21, [x21, _kCFNumberSInt32Type@GOTPAGEOFF]
	ldr	w1, [x21]
	add	x2, sp, #16
                                        ; kill: def $w0 killed $w0 killed $x0
	bl	_CFNumberGetValue
	cbz	w0, LBB0_12
; %bb.3:
	ldr	x8, [sp, #16]
Lloh14:
	adrp	x9, _kHIDPage_GenericDesktop@GOTPAGE
Lloh15:
	ldr	x9, [x9, _kHIDPage_GenericDesktop@GOTPAGEOFF]
Lloh16:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_12
; %bb.4:
	ldr	w20, [sp, #28]
Lloh17:
	adrp	x8, _kIOHIDPrimaryUsageKey@GOTPAGE
Lloh18:
	ldr	x8, [x8, _kIOHIDPrimaryUsageKey@GOTPAGEOFF]
Lloh19:
	ldr	w0, [x8]
	bl	_CFSTR
	mov	x1, x0
	mov	x0, x20
	bl	_CFDictionaryGetValue
	cbz	x0, LBB0_12
; %bb.5:
	ldr	w1, [x21]
	add	x2, sp, #8
                                        ; kill: def $w0 killed $w0 killed $x0
	bl	_CFNumberGetValue
	cbz	w0, LBB0_12
; %bb.6:
	ldr	x8, [sp, #8]
Lloh20:
	adrp	x9, _kHIDUsage_GD_GamePad@GOTPAGE
Lloh21:
	ldr	x9, [x9, _kHIDUsage_GD_GamePad@GOTPAGEOFF]
Lloh22:
	ldr	x9, [x9]
	cmp	x8, x9
	b.eq	LBB0_8
; %bb.7:
Lloh23:
	adrp	x9, _kHIDUsage_GD_Joystick@GOTPAGE
Lloh24:
	ldr	x9, [x9, _kHIDUsage_GD_Joystick@GOTPAGEOFF]
Lloh25:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_12
LBB0_8:
Lloh26:
	adrp	x22, _joys@GOTPAGE
Lloh27:
	ldr	x22, [x22, _joys@GOTPAGEOFF]
	ldr	x0, [x22]
Lloh28:
	adrp	x21, _joy_count@GOTPAGE
Lloh29:
	ldr	x21, [x21, _joy_count@GOTPAGEOFF]
	ldr	w8, [x21]
	mov	w9, #12
	orr	w10, wzr, #0xc
	madd	w1, w8, w9, w10
	bl	_realloc
	cbz	x0, LBB0_12
; %bb.9:
	str	x0, [x22]
	ldrsw	x8, [x21]
	mov	w23, #12
	madd	x0, x8, x23, x0
	mov	w1, #0
	mov	w2, #12
	bl	_memset
	ldr	w20, [sp, #28]
Lloh30:
	adrp	x8, _kIOHIDProductKey@GOTPAGE
Lloh31:
	ldr	x8, [x8, _kIOHIDProductKey@GOTPAGEOFF]
Lloh32:
	ldr	w0, [x8]
	bl	_CFSTR
	mov	x1, x0
	mov	x0, x20
	bl	_CFDictionaryGetValue
	ldr	x8, [x22]
	ldrsw	x9, [x21]
	madd	x8, x9, x23, x8
	ldr	w1, [x8, #8]
Lloh33:
	adrp	x8, _kCFStringEncodingUTF8@GOTPAGE
Lloh34:
	ldr	x8, [x8, _kCFStringEncodingUTF8@GOTPAGEOFF]
Lloh35:
	ldr	w3, [x8]
                                        ; kill: def $w0 killed $w0 killed $x0
	mov	w2, #256
	bl	_CFStringGetCString
	cbz	w0, LBB0_12
; %bb.10:
	ldr	x8, [x22]
	ldrsw	x9, [x21]
	mov	w10, #12
	madd	x1, x9, x10, x8
	mov	x0, x19
	bl	_joy_create_interface
	cbz	w0, LBB0_12
; %bb.11:
	ldr	w0, [sp, #28]
	ldr	x8, [x22]
	ldrsw	x9, [x21]
	mov	w19, #12
	madd	x1, x9, x19, x8
	bl	_joy_find_elements
	ldr	x8, [x22]
	ldrsw	x9, [x21]
	madd	x8, x9, x19, x8
	ldp	w1, w0, [x8]
Lloh36:
	adrp	x3, _joy_cmp_buttons@GOTPAGE
Lloh37:
	ldr	x3, [x3, _joy_cmp_buttons@GOTPAGEOFF]
	mov	w2, #4
	bl	_qsort
	ldr	w8, [x21]
	add	w8, w8, #1
	str	w8, [x21]
LBB0_12:
	ldr	w0, [sp, #28]
	bl	_CFRelease
	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
	add	sp, sp, #96
	ret
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh28, Lloh29
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGot	Lloh36, Lloh37
	.cfi_endproc
                                        ; -- End function
	.comm	_kCFAllocatorDefault,4,2        ; @kCFAllocatorDefault
	.comm	_kNilOptions,4,2                ; @kNilOptions
	.comm	_KERN_SUCCESS,8,3               ; @KERN_SUCCESS
	.comm	_kIOHIDPrimaryUsagePageKey,4,2  ; @kIOHIDPrimaryUsagePageKey
	.comm	_kCFNumberSInt32Type,4,2        ; @kCFNumberSInt32Type
	.comm	_kHIDPage_GenericDesktop,8,3    ; @kHIDPage_GenericDesktop
	.comm	_kIOHIDPrimaryUsageKey,4,2      ; @kIOHIDPrimaryUsageKey
	.comm	_kHIDUsage_GD_GamePad,8,3       ; @kHIDUsage_GD_GamePad
	.comm	_kHIDUsage_GD_Joystick,8,3      ; @kHIDUsage_GD_Joystick
	.comm	_joys,8,3                       ; @joys
	.comm	_joy_count,4,2                  ; @joy_count
	.comm	_kIOHIDProductKey,4,2           ; @kIOHIDProductKey
	.comm	_kCFStringEncodingUTF8,4,2      ; @kCFStringEncodingUTF8
	.comm	_joy_cmp_buttons,4,2            ; @joy_cmp_buttons
	.no_dead_strip	_joy_read_device
.subsections_via_symbols
