	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_gdImagePaletteCopy             ## -- Begin function gdImagePaletteCopy
	.p2align	4, 0x90
_gdImagePaletteCopy:                    ## @gdImagePaletteCopy
	.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	$1032, %rsp                     ## imm = 0x408
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	cmpq	$0, 56(%rdi)
	jne	LBB0_19
## %bb.1:
	movq	%rsi, %r14
	cmpq	$0, 56(%rsi)
	jne	LBB0_19
## %bb.2:
	movq	%rdi, %r12
	leaq	-1072(%rbp), %rdi
	movl	$1024, %edx                     ## imm = 0x400
	movl	$255, %esi
	callq	_memset
	movl	(%r12), %ecx
	testl	%ecx, %ecx
	jle	LBB0_11
## %bb.3:
	movl	4(%r12), %eax
	xorl	%r15d, %r15d
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_4 Depth=1
	movl	(%r12), %ecx
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=1
	incl	%r15d
	cmpl	%ecx, %r15d
	jge	LBB0_11
LBB0_4:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_6 Depth 2
	testl	%eax, %eax
	jle	LBB0_10
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	xorl	%ebx, %ebx
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_6 Depth=2
	movq	%r12, %rdi
	movl	%ebx, %esi
	movl	%r15d, %edx
	callq	_gdImageSetPixel
	incl	%ebx
	movl	4(%r12), %eax
	cmpl	%eax, %ebx
	jge	LBB0_9
LBB0_6:                                 ##   Parent Loop BB0_4 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%r12, %rdi
	movl	%ebx, %esi
	movl	%r15d, %edx
	callq	_gdImageGetPixel
	movslq	%eax, %r13
	movl	-1072(%rbp,%r13,4), %ecx
	cmpl	$-1, %ecx
	jne	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=2
	movq	48(%r12), %rax
	movl	(%rax,%r13,4), %esi
	movq	24(%r12), %rax
	movq	32(%r12), %rcx
	movl	(%rcx,%r13,4), %edx
	movq	40(%r12), %rcx
	movl	(%rcx,%r13,4), %ecx
	movl	(%rax,%r13,4), %r8d
	movq	%r14, %rdi
	callq	_gdImageColorClosestAlpha
	movl	%eax, %ecx
	movl	%eax, -1072(%rbp,%r13,4)
	jmp	LBB0_8
LBB0_11:
	movl	8(%r14), %ebx
	testl	%ebx, %ebx
	jle	LBB0_14
## %bb.12:
	movq	48(%r14), %r8
	movq	48(%r12), %r9
	movq	40(%r14), %r10
	movq	40(%r12), %r11
	movq	24(%r14), %r15
	movq	32(%r14), %rax
	movq	32(%r12), %rcx
	movq	16(%r12), %rdx
	movq	24(%r12), %rsi
	xorl	%edi, %edi
	.p2align	4, 0x90
LBB0_13:                                ## =>This Inner Loop Header: Depth=1
	movl	(%r8,%rdi,4), %ebx
	movl	%ebx, (%r9,%rdi,4)
	movl	(%r10,%rdi,4), %ebx
	movl	%ebx, (%r11,%rdi,4)
	movl	(%rax,%rdi,4), %ebx
	movl	%ebx, (%rcx,%rdi,4)
	movl	(%r15,%rdi,4), %ebx
	movl	%ebx, (%rsi,%rdi,4)
	movl	$0, (%rdx,%rdi,4)
	incq	%rdi
	movslq	8(%r14), %rbx
	cmpq	%rbx, %rdi
	jl	LBB0_13
LBB0_14:
	cmpl	8(%r12), %ebx
	jge	LBB0_18
## %bb.15:
	movq	16(%r12), %rax
	movslq	%ebx, %rcx
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	movl	$1, (%rax,%rcx,4)
	incq	%rcx
	movslq	8(%r12), %rdx
	cmpq	%rdx, %rcx
	jl	LBB0_16
## %bb.17:
	movl	8(%r14), %ebx
LBB0_18:
	movl	%ebx, 8(%r12)
LBB0_19:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_21
## %bb.20:
	addq	$1032, %rsp                     ## imm = 0x408
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_21:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_gdImagePaletteCopy             ; -- Begin function gdImagePaletteCopy
	.p2align	2
