	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function get_palette
_get_palette:                           ## @get_palette
	.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	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r14d
	movq	%rdi, %rbx
	movq	_WINCODEC_SDK_VERSION@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	-48(%rbp), %rsi
	callq	_WICCreateImagingFactory_Proxy
	movq	_S_OK@GOTPCREL(%rip), %r15
	cmpq	(%r15), %rax
	jne	LBB0_1
## %bb.2:
	movq	-48(%rbp), %rdi
	leaq	-32(%rbp), %rsi
	callq	_IWICImagingFactory_CreatePalette
	cmpq	(%r15), %rax
	jne	LBB0_3
## %bb.4:
	testq	%rbx, %rbx
	je	LBB0_5
## %bb.6:
	movq	-32(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_IWICBitmapFrameDecode_CopyPalette
	movq	%rax, %rcx
	movq	(%r15), %rax
	cmpq	%rax, %rcx
	jne	LBB0_8
	jmp	LBB0_10
LBB0_1:
	xorl	%ebx, %ebx
	jmp	LBB0_20
LBB0_3:
	xorl	%ebx, %ebx
	jmp	LBB0_19
LBB0_5:
	movq	_WINCODEC_ERR_PALETTEUNAVAILABLE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	%rax, %rcx
	je	LBB0_10
LBB0_8:
	leaq	L_.str(%rip), %rdi
	movl	%r14d, %esi
	callq	_TRACE
	movq	-32(%rbp), %rdi
	movq	_FALSE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	%r14d, %esi
	callq	_IWICPalette_InitializePredefined
	cmpq	(%r15), %rax
	jne	LBB0_9
LBB0_10:
	movq	-32(%rbp), %rdi
	leaq	-36(%rbp), %rsi
	callq	_IWICPalette_GetColorCount
	movl	-36(%rbp), %eax
	leal	8(,%rax,4), %edi
	callq	_heap_alloc
	movq	%rax, %rbx
	movq	-32(%rbp), %rdi
	movl	-36(%rbp), %esi
	movl	8(%rax), %edx
	leaq	4(%rax), %rcx
	callq	_IWICPalette_GetColors
	movq	-32(%rbp), %rdi
	leaq	-40(%rbp), %rsi
	callq	_IWICPalette_GetType
	movl	-40(%rbp), %eax
	leal	-128(%rax), %ecx
	cmpl	$7, %ecx
	jae	LBB0_11
## %bb.14:
	movq	_PaletteFlagsHalftone@GOTPCREL(%rip), %rax
	jmp	LBB0_15
LBB0_11:
	addl	$-135, %eax
	cmpl	$2, %eax
	ja	LBB0_12
## %bb.13:
	movq	_PaletteFlagsGrayScale@GOTPCREL(%rip), %rax
LBB0_15:
	movl	(%rax), %eax
LBB0_16:
	movl	%eax, (%rbx)
	movq	-32(%rbp), %rdi
	leaq	-56(%rbp), %rsi
	callq	_IWICPalette_HasAlpha
	cmpq	$0, -56(%rbp)
	je	LBB0_18
## %bb.17:
	movq	_PaletteFlagsHasAlpha@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	orl	%eax, (%rbx)
	jmp	LBB0_18
LBB0_9:
	xorl	%ebx, %ebx
LBB0_18:
	movq	-32(%rbp), %rdi
	callq	_IWICPalette_Release
LBB0_19:
	movq	-48(%rbp), %rdi
	callq	_IWICImagingFactory_Release
LBB0_20:
	movq	%rbx, %rax
	addq	$40, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	xorl	%eax, %eax
	jmp	LBB0_16
	.cfi_endproc
                                        ## -- End function
	.comm	_WINCODEC_SDK_VERSION,4,2       ## @WINCODEC_SDK_VERSION
	.comm	_S_OK,8,3                       ## @S_OK
	.comm	_WINCODEC_ERR_PALETTEUNAVAILABLE,8,3 ## @WINCODEC_ERR_PALETTEUNAVAILABLE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"using predefined palette %#x\n"

	.comm	_FALSE,4,2                      ## @FALSE
	.comm	_PaletteFlagsGrayScale,4,2      ## @PaletteFlagsGrayScale
	.comm	_PaletteFlagsHalftone,4,2       ## @PaletteFlagsHalftone
	.comm	_PaletteFlagsHasAlpha,4,2       ## @PaletteFlagsHasAlpha
	.no_dead_strip	_get_palette
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function get_palette
_get_palette:                           ; @get_palette
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	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
	mov	x19, x1
	mov	x20, x0
Lloh0:
	adrp	x8, _WINCODEC_SDK_VERSION@GOTPAGE
Lloh1:
	ldr	x8, [x8, _WINCODEC_SDK_VERSION@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	add	x1, sp, #40
	bl	_WICCreateImagingFactory_Proxy
Lloh3:
	adrp	x21, _S_OK@GOTPAGE
Lloh4:
	ldr	x21, [x21, _S_OK@GOTPAGEOFF]
	ldr	x8, [x21]
	cmp	x0, x8
	b.ne	LBB0_4
; %bb.1:
	ldr	x0, [sp, #40]
	add	x1, sp, #32
	bl	_IWICImagingFactory_CreatePalette
	ldr	x8, [x21]
	cmp	x0, x8
	b.ne	LBB0_5
; %bb.2:
	cbz	x20, LBB0_6
; %bb.3:
	ldr	x1, [sp, #32]
	mov	x0, x20
	bl	_IWICBitmapFrameDecode_CopyPalette
	mov	x8, x0
	ldr	x0, [x21]
	cmp	x8, x0
	b.ne	LBB0_7
	b	LBB0_8
LBB0_4:
	mov	x19, #0
	b	LBB0_18
LBB0_5:
	mov	x19, #0
	b	LBB0_17
LBB0_6:
Lloh5:
	adrp	x8, _WINCODEC_ERR_PALETTEUNAVAILABLE@GOTPAGE
Lloh6:
	ldr	x8, [x8, _WINCODEC_ERR_PALETTEUNAVAILABLE@GOTPAGEOFF]
Lloh7:
	ldr	x8, [x8]
	cmp	x8, x0
	b.eq	LBB0_8
LBB0_7:
Lloh8:
	adrp	x0, l_.str@PAGE
Lloh9:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x19
	bl	_TRACE
	ldr	x0, [sp, #32]
Lloh10:
	adrp	x8, _FALSE@GOTPAGE
Lloh11:
	ldr	x8, [x8, _FALSE@GOTPAGEOFF]
Lloh12:
	ldr	w2, [x8]
	mov	x1, x19
	bl	_IWICPalette_InitializePredefined
	ldr	x8, [x21]
	cmp	x0, x8
	b.ne	LBB0_15
LBB0_8:
	ldr	x0, [sp, #32]
	add	x1, sp, #12
	bl	_IWICPalette_GetColorCount
	ldr	w8, [sp, #12]
	lsl	w8, w8, #2
	add	w0, w8, #8
	bl	_heap_alloc
	mov	x19, x0
	ldr	x0, [sp, #32]
	ldr	w1, [sp, #12]
	ldr	w2, [x19, #8]
	add	x3, x19, #4
	bl	_IWICPalette_GetColors
	ldr	x0, [sp, #32]
	add	x1, sp, #28
	bl	_IWICPalette_GetType
	ldr	w8, [sp, #28]
	sub	w9, w8, #128
	cmp	w9, #7
	b.hs	LBB0_10
; %bb.9:
Lloh13:
	adrp	x8, _PaletteFlagsHalftone@GOTPAGE
Lloh14:
	ldr	x8, [x8, _PaletteFlagsHalftone@GOTPAGEOFF]
	b	LBB0_12
LBB0_10:
	sub	w8, w8, #135
	cmp	w8, #2
	b.hi	LBB0_19
; %bb.11:
Lloh15:
	adrp	x8, _PaletteFlagsGrayScale@GOTPAGE
Lloh16:
	ldr	x8, [x8, _PaletteFlagsGrayScale@GOTPAGEOFF]
LBB0_12:
	ldr	w8, [x8]
LBB0_13:
	str	w8, [x19]
	ldr	x0, [sp, #32]
	add	x1, sp, #16
	bl	_IWICPalette_HasAlpha
	ldr	x8, [sp, #16]
	cbz	x8, LBB0_16
; %bb.14:
Lloh17:
	adrp	x8, _PaletteFlagsHasAlpha@GOTPAGE
Lloh18:
	ldr	x8, [x8, _PaletteFlagsHasAlpha@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	ldr	w9, [x19]
	orr	w8, w9, w8
	str	w8, [x19]
	b	LBB0_16
LBB0_15:
	mov	x19, #0
LBB0_16:
	ldr	x0, [sp, #32]
	bl	_IWICPalette_Release
LBB0_17:
	ldr	x0, [sp, #40]
	bl	_IWICImagingFactory_Release
LBB0_18:
	mov	x0, x19
	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
	add	sp, sp, #96
	ret
LBB0_19:
	mov	w8, #0
	b	LBB0_13
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_WINCODEC_SDK_VERSION,4,2       ; @WINCODEC_SDK_VERSION
	.comm	_S_OK,8,3                       ; @S_OK
	.comm	_WINCODEC_ERR_PALETTEUNAVAILABLE,8,3 ; @WINCODEC_ERR_PALETTEUNAVAILABLE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"using predefined palette %#x\n"

	.comm	_FALSE,4,2                      ; @FALSE
	.comm	_PaletteFlagsGrayScale,4,2      ; @PaletteFlagsGrayScale
	.comm	_PaletteFlagsHalftone,4,2       ; @PaletteFlagsHalftone
	.comm	_PaletteFlagsHasAlpha,4,2       ; @PaletteFlagsHasAlpha
	.no_dead_strip	_get_palette
.subsections_via_symbols
