	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_p32x_reset_sh2s                ## -- Begin function p32x_reset_sh2s
	.p2align	4, 0x90
_p32x_reset_sh2s:                       ## @p32x_reset_sh2s
	.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
	movq	_EL_32X@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_elprintf
	movq	_msh2@GOTPCREL(%rip), %r15
	movq	%r15, %rdi
	callq	_sh2_reset
	movq	_ssh2@GOTPCREL(%rip), %rbx
	movq	%rbx, %rdi
	callq	_sh2_reset
	movq	%r15, %rdi
	callq	_sh2_peripheral_reset
	movq	%rbx, %rdi
	callq	_sh2_peripheral_reset
	movq	_p32x_bios_m@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	jne	LBB0_10
## %bb.1:
	movq	_Pico@GOTPCREL(%rip), %r15
	movq	8(%r15), %rax
	movl	980(%rax), %edi
	callq	_HWSWAP
	movl	%eax, %r13d
	movl	%eax, %r12d
	andl	$268435455, %r12d               ## imm = 0xFFFFFFF
	movq	8(%r15), %rax
	movl	984(%rax), %edi
	callq	_HWSWAP
	movl	%eax, %r14d
	movl	%eax, %ebx
	andl	$268435455, %ebx                ## imm = 0xFFFFFFF
	movq	8(%r15), %rax
	movl	988(%rax), %edi
	callq	_HWSWAP
                                        ## kill: def $eax killed $eax def $rax
	movl	(%r15), %ecx
	cmpl	%ecx, %eax
	ja	LBB0_7
## %bb.2:
	cmpl	$262144, %eax                   ## imm = 0x40000
	ja	LBB0_7
## %bb.3:
	leal	(%rax,%r12), %edx
	cmpl	%ecx, %edx
	ja	LBB0_7
## %bb.4:
	movl	%eax, %ecx
	addl	%ebx, %ecx
	cmpl	$262144, %ecx                   ## imm = 0x40000
	ja	LBB0_7
## %bb.5:
	andl	$3, %r13d
	jne	LBB0_7
## %bb.6:
	andl	$3, %r14d
	jne	LBB0_7
## %bb.8:
	movq	_Pico32xMem@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	%ebx, %edi
	addq	(%rcx), %rdi
	movl	%r12d, %esi
	movq	_Pico@GOTPCREL(%rip), %rbx
	addq	8(%rbx), %rsi
	movl	%eax, %edx
	callq	_memcpy
	jmp	LBB0_9
LBB0_7:
	movq	_EL_STATUS@GOTPCREL(%rip), %rcx
	movq	_EL_ANOMALY@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edi
	orl	(%rcx), %edi
	leaq	L_.str.1(%rip), %rsi
	movl	%r12d, %edx
	movl	%ebx, %ecx
	movl	%eax, %r8d
	xorl	%eax, %eax
	callq	_elprintf
	movq	_Pico@GOTPCREL(%rip), %rbx
LBB0_9:
	movq	8(%rbx), %rax
	movl	1000(%rax), %edi
	callq	_HWSWAP
	movl	%eax, %r14d
	xorl	%edi, %edi
	movl	$536887296, %esi                ## imm = 0x20004000
	callq	_sh2_set_gbr
	xorl	%edi, %edi
	movl	%r14d, %esi
	callq	_sh2_set_vbr
	movq	8(%rbx), %rax
	movzwl	398(%rax), %eax
	movq	_Pico32x@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movw	%ax, 40(%rcx)
	movq	_msh2@GOTPCREL(%rip), %r15
	movq	_ssh2@GOTPCREL(%rip), %rbx
LBB0_10:
	movq	_p32x_bios_s@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	jne	LBB0_12
## %bb.11:
	movq	_Pico@GOTPCREL(%rip), %rax
	movq	8(%rax), %rax
	movl	1004(%rax), %edi
	callq	_HWSWAP
	movl	%eax, %r14d
	movl	$1, %edi
	movl	$536887296, %esi                ## imm = 0x20004000
	callq	_sh2_set_gbr
	movl	$1, %edi
	movl	%r14d, %esi
	callq	_sh2_set_vbr
LBB0_12:
	xorl	%eax, %eax
	callq	_SekCyclesDone
	movl	%eax, (%rbx)
	movl	%eax, (%r15)
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EL_32X,4,2                     ## @EL_32X
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"sh2 reset"

	.comm	_msh2,4,2                       ## @msh2
	.comm	_ssh2,4,2                       ## @ssh2
	.comm	_p32x_bios_m,8,3                ## @p32x_bios_m
	.comm	_Pico,16,3                      ## @Pico
	.comm	_EL_STATUS,4,2                  ## @EL_STATUS
	.comm	_EL_ANOMALY,4,2                 ## @EL_ANOMALY
L_.str.1:                               ## @.str.1
	.asciz	"32x: invalid initial data ptrs: %06x -> %06x, %06x"

	.comm	_Pico32xMem,8,3                 ## @Pico32xMem
	.comm	_Pico32x,8,3                    ## @Pico32x
	.comm	_p32x_bios_s,8,3                ## @p32x_bios_s
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_p32x_reset_sh2s                ; -- Begin function p32x_reset_sh2s
	.p2align	2
_p32x_reset_sh2s:                       ; @p32x_reset_sh2s
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
Lloh0:
	adrp	x8, _EL_32X@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EL_32X@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	bl	_elprintf
Lloh5:
	adrp	x19, _msh2@GOTPAGE
Lloh6:
	ldr	x19, [x19, _msh2@GOTPAGEOFF]
	mov	x0, x19
	bl	_sh2_reset
