	.file	"extr_if_cgem.c_cgem_detach.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	cgem_detach, @function
cgem_detach:
.LFB0:
	.cfi_startproc
	endbr64
	push	r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	push	r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	mov	r12d, edi
	push	rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	push	rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	sub	rsp, 8
	.cfi_def_cfa_offset 48
	call	device_get_softc@PLT
	test	rax, rax
	je	.L60
	mov	edi, r12d
	mov	rbp, rax
	call	device_is_attached@PLT
	test	rax, rax
	jne	.L61
	mov	rsi, QWORD PTR 104[rbp]
	test	rsi, rsi
	je	.L5
.L65:
	mov	edi, r12d
	call	device_delete_child@PLT
	mov	QWORD PTR 104[rbp], 0
.L5:
	mov	r13, QWORD PTR 96[rbp]
	test	r13, r13
	je	.L6
	mov	rdi, r13
	call	rman_get_rid@PLT
	mov	esi, DWORD PTR SYS_RES_MEMORY[rip]
	mov	rcx, r13
	mov	edi, r12d
	mov	edx, eax
	call	bus_release_resource@PLT
	mov	QWORD PTR 96[rbp], 0
.L6:
	mov	r13, QWORD PTR 80[rbp]
	test	r13, r13
	je	.L7
	mov	rdx, QWORD PTR 88[rbp]
	test	rdx, rdx
	jne	.L62
.L8:
	mov	rdi, r13
	call	rman_get_rid@PLT
	mov	esi, DWORD PTR SYS_RES_IRQ[rip]
	mov	rcx, r13
	mov	edi, r12d
	mov	edx, eax
	call	bus_release_resource@PLT
	mov	QWORD PTR 80[rbp], 0
.L7:
	mov	rsi, QWORD PTR 64[rbp]
	mov	rdi, QWORD PTR 24[rbp]
	test	rsi, rsi
	je	.L9
	cmp	QWORD PTR 0[rbp], 0
	mov	edx, DWORD PTR 72[rbp]
	jne	.L63
.L10:
	call	bus_dmamem_free@PLT
	mov	edx, DWORD PTR CGEM_NUM_RX_DESCS[rip]
	mov	QWORD PTR 64[rbp], 0
	test	edx, edx
	jle	.L57
	mov	rax, QWORD PTR 56[rbp]
	xor	ebx, ebx
	.p2align 4,,10
	.p2align 3
.L11:
	mov	rsi, QWORD PTR [rax+rbx*8]
	test	rsi, rsi
	je	.L12
	mov	rdi, QWORD PTR 16[rbp]
	call	bus_dmamap_destroy@PLT
	mov	rax, QWORD PTR 56[rbp]
	mov	QWORD PTR [rax+rbx*8], 0
.L12:
	add	rbx, 1
	cmp	DWORD PTR CGEM_NUM_RX_DESCS[rip], ebx
	jg	.L11
.L57:
	mov	rdi, QWORD PTR 24[rbp]
.L9:
	mov	rsi, QWORD PTR 40[rbp]
	test	rsi, rsi
	je	.L13
	cmp	QWORD PTR 8[rbp], 0
	mov	edx, DWORD PTR 48[rbp]
	jne	.L64
.L14:
	call	bus_dmamem_free@PLT
	mov	eax, DWORD PTR CGEM_NUM_TX_DESCS[rip]
	mov	QWORD PTR 40[rbp], 0
	test	eax, eax
	jle	.L58
	mov	rax, QWORD PTR 32[rbp]
	xor	ebx, ebx
	.p2align 4,,10
	.p2align 3
.L15:
	mov	rsi, QWORD PTR [rax+rbx*8]
	test	rsi, rsi
	je	.L16
	mov	rdi, QWORD PTR 16[rbp]
	call	bus_dmamap_destroy@PLT
	mov	rax, QWORD PTR 32[rbp]
	mov	QWORD PTR [rax+rbx*8], 0
.L16:
	add	rbx, 1
	cmp	DWORD PTR CGEM_NUM_TX_DESCS[rip], ebx
	jg	.L15
.L58:
	mov	rdi, QWORD PTR 24[rbp]
.L13:
	test	rdi, rdi
	je	.L17
	call	bus_dma_tag_destroy@PLT
	mov	QWORD PTR 24[rbp], 0
