	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bttv_prepare_buffer
_bttv_prepare_buffer:                   ## @bttv_prepare_buffer
	.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
                                        ## kill: def $r9d killed $r9d def $r9
	testq	%rcx, %rcx
	je	LBB0_1
## %bb.2:
	movq	%rdx, %r12
	movq	%rsi, %r14
	movq	%rdi, %r15
	movl	16(%rbp), %r10d
	movq	(%rcx), %rax
	movq	_BT848_COLOR_FMT_RAW@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rax
	jne	LBB0_6
## %bb.3:
	movq	_RAW_BPL@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	_RAW_LINES@GOTPCREL(%rip), %rax
	movl	(%rax), %r9d
	addl	%r9d, %r9d
	movl	%r9d, %edx
	imull	%r8d, %edx
	movl	8(%r12), %eax
	cmpl	%eax, %edx
	ja	LBB0_1
## %bb.4:
	movl	%eax, 12(%r12)
	movl	(%r14), %edx
	movq	_bttv_tvnorms@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movslq	%edx, %rdi
	shlq	$5, %rdi
	movq	(%rax,%rdi), %rsi
	cmpq	%rsi, 8(%r14)
	jg	LBB0_1
## %bb.5:
	movdqu	8(%rax,%rdi), %xmm0
	movq	24(%rax,%rdi), %rdi
LBB0_14:
	cmpl	%r8d, 24(%r12)
	jne	LBB0_24
## %bb.15:
	cmpl	%r9d, 28(%r12)
	jne	LBB0_24
## %bb.16:
	cmpl	%r10d, 32(%r12)
	jne	LBB0_24
## %bb.17:
	cmpl	%edx, (%r12)
	jne	LBB0_24
## %bb.18:
	cmpq	%rcx, 80(%r12)
	jne	LBB0_24
## %bb.19:
	cmpq	%rsi, 48(%r12)
	jne	LBB0_24
## %bb.20:
	movq	%xmm0, %rax
	cmpq	%rax, 56(%r12)
	jne	LBB0_24
## %bb.21:
	pextrq	$1, %xmm0, %rax
	cmpq	%rax, 64(%r12)
	jne	LBB0_24
## %bb.22:
	cmpq	%rdi, 72(%r12)
	jne	LBB0_24
## %bb.23:
	movq	_VIDEOBUF_NEEDS_INIT@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	leaq	40(%r12), %r13
	cmpq	40(%r12), %rax
	je	LBB0_25
	jmp	LBB0_27
LBB0_6:
	movq	(%r15), %rax
	movq	24(%r14), %rdi
	xorl	%edx, %edx
	cmpl	$0, (%rax)
	setne	%dl
	leaq	(%rdx,%rdx,2), %rbx
	shlq	$4, %rbx
	cmpl	%r8d, (%rdi,%rbx)
	ja	LBB0_1
## %bb.7:
	cmpl	%r8d, 4(%rdi,%rbx)
	jb	LBB0_1
## %bb.8:
	cmpl	%r9d, 8(%rdi,%rbx)
	ja	LBB0_1
## %bb.9:
	movl	(%r14), %edx
	movl	12(%rdi,%rbx), %eax
	movq	16(%rdi,%rbx), %rsi
	movdqu	24(%rdi,%rbx), %xmm0
	movq	40(%rdi,%rbx), %rdi
	leal	-128(%r10), %ebx
	cmpl	$2, %ebx
	ja	LBB0_11
## %bb.10:
	leal	(%r9,%r9), %ebx
	cmpl	%eax, %ebx
	jbe	LBB0_12
	jmp	LBB0_1
LBB0_24:
	movl	%r8d, 24(%r12)
	movl	%r9d, 28(%r12)
	movl	%r10d, 32(%r12)
	movl	%edx, (%r12)
	movq	%rcx, 80(%r12)
	movq	%rsi, 48(%r12)
	movdqu	%xmm0, 56(%r12)
	movq	%rdi, 72(%r12)
	movq	_VIDEOBUF_NEEDS_INIT@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	leaq	40(%r12), %r13
	cmpq	40(%r12), %rax
	jne	LBB0_26
LBB0_25:
	leaq	8(%r12), %rsi
	leaq	16(%r14), %rdx
	movq	%r15, %rdi
	callq	_videobuf_iolock
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_28
LBB0_26:
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_bttv_buffer_risc
	movl	%eax, %ebx
	testl	%eax, %eax
	je	LBB0_27
