	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function nes_reset_link
_nes_reset_link:                        ## @nes_reset_link
	.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	8(%rdi), %rbx
	movq	(%rbx), %rax
	movq	_NE020_REV@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_21
## %bb.1:
	movl	%esi, %r12d
	movq	%rdi, %r13
	movq	_mh_detected@GOTPCREL(%rip), %rax
	incl	(%rax)
	movq	_NES_SOFTWARE_RESET@GOTPCREL(%rip), %r15
	movq	(%r15), %rdi
	addq	(%r13), %rdi
	callq	_nes_read32
	movl	%eax, %edi
	movl	$29, %r14d
	testl	%r12d, %r12d
	je	LBB0_5
## %bb.2:
	cmpl	$1, %r12d
	jne	LBB0_4
## %bb.3:
	cmpq	$0, 24(%rbx)
	jne	LBB0_5
LBB0_4:
	movl	$45, %r14d
LBB0_5:
	orl	%edi, %r14d
	movq	8(%rbx), %rcx
	movslq	%r12d, %r12
	movl	(%rcx,%r12,4), %eax
	movq	_NES_MAX_LINK_INTERRUPTS@GOTPCREL(%rip), %rsi
	cltd
	idivl	(%rsi)
	cmpl	$4, %eax
	jl	LBB0_10
## %bb.6:
	cmpq	$0, 24(%rbx)
	jne	LBB0_9
## %bb.7:
	cmpl	$2, 16(%rbx)
	jne	LBB0_9
## %bb.8:
	movq	$0, (%rcx)
	movq	_NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	movl	%edi, %r14d
	movq	%r13, %rdi
	callq	_nes_read_indexed
	andl	$64, %eax
	movq	_NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	xorl	$61640, %eax                    ## imm = 0xF0C8
	movq	%r13, %rdi
	movl	%eax, %edx
	callq	_nes_write_indexed
	orl	$61, %r14d
	movq	8(%rbx), %rcx
LBB0_9:
	movl	$0, (%rcx,%r12,4)
LBB0_10:
	movq	(%r15), %rdi
	addq	(%r13), %rdi
	movl	%r14d, %esi
	callq	_nes_write32
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_11:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r15), %rdi
	addq	(%r13), %rdi
	callq	_nes_read32
	testb	$64, %al
	jne	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_11 Depth=1
	leal	1(%rbx), %eax
	cmpl	$5000, %ebx                     ## imm = 0x1388
	movl	%eax, %ebx
	jb	LBB0_11
LBB0_13:
	movl	%r14d, -44(%rbp)                ## 4-byte Spill
	notl	%r14d
	testb	$61, %r14b
	jne	LBB0_21
## %bb.14:
	movl	$10, %r12d
	movq	_NES_IDX_PHY_PCS_CONTROL_STATUS0@GOTPCREL(%rip), %r14
	jmp	LBB0_15
	.p2align	4, 0x90
LBB0_17:                                ##   in Loop: Header=BB0_15 Depth=1
	decl	%r12d
	je	LBB0_18
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r14), %rsi
	movq	%r13, %rdi
	callq	_nes_read_indexed
	movl	%eax, %ebx
	movq	(%r14), %rsi
	movl	$512, %eax                      ## imm = 0x200
	addq	%rax, %rsi
	movq	%r13, %rdi
	callq	_nes_read_indexed
	notl	%ebx
	testl	$252706816, %ebx                ## imm = 0xF100000
	je	LBB0_17
## %bb.16:                              ##   in Loop: Header=BB0_15 Depth=1
	andl	$252706816, %eax                ## imm = 0xF100000
	cmpl	$252706816, %eax                ## imm = 0xF100000
	je	LBB0_17
	jmp	LBB0_21
LBB0_18:
	movq	_NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rsi
	movq	%r13, %rdi
	callq	_nes_read_indexed
	andl	$64, %eax
	movq	(%rbx), %rsi
	xorl	$61640, %eax                    ## imm = 0xF0C8
	movq	%r13, %rdi
	movl	%eax, %edx
	callq	_nes_write_indexed
	movq	(%r15), %rdi
	addq	(%r13), %rdi
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	callq	_nes_write32
	movl	$10, %ebx
	.p2align	4, 0x90
LBB0_19:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r15), %rdi
	addq	(%r13), %rdi
	callq	_nes_read32
	testb	$64, %al
	jne	LBB0_21
## %bb.20:                              ##   in Loop: Header=BB0_19 Depth=1
	leal	1(%rbx), %eax
	cmpl	$5000, %ebx                     ## imm = 0x1388
	movl	%eax, %ebx
	jb	LBB0_19
