	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function niu_get_and_validate_port
_niu_get_and_validate_port:             ## @niu_get_and_validate_port
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	%rdi, %rbx
	movq	8(%rdi), %r14
	cmpl	$1, (%rdi)
	jg	LBB0_2
## %bb.1:
	movq	_NIU_FLAGS_XMAC@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	%eax, 4(%rbx)
LBB0_2:
	movl	(%r14), %eax
	testl	%eax, %eax
	jne	LBB0_7
## %bb.3:
	movq	8(%r14), %rcx
	movq	_PLAT_TYPE_NIU@GOTPCREL(%rip), %rdx
	movl	$2, %eax
	cmpq	(%rdx), %rcx
	je	LBB0_6
## %bb.4:
	movq	%rbx, %rdi
	callq	_niu_pci_vpd_get_nports
	movl	%eax, (%r14)
	testl	%eax, %eax
	jne	LBB0_7
## %bb.5:
	movq	_ESPC_NUM_PORTS_MACS@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_nr64
	movl	%eax, %ecx
	movq	_ESPC_NUM_PORTS_MACS_VAL@GOTPCREL(%rip), %rax
	andl	(%rax), %ecx
	movl	$4, %eax
	cmovnel	%ecx, %eax
LBB0_6:
	movl	%eax, (%r14)
LBB0_7:
	movq	_ENODEV@GOTPCREL(%rip), %rdx
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	subl	(%rdx), %ecx
	cmpl	%eax, (%rbx)
	cmovll	%esi, %ecx
	movl	%ecx, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_NIU_FLAGS_XMAC,4,2             ## @NIU_FLAGS_XMAC
	.comm	_PLAT_TYPE_NIU,8,3              ## @PLAT_TYPE_NIU
	.comm	_ESPC_NUM_PORTS_MACS,4,2        ## @ESPC_NUM_PORTS_MACS
	.comm	_ESPC_NUM_PORTS_MACS_VAL,4,2    ## @ESPC_NUM_PORTS_MACS_VAL
	.comm	_ENODEV,4,2                     ## @ENODEV
	.no_dead_strip	_niu_get_and_validate_port
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function niu_get_and_validate_port
_niu_get_and_validate_port:             ; @niu_get_and_validate_port
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	ldr	x20, [x0, #8]
	ldr	w8, [x0]
	cmp	w8, #1
	b.gt	LBB0_2
; %bb.1:
Lloh0:
	adrp	x8, _NIU_FLAGS_XMAC@GOTPAGE
Lloh1:
	ldr	x8, [x8, _NIU_FLAGS_XMAC@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	ldr	w9, [x19, #4]
	orr	w8, w9, w8
	str	w8, [x19, #4]
LBB0_2:
	ldr	w0, [x20]
	cbnz	w0, LBB0_8
; %bb.3:
	ldr	x8, [x20, #8]
Lloh3:
	adrp	x9, _PLAT_TYPE_NIU@GOTPAGE
Lloh4:
	ldr	x9, [x9, _PLAT_TYPE_NIU@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_5
; %bb.4:
	mov	w0, #2
	b	LBB0_7
LBB0_5:
	mov	x0, x19
	bl	_niu_pci_vpd_get_nports
	str	w0, [x20]
	cbnz	w0, LBB0_8
; %bb.6:
Lloh6:
	adrp	x8, _ESPC_NUM_PORTS_MACS@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ESPC_NUM_PORTS_MACS@GOTPAGEOFF]
Lloh8:
	ldr	w0, [x8]
	bl	_nr64
Lloh9:
	adrp	x8, _ESPC_NUM_PORTS_MACS_VAL@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ESPC_NUM_PORTS_MACS_VAL@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	ands	w8, w8, w0
	mov	w9, #4
	csel	w0, w9, w8, eq
LBB0_7:
	str	w0, [x20]
LBB0_8:
	ldr	w8, [x19]
Lloh12:
	adrp	x9, _ENODEV@GOTPAGE
Lloh13:
	ldr	x9, [x9, _ENODEV@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	cmp	w8, w0
	csneg	w0, wzr, w9, lt
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_NIU_FLAGS_XMAC,4,2             ; @NIU_FLAGS_XMAC
	.comm	_PLAT_TYPE_NIU,8,3              ; @PLAT_TYPE_NIU
	.comm	_ESPC_NUM_PORTS_MACS,4,2        ; @ESPC_NUM_PORTS_MACS
	.comm	_ESPC_NUM_PORTS_MACS_VAL,4,2    ; @ESPC_NUM_PORTS_MACS_VAL
	.comm	_ENODEV,4,2                     ; @ENODEV
	.no_dead_strip	_niu_get_and_validate_port
.subsections_via_symbols
