	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vaapi_encode_mjpeg_write_image_header
_vaapi_encode_mjpeg_write_image_header: ## @vaapi_encode_mjpeg_write_image_header
	.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	%r8, %r14
	movq	%rcx, -48(%rbp)                 ## 8-byte Spill
	movq	%rdi, %r15
	movq	(%rdi), %r12
	leaq	48(%r12), %r13
	cmpq	$0, 40(%r12)
	je	LBB0_2
## %bb.1:
	movl	(%r12), %edi
	movq	_JPEG_MARKER_APPN@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	leaq	32(%r12), %r8
	movq	%r13, %rsi
	movl	$-1, %edx
	xorl	%r9d, %r9d
	callq	_ff_cbs_insert_unit_content
	testl	%eax, %eax
	js	LBB0_11
LBB0_2:
	movl	(%r12), %edi
	movq	_JPEG_MARKER_DQT@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	leaq	28(%r12), %r8
	movq	%r13, %rsi
	movl	$-1, %edx
	xorl	%r9d, %r9d
	callq	_ff_cbs_insert_unit_content
	testl	%eax, %eax
	js	LBB0_11
## %bb.3:
	movl	(%r12), %edi
	movq	_JPEG_MARKER_SOF0@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	leaq	24(%r12), %r8
	movq	%r13, %rsi
	movl	$-1, %edx
	xorl	%r9d, %r9d
	callq	_ff_cbs_insert_unit_content
	testl	%eax, %eax
	js	LBB0_11
## %bb.4:
	cmpq	$0, 16(%r12)
	je	LBB0_6
## %bb.5:
	movl	(%r12), %edi
	movq	_JPEG_MARKER_DHT@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	leaq	8(%r12), %r8
	movq	%r13, %rsi
	movl	$-1, %edx
	xorl	%r9d, %r9d
	callq	_ff_cbs_insert_unit_content
	testl	%eax, %eax
	js	LBB0_11
LBB0_6:
	movl	(%r12), %edi
	movq	_JPEG_MARKER_SOS@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	leaq	4(%r12), %r8
	movq	%r13, %rsi
	movl	$-1, %edx
	xorl	%r9d, %r9d
	callq	_ff_cbs_insert_unit_content
	testl	%eax, %eax
	js	LBB0_11
## %bb.7:
	movl	(%r12), %edi
	movq	%r13, %rsi
	callq	_ff_cbs_write_fragment_data
	testl	%eax, %eax
	js	LBB0_15
## %bb.8:
	movq	(%r14), %rcx
	movslq	(%r13), %rdx
	leaq	(,%rdx,8), %r8
	cmpq	%r8, %rcx
	jae	LBB0_16
## %bb.9:
	movq	_AV_LOG_ERROR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str.1(%rip), %rdx
	movq	%r15, %rdi
                                        ## kill: def $r8d killed $r8d killed $r8
	xorl	%eax, %eax
	callq	_av_log
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_AVERROR
LBB0_11:
	movl	%eax, %ebx
LBB0_17:
	movl	(%r12), %edi
	movq	%r13, %rsi
	callq	_ff_cbs_fragment_reset
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_15:
	movl	%eax, %ebx
	movq	_AV_LOG_ERROR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str(%rip), %rdx
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_av_log
	jmp	LBB0_17
LBB0_16:
	movl	52(%r12), %esi
	addl	$-2, %edx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_memcpy
	movl	48(%r12), %eax
	leal	-16(,%rax,8), %eax
	cltq
	movq	%rax, (%r14)
	xorl	%ebx, %ebx
	jmp	LBB0_17
	.cfi_endproc
                                        ## -- End function
	.comm	_JPEG_MARKER_APPN,8,3           ## @JPEG_MARKER_APPN
	.comm	_JPEG_MARKER_DQT,8,3            ## @JPEG_MARKER_DQT
	.comm	_JPEG_MARKER_SOF0,8,3           ## @JPEG_MARKER_SOF0
	.comm	_JPEG_MARKER_DHT,8,3            ## @JPEG_MARKER_DHT
	.comm	_JPEG_MARKER_SOS,8,3            ## @JPEG_MARKER_SOS
	.comm	_AV_LOG_ERROR,4,2               ## @AV_LOG_ERROR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to write image header.\n"

L_.str.1:                               ## @.str.1
	.asciz	"Image header too large: %zu < %zu.\n"

	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.no_dead_strip	_vaapi_encode_mjpeg_write_image_header
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function vaapi_encode_mjpeg_write_image_header
_vaapi_encode_mjpeg_write_image_header: ; @vaapi_encode_mjpeg_write_image_header
	.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, x4
	mov	x22, x3
	mov	x20, x0
	ldr	x24, [x0]
	add	x19, x24, #48
	ldr	x8, [x24, #40]
	cbz	x8, LBB0_2
; %bb.1:
	mov	x4, x24
	ldr	w0, [x4], #32
Lloh0:
	adrp	x8, _JPEG_MARKER_APPN@GOTPAGE
Lloh1:
	ldr	x8, [x8, _JPEG_MARKER_APPN@GOTPAGEOFF]
Lloh2:
	ldr	x3, [x8]
	mov	x1, x19
	mov	w2, #-1
	mov	x5, #0
	bl	_ff_cbs_insert_unit_content
	tbnz	w0, #31, LBB0_10
LBB0_2:
	mov	x4, x24
	ldr	w0, [x4], #28
Lloh3:
	adrp	x8, _JPEG_MARKER_DQT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _JPEG_MARKER_DQT@GOTPAGEOFF]
