	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ddraw_palette_init             ## -- Begin function ddraw_palette_init
	.p2align	4, 0x90
_ddraw_palette_init:                    ## @ddraw_palette_init
	.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
	movq	%rcx, %r15
	movl	%edx, %ebx
	movq	%rsi, %r14
	movq	%rdi, %r12
	movl	%edx, %edi
	callq	_palette_size
	cmpl	$-1, %eax
	je	LBB0_1
## %bb.2:
	movq	_DDPCAPS_8BITENTRIES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	andl	%ebx, %ecx
	je	LBB0_4
## %bb.3:
	movq	_WINED3D_PALETTE_8BIT_ENTRIES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
LBB0_4:
	movq	_DDPCAPS_ALLOW256@GOTPCREL(%rip), %rdx
	movl	(%rdx), %esi
	andl	%ebx, %esi
	je	LBB0_6
## %bb.5:
	movq	_WINED3D_PALETTE_ALLOW_256@GOTPCREL(%rip), %rdx
	movl	(%rdx), %esi
LBB0_6:
	orl	%ecx, %esi
	movq	_DDPCAPS_ALPHA@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	andl	%ebx, %ecx
	je	LBB0_8
## %bb.7:
	movq	_WINED3D_PALETTE_ALPHA@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
LBB0_8:
	orl	%ecx, %esi
	movq	_ddraw_palette_vtbl@GOTPCREL(%rip), %rcx
	movq	%rcx, 32(%r12)
	movl	$1, (%r12)
	movl	%ebx, 4(%r12)
	movl	4(%r14), %edi
	leaq	24(%r12), %r8
	movl	%eax, %edx
	movq	%r15, %rcx
	callq	_wined3d_palette_create
	movl	%eax, %ebx
	movl	%eax, %edi
	callq	_FAILED
	testq	%rax, %rax
	je	LBB0_10
## %bb.9:
	leaq	L_.str.1(%rip), %rdi
	movl	%ebx, %esi
	callq	_WARN
	jmp	LBB0_12
LBB0_1:
	leaq	L_.str(%rip), %rdi
	movl	%ebx, %esi
	callq	_WARN
	movq	_DDERR_INVALIDPARAMS@GOTPCREL(%rip), %rax
	jmp	LBB0_11
LBB0_10:
	movq	%r14, 16(%r12)
	movq	%r14, 8(%r12)
	movq	%r14, %rdi
	callq	_IUnknown_AddRef
	movq	_DD_OK@GOTPCREL(%rip), %rax
LBB0_11:
	movl	(%rax), %ebx
LBB0_12:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid flags %#x.\n"

	.comm	_DDERR_INVALIDPARAMS,4,2        ## @DDERR_INVALIDPARAMS
	.comm	_DDPCAPS_8BITENTRIES,4,2        ## @DDPCAPS_8BITENTRIES
	.comm	_WINED3D_PALETTE_8BIT_ENTRIES,4,2 ## @WINED3D_PALETTE_8BIT_ENTRIES
	.comm	_DDPCAPS_ALLOW256,4,2           ## @DDPCAPS_ALLOW256
	.comm	_WINED3D_PALETTE_ALLOW_256,4,2  ## @WINED3D_PALETTE_ALLOW_256
	.comm	_DDPCAPS_ALPHA,4,2              ## @DDPCAPS_ALPHA
	.comm	_WINED3D_PALETTE_ALPHA,4,2      ## @WINED3D_PALETTE_ALPHA
	.comm	_ddraw_palette_vtbl,4,2         ## @ddraw_palette_vtbl
L_.str.1:                               ## @.str.1
	.asciz	"Failed to create wined3d palette, hr %#x.\n"

	.comm	_DD_OK,4,2                      ## @DD_OK
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ddraw_palette_init             ; -- Begin function ddraw_palette_init
	.p2align	2
_ddraw_palette_init:                    ; @ddraw_palette_init
	.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	x21, x3
	mov	x22, x2
	mov	x19, x1
	mov	x20, x0
	mov	x0, x2
	bl	_palette_size
	cmn	w0, #1
	b.eq	LBB0_3
; %bb.1:
	mov	x2, x0
Lloh0:
	adrp	x8, _DDPCAPS_8BITENTRIES@GOTPAGE
