	.file	"extr_arswitch.c_arswitch_getport.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	arswitch_getport, @function
arswitch_getport:
.LFB0:
	.cfi_startproc
	endbr64
	push	r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	push	r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	push	r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	mov	r12d, edi
	push	rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	push	rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	mov	rbx, rsi
	call	device_get_softc@PLT
	mov	rbp, rax
	mov	rax, QWORD PTR [rbx]
	test	rax, rax
	js	.L7
	cmp	rax, QWORD PTR 8[rbp]
	jg	.L7
	mov	rsi, rbx
	mov	rdi, rbp
	call	[QWORD PTR 0[rbp]]
	mov	r13d, eax
	test	eax, eax
	jne	.L1
	mov	rsi, QWORD PTR [rbx]
	mov	rdi, rbp
	call	arswitch_miiforport@PLT
	mov	rsi, QWORD PTR [rbx]
	mov	rdi, rbp
	mov	r14, rax
	call	arswitch_is_cpuport@PLT
	test	rax, rax
	jne	.L22
	test	r14, r14
	je	.L7
	mov	edi, DWORD PTR 4[r14]
	mov	ecx, DWORD PTR SIOCGIFMEDIA[rip]
	lea	rsi, 24[rbx]
	mov	rdx, r14
	call	ifmedia_ioctl@PLT
	test	eax, eax
	jne	.L23
.L6:
	mov	rsi, QWORD PTR [rbx]
	mov	rdi, rbp
	call	arswitch_is_cpuport@PLT
	test	rax, rax
	je	.L24
.L8:
	mov	eax, r13d
	mov	DWORD PTR 8[rbx], 0
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L7:
	.cfi_restore_state
	mov	r13d, DWORD PTR ENXIO[rip]
.L1:
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	mov	eax, r13d
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L22:
	.cfi_restore_state
	mov	eax, DWORD PTR ETHERSWITCH_PORT_CPU[rip]
	or	DWORD PTR 64[rbx], eax
	mov	eax, DWORD PTR IFM_ETHER[rip]
	or	eax, DWORD PTR IFM_1000_T[rip]
	mov	QWORD PTR 56[rbx], 0
	or	eax, DWORD PTR IFM_FDX[rip]
	mov	QWORD PTR 48[rbx], 0
	mov	DWORD PTR 36[rbx], eax
	mov	DWORD PTR 32[rbx], eax
	mov	eax, DWORD PTR IFM_ACTIVE[rip]
	or	eax, DWORD PTR IFM_AVALID[rip]
	mov	DWORD PTR 40[rbx], eax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L24:
	mov	esi, DWORD PTR AR8327[rip]
	mov	rdi, rbp
	call	AR8X16_IS_SWITCH@PLT
	test	rax, rax
	je	.L8
	mov	rdx, QWORD PTR [rbx]
	mov	rax, QWORD PTR ar8327_led_mapping[rip]
	mov	DWORD PTR 8[rbx], 3
	xor	ebp, ebp
	mov	r10, QWORD PTR -8[rax+rdx*8]
	.p2align 4,,10
	.p2align 3
.L12:
	mov	esi, DWORD PTR 4[r10+rbp*8]
	mov	edi, r12d
	call	arswitch_readreg@PLT
	mov	rcx, QWORD PTR [rbx]
	mov	rdx, QWORD PTR ar8327_led_mapping[rip]
	mov	r9d, DWORD PTR ETHERSWITCH_PORT_LED_MAX[rip]
	mov	r10, QWORD PTR -8[rdx+rcx*8]
	mov	ecx, DWORD PTR [r10+rbp*8]
	sar	eax, cl
	and	eax, 3
	test	r9d, r9d
	jle	.L14
	mov	rdi, QWORD PTR led_pattern_table[rip]
	lea	r8d, -1[r9]
	xor	edx, edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L25:
	lea	ecx, 1[rdx]
	lea	rsi, 1[rdx]
	cmp	rdx, r8
	je	.L9
	mov	rdx, rsi
.L11:
	mov	ecx, edx
	cmp	DWORD PTR [rdi+rdx*4], eax
	jne	.L25
	mov	rax, QWORD PTR 16[rbx]
	mov	DWORD PTR [rax+rbp*4], ecx
	add	rbp, 1
	cmp	DWORD PTR 8[rbx], ebp
	jg	.L12
	jmp	.L1
.L14:
	xor	ecx, ecx
	.p2align 4,,10
	.p2align 3
.L9:
	cmp	ecx, r9d
	mov	rax, QWORD PTR 16[rbx]
	cmove	ecx, DWORD PTR ETHERSWITCH_PORT_LED_DEFAULT[rip]
	mov	DWORD PTR [rax+rbp*4], ecx
	add	rbp, 1
	cmp	DWORD PTR 8[rbx], ebp
	jg	.L12
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L23:
	mov	r13d, eax
	jmp	.L1
	.cfi_endproc
.LFE0:
	.size	arswitch_getport, .-arswitch_getport
	.comm	led_pattern_table,8,8
	.comm	ar8327_led_mapping,8,8
	.comm	SIOCGIFMEDIA,4,4
	.comm	IFM_FDX,4,4
	.comm	IFM_ETHER,4,4
	.comm	IFM_AVALID,4,4
	.comm	IFM_ACTIVE,4,4
	.comm	IFM_1000_T,4,4
	.comm	ETHERSWITCH_PORT_LED_MAX,4,4
	.comm	ETHERSWITCH_PORT_LED_DEFAULT,4,4
	.comm	ETHERSWITCH_PORT_CPU,4,4
	.comm	ENXIO,4,4
	.comm	AR8327,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_arswitch.c_arswitch_getport.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	arswitch_getport, %function