LBB0_28:
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%r12, %rdx
	callq	_bttv_dma_free
	jmp	LBB0_29
LBB0_11:
	cmpl	%r9d, %eax
	jb	LBB0_1
LBB0_12:
	movl	%r9d, %eax
	imull	%r8d, %eax
	imull	8(%rcx), %eax
	shrl	$3, %eax
	movl	%eax, 12(%r12)
	cmpq	$0, 16(%r12)
	je	LBB0_14
## %bb.13:
	cmpl	%eax, 8(%r12)
	jae	LBB0_14
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_29:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_27:
	movq	_VIDEOBUF_PREPARED@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%r13)
	xorl	%ebx, %ebx
	jmp	LBB0_29
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_BT848_COLOR_FMT_RAW,8,3        ## @BT848_COLOR_FMT_RAW
	.comm	_RAW_BPL,4,2                    ## @RAW_BPL
	.comm	_RAW_LINES,4,2                  ## @RAW_LINES
	.comm	_bttv_tvnorms,8,3               ## @bttv_tvnorms
	.comm	_VIDEOBUF_NEEDS_INIT,8,3        ## @VIDEOBUF_NEEDS_INIT
	.comm	_VIDEOBUF_PREPARED,8,3          ## @VIDEOBUF_PREPARED
	.no_dead_strip	_bttv_prepare_buffer
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bttv_prepare_buffer
_bttv_prepare_buffer:                   ; @bttv_prepare_buffer
	.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
	cbz	x3, LBB0_26
; %bb.1:
	mov	x19, x2
	mov	x20, x1
	mov	x21, x0
	ldr	x8, [x3]
Lloh0:
	adrp	x9, _BT848_COLOR_FMT_RAW@GOTPAGE
Lloh1:
	ldr	x9, [x9, _BT848_COLOR_FMT_RAW@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_15
; %bb.2:
Lloh3:
	adrp	x8, _RAW_BPL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _RAW_BPL@GOTPAGEOFF]
Lloh5:
	adrp	x9, _RAW_LINES@GOTPAGE
Lloh6:
	ldr	x9, [x9, _RAW_LINES@GOTPAGEOFF]
Lloh7:
	ldr	w4, [x8]
