	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sms_cart_switch                ## -- Begin function sms_cart_switch
	.p2align	4, 0x90
_sms_cart_switch:                       ## @sms_cart_switch
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edi, %ebx
	movq	_slot@GOTPCREL(%rip), %rax
	movl	$0, (%rax)
	testb	$64, %bl
	jne	LBB0_1
## %bb.3:
	movq	_bios_rom@GOTPCREL(%rip), %r14
	movl	(%r14), %ecx
	testb	$8, %bl
	je	LBB0_8
## %bb.4:
	movq	_cart@GOTPCREL(%rip), %rdx
	movq	8(%rdx), %rdx
	cmpl	$2, %ecx
	jl	LBB0_7
## %bb.5:
	addq	$4194304, %rdx                  ## imm = 0x400000
	movq	%rdx, 16(%rax)
	movq	8(%r14), %rdx
	movq	%rdx, 8(%rax)
	movl	4(%r14), %edx
	jmp	LBB0_6
LBB0_1:
	movq	_cart_rom@GOTPCREL(%rip), %rdx
	movl	(%rdx), %ecx
	testl	%ecx, %ecx
	je	LBB0_11
## %bb.2:
	movq	_cart@GOTPCREL(%rip), %rsi
	movq	8(%rsi), %rsi
	movq	%rsi, 16(%rax)
	movq	8(%rdx), %rsi
	movq	%rsi, 8(%rax)
	movl	4(%rdx), %edx
LBB0_6:
	movl	%edx, 4(%rax)
	movl	%ecx, (%rax)
	jmp	LBB0_11
LBB0_7:
	movq	%rdx, 16(%rax)
	movq	_cart_rom@GOTPCREL(%rip), %rdx
	movups	(%rdx), %xmm0
	movups	%xmm0, (%rax)
LBB0_8:
	testl	%ecx, %ecx
	jne	LBB0_11
## %bb.9:
	movq	_cart@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	cmpl	$1048576, %edx                  ## imm = 0x100000
	jg	LBB0_11
## %bb.10:
	movq	8(%rax), %rsi
	leaq	4194304(%rsi), %rdi
	callq	_memcpy
	movq	8(%r14), %rdi
	movq	_cart_rom@GOTPCREL(%rip), %r15
	movq	8(%r15), %rsi
	movl	$4, %edx
	callq	_memcpy
	movq	(%r15), %rax
	movq	%rax, (%r14)
	movl	$0, (%r15)
LBB0_11:
	xorl	%eax, %eax
	callq	_mapper_reset
	andl	$72, %ebx
	cmpl	$8, %ebx
	jne	LBB0_14
## %bb.12:
	movq	_bios_rom@GOTPCREL(%rip), %rax
	cmpl	$1, (%rax)
	jne	LBB0_14
## %bb.13:
	movq	_cart@GOTPCREL(%rip), %rax
	movl	$4194304, %ecx                  ## imm = 0x400000
	addq	8(%rax), %rcx
	movq	_z80_readmap@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rcx, (%rax)
LBB0_14:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_slot,24,3                      ## @slot
	.comm	_cart_rom,16,3                  ## @cart_rom
	.comm	_cart,16,3                      ## @cart
	.comm	_bios_rom,16,3                  ## @bios_rom
	.comm	_z80_readmap,8,3                ## @z80_readmap
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sms_cart_switch                ; -- Begin function sms_cart_switch
	.p2align	2
_sms_cart_switch:                       ; @sms_cart_switch
	.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
	mov	x19, x0
Lloh0:
	adrp	x8, _slot@GOTPAGE
Lloh1:
	ldr	x8, [x8, _slot@GOTPAGEOFF]
	str	wzr, [x8]
Lloh2:
	adrp	x20, _bios_rom@GOTPAGE
Lloh3:
	ldr	x20, [x20, _bios_rom@GOTPAGEOFF]
	tbnz	w0, #6, LBB0_4
; %bb.1:
	ldr	w9, [x20]
	tbz	w19, #3, LBB0_8
; %bb.2:
Lloh4:
	adrp	x10, _cart@GOTPAGE
Lloh5:
	ldr	x10, [x10, _cart@GOTPAGEOFF]
Lloh6:
	ldr	x10, [x10, #8]
	cmp	w9, #2
	b.lt	LBB0_7
; %bb.3:
	add	x10, x10, #1024, lsl #12        ; =4194304
	ldr	x11, [x20, #8]
	stp	x11, x10, [x8, #8]
	ldr	w10, [x20, #4]
	b	LBB0_6
LBB0_4:
Lloh7:
	adrp	x10, _cart_rom@GOTPAGE
Lloh8:
	ldr	x10, [x10, _cart_rom@GOTPAGEOFF]
	ldr	w9, [x10]
	cbz	w9, LBB0_11
; %bb.5:
Lloh9:
	adrp	x11, _cart@GOTPAGE
Lloh10:
	ldr	x11, [x11, _cart@GOTPAGEOFF]
Lloh11:
	ldr	x11, [x11, #8]
	ldr	x12, [x10, #8]
	stp	x12, x11, [x8, #8]
	ldr	w10, [x10, #4]
LBB0_6:
	stp	w9, w10, [x8]
	b	LBB0_11
LBB0_7:
Lloh12:
	adrp	x11, _cart_rom@GOTPAGE
Lloh13:
	ldr	x11, [x11, _cart_rom@GOTPAGEOFF]
	ldr	x12, [x11, #8]
	stp	x12, x10, [x8, #8]
	ldr	d0, [x11]
	str	d0, [x8]
LBB0_8:
	cbnz	w9, LBB0_11
; %bb.9:
Lloh14:
	adrp	x8, _cart@GOTPAGE
Lloh15:
	ldr	x8, [x8, _cart@GOTPAGEOFF]
	ldr	w2, [x8]
	cmp	w2, #256, lsl #12               ; =1048576
	b.gt	LBB0_11
; %bb.10:
	ldr	x1, [x8, #8]
	add	x0, x1, #1024, lsl #12          ; =4194304
	bl	_memcpy
	ldr	x0, [x20, #8]
Lloh16:
	adrp	x21, _cart_rom@GOTPAGE
Lloh17:
	ldr	x21, [x21, _cart_rom@GOTPAGEOFF]
	ldr	x1, [x21, #8]
	mov	w2, #4
	bl	_memcpy
	ldr	d0, [x21]
	str	d0, [x20]
	str	wzr, [x21]
LBB0_11:
	bl	_mapper_reset
	mov	w8, #72
	and	w8, w19, w8
	cmp	w8, #8
	b.ne	LBB0_14
; %bb.12:
	ldr	w8, [x20]
	cmp	w8, #1
	b.ne	LBB0_14
; %bb.13:
Lloh18:
	adrp	x8, _cart@GOTPAGE
Lloh19:
	ldr	x8, [x8, _cart@GOTPAGEOFF]
Lloh20:
	ldr	x8, [x8, #8]
	add	x8, x8, #1024, lsl #12          ; =4194304
Lloh21:
	adrp	x9, _z80_readmap@GOTPAGE
Lloh22:
	ldr	x9, [x9, _z80_readmap@GOTPAGEOFF]
Lloh23:
	ldr	x9, [x9]
	str	x8, [x9]
LBB0_14:
	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
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_slot,24,3                      ; @slot
	.comm	_cart_rom,16,3                  ; @cart_rom
	.comm	_cart,16,3                      ; @cart
	.comm	_bios_rom,16,3                  ; @bios_rom
	.comm	_z80_readmap,8,3                ; @z80_readmap
.subsections_via_symbols