.L17:
	mov	rdi, QWORD PTR 16[rbp]
	test	rdi, rdi
	je	.L18
	call	bus_dma_tag_destroy@PLT
	mov	QWORD PTR 16[rbp], 0
.L18:
	mov	edi, r12d
	call	bus_generic_detach@PLT
	mov	rdi, rbp
	call	CGEM_LOCK_DESTROY@PLT
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xor	eax, eax
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L61:
	.cfi_restore_state
	mov	rdi, rbp
	call	CGEM_LOCK@PLT
	mov	rdi, rbp
	call	cgem_stop@PLT
	mov	rdi, rbp
	call	CGEM_UNLOCK@PLT
	lea	rdi, 116[rbp]
	call	callout_drain@PLT
	mov	edi, DWORD PTR 112[rbp]
	mov	edx, DWORD PTR IFF_UP[rip]
	xor	esi, esi
	call	if_setflagbits@PLT
	mov	edi, DWORD PTR 112[rbp]
	call	ether_ifdetach@PLT
	mov	rsi, QWORD PTR 104[rbp]
	test	rsi, rsi
	jne	.L65
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L60:
	mov	eax, DWORD PTR ENODEV[rip]
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L64:
	.cfi_restore_state
	mov	esi, edx
	call	bus_dmamap_unload@PLT
	mov	QWORD PTR 8[rbp], 0
	mov	edx, DWORD PTR 48[rbp]
	mov	rsi, QWORD PTR 40[rbp]
	mov	rdi, QWORD PTR 24[rbp]
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L62:
	mov	rsi, r13
	mov	edi, r12d
	call	bus_teardown_intr@PLT
	mov	r13, QWORD PTR 80[rbp]
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L63:
	mov	esi, edx
	call	bus_dmamap_unload@PLT
	mov	QWORD PTR 0[rbp], 0
	mov	edx, DWORD PTR 72[rbp]
	mov	rsi, QWORD PTR 64[rbp]
	mov	rdi, QWORD PTR 24[rbp]
	jmp	.L10
	.cfi_endproc
.LFE0:
	.size	cgem_detach, .-cgem_detach
	.comm	SYS_RES_MEMORY,4,4
	.comm	SYS_RES_IRQ,4,4
	.comm	IFF_UP,4,4
	.comm	ENODEV,4,4
	.comm	CGEM_NUM_TX_DESCS,4,4
	.comm	CGEM_NUM_RX_DESCS,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_if_cgem.c_cgem_detach.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	cgem_detach, %function
