	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cpia2_close
_cpia2_close:                           ## @cpia2_close
	.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	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r12
	callq	_video_devdata
	movq	%rax, %r14
	movq	%rax, %rdi
	callq	_video_get_drvdata
	movq	%rax, %rbx
	movq	(%r12), %r13
	leaq	16(%rax), %r15
	movq	%r15, %rdi
	callq	_mutex_lock
	cmpq	$0, 24(%rbx)
	je	LBB0_5
## %bb.1:
	cmpl	$1, (%rbx)
	je	LBB0_3
## %bb.2:
	movq	8(%r13), %rax
	movq	_V4L2_PRIORITY_RECORD@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_5
LBB0_3:
	movq	%rbx, %rdi
	callq	_cpia2_usb_stream_stop
	cmpl	$1, (%rbx)
	jne	LBB0_5
## %bb.4:
	movq	%rbx, %rdi
	callq	_cpia2_save_camera_state
	movq	%rbx, %rdi
	callq	_cpia2_set_low_power
	movq	%rbx, %rdi
	callq	_cpia2_free_buffers
LBB0_5:
	cmpq	$0, 32(%r13)
	je	LBB0_7
## %bb.6:
	movq	$0, 32(%rbx)
LBB0_7:
	movq	%rbx, %rdi
	addq	$8, %rdi
	leaq	8(%r13), %rsi
	callq	_v4l2_prio_close
	movq	$0, (%r12)
	movq	%r13, %rdi
	callq	_kfree
	decl	(%rbx)
	jne	LBB0_10
## %bb.8:
	movq	%rbx, %rdi
	callq	_cpia2_free_buffers
	cmpq	$0, 24(%rbx)
	je	LBB0_9
LBB0_10:
	movq	%r15, %rdi
	callq	_mutex_unlock
LBB0_11:
	xorl	%eax, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	movq	%r14, %rdi
	callq	_video_unregister_device
	movq	%r15, %rdi
	callq	_mutex_unlock
	movq	%rbx, %rdi
	callq	_kfree
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_V4L2_PRIORITY_RECORD,8,3       ## @V4L2_PRIORITY_RECORD
	.no_dead_strip	_cpia2_close
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cpia2_close
_cpia2_close:                           ; @cpia2_close
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x22, x0
	bl	_video_devdata
	mov	x20, x0
	bl	_video_get_drvdata
	mov	x19, x0
	ldr	x23, [x22]
	add	x21, x0, #16
	mov	x0, x21
	bl	_mutex_lock
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_5
; %bb.1:
	ldr	w8, [x19]
	cmp	w8, #1
	b.eq	LBB0_3
; %bb.2:
	ldr	x8, [x23, #8]
Lloh0:
	adrp	x9, _V4L2_PRIORITY_RECORD@GOTPAGE
Lloh1:
	ldr	x9, [x9, _V4L2_PRIORITY_RECORD@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_5
LBB0_3:
	mov	x0, x19
	bl	_cpia2_usb_stream_stop
	ldr	w8, [x19]
	cmp	w8, #1
	b.ne	LBB0_5
; %bb.4:
	mov	x0, x19
	bl	_cpia2_save_camera_state
	mov	x0, x19
	bl	_cpia2_set_low_power
	mov	x0, x19
	bl	_cpia2_free_buffers
LBB0_5:
	ldr	x8, [x23, #32]
	cbz	x8, LBB0_7
; %bb.6:
	str	xzr, [x19, #32]
LBB0_7:
	add	x0, x19, #8
	add	x1, x23, #8
	bl	_v4l2_prio_close
	str	xzr, [x22]
	mov	x0, x23
	bl	_kfree
	ldr	w8, [x19]
	subs	w8, w8, #1
	str	w8, [x19]
	b.ne	LBB0_9
; %bb.8:
	mov	x0, x19
	bl	_cpia2_free_buffers
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_11
LBB0_9:
	mov	x0, x21
	bl	_mutex_unlock
LBB0_10:
	mov	w0, #0
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_11:
	mov	x0, x20
	bl	_video_unregister_device
	mov	x0, x21
	bl	_mutex_unlock
	mov	x0, x19
	bl	_kfree
	b	LBB0_10
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_V4L2_PRIORITY_RECORD,8,3       ; @V4L2_PRIORITY_RECORD
	.no_dead_strip	_cpia2_close
.subsections_via_symbols
