	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_io_z80_write                   ## -- Begin function io_z80_write
	.p2align	4, 0x90
_io_z80_write:                          ## @io_z80_write
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %ebx
	testl	%edi, %edi
	je	LBB0_8
## %bb.1:
	movq	_region_code@GOTPCREL(%rip), %rax
	movq	_REGION_USA@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, (%rax)
	je	LBB0_9
## %bb.2:
	movl	%edx, %r14d
	movq	_port@GOTPCREL(%rip), %r12
	movq	(%r12), %rax
	leal	(%rbx,%rbx), %edi
	andl	$96, %edi
	movq	_io_reg@GOTPCREL(%rip), %r15
	movq	(%r15), %rcx
	movl	60(%rcx), %esi
	notl	%esi
	shll	$5, %esi
	andl	$96, %esi
	callq	*(%rax)
	movq	(%r12), %rax
	movl	%ebx, %edi
	shrl	%edi
	andl	$96, %edi
	movq	(%r15), %rcx
	movl	60(%rcx), %esi
	notl	%esi
	shll	$3, %esi
	andl	$96, %esi
	callq	*8(%rax)
	movq	(%r15), %rcx
	movl	60(%rcx), %eax
	testb	$-128, %bl
	je	LBB0_4
## %bb.3:
	movl	%eax, %edx
	andl	$128, %edx
	je	LBB0_6
LBB0_4:
	testb	$32, %bl
	je	LBB0_7
## %bb.5:
	andl	$32, %eax
	jne	LBB0_7
LBB0_6:
	movq	_hctab@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	movq	_MCYCLES_PER_LINE@GOTPCREL(%rip), %rdi
	movl	%r14d, %eax
	xorl	%edx, %edx
	divl	(%rdi)
                                        ## kill: def $edx killed $edx def $rdx
	movl	$65536, %eax                    ## imm = 0x10000
	orl	(%rsi,%rdx,4), %eax
	movq	_hvc_latch@GOTPCREL(%rip), %rdx
	movl	%eax, (%rdx)
LBB0_7:
	movl	%ebx, 60(%rcx)
	jmp	LBB0_10
LBB0_8:
	movq	_io_reg@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	%ebx, 56(%rax)
	notl	%ebx
	movl	%ebx, %edi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_sms_cart_switch                ## TAILCALL
LBB0_9:
	movl	%ebx, %eax
	andl	$90, %eax
	orl	$5, %eax
	movq	_io_reg@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	%eax, 60(%rcx)
	movl	%ebx, %eax
	shll	$4, %eax
	andl	$16, %eax
	andl	$4, %ebx
	leal	(%rax,%rbx,8), %eax
	movl	%eax, 52(%rcx)
LBB0_10:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_region_code,4,2                ## @region_code
	.comm	_REGION_USA,4,2                 ## @REGION_USA
	.comm	_port,8,3                       ## @port
	.comm	_io_reg,8,3                     ## @io_reg
	.comm	_hctab,8,3                      ## @hctab
	.comm	_MCYCLES_PER_LINE,4,2           ## @MCYCLES_PER_LINE
	.comm	_hvc_latch,4,2                  ## @hvc_latch
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_io_z80_write                   ; -- Begin function io_z80_write
	.p2align	2
_io_z80_write:                          ; @io_z80_write
	.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, x1
	cbz	w0, LBB0_8
; %bb.1:
Lloh0:
	adrp	x8, _region_code@GOTPAGE
Lloh1:
	ldr	x8, [x8, _region_code@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
Lloh3:
	adrp	x9, _REGION_USA@GOTPAGE
Lloh4:
	ldr	x9, [x9, _REGION_USA@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_9
; %bb.2:
	mov	x20, x2
Lloh6:
	adrp	x21, _port@GOTPAGE
Lloh7:
	ldr	x21, [x21, _port@GOTPAGEOFF]
	ldr	x8, [x21]
	ldr	x8, [x8]
	lsl	w9, w19, #1
	and	w0, w9, #0x60
Lloh8:
	adrp	x22, _io_reg@GOTPAGE
Lloh9:
	ldr	x22, [x22, _io_reg@GOTPAGEOFF]
	ldr	x9, [x22]
	ldr	w9, [x9, #60]
	mvn	w9, w9
	ubfiz	w1, w9, #5, #2
	blr	x8
	ldr	x8, [x21]
	ldr	x8, [x8, #8]
	lsr	w9, w19, #1
	and	w0, w9, #0x60
	ldr	x9, [x22]
	ldr	w9, [x9, #60]
	mvn	w9, w9
	lsl	w9, w9, #3
	and	w1, w9, #0x60
	blr	x8
	ldr	x8, [x22]
	ldr	w9, [x8, #60]
	tbz	w19, #7, LBB0_4
; %bb.3:
	tbz	w9, #7, LBB0_6
LBB0_4:
	tbz	w19, #5, LBB0_7
; %bb.5:
	tbnz	w9, #5, LBB0_7
LBB0_6:
Lloh10:
	adrp	x9, _hctab@GOTPAGE
Lloh11:
	ldr	x9, [x9, _hctab@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
Lloh13:
	adrp	x10, _MCYCLES_PER_LINE@GOTPAGE
Lloh14:
	ldr	x10, [x10, _MCYCLES_PER_LINE@GOTPAGEOFF]
Lloh15:
	ldr	w10, [x10]
	udiv	w11, w20, w10
	msub	w10, w11, w10, w20
	ldr	w9, [x9, w10, uxtw #2]
	orr	w9, w9, #0x10000
Lloh16:
	adrp	x10, _hvc_latch@GOTPAGE
Lloh17:
	ldr	x10, [x10, _hvc_latch@GOTPAGEOFF]
Lloh18:
	str	w9, [x10]
LBB0_7:
	str	w19, [x8, #60]
	b	LBB0_10
LBB0_8:
Lloh19:
	adrp	x8, _io_reg@GOTPAGE
Lloh20:
	ldr	x8, [x8, _io_reg@GOTPAGEOFF]
Lloh21:
	ldr	x8, [x8]
	str	w19, [x8, #56]
	mvn	w0, w19
	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
	b	_sms_cart_switch
LBB0_9:
	mov	w8, #90
	and	w8, w19, w8
	mov	w9, #5
	orr	w8, w8, w9
Lloh22:
	adrp	x9, _io_reg@GOTPAGE
Lloh23:
	ldr	x9, [x9, _io_reg@GOTPAGEOFF]
Lloh24:
	ldr	x9, [x9]
	str	w8, [x9, #60]
	lsl	w8, w19, #3
	and	w8, w8, #0x20
	bfi	w8, w19, #4, #1
	str	w8, [x9, #52]
LBB0_10:
	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 AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotStr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.cfi_endproc
                                        ; -- End function
	.comm	_region_code,4,2                ; @region_code
	.comm	_REGION_USA,4,2                 ; @REGION_USA
	.comm	_port,8,3                       ; @port
	.comm	_io_reg,8,3                     ; @io_reg
	.comm	_hctab,8,3                      ; @hctab
	.comm	_MCYCLES_PER_LINE,4,2           ; @MCYCLES_PER_LINE
	.comm	_hvc_latch,4,2                  ; @hvc_latch
.subsections_via_symbols
