	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cas_mii_link_check
_cas_mii_link_check:                    ## @cas_mii_link_check
	.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
	movq	%rdi, %rbx
	movq	_BMSR_LSTATUS@GOTPCREL(%rip), %rcx
	movq	(%rdi), %rax
	testl	%esi, (%rcx)
	je	LBB0_9
## %bb.1:
	movq	_link_force_try@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_6
## %bb.2:
	movq	_BMCR_ANENABLE@GOTPCREL(%rip), %r15
	movl	(%r15), %ecx
	testl	%ecx, 8(%rbx)
	je	LBB0_6
## %bb.3:
	movq	_link_force_ret@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%rbx)
	movq	_LINK_TRANSITION_LINK_CONFIG@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 32(%rbx)
	xorl	%r14d, %r14d
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_cas_mif_poll
	movq	_MII_BMCR@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	movq	%rbx, %rdi
	callq	_cas_phy_read
	movl	%eax, 12(%rbx)
	movl	$5, 16(%rbx)
	cmpq	$0, 24(%rbx)
	je	LBB0_5
## %bb.4:
	movq	_link@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	20(%rbx), %edx
	leaq	L_.str(%rip), %rcx
	movq	%rbx, %rdi
	callq	_netif_info
	movl	12(%rbx), %eax
LBB0_5:
	orl	(%r15), %eax
	movl	(%r12), %esi
	movq	_BMCR_ANRESTART@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	%rbx, %rdi
	movl	%eax, %edx
	callq	_cas_phy_write
	movq	%rbx, %rdi
	movl	$1, %esi
	callq	_cas_mif_poll
	jmp	LBB0_14
LBB0_6:
	movq	_link_up@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	xorl	%r14d, %r14d
	cmpq	%rcx, %rax
	je	LBB0_14
## %bb.7:
	movq	%rcx, (%rbx)
	movq	_LINK_TRANSITION_LINK_UP@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 32(%rbx)
	cmpq	$0, 24(%rbx)
	je	LBB0_14
## %bb.8:
	movq	%rbx, %rdi
	callq	_cas_set_link_modes
	movl	20(%rbx), %edi
	callq	_netif_carrier_on
	jmp	LBB0_14
LBB0_9:
	movq	_link_up@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
## %bb.10:
	movq	_link_down@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%rbx)
	movq	_LINK_TRANSITION_LINK_DOWN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 32(%rbx)
	movl	20(%rbx), %edi
	callq	_netif_carrier_off
	movl	$1, %r14d
	cmpq	$0, 24(%rbx)
	je	LBB0_14
## %bb.11:
	movq	_link@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	20(%rbx), %edx
	leaq	L_.str.1(%rip), %rcx
	movq	%rbx, %rdi
	callq	_netif_info
	jmp	LBB0_14
LBB0_12:
	movl	16(%rbx), %eax
	leal	1(%rax), %ecx
	movl	%ecx, 16(%rbx)
	xorl	%r14d, %r14d
	cmpl	$10, %eax
	jl	LBB0_14
## %bb.13:
	movq	%rbx, %rdi
	callq	_cas_mdio_link_not_up
LBB0_14:
	movl	%r14d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_BMSR_LSTATUS,4,2               ## @BMSR_LSTATUS
	.comm	_link_force_try,8,3             ## @link_force_try
	.comm	_BMCR_ANENABLE,4,2              ## @BMCR_ANENABLE
	.comm	_link_force_ret,8,3             ## @link_force_ret
	.comm	_LINK_TRANSITION_LINK_CONFIG,4,2 ## @LINK_TRANSITION_LINK_CONFIG
	.comm	_MII_BMCR,4,2                   ## @MII_BMCR
	.comm	_link,4,2                       ## @link
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Got link after fallback, retrying autoneg once...\n"

	.comm	_BMCR_ANRESTART,4,2             ## @BMCR_ANRESTART
	.comm	_link_up,8,3                    ## @link_up
	.comm	_LINK_TRANSITION_LINK_UP,4,2    ## @LINK_TRANSITION_LINK_UP
	.comm	_link_down,8,3                  ## @link_down
	.comm	_LINK_TRANSITION_LINK_DOWN,4,2  ## @LINK_TRANSITION_LINK_DOWN
L_.str.1:                               ## @.str.1
	.asciz	"Link down\n"

	.no_dead_strip	_cas_mii_link_check
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cas_mii_link_check
_cas_mii_link_check:                    ; @cas_mii_link_check
	.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, _BMSR_LSTATUS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _BMSR_LSTATUS@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x8]
	ldr	x8, [x0]
	tst	w9, w1
	b.eq	LBB0_9
; %bb.1:
Lloh3:
	adrp	x9, _link_force_try@GOTPAGE
