	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_emu_save_load_game             ## -- Begin function emu_save_load_game
	.p2align	4, 0x90
_emu_save_load_game:                    ## @emu_save_load_game
	.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	%esi, %ebx
	movl	%edi, %r13d
	movq	_state_slot@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%ecx, %ecx
	callq	_emu_get_save_fname
	testq	%rax, %rax
	je	LBB0_6
## %bb.1:
	movq	%rax, %r15
	leaq	L_.str.2(%rip), %rdi
	movl	%r13d, %esi
	movl	%ebx, %edx
	movq	%rax, %rcx
	callq	_lprintf
	testl	%ebx, %ebx
	je	LBB0_8
## %bb.2:
	movq	_PicoAHW@GOTPCREL(%rip), %rbx
	movq	_PAHW_MCD@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rbx)
	je	LBB0_10
## %bb.3:
	movq	_PicoOpt@GOTPCREL(%rip), %rax
	movq	_POPT_EN_MCD_RAMCART@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, (%rax)
	je	LBB0_11
## %bb.4:
	movq	_SRam@GOTPCREL(%rip), %rax
	movq	(%rax), %r14
	testq	%r14, %r14
	je	LBB0_24
## %bb.5:
	movq	_Pico_mcd@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	(%rax), %rsi
	movq	%r14, %rdi
	movl	$2048, %edx                     ## imm = 0x800
	callq	_memcpy32
	movl	$73728, %r12d                   ## imm = 0x12000
	leaq	L_.str.4(%rip), %rsi
	jmp	LBB0_13
LBB0_6:
	movl	$-1, %r15d
	testl	%ebx, %ebx
	jne	LBB0_30
## %bb.7:
	testl	%r13d, %r13d
	leaq	L_.str.1(%rip), %rax
	leaq	L_.str(%rip), %rdi
	cmoveq	%rax, %rdi
	callq	_emu_status_msg
	jmp	LBB0_30
LBB0_8:
	xorl	%esi, %esi
	testl	%r13d, %r13d
	sete	%sil
	movq	%r15, %rdi
	callq	_PicoState
	testl	%eax, %eax
	je	LBB0_22
## %bb.9:
	testl	%r13d, %r13d
	leaq	L_.str.1(%rip), %rax
	leaq	L_.str.8(%rip), %rdi
	cmoveq	%rax, %rdi
	callq	_emu_status_msg
	jmp	LBB0_29
LBB0_10:
	movq	_SRam@GOTPCREL(%rip), %rax
	movl	8(%rax), %r12d
	leaq	L_.str.4(%rip), %rsi
	jmp	LBB0_12
LBB0_11:
	movq	_Pico_mcd@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	leaq	L_.str.5(%rip), %rsi
	movl	$8192, %r12d                    ## imm = 0x2000
LBB0_12:
	movq	(%rax), %r14
	testq	%r14, %r14
	je	LBB0_24
LBB0_13:
	testl	%r13d, %r13d
	je	LBB0_18
## %bb.14:
	movq	%rbx, %r13
	leaq	L_.str.3(%rip), %rsi
	movq	%r15, %rdi
	callq	_fopen
	testq	%rax, %rax
	je	LBB0_29
## %bb.15:
	movq	%rax, %rbx
	movq	%r14, %rdi
	movl	$1, %esi
	movl	%r12d, %edx
	movq	%rax, %rcx
	callq	_fread
	xorl	%r15d, %r15d
	testl	%eax, %eax
	setle	%r15b
	negl	%r15d
	movq	%rbx, %rdi
	callq	_fclose
	movq	_PAHW_MCD@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r13)
	je	LBB0_30
## %bb.16:
	movq	_PicoOpt@GOTPCREL(%rip), %rax
	movq	_POPT_EN_MCD_RAMCART@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, (%rax)
	je	LBB0_30
## %bb.17:
	movq	_Pico_mcd@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	(%rax), %rdi
	movq	%r14, %rsi
	movl	$2048, %edx                     ## imm = 0x800
	callq	_memcpy32
	jmp	LBB0_30
