	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function hidpad_psxadapter_packet_handler
_hidpad_psxadapter_packet_handler:      ## @hidpad_psxadapter_packet_handler
	.cfi_startproc
## %bb.0:
	testq	%rdi, %rdi
	je	LBB0_9
## %bb.1:
	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	%rdi, %r13
	movq	(%rdi), %rdi
	callq	_memcpy
	movl	$0, 8(%r13)
	movq	(%r13), %r8
	movl	24(%r8), %esi
	shll	$8, %esi
	orl	28(%r8), %esi
	xorl	%r9d, %r9d
	leaq	_hidpad_psxadapter_packet_handler.button_mapping(%rip), %rax
	xorl	%edx, %edx
	xorl	%edi, %edi
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_4:                                 ##   in Loop: Header=BB0_2 Depth=1
	incq	%rdi
	addq	$4, %rax
	cmpq	$16, %rdi
	je	LBB0_5
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movl	%edi, %ecx
	andl	$2147483644, %ecx               ## imm = 0x7FFFFFFC
	cmpl	$8, %ecx
	je	LBB0_4
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movzbl	(%rax), %ecx
	movl	$1, %ebx
	shll	%cl, %ebx
	btl	%edi, %esi
	cmovael	%r9d, %ebx
	orl	%ebx, %edx
	movl	%edx, 8(%r13)
	jmp	LBB0_4
LBB0_5:
	cmpl	$127, 8(%r8)
	jne	LBB0_7
## %bb.6:
	movq	_RETRO_DEVICE_ID_JOYPAD_LEFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	movl	$1, %esi
	shll	%cl, %esi
	xorl	%eax, %eax
	cmpl	$0, 16(%r8)
	cmovnel	%eax, %esi
	orl	%edx, %esi
	movl	%esi, 8(%r13)
	movq	_RETRO_DEVICE_ID_JOYPAD_RIGHT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	$1, %edx
	shll	%cl, %edx
	cmpl	$255, 16(%r8)
	cmovnel	%eax, %edx
	orl	%esi, %edx
	movl	%edx, 8(%r13)
	movq	_RETRO_DEVICE_ID_JOYPAD_UP@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	$1, %esi
	shll	%cl, %esi
	cmpl	$0, 20(%r8)
	cmovnel	%eax, %esi
	movl	$1, %r15d
	orl	%edx, %esi
	movl	%esi, 8(%r13)
	movq	_RETRO_DEVICE_ID_JOYPAD_DOWN@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %r15d
	cmpl	$255, 20(%r8)
	cmovnel	%eax, %r15d
	orl	%esi, %r15d
	jmp	LBB0_8
LBB0_7:
	movl	24(%r8), %edi
	callq	_PSX_H_GET
	movl	%eax, %r14d
	movl	%eax, %edi
	callq	_PSX_H_LEFT
	movq	_RETRO_DEVICE_ID_JOYPAD_LEFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	$1, %edx
	shll	%cl, %edx
	xorl	%r12d, %r12d
	testq	%rax, %rax
	cmovel	%r12d, %edx
	movl	$1, %r15d
	orl	%edx, 8(%r13)
	movl	%r14d, %edi
	callq	_PSX_H_RIGHT
	movq	_RETRO_DEVICE_ID_JOYPAD_RIGHT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	$1, %edx
	shll	%cl, %edx
	testq	%rax, %rax
	cmovel	%r12d, %edx
	orl	%edx, 8(%r13)
	movl	%r14d, %edi
	callq	_PSX_H_UP
	movq	_RETRO_DEVICE_ID_JOYPAD_UP@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	$1, %edx
	shll	%cl, %edx
	testq	%rax, %rax
	cmovel	%r12d, %edx
	orl	%edx, 8(%r13)
	movl	%r14d, %edi
	callq	_PSX_H_DOWN
	movq	_RETRO_DEVICE_ID_JOYPAD_DOWN@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %r15d
	testq	%rax, %rax
	cmovel	%r12d, %r15d
	orl	8(%r13), %r15d
LBB0_8:
	movl	%r15d, 8(%r13)
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
LBB0_9:
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__const
	.p2align	4                               ## @hidpad_psxadapter_packet_handler.button_mapping