_gdImagePaletteCopy:                    ; @gdImagePaletteCopy
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-80]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w27, -72
	.cfi_offset w28, -80
	sub	sp, sp, #1040
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-72]
	ldr	x8, [x0, #56]
	cbnz	x8, LBB0_20
; %bb.1:
	mov	x20, x1
	ldr	x8, [x1, #56]
	cbnz	x8, LBB0_20
; %bb.2:
	mov	x19, x0
	add	x23, sp, #8
	add	x0, sp, #8
	mov	w1, #255
	mov	w2, #1024
	bl	_memset
	ldr	w9, [x19]
	cmp	w9, #1
	b.lt	LBB0_11
; %bb.3:
	mov	w21, #0
	ldr	w8, [x19, #4]
	b	LBB0_6
LBB0_4:                                 ;   in Loop: Header=BB0_6 Depth=1
	ldr	w9, [x19]
LBB0_5:                                 ;   in Loop: Header=BB0_6 Depth=1
	add	w21, w21, #1
	cmp	w21, w9
	b.ge	LBB0_11
LBB0_6:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_9 Depth 2
	cmp	w8, #1
	b.lt	LBB0_5
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=1
	mov	w22, #0
	b	LBB0_9
LBB0_8:                                 ;   in Loop: Header=BB0_9 Depth=2
	mov	x0, x19
	mov	x1, x22
	mov	x2, x21
	bl	_gdImageSetPixel
	add	w22, w22, #1
	ldr	w8, [x19, #4]
	cmp	w22, w8
	b.ge	LBB0_4
LBB0_9:                                 ;   Parent Loop BB0_6 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x19
	mov	x1, x22
	mov	x2, x21
	bl	_gdImageGetPixel
                                        ; kill: def $w0 killed $w0 def $x0
	ldr	w3, [x23, w0, sxtw #2]
	cmn	w3, #1
	b.ne	LBB0_8
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=2
	sxtw	x8, w0
	lsl	x24, x8, #2
	ldp	x9, x8, [x19, #40]
	ldr	w1, [x8, x24]
	ldp	x10, x8, [x19, #24]
	ldr	w2, [x8, x24]
	ldr	w3, [x9, x24]
	ldr	w4, [x10, x24]
	mov	x0, x20
	bl	_gdImageColorClosestAlpha
	mov	x3, x0
	str	w0, [x23, x24]
	b	LBB0_8
LBB0_11:
	ldr	w8, [x20, #8]
	cmp	w8, #1
	b.lt	LBB0_15
; %bb.12:
	mov	x8, #0
	ldp	x12, x9, [x19, #40]
	ldp	x11, x10, [x20, #40]
	ldp	x16, x13, [x19, #24]
	ldp	x15, x14, [x20, #24]
	ldr	x17, [x19, #16]
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	lsl	x0, x8, #2
	ldr	w1, [x10, x0]
	str	w1, [x9, x0]
	ldr	w1, [x11, x0]
	str	w1, [x12, x0]
	ldr	w1, [x14, x0]
	str	w1, [x13, x0]
	ldr	w1, [x15, x0]
	str	w1, [x16, x0]
	str	wzr, [x17, x0]
	add	x8, x8, #1
	ldrsw	x0, [x20, #8]
	cmp	x8, x0
	b.lt	LBB0_13
; %bb.14:
	mov	x8, x0
LBB0_15:
	ldr	w9, [x19, #8]
	cmp	w8, w9
	b.ge	LBB0_19
; %bb.16:
	ldr	x9, [x19, #16]
	sxtw	x8, w8
	mov	w10, #1
LBB0_17:                                ; =>This Inner Loop Header: Depth=1
	str	w10, [x9, x8, lsl #2]
	add	x8, x8, #1
	ldrsw	x11, [x19, #8]
	cmp	x8, x11
	b.lt	LBB0_17
; %bb.18:
	ldr	w8, [x20, #8]
LBB0_19:
	str	w8, [x19, #8]
LBB0_20:
	ldur	x8, [x29, #-72]
Lloh3:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh4:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_22
; %bb.21:
	add	sp, sp, #1040
	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
	ldp	x28, x27, [sp], #80             ; 16-byte Folded Reload
	ret
LBB0_22:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols
