	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function filter_avg
_filter_avg:                            ## @filter_avg
	.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
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	imull	%r8d, %ecx
	movl	%r8d, %r15d
	testl	%r8d, %r8d
	je	LBB0_15
## %bb.1:
	cmpl	$8, %r8d
	jae	LBB0_3
## %bb.2:
	xorl	%r14d, %r14d
LBB0_12:
	movq	%r14, %r11
	notq	%r11
	testb	$1, %r15b
	je	LBB0_14
## %bb.13:
	movl	(%rsi,%r14,4), %r10d
	movl	(%rdx,%r14,4), %ebx
	sarl	%ebx
	subl	%ebx, %r10d
	movl	%r10d, (%rdi,%r14,4)
	orq	$1, %r14
LBB0_14:
	addq	%r15, %r11
	je	LBB0_15
	.p2align	4, 0x90
LBB0_29:                                ## =>This Inner Loop Header: Depth=1
	movl	(%rsi,%r14,4), %ebx
	movl	(%rdx,%r14,4), %eax
	sarl	%eax
	subl	%eax, %ebx
	movl	%ebx, (%rdi,%r14,4)
	movl	4(%rsi,%r14,4), %eax
	movl	4(%rdx,%r14,4), %ebx
	sarl	%ebx
	subl	%ebx, %eax
	movl	%eax, 4(%rdi,%r14,4)
	addq	$2, %r14
	cmpq	%r14, %r15
	jne	LBB0_29
	jmp	LBB0_15
LBB0_3:
	movq	%rdi, %rbx
	subq	%rsi, %rbx
	xorl	%r14d, %r14d
	cmpq	$32, %rbx
	jb	LBB0_12
## %bb.4:
	movq	%rdi, %rbx
	subq	%rdx, %rbx
	cmpq	$32, %rbx
	jb	LBB0_12
## %bb.5:
	movl	%r15d, %r14d
	andl	$-8, %r14d
	leaq	-8(%r14), %rbx
	movq	%rbx, %r11
	shrq	$3, %r11
	incq	%r11
	testq	%rbx, %rbx
	je	LBB0_6
## %bb.7:
	movq	%r11, %rbx
	andq	$-2, %rbx
	xorl	%r10d, %r10d
	.p2align	4, 0x90
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movdqu	(%rsi,%r10,4), %xmm0
	movdqu	16(%rsi,%r10,4), %xmm1
	movdqu	(%rdx,%r10,4), %xmm2
	movdqu	16(%rdx,%r10,4), %xmm3
	psrad	$1, %xmm2
	psubd	%xmm2, %xmm0
	psrad	$1, %xmm3
	psubd	%xmm3, %xmm1
	movdqu	%xmm0, (%rdi,%r10,4)
	movdqu	%xmm1, 16(%rdi,%r10,4)
	movdqu	32(%rsi,%r10,4), %xmm0
	movdqu	48(%rsi,%r10,4), %xmm1
	movdqu	32(%rdx,%r10,4), %xmm2
	movdqu	48(%rdx,%r10,4), %xmm3
	psrad	$1, %xmm2
	psubd	%xmm2, %xmm0
	psrad	$1, %xmm3
	psubd	%xmm3, %xmm1
	movdqu	%xmm0, 32(%rdi,%r10,4)
	movdqu	%xmm1, 48(%rdi,%r10,4)
	addq	$16, %r10
	addq	$-2, %rbx
	jne	LBB0_8
## %bb.9:
	testb	$1, %r11b
	je	LBB0_11
LBB0_10:
	movdqu	(%rsi,%r10,4), %xmm0
	movdqu	16(%rsi,%r10,4), %xmm1
	movdqu	(%rdx,%r10,4), %xmm2
	movdqu	16(%rdx,%r10,4), %xmm3
	psrad	$1, %xmm2
	psubd	%xmm2, %xmm0
	psrad	$1, %xmm3
	psubd	%xmm3, %xmm1
	movdqu	%xmm0, (%rdi,%r10,4)
	movdqu	%xmm1, 16(%rdi,%r10,4)
LBB0_11:
	cmpq	%r15, %r14
	jne	LBB0_12
LBB0_15:
	cmpl	%r8d, %ecx
	jbe	LBB0_28
## %bb.16:
	movl	%ecx, %r8d
	movq	%r8, %r10
	subq	%r15, %r10
	movq	%r15, %r9
	cmpq	$8, %r10
	jb	LBB0_23