Lloh5:
	ldr	x3, [x8]
	mov	x1, x19
	mov	w2, #-1
	mov	x5, #0
	bl	_ff_cbs_insert_unit_content
	tbnz	w0, #31, LBB0_10
; %bb.3:
	mov	x4, x24
	ldr	w0, [x4], #24
Lloh6:
	adrp	x8, _JPEG_MARKER_SOF0@GOTPAGE
Lloh7:
	ldr	x8, [x8, _JPEG_MARKER_SOF0@GOTPAGEOFF]
Lloh8:
	ldr	x3, [x8]
	mov	x1, x19
	mov	w2, #-1
	mov	x5, #0
	bl	_ff_cbs_insert_unit_content
	tbnz	w0, #31, LBB0_10
; %bb.4:
	ldr	x8, [x24, #16]
	cbz	x8, LBB0_6
; %bb.5:
	mov	x4, x24
	ldr	w0, [x4], #8
Lloh9:
	adrp	x8, _JPEG_MARKER_DHT@GOTPAGE
Lloh10:
	ldr	x8, [x8, _JPEG_MARKER_DHT@GOTPAGEOFF]
Lloh11:
	ldr	x3, [x8]
	mov	x1, x19
	mov	w2, #-1
	mov	x5, #0
	bl	_ff_cbs_insert_unit_content
	tbnz	w0, #31, LBB0_10
LBB0_6:
	mov	x4, x24
	ldr	w0, [x4], #4
Lloh12:
	adrp	x8, _JPEG_MARKER_SOS@GOTPAGE
Lloh13:
	ldr	x8, [x8, _JPEG_MARKER_SOS@GOTPAGEOFF]
Lloh14:
	ldr	x3, [x8]
	mov	x1, x19
	mov	w2, #-1
	mov	x5, #0
	bl	_ff_cbs_insert_unit_content
	tbnz	w0, #31, LBB0_10
; %bb.7:
	ldr	w0, [x24]
	mov	x1, x19
	bl	_ff_cbs_write_fragment_data
	tbnz	w0, #31, LBB0_12
; %bb.8:
	ldr	x8, [x21]
	ldrsw	x10, [x19]
	lsl	x9, x10, #3
	cmp	x8, x9
	b.hs	LBB0_13
; %bb.9:
Lloh15:
	adrp	x10, _AV_LOG_ERROR@GOTPAGE
Lloh16:
	ldr	x10, [x10, _AV_LOG_ERROR@GOTPAGEOFF]
Lloh17:
	ldr	w1, [x10]
                                        ; kill: def $w9 killed $w9 killed $x9 def $x9
	stp	x8, x9, [sp]
Lloh18:
	adrp	x2, l_.str.1@PAGE
Lloh19:
	add	x2, x2, l_.str.1@PAGEOFF
	mov	x0, x20
	bl	_av_log
Lloh20:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh21:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh22:
	ldr	w0, [x8]
	bl	_AVERROR
LBB0_10:
	mov	x23, x0
LBB0_11:
	ldr	w0, [x24]
	mov	x1, x19
	bl	_ff_cbs_fragment_reset
	mov	x0, x23
	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_12:
	mov	x23, x0
Lloh23:
	adrp	x8, _AV_LOG_ERROR@GOTPAGE
Lloh24:
	ldr	x8, [x8, _AV_LOG_ERROR@GOTPAGEOFF]
Lloh25:
	ldr	w1, [x8]
Lloh26:
	adrp	x2, l_.str@PAGE
Lloh27:
	add	x2, x2, l_.str@PAGEOFF
	mov	x0, x20
	bl	_av_log
	b	LBB0_11
LBB0_13:
	ldr	w1, [x24, #52]
	sub	w2, w10, #2
	mov	x0, x22
	bl	_memcpy
	mov	w23, #0
	ldr	w8, [x24, #48]
	lsl	w8, w8, #3
	sub	w8, w8, #16
	sxtw	x8, w8
	str	x8, [x21]
	b	LBB0_11
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_JPEG_MARKER_APPN,8,3           ; @JPEG_MARKER_APPN
	.comm	_JPEG_MARKER_DQT,8,3            ; @JPEG_MARKER_DQT
	.comm	_JPEG_MARKER_SOF0,8,3           ; @JPEG_MARKER_SOF0
	.comm	_JPEG_MARKER_DHT,8,3            ; @JPEG_MARKER_DHT
	.comm	_JPEG_MARKER_SOS,8,3            ; @JPEG_MARKER_SOS
	.comm	_AV_LOG_ERROR,4,2               ; @AV_LOG_ERROR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to write image header.\n"

l_.str.1:                               ; @.str.1
	.asciz	"Image header too large: %zu < %zu.\n"

	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.no_dead_strip	_vaapi_encode_mjpeg_write_image_header
.subsections_via_symbols
