	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ivtv_claim_stream              ## -- Begin function ivtv_claim_stream
	.p2align	4, 0x90
_ivtv_claim_stream:                     ## @ivtv_claim_stream
	.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
	movl	%esi, %r12d
	movq	%rdi, %r15
	movq	8(%rdi), %r14
	movq	(%r14), %rbx
	movslq	%esi, %r13
	movq	_IVTV_F_S_CLAIMED@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	shlq	$4, %r13
	leaq	(%rbx,%r13), %rsi
	callq	_test_and_set_bit
	testq	%rax, %rax
	je	LBB0_7
## %bb.1:
	movq	8(%rbx,%r13), %rax
	cmpq	%r15, %rax
	je	LBB0_18
## %bb.2:
	testq	%rax, %rax
	jne	LBB0_6
## %bb.3:
	movq	_IVTV_DEC_STREAM_TYPE_VBI@GOTPCREL(%rip), %rax
	cmpl	%r12d, (%rax)
	je	LBB0_5
## %bb.4:
	movq	_IVTV_ENC_STREAM_TYPE_VBI@GOTPCREL(%rip), %rax
	cmpl	%r12d, (%rax)
	je	LBB0_5
LBB0_6:
	leaq	L_.str.1(%rip), %rdi
	xorl	%r15d, %r15d
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	_IVTV_DEBUG_INFO
	movq	_EBUSY@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
	jmp	LBB0_19
LBB0_7:
	movq	%r15, 8(%rbx,%r13)
	movq	_IVTV_DEC_STREAM_TYPE_VBI@GOTPCREL(%rip), %r13
	cmpl	%r12d, (%r13)
	jne	LBB0_9
## %bb.8:
	movq	_IVTV_IRQ_DEC_VBI_RE_INSERT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_ivtv_clear_irq_mask
LBB0_9:
	movq	_IVTV_DEC_STREAM_TYPE_MPG@GOTPCREL(%rip), %rcx
	movq	%r13, %rax
	cmpl	%r12d, (%rcx)
	movq	_IVTV_F_S_CLAIMED@GOTPCREL(%rip), %rbx
	jne	LBB0_10
LBB0_14:
	movslq	(%rax), %r15
	movl	(%rbx), %edi
	movq	%r15, %rbx
	shlq	$4, %rbx
	addq	(%r14), %rbx
	movq	%rbx, %rsi
	callq	_test_and_set_bit
	testq	%rax, %rax
	jne	LBB0_17
## %bb.15:
	cmpl	(%r13), %r15d
	jne	LBB0_17
## %bb.16:
	movq	_IVTV_IRQ_DEC_VBI_RE_INSERT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_ivtv_clear_irq_mask
LBB0_17:
	movq	_IVTV_F_S_INTERNAL_USE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	%rbx, %rsi
	callq	_set_bit
LBB0_18:
	xorl	%r15d, %r15d
LBB0_19:
	movl	%r15d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_10:
	movq	_IVTV_ENC_STREAM_TYPE_MPG@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	cmpl	%r12d, (%rax)
	jne	LBB0_19
## %bb.11:
	cmpq	$0, 8(%r14)
	je	LBB0_19
## %bb.12:
	movq	%r14, %rdi
	callq	_ivtv_raw_vbi
	testl	%eax, %eax
	jne	LBB0_19
## %bb.13:
	movq	_IVTV_ENC_STREAM_TYPE_VBI@GOTPCREL(%rip), %rax
	jmp	LBB0_14
