	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ivtv_init_on_first_open        ## -- Begin function ivtv_init_on_first_open
	.p2align	4, 0x90
_ivtv_init_on_first_open:               ## @ivtv_init_on_first_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	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movq	%rdi, -48(%rbp)
	movq	_IVTV_ENC_STREAM_TYPE_MPG@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
	movq	_IVTV_F_I_FAILED@GOTPCREL(%rip), %r15
	movl	(%r15), %edi
	leaq	44(%r14), %rbx
	movq	%rbx, %rsi
	callq	_test_bit
	testq	%rax, %rax
	je	LBB0_2
LBB0_1:
	movq	_ENXIO@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_20
LBB0_2:
	movq	_IVTV_F_I_INITED@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	%rbx, %rsi
	callq	_test_and_set_bit
	movq	%rax, %rcx
	xorl	%eax, %eax
	testq	%rcx, %rcx
	jne	LBB0_20
## %bb.3:
	movq	%r14, %rdi
	callq	_ivtv_firmware_init
	testq	%rax, %rax
	je	LBB0_6
## %bb.4:
	leaq	L_.str(%rip), %rdi
	callq	_IVTV_WARN
	movq	%r14, %rdi
	callq	_ivtv_firmware_init
	testq	%rax, %rax
	je	LBB0_6
## %bb.5:
	movl	(%r15), %edi
	movq	%rbx, %rsi
	callq	_set_bit
	jmp	LBB0_1
LBB0_6:
	leaq	L_.str.1(%rip), %rdi
	callq	_IVTV_DEBUG_INFO
	movq	%r14, %rdi
	callq	_ivtv_firmware_versions
	movq	32(%r14), %rax
	movq	_IVTV_HW_CX25840@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, (%rax)
	je	LBB0_8
## %bb.7:
	movl	40(%r14), %edi
	movq	_core@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_load_fw@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_v4l2_subdev_call
LBB0_8:
	movq	$0, -32(%rbp)
	movq	_V4L2_TUNER_ANALOG_TV@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -36(%rbp)
	movl	$6400, -40(%rbp)                ## imm = 0x1900
	movl	(%r14), %eax
	movq	_V4L2_STD_NTSC_M_JP@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_10
## %bb.9:
	movl	$1460, -40(%rbp)                ## imm = 0x5B4
	jmp	LBB0_12
LBB0_10:
	movq	_V4L2_STD_NTSC_M@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	je	LBB0_12
## %bb.11:
	movl	$1076, -40(%rbp)                ## imm = 0x434
LBB0_12:
	movl	4(%r14), %edx
	leal	1(%rdx), %eax
	movl	%eax, 4(%r14)
	leaq	-56(%rbp), %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_ivtv_s_input
	movl	(%r14), %eax
	incl	%eax
	movl	%eax, (%r14)
	movl	%eax, 8(%r14)
	leaq	-40(%rbp), %rdx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_ivtv_s_frequency
	movq	32(%r14), %rax
	movq	_V4L2_CAP_VIDEO_OUTPUT@GOTPCREL(%rip), %rbx
	movl	(%rbx), %ecx
	testl	%ecx, 4(%rax)
	je	LBB0_14
## %bb.13:
	movq	_IVTV_HW_SAA7127@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_video@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_s_stream@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r14, %rdi
	movl	$1, %r8d
	callq	_ivtv_call_hw
	movq	%r14, %rdi
	callq	_ivtv_init_mpeg_decoder
LBB0_14:
	cmpl	$0, 24(%r14)
	jne	LBB0_16
## %bb.15:
	movq	_IVTV_REG_DMACONTROL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$3, %edi
	callq	_write_reg_sync
LBB0_16:
	movl	20(%r14), %esi
	movq	%r14, %rdi
	callq	_ivtv_s_std_enc
	movl	(%rbx), %eax
	movq	_IVTV_IRQ_MASK_INIT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	testl	%eax, 12(%r14)
	je	LBB0_18