Lloh7:
	adrp	x20, _ssh2@GOTPAGE
Lloh8:
	ldr	x20, [x20, _ssh2@GOTPAGEOFF]
	mov	x0, x20
	bl	_sh2_reset
	mov	x0, x19
	bl	_sh2_peripheral_reset
	mov	x0, x20
	bl	_sh2_peripheral_reset
Lloh9:
	adrp	x8, _p32x_bios_m@GOTPAGE
Lloh10:
	ldr	x8, [x8, _p32x_bios_m@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	cbnz	x8, LBB0_6
; %bb.1:
Lloh12:
	adrp	x23, _Pico@GOTPAGE
Lloh13:
	ldr	x23, [x23, _Pico@GOTPAGEOFF]
	ldr	x8, [x23, #8]
	ldr	w0, [x8, #980]
	bl	_HWSWAP
	mov	x21, x0
	and	w24, w0, #0xfffffff
	ldr	x8, [x23, #8]
	ldr	w0, [x8, #984]
	bl	_HWSWAP
	mov	x22, x0
	and	w25, w0, #0xfffffff
	ldr	x8, [x23, #8]
	ldr	w0, [x8, #988]
	bl	_HWSWAP
	mov	x2, x0
	ldr	w8, [x23]
	cmp	w0, w8
	b.hi	LBB0_3
; %bb.2:
	add	w9, w2, w24
	add	w10, w2, w25
	and	w11, w21, #0x3
	and	w12, w22, #0x3
	mov	w13, #1
	movk	w13, #4, lsl #16
	cmp	w2, #64, lsl #12                ; =262144
	ccmp	w9, w8, #2, ls
	ccmp	w10, w13, #2, ls
	ccmp	w11, #0, #0, lo
	ccmp	w12, #0, #0, eq
	b.eq	LBB0_4
LBB0_3:
Lloh14:
	adrp	x8, _EL_STATUS@GOTPAGE
Lloh15:
	ldr	x8, [x8, _EL_STATUS@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
Lloh17:
	adrp	x9, _EL_ANOMALY@GOTPAGE
Lloh18:
	ldr	x9, [x9, _EL_ANOMALY@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	orr	w0, w9, w8
	stp	x25, x2, [sp, #8]
	str	x24, [sp]
Lloh20:
	adrp	x1, l_.str.1@PAGE
Lloh21:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_elprintf
	b	LBB0_5
LBB0_4:
Lloh22:
	adrp	x8, _Pico32xMem@GOTPAGE
Lloh23:
	ldr	x8, [x8, _Pico32xMem@GOTPAGEOFF]
Lloh24:
	ldr	x8, [x8]
	ldr	x8, [x8]
	add	x0, x8, w25, uxtw
	ldr	x8, [x23, #8]
	add	x1, x8, w24, uxtw
                                        ; kill: def $w2 killed $w2 killed $x2
	bl	_memcpy
LBB0_5:
	ldr	x8, [x23, #8]
	ldr	w0, [x8, #1000]
	bl	_HWSWAP
	mov	x21, x0
	mov	w0, #0
	mov	w1, #16384
	movk	w1, #8192, lsl #16
	bl	_sh2_set_gbr
	mov	w0, #0
	mov	x1, x21
	bl	_sh2_set_vbr
	ldr	x8, [x23, #8]
	ldrh	w8, [x8, #398]
Lloh25:
	adrp	x9, _Pico32x@GOTPAGE
Lloh26:
	ldr	x9, [x9, _Pico32x@GOTPAGEOFF]
Lloh27:
	ldr	x9, [x9]
	strh	w8, [x9, #40]
LBB0_6:
Lloh28:
	adrp	x8, _p32x_bios_s@GOTPAGE
Lloh29:
	ldr	x8, [x8, _p32x_bios_s@GOTPAGEOFF]
Lloh30:
	ldr	x8, [x8]
	cbnz	x8, LBB0_8
; %bb.7:
Lloh31:
	adrp	x8, _Pico@GOTPAGE
Lloh32:
	ldr	x8, [x8, _Pico@GOTPAGEOFF]
Lloh33:
	ldr	x8, [x8, #8]
	ldr	w0, [x8, #1004]
	bl	_HWSWAP
	mov	x21, x0
	mov	w0, #1
	mov	w1, #16384
	movk	w1, #8192, lsl #16
	bl	_sh2_set_gbr
	mov	w0, #1
	mov	x1, x21
	bl	_sh2_set_vbr
LBB0_8:
	bl	_SekCyclesDone
	str	w0, [x20]
	str	w0, [x19]
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.cfi_endproc
                                        ; -- End function
	.comm	_EL_32X,4,2                     ; @EL_32X
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"sh2 reset"

	.comm	_msh2,4,2                       ; @msh2
	.comm	_ssh2,4,2                       ; @ssh2
	.comm	_p32x_bios_m,8,3                ; @p32x_bios_m
	.comm	_Pico,16,3                      ; @Pico
	.comm	_EL_STATUS,4,2                  ; @EL_STATUS
	.comm	_EL_ANOMALY,4,2                 ; @EL_ANOMALY
l_.str.1:                               ; @.str.1
	.asciz	"32x: invalid initial data ptrs: %06x -> %06x, %06x"

	.comm	_Pico32xMem,8,3                 ; @Pico32xMem
	.comm	_Pico32x,8,3                    ; @Pico32x
	.comm	_p32x_bios_s,8,3                ; @p32x_bios_s
.subsections_via_symbols