_hidpad_psxadapter_packet_handler.button_mapping:
	.long	136                             ## 0x88
	.long	133                             ## 0x85
	.long	137                             ## 0x89
	.long	134                             ## 0x86
	.long	131                             ## 0x83
	.long	130                             ## 0x82
	.long	135                             ## 0x87
	.long	132                             ## 0x84
	.long	140                             ## 0x8c
	.long	140                             ## 0x8c
	.long	140                             ## 0x8c
	.long	140                             ## 0x8c
	.long	129                             ## 0x81
	.long	139                             ## 0x8b
	.long	138                             ## 0x8a
	.long	128                             ## 0x80

	.comm	_RETRO_DEVICE_ID_JOYPAD_LEFT,4,2 ## @RETRO_DEVICE_ID_JOYPAD_LEFT
	.comm	_RETRO_DEVICE_ID_JOYPAD_RIGHT,4,2 ## @RETRO_DEVICE_ID_JOYPAD_RIGHT
	.comm	_RETRO_DEVICE_ID_JOYPAD_UP,4,2  ## @RETRO_DEVICE_ID_JOYPAD_UP
	.comm	_RETRO_DEVICE_ID_JOYPAD_DOWN,4,2 ## @RETRO_DEVICE_ID_JOYPAD_DOWN
	.no_dead_strip	_hidpad_psxadapter_packet_handler
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function hidpad_psxadapter_packet_handler
_hidpad_psxadapter_packet_handler:      ; @hidpad_psxadapter_packet_handler
	.cfi_startproc
; %bb.0:
	cbz	x0, LBB0_9
