	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bttv_s_selection
_bttv_s_selection:                      ## @bttv_s_selection
	.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
	subq	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r13
	movq	%rsi, %r15
	movq	24(%rsi), %r14
	movq	(%rdx), %rax
	movq	_V4L2_BUF_TYPE_VIDEO_CAPTURE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_3
## %bb.1:
	movq	_V4L2_BUF_TYPE_VIDEO_OVERLAY@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_2
LBB0_3:
	movq	8(%r13), %rax
	movq	_V4L2_SEL_TGT_CROP@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_2
## %bb.4:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movq	_VIDEO_RESOURCES@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_locked_btres
	testq	%rax, %rax
	jne	LBB0_13
## %bb.5:
	movq	_bttv_tvnorms@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	(%r14), %rcx
	shlq	$4, %rcx
	movl	(%rax,%rcx), %edx
	movq	%rdx, -104(%rbp)                ## 8-byte Spill
	movl	4(%rax,%rcx), %edx
	movq	%rdx, -48(%rbp)                 ## 8-byte Spill
	movl	8(%rax,%rcx), %edi
	movl	12(%rax,%rcx), %r12d
	addl	%edi, %r12d
	movl	32(%r14), %esi
	callq	_max
                                        ## kill: def $eax killed $eax def $rax
	leal	32(%rax), %ecx
	cmpl	%r12d, %ecx
	jge	LBB0_13
## %bb.6:
	movq	_s32@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	movl	16(%r13), %esi
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movl	%ecx, %ebx
	movq	-104(%rbp), %rdx                ## 8-byte Reload
	addl	%edx, %ebx
	addl	%edx, %ecx
	addl	$-48, %ecx
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_clamp_t
	movq	_MAX_HDELAY@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	movl	%eax, %edi
	callq	_min
	movl	%eax, -64(%rbp)
	movq	_s32@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	movl	20(%r13), %esi
	subl	%eax, %ebx
	movl	$48, %edx
	movl	%ebx, %ecx
	callq	_clamp_t
	movl	%eax, -60(%rbp)
	movq	_s32@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edi
	movl	24(%r13), %esi
	leal	-32(%r12), %ecx
	movq	-48(%rbp), %rdx                 ## 8-byte Reload
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_clamp_t
	incl	%eax
	andl	$-2, %eax
	movl	%eax, -56(%rbp)
	movl	(%rbx), %edi
	movl	28(%r13), %esi
	subl	%eax, %r12d
	movl	$32, %edx
	movl	%r12d, %ecx
	callq	_clamp_t
	incl	%eax
	andl	$-2, %eax
	movl	%eax, -52(%rbp)
	leaq	-96(%rbp), %rdi
	callq	_bttv_crop_calc_limits
	movups	-64(%rbp), %xmm0
	movups	%xmm0, 16(%r13)
	movq	24(%r14), %rax
	movups	-96(%rbp), %xmm0
	movups	-80(%rbp), %xmm1
	movups	-64(%rbp), %xmm2
	movups	%xmm2, 80(%rax)
	movups	%xmm1, 64(%rax)
	movups	%xmm0, 48(%rax)
	movl	$1, (%r15)
	movq	8(%r15), %rcx
	movq	-96(%rbp), %rax
	cmpq	%rax, %rcx
	jl	LBB0_8
## %bb.7:
	movq	-88(%rbp), %rax
	cmpq	%rax, %rcx
	jle	LBB0_9
LBB0_8:
	movq	%rax, 8(%r15)
	movq	%rax, 8(%r14)
LBB0_9:
	movq	16(%r15), %rax
	movq	-80(%rbp), %rcx
	cmpq	%rcx, %rax
	jge	LBB0_11
## %bb.10:
	movq	%rcx, 16(%r15)
	movq	%rcx, 16(%r14)
	xorl	%ebx, %ebx
	jmp	LBB0_13
LBB0_2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_13:
	movl	%ebx, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_11:
	movq	-72(%rbp), %rcx
	xorl	%ebx, %ebx
	cmpq	%rcx, %rax
	jle	LBB0_13
## %bb.12:
	movq	%rcx, 16(%r15)
	movq	%rcx, 16(%r14)
	jmp	LBB0_13
	.cfi_endproc
                                        ## -- End function
	.comm	_V4L2_BUF_TYPE_VIDEO_CAPTURE,8,3 ## @V4L2_BUF_TYPE_VIDEO_CAPTURE
	.comm	_V4L2_BUF_TYPE_VIDEO_OVERLAY,8,3 ## @V4L2_BUF_TYPE_VIDEO_OVERLAY
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_V4L2_SEL_TGT_CROP,8,3          ## @V4L2_SEL_TGT_CROP
	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_VIDEO_RESOURCES,4,2            ## @VIDEO_RESOURCES
	.comm	_bttv_tvnorms,8,3               ## @bttv_tvnorms
	.comm	_s32,4,2                        ## @s32
	.comm	_MAX_HDELAY,8,3                 ## @MAX_HDELAY
	.no_dead_strip	_bttv_s_selection
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bttv_s_selection
_bttv_s_selection:                      ; @bttv_s_selection
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	ldr	x8, [x2]
Lloh0:
	adrp	x9, _V4L2_BUF_TYPE_VIDEO_CAPTURE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _V4L2_BUF_TYPE_VIDEO_CAPTURE@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