## %bb.17:
	leaq	(%rdi,%r15,4), %r11
	movq	%r11, %rbx
	subq	%rsi, %rbx
	movq	%r15, %r9
	cmpq	$32, %rbx
	jb	LBB0_23
## %bb.18:
	leaq	(%rsi,%r15,4), %rax
	movq	%r11, %rbx
	subq	%rax, %rbx
	movq	%r15, %r9
	cmpq	$32, %rbx
	jb	LBB0_23
## %bb.19:
	leaq	(%rdx,%r15,4), %rax
	subq	%rax, %r11
	movq	%r15, %r9
	cmpq	$32, %r11
	jb	LBB0_23
## %bb.20:
	leaq	(,%r15,4), %r14
	movq	%r10, %r11
	andq	$-8, %r11
	movq	%r15, %rax
	leaq	(%r11,%r15), %r9
	leaq	16(%rsi), %rbx
	leaq	16(%rdx), %r15
	leaq	16(%rdi), %r12
	movq	%r11, %r13
	.p2align	4, 0x90
LBB0_21:                                ## =>This Inner Loop Header: Depth=1
	movdqu	-16(%rbx,%r14), %xmm0
	movdqu	(%rbx,%r14), %xmm1
	movdqu	-16(%rbx), %xmm2
	movdqu	(%rbx), %xmm3
	movdqu	-16(%r15,%r14), %xmm4
	paddd	%xmm2, %xmm4
	movdqu	(%r15,%r14), %xmm2
	paddd	%xmm3, %xmm2
	psrad	$1, %xmm4
	psubd	%xmm4, %xmm0
	psrad	$1, %xmm2
	psubd	%xmm2, %xmm1
	movdqu	%xmm0, -16(%r12,%r14)
	movdqu	%xmm1, (%r12,%r14)
	addq	$32, %rbx
	addq	$32, %r15
	addq	$32, %r12
	addq	$-8, %r13
	jne	LBB0_21
## %bb.22:
	cmpq	%r11, %r10
	movq	%rax, %r15
	je	LBB0_28
LBB0_23:
	movl	%r8d, %ebx
	subl	%r9d, %ebx
	movq	%r9, %r10
	notq	%r10
	testb	$1, %bl
	je	LBB0_25
## %bb.24:
	movl	(%rsi,%r9,4), %r11d
	movq	%r9, %r14
	subq	%r15, %r14
	movl	(%rdx,%r9,4), %ebx
	addl	(%rsi,%r14,4), %ebx
	sarl	%ebx
	subl	%ebx, %r11d
	movl	%r11d, (%rdi,%r9,4)
	incq	%r9
LBB0_25:
	addq	%r8, %r10
	je	LBB0_28
## %bb.26:
	movl	$1, %ebx
	subq	%r15, %rbx
	leaq	(%rsi,%rbx,4), %r10
	.p2align	4, 0x90
LBB0_27:                                ## =>This Inner Loop Header: Depth=1
	movl	(%rsi,%r9,4), %ebx
	movl	(%rdx,%r9,4), %eax
	addl	-4(%r10,%r9,4), %eax
	sarl	%eax
	subl	%eax, %ebx
	movl	%ebx, (%rdi,%r9,4)
	movl	4(%rsi,%r9,4), %eax
	movl	4(%rdx,%r9,4), %ebx
	addl	(%r10,%r9,4), %ebx
	sarl	%ebx
	subl	%ebx, %eax
	movl	%eax, 4(%rdi,%r9,4)
	addq	$2, %r9
	cmpq	%r9, %r8
	jne	LBB0_27
LBB0_28:
	movl	%ecx, %esi
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_count_sad                      ## TAILCALL
LBB0_6:
	xorl	%r10d, %r10d
	testb	$1, %r11b
	jne	LBB0_10
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.no_dead_strip	_filter_avg
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function filter_avg
_filter_avg:                            ; @filter_avg
	.cfi_startproc
; %bb.0:
	mov	x8, x1
	mul	w1, w4, w3
	cbz	w4, LBB0_5
; %bb.1:
	mov	w9, w4
	cmp	w4, #16
	b.hs	LBB0_16
; %bb.2:
	mov	x10, #0
LBB0_3:
	lsl	x13, x10, #2
	add	x11, x8, x13
	add	x12, x2, x13
	add	x13, x0, x13
	sub	x9, x9, x10
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w10, [x11], #4
	ldr	w14, [x12], #4
	sub	w10, w10, w14, asr #1
	str	w10, [x13], #4
	subs	x9, x9, #1
	b.ne	LBB0_4
