	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_detach_mtd_dev             ## -- Begin function ubi_detach_mtd_dev
	.p2align	4, 0x90
_ubi_detach_mtd_dev:                    ## @ubi_detach_mtd_dev
	.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
	testl	%edi, %edi
	js	LBB0_2
## %bb.1:
	movl	%edi, %ebx
	movq	_UBI_MAX_DEVICES@GOTPCREL(%rip), %rax
	cmpl	%edi, (%rax)
	jle	LBB0_2
## %bb.4:
	movl	%esi, %r15d
	movl	%ebx, %edi
	callq	_ubi_get_device
	testq	%rax, %rax
	je	LBB0_2
## %bb.5:
	movq	%rax, %r12
	movq	_ubi_devices_lock@GOTPCREL(%rip), %rdi
	callq	_spin_lock
	leaq	4(%r12), %r14
	movq	%r14, %rdi
	callq	_put_device
	movq	48(%r12), %rdx
	decq	%rdx
	movq	%rdx, 48(%r12)
	je	LBB0_9
## %bb.6:
	testl	%r15d, %r15d
	je	LBB0_7
## %bb.8:
	movl	56(%r12), %esi
	leaq	L_.str(%rip), %rdi
	callq	_ubi_err
LBB0_9:
	movq	_ubi_devices@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	%ebx, %ecx
	movq	$0, (%rax,%rcx,8)
	movq	_ubi_devices_lock@GOTPCREL(%rip), %rdi
	callq	_spin_unlock
	xorl	%edi, %edi
	cmpl	%ebx, (%r12)
	sete	%dil
	callq	_ubi_assert
	movq	_UBI_VOLUME_REMOVED@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%r15d, %r15d
	movq	%r12, %rdi
	xorl	%edx, %edx
	callq	_ubi_notify_all
	movq	8(%r12), %rax
	movl	(%rax), %esi
	leaq	L_.str.1(%rip), %rdi
	movl	%ebx, %edx
	callq	_dbg_msg
	movq	%r12, %rdi
	addq	$40, %rdi
	callq	_unregister_reboot_notifier
	movq	32(%r12), %rdi
	testq	%rdi, %rdi
	je	LBB0_11
## %bb.10:
	callq	_kthread_stop
LBB0_11:
	movq	%r14, %rdi
	callq	_get_device
	movq	%r12, %rdi
	callq	_uif_close
	movq	%r12, %rdi
	callq	_ubi_wl_close
	movq	%r12, %rdi
	callq	_free_internal_volumes
	movl	28(%r12), %edi
	callq	_vfree
	movq	8(%r12), %rdi
	callq	_put_mtd_device
	movl	24(%r12), %edi
	callq	_vfree
	movl	20(%r12), %edi
	callq	_vfree
	movq	8(%r12), %rax
	movl	(%rax), %esi
	movl	(%r12), %edx
	leaq	L_.str.2(%rip), %rdi
	callq	_ubi_msg
	movq	%r14, %rdi
	callq	_put_device
	jmp	LBB0_12
LBB0_2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_3:
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
LBB0_12:
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	movq	_ubi_devices_lock@GOTPCREL(%rip), %rdi
	callq	_spin_unlock
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_3
	.cfi_endproc
                                        ## -- End function
	.comm	_UBI_MAX_DEVICES,4,2            ## @UBI_MAX_DEVICES
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ubi_devices_lock,4,2           ## @ubi_devices_lock
	.comm	_EBUSY,4,2                      ## @EBUSY
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%s reference count %d, destroy anyway"

	.comm	_ubi_devices,8,3                ## @ubi_devices
	.comm	_UBI_VOLUME_REMOVED,4,2         ## @UBI_VOLUME_REMOVED
L_.str.1:                               ## @.str.1
	.asciz	"detaching mtd%d from ubi%d"

L_.str.2:                               ## @.str.2
	.asciz	"mtd%d is detached from ubi%d"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_detach_mtd_dev             ; -- Begin function ubi_detach_mtd_dev
	.p2align	2
_ubi_detach_mtd_dev:                    ; @ubi_detach_mtd_dev
	.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
	tbnz	w0, #31, LBB0_9
; %bb.1:
	mov	x21, x0
