	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function encode_nals
_encode_nals:                           ## @encode_nals
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r12
	movq	(%rdi), %r14
	movq	_AV_INPUT_BUFFER_MIN_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	addl	(%r14), %edx
	testl	%ecx, %ecx
	je	LBB0_1
## %bb.2:
	movl	%ecx, %r15d
	movq	%rsi, %rbx
	movl	%ecx, %r13d
	jle	LBB0_13
## %bb.3:
	cmpl	$4, %r15d
	jae	LBB0_5
## %bb.4:
	xorl	%eax, %eax
	jmp	LBB0_12
LBB0_1:
	xorl	%eax, %eax
	jmp	LBB0_23
LBB0_5:
	movl	%r13d, %eax
	andl	$-4, %eax
	movd	%edx, %xmm0
	leaq	-4(%rax), %rdx
	movq	%rdx, %rcx
	shrq	$2, %rcx
	incq	%rcx
	testq	%rdx, %rdx
	je	LBB0_6
## %bb.7:
	movq	%rcx, %rsi
	andq	$-2, %rsi
	pxor	%xmm1, %xmm1
	xorl	%edx, %edx
	.p2align	4, 0x90
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movdqu	(%r12,%rdx,8), %xmm2
	movdqu	16(%r12,%rdx,8), %xmm3
	movdqu	32(%r12,%rdx,8), %xmm4
	movdqu	48(%r12,%rdx,8), %xmm5
	pshufd	$232, %xmm2, %xmm2              ## xmm2 = xmm2[0,2,2,3]
	paddd	%xmm0, %xmm2
	pshufd	$232, %xmm3, %xmm3              ## xmm3 = xmm3[0,2,2,3]
	paddd	%xmm1, %xmm3
	pshufd	$232, %xmm4, %xmm0              ## xmm0 = xmm4[0,2,2,3]
	paddd	%xmm2, %xmm0
	pshufd	$232, %xmm5, %xmm1              ## xmm1 = xmm5[0,2,2,3]
	paddd	%xmm3, %xmm1
	addq	$8, %rdx
	addq	$-2, %rsi
	jne	LBB0_8
## %bb.9:
	testb	$1, %cl
	je	LBB0_11
LBB0_10:
	movdqu	(%r12,%rdx,8), %xmm2
	movdqu	16(%r12,%rdx,8), %xmm3
	pshufd	$232, %xmm2, %xmm2              ## xmm2 = xmm2[0,2,2,3]
	paddd	%xmm2, %xmm0
	pshufd	$232, %xmm3, %xmm2              ## xmm2 = xmm3[0,2,2,3]
	paddd	%xmm2, %xmm1
LBB0_11:
	paddd	%xmm1, %xmm0
	pshufd	$85, %xmm0, %xmm1               ## xmm1 = xmm0[1,1,1,1]
	paddd	%xmm0, %xmm1
	movd	%xmm1, %edx
	cmpq	%r13, %rax
	je	LBB0_13
	.p2align	4, 0x90
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	addl	(%r12,%rax,8), %edx
	incq	%rax
	cmpq	%rax, %r13
	jne	LBB0_12
LBB0_13:
	movl	%edx, -44(%rbp)
	movq	%rbx, %rsi
	xorl	%ecx, %ecx
	callq	_ff_alloc_packet2
	testl	%eax, %eax
	js	LBB0_23
## %bb.14:
	movq	%rbx, -56(%rbp)                 ## 8-byte Spill
	movq	8(%rbx), %rbx
	testl	%r15d, %r15d
	jle	LBB0_17
## %bb.15:
	movl	(%r14), %edx
	testl	%edx, %edx
	jle	LBB0_17
## %bb.16:
	movl	4(%r14), %esi
	movq	%rbx, %rdi
	callq	_memcpy
	movslq	(%r14), %rax
	leaq	(%rbx,%rax,4), %rbx
	movl	$0, (%r14)
LBB0_17:
	testl	%r15d, %r15d
	jle	LBB0_22
## %bb.18:
	leaq	-44(%rbp), %r15
	.p2align	4, 0x90
LBB0_19:                                ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movq	%r15, %rsi
	movl	$1, %edx
	movq	%r12, %rcx
	callq	_xavs_nal_encode
	testl	%eax, %eax
	js	LBB0_20
