	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function add_candidate_ref
_add_candidate_ref:                     ## @add_candidate_ref
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %r14d
	movl	%edx, %r12d
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movl	%edx, %esi
	callq	_find_ref_idx
	cmpq	(%rbx), %rax
	je	LBB0_2
## %bb.1:
	movq	(%r15), %rcx
	movq	_HEVC_MAX_REFS@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	jae	LBB0_2
## %bb.3:
	testq	%rax, %rax
	jne	LBB0_6
## %bb.4:
	movq	%rbx, %rdi
	movl	%r12d, %esi
	callq	_generate_missing_ref
	testq	%rax, %rax
	je	LBB0_8
## %bb.5:
	movq	(%r15), %rcx
LBB0_6:
	movl	(%rax), %edx
	movq	16(%r15), %rsi
	movl	%edx, (%rsi,%rcx,4)
	movq	8(%r15), %rdx
	movq	%rax, (%rdx,%rcx,8)
	incq	%rcx
	movq	%rcx, (%r15)
	movq	%rax, %rdi
	movl	%r14d, %esi
	callq	_mark_ref
	xorl	%eax, %eax
	jmp	LBB0_7
LBB0_2:
	movq	_AVERROR_INVALIDDATA@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_7:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_AVERROR                        ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_HEVC_MAX_REFS,8,3              ## @HEVC_MAX_REFS
	.comm	_AVERROR_INVALIDDATA,4,2        ## @AVERROR_INVALIDDATA
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.no_dead_strip	_add_candidate_ref
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function add_candidate_ref
_add_candidate_ref:                     ; @add_candidate_ref
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x19, x3
	mov	x21, x2
	mov	x20, x1
	mov	x22, x0
	mov	x1, x2
	bl	_find_ref_idx
	ldr	x8, [x22]
	cmp	x0, x8
	b.eq	LBB0_6
; %bb.1:
	ldr	x8, [x20]
Lloh0:
	adrp	x9, _HEVC_MAX_REFS@GOTPAGE
Lloh1:
	ldr	x9, [x9, _HEVC_MAX_REFS@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.hs	LBB0_6
; %bb.2:
	cbnz	x0, LBB0_5
; %bb.3:
	mov	x0, x22
	mov	x1, x21
	bl	_generate_missing_ref
	cbz	x0, LBB0_8
; %bb.4:
	ldr	x8, [x20]
LBB0_5:
	ldr	w9, [x0]
	ldp	x11, x10, [x20, #8]
	str	w9, [x10, x8, lsl #2]
	str	x0, [x11, x8, lsl #3]
	add	x8, x8, #1
	str	x8, [x20]
	mov	x1, x19
	bl	_mark_ref
	mov	w0, #0
	b	LBB0_7
LBB0_6:
Lloh3:
	adrp	x8, _AVERROR_INVALIDDATA@GOTPAGE
Lloh4:
	ldr	x8, [x8, _AVERROR_INVALIDDATA@GOTPAGEOFF]
Lloh5:
	ldr	w0, [x8]
LBB0_7:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
LBB0_8:
Lloh6:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh8:
	ldr	w0, [x8]
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	b	_AVERROR
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_HEVC_MAX_REFS,8,3              ; @HEVC_MAX_REFS
	.comm	_AVERROR_INVALIDDATA,4,2        ; @AVERROR_INVALIDDATA
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.no_dead_strip	_add_candidate_ref
.subsections_via_symbols