Lloh3:
	adrp	x10, _V4L2_BUF_TYPE_VIDEO_OVERLAY@GOTPAGE
Lloh4:
	ldr	x10, [x10, _V4L2_BUF_TYPE_VIDEO_OVERLAY@GOTPAGEOFF]
Lloh5:
	ldr	x10, [x10]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_10
; %bb.1:
	mov	x21, x2
	ldr	x8, [x2, #8]
Lloh6:
	adrp	x9, _V4L2_SEL_TGT_CROP@GOTPAGE
Lloh7:
	ldr	x9, [x9, _V4L2_SEL_TGT_CROP@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_10
; %bb.2:
	mov	x19, x1
Lloh9:
	adrp	x8, _EBUSY@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
	ldr	x20, [x1, #24]
Lloh11:
	ldr	w8, [x8]
	neg	w22, w8
Lloh12:
	adrp	x8, _VIDEO_RESOURCES@GOTPAGE
Lloh13:
	ldr	x8, [x8, _VIDEO_RESOURCES@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_locked_btres
	cbnz	x0, LBB0_11
; %bb.3:
Lloh15:
	adrp	x8, _bttv_tvnorms@GOTPAGE
Lloh16:
	ldr	x8, [x8, _bttv_tvnorms@GOTPAGEOFF]
Lloh17:
	ldr	x8, [x8]
	ldr	x9, [x20]
	add	x8, x8, x9, lsl #4
	ldp	w24, w26, [x8]
	ldp	w0, w8, [x8, #8]
	add	w25, w8, w0
	ldr	w1, [x20, #32]
	bl	_max
	add	w8, w0, #32
	cmp	w8, w25
	b.ge	LBB0_11
; %bb.4:
	mov	x23, x0
	add	w22, w26, w24
Lloh18:
	adrp	x26, _s32@GOTPAGE
Lloh19:
	ldr	x26, [x26, _s32@GOTPAGEOFF]
	ldr	w0, [x26]
	ldr	w1, [x21, #16]
	sub	w3, w22, #48
	mov	x2, x24
	bl	_clamp_t
Lloh20:
	adrp	x8, _MAX_HDELAY@GOTPAGE
Lloh21:
	ldr	x8, [x8, _MAX_HDELAY@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
                                        ; kill: def $w0 killed $w0 killed $x0
	bl	_min
	str	w0, [sp, #32]
	ldr	w8, [x26]
	ldr	w1, [x21, #20]
	sub	w3, w22, w0
	mov	x0, x8
	mov	w2, #48
	bl	_clamp_t
	str	w0, [sp, #36]
	ldr	w0, [x26]
	ldr	w1, [x21, #24]
	sub	w3, w25, #32
	mov	x2, x23
	bl	_clamp_t
	add	w8, w0, #1
	and	w8, w8, #0xfffffffe
	str	w8, [sp, #40]
	ldr	w0, [x26]
	ldr	w1, [x21, #28]
	sub	w3, w25, w8
	mov	w2, #32
	bl	_clamp_t
	add	w8, w0, #1
	and	w8, w8, #0xfffffffe
	str	w8, [sp, #44]
	mov	x0, sp
	bl	_bttv_crop_calc_limits
	ldp	q1, q0, [sp, #16]
	str	q0, [x21, #16]
	ldr	x8, [x20, #24]
	ldr	q2, [sp]
	stp	q2, q1, [x8, #48]
	str	q0, [x8, #80]
	mov	w8, #1
	str	w8, [x19]
	ldr	x9, [x19, #8]
	ldr	x8, [sp]
	cmp	x9, x8
	b.lt	LBB0_6
; %bb.5:
	ldr	x8, [sp, #8]
	cmp	x9, x8
	b.le	LBB0_7
LBB0_6:
	str	x8, [x19, #8]
	str	x8, [x20, #8]
LBB0_7:
	ldr	x9, [x19, #16]
	ldr	x8, [sp, #16]
	cmp	x9, x8
	b.lt	LBB0_9
; %bb.8:
	ldr	x8, [sp, #24]
	cmp	x9, x8
	b.le	LBB0_12
LBB0_9:
	mov	w22, #0
	str	x8, [x19, #16]
	str	x8, [x20, #16]
	b	LBB0_11
LBB0_10:
Lloh23:
	adrp	x8, _EINVAL@GOTPAGE
Lloh24:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh25:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_11:
	mov	x0, x22
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_12:
	mov	w22, #0
	b	LBB0_11
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_V4L2_BUF_TYPE_VIDEO_CAPTURE,8,3 ; @V4L2_BUF_TYPE_VIDEO_CAPTURE
	.comm	_V4L2_BUF_TYPE_VIDEO_OVERLAY,8,3 ; @V4L2_BUF_TYPE_VIDEO_OVERLAY
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_V4L2_SEL_TGT_CROP,8,3          ; @V4L2_SEL_TGT_CROP
	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_VIDEO_RESOURCES,4,2            ; @VIDEO_RESOURCES
	.comm	_bttv_tvnorms,8,3               ; @bttv_tvnorms
	.comm	_s32,4,2                        ; @s32
	.comm	_MAX_HDELAY,8,3                 ; @MAX_HDELAY
	.no_dead_strip	_bttv_s_selection
.subsections_via_symbols