LBB0_5:
	leaq	(%rbx,%r13), %rax
	addq	$8, %rax
	movq	%r15, (%rax)
	leaq	L_.str(%rip), %rdi
	xorl	%r15d, %r15d
	xorl	%eax, %eax
	callq	_IVTV_DEBUG_INFO
	jmp	LBB0_19
	.cfi_endproc
                                        ## -- End function
	.comm	_IVTV_F_S_CLAIMED,4,2           ## @IVTV_F_S_CLAIMED
	.comm	_IVTV_DEC_STREAM_TYPE_VBI,4,2   ## @IVTV_DEC_STREAM_TYPE_VBI
	.comm	_IVTV_ENC_STREAM_TYPE_VBI,4,2   ## @IVTV_ENC_STREAM_TYPE_VBI
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Start Read VBI\n"

L_.str.1:                               ## @.str.1
	.asciz	"Stream %d is busy\n"

	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_IVTV_IRQ_DEC_VBI_RE_INSERT,4,2 ## @IVTV_IRQ_DEC_VBI_RE_INSERT
	.comm	_IVTV_DEC_STREAM_TYPE_MPG,4,2   ## @IVTV_DEC_STREAM_TYPE_MPG
	.comm	_IVTV_ENC_STREAM_TYPE_MPG,4,2   ## @IVTV_ENC_STREAM_TYPE_MPG
	.comm	_IVTV_F_S_INTERNAL_USE,4,2      ## @IVTV_F_S_INTERNAL_USE
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ivtv_claim_stream              ; -- Begin function ivtv_claim_stream
	.p2align	2