Lloh1:
	ldr	x8, [x8, _DDPCAPS_8BITENTRIES@GOTPAGEOFF]
Lloh2:
	adrp	x9, _WINED3D_PALETTE_8BIT_ENTRIES@GOTPAGE
Lloh3:
	ldr	x9, [x9, _WINED3D_PALETTE_8BIT_ENTRIES@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
Lloh5:
	ldr	w9, [x9]
	tst	w8, w22
	csel	w8, wzr, w9, eq
Lloh6:
	adrp	x9, _DDPCAPS_ALLOW256@GOTPAGE
Lloh7:
	ldr	x9, [x9, _DDPCAPS_ALLOW256@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
Lloh9:
	adrp	x10, _WINED3D_PALETTE_ALLOW_256@GOTPAGE
Lloh10:
	ldr	x10, [x10, _WINED3D_PALETTE_ALLOW_256@GOTPAGEOFF]
Lloh11:
	ldr	w10, [x10]
	tst	w9, w22
	csel	w9, wzr, w10, eq
	orr	w8, w9, w8
Lloh12:
	adrp	x9, _DDPCAPS_ALPHA@GOTPAGE
Lloh13:
	ldr	x9, [x9, _DDPCAPS_ALPHA@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
Lloh15:
	adrp	x10, _WINED3D_PALETTE_ALPHA@GOTPAGE
Lloh16:
	ldr	x10, [x10, _WINED3D_PALETTE_ALPHA@GOTPAGEOFF]
Lloh17:
	ldr	w10, [x10]
	tst	w9, w22
	csel	w9, wzr, w10, eq
	orr	w1, w8, w9
Lloh18:
	adrp	x8, _ddraw_palette_vtbl@GOTPAGE
Lloh19:
	ldr	x8, [x8, _ddraw_palette_vtbl@GOTPAGEOFF]
	str	x8, [x20, #32]
	mov	w8, #1
	stp	w8, w22, [x20]
	ldr	w0, [x19, #4]
	add	x4, x20, #24
	mov	x3, x21
	bl	_wined3d_palette_create
	mov	x21, x0
	bl	_FAILED
	cbz	x0, LBB0_4
; %bb.2:
Lloh20:
	adrp	x0, l_.str.1@PAGE
Lloh21:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x21
	bl	_WARN
	b	LBB0_6
LBB0_3:
Lloh22:
	adrp	x0, l_.str@PAGE
Lloh23:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x22
	bl	_WARN
Lloh24:
	adrp	x8, _DDERR_INVALIDPARAMS@GOTPAGE
Lloh25:
	ldr	x8, [x8, _DDERR_INVALIDPARAMS@GOTPAGEOFF]
	b	LBB0_5
LBB0_4:
	stp	x19, x19, [x20, #8]
	mov	x0, x19
	bl	_IUnknown_AddRef
Lloh26:
	adrp	x8, _DD_OK@GOTPAGE
Lloh27:
	ldr	x8, [x8, _DD_OK@GOTPAGEOFF]
LBB0_5:
	ldr	w21, [x8]
LBB0_6:
	mov	x0, x21
	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
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh4
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGot	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid flags %#x.\n"

	.comm	_DDERR_INVALIDPARAMS,4,2        ; @DDERR_INVALIDPARAMS
	.comm	_DDPCAPS_8BITENTRIES,4,2        ; @DDPCAPS_8BITENTRIES
	.comm	_WINED3D_PALETTE_8BIT_ENTRIES,4,2 ; @WINED3D_PALETTE_8BIT_ENTRIES
	.comm	_DDPCAPS_ALLOW256,4,2           ; @DDPCAPS_ALLOW256
	.comm	_WINED3D_PALETTE_ALLOW_256,4,2  ; @WINED3D_PALETTE_ALLOW_256
	.comm	_DDPCAPS_ALPHA,4,2              ; @DDPCAPS_ALPHA
	.comm	_WINED3D_PALETTE_ALPHA,4,2      ; @WINED3D_PALETTE_ALPHA
	.comm	_ddraw_palette_vtbl,4,2         ; @ddraw_palette_vtbl
l_.str.1:                               ; @.str.1
	.asciz	"Failed to create wined3d palette, hr %#x.\n"

	.comm	_DD_OK,4,2                      ; @DD_OK
.subsections_via_symbols