LBB0_5:
	cmp	w1, w4
	b.ls	LBB0_15
; %bb.6:
	mov	w9, w4
	sub	x10, x1, x9
	mov	x11, x9
	cmp	x10, #16
	b.lo	LBB0_13
; %bb.7:
	lsl	x12, x9, #2
	add	x13, x12, x0
	sub	x14, x13, x8
	mov	x11, x9
	cmp	x14, #64
	b.lo	LBB0_13
; %bb.8:
	add	x11, x12, x8
	sub	x14, x13, x11
	mov	x11, x9
	cmp	x14, #64
	b.lo	LBB0_13
; %bb.9:
	add	x11, x12, x2
	sub	x13, x13, x11
	mov	x11, x9
	cmp	x13, #64
	b.lo	LBB0_13
; %bb.10:
	and	x13, x10, #0xfffffffffffffff0
	add	x11, x13, x9
	add	x15, x12, #32
	add	x14, x0, x15
	add	x15, x2, x15
	add	x16, x8, #32
	mov	x17, x13
LBB0_11:                                ; =>This Inner Loop Header: Depth=1
	add	x3, x16, x12
	ldp	q0, q1, [x3, #-32]
	ldp	q2, q3, [x3]
	ldp	q4, q5, [x16, #-32]
	ldp	q6, q7, [x16], #64
	ldp	q16, q17, [x15, #-32]
	ldp	q18, q19, [x15], #64
	add.4s	v4, v16, v4
	add.4s	v5, v17, v5
	add.4s	v6, v18, v6
	add.4s	v7, v19, v7
	sshr.4s	v4, v4, #1
	sshr.4s	v5, v5, #1
	sshr.4s	v6, v6, #1
	sshr.4s	v7, v7, #1
	sub.4s	v0, v0, v4
	sub.4s	v1, v1, v5
	sub.4s	v2, v2, v6
	sub.4s	v3, v3, v7
	stp	q0, q1, [x14, #-32]
	stp	q2, q3, [x14], #64
	subs	x17, x17, #16
	b.ne	LBB0_11
; %bb.12:
	cmp	x10, x13
	b.eq	LBB0_15
LBB0_13:
	neg	x9, x9, lsl #2
	lsl	x12, x11, #2
	add	x8, x8, x12
	add	x10, x2, x12
	add	x12, x0, x12
	sub	x11, x1, x11
LBB0_14:                                ; =>This Inner Loop Header: Depth=1
	ldr	w13, [x8]
	ldr	w14, [x8, x9]
	ldr	w15, [x10], #4
	add	w14, w15, w14
	sub	w13, w13, w14, asr #1
	str	w13, [x12], #4
	add	x8, x8, #4
	subs	x11, x11, #1
	b.ne	LBB0_14
LBB0_15:
                                        ; kill: def $w1 killed $w1 killed $x1
	b	_count_sad
LBB0_16:
	mov	x10, #0
	sub	x11, x0, x8
	cmp	x11, #64
	b.lo	LBB0_3
; %bb.17:
	sub	x11, x0, x2
	cmp	x11, #64
	b.lo	LBB0_3
; %bb.18:
	and	x10, x9, #0xfffffff0
	add	x11, x0, #32
	add	x12, x8, #32
	add	x13, x2, #32
	mov	x14, x10
LBB0_19:                                ; =>This Inner Loop Header: Depth=1
	ldp	q0, q1, [x12, #-32]
	ldp	q2, q3, [x12], #64
	ldp	q4, q5, [x13, #-32]
	ldp	q6, q7, [x13], #64
	sshr.4s	v4, v4, #1
	sshr.4s	v5, v5, #1
	sshr.4s	v6, v6, #1
	sshr.4s	v7, v7, #1
	sub.4s	v0, v0, v4
	sub.4s	v1, v1, v5
	sub.4s	v2, v2, v6
	sub.4s	v3, v3, v7
	stp	q0, q1, [x11, #-32]
	stp	q2, q3, [x11], #64
	subs	x14, x14, #16
	b.ne	LBB0_19
; %bb.20:
	cmp	x10, x9
	b.ne	LBB0_3
	b	LBB0_5
	.cfi_endproc
                                        ; -- End function
	.no_dead_strip	_filter_avg
.subsections_via_symbols