arswitch_getport:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	mov	r4, r1
	mov	r6, r0
	bl	device_get_softc
	ldr	r3, [r4]
	cmp	r3, #0
	blt	.L7
	ldr	r2, [r0, #4]
	mov	r5, r0
	cmp	r3, r2
	bgt	.L7
	mov	r1, r4
	ldr	r3, [r0]
	blx	r3
	subs	r7, r0, #0
	bne	.L1
	ldr	r1, [r4]
	mov	r0, r5
	bl	arswitch_miiforport
	ldr	r1, [r4]
	mov	r8, r0
	mov	r0, r5
	bl	arswitch_is_cpuport
	cmp	r0, #0
	bne	.L23
	cmp	r8, #0
	beq	.L7
	ldr	r3, .L27
	mov	r2, r8
	ldr	r3, [r3]
	ldr	r0, [r8, #4]
	add	r1, r4, #12
	bl	ifmedia_ioctl
	cmp	r0, #0
	bne	.L24
.L6:
	mov	r0, r5
	ldr	r1, [r4]
	bl	arswitch_is_cpuport
	subs	r8, r0, #0
	beq	.L25
.L8:
	mov	r3, #0
	mov	r0, r7
	str	r3, [r4, #4]
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L7:
	ldr	r3, .L27+4
	ldr	r7, [r3]
.L1:
	mov	r0, r7
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L23:
	ldr	r3, .L27+8
	ldr	r2, .L27+12
	ldr	r0, .L27+16
	ldr	r2, [r2]
	ldr	r1, .L27+20
	ldr	r3, [r3]
	ldr	ip, [r0]
	orr	r3, r3, r2
	ldr	r0, [r1]
	ldr	r2, .L27+24
	ldr	r1, .L27+28
	ldr	r2, [r2]
	ldr	r1, [r1]
	orr	r3, r3, ip
	orr	r2, r2, r1
	ldr	r1, [r4, #36]
	str	r7, [r4, #32]
	orr	r1, r1, r0
	str	r7, [r4, #28]
	str	r3, [r4, #20]
	str	r3, [r4, #16]
	str	r1, [r4, #36]
	str	r2, [r4, #24]
	b	.L6
.L25:
	ldr	r3, .L27+32
	mov	r0, r5
	ldr	r1, [r3]
	bl	AR8X16_IS_SWITCH
	cmp	r0, #0
	beq	.L8
	mov	r2, #3
	ldr	r9, .L27+36
	ldr	r3, [r4]
	ldr	r1, [r9]
	mov	r5, r8
	sub	r3, r3, #-1073741823
	ldr	r7, .L27+40
	ldr	r8, .L27+44
	ldr	r10, .L27+48
	ldr	lr, [r1, r3, lsl #2]
	str	r2, [r4, #4]
.L13:
	add	lr, lr, r5, lsl #3
	ldr	r1, [lr, #4]
	mov	r0, r6
	bl	arswitch_readreg
	ldr	r3, [r4]
	ldr	r2, [r9]
	sub	r3, r3, #-1073741823
	ldr	lr, [r2, r3, lsl #2]
	ldr	ip, [r7]
	ldr	r3, [lr, r5, lsl #3]
	cmp	ip, #0
	asr	r0, r0, r3
	and	r0, r0, #3
	ble	.L9
	ldr	r2, [r10]
	mov	r3, #0
	sub	r2, r2, #4
	b	.L11
.L26:
	add	r3, r3, #1
	cmp	r3, ip
	beq	.L12
.L11:
	ldr	r1, [r2, #4]!
	cmp	r1, r0
	bne	.L26
.L10:
	ldr	r2, [r4, #8]
	str	r3, [r2, r5, lsl #2]
	ldr	r3, [r4, #4]
	add	r5, r5, #1
	cmp	r3, r5
	bgt	.L13
	mov	r7, #0
	b	.L1
.L9:
	movne	r3, #0
	bne	.L10
.L12:
	ldr	r3, [r8]
	b	.L10
.L24:
	mov	r7, r0
	b	.L1
.L28:
	.align	2
.L27:
	.word	SIOCGIFMEDIA
	.word	ENXIO
	.word	IFM_ETHER
	.word	IFM_1000_T
	.word	IFM_FDX
	.word	ETHERSWITCH_PORT_CPU
	.word	IFM_ACTIVE
	.word	IFM_AVALID
	.word	AR8327
	.word	ar8327_led_mapping
	.word	ETHERSWITCH_PORT_LED_MAX
	.word	ETHERSWITCH_PORT_LED_DEFAULT
	.word	led_pattern_table
	.size	arswitch_getport, .-arswitch_getport
	.comm	led_pattern_table,4,4
	.comm	ar8327_led_mapping,4,4
	.comm	SIOCGIFMEDIA,4,4
	.comm	IFM_FDX,4,4
	.comm	IFM_ETHER,4,4
	.comm	IFM_AVALID,4,4
	.comm	IFM_ACTIVE,4,4
	.comm	IFM_1000_T,4,4
	.comm	ETHERSWITCH_PORT_LED_MAX,4,4
	.comm	ETHERSWITCH_PORT_LED_DEFAULT,4,4
	.comm	ETHERSWITCH_PORT_CPU,4,4
	.comm	ENXIO,4,4
	.comm	AR8327,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