## %bb.17:
	movq	_IVTV_IRQ_DEC_VSYNC@GOTPCREL(%rip), %rax
	orl	(%rax), %esi
	movq	%r14, %rdi
	callq	_ivtv_clear_irq_mask
	movq	%r14, %rdi
	callq	_ivtv_set_osd_alpha
	movl	20(%r14), %esi
	movq	%r14, %rdi
	callq	_ivtv_s_std_dec
	jmp	LBB0_19
LBB0_18:
	movq	%r14, %rdi
	callq	_ivtv_clear_irq_mask
LBB0_19:
	addq	$16, %r14
	movq	%r14, %rdi
	callq	_cx2341x_handler_setup
	xorl	%eax, %eax
LBB0_20:
	addq	$40, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_IVTV_ENC_STREAM_TYPE_MPG,4,2   ## @IVTV_ENC_STREAM_TYPE_MPG
	.comm	_IVTV_F_I_FAILED,4,2            ## @IVTV_F_I_FAILED
	.comm	_ENXIO,4,2                      ## @ENXIO
	.comm	_IVTV_F_I_INITED,4,2            ## @IVTV_F_I_INITED
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Retry loading firmware\n"

L_.str.1:                               ## @.str.1
	.asciz	"Getting firmware version..\n"

	.comm	_IVTV_HW_CX25840,4,2            ## @IVTV_HW_CX25840
	.comm	_core,4,2                       ## @core
	.comm	_load_fw,4,2                    ## @load_fw
	.comm	_V4L2_TUNER_ANALOG_TV,4,2       ## @V4L2_TUNER_ANALOG_TV
	.comm	_V4L2_STD_NTSC_M_JP,4,2         ## @V4L2_STD_NTSC_M_JP
	.comm	_V4L2_STD_NTSC_M,4,2            ## @V4L2_STD_NTSC_M
	.comm	_V4L2_CAP_VIDEO_OUTPUT,4,2      ## @V4L2_CAP_VIDEO_OUTPUT
	.comm	_IVTV_HW_SAA7127,4,2            ## @IVTV_HW_SAA7127
	.comm	_video,4,2                      ## @video
	.comm	_s_stream,4,2                   ## @s_stream
	.comm	_IVTV_REG_DMACONTROL,4,2        ## @IVTV_REG_DMACONTROL
	.comm	_IVTV_IRQ_MASK_INIT,4,2         ## @IVTV_IRQ_MASK_INIT
	.comm	_IVTV_IRQ_DEC_VSYNC,4,2         ## @IVTV_IRQ_DEC_VSYNC
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ivtv_init_on_first_open        ; -- Begin function ivtv_init_on_first_open
	.p2align	2