LBB0_18:
	movl	%r12d, %ebx
	.p2align	4, 0x90
LBB0_19:                                ## =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	jle	LBB0_25
## %bb.20:                              ##   in Loop: Header=BB0_19 Depth=1
	leaq	-1(%rbx), %rax
	cmpb	$0, -1(%r14,%rbx)
	movq	%rax, %rbx
	je	LBB0_19
## %bb.21:
	incl	%eax
	movl	%eax, %ebx
	jmp	LBB0_26
LBB0_22:
	testl	%r13d, %r13d
	leaq	L_.str.7(%rip), %rax
	leaq	L_.str.6(%rip), %rdi
	cmoveq	%rax, %rdi
	callq	_emu_status_msg
LBB0_24:
	xorl	%r15d, %r15d
	jmp	LBB0_30
LBB0_25:
	testl	%ebx, %ebx
	je	LBB0_24
LBB0_26:
	movq	%r15, %rdi
	callq	_fopen
	movq	%rax, %r12
	testq	%rax, %rax
	jne	LBB0_28
## %bb.27:
	leaq	L_.str.4(%rip), %rsi
	movq	%r15, %rdi
	callq	_fopen
	movq	%rax, %r12
	testq	%rax, %rax
	je	LBB0_29
LBB0_28:
	movq	%r14, %rdi
	movl	$1, %esi
	movl	%ebx, %edx
	movq	%r12, %rcx
	callq	_fwrite
	xorl	%r15d, %r15d
	cmpl	%ebx, %eax
	setne	%r15b
	negl	%r15d
	movq	%r12, %rdi
	callq	_fclose
	jmp	LBB0_30
LBB0_29:
	movl	$-1, %r15d
LBB0_30:
	movl	%r15d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_state_slot,4,2                 ## @state_slot
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"LOAD FAILED (missing file)"

L_.str.1:                               ## @.str.1
	.asciz	"SAVE FAILED"

L_.str.2:                               ## @.str.2
	.asciz	"saveLoad (%i, %i): %s\n"

	.comm	_PicoAHW,4,2                    ## @PicoAHW
	.comm	_PAHW_MCD,4,2                   ## @PAHW_MCD
	.comm	_PicoOpt,4,2                    ## @PicoOpt
	.comm	_POPT_EN_MCD_RAMCART,4,2        ## @POPT_EN_MCD_RAMCART
	.comm	_SRam,16,3                      ## @SRam
	.comm	_Pico_mcd,8,3                   ## @Pico_mcd
L_.str.3:                               ## @.str.3
	.asciz	"rb"

L_.str.4:                               ## @.str.4
	.asciz	"wb"

L_.str.5:                               ## @.str.5
	.asciz	"r+b"

L_.str.6:                               ## @.str.6
	.asciz	"STATE LOADED"

L_.str.7:                               ## @.str.7
	.asciz	"STATE SAVED"

L_.str.8:                               ## @.str.8
	.asciz	"LOAD FAILED"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_emu_save_load_game             ; -- Begin function emu_save_load_game
	.p2align	2
_emu_save_load_game:                    ; @emu_save_load_game
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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	x20, x1
	mov	x21, x0
Lloh0:
	adrp	x8, _state_slot@GOTPAGE