; %bb.1:
	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
	mov	x19, x0
	ldr	x0, [x0]
	bl	_memcpy
	mov	w9, #0
	mov	x10, #0
	str	wzr, [x19, #8]
	ldr	x8, [x19]
	ldp	w12, w11, [x8, #24]
	orr	w11, w11, w12, lsl #8
Lloh0:
	adrp	x12, _hidpad_psxadapter_packet_handler.button_mapping@PAGE
Lloh1:
	add	x12, x12, _hidpad_psxadapter_packet_handler.button_mapping@PAGEOFF
	mov	w13, #1
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	add	x10, x10, #1
	cmp	x10, #16
	b.eq	LBB0_5
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	and	x14, x10, #0x7ffffffc
	cmp	x14, #8
	b.eq	LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	w14, [x12, x10, lsl #2]
	lsl	w14, w13, w14
	lsr	w15, w11, w10
	sbfx	w15, w15, #0, #1
	and	w14, w15, w14
	orr	w9, w14, w9
	str	w9, [x19, #8]
	b	LBB0_2
LBB0_5:
	ldr	w10, [x8, #8]
	cmp	w10, #127
	b.ne	LBB0_7
; %bb.6:
	ldr	w10, [x8, #16]
Lloh2:
	adrp	x11, _RETRO_DEVICE_ID_JOYPAD_LEFT@GOTPAGE
Lloh3:
	ldr	x11, [x11, _RETRO_DEVICE_ID_JOYPAD_LEFT@GOTPAGEOFF]
Lloh4:
	ldr	w11, [x11]
	mov	w12, #1
	lsl	w11, w12, w11
	cmp	w10, #0
	csel	w10, w11, wzr, eq
	orr	w9, w10, w9
	str	w9, [x19, #8]
Lloh5:
	adrp	x10, _RETRO_DEVICE_ID_JOYPAD_RIGHT@GOTPAGE
Lloh6:
	ldr	x10, [x10, _RETRO_DEVICE_ID_JOYPAD_RIGHT@GOTPAGEOFF]
	ldr	w11, [x8, #16]
Lloh7:
	ldr	w10, [x10]
	lsl	w10, w12, w10
	cmp	w11, #255
	csel	w10, w10, wzr, eq
	orr	w9, w10, w9
	str	w9, [x19, #8]
	ldr	w10, [x8, #20]
Lloh8:
	adrp	x11, _RETRO_DEVICE_ID_JOYPAD_UP@GOTPAGE
Lloh9:
	ldr	x11, [x11, _RETRO_DEVICE_ID_JOYPAD_UP@GOTPAGEOFF]
Lloh10:
	ldr	w11, [x11]
	lsl	w11, w12, w11
	cmp	w10, #0
	csel	w10, w11, wzr, eq
	orr	w9, w10, w9
	str	w9, [x19, #8]
Lloh11:
	adrp	x10, _RETRO_DEVICE_ID_JOYPAD_DOWN@GOTPAGE
Lloh12:
	ldr	x10, [x10, _RETRO_DEVICE_ID_JOYPAD_DOWN@GOTPAGEOFF]
	ldr	w8, [x8, #20]
Lloh13:
	ldr	w10, [x10]
	lsl	w10, w12, w10
	cmp	w8, #255
	csel	w8, w10, wzr, eq
	b	LBB0_8
LBB0_7:
	ldr	w0, [x8, #24]
	bl	_PSX_H_GET
	mov	x20, x0
	bl	_PSX_H_LEFT
Lloh14:
	adrp	x8, _RETRO_DEVICE_ID_JOYPAD_LEFT@GOTPAGE
Lloh15:
	ldr	x8, [x8, _RETRO_DEVICE_ID_JOYPAD_LEFT@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	mov	w21, #1
	lsl	w8, w21, w8
	cmp	x0, #0
	csel	w8, wzr, w8, eq
	ldr	w9, [x19, #8]
	orr	w8, w8, w9
	str	w8, [x19, #8]
	mov	x0, x20
	bl	_PSX_H_RIGHT
Lloh17:
	adrp	x8, _RETRO_DEVICE_ID_JOYPAD_RIGHT@GOTPAGE
Lloh18:
	ldr	x8, [x8, _RETRO_DEVICE_ID_JOYPAD_RIGHT@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	lsl	w8, w21, w8
	cmp	x0, #0
	csel	w8, wzr, w8, eq
	ldr	w9, [x19, #8]
	orr	w8, w8, w9
	str	w8, [x19, #8]
	mov	x0, x20
	bl	_PSX_H_UP
Lloh20:
	adrp	x8, _RETRO_DEVICE_ID_JOYPAD_UP@GOTPAGE
Lloh21:
	ldr	x8, [x8, _RETRO_DEVICE_ID_JOYPAD_UP@GOTPAGEOFF]
Lloh22:
	ldr	w8, [x8]
	lsl	w8, w21, w8
	cmp	x0, #0
	csel	w8, wzr, w8, eq
	ldr	w9, [x19, #8]
	orr	w8, w8, w9
	str	w8, [x19, #8]
	mov	x0, x20
	bl	_PSX_H_DOWN
Lloh23:
	adrp	x8, _RETRO_DEVICE_ID_JOYPAD_DOWN@GOTPAGE
Lloh24:
	ldr	x8, [x8, _RETRO_DEVICE_ID_JOYPAD_DOWN@GOTPAGEOFF]
Lloh25:
	ldr	w8, [x8]
	lsl	w8, w21, w8
	cmp	x0, #0
	csel	w8, wzr, w8, eq
	ldr	w9, [x19, #8]
LBB0_8:
	orr	w8, w8, w9
	str	w8, [x19, #8]
	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
LBB0_9:
	.cfi_def_cfa wsp, 0
	.cfi_same_value w30
	.cfi_same_value w29
	.cfi_same_value w19
	.cfi_same_value w20
	.cfi_same_value w21
	.cfi_same_value w22
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__const
	.p2align	2                               ; @hidpad_psxadapter_packet_handler.button_mapping
_hidpad_psxadapter_packet_handler.button_mapping:
	.long	136                             ; 0x88
	.long	133                             ; 0x85
	.long	137                             ; 0x89
	.long	134                             ; 0x86
	.long	131                             ; 0x83
	.long	130                             ; 0x82
	.long	135                             ; 0x87
	.long	132                             ; 0x84
	.long	140                             ; 0x8c
	.long	140                             ; 0x8c
	.long	140                             ; 0x8c
	.long	140                             ; 0x8c
	.long	129                             ; 0x81
	.long	139                             ; 0x8b
	.long	138                             ; 0x8a
	.long	128                             ; 0x80

	.comm	_RETRO_DEVICE_ID_JOYPAD_LEFT,4,2 ; @RETRO_DEVICE_ID_JOYPAD_LEFT
	.comm	_RETRO_DEVICE_ID_JOYPAD_RIGHT,4,2 ; @RETRO_DEVICE_ID_JOYPAD_RIGHT
	.comm	_RETRO_DEVICE_ID_JOYPAD_UP,4,2  ; @RETRO_DEVICE_ID_JOYPAD_UP
	.comm	_RETRO_DEVICE_ID_JOYPAD_DOWN,4,2 ; @RETRO_DEVICE_ID_JOYPAD_DOWN
	.no_dead_strip	_hidpad_psxadapter_packet_handler
.subsections_via_symbols
