	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal16,16byte_literals
	.p2align	4                               ## -- Begin function bttv_s_fbuf
LCPI0_0:
	.space	16
	.section	__TEXT,__text,regular,pure_instructions
	.p2align	4, 0x90
_bttv_s_fbuf:                           ## @bttv_s_fbuf
	.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	%rdx, %r12
	movq	%rsi, %r15
	movq	56(%rsi), %r14
	movq	_CAP_SYS_ADMIN@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_capable
	testl	%eax, %eax
	jne	LBB0_4
## %bb.1:
	movq	_CAP_SYS_RAWIO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_capable
	testl	%eax, %eax
	je	LBB0_2
LBB0_4:
	movl	24(%r12), %edi
	callq	_format_by_fourcc
	testq	%rax, %rax
	je	LBB0_5
## %bb.6:
	movq	%rax, %r13
	movq	_FORMAT_FLAGS_PACKED@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r13)
	je	LBB0_5
## %bb.7:
	movq	_V4L2_FBUF_FLAG_OVERLAY@GOTPCREL(%rip), %rdi
	movl	(%rdi), %eax
	testl	%eax, (%r12)
	je	LBB0_9
## %bb.8:
	movl	8(%r12), %eax
	movl	%eax, -48(%rbp)
	movl	12(%r12), %eax
	movl	%eax, -44(%rbp)
	movq	_V4L2_FIELD_INTERLACED@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	leaq	-48(%rbp), %rsi
	leaq	-44(%rbp), %rdx
	movq	%rdi, %rbx
	movq	%r15, %rdi
	movl	$-4, %r8d
	movl	$2, %r9d
	pushq	$0
	pushq	$0
	callq	_limit_scaled_size_lock
	movq	%rbx, %rdi
	addq	$16, %rsp
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_14
LBB0_9:
	movl	32(%r12), %eax
	movl	%eax, 40(%r14)
	movl	8(%r12), %eax
	movl	%eax, 24(%r14)
	movl	12(%r12), %ecx
	movl	%ecx, 28(%r14)
	movq	16(%r12), %rdx
	testq	%rdx, %rdx
	jne	LBB0_11
## %bb.10:
	movl	4(%r13), %edx
	imull	%eax, %edx
	leal	7(%rdx), %esi
	testl	%edx, %edx
	cmovnsl	%edx, %esi
	sarl	$3, %esi
	movslq	%esi, %rdx
LBB0_11:
	movq	%rdx, 32(%r14)
	movq	%r13, (%r15)
	movq	%r13, 16(%r14)
	movl	(%rdi), %edx
	xorl	%ebx, %ebx
	testl	%edx, (%r12)
	je	LBB0_14
## %bb.12:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 32(%r15)
	movl	%eax, 24(%r15)
	movl	%ecx, 28(%r15)
	movl	%eax, 8(%r14)
	movl	%ecx, 12(%r14)
	movq	16(%r15), %rdi
	callq	_kfree
	xorps	%xmm0, %xmm0
	movups	%xmm0, 8(%r15)
	movq	_RESOURCE_OVERLAY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_check_btres
	testq	%rax, %rax
	je	LBB0_14
## %bb.13:
	leaq	8(%r15), %r12
	movl	$4, %edi
	callq	_videobuf_sg_alloc
	movq	%rax, %rbx
	movq	(%r14), %rax
	xorl	%ecx, %ecx
	cmpl	$0, 48(%r15)
	setne	%cl
	movl	(%rax,%rcx,4), %eax
	movl	%eax, (%rbx)
	movq	(%r15), %rdx
	movq	%r14, %rdi
	movq	%r12, %rsi
	movq	%rbx, %rcx
	callq	_bttv_overlay_risc
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	callq	_bttv_switch_overlay
	movl	%eax, %ebx
	jmp	LBB0_14
LBB0_5:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_2:
	movq	_EPERM@GOTPCREL(%rip), %rax
