	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function pgmyuv_save
_pgmyuv_save:                           ## @pgmyuv_save
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	movl	%edx, %r12d
	movl	%esi, %r14d
	movq	%rdi, -48(%rbp)                 ## 8-byte Spill
	movl	%edx, %r15d
	imull	%esi, %r15d
	movl	%r15d, %edi
	callq	_malloc
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	leal	3(%r15), %ebx
	testl	%r15d, %r15d
	cmovnsl	%r15d, %ebx
	sarl	$2, %ebx
	movl	%ebx, %edi
	callq	_malloc
	movq	%rax, %r13
	movl	%ebx, %edi
	callq	_malloc
	movq	%rax, %rbx
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movq	%r13, -80(%rbp)                 ## 8-byte Spill
	movq	%r13, %rsi
	movq	%rax, %rdx
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	movl	%r14d, %r8d
	movl	%r12d, %r9d
	callq	_rgb24_to_yuv420p
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	testq	%rdi, %rdi
	movq	%rbx, -72(%rbp)                 ## 8-byte Spill
	je	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rsi
	callq	_fopen
	movq	%rax, %r13
	leal	(%r12,%r12,2), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%eax, %ecx
	sarl	%ecx
	leaq	L_.str.1(%rip), %rsi
	movq	%r13, %rdi
	movl	%r14d, %edx
	movl	$255, %r8d
	callq	_fprintf
	jmp	LBB0_3
LBB0_2:
	movq	_stdout@GOTPCREL(%rip), %rax
	movq	(%rax), %r13
LBB0_3:
	movl	%r14d, %ebx
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movl	$1, %esi
	movl	%r15d, %edx
	movq	%r13, %rcx
	callq	_fwrite
	xorl	%edi, %edi
	cmpl	%r15d, %eax
	setne	%dil
	callq	_err_if
	movl	%r12d, %r14d
	shrl	$31, %r14d
	addl	%r12d, %r14d
	sarl	%r14d
	movl	%ebx, %ecx
	shrl	$31, %ecx
	addl	%ebx, %ecx
	sarl	%ecx
	cmpq	$0, -48(%rbp)                   ## 8-byte Folded Reload
	je	LBB0_8
## %bb.4:
	cmpl	$2, %r12d
	jl	LBB0_7
## %bb.5:
	movslq	%ecx, %r15
	movq	-80(%rbp), %r12                 ## 8-byte Reload
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	$1, %esi
	movl	%r15d, %edx
	movq	%r13, %rcx
	callq	_fwrite
	xorl	%edi, %edi
	cmpl	%r15d, %eax
	setne	%dil
	callq	_err_if
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	%r15d, %edx
	movq	%r13, %rcx
	callq	_fwrite
	xorl	%edi, %edi
	cmpl	%r15d, %eax
	setne	%dil
	callq	_err_if
	addq	%r15, %r12
	addq	%r15, %rbx
	decl	%r14d
	jne	LBB0_6
LBB0_7:
	movq	%r13, %rdi
	callq	_fclose
	jmp	LBB0_13
LBB0_8:
	cmpl	$2, %r12d
	jl	LBB0_13
## %bb.9:
	movq	%r13, %rax
	movl	%ecx, -64(%rbp)                 ## 4-byte Spill
	movslq	%ecx, %rcx
	movl	%r14d, %r13d
	movq	-80(%rbp), %rbx                 ## 8-byte Reload
	movq	%rcx, -48(%rbp)                 ## 8-byte Spill
	movl	-64(%rbp), %r15d                ## 4-byte Reload
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	%r15d, %edx
	movq	%rax, %r12
	movq	%rax, %rcx
	callq	_fwrite
	xorl	%edi, %edi
	cmpl	%r15d, %eax
	setne	%dil
	callq	_err_if
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movq	%r12, %rax
	addq	%rcx, %rbx
	decl	%r13d
	jne	LBB0_10
## %bb.11:
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	movl	-64(%rbp), %r13d                ## 4-byte Reload
	.p2align	4, 0x90
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movl	%r13d, %edx
	movq	%r12, %rcx
	callq	_fwrite
	xorl	%edi, %edi
	cmpl	%r13d, %eax
	setne	%dil
	callq	_err_if
	addq	-48(%rbp), %rbx                 ## 8-byte Folded Reload
	decl	%r14d
	jne	LBB0_12
