	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_hl_device_fini                 ## -- Begin function hl_device_fini
	.p2align	4, 0x90
_hl_device_fini:                        ## @hl_device_fini
	.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, %r14
	movl	32(%rdi), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_info
	xorl	%eax, %eax
	callq	_ktime_get
	movq	_HL_PENDING_RESET_PER_SEC@GOTPCREL(%rip), %rcx
	imull	$4000000, (%rcx), %esi          ## imm = 0x3D0900
	movl	%eax, %edi
	callq	_ktime_add_us
	movl	%eax, %r15d
	leaq	52(%r14), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	movl	$1, %edx
	callq	_atomic_cmpxchg
	movl	%eax, %ebx
	.p2align	4, 0x90
LBB0_1:                                 ## =>This Inner Loop Header: Depth=1
	testl	%ebx, %ebx
	je	LBB0_4
## %bb.2:                               ##   in Loop: Header=BB0_1 Depth=1
	movl	$50, %edi
	movl	$200, %esi
	callq	_usleep_range
	movq	%r12, %rdi
	xorl	%esi, %esi
	movl	$1, %edx
	callq	_atomic_cmpxchg
	movl	%eax, %ebx
	xorl	%eax, %eax
	callq	_ktime_get
	movl	%eax, %edi
	movl	%r15d, %esi
	callq	_ktime_compare
	testq	%rax, %rax
	jle	LBB0_1
## %bb.3:
	leaq	L_.str.1(%rip), %rsi
	movl	$1, %edi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_WARN                           ## TAILCALL
LBB0_4:
	movl	$1, (%r14)
	movq	8(%r14), %rax
	movq	%r14, %rdi
	callq	*32(%rax)
	movq	8(%r14), %rax
	movq	%r14, %rdi
	callq	*24(%rax)
	leaq	48(%r14), %rbx
	movq	%rbx, %rdi
	callq	_mutex_lock
	movq	%rbx, %rdi
	callq	_mutex_unlock
	movl	$1, 4(%r14)
	movq	%r14, %rdi
	callq	_hl_hwmon_fini
	movq	%r14, %rdi
	callq	_device_late_fini
	movq	%r14, %rdi
	callq	_hl_debugfs_remove_device
	movq	8(%r14), %rax
	movq	%r14, %rdi
	movl	$1, %esi
	callq	*16(%rax)
	movq	%r14, %rdi
	callq	_hl_cs_rollback_all
	movq	%r14, %rdi
	callq	_device_kill_open_processes
	movq	%r14, %rdi
	callq	_hl_cb_pool_fini
	movq	40(%r14), %rdi
	testq	%rdi, %rdi
	je	LBB0_7
## %bb.5:
	callq	_hl_ctx_put
	cmpl	$1, %eax
	je	LBB0_7
## %bb.6:
	movl	32(%r14), %edi
	leaq	L_.str.2(%rip), %rsi
	callq	_dev_err
LBB0_7:
	movq	8(%r14), %rax
	movq	%r14, %rdi
	movl	$1, %esi
	callq	*8(%rax)
	movq	%r14, %rdi
	callq	_hl_vm_fini
	movq	%r14, %rdi
	callq	_hl_mmu_fini
	leaq	28(%r14), %rsi
	movq	%r14, %rdi
	callq	_hl_eq_fini
	cmpl	$0, 24(%r14)
	jle	LBB0_10
## %bb.8:
	xorl	%r15d, %r15d
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movq	16(%r14), %rsi
	addq	%r15, %rsi
	movq	%r14, %rdi
	callq	_hl_cq_fini
	incq	%rbx
	movslq	24(%r14), %rax
	addq	$4, %r15
	cmpq	%rax, %rbx
	jl	LBB0_9
LBB0_10:
	movq	16(%r14), %rdi
	callq	_kfree
	movq	%r14, %rdi
	callq	_hl_hw_queues_destroy
	movq	8(%r14), %rax
	movq	%r14, %rdi
	callq	*(%rax)
	movq	%r14, %rdi
	callq	_device_early_fini
	movq	%r14, %rdi
	callq	_device_cdev_sysfs_del
	leaq	L_.str.3(%rip), %rdi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_pr_info                        ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Removing device\n"

	.comm	_HL_PENDING_RESET_PER_SEC,4,2   ## @HL_PENDING_RESET_PER_SEC
L_.str.1:                               ## @.str.1
	.asciz	"Failed to remove device because reset function did not finish\n"

L_.str.2:                               ## @.str.2
	.asciz	"kernel ctx is still alive\n"

L_.str.3:                               ## @.str.3
	.asciz	"removed device successfully\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_hl_device_fini                 ; -- Begin function hl_device_fini
	.p2align	2