_ivtv_init_on_first_open:               ; @ivtv_init_on_first_open
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	str	x0, [sp, #8]
Lloh0:
	adrp	x8, _IVTV_ENC_STREAM_TYPE_MPG@GOTPAGE
Lloh1:
	ldr	x8, [x8, _IVTV_ENC_STREAM_TYPE_MPG@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	str	w8, [sp]
Lloh3:
	adrp	x21, _IVTV_F_I_FAILED@GOTPAGE
Lloh4:
	ldr	x21, [x21, _IVTV_F_I_FAILED@GOTPAGEOFF]
	ldr	w0, [x21]
	add	x20, x19, #44
	mov	x1, x20
	bl	_test_bit
	cbz	x0, LBB0_2
LBB0_1:
Lloh5:
	adrp	x8, _ENXIO@GOTPAGE
Lloh6:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_22
LBB0_2:
Lloh8:
	adrp	x8, _IVTV_F_I_INITED@GOTPAGE
Lloh9:
	ldr	x8, [x8, _IVTV_F_I_INITED@GOTPAGEOFF]
Lloh10:
	ldr	w0, [x8]
	mov	x1, x20
	bl	_test_and_set_bit
	cbnz	x0, LBB0_21
; %bb.3:
	mov	x0, x19
	bl	_ivtv_firmware_init
	cbz	x0, LBB0_6
; %bb.4:
Lloh11:
	adrp	x0, l_.str@PAGE
Lloh12:
	add	x0, x0, l_.str@PAGEOFF
	bl	_IVTV_WARN
	mov	x0, x19
	bl	_ivtv_firmware_init
	cbz	x0, LBB0_6
; %bb.5:
	ldr	w0, [x21]
	mov	x1, x20
	bl	_set_bit
	b	LBB0_1
LBB0_6:
Lloh13:
	adrp	x0, l_.str.1@PAGE
Lloh14:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_IVTV_DEBUG_INFO
	mov	x0, x19
	bl	_ivtv_firmware_versions
	ldr	x8, [x19, #32]
	ldr	w8, [x8]
Lloh15:
	adrp	x9, _IVTV_HW_CX25840@GOTPAGE
Lloh16:
	ldr	x9, [x9, _IVTV_HW_CX25840@GOTPAGEOFF]
Lloh17:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_8
; %bb.7:
	ldr	w0, [x19, #40]
Lloh18:
	adrp	x8, _core@GOTPAGE
Lloh19:
	ldr	x8, [x8, _core@GOTPAGEOFF]
Lloh20:
	ldr	w1, [x8]
Lloh21:
	adrp	x8, _load_fw@GOTPAGE
Lloh22:
	ldr	x8, [x8, _load_fw@GOTPAGEOFF]
Lloh23:
	ldr	w2, [x8]
	bl	_v4l2_subdev_call
LBB0_8:
	str	xzr, [sp, #24]
Lloh24:
	adrp	x8, _V4L2_TUNER_ANALOG_TV@GOTPAGE
Lloh25:
	ldr	x8, [x8, _V4L2_TUNER_ANALOG_TV@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	mov	w9, #6400
	stp	w9, w8, [sp, #16]
	ldr	w8, [x19]
Lloh27:
	adrp	x9, _V4L2_STD_NTSC_M_JP@GOTPAGE
Lloh28:
	ldr	x9, [x9, _V4L2_STD_NTSC_M_JP@GOTPAGEOFF]
Lloh29:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_10
; %bb.9:
	mov	w8, #1460
	b	LBB0_12
LBB0_10:
Lloh30:
	adrp	x9, _V4L2_STD_NTSC_M@GOTPAGE
Lloh31:
	ldr	x9, [x9, _V4L2_STD_NTSC_M@GOTPAGEOFF]
Lloh32:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_13
; %bb.11:
	mov	w8, #1076
LBB0_12:
	str	w8, [sp, #16]
LBB0_13:
	ldr	w2, [x19, #4]
	add	w8, w2, #1
	str	w8, [x19, #4]
	mov	x1, sp
	mov	x0, #0
	bl	_ivtv_s_input
	ldr	w8, [x19]
	add	w8, w8, #1
	str	w8, [x19]
	str	w8, [x19, #8]
	mov	x1, sp
	add	x2, sp, #16
	mov	x0, #0
	bl	_ivtv_s_frequency
	ldr	x8, [x19, #32]
	ldr	w8, [x8, #4]
Lloh33:
	adrp	x20, _V4L2_CAP_VIDEO_OUTPUT@GOTPAGE
Lloh34:
	ldr	x20, [x20, _V4L2_CAP_VIDEO_OUTPUT@GOTPAGEOFF]
	ldr	w9, [x20]
	tst	w9, w8
	b.eq	LBB0_15
; %bb.14:
Lloh35:
	adrp	x8, _IVTV_HW_SAA7127@GOTPAGE
Lloh36:
	ldr	x8, [x8, _IVTV_HW_SAA7127@GOTPAGEOFF]
Lloh37:
	ldr	w1, [x8]
Lloh38:
	adrp	x8, _video@GOTPAGE
Lloh39:
	ldr	x8, [x8, _video@GOTPAGEOFF]
Lloh40:
	ldr	w2, [x8]
Lloh41:
	adrp	x8, _s_stream@GOTPAGE
Lloh42:
	ldr	x8, [x8, _s_stream@GOTPAGEOFF]
Lloh43:
	ldr	w3, [x8]
	mov	x0, x19
	mov	w4, #1
	bl	_ivtv_call_hw
	mov	x0, x19
	bl	_ivtv_init_mpeg_decoder
LBB0_15:
	ldr	w8, [x19, #24]
	cbnz	w8, LBB0_17
; %bb.16:
Lloh44:
	adrp	x8, _IVTV_REG_DMACONTROL@GOTPAGE
Lloh45:
	ldr	x8, [x8, _IVTV_REG_DMACONTROL@GOTPAGEOFF]
Lloh46:
	ldr	w1, [x8]
	mov	w0, #3
	bl	_write_reg_sync
LBB0_17:
	ldr	w1, [x19, #20]
	mov	x0, x19
	bl	_ivtv_s_std_enc
	ldr	w8, [x19, #12]
	ldr	w9, [x20]
Lloh47:
	adrp	x10, _IVTV_IRQ_MASK_INIT@GOTPAGE
Lloh48:
	ldr	x10, [x10, _IVTV_IRQ_MASK_INIT@GOTPAGEOFF]
Lloh49:
	ldr	w1, [x10]
	tst	w9, w8
	b.eq	LBB0_19
; %bb.18:
Lloh50:
	adrp	x8, _IVTV_IRQ_DEC_VSYNC@GOTPAGE
Lloh51:
	ldr	x8, [x8, _IVTV_IRQ_DEC_VSYNC@GOTPAGEOFF]
Lloh52:
	ldr	w8, [x8]
	orr	w1, w8, w1
	mov	x0, x19
	bl	_ivtv_clear_irq_mask
	mov	x0, x19
	bl	_ivtv_set_osd_alpha
	ldr	w1, [x19, #20]
	mov	x0, x19
	bl	_ivtv_s_std_dec
	b	LBB0_20
LBB0_19:
	mov	x0, x19
	bl	_ivtv_clear_irq_mask
LBB0_20:
	add	x0, x19, #16
	bl	_cx2341x_handler_setup
LBB0_21:
	mov	w0, #0
LBB0_22:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh41, Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh44, Lloh45, Lloh46
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpLdrGotLdr	Lloh50, Lloh51, Lloh52
	.cfi_endproc
                                        ; -- End function
	.comm	_IVTV_ENC_STREAM_TYPE_MPG,4,2   ; @IVTV_ENC_STREAM_TYPE_MPG
	.comm	_IVTV_F_I_FAILED,4,2            ; @IVTV_F_I_FAILED
	.comm	_ENXIO,4,2                      ; @ENXIO
	.comm	_IVTV_F_I_INITED,4,2            ; @IVTV_F_I_INITED
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Retry loading firmware\n"

l_.str.1:                               ; @.str.1
	.asciz	"Getting firmware version..\n"

	.comm	_IVTV_HW_CX25840,4,2            ; @IVTV_HW_CX25840
	.comm	_core,4,2                       ; @core
	.comm	_load_fw,4,2                    ; @load_fw
	.comm	_V4L2_TUNER_ANALOG_TV,4,2       ; @V4L2_TUNER_ANALOG_TV
	.comm	_V4L2_STD_NTSC_M_JP,4,2         ; @V4L2_STD_NTSC_M_JP
	.comm	_V4L2_STD_NTSC_M,4,2            ; @V4L2_STD_NTSC_M
	.comm	_V4L2_CAP_VIDEO_OUTPUT,4,2      ; @V4L2_CAP_VIDEO_OUTPUT
	.comm	_IVTV_HW_SAA7127,4,2            ; @IVTV_HW_SAA7127
	.comm	_video,4,2                      ; @video
	.comm	_s_stream,4,2                   ; @s_stream
	.comm	_IVTV_REG_DMACONTROL,4,2        ; @IVTV_REG_DMACONTROL
	.comm	_IVTV_IRQ_MASK_INIT,4,2         ; @IVTV_IRQ_MASK_INIT
	.comm	_IVTV_IRQ_DEC_VSYNC,4,2         ; @IVTV_IRQ_DEC_VSYNC
.subsections_via_symbols