Lloh0:
	adrp	x8, _UBI_MAX_DEVICES@GOTPAGE
Lloh1:
	ldr	x8, [x8, _UBI_MAX_DEVICES@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w8, w0
	b.le	LBB0_9
; %bb.2:
	mov	x22, x1
	mov	x0, x21
	bl	_ubi_get_device
	cbz	x0, LBB0_9
; %bb.3:
	mov	x19, x0
Lloh3:
	adrp	x0, _ubi_devices_lock@GOTPAGE
Lloh4:
	ldr	x0, [x0, _ubi_devices_lock@GOTPAGEOFF]
	bl	_spin_lock
	add	x20, x19, #4
	mov	x0, x20
	bl	_put_device
	ldr	x8, [x19, #48]
	subs	x2, x8, #1
	str	x2, [x19, #48]
	b.eq	LBB0_6
; %bb.4:
	cbz	w22, LBB0_12
; %bb.5:
	ldr	w1, [x19, #56]
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	bl	_ubi_err
LBB0_6:
Lloh7:
	adrp	x8, _ubi_devices@GOTPAGE
Lloh8:
	ldr	x8, [x8, _ubi_devices@GOTPAGEOFF]
Lloh9:
	ldr	x8, [x8]
	str	xzr, [x8, w21, uxtw #3]
Lloh10:
	adrp	x0, _ubi_devices_lock@GOTPAGE
Lloh11:
	ldr	x0, [x0, _ubi_devices_lock@GOTPAGEOFF]
	bl	_spin_unlock
	ldr	w8, [x19]
	cmp	w8, w21
	cset	w0, eq
	bl	_ubi_assert
Lloh12:
	adrp	x8, _UBI_VOLUME_REMOVED@GOTPAGE
Lloh13:
	ldr	x8, [x8, _UBI_VOLUME_REMOVED@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x19
	mov	x2, #0
	bl	_ubi_notify_all
	ldr	x8, [x19, #8]
	ldr	w1, [x8]
Lloh15:
	adrp	x0, l_.str.1@PAGE
Lloh16:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x2, x21
	bl	_dbg_msg
	add	x0, x19, #40
	bl	_unregister_reboot_notifier
	ldr	x0, [x19, #32]
	cbz	x0, LBB0_8
; %bb.7:
	bl	_kthread_stop
LBB0_8:
	mov	x0, x20
	bl	_get_device
	mov	x0, x19
	bl	_uif_close
	mov	x0, x19
	bl	_ubi_wl_close
	mov	x0, x19
	bl	_free_internal_volumes
	ldr	w0, [x19, #28]
	bl	_vfree
	ldr	x0, [x19, #8]
	bl	_put_mtd_device
	ldr	w0, [x19, #24]
	bl	_vfree
	ldr	w0, [x19, #20]
	bl	_vfree
	ldr	x8, [x19, #8]
	ldr	w1, [x8]
	ldr	w2, [x19]
Lloh17:
	adrp	x0, l_.str.2@PAGE
Lloh18:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_ubi_msg
	mov	x0, x20
	bl	_put_device
	mov	w0, #0
	b	LBB0_11
LBB0_9:
Lloh19:
	adrp	x8, _EINVAL@GOTPAGE
Lloh20:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_10:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_11:
	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_12:
Lloh21:
	adrp	x0, _ubi_devices_lock@GOTPAGE
Lloh22:
	ldr	x0, [x0, _ubi_devices_lock@GOTPAGEOFF]
	bl	_spin_unlock
Lloh23:
	adrp	x8, _EBUSY@GOTPAGE
Lloh24:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_10
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.comm	_UBI_MAX_DEVICES,4,2            ; @UBI_MAX_DEVICES
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ubi_devices_lock,4,2           ; @ubi_devices_lock
	.comm	_EBUSY,4,2                      ; @EBUSY
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%s reference count %d, destroy anyway"

	.comm	_ubi_devices,8,3                ; @ubi_devices
	.comm	_UBI_VOLUME_REMOVED,4,2         ; @UBI_VOLUME_REMOVED
l_.str.1:                               ; @.str.1
	.asciz	"detaching mtd%d from ubi%d"

l_.str.2:                               ; @.str.2
	.asciz	"mtd%d is detached from ubi%d"

.subsections_via_symbols