Lloh8:
	ldr	w8, [x9]
	lsl	w5, w8, #1
	mul	w9, w5, w4
	ldr	w8, [x19, #8]
	cmp	w9, w8
	b.hi	LBB0_26
; %bb.3:
	str	w8, [x19, #12]
	ldr	w8, [x20]
Lloh9:
	adrp	x9, _bttv_tvnorms@GOTPAGE
Lloh10:
	ldr	x9, [x9, _bttv_tvnorms@GOTPAGEOFF]
	ldr	x11, [x20, #8]
Lloh11:
	ldr	x10, [x9]
	sbfiz	x9, x8, #5, #32
	ldr	x9, [x10, x9]
	cmp	x11, x9
	b.gt	LBB0_26
; %bb.4:
	sxtw	x11, w8
	add	x12, x10, x11, lsl #5
	ldp	x10, x11, [x12, #8]
	ldr	x12, [x12, #24]
LBB0_5:
	ldr	w13, [x19, #24]
	cmp	w13, w4
	b.ne	LBB0_19
; %bb.6:
	ldr	w13, [x19, #28]
	cmp	w13, w5
	b.ne	LBB0_19
; %bb.7:
	ldr	w13, [x19, #32]
	cmp	w13, w6
	b.ne	LBB0_19
; %bb.8:
	ldr	w13, [x19]
	cmp	w13, w8
	b.ne	LBB0_19
; %bb.9:
	ldr	x13, [x19, #80]
	cmp	x13, x3
	b.ne	LBB0_19
; %bb.10:
	ldr	x13, [x19, #48]
	cmp	x13, x9
	b.ne	LBB0_19
; %bb.11:
	ldr	x13, [x19, #56]
	cmp	x13, x10
	b.ne	LBB0_19
; %bb.12:
	ldr	x13, [x19, #64]
	cmp	x13, x11
	b.ne	LBB0_19
; %bb.13:
	ldr	x13, [x19, #72]
	cmp	x13, x12
	b.ne	LBB0_19
; %bb.14:
Lloh12:
	adrp	x8, _VIDEOBUF_NEEDS_INIT@GOTPAGE
Lloh13:
	ldr	x8, [x8, _VIDEOBUF_NEEDS_INIT@GOTPAGEOFF]
Lloh14:
	ldr	x8, [x8]
	mov	x23, x19
	ldr	x9, [x23, #40]!
	cmp	x8, x9
	b.eq	LBB0_20
	b	LBB0_28
LBB0_15:
	ldr	x9, [x21]
	ldr	x8, [x20, #24]
	ldr	w9, [x9]
	cmp	w9, #0
	cset	w9, ne
	mov	w10, #48
	umaddl	x12, w9, w10, x8
	ldr	w10, [x12]
	cmp	w10, w4
	b.hi	LBB0_26
; %bb.16:
	mov	w10, #48
	madd	x8, x9, x10, x8
	ldp	w8, w9, [x8, #4]
	cmp	w8, w4
	ccmp	w9, w5, #2, hs
	b.hi	LBB0_26
; %bb.17:
	ldr	w8, [x20]
	ldr	w13, [x12, #12]
	ldp	x9, x10, [x12, #16]
	sub	w14, w6, #128
	ldp	x11, x12, [x12, #32]
	cmp	w14, #2
	b.hi	LBB0_23
; %bb.18:
	cmp	w13, w5, lsl #1
	b.hs	LBB0_24
	b	LBB0_26
LBB0_19:
	stp	w4, w5, [x19, #24]
	str	w6, [x19, #32]
	str	w8, [x19]
	str	x3, [x19, #80]
	stp	x9, x10, [x19, #48]
Lloh15:
	adrp	x8, _VIDEOBUF_NEEDS_INIT@GOTPAGE
Lloh16:
	ldr	x8, [x8, _VIDEOBUF_NEEDS_INIT@GOTPAGEOFF]
	stp	x11, x12, [x19, #64]
Lloh17:
	ldr	x8, [x8]
	mov	x23, x19
	ldr	x9, [x23, #40]!
	cmp	x8, x9
	b.ne	LBB0_21
LBB0_20:
	add	x1, x19, #8
	add	x2, x20, #16
	mov	x0, x21
	bl	_videobuf_iolock
	mov	x22, x0
	cbnz	w0, LBB0_22
LBB0_21:
	mov	x0, x20
	mov	x1, x19
	bl	_bttv_buffer_risc
	mov	x22, x0
	cbz	w0, LBB0_28
LBB0_22:
	mov	x0, x21
	mov	x1, x20
	mov	x2, x19
	bl	_bttv_dma_free
	b	LBB0_27
LBB0_23:
	cmp	w13, w5
	b.lo	LBB0_26
LBB0_24:
	mul	w13, w5, w4
	ldr	w14, [x3, #8]
	mul	w13, w13, w14
	lsr	w13, w13, #3
	str	w13, [x19, #12]
	ldr	x14, [x19, #16]
	cbz	x14, LBB0_5
; %bb.25:
	ldr	w14, [x19, #8]
	cmp	w14, w13
	b.hs	LBB0_5
LBB0_26:
Lloh18:
	adrp	x8, _EINVAL@GOTPAGE
Lloh19:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_27:
	mov	x0, x22
	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_28:
	mov	w22, #0
Lloh21:
	adrp	x8, _VIDEOBUF_PREPARED@GOTPAGE
Lloh22:
	ldr	x8, [x8, _VIDEOBUF_PREPARED@GOTPAGEOFF]
Lloh23:
	ldr	x8, [x8]
	str	x8, [x23]
	b	LBB0_27
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh7
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_BT848_COLOR_FMT_RAW,8,3        ; @BT848_COLOR_FMT_RAW
	.comm	_RAW_BPL,4,2                    ; @RAW_BPL
	.comm	_RAW_LINES,4,2                  ; @RAW_LINES
	.comm	_bttv_tvnorms,8,3               ; @bttv_tvnorms
	.comm	_VIDEOBUF_NEEDS_INIT,8,3        ; @VIDEOBUF_NEEDS_INIT
	.comm	_VIDEOBUF_PREPARED,8,3          ; @VIDEOBUF_PREPARED
	.no_dead_strip	_bttv_prepare_buffer
.subsections_via_symbols
