	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_run_events_pico                ## -- Begin function run_events_pico
	.p2align	4, 0x90
_run_events_pico:                       ## @run_events_pico
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	movl	%edi, %ebx
	movq	_PEV_PICO_SWINP@GOTPCREL(%rip), %rax
	testl	%edi, (%rax)
	je	LBB0_8
## %bb.1:
	movq	_pico_inp_mode@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	leal	1(%rdx), %esi
	xorl	%eax, %eax
	cmpl	$2, %edx
	cmovll	%esi, %eax
	movl	%eax, (%rcx)
	testl	%eax, %eax
	je	LBB0_7
## %bb.2:
	cmpl	$1, %eax
	je	LBB0_6
## %bb.3:
	cmpl	$2, %eax
	jne	LBB0_8
## %bb.4:
	leaq	L_.str(%rip), %rdi
	jmp	LBB0_5
LBB0_7:
	leaq	L_.str.2(%rip), %rdi
	xorl	%eax, %eax
	callq	_emu_status_msg
	movq	_PicoPicohw@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movabsq	$140737488388096, %rcx          ## imm = 0x800000008000
	movq	%rcx, (%rax)
	jmp	LBB0_8
LBB0_6:
	leaq	L_.str.1(%rip), %rdi
LBB0_5:
	xorl	%eax, %eax
	callq	_emu_status_msg
LBB0_8:
	movq	_PEV_PICO_PPREV@GOTPCREL(%rip), %rax
	testl	%ebx, (%rax)
	je	LBB0_10
## %bb.9:
	movq	_PicoPicohw@GOTPCREL(%rip), %rax
	movl	8(%rax), %ecx
	cmpl	$2, %ecx
	movl	$1, %esi
	cmovgel	%ecx, %esi
	decl	%esi
	movl	%esi, 8(%rax)
	leaq	L_.str.3(%rip), %rdi
	xorl	%eax, %eax
	callq	_emu_status_msg
LBB0_10:
	movq	_PEV_PICO_PNEXT@GOTPCREL(%rip), %rax
	testl	%ebx, (%rax)
	je	LBB0_12
## %bb.11:
	movq	_PicoPicohw@GOTPCREL(%rip), %rax
	movl	8(%rax), %ecx
	cmpl	$5, %ecx
	movl	$5, %esi
	cmovll	%ecx, %esi
	incl	%esi
	movl	%esi, 8(%rax)
	leaq	L_.str.3(%rip), %rdi
	xorl	%eax, %eax
	callq	_emu_status_msg
LBB0_12:
	movq	_pico_inp_mode@GOTPCREL(%rip), %r8
	cmpl	$0, (%r8)
	je	LBB0_32
## %bb.13:
	movq	_PicoPad@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rcx), %edx
	testb	$1, %dl
	jne	LBB0_14
## %bb.15:
	testb	$2, %dl
	jne	LBB0_16
LBB0_17:
	testb	$4, %dl
	jne	LBB0_18
LBB0_19:
	testb	$8, %dl
	je	LBB0_21
LBB0_20:
	movq	_pico_pen_x@GOTPCREL(%rip), %rdx
	incl	(%rdx)
	movl	(%rcx), %edx
LBB0_21:
	andl	$-16, %edx
	movl	%edx, (%rcx)
	movq	_Pico@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rdx
	movl	48(%rdx), %esi
	andl	$1, %esi
	movq	_pico_pen_y@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	cmpl	$7, %edi
	jg	LBB0_23
## %bb.22:
	movl	$8, (%rcx)
	movl	$8, %edi
LBB0_23:
	shll	$6, %esi
	movq	_PICO_PEN_ADJUST_Y@GOTPCREL(%rip), %rax
	movl	$224, %ebx
	subl	(%rax), %ebx
	cmpl	%ebx, %edi
	jle	LBB0_25
## %bb.24:
	movl	%ebx, (%rcx)
LBB0_25:
	addl	$255, %esi
	movq	_pico_pen_x@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edi
	testl	%edi, %edi
	jns	LBB0_27
