	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function savestate_menu_loop
_savestate_menu_loop:                   ## @savestate_menu_loop
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edi, %ebx
	xorl	%r14d, %r14d
	xorl	%eax, %eax
	callq	_state_check_slots
	movq	_PBTN_DOWN@GOTPCREL(%rip), %r15
	movq	_PBTN_STOP@GOTPCREL(%rip), %r13
	movl	$10, %r12d
	.p2align	4, 0x90
LBB0_1:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_3 Depth 2
                                        ##     Child Loop BB0_9 Depth 2
	movl	_savestate_menu_loop.menu_sel(%rip), %edi
	movl	%ebx, %esi
	callq	_draw_savestate_menu
	movq	(%r15), %rdi
	movq	_PBTN_UP@GOTPCREL(%rip), %r15
	orq	(%r15), %rdi
	movq	_PBTN_PLAY@GOTPCREL(%rip), %rax
	orq	(%rax), %rdi
	orq	(%r13), %rdi
	callq	_in_menu_wait
	testq	%rax, (%r15)
	je	LBB0_7
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	_state_slot_flags@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	_savestate_menu_loop.menu_sel(%rip), %edx
	.p2align	4, 0x90
LBB0_3:                                 ##   Parent Loop BB0_1 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	testl	%edx, %edx
	leal	-1(%rdx), %edx
                                        ## kill: def $edx killed $edx def $rdx
	cmovlel	%r12d, %edx
	btl	%edx, %ecx
	jb	LBB0_6
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=2
	testl	%ebx, %ebx
	je	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_3 Depth=2
	cmpl	$10, %edx
	jne	LBB0_3
LBB0_6:                                 ##   in Loop: Header=BB0_1 Depth=1
	movl	%edx, _savestate_menu_loop.menu_sel(%rip)
LBB0_7:                                 ##   in Loop: Header=BB0_1 Depth=1
	movq	_PBTN_DOWN@GOTPCREL(%rip), %r15
	testq	%rax, (%r15)
	je	LBB0_13
## %bb.8:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	_state_slot_flags@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	_savestate_menu_loop.menu_sel(%rip), %edx
	.p2align	4, 0x90
LBB0_9:                                 ##   Parent Loop BB0_1 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	cmpl	$10, %edx
	leal	1(%rdx), %edx
                                        ## kill: def $edx killed $edx def $rdx
	cmovgel	%r14d, %edx
	btl	%edx, %ecx
	jb	LBB0_12
## %bb.10:                              ##   in Loop: Header=BB0_9 Depth=2
	testl	%ebx, %ebx
	je	LBB0_12
## %bb.11:                              ##   in Loop: Header=BB0_9 Depth=2
	cmpl	$10, %edx
	jne	LBB0_9
LBB0_12:                                ##   in Loop: Header=BB0_1 Depth=1
	movl	%edx, _savestate_menu_loop.menu_sel(%rip)
LBB0_13:                                ##   in Loop: Header=BB0_1 Depth=1
	movq	_PBTN_PLAY@GOTPCREL(%rip), %rcx
	testq	%rax, (%rcx)
	jne	LBB0_14
## %bb.17:                              ##   in Loop: Header=BB0_1 Depth=1
	movq	_PBTN_STOP@GOTPCREL(%rip), %r13
	testq	%rax, (%r13)
	je	LBB0_1
	jmp	LBB0_18
LBB0_14:
	movl	_savestate_menu_loop.menu_sel(%rip), %eax
	movl	$1, %r14d
	cmpl	$9, %eax
	jg	LBB0_19
## %bb.15:
	movq	_state_slot@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	movq	_emu_stateCb@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	_PicoStateProgressCB@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	xorl	%r14d, %r14d
	movl	%ebx, %edi
	xorl	%esi, %esi
	callq	_emu_SaveLoadGame
	testq	%rax, %rax
	je	LBB0_19
## %bb.16:
	movq	_menuErrorMsg@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	testl	%ebx, %ebx
	leaq	L_.str.1(%rip), %rax
	leaq	L_.str(%rip), %rsi
	cmoveq	%rax, %rsi
	callq	_strcpy
LBB0_18:
	movl	$1, %r14d
LBB0_19:
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__DATA,__data
	.p2align	2                               ## @savestate_menu_loop.menu_sel
_savestate_menu_loop.menu_sel:
	.long	10                              ## 0xa

	.comm	_PBTN_UP,8,3                    ## @PBTN_UP
	.comm	_PBTN_DOWN,8,3                  ## @PBTN_DOWN
	.comm	_PBTN_PLAY,8,3                  ## @PBTN_PLAY
	.comm	_PBTN_STOP,8,3                  ## @PBTN_STOP
	.comm	_state_slot_flags,4,2           ## @state_slot_flags
	.comm	_state_slot,4,2                 ## @state_slot
	.comm	_emu_stateCb,4,2                ## @emu_stateCb
	.comm	_PicoStateProgressCB,4,2        ## @PicoStateProgressCB
	.comm	_menuErrorMsg,4,2               ## @menuErrorMsg
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Load failed"

L_.str.1:                               ## @.str.1
	.asciz	"Save failed"

	.no_dead_strip	_savestate_menu_loop
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function savestate_menu_loop
_savestate_menu_loop:                   ; @savestate_menu_loop
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x19, x0
	bl	_state_check_slots
Lloh0:
	adrp	x20, _PBTN_UP@GOTPAGE
Lloh1:
	ldr	x20, [x20, _PBTN_UP@GOTPAGEOFF]
Lloh2:
	adrp	x21, _PBTN_DOWN@GOTPAGE
Lloh3:
	ldr	x21, [x21, _PBTN_DOWN@GOTPAGEOFF]
Lloh4:
	adrp	x23, _PBTN_PLAY@GOTPAGE