LBB0_13:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_free
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	callq	_free
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_free                           ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"wb"

L_.str.1:                               ## @.str.1
	.asciz	"P5\n%d %d\n%d\n"

	.comm	_stdout,8,3                     ## @stdout
	.no_dead_strip	_pgmyuv_save
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function pgmyuv_save
_pgmyuv_save:                           ; @pgmyuv_save
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x22, x3
	mov	x24, x2
	mov	x23, x1
	mov	x25, x0
	mul	w26, w2, w1
	mov	x0, x26
	bl	_malloc
	mov	x19, x0
	add	w8, w26, #3
	cmp	w26, #0
	csel	w8, w8, w26, lt
	asr	w21, w8, #2
	mov	x0, x21
	bl	_malloc
	mov	x20, x0
	mov	x0, x21
	bl	_malloc
	mov	x21, x0
	mov	x0, x19
	mov	x1, x20
	mov	x2, x21
	mov	x3, x22
	mov	x4, x23
	mov	x5, x24
	bl	_rgb24_to_yuv420p
	cbz	x25, LBB0_2
; %bb.1:
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x25
	bl	_fopen
	mov	x22, x0
	add	w8, w24, w24, lsl #1
	cmp	w8, #0
	cinc	w8, w8, lt
	asr	w3, w8, #1
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x2, x23
	mov	w4, #255
	bl	_fprintf
	b	LBB0_3
LBB0_2:
Lloh4:
	adrp	x8, _stdout@GOTPAGE
Lloh5:
	ldr	x8, [x8, _stdout@GOTPAGEOFF]
Lloh6:
	ldr	x22, [x8]
LBB0_3:
	mov	x0, x19
	mov	w1, #1
	mov	x2, x26
	mov	x3, x22
	bl	_fwrite
	cmp	w0, w26
	cset	w0, ne
	bl	_err_if
	cmp	w24, #0
	cinc	w8, w24, lt
	asr	w26, w8, #1
	cmp	w23, #0
	cinc	w8, w23, lt
	asr	w23, w8, #1
	cmp	w24, #2
	cbz	x25, LBB0_8
; %bb.4:
	b.lt	LBB0_7
; %bb.5:
	mov	x25, #0
	sxtw	x27, w23
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	add	x0, x20, x25
	add	x24, x21, x25
	mov	w1, #1
	mov	x2, x23
	mov	x3, x22
	bl	_fwrite
	cmp	w0, w23
	cset	w0, ne
	bl	_err_if
	mov	x0, x24
	mov	w1, #1
	mov	x2, x23
	mov	x3, x22
	bl	_fwrite
	cmp	w0, w23
	cset	w0, ne
	bl	_err_if
	add	x25, x25, x27
	subs	w26, w26, #1
	b.ne	LBB0_6
LBB0_7:
	mov	x0, x22
	bl	_fclose
	b	LBB0_13
LBB0_8:
	b.lt	LBB0_13
; %bb.9:
	mov	x8, x23
	sxtw	x25, w8
	mov	x27, x26
	mov	x24, x20
LBB0_10:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x24
	mov	w1, #1
	mov	x2, x23
	mov	x3, x22
	bl	_fwrite
	cmp	w0, w23
	cset	w0, ne
	bl	_err_if
	add	x24, x24, x25
	subs	w27, w27, #1
	b.ne	LBB0_10
; %bb.11:
	mov	x24, x21
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x24
	mov	w1, #1
	mov	x2, x23
	mov	x3, x22
	bl	_fwrite
	cmp	w0, w23
	cset	w0, ne
	bl	_err_if
	add	x24, x24, x25
	subs	w26, w26, #1
	b.ne	LBB0_12
LBB0_13:
	mov	x0, x19
	bl	_free
	mov	x0, x20
	bl	_free
	mov	x0, x21
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_free
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"wb"

l_.str.1:                               ; @.str.1
	.asciz	"P5\n%d %d\n%d\n"

	.comm	_stdout,8,3                     ; @stdout
	.no_dead_strip	_pgmyuv_save
.subsections_via_symbols