## %bb.26:
	movl	$0, (%rbx)
	xorl	%edi, %edi
LBB0_27:
	movq	_PICO_PEN_ADJUST_X@GOTPCREL(%rip), %rax
	subl	(%rax), %esi
	cmpl	%esi, %edi
	jle	LBB0_29
## %bb.28:
	movl	%esi, (%rbx)
	movl	%esi, %edi
LBB0_29:
	movq	_PicoPicohw@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	movl	%edi, (%rsi)
	testb	$1, 48(%rdx)
	jne	LBB0_31
## %bb.30:
	movl	(%rbx), %eax
	leal	3(%rax), %edx
	testl	%eax, %eax
	cmovnsl	%eax, %edx
	sarl	$2, %edx
	addl	%edx, %edi
	movl	%edi, (%rsi)
LBB0_31:
	addl	$60, %edi
	movl	%edi, (%rsi)
	cmpl	$1, (%r8)
	movl	$760, %eax                      ## imm = 0x2F8
	movl	$508, %edx                      ## imm = 0x1FC
	cmovel	%eax, %edx
	addl	(%rcx), %edx
	movl	%edx, 4(%rsi)
LBB0_32:
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	retq
LBB0_14:
	movq	_pico_pen_y@GOTPCREL(%rip), %rdx
	decl	(%rdx)
	movl	(%rcx), %edx
	testb	$2, %dl
	je	LBB0_17
LBB0_16:
	movq	_pico_pen_y@GOTPCREL(%rip), %rdx
	incl	(%rdx)
	movl	(%rcx), %edx
	testb	$4, %dl
	je	LBB0_19
LBB0_18:
	movq	_pico_pen_x@GOTPCREL(%rip), %rdx
	decl	(%rdx)
	movl	(%rcx), %edx
	testb	$8, %dl
	jne	LBB0_20
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.comm	_PEV_PICO_SWINP,4,2             ## @PEV_PICO_SWINP
	.comm	_pico_inp_mode,4,2              ## @pico_inp_mode
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Input: Pen on Pad"

L_.str.1:                               ## @.str.1
	.asciz	"Input: Pen on Storyware"

L_.str.2:                               ## @.str.2
	.asciz	"Input: Joystick"

	.comm	_PicoPicohw,16,3                ## @PicoPicohw
	.comm	_PEV_PICO_PPREV,4,2             ## @PEV_PICO_PPREV
L_.str.3:                               ## @.str.3
	.asciz	"Page %i"

	.comm	_PEV_PICO_PNEXT,4,2             ## @PEV_PICO_PNEXT
	.comm	_PicoPad,8,3                    ## @PicoPad
	.comm	_pico_pen_y,4,2                 ## @pico_pen_y
	.comm	_pico_pen_x,4,2                 ## @pico_pen_x
	.comm	_Pico,8,3                       ## @Pico
	.comm	_PICO_PEN_ADJUST_Y,4,2          ## @PICO_PEN_ADJUST_Y
	.comm	_PICO_PEN_ADJUST_X,4,2          ## @PICO_PEN_ADJUST_X
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_run_events_pico                ; -- Begin function run_events_pico
	.p2align	2
_run_events_pico:                       ; @run_events_pico
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.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
	mov	x19, x0
Lloh0:
	adrp	x8, _PEV_PICO_SWINP@GOTPAGE
