	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cpia_close
_cpia_close:                            ## @cpia_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	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	%rdi, %r14
	movq	(%rdi), %rdi
	callq	_video_get_drvdata
	movq	%rax, %rbx
	cmpq	$0, 8(%rax)
	je	LBB0_4
## %bb.1:
	movq	48(%rbx), %rax
	testq	%rax, %rax
	je	LBB0_3
## %bb.2:
	movq	$0, (%rax)
LBB0_3:
	movq	%rbx, %rdi
	callq	_save_camera_state
	movq	%rbx, %rdi
	callq	_goto_low_power
	movq	_CPIA_COMMAND_GetCameraStatus@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	_do_command
	movl	44(%rbx), %edi
	callq	_free_frames
	movq	8(%rbx), %rax
	movl	40(%rbx), %edi
	callq	*(%rax)
	movq	8(%rbx), %rdi
	callq	_put_cam
LBB0_4:
	decq	(%rbx)
	jne	LBB0_13
## %bb.5:
	movq	32(%rbx), %rdi
	testq	%rdi, %rdi
	je	LBB0_7
## %bb.6:
	movq	_CPIA_MAX_IMAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_rvfree
	movq	$0, 32(%rbx)
LBB0_7:
	movq	24(%rbx), %rdi
	testq	%rdi, %rdi
	je	LBB0_9
## %bb.8:
	movq	_CPIA_MAX_FRAME_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_rvfree
	movq	$0, 24(%rbx)
LBB0_9:
	cmpq	$0, 16(%rbx)
	je	LBB0_11
## %bb.10:
	movq	%rbx, %rdi
	callq	_free_frame_buf
LBB0_11:
	cmpq	$0, 8(%rbx)
	jne	LBB0_13
## %bb.12:
	movq	%rbx, %rdi
	callq	_kfree
LBB0_13:
	movq	$0, (%r14)
	xorl	%eax, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CPIA_COMMAND_GetCameraStatus,4,2 ## @CPIA_COMMAND_GetCameraStatus
	.comm	_CPIA_MAX_IMAGE_SIZE,4,2        ## @CPIA_MAX_IMAGE_SIZE
	.comm	_CPIA_MAX_FRAME_SIZE,4,2        ## @CPIA_MAX_FRAME_SIZE
	.no_dead_strip	_cpia_close
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cpia_close
_cpia_close:                            ; @cpia_close
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	ldr	x0, [x0]
	bl	_video_get_drvdata
	mov	x20, x0
	ldr	x8, [x0, #8]
	cbz	x8, LBB0_4
; %bb.1:
	ldr	x8, [x20, #48]
	cbz	x8, LBB0_3
; %bb.2:
	str	xzr, [x8]
LBB0_3:
	mov	x0, x20
	bl	_save_camera_state
	mov	x0, x20
	bl	_goto_low_power
Lloh0:
	adrp	x8, _CPIA_COMMAND_GetCameraStatus@GOTPAGE
Lloh1:
	ldr	x8, [x8, _CPIA_COMMAND_GetCameraStatus@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x20
	mov	w2, #0
	mov	w3, #0
	mov	w4, #0
	mov	w5, #0
	bl	_do_command
	ldr	w0, [x20, #44]
	bl	_free_frames
	ldr	x8, [x20, #8]
	ldr	x8, [x8]
	ldr	w0, [x20, #40]
	blr	x8
	ldr	x0, [x20, #8]
	bl	_put_cam
LBB0_4:
	ldr	x8, [x20]
	subs	x8, x8, #1
	str	x8, [x20]
	b.ne	LBB0_13
; %bb.5:
	ldr	x0, [x20, #32]
	cbz	x0, LBB0_7
; %bb.6:
Lloh3:
	adrp	x8, _CPIA_MAX_IMAGE_SIZE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CPIA_MAX_IMAGE_SIZE@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	bl	_rvfree
	str	xzr, [x20, #32]
LBB0_7:
	ldr	x0, [x20, #24]
	cbz	x0, LBB0_9
; %bb.8:
Lloh6:
	adrp	x8, _CPIA_MAX_FRAME_SIZE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _CPIA_MAX_FRAME_SIZE@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	bl	_rvfree
	str	xzr, [x20, #24]
LBB0_9:
	ldr	x8, [x20, #16]
	cbz	x8, LBB0_11
; %bb.10:
	mov	x0, x20
	bl	_free_frame_buf
LBB0_11:
	ldr	x8, [x20, #8]
	cbnz	x8, LBB0_13
; %bb.12:
	mov	x0, x20
	bl	_kfree
LBB0_13:
	str	xzr, [x19]
	mov	w0, #0
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_CPIA_COMMAND_GetCameraStatus,4,2 ; @CPIA_COMMAND_GetCameraStatus
	.comm	_CPIA_MAX_IMAGE_SIZE,4,2        ; @CPIA_MAX_IMAGE_SIZE
	.comm	_CPIA_MAX_FRAME_SIZE,4,2        ; @CPIA_MAX_FRAME_SIZE
	.no_dead_strip	_cpia_close
.subsections_via_symbols
