	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cpia_open
_cpia_open:                             ## @cpia_open
	.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, %r13
	movq	%rax, %rdi
	callq	_video_get_drvdata
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r15
	cmpq	$0, (%rax)
	jle	LBB0_4
## %bb.3:
	leaq	L_.str.1(%rip), %rdi
	callq	_DBG
	movq	_EBUSY@GOTPCREL(%rip), %rax
	jmp	LBB0_6
LBB0_1:
	leaq	L_.str(%rip), %rdi
	callq	_DBG
LBB0_5:
	movq	_ENODEV@GOTPCREL(%rip), %rax
LBB0_6:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_23:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	16(%r15), %rax
	movl	16(%rax), %edi
	callq	_try_module_get
	testl	%eax, %eax
	je	LBB0_5
## %bb.7:
	movq	%r15, %r14
	addq	$24, %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	cmpq	$0, 32(%r15)
	jne	LBB0_9
## %bb.8:
	movq	_CPIA_MAX_IMAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_rvmalloc
	movq	%rax, 32(%r15)
	testq	%rax, %rax
	je	LBB0_14
LBB0_9:
	cmpq	$0, 40(%r15)
	jne	LBB0_11
## %bb.10:
	movq	_CPIA_MAX_FRAME_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_rvmalloc
	movq	%rax, 40(%r15)
	testq	%rax, %rax
	je	LBB0_14
LBB0_11:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movq	16(%r15), %rax
	movl	64(%r15), %edi
	callq	*8(%rax)
	testq	%rax, %rax
	jne	LBB0_14
## %bb.12:
	movq	%r15, %rdi
	callq	_reset_camera
	testl	%eax, %eax
	je	LBB0_19
## %bb.13:
	movl	%eax, %ebx
	movq	16(%r15), %rax
	movl	64(%r15), %edi
	callq	*(%rax)
	jmp	LBB0_14
LBB0_19:
	movq	_EINTR@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movq	_current@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_signal_pending
	testq	%rax, %rax
	je	LBB0_20
LBB0_14:
	movq	40(%r15), %rdi
	testq	%rdi, %rdi
	je	LBB0_16
## %bb.15:
	movq	_CPIA_MAX_FRAME_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_rvfree
	movq	$0, 40(%r15)
LBB0_16:
	movq	32(%r15), %rdi
	testq	%rdi, %rdi
	je	LBB0_18
## %bb.17:
	movq	_CPIA_MAX_IMAGE_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_rvfree
	movq	$0, 32(%r15)
LBB0_18:
	movq	%r14, %rdi
	callq	_mutex_unlock
	movq	16(%r15), %rdi
	callq	_put_cam
	jmp	LBB0_23
LBB0_20:
	cmpq	$0, 56(%r15)
	je	LBB0_22
## %bb.21:
	xorl	%eax, %eax
	callq	_current_uid
	movq	56(%r15), %rcx
	movl	%eax, (%rcx)
LBB0_22:
	movl	$1, 8(%r15)
	movq	$0, 48(%r15)
	incq	(%r15)
	movq	%r13, (%r12)
	movq	%r14, %rdi
	callq	_mutex_unlock
	xorl	%ebx, %ebx
	jmp	LBB0_23
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Internal error, cam_data not found!\n"

	.comm	_ENODEV,4,2                     ## @ENODEV
L_.str.1:                               ## @.str.1
	.asciz	"Camera already open\n"

	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_CPIA_MAX_IMAGE_SIZE,4,2        ## @CPIA_MAX_IMAGE_SIZE
	.comm	_CPIA_MAX_FRAME_SIZE,4,2        ## @CPIA_MAX_FRAME_SIZE
	.comm	_EINTR,4,2                      ## @EINTR
	.comm	_current,4,2                    ## @current
	.no_dead_strip	_cpia_open
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cpia_open
_cpia_open:                             ; @cpia_open
	.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	x21, x0
	bl	_video_devdata
	mov	x22, x0
	bl	_video_get_drvdata
	cbz	x0, LBB0_3
; %bb.1:
	mov	x19, x0
	ldr	x8, [x0]
	cmp	x8, #1
	b.lt	LBB0_7
; %bb.2:
Lloh0:
	adrp	x0, l_.str.1@PAGE
Lloh1:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_DBG
Lloh2:
	adrp	x8, _EBUSY@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	b	LBB0_5
LBB0_3:
Lloh4:
	adrp	x0, l_.str@PAGE