Lloh1:
	ldr	x8, [x8, _state_slot@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
	mov	x3, #0
	bl	_emu_get_save_fname
	cbz	x0, LBB0_6
; %bb.1:
	mov	x19, x0
Lloh3:
	adrp	x0, l_.str.2@PAGE
Lloh4:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x21
	mov	x2, x20
	mov	x3, x19
	bl	_lprintf
	cbz	w20, LBB0_8
; %bb.2:
Lloh5:
	adrp	x23, _PicoAHW@GOTPAGE
Lloh6:
	ldr	x23, [x23, _PicoAHW@GOTPAGEOFF]
	ldr	w8, [x23]
Lloh7:
	adrp	x24, _PAHW_MCD@GOTPAGE
Lloh8:
	ldr	x24, [x24, _PAHW_MCD@GOTPAGEOFF]
	ldr	w9, [x24]
	tst	w9, w8
	b.eq	LBB0_12
; %bb.3:
Lloh9:
	adrp	x8, _PicoOpt@GOTPAGE
Lloh10:
	ldr	x8, [x8, _PicoOpt@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
Lloh12:
	adrp	x9, _POPT_EN_MCD_RAMCART@GOTPAGE
Lloh13:
	ldr	x9, [x9, _POPT_EN_MCD_RAMCART@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_13
; %bb.4:
Lloh15:
	adrp	x8, _SRam@GOTPAGE
Lloh16:
	ldr	x8, [x8, _SRam@GOTPAGEOFF]
Lloh17:
	ldr	x20, [x8]
	cbz	x20, LBB0_24
; %bb.5:
Lloh18:
	adrp	x8, _Pico_mcd@GOTPAGE
Lloh19:
	ldr	x8, [x8, _Pico_mcd@GOTPAGEOFF]
Lloh20:
	ldr	x8, [x8]
	ldr	x1, [x8]
	mov	x0, x20
	mov	w2, #2048
	bl	_memcpy32
	mov	w22, #8192
	movk	w22, #1, lsl #16
Lloh21:
	adrp	x1, l_.str.4@PAGE
Lloh22:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_14
LBB0_6:
	cbnz	w20, LBB0_11
; %bb.7:
Lloh23:
	adrp	x8, l_.str@PAGE
Lloh24:
	add	x8, x8, l_.str@PAGEOFF
	b	LBB0_10
LBB0_8:
	cmp	w21, #0
	cset	w1, eq
	mov	x0, x19
	bl	_PicoState
	cbz	w0, LBB0_23
; %bb.9:
Lloh25:
	adrp	x8, l_.str.8@PAGE
Lloh26:
	add	x8, x8, l_.str.8@PAGEOFF
LBB0_10:
Lloh27:
	adrp	x9, l_.str.1@PAGE
Lloh28:
	add	x9, x9, l_.str.1@PAGEOFF
	cmp	w21, #0
	csel	x0, x9, x8, eq
	bl	_emu_status_msg
LBB0_11:
	mov	w19, #-1
	b	LBB0_29
LBB0_12:
Lloh29:
	adrp	x8, _SRam@GOTPAGE
Lloh30:
	ldr	x8, [x8, _SRam@GOTPAGEOFF]
	ldr	w22, [x8, #8]
Lloh31:
	adrp	x1, l_.str.4@PAGE
Lloh32:
	add	x1, x1, l_.str.4@PAGEOFF
	ldr	x20, [x8]
	cbnz	x20, LBB0_14
	b	LBB0_24
LBB0_13:
Lloh33:
	adrp	x8, _Pico_mcd@GOTPAGE
Lloh34:
	ldr	x8, [x8, _Pico_mcd@GOTPAGEOFF]
Lloh35:
	ldr	x8, [x8]
Lloh36:
	adrp	x1, l_.str.5@PAGE
Lloh37:
	add	x1, x1, l_.str.5@PAGEOFF
	mov	w22, #8192
	ldr	x20, [x8]
	cbz	x20, LBB0_24
LBB0_14:
	cbz	w21, LBB0_19
; %bb.15:
Lloh38:
	adrp	x1, l_.str.3@PAGE
Lloh39:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x19
	bl	_fopen
	cbz	x0, LBB0_11
; %bb.16:
	mov	x21, x0
	mov	x0, x20
	mov	w1, #1
	mov	x2, x22
	mov	x3, x21
	bl	_fread
	cmp	w0, #1
	csetm	w19, lt
	mov	x0, x21
	bl	_fclose
	ldr	w8, [x23]
	ldr	w9, [x24]
	tst	w9, w8
	b.eq	LBB0_29
; %bb.17:
Lloh40:
	adrp	x8, _PicoOpt@GOTPAGE
Lloh41:
	ldr	x8, [x8, _PicoOpt@GOTPAGEOFF]
Lloh42:
	ldr	w8, [x8]
Lloh43:
	adrp	x9, _POPT_EN_MCD_RAMCART@GOTPAGE
Lloh44:
	ldr	x9, [x9, _POPT_EN_MCD_RAMCART@GOTPAGEOFF]
Lloh45:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_29
; %bb.18:
Lloh46:
	adrp	x8, _Pico_mcd@GOTPAGE
Lloh47:
	ldr	x8, [x8, _Pico_mcd@GOTPAGEOFF]
Lloh48:
	ldr	x8, [x8]
	ldr	x0, [x8]
	mov	x1, x20
	mov	w2, #2048
	bl	_memcpy32
	b	LBB0_29
LBB0_19:
	mov	w21, w22
LBB0_20:                                ; =>This Inner Loop Header: Depth=1
	cmp	w21, #1
	b.lt	LBB0_25
; %bb.21:                               ;   in Loop: Header=BB0_20 Depth=1
	sub	x8, x21, #1
	add	x9, x20, x21
	ldurb	w9, [x9, #-1]
	mov	x21, x8
	cbz	w9, LBB0_20
; %bb.22:
	add	w21, w8, #1
	b	LBB0_26
LBB0_23:
Lloh49:
	adrp	x8, l_.str.6@PAGE
Lloh50:
	add	x8, x8, l_.str.6@PAGEOFF
Lloh51:
	adrp	x9, l_.str.7@PAGE
Lloh52:
	add	x9, x9, l_.str.7@PAGEOFF
	cmp	w21, #0
	csel	x0, x9, x8, eq
	bl	_emu_status_msg
LBB0_24:
	mov	w19, #0
	b	LBB0_29
LBB0_25:
	cbz	w21, LBB0_24
LBB0_26:
	mov	x0, x19
	bl	_fopen
	mov	x22, x0
	cbnz	x0, LBB0_28
; %bb.27:
Lloh53:
	adrp	x1, l_.str.4@PAGE
Lloh54:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x19
	bl	_fopen
	mov	x22, x0
	cbz	x0, LBB0_11
LBB0_28:
	mov	x0, x20
	mov	w1, #1
	mov	x2, x21
	mov	x3, x22
	bl	_fwrite
	cmp	w0, w21
	csetm	w19, ne
	mov	x0, x22
	bl	_fclose
LBB0_29:
	mov	x0, x19
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpAdd	Lloh31, Lloh32
	.loh AdrpLdrGot	Lloh29, Lloh30
	.loh AdrpAdd	Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpAdd	Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh43, Lloh44, Lloh45
	.loh AdrpLdrGotLdr	Lloh40, Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh46, Lloh47, Lloh48
	.loh AdrpAdd	Lloh51, Lloh52
	.loh AdrpAdd	Lloh49, Lloh50
	.loh AdrpAdd	Lloh53, Lloh54
	.cfi_endproc
                                        ; -- End function
	.comm	_state_slot,4,2                 ; @state_slot
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"LOAD FAILED (missing file)"

l_.str.1:                               ; @.str.1
	.asciz	"SAVE FAILED"

l_.str.2:                               ; @.str.2
	.asciz	"saveLoad (%i, %i): %s\n"

	.comm	_PicoAHW,4,2                    ; @PicoAHW
	.comm	_PAHW_MCD,4,2                   ; @PAHW_MCD
	.comm	_PicoOpt,4,2                    ; @PicoOpt
	.comm	_POPT_EN_MCD_RAMCART,4,2        ; @POPT_EN_MCD_RAMCART
	.comm	_SRam,16,3                      ; @SRam
	.comm	_Pico_mcd,8,3                   ; @Pico_mcd
l_.str.3:                               ; @.str.3
	.asciz	"rb"

l_.str.4:                               ; @.str.4
	.asciz	"wb"

l_.str.5:                               ; @.str.5
	.asciz	"r+b"

l_.str.6:                               ; @.str.6
	.asciz	"STATE LOADED"

l_.str.7:                               ; @.str.7
	.asciz	"STATE SAVED"

l_.str.8:                               ; @.str.8
	.asciz	"LOAD FAILED"

.subsections_via_symbols