Lloh4:
	ldr	x9, [x9, _link_force_try@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_6
; %bb.2:
	ldr	w9, [x19, #8]
Lloh6:
	adrp	x20, _BMCR_ANENABLE@GOTPAGE
Lloh7:
	ldr	x20, [x20, _BMCR_ANENABLE@GOTPAGEOFF]
	ldr	w10, [x20]
	tst	w10, w9
	b.eq	LBB0_6
; %bb.3:
Lloh8:
	adrp	x8, _link_force_ret@GOTPAGE
Lloh9:
	ldr	x8, [x8, _link_force_ret@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
	str	x8, [x19]
Lloh11:
	adrp	x8, _LINK_TRANSITION_LINK_CONFIG@GOTPAGE
Lloh12:
	ldr	x8, [x8, _LINK_TRANSITION_LINK_CONFIG@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	str	w8, [x19, #32]
	mov	x0, x19
	mov	w1, #0
	bl	_cas_mif_poll
Lloh14:
	adrp	x21, _MII_BMCR@GOTPAGE
Lloh15:
	ldr	x21, [x21, _MII_BMCR@GOTPAGEOFF]
	ldr	w1, [x21]
	mov	x0, x19
	bl	_cas_phy_read
	mov	w8, #5
	stp	w0, w8, [x19, #12]
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_5
; %bb.4:
Lloh16:
	adrp	x8, _link@GOTPAGE
Lloh17:
	ldr	x8, [x8, _link@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
	ldr	w2, [x19, #20]
Lloh19:
	adrp	x3, l_.str@PAGE
Lloh20:
	add	x3, x3, l_.str@PAGEOFF
	mov	x0, x19
	bl	_netif_info
	ldr	w0, [x19, #12]
LBB0_5:
	ldr	w1, [x21]
	ldr	w8, [x20]
	orr	w8, w8, w0
Lloh21:
	adrp	x9, _BMCR_ANRESTART@GOTPAGE
Lloh22:
	ldr	x9, [x9, _BMCR_ANRESTART@GOTPAGEOFF]
Lloh23:
	ldr	w9, [x9]
	orr	w2, w8, w9
	mov	x0, x19
	bl	_cas_phy_write
	mov	x0, x19
	mov	w1, #1
	bl	_cas_mif_poll
	b	LBB0_14
LBB0_6:
Lloh24:
	adrp	x9, _link_up@GOTPAGE
Lloh25:
	ldr	x9, [x9, _link_up@GOTPAGEOFF]
Lloh26:
	ldr	x9, [x9]
	cmp	x8, x9
	b.eq	LBB0_14
; %bb.7:
	str	x9, [x19]
Lloh27:
	adrp	x8, _LINK_TRANSITION_LINK_UP@GOTPAGE
Lloh28:
	ldr	x8, [x8, _LINK_TRANSITION_LINK_UP@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	str	w8, [x19, #32]
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_14
; %bb.8:
	mov	x0, x19
	bl	_cas_set_link_modes
	ldr	w0, [x19, #20]
	bl	_netif_carrier_on
	b	LBB0_14
LBB0_9:
Lloh30:
	adrp	x9, _link_up@GOTPAGE
Lloh31:
	ldr	x9, [x9, _link_up@GOTPAGEOFF]
Lloh32:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_12
; %bb.10:
Lloh33:
	adrp	x8, _link_down@GOTPAGE
Lloh34:
	ldr	x8, [x8, _link_down@GOTPAGEOFF]
Lloh35:
	ldr	x8, [x8]
	str	x8, [x19]
Lloh36:
	adrp	x8, _LINK_TRANSITION_LINK_DOWN@GOTPAGE
Lloh37:
	ldr	x8, [x8, _LINK_TRANSITION_LINK_DOWN@GOTPAGEOFF]
Lloh38:
	ldr	w8, [x8]
	str	w8, [x19, #32]
	ldr	w0, [x19, #20]
	bl	_netif_carrier_off
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_16
; %bb.11:
Lloh39:
	adrp	x8, _link@GOTPAGE
Lloh40:
	ldr	x8, [x8, _link@GOTPAGEOFF]
Lloh41:
	ldr	w1, [x8]
	ldr	w2, [x19, #20]
Lloh42:
	adrp	x3, l_.str.1@PAGE
Lloh43:
	add	x3, x3, l_.str.1@PAGEOFF
	mov	x0, x19
	bl	_netif_info
	mov	w0, #1
	b	LBB0_15
LBB0_12:
	ldr	w8, [x19, #16]
	add	w9, w8, #1
	str	w9, [x19, #16]
	cmp	w8, #10
	b.lt	LBB0_14
; %bb.13:
	mov	x0, x19
	bl	_cas_mdio_link_not_up
LBB0_14:
	mov	w0, #0
LBB0_15:
	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_16:
	mov	w0, #1
	b	LBB0_15
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpAdd	Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh39, Lloh40, Lloh41
	.cfi_endproc
                                        ; -- End function
	.comm	_BMSR_LSTATUS,4,2               ; @BMSR_LSTATUS
	.comm	_link_force_try,8,3             ; @link_force_try
	.comm	_BMCR_ANENABLE,4,2              ; @BMCR_ANENABLE
	.comm	_link_force_ret,8,3             ; @link_force_ret
	.comm	_LINK_TRANSITION_LINK_CONFIG,4,2 ; @LINK_TRANSITION_LINK_CONFIG
	.comm	_MII_BMCR,4,2                   ; @MII_BMCR
	.comm	_link,4,2                       ; @link
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Got link after fallback, retrying autoneg once...\n"

	.comm	_BMCR_ANRESTART,4,2             ; @BMCR_ANRESTART
	.comm	_link_up,8,3                    ; @link_up
	.comm	_LINK_TRANSITION_LINK_UP,4,2    ; @LINK_TRANSITION_LINK_UP
	.comm	_link_down,8,3                  ; @link_down
	.comm	_LINK_TRANSITION_LINK_DOWN,4,2  ; @LINK_TRANSITION_LINK_DOWN
l_.str.1:                               ; @.str.1
	.asciz	"Link down\n"

	.no_dead_strip	_cas_mii_link_check
.subsections_via_symbols