Lloh5:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DBG
LBB0_4:
Lloh6:
	adrp	x8, _ENODEV@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_5:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_6:
	mov	x0, x23
	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_7:
	ldr	x8, [x19, #16]
	ldr	w0, [x8, #16]
	bl	_try_module_get
	cbz	w0, LBB0_4
; %bb.8:
	add	x20, x19, #24
	mov	x0, x20
	bl	_mutex_lock
Lloh8:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh9:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w23, w8
	ldr	x8, [x19, #32]
	cbnz	x8, LBB0_10
; %bb.9:
Lloh11:
	adrp	x8, _CPIA_MAX_IMAGE_SIZE@GOTPAGE
Lloh12:
	ldr	x8, [x8, _CPIA_MAX_IMAGE_SIZE@GOTPAGEOFF]
Lloh13:
	ldr	w0, [x8]
	bl	_rvmalloc
	str	x0, [x19, #32]
	cbz	x0, LBB0_14
LBB0_10:
	ldr	x8, [x19, #40]
	cbnz	x8, LBB0_12
; %bb.11:
Lloh14:
	adrp	x8, _CPIA_MAX_FRAME_SIZE@GOTPAGE
Lloh15:
	ldr	x8, [x8, _CPIA_MAX_FRAME_SIZE@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
	bl	_rvmalloc
	str	x0, [x19, #40]
	cbz	x0, LBB0_14
LBB0_12:
Lloh17:
	adrp	x8, _ENODEV@GOTPAGE
Lloh18:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh19:
	ldr	w23, [x8]
	ldr	x8, [x19, #16]
	ldr	x8, [x8, #8]
	ldr	w0, [x19, #64]
	blr	x8
	cbz	x0, LBB0_19
LBB0_13:
	neg	w23, w23
LBB0_14:
	ldr	x0, [x19, #40]
	cbz	x0, LBB0_16
LBB0_15:
Lloh20:
	adrp	x8, _CPIA_MAX_FRAME_SIZE@GOTPAGE
Lloh21:
	ldr	x8, [x8, _CPIA_MAX_FRAME_SIZE@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	bl	_rvfree
	str	xzr, [x19, #40]
LBB0_16:
	ldr	x0, [x19, #32]
	cbz	x0, LBB0_18
; %bb.17:
Lloh23:
	adrp	x8, _CPIA_MAX_IMAGE_SIZE@GOTPAGE
Lloh24:
	ldr	x8, [x8, _CPIA_MAX_IMAGE_SIZE@GOTPAGEOFF]
Lloh25:
	ldr	w1, [x8]
	bl	_rvfree
	str	xzr, [x19, #32]
LBB0_18:
	mov	x0, x20
	bl	_mutex_unlock
	ldr	x0, [x19, #16]
	bl	_put_cam
	b	LBB0_6
LBB0_19:
	mov	x0, x19
	bl	_reset_camera
	cbz	w0, LBB0_21
; %bb.20:
	mov	x23, x0
	ldr	x8, [x19, #16]
	ldr	x8, [x8]
	ldr	w0, [x19, #64]
	blr	x8
	ldr	x0, [x19, #40]
	cbnz	x0, LBB0_15
	b	LBB0_16
LBB0_21:
Lloh26:
	adrp	x8, _EINTR@GOTPAGE
Lloh27:
	ldr	x8, [x8, _EINTR@GOTPAGEOFF]
Lloh28:
	ldr	w23, [x8]
Lloh29:
	adrp	x8, _current@GOTPAGE
Lloh30:
	ldr	x8, [x8, _current@GOTPAGEOFF]
Lloh31:
	ldr	w0, [x8]
	bl	_signal_pending
	cbnz	x0, LBB0_13
; %bb.22:
	ldr	x8, [x19, #56]
	cbz	x8, LBB0_24
; %bb.23:
	bl	_current_uid
	ldr	x8, [x19, #56]
	str	w0, [x8]
LBB0_24:
	mov	w8, #1
	str	w8, [x19, #8]
	str	xzr, [x19, #48]
	ldr	x8, [x19]
	add	x8, x8, #1
	str	x8, [x19]
	str	x22, [x21]
	mov	x0, x20
	bl	_mutex_unlock
	mov	w23, #0
	b	LBB0_6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Internal error, cam_data not found!\n"

	.comm	_ENODEV,4,2                     ; @ENODEV
l_.str.1:                               ; @.str.1
	.asciz	"Camera already open\n"

	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_CPIA_MAX_IMAGE_SIZE,4,2        ; @CPIA_MAX_IMAGE_SIZE
	.comm	_CPIA_MAX_FRAME_SIZE,4,2        ; @CPIA_MAX_FRAME_SIZE
	.comm	_EINTR,4,2                      ; @EINTR
	.comm	_current,4,2                    ; @current
	.no_dead_strip	_cpia_open
.subsections_via_symbols