cgem_detach:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, lr}
	mov	r6, r0
	bl	device_get_softc
	subs	r4, r0, #0
	beq	.L66
	mov	r0, r6
	bl	device_is_attached
	cmp	r0, #0
	bne	.L67
	ldr	r1, [r4, #52]
	cmp	r1, #0
	beq	.L5
.L71:
	mov	r0, r6
	bl	device_delete_child
	mov	r3, #0
	str	r3, [r4, #52]
.L5:
	ldr	r0, [r4, #48]
	cmp	r0, #0
	beq	.L6
	ldr	r3, .L72
	ldr	r5, [r3]
	bl	rman_get_rid
	ldr	r3, [r4, #48]
	mov	r2, r0
	mov	r1, r5
	mov	r0, r6
	bl	bus_release_resource
	mov	r3, #0
	str	r3, [r4, #48]
.L6:
	ldr	r0, [r4, #40]
	cmp	r0, #0
	beq	.L7
	ldr	r2, [r4, #44]
	cmp	r2, #0
	bne	.L68
.L8:
	ldr	r3, .L72+4
	ldr	r5, [r3]
	bl	rman_get_rid
	ldr	r3, [r4, #40]
	mov	r2, r0
	mov	r1, r5
	mov	r0, r6
	bl	bus_release_resource
	mov	r3, #0
	str	r3, [r4, #40]
.L7:
	ldr	r1, [r4, #32]
	ldr	r0, [r4, #12]
	cmp	r1, #0
	beq	.L9
	ldr	r3, [r4]
	ldr	r2, [r4, #36]
	cmp	r3, #0
	bne	.L69
.L10:
	mov	r5, #0
	ldr	r7, .L72+8
	bl	bus_dmamem_free
	ldr	r3, [r7]
	str	r5, [r4, #32]
	cmp	r3, r5
	movgt	r8, r5
	ldrgt	r3, [r4, #28]
	ble	.L63
.L11:
	ldr	r1, [r3, r5, lsl #2]
	cmp	r1, #0
	beq	.L12
	ldr	r0, [r4, #8]
	bl	bus_dmamap_destroy
	ldr	r3, [r4, #28]
	str	r8, [r3, r5, lsl #2]
.L12:
	ldr	r2, [r7]
	add	r5, r5, #1
	cmp	r2, r5
	bgt	.L11
.L63:
	ldr	r0, [r4, #12]
.L9:
	ldr	r1, [r4, #20]
	cmp	r1, #0
	beq	.L13
	ldr	r3, [r4, #4]
	ldr	r2, [r4, #24]
	cmp	r3, #0
	bne	.L70
.L14:
	mov	r5, #0
	ldr	r7, .L72+12
	bl	bus_dmamem_free
	ldr	r3, [r7]
	str	r5, [r4, #20]
	cmp	r3, r5
	movgt	r8, r5
	ldrgt	r3, [r4, #16]
	ble	.L64
.L15:
	ldr	r1, [r3, r5, lsl #2]
	cmp	r1, #0
	beq	.L16
	ldr	r0, [r4, #8]
	bl	bus_dmamap_destroy
	ldr	r3, [r4, #16]
	str	r8, [r3, r5, lsl #2]
.L16:
	ldr	r2, [r7]
	add	r5, r5, #1
	cmp	r2, r5
	bgt	.L15
.L64:
	ldr	r0, [r4, #12]
.L13:
	cmp	r0, #0
	beq	.L17
	bl	bus_dma_tag_destroy
	mov	r3, #0
	str	r3, [r4, #12]
.L17:
	ldr	r0, [r4, #8]
	cmp	r0, #0
	beq	.L18
	bl	bus_dma_tag_destroy
	mov	r3, #0
	str	r3, [r4, #8]
.L18:
	mov	r0, r6
	bl	bus_generic_detach
	mov	r0, r4
	bl	CGEM_LOCK_DESTROY
	mov	r0, #0
	pop	{r4, r5, r6, r7, r8, pc}
.L67:
	mov	r0, r4
	bl	CGEM_LOCK
	mov	r0, r4
	bl	cgem_stop
	mov	r0, r4
	bl	CGEM_UNLOCK
	add	r0, r4, #60
	bl	callout_drain
	ldr	r3, .L72+16
	mov	r1, #0
	ldr	r2, [r3]
	ldr	r0, [r4, #56]
	bl	if_setflagbits
	ldr	r0, [r4, #56]
	bl	ether_ifdetach
	ldr	r1, [r4, #52]
	cmp	r1, #0
	bne	.L71
	b	.L5
.L66:
	ldr	r3, .L72+20
	ldr	r0, [r3]
	pop	{r4, r5, r6, r7, r8, pc}
.L70:
	mov	r1, r2
	bl	bus_dmamap_unload
	mov	r3, #0
	ldr	r0, [r4, #12]
	ldr	r1, [r4, #20]
	ldr	r2, [r4, #24]
	str	r3, [r4, #4]
	b	.L14
.L68:
	mov	r1, r0
	mov	r0, r6
	bl	bus_teardown_intr
	ldr	r0, [r4, #40]
	b	.L8
.L69:
	mov	r1, r2
	bl	bus_dmamap_unload
	mov	r3, #0
	ldr	r0, [r4, #12]
	ldr	r1, [r4, #32]
	ldr	r2, [r4, #36]
	str	r3, [r4]
	b	.L10
.L73:
	.align	2
.L72:
	.word	SYS_RES_MEMORY
	.word	SYS_RES_IRQ
	.word	CGEM_NUM_RX_DESCS
	.word	CGEM_NUM_TX_DESCS
	.word	IFF_UP
	.word	ENODEV
	.size	cgem_detach, .-cgem_detach
	.comm	SYS_RES_MEMORY,4,4
	.comm	SYS_RES_IRQ,4,4
	.comm	IFF_UP,4,4
	.comm	ENODEV,4,4
	.comm	CGEM_NUM_TX_DESCS,4,4
	.comm	CGEM_NUM_RX_DESCS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