LBB0_21:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NE020_REV,8,3                  ## @NE020_REV
	.comm	_mh_detected,4,2                ## @mh_detected
	.comm	_NES_SOFTWARE_RESET,8,3         ## @NES_SOFTWARE_RESET
	.comm	_NES_MAX_LINK_INTERRUPTS,8,3    ## @NES_MAX_LINK_INTERRUPTS
	.comm	_NES_IDX_ETH_SERDES_COMMON_CONTROL1,8,3 ## @NES_IDX_ETH_SERDES_COMMON_CONTROL1
	.comm	_NES_IDX_PHY_PCS_CONTROL_STATUS0,8,3 ## @NES_IDX_PHY_PCS_CONTROL_STATUS0
	.no_dead_strip	_nes_reset_link
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function nes_reset_link
_nes_reset_link:                        ; @nes_reset_link
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	ldr	x24, [x0, #8]
	ldr	x8, [x24]
Lloh0:
	adrp	x9, _NE020_REV@GOTPAGE
Lloh1:
	ldr	x9, [x9, _NE020_REV@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.eq	LBB0_21
; %bb.1:
	mov	x22, x1
	mov	x19, x0
Lloh3:
	adrp	x8, _mh_detected@GOTPAGE
Lloh4:
	ldr	x8, [x8, _mh_detected@GOTPAGEOFF]
	ldr	w9, [x8]
	add	w9, w9, #1
	str	w9, [x8]
	ldr	x8, [x0]
Lloh5:
	adrp	x23, _NES_SOFTWARE_RESET@GOTPAGE
Lloh6:
	ldr	x23, [x23, _NES_SOFTWARE_RESET@GOTPAGEOFF]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_nes_read32
	mov	x21, x0
	cbz	w22, LBB0_4
; %bb.2:
	cmp	w22, #1
	b.ne	LBB0_5
; %bb.3:
	ldr	x8, [x24, #24]
	cbz	x8, LBB0_5
LBB0_4:
	mov	w9, #29
	b	LBB0_6
LBB0_5:
	mov	w9, #45
LBB0_6:
	ldr	x8, [x24, #8]
	ldr	w10, [x8, w22, sxtw #2]
	orr	w20, w21, w9
Lloh7:
	adrp	x9, _NES_MAX_LINK_INTERRUPTS@GOTPAGE
Lloh8:
	ldr	x9, [x9, _NES_MAX_LINK_INTERRUPTS@GOTPAGEOFF]
Lloh9:
	ldr	w9, [x9]
	sdiv	w9, w10, w9
	cmp	w9, #4
	b.lt	LBB0_11
; %bb.7:
	sxtw	x22, w22
	ldr	x9, [x24, #24]
	cbnz	x9, LBB0_10
; %bb.8:
	ldr	w9, [x24, #16]
	cmp	w9, #2
	b.ne	LBB0_10
; %bb.9:
	str	xzr, [x8]
Lloh10:
	adrp	x20, _NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPAGE
Lloh11:
	ldr	x20, [x20, _NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPAGEOFF]
	ldr	x1, [x20]
	mov	x0, x19
	bl	_nes_read_indexed
	and	w8, w0, #0x40
	ldr	x1, [x20]
	mov	w9, #61640
	eor	w2, w8, w9
	mov	x0, x19
	bl	_nes_write_indexed
	mov	w8, #61
	orr	w20, w21, w8
	ldr	x8, [x24, #8]
LBB0_10:
	str	wzr, [x8, x22, lsl #2]
LBB0_11:
	ldr	x8, [x19]
	ldr	x9, [x23]
	add	x0, x9, x8
	mov	x1, x20
	bl	_nes_write32
	mov	w21, #0
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_nes_read32
	tbnz	w0, #6, LBB0_14
; %bb.13:                               ;   in Loop: Header=BB0_12 Depth=1
	lsr	w8, w21, #3
	add	w21, w21, #1
	cmp	w8, #625
	b.lo	LBB0_12
LBB0_14:
	mov	w8, #61
	bics	wzr, w8, w20
	b.ne	LBB0_21
; %bb.15:
	mov	w22, #10
Lloh12:
	adrp	x24, _NES_IDX_PHY_PCS_CONTROL_STATUS0@GOTPAGE
Lloh13:
	ldr	x24, [x24, _NES_IDX_PHY_PCS_CONTROL_STATUS0@GOTPAGEOFF]
	mov	w25, #252706816
LBB0_16:                                ; =>This Inner Loop Header: Depth=1
	ldr	x1, [x24]
	mov	x0, x19
	bl	_nes_read_indexed
	mov	x21, x0
	ldr	x8, [x24]
	add	x1, x8, #512
	mov	x0, x19
	bl	_nes_read_indexed
	bic	w8, w25, w21
	and	w9, w0, w25
	cmp	w8, #0
	ccmp	w9, w25, #4, ne
	b.ne	LBB0_21
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=1
	subs	w22, w22, #1
	b.ne	LBB0_16
; %bb.18:
Lloh14:
	adrp	x21, _NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPAGE
Lloh15:
	ldr	x21, [x21, _NES_IDX_ETH_SERDES_COMMON_CONTROL1@GOTPAGEOFF]
	ldr	x1, [x21]
	mov	x0, x19
	bl	_nes_read_indexed
	and	w8, w0, #0x40
	ldr	x1, [x21]
	mov	w9, #61640
	eor	w2, w8, w9
	mov	x0, x19
	bl	_nes_write_indexed
	ldr	x8, [x19]
	ldr	x9, [x23]
	add	x0, x9, x8
	mov	x1, x20
	bl	_nes_write32
	mov	w20, #10
LBB0_19:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_nes_read32
	tbnz	w0, #6, LBB0_21
; %bb.20:                               ;   in Loop: Header=BB0_19 Depth=1
	lsr	w8, w20, #3
	add	w20, w20, #1
	cmp	w8, #625
	b.lo	LBB0_19
LBB0_21:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_NE020_REV,8,3                  ; @NE020_REV
	.comm	_mh_detected,4,2                ; @mh_detected
	.comm	_NES_SOFTWARE_RESET,8,3         ; @NES_SOFTWARE_RESET
	.comm	_NES_MAX_LINK_INTERRUPTS,8,3    ; @NES_MAX_LINK_INTERRUPTS
	.comm	_NES_IDX_ETH_SERDES_COMMON_CONTROL1,8,3 ; @NES_IDX_ETH_SERDES_COMMON_CONTROL1
	.comm	_NES_IDX_PHY_PCS_CONTROL_STATUS0,8,3 ; @NES_IDX_PHY_PCS_CONTROL_STATUS0
	.no_dead_strip	_nes_reset_link
.subsections_via_symbols
