	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_CARTRIDGE_StateRead            ## -- Begin function CARTRIDGE_StateRead
	.p2align	4, 0x90
_CARTRIDGE_StateRead:                   ## @CARTRIDGE_StateRead
	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edi, %r14d
	movq	%rsp, %r15
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	_CARTRIDGE_NONE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %eax
	movl	%eax, -52(%rbp)
	movq	_FILENAME_MAX@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	callq	____chkstk_darwin
	addq	$15, %rax
	andq	$-16, %rax
	subq	%rax, %rsp
	movq	%rsp, %r13
	leaq	-52(%rbp), %rdi
	movl	$1, %esi
	callq	_StateSav_ReadINT
	movl	-52(%rbp), %eax
	cmpl	(%rbx), %eax
	jne	LBB0_1
## %bb.22:
	movq	_CARTRIDGE_main@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	testl	%eax, %eax
	jns	LBB0_13
	jmp	LBB0_8
LBB0_1:
	movq	%r13, %rdi
	callq	_StateSav_ReadFNAME
	cmpb	$0, (%r13)
	je	LBB0_4
## %bb.2:
	movq	%r13, %rdi
	callq	_CARTRIDGE_Insert
	testq	%rax, %rax
	js	LBB0_4
## %bb.3:
	movl	-52(%rbp), %eax
	movq	_CARTRIDGE_main@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
LBB0_4:
	cmpl	$7, %r14d
	jl	LBB0_6
## %bb.5:
	movq	_CARTRIDGE_main@GOTPCREL(%rip), %rdi
	addq	$4, %rdi
	movl	$1, %esi
	callq	_StateSav_ReadINT
LBB0_6:
	movl	-52(%rbp), %eax
	testl	%eax, %eax
	jns	LBB0_13
LBB0_8:
	negl	%eax
	movq	_CARTRIDGE_main@GOTPCREL(%rip), %r12
	movl	%eax, (%r12)
	leaq	-52(%rbp), %rdi
	movl	$1, %esi
	callq	_StateSav_ReadINT
	movq	%r13, %rdi
	callq	_StateSav_ReadFNAME
	cmpb	$0, (%r13)
	je	LBB0_11
## %bb.9:
	movq	%r13, %rdi
	callq	_CARTRIDGE_Insert_Second
	testq	%rax, %rax
	js	LBB0_11
## %bb.10:
	movl	-52(%rbp), %eax
	movq	_CARTRIDGE_piggyback@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
LBB0_11:
	cmpl	$7, %r14d
	jl	LBB0_17
## %bb.12:
	movq	_CARTRIDGE_piggyback@GOTPCREL(%rip), %rdi
	addq	$4, %rdi
	movl	$1, %esi
	callq	_StateSav_ReadINT
LBB0_13:
	movq	_CARTRIDGE_main@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edi
	callq	_CartIsPassthrough
	testq	%rax, %rax
	je	LBB0_16
## %bb.14:
	movl	4(%rbx), %eax
	andl	$12, %eax
	cmpl	$8, %eax
	jne	LBB0_16
## %bb.15:
	movq	_CARTRIDGE_piggyback@GOTPCREL(%rip), %rbx
LBB0_16:
	movq	_active_cart@GOTPCREL(%rip), %rax
	movq	%rbx, (%rax)
	xorl	%eax, %eax
	callq	_MapActiveCart
LBB0_20:
	movq	%r15, %rsp
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_23
## %bb.21:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_17:
	leaq	-56(%rbp), %rdi
	movl	$1, %esi
	callq	_StateSav_ReadINT
	cmpl	$0, -56(%rbp)
	je	LBB0_19
## %bb.18:
	movq	_CARTRIDGE_piggyback@GOTPCREL(%rip), %r12
LBB0_19:
	movq	_active_cart@GOTPCREL(%rip), %rax
	movq	%r12, (%rax)
	jmp	LBB0_20
LBB0_23:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_CARTRIDGE_NONE,4,2             ## @CARTRIDGE_NONE
	.comm	_FILENAME_MAX,4,2               ## @FILENAME_MAX
	.comm	_CARTRIDGE_main,8,2             ## @CARTRIDGE_main
	.comm	_CARTRIDGE_piggyback,8,2        ## @CARTRIDGE_piggyback
	.comm	_active_cart,8,3                ## @active_cart
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_CARTRIDGE_StateRead            ; -- Begin function CARTRIDGE_StateRead
	.p2align	2
_CARTRIDGE_StateRead:                   ; @CARTRIDGE_StateRead
	.cfi_startproc
; %bb.0:
	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
	sub	sp, sp, #16
	mov	x19, x0
	mov	x21, sp
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
Lloh3:
	adrp	x22, _CARTRIDGE_NONE@GOTPAGE