_hl_device_fini:                        ; @hl_device_fini
	.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
	ldr	w0, [x0, #32]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_info
	bl	_ktime_get
Lloh2:
	adrp	x8, _HL_PENDING_RESET_PER_SEC@GOTPAGE
Lloh3:
	ldr	x8, [x8, _HL_PENDING_RESET_PER_SEC@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	mov	w9, #2304
	movk	w9, #61, lsl #16
	mul	w1, w8, w9
	bl	_ktime_add_us
	mov	x20, x0
	add	x21, x19, #52
	mov	x0, x21
	mov	w1, #0
	mov	w2, #1
	bl	_atomic_cmpxchg
	mov	x22, x0
LBB0_1:                                 ; =>This Inner Loop Header: Depth=1
	cbz	w22, LBB0_4
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	mov	w0, #50
	mov	w1, #200
	bl	_usleep_range
	mov	x0, x21
	mov	w1, #0
	mov	w2, #1
	bl	_atomic_cmpxchg
	mov	x22, x0
	bl	_ktime_get
	mov	x1, x20
	bl	_ktime_compare
	cmp	x0, #1
	b.lt	LBB0_1
; %bb.3:
Lloh5:
	adrp	x1, l_.str.1@PAGE
Lloh6:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	w0, #1
	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
	b	_WARN
LBB0_4:
	mov	w21, #1
	str	w21, [x19]
	ldr	x8, [x19, #8]
	ldr	x8, [x8, #32]
	mov	x0, x19
	blr	x8
	ldr	x8, [x19, #8]
	ldr	x8, [x8, #24]
	mov	x0, x19
	blr	x8
	add	x20, x19, #48
	mov	x0, x20
	bl	_mutex_lock
	mov	x0, x20
	bl	_mutex_unlock
	str	w21, [x19, #4]
	mov	x0, x19
	bl	_hl_hwmon_fini
	mov	x0, x19
	bl	_device_late_fini
	mov	x0, x19
	bl	_hl_debugfs_remove_device
	ldr	x8, [x19, #8]
	ldr	x8, [x8, #16]
	mov	x0, x19
	mov	w1, #1
	blr	x8
	mov	x0, x19
	bl	_hl_cs_rollback_all
	mov	x0, x19
	bl	_device_kill_open_processes
	mov	x0, x19
	bl	_hl_cb_pool_fini
	ldr	x0, [x19, #40]
	cbz	x0, LBB0_7
; %bb.5:
	bl	_hl_ctx_put
	cmp	w0, #1
	b.eq	LBB0_7
; %bb.6:
	ldr	w0, [x19, #32]
Lloh7:
	adrp	x1, l_.str.2@PAGE
Lloh8:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
LBB0_7:
	ldr	x8, [x19, #8]
	ldr	x8, [x8, #8]
	mov	x0, x19
	mov	w1, #1
	blr	x8
	mov	x0, x19
	bl	_hl_vm_fini
	mov	x0, x19
	bl	_hl_mmu_fini
	add	x1, x19, #28
	mov	x0, x19
	bl	_hl_eq_fini
	ldr	w8, [x19, #24]
	cmp	w8, #1
	b.lt	LBB0_10
; %bb.8:
	mov	x20, #0
	mov	x21, #0
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19, #16]
	add	x1, x8, x20
	mov	x0, x19
	bl	_hl_cq_fini
	add	x21, x21, #1
	ldrsw	x8, [x19, #24]
	add	x20, x20, #4
	cmp	x21, x8
	b.lt	LBB0_9
LBB0_10:
	ldr	x0, [x19, #16]
	bl	_kfree
	mov	x0, x19
	bl	_hl_hw_queues_destroy
	ldr	x8, [x19, #8]
	ldr	x8, [x8]
	mov	x0, x19
	blr	x8
	mov	x0, x19
	bl	_device_early_fini
	mov	x0, x19
	bl	_device_cdev_sysfs_del
Lloh9:
	adrp	x0, l_.str.3@PAGE
Lloh10:
	add	x0, x0, l_.str.3@PAGEOFF
	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
	b	_pr_info
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Removing device\n"

	.comm	_HL_PENDING_RESET_PER_SEC,4,2   ; @HL_PENDING_RESET_PER_SEC
l_.str.1:                               ; @.str.1
	.asciz	"Failed to remove device because reset function did not finish\n"

l_.str.2:                               ; @.str.2
	.asciz	"kernel ctx is still alive\n"

l_.str.3:                               ; @.str.3
	.asciz	"removed device successfully\n"

.subsections_via_symbols