Lloh5:
	ldr	x23, [x23, _PBTN_PLAY@GOTPAGEOFF]
	adrp	x22, _savestate_menu_loop.menu_sel@PAGE
Lloh6:
	adrp	x24, _PBTN_STOP@GOTPAGE
Lloh7:
	ldr	x24, [x24, _PBTN_STOP@GOTPAGEOFF]
	mov	w25, #10
Lloh8:
	adrp	x26, _state_slot_flags@GOTPAGE
Lloh9:
	ldr	x26, [x26, _state_slot_flags@GOTPAGEOFF]
LBB0_1:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
                                        ;     Child Loop BB0_9 Depth 2
	ldr	w0, [x22, _savestate_menu_loop.menu_sel@PAGEOFF]
	mov	x1, x19
	bl	_draw_savestate_menu
	ldr	x8, [x20]
	ldr	x9, [x21]
	orr	x8, x9, x8
	ldr	x9, [x23]
	orr	x8, x8, x9
	ldr	x9, [x24]
	orr	x0, x8, x9
	bl	_in_menu_wait
	ldr	x8, [x20]
	tst	x8, x0
	b.eq	LBB0_7
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	ldr	w8, [x26]
	ldr	w9, [x22, _savestate_menu_loop.menu_sel@PAGEOFF]
LBB0_3:                                 ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	subs	w9, w9, #1
	csel	w9, w25, w9, lt
	lsr	w10, w8, w9
	tbnz	w10, #0, LBB0_6
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=2
	cbz	w19, LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_3 Depth=2
	cmp	w9, #10
	b.ne	LBB0_3
LBB0_6:                                 ;   in Loop: Header=BB0_1 Depth=1
	str	w9, [x22, _savestate_menu_loop.menu_sel@PAGEOFF]
LBB0_7:                                 ;   in Loop: Header=BB0_1 Depth=1
	ldr	x8, [x21]
	tst	x8, x0
	b.eq	LBB0_13
; %bb.8:                                ;   in Loop: Header=BB0_1 Depth=1
	ldr	w9, [x26]
	ldr	w8, [x22, _savestate_menu_loop.menu_sel@PAGEOFF]
LBB0_9:                                 ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	cmp	w8, #9
	csinc	w8, wzr, w8, gt
	lsr	w10, w9, w8
	tbnz	w10, #0, LBB0_12
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=2
	cbz	w19, LBB0_12
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=2
	cmp	w8, #10
	b.ne	LBB0_9
LBB0_12:                                ;   in Loop: Header=BB0_1 Depth=1
	str	w8, [x22, _savestate_menu_loop.menu_sel@PAGEOFF]
LBB0_13:                                ;   in Loop: Header=BB0_1 Depth=1
	ldr	x8, [x23]
	tst	x8, x0
	b.ne	LBB0_15
; %bb.14:                               ;   in Loop: Header=BB0_1 Depth=1
	ldr	x8, [x24]
	tst	x8, x0
	b.eq	LBB0_1
	b	LBB0_18
LBB0_15:
	ldr	w8, [x22, _savestate_menu_loop.menu_sel@PAGEOFF]
	cmp	w8, #9
	b.gt	LBB0_18
; %bb.16:
Lloh10:
	adrp	x9, _state_slot@GOTPAGE
Lloh11:
	ldr	x9, [x9, _state_slot@GOTPAGEOFF]
Lloh12:
	str	w8, [x9]
Lloh13:
	adrp	x8, _emu_stateCb@GOTPAGE
Lloh14:
	ldr	x8, [x8, _emu_stateCb@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
Lloh16:
	adrp	x9, _PicoStateProgressCB@GOTPAGE
Lloh17:
	ldr	x9, [x9, _PicoStateProgressCB@GOTPAGEOFF]
Lloh18:
	str	w8, [x9]
	mov	x0, x19
	mov	w1, #0
	bl	_emu_SaveLoadGame
	cbz	x0, LBB0_19
; %bb.17:
Lloh19:
	adrp	x8, _menuErrorMsg@GOTPAGE
Lloh20:
	ldr	x8, [x8, _menuErrorMsg@GOTPAGEOFF]
Lloh21:
	ldr	w0, [x8]
Lloh22:
	adrp	x8, l_.str@PAGE
Lloh23:
	add	x8, x8, l_.str@PAGEOFF
Lloh24:
	adrp	x9, l_.str.1@PAGE
Lloh25:
	add	x9, x9, l_.str.1@PAGEOFF
	cmp	w19, #0
	csel	x1, x9, x8, eq
	bl	_strcpy
LBB0_18:
	mov	w0, #1
LBB0_19:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotStr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotStr	Lloh10, Lloh11, Lloh12
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.section	__DATA,__data
	.p2align	2                               ; @savestate_menu_loop.menu_sel
_savestate_menu_loop.menu_sel:
	.long	10                              ; 0xa

	.comm	_PBTN_UP,8,3                    ; @PBTN_UP
	.comm	_PBTN_DOWN,8,3                  ; @PBTN_DOWN
	.comm	_PBTN_PLAY,8,3                  ; @PBTN_PLAY
	.comm	_PBTN_STOP,8,3                  ; @PBTN_STOP
	.comm	_state_slot_flags,4,2           ; @state_slot_flags
	.comm	_state_slot,4,2                 ; @state_slot
	.comm	_emu_stateCb,4,2                ; @emu_stateCb
	.comm	_PicoStateProgressCB,4,2        ; @PicoStateProgressCB
	.comm	_menuErrorMsg,4,2               ; @menuErrorMsg
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Load failed"

l_.str.1:                               ; @.str.1
	.asciz	"Save failed"

	.no_dead_strip	_savestate_menu_loop
.subsections_via_symbols