Lloh4:
	ldr	x22, [x22, _CARTRIDGE_NONE@GOTPAGEOFF]
	stur	x8, [x29, #-40]
	ldr	w8, [x22]
	stur	w8, [x29, #-44]
Lloh5:
	adrp	x8, _FILENAME_MAX@GOTPAGE
Lloh6:
	ldr	x8, [x8, _FILENAME_MAX@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	mov	x9, x8
Lloh8:
	adrp	x16, ___chkstk_darwin@GOTPAGE
Lloh9:
	ldr	x16, [x16, ___chkstk_darwin@GOTPAGEOFF]
	blr	x16
	mov	x9, sp
	add	x8, x8, #15
	and	x8, x8, #0x1fffffff0
	sub	x20, x9, x8
	mov	sp, x20
	sub	x0, x29, #44
	mov	w1, #1
	bl	_StateSav_ReadINT
	ldur	w8, [x29, #-44]
	ldr	w9, [x22]
Lloh10:
	adrp	x22, _CARTRIDGE_main@GOTPAGE
Lloh11:
	ldr	x22, [x22, _CARTRIDGE_main@GOTPAGEOFF]
	cmp	w8, w9
	b.ne	LBB0_2
; %bb.1:
	str	w8, [x22]
	tbz	w8, #31, LBB0_13
	b	LBB0_8
LBB0_2:
	mov	x0, x20
	bl	_StateSav_ReadFNAME
	ldrb	w8, [x20]
	cbz	w8, LBB0_5
; %bb.3:
	mov	x0, x20
	bl	_CARTRIDGE_Insert
	tbnz	x0, #63, LBB0_5
; %bb.4:
	ldur	w8, [x29, #-44]
	str	w8, [x22]
LBB0_5:
	cmp	w19, #7
	b.lt	LBB0_7
; %bb.6:
	add	x0, x22, #4
	mov	w1, #1
	bl	_StateSav_ReadINT
LBB0_7:
	ldur	w8, [x29, #-44]
	tbz	w8, #31, LBB0_13
LBB0_8:
	neg	w8, w8
	str	w8, [x22]
	sub	x0, x29, #44
	mov	w1, #1
	bl	_StateSav_ReadINT
	mov	x0, x20
	bl	_StateSav_ReadFNAME
	ldrb	w8, [x20]
	cbz	w8, LBB0_11
; %bb.9:
	mov	x0, x20
	bl	_CARTRIDGE_Insert_Second
	tbnz	x0, #63, LBB0_11
; %bb.10:
	ldur	w8, [x29, #-44]
Lloh12:
	adrp	x9, _CARTRIDGE_piggyback@GOTPAGE
Lloh13:
	ldr	x9, [x9, _CARTRIDGE_piggyback@GOTPAGEOFF]
Lloh14:
	str	w8, [x9]
LBB0_11:
	cmp	w19, #7
	b.lt	LBB0_20
; %bb.12:
Lloh15:
	adrp	x8, _CARTRIDGE_piggyback@GOTPAGE
Lloh16:
	ldr	x8, [x8, _CARTRIDGE_piggyback@GOTPAGEOFF]
	add	x0, x8, #4
	mov	w1, #1
	bl	_StateSav_ReadINT
LBB0_13:
	ldr	w0, [x22]
	bl	_CartIsPassthrough
	cbz	x0, LBB0_16
; %bb.14:
	ldr	w8, [x22, #4]
	and	w8, w8, #0xc
	cmp	w8, #8
	b.ne	LBB0_16
; %bb.15:
Lloh17:
	adrp	x8, _CARTRIDGE_piggyback@GOTPAGE
Lloh18:
	ldr	x8, [x8, _CARTRIDGE_piggyback@GOTPAGEOFF]
	b	LBB0_17
LBB0_16:
Lloh19:
	adrp	x8, _CARTRIDGE_main@GOTPAGE
Lloh20:
	ldr	x8, [x8, _CARTRIDGE_main@GOTPAGEOFF]
LBB0_17:
Lloh21:
	adrp	x9, _active_cart@GOTPAGE
Lloh22:
	ldr	x9, [x9, _active_cart@GOTPAGEOFF]
Lloh23:
	str	x8, [x9]
	bl	_MapActiveCart
LBB0_18:
	mov	sp, x21
	ldur	x8, [x29, #-40]
Lloh24:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh25:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh26:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_21
; %bb.19:
	sub	sp, x29, #32
	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
	ret
LBB0_20:
	sub	x0, x29, #48
	mov	w1, #1
	bl	_StateSav_ReadINT
Lloh27:
	adrp	x8, _CARTRIDGE_piggyback@GOTPAGE
Lloh28:
	ldr	x8, [x8, _CARTRIDGE_piggyback@GOTPAGEOFF]
	ldur	w9, [x29, #-48]
	cmp	w9, #0
	csel	x8, x22, x8, eq
Lloh29:
	adrp	x9, _active_cart@GOTPAGE
Lloh30:
	ldr	x9, [x9, _active_cart@GOTPAGEOFF]
Lloh31:
	str	x8, [x9]
	b	LBB0_18
LBB0_21:
	bl	___stack_chk_fail
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotStr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGotStr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotStr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh27, Lloh28
	.cfi_endproc
                                        ; -- End function
	.comm	_CARTRIDGE_NONE,4,2             ; @CARTRIDGE_NONE
	.comm	_FILENAME_MAX,4,2               ; @FILENAME_MAX
	.comm	_CARTRIDGE_main,8,2             ; @CARTRIDGE_main
	.comm	_CARTRIDGE_piggyback,8,2        ; @CARTRIDGE_piggyback
	.comm	_active_cart,8,3                ; @active_cart
.subsections_via_symbols