Lloh1:
	ldr	x8, [x8, _PEV_PICO_SWINP@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
Lloh3:
	adrp	x20, _pico_inp_mode@GOTPAGE
Lloh4:
	ldr	x20, [x20, _pico_inp_mode@GOTPAGEOFF]
	tst	w8, w0
	b.eq	LBB0_8
; %bb.1:
	ldr	w8, [x20]
	cmp	w8, #1
	csinc	w8, wzr, w8, gt
	str	w8, [x20]
	cbz	w8, LBB0_5
; %bb.2:
	cmp	w8, #1
	b.eq	LBB0_6
; %bb.3:
	cmp	w8, #2
	b.ne	LBB0_8
; %bb.4:
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	b	LBB0_7
LBB0_5:
Lloh7:
	adrp	x0, l_.str.2@PAGE
Lloh8:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_emu_status_msg
Lloh9:
	adrp	x8, _PicoPicohw@GOTPAGE
Lloh10:
	ldr	x8, [x8, _PicoPicohw@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	movi.2s	v0, #128, lsl #8
	str	d0, [x8]
	b	LBB0_8
LBB0_6:
Lloh12:
	adrp	x0, l_.str.1@PAGE
Lloh13:
	add	x0, x0, l_.str.1@PAGEOFF
LBB0_7:
	bl	_emu_status_msg
LBB0_8:
Lloh14:
	adrp	x8, _PEV_PICO_PPREV@GOTPAGE
Lloh15:
	ldr	x8, [x8, _PEV_PICO_PPREV@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	tst	w8, w19
	b.eq	LBB0_10
; %bb.9:
Lloh17:
	adrp	x8, _PicoPicohw@GOTPAGE
Lloh18:
	ldr	x8, [x8, _PicoPicohw@GOTPAGEOFF]
	ldr	w9, [x8, #8]
	cmp	w9, #1
	csinc	w9, w9, wzr, gt
	sub	w9, w9, #1
	str	w9, [x8, #8]
	str	x9, [sp]
Lloh19:
	adrp	x0, l_.str.3@PAGE
Lloh20:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_emu_status_msg
LBB0_10:
Lloh21:
	adrp	x8, _PEV_PICO_PNEXT@GOTPAGE
Lloh22:
	ldr	x8, [x8, _PEV_PICO_PNEXT@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
	tst	w8, w19
	b.eq	LBB0_12
; %bb.11:
Lloh24:
	adrp	x8, _PicoPicohw@GOTPAGE
Lloh25:
	ldr	x8, [x8, _PicoPicohw@GOTPAGEOFF]
	ldr	w9, [x8, #8]
	mov	w10, #5
	cmp	w9, #5
	csel	w9, w9, w10, lt
	add	w9, w9, #1
	str	w9, [x8, #8]
	str	x9, [sp]
Lloh26:
	adrp	x0, l_.str.3@PAGE
Lloh27:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_emu_status_msg
LBB0_12:
	ldr	w8, [x20]
	cbz	w8, LBB0_32
; %bb.13:
Lloh28:
	adrp	x8, _PicoPad@GOTPAGE
Lloh29:
	ldr	x8, [x8, _PicoPad@GOTPAGEOFF]
Lloh30:
	ldr	x10, [x8]
	ldr	w11, [x10]
Lloh31:
	adrp	x8, _pico_pen_y@GOTPAGE
Lloh32:
	ldr	x8, [x8, _pico_pen_y@GOTPAGEOFF]
	tbz	w11, #0, LBB0_15
; %bb.14:
	ldr	w9, [x8]
	sub	w9, w9, #1
	str	w9, [x8]
	ldr	w11, [x10]
LBB0_15:
	tbz	w11, #1, LBB0_17
; %bb.16:
	ldr	w9, [x8]
	add	w9, w9, #1
	str	w9, [x8]
	ldr	w11, [x10]
LBB0_17:
Lloh33:
	adrp	x9, _pico_pen_x@GOTPAGE
Lloh34:
	ldr	x9, [x9, _pico_pen_x@GOTPAGEOFF]
	tbz	w11, #2, LBB0_19
; %bb.18:
	ldr	w11, [x9]
	sub	w11, w11, #1
	str	w11, [x9]
	ldr	w11, [x10]
LBB0_19:
	tbz	w11, #3, LBB0_21
; %bb.20:
	ldr	w11, [x9]
	add	w11, w11, #1
	str	w11, [x9]
	ldr	w11, [x10]
LBB0_21:
	and	w11, w11, #0xfffffff0
	str	w11, [x10]
Lloh35:
	adrp	x10, _Pico@GOTPAGE
Lloh36:
	ldr	x10, [x10, _Pico@GOTPAGEOFF]
Lloh37:
	ldr	x10, [x10]
	ldrb	w11, [x10, #48]
	tst	w11, #0x1
	mov	w11, #319
	mov	w12, #255
	csel	w12, w12, w11, eq
	ldr	w11, [x8]
	cmp	w11, #7
	b.gt	LBB0_23
; %bb.22:
	mov	w11, #8
	str	w11, [x8]
LBB0_23:
Lloh38:
	adrp	x13, _PICO_PEN_ADJUST_Y@GOTPAGE
Lloh39:
	ldr	x13, [x13, _PICO_PEN_ADJUST_Y@GOTPAGEOFF]
Lloh40:
	ldr	w13, [x13]
	mov	w14, #224
	sub	w13, w14, w13
	cmp	w11, w13
	b.le	LBB0_25
; %bb.24:
	str	w13, [x8]
LBB0_25:
	ldr	w11, [x9]
	tbz	w11, #31, LBB0_27
; %bb.26:
	mov	w11, #0
	str	wzr, [x9]
LBB0_27:
Lloh41:
	adrp	x13, _PICO_PEN_ADJUST_X@GOTPAGE
Lloh42:
	ldr	x13, [x13, _PICO_PEN_ADJUST_X@GOTPAGEOFF]
Lloh43:
	ldr	w13, [x13]
	sub	w12, w12, w13
	cmp	w11, w12
	b.le	LBB0_29
; %bb.28:
	str	w12, [x9]
	mov	x11, x12
LBB0_29:
Lloh44:
	adrp	x12, _PicoPicohw@GOTPAGE
Lloh45:
	ldr	x12, [x12, _PicoPicohw@GOTPAGEOFF]
Lloh46:
	ldr	x12, [x12]
	str	w11, [x12]
	ldrb	w10, [x10, #48]
	tbnz	w10, #0, LBB0_31
; %bb.30:
	ldr	w9, [x9]
	add	w10, w9, #3
	cmp	w9, #0
	csel	w9, w10, w9, lt
	add	w11, w11, w9, asr #2
	str	w11, [x12]
LBB0_31:
	add	w9, w11, #60
	str	w9, [x12]
	ldr	w9, [x20]
	ldr	w8, [x8]
	mov	w10, #508
	mov	w11, #760
	cmp	w9, #1
	csel	w9, w11, w10, eq
	add	w8, w9, w8
	str	w8, [x12, #4]
LBB0_32:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh41, Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh44, Lloh45, Lloh46
	.cfi_endproc
                                        ; -- End function
	.comm	_PEV_PICO_SWINP,4,2             ; @PEV_PICO_SWINP
	.comm	_pico_inp_mode,4,2              ; @pico_inp_mode
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Input: Pen on Pad"

l_.str.1:                               ; @.str.1
	.asciz	"Input: Pen on Storyware"

l_.str.2:                               ; @.str.2
	.asciz	"Input: Joystick"

	.comm	_PicoPicohw,16,3                ; @PicoPicohw
	.comm	_PEV_PICO_PPREV,4,2             ; @PEV_PICO_PPREV
l_.str.3:                               ; @.str.3
	.asciz	"Page %i"

	.comm	_PEV_PICO_PNEXT,4,2             ; @PEV_PICO_PNEXT
	.comm	_PicoPad,8,3                    ; @PicoPad
	.comm	_pico_pen_y,4,2                 ; @pico_pen_y
	.comm	_pico_pen_x,4,2                 ; @pico_pen_x
	.comm	_Pico,8,3                       ; @Pico
	.comm	_PICO_PEN_ADJUST_Y,4,2          ; @PICO_PEN_ADJUST_Y
	.comm	_PICO_PEN_ADJUST_X,4,2          ; @PICO_PEN_ADJUST_X
.subsections_via_symbols