_ivtv_claim_stream:                     ; @ivtv_claim_stream
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x20, x1
	mov	x21, x0
	ldr	x19, [x0, #8]
	ldr	x23, [x19]
	mov	x8, x1
	sxtw	x24, w8
Lloh0:
	adrp	x22, _IVTV_F_S_CLAIMED@GOTPAGE
Lloh1:
	ldr	x22, [x22, _IVTV_F_S_CLAIMED@GOTPAGEOFF]
	ldr	w0, [x22]
	add	x1, x23, w1, sxtw #4
	bl	_test_and_set_bit
	add	x8, x23, x24, lsl #4
	cbz	x0, LBB0_5
; %bb.1:
	ldr	x9, [x8, #8]!
	cmp	x9, x21
	b.eq	LBB0_15
; %bb.2:
	cbnz	x9, LBB0_11
; %bb.3:
Lloh2:
	adrp	x9, _IVTV_DEC_STREAM_TYPE_VBI@GOTPAGE
Lloh3:
	ldr	x9, [x9, _IVTV_DEC_STREAM_TYPE_VBI@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
Lloh5:
	adrp	x10, _IVTV_ENC_STREAM_TYPE_VBI@GOTPAGE
Lloh6:
	ldr	x10, [x10, _IVTV_ENC_STREAM_TYPE_VBI@GOTPAGEOFF]
Lloh7:
	ldr	w10, [x10]
	cmp	w9, w20
	ccmp	w10, w20, #4, ne
	b.ne	LBB0_11
; %bb.4:
	str	x21, [x8]
Lloh8:
	adrp	x0, l_.str@PAGE
Lloh9:
	add	x0, x0, l_.str@PAGEOFF
	bl	_IVTV_DEBUG_INFO
	b	LBB0_15
LBB0_5:
	str	x21, [x8, #8]
Lloh10:
	adrp	x8, _IVTV_DEC_STREAM_TYPE_VBI@GOTPAGE
Lloh11:
	ldr	x8, [x8, _IVTV_DEC_STREAM_TYPE_VBI@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	cmp	w8, w20
	b.ne	LBB0_7
; %bb.6:
Lloh13:
	adrp	x8, _IVTV_IRQ_DEC_VBI_RE_INSERT@GOTPAGE
Lloh14:
	ldr	x8, [x8, _IVTV_IRQ_DEC_VBI_RE_INSERT@GOTPAGEOFF]
Lloh15:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_ivtv_clear_irq_mask
LBB0_7:
Lloh16:
	adrp	x8, _IVTV_DEC_STREAM_TYPE_MPG@GOTPAGE
Lloh17:
	ldr	x8, [x8, _IVTV_DEC_STREAM_TYPE_MPG@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x8]
Lloh19:
	adrp	x21, _IVTV_DEC_STREAM_TYPE_VBI@GOTPAGE
Lloh20:
	ldr	x21, [x21, _IVTV_DEC_STREAM_TYPE_VBI@GOTPAGEOFF]
	mov	x8, x21
	cmp	w9, w20
	b.ne	LBB0_12
LBB0_8:
	ldrsw	x23, [x8]
	ldr	x8, [x19]
	ldr	w0, [x22]
	add	x20, x8, x23, lsl #4
	mov	x1, x20
	bl	_test_and_set_bit
	ldr	w8, [x21]
	cmp	x0, #0
	ccmp	w23, w8, #0, eq
	b.ne	LBB0_10
; %bb.9:
Lloh21:
	adrp	x8, _IVTV_IRQ_DEC_VBI_RE_INSERT@GOTPAGE
Lloh22:
	ldr	x8, [x8, _IVTV_IRQ_DEC_VBI_RE_INSERT@GOTPAGEOFF]
Lloh23:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_ivtv_clear_irq_mask
LBB0_10:
Lloh24:
	adrp	x8, _IVTV_F_S_INTERNAL_USE@GOTPAGE
Lloh25:
	ldr	x8, [x8, _IVTV_F_S_INTERNAL_USE@GOTPAGEOFF]
Lloh26:
	ldr	w0, [x8]
	mov	x1, x20
	bl	_set_bit
	b	LBB0_15
LBB0_11:
	str	x20, [sp]
Lloh27:
	adrp	x0, l_.str.1@PAGE
Lloh28:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_IVTV_DEBUG_INFO
Lloh29:
	adrp	x8, _EBUSY@GOTPAGE
Lloh30:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
Lloh31:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_16
LBB0_12:
Lloh32:
	adrp	x8, _IVTV_ENC_STREAM_TYPE_MPG@GOTPAGE
Lloh33:
	ldr	x8, [x8, _IVTV_ENC_STREAM_TYPE_MPG@GOTPAGEOFF]
Lloh34:
	ldr	w8, [x8]
	cmp	w8, w20
	b.ne	LBB0_15
; %bb.13:
	ldr	x8, [x19, #8]
	cbz	x8, LBB0_15
; %bb.14:
	mov	x0, x19
	bl	_ivtv_raw_vbi
	cbz	w0, LBB0_17
LBB0_15:
	mov	w0, #0
LBB0_16:
	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
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_17:
Lloh35:
	adrp	x8, _IVTV_ENC_STREAM_TYPE_VBI@GOTPAGE
Lloh36:
	ldr	x8, [x8, _IVTV_ENC_STREAM_TYPE_VBI@GOTPAGEOFF]
	b	LBB0_8
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.comm	_IVTV_F_S_CLAIMED,4,2           ; @IVTV_F_S_CLAIMED
	.comm	_IVTV_DEC_STREAM_TYPE_VBI,4,2   ; @IVTV_DEC_STREAM_TYPE_VBI
	.comm	_IVTV_ENC_STREAM_TYPE_VBI,4,2   ; @IVTV_ENC_STREAM_TYPE_VBI
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Start Read VBI\n"

l_.str.1:                               ; @.str.1
	.asciz	"Stream %d is busy\n"

	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_IVTV_IRQ_DEC_VBI_RE_INSERT,4,2 ; @IVTV_IRQ_DEC_VBI_RE_INSERT
	.comm	_IVTV_DEC_STREAM_TYPE_MPG,4,2   ; @IVTV_DEC_STREAM_TYPE_MPG
	.comm	_IVTV_ENC_STREAM_TYPE_MPG,4,2   ; @IVTV_ENC_STREAM_TYPE_MPG
	.comm	_IVTV_F_S_INTERNAL_USE,4,2      ; @IVTV_F_S_INTERNAL_USE
.subsections_via_symbols
