	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function gp2x_video_setpalette_
_gp2x_video_setpalette_:                ## @gp2x_video_setpalette_
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	.cfi_offset %rbx, -24
	testl	%esi, %esi
	jle	LBB0_14
## %bb.1:
	movq	_memregl@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	leaq	16496(%rcx), %r10
	movl	%esi, %r8d
	cmpl	$8, %esi
	jb	LBB0_2
## %bb.3:
	leaq	(%rdi,%r8,4), %rdx
	cmpq	%rdx, %r10
	jae	LBB0_6
## %bb.4:
	addq	$16500, %rcx                    ## imm = 0x4074
	cmpq	%rdi, %rcx
	jbe	LBB0_6
LBB0_2:
	xorl	%r11d, %r11d
LBB0_9:
	movq	%r11, %rsi
	notq	%rsi
	testb	$1, %r8b
	je	LBB0_11
## %bb.10:
	movl	(%rdi,%r11,4), %eax
	movl	%eax, %ecx
	shrl	$8, %ecx
	andl	$63488, %ecx                    ## imm = 0xF800
	movl	%eax, %edx
	shrl	$5, %edx
	andl	$1984, %edx                     ## imm = 0x7C0
	shrl	$3, %eax
	andl	$31, %eax
	movl	%r11d, %ebx
	shll	$24, %ebx
	orl	%edx, %ebx
	orl	%ecx, %ebx
	orl	%eax, %ebx
	movl	%ebx, (%r10)
	orq	$1, %r11
LBB0_11:
	addq	%r8, %rsi
	je	LBB0_14
## %bb.12:
	movl	%r11d, %esi
	shll	$24, %esi
	.p2align	4, 0x90
LBB0_13:                                ## =>This Inner Loop Header: Depth=1
	movl	(%rdi,%r11,4), %eax
	movl	%eax, %ecx
	shrl	$8, %ecx
	andl	$63488, %ecx                    ## imm = 0xF800
	movl	%eax, %edx
	shrl	$5, %edx
	andl	$1984, %edx                     ## imm = 0x7C0
	shrl	$3, %eax
	andl	$31, %eax
	orl	%ecx, %eax
	orl	%esi, %edx
	orl	%eax, %edx
	movl	%edx, (%r10)
	movl	4(%rdi,%r11,4), %eax
	movl	%eax, %ecx
	shrl	$8, %ecx
	andl	$63488, %ecx                    ## imm = 0xF800
	movl	%eax, %edx
	shrl	$5, %edx
	andl	$1984, %edx                     ## imm = 0x7C0
	shrl	$3, %eax
	andl	$31, %eax
	orl	%ecx, %eax
	leal	16777216(%rsi), %ecx
	orl	%edx, %ecx
	orl	%eax, %ecx
	movl	%ecx, (%r10)
	addq	$2, %r11
	addl	$33554432, %esi                 ## imm = 0x2000000
	cmpq	%r11, %r8
	jne	LBB0_13
	jmp	LBB0_14
LBB0_6:
	movl	%r8d, %r11d
	andl	$-8, %r11d
	leaq	(,%r8,4), %r9
	andq	$-32, %r9
	movl	$117440512, %ecx                ## imm = 0x7000000
	xorl	%esi, %esi
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movl	28(%rdi,%rsi), %eax
	movl	%eax, %edx
	shrl	$5, %edx
	andl	$1984, %edx                     ## imm = 0x7C0
	orl	%ecx, %edx
	movl	%eax, %ebx
	shrl	$8, %ebx
	andl	$63488, %ebx                    ## imm = 0xF800
	shrl	$3, %eax
	andl	$31, %eax
	orl	%ebx, %eax
	orl	%edx, %eax
	movl	%eax, (%r10)
	addq	$32, %rsi
	addl	$134217728, %ecx                ## imm = 0x8000000
	cmpq	%rsi, %r9
	jne	LBB0_7
## %bb.8:
	cmpq	%r8, %r11
	jne	LBB0_9
LBB0_14:
	popq	%rbx
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_memregl,8,3                    ## @memregl
	.no_dead_strip	_gp2x_video_setpalette_
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function gp2x_video_setpalette_
_gp2x_video_setpalette_:                ; @gp2x_video_setpalette_
	.cfi_startproc
; %bb.0:
	cmp	w1, #1
	b.lt	LBB0_9
; %bb.1:
Lloh0:
	adrp	x8, _memregl@GOTPAGE
Lloh1:
	ldr	x8, [x8, _memregl@GOTPAGEOFF]
Lloh2:
	ldr	x10, [x8]
	mov	w8, #16496
	add	x8, x10, x8
	mov	w9, w1
	cmp	w1, #16
	b.lo	LBB0_6
; %bb.2:
	mov	w11, #16500
	add	x10, x10, x11
	add	x11, x0, x9, lsl #2
	cmp	x8, x11
	ccmp	x10, x0, #0, lo
	b.hi	LBB0_6
; %bb.3:
	and	x10, x9, #0xfffffff0
	add	x11, x0, #60
	mov	w12, #251658240
	mov	w13, #268435456
	mov	x14, x10
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w15, [x11], #64
	lsr	w16, w15, #5
	and	w16, w16, #0x7c0
	orr	w16, w16, w12
	lsr	w17, w15, #8
	and	w17, w17, #0xf800
	orr	w16, w16, w17
	ubfx	w15, w15, #3, #5
	orr	w15, w16, w15
	str	w15, [x8]
	add	w12, w12, w13
	subs	x14, x14, #16
	b.ne	LBB0_4
; %bb.5:
	cmp	x10, x9
	b.ne	LBB0_7
	b	LBB0_9
LBB0_6:
	mov	x10, #0
LBB0_7:
	lsl	w11, w10, #24
	sub	x9, x9, x10
	mov	w12, #16777216
	add	x10, x0, x10, lsl #2
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w13, [x10], #4
	lsr	w14, w13, #8
	and	w14, w14, #0xf800
	lsr	w15, w13, #5
	and	w15, w15, #0x7c0
	ubfx	w13, w13, #3, #5
	orr	w15, w15, w11
	orr	w14, w15, w14
	orr	w13, w14, w13
	str	w13, [x8]
	add	w11, w11, w12
	subs	x9, x9, #1
	b.ne	LBB0_8
LBB0_9:
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_memregl,8,3                    ; @memregl
	.no_dead_strip	_gp2x_video_setpalette_
.subsections_via_symbols