LBB0_3:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_14:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CAP_SYS_ADMIN,4,2              ## @CAP_SYS_ADMIN
	.comm	_CAP_SYS_RAWIO,4,2              ## @CAP_SYS_RAWIO
	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_FORMAT_FLAGS_PACKED,4,2        ## @FORMAT_FLAGS_PACKED
	.comm	_V4L2_FBUF_FLAG_OVERLAY,4,2     ## @V4L2_FBUF_FLAG_OVERLAY
	.comm	_V4L2_FIELD_INTERLACED,4,2      ## @V4L2_FIELD_INTERLACED
	.comm	_RESOURCE_OVERLAY,4,2           ## @RESOURCE_OVERLAY
	.no_dead_strip	_bttv_s_fbuf
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bttv_s_fbuf
_bttv_s_fbuf:                           ; @bttv_s_fbuf
	.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	x21, x2
	mov	x19, x1
	ldr	x20, [x1, #56]
Lloh0:
	adrp	x8, _CAP_SYS_ADMIN@GOTPAGE
Lloh1:
	ldr	x8, [x8, _CAP_SYS_ADMIN@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	bl	_capable
	cbnz	w0, LBB0_2
; %bb.1:
Lloh3:
	adrp	x8, _CAP_SYS_RAWIO@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CAP_SYS_RAWIO@GOTPAGEOFF]
Lloh5:
	ldr	w0, [x8]
	bl	_capable
	cbz	w0, LBB0_12
LBB0_2:
	ldr	w0, [x21, #24]
	bl	_format_by_fourcc
	cbz	x0, LBB0_11
; %bb.3:
	mov	x22, x0
	ldr	w8, [x0]
Lloh6:
	adrp	x9, _FORMAT_FLAGS_PACKED@GOTPAGE
Lloh7:
	ldr	x9, [x9, _FORMAT_FLAGS_PACKED@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_11
; %bb.4:
	ldr	w8, [x21]
Lloh9:
	adrp	x23, _V4L2_FBUF_FLAG_OVERLAY@GOTPAGE
Lloh10:
	ldr	x23, [x23, _V4L2_FBUF_FLAG_OVERLAY@GOTPAGEOFF]
	ldr	w9, [x23]
	tst	w9, w8
	b.eq	LBB0_6
; %bb.5:
	ldp	w8, w9, [x21, #8]
	stp	w9, w8, [sp, #8]
Lloh11:
	adrp	x8, _V4L2_FIELD_INTERLACED@GOTPAGE
Lloh12:
	ldr	x8, [x8, _V4L2_FIELD_INTERLACED@GOTPAGEOFF]
Lloh13:
	ldr	w3, [x8]
	add	x1, sp, #12
	add	x2, sp, #8
	mov	x0, x19
	mov	w4, #-4
	mov	w5, #2
	mov	w6, #0
	mov	w7, #0
	bl	_limit_scaled_size_lock
	cbnz	w0, LBB0_14
LBB0_6:
	ldr	w8, [x21, #32]
	str	w8, [x20, #40]
	ldp	w8, w9, [x21, #8]
	stp	w8, w9, [x20, #24]
	ldr	x10, [x21, #16]
	cbnz	x10, LBB0_8
; %bb.7:
	ldr	w10, [x22, #4]
	mul	w10, w10, w8
	add	w11, w10, #7
	cmp	w10, #0
	csel	w10, w11, w10, lt
	sbfx	x10, x10, #3, #29
LBB0_8:
	str	x10, [x20, #32]
	str	x22, [x19]
	str	x22, [x20, #16]
	ldr	w10, [x21]
	ldr	w11, [x23]
	tst	w11, w10
	b.eq	LBB0_15
; %bb.9:
	stp	xzr, xzr, [x19, #32]
	stp	w8, w9, [x19, #24]
	stp	w8, w9, [x20, #8]
	ldr	x0, [x19, #16]
	bl	_kfree
	mov	x21, x19
	str	xzr, [x21, #8]!
	str	xzr, [x19, #16]
Lloh14:
	adrp	x8, _RESOURCE_OVERLAY@GOTPAGE
Lloh15:
	ldr	x8, [x8, _RESOURCE_OVERLAY@GOTPAGEOFF]
Lloh16:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_check_btres
	cbz	x0, LBB0_14
; %bb.10:
	mov	w0, #4
	bl	_videobuf_sg_alloc
	mov	x22, x0
	ldr	x8, [x20]
	ldr	w9, [x19, #48]
	cmp	w9, #0
	cset	w9, ne
	ldr	w8, [x8, w9, uxtw #2]
	str	w8, [x0]
	ldr	x2, [x19]
	mov	x0, x20
	mov	x1, x21
	mov	x3, x22
	bl	_bttv_overlay_risc
	mov	x0, x20
	mov	x1, x19
	mov	x2, x22
	bl	_bttv_switch_overlay
	b	LBB0_14
LBB0_11:
Lloh17:
	adrp	x8, _EINVAL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_13
LBB0_12:
Lloh19:
	adrp	x8, _EPERM@GOTPAGE
Lloh20:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
LBB0_13:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_14:
	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_15:
	mov	w0, #0
	b	LBB0_14
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_CAP_SYS_ADMIN,4,2              ; @CAP_SYS_ADMIN
	.comm	_CAP_SYS_RAWIO,4,2              ; @CAP_SYS_RAWIO
	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_FORMAT_FLAGS_PACKED,4,2        ; @FORMAT_FLAGS_PACKED
	.comm	_V4L2_FBUF_FLAG_OVERLAY,4,2     ; @V4L2_FBUF_FLAG_OVERLAY
	.comm	_V4L2_FIELD_INTERLACED,4,2      ; @V4L2_FIELD_INTERLACED
	.comm	_RESOURCE_OVERLAY,4,2           ; @RESOURCE_OVERLAY
	.no_dead_strip	_bttv_s_fbuf
.subsections_via_symbols