## %bb.21:                              ##   in Loop: Header=BB0_19 Depth=1
	movl	%eax, %eax
	leaq	(%rbx,%rax,4), %rbx
	addq	$8, %r12
	decq	%r13
	jne	LBB0_19
LBB0_22:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	subq	8(%rax), %rbx
	shrq	$2, %rbx
	movl	%ebx, (%rax)
	movl	$1, %eax
	jmp	LBB0_23
LBB0_20:
	movl	$-1, %eax
LBB0_23:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_6:
	pxor	%xmm1, %xmm1
	xorl	%edx, %edx
	testb	$1, %cl
	jne	LBB0_10
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_AV_INPUT_BUFFER_MIN_SIZE,4,2   ## @AV_INPUT_BUFFER_MIN_SIZE
	.no_dead_strip	_encode_nals
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function encode_nals
_encode_nals:                           ; @encode_nals
	.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
	cbz	w3, LBB0_4
; %bb.1:
	mov	x21, x3
	mov	x20, x2
	mov	x19, x1
	ldr	x24, [x0]
	ldr	w8, [x24]
Lloh0:
	adrp	x9, _AV_INPUT_BUFFER_MIN_SIZE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _AV_INPUT_BUFFER_MIN_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	add	w2, w9, w8
	mov	w23, w3
	cmp	w3, #1
	b.lt	LBB0_10
; %bb.2:
	cmp	w21, #8
	b.hs	LBB0_5
; %bb.3:
	mov	x8, #0
	b	LBB0_8
LBB0_4:
	mov	w0, #0
	b	LBB0_19
LBB0_5:
	movi	d0, #0000000000000000
	mov.s	v0[0], w2
	and	x8, x23, #0xfffffff8
	movi.2d	v1, #0000000000000000
	add	x9, x20, #32
	mov	x10, x8
	movi.2d	v2, #0000000000000000
	movi.2d	v3, #0000000000000000
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	ldp	q4, q5, [x9, #-32]
	ldp	q6, q7, [x9], #64
	xtn.2s	v4, v4
	xtn.2s	v5, v5
	xtn.2s	v6, v6
	xtn.2s	v7, v7
	add.2s	v0, v0, v4
	add.2s	v1, v1, v5
	add.2s	v2, v2, v6
	add.2s	v3, v3, v7
	subs	x10, x10, #8
	b.ne	LBB0_6
; %bb.7:
	add.2s	v0, v1, v0
	add.2s	v0, v2, v0
	add.2s	v0, v3, v0
	addp.2s	v0, v0, v0
	fmov	w2, s0
	cmp	x8, x23
	b.eq	LBB0_10
LBB0_8:
	add	x9, x20, x8, lsl #3
	sub	x8, x23, x8
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w10, [x9], #8
	add	w2, w2, w10
	subs	x8, x8, #1
	b.ne	LBB0_9
LBB0_10:
	str	w2, [sp, #12]
	mov	x1, x19
	mov	w3, #0
	bl	_ff_alloc_packet2
	tbnz	w0, #31, LBB0_19
; %bb.11:
	ldr	x22, [x19, #8]
	cmp	w21, #1
	b.lt	LBB0_14
; %bb.12:
	ldr	w2, [x24]
	cmp	w2, #1
	b.lt	LBB0_14
; %bb.13:
	ldr	w1, [x24, #4]
	mov	x0, x22
	bl	_memcpy
	ldrsw	x8, [x24]
	add	x22, x22, x8, lsl #2
	str	wzr, [x24]
LBB0_14:
	cmp	w21, #1
	b.lt	LBB0_17
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	add	x1, sp, #12
	mov	x0, x22
	mov	w2, #1
	mov	x3, x20
	bl	_xavs_nal_encode
	tbnz	w0, #31, LBB0_18
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=1
	add	x22, x22, w0, uxtw #2
	add	x20, x20, #8
	subs	x23, x23, #1
	b.ne	LBB0_15
LBB0_17:
	ldr	x8, [x19, #8]
	sub	x8, x22, x8
	lsr	x8, x8, #2
	str	w8, [x19]
	mov	w0, #1
	b	LBB0_19
LBB0_18:
	mov	w0, #-1
LBB0_19:
	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
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_AV_INPUT_BUFFER_MIN_SIZE,4,2   ; @AV_INPUT_BUFFER_MIN_SIZE
	.no_dead_strip	_encode_nals
.subsections_via_symbols
