	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_render_bg_m4                   ## -- Begin function render_bg_m4
	.p2align	4, 0x90
_render_bg_m4:                          ## @render_bg_m4
	.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
	movl	%esi, %r13d
	movl	%edi, %eax
	movq	_reg@GOTPCREL(%rip), %r9
	movq	(%r9), %rcx
	cmpl	$15, %edi
	jg	LBB0_2
## %bb.1:
	movl	(%rcx), %edx
	movl	$256, %r8d                      ## imm = 0x100
	andl	$64, %edx
	jne	LBB0_3
LBB0_2:
	movl	32(%rcx), %r8d
LBB0_3:
	movl	%r8d, %edx
	andl	$7, %edx
	movq	_linebuf@GOTPCREL(%rip), %r10
	movq	_vscroll@GOTPCREL(%rip), %rsi
	movl	(%rsi), %r14d
	addl	%eax, %r14d
	movl	8(%rcx), %ecx
	shll	$10, %ecx
	xorl	$-15361, %ecx                   ## imm = 0xC3FF
	movq	_system_hw@GOTPCREL(%rip), %rsi
	movq	(%rsi), %rsi
	movq	_SYSTEM_SMS@GOTPCREL(%rip), %rdi
	movl	%ecx, %ebx
	orl	$1024, %ebx                     ## imm = 0x400
	cmpq	(%rdi), %rsi
	cmovlel	%ecx, %ebx
	movq	(%r10), %r10
	movq	_bitmap@GOTPCREL(%rip), %rcx
	cmpl	$193, (%rcx)
	jl	LBB0_5
## %bb.4:
	leal	255(%r14), %ecx
	testl	%r14d, %r14d
	cmovnsl	%r14d, %ecx
	andl	$536870656, %ecx                ## imm = 0x1FFFFF00
	subl	%ecx, %r14d
	movl	%ebx, %esi
	andl	$14080, %esi                    ## imm = 0x3700
	shll	$3, %r14d
	movl	%r14d, %ecx
	andl	$-64, %ecx
	addl	%esi, %ecx
	jmp	LBB0_6
LBB0_5:
	movslq	%r14d, %rcx
	imulq	$-1840700269, %rcx, %rsi        ## imm = 0x92492493
	shrq	$32, %rsi
	addl	%r14d, %esi
	movl	%esi, %edi
	shrl	$31, %edi
	sarl	$7, %esi
	addl	%edi, %esi
	imull	$224, %esi, %esi
	subl	%esi, %ecx
	movl	%ecx, %r14d
	shll	$3, %r14d
	leal	14336(,%rcx,8), %ecx
	andl	%ebx, %ecx
	andl	$-64, %ecx
LBB0_6:
	movq	(%r10), %rdi
	movq	_vram@GOTPCREL(%rip), %rsi
	movslq	%ecx, %r12
	shlq	$2, %r12
	addq	(%rsi), %r12
	movl	$256, %r15d                     ## imm = 0x100
	subl	%r8d, %r15d
	sarl	$3, %r15d
	testl	%edx, %edx
	movq	%rdx, -64(%rbp)                 ## 8-byte Spill
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	je	LBB0_8
## %bb.7:
	addq	$128, %rdi
	xorl	%esi, %esi
                                        ## kill: def $edx killed $edx killed $rdx
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	callq	_memset
	movq	_vram@GOTPCREL(%rip), %rsi
	movq	_reg@GOTPCREL(%rip), %r9
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	incl	%r15d
LBB0_8:
	cmpl	$8, %r13d
	jl	LBB0_14
## %bb.9:
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	orl	$32, %ecx
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	leaq	(%rdx,%rcx,4), %rcx
	andl	$56, %r14d
	sarl	$3, %r13d
	movq	(%r9), %rdx
	movq	%rdx, -64(%rbp)                 ## 8-byte Spill
	movq	(%rsi), %rdx
	movl	%eax, %esi
	shll	$3, %esi
	leal	14336(,%rax,8), %eax
	andl	%ebx, %eax
	andl	$-64, %eax
	movl	%eax, -48(%rbp)                 ## 4-byte Spill
	andl	$14080, %ebx                    ## imm = 0x3700
	movl	%esi, %eax
	andl	$-64, %eax
	addl	%ebx, %eax
	movl	%eax, -68(%rbp)                 ## 4-byte Spill
	andl	$56, %esi
	movl	%esi, -56(%rbp)                 ## 4-byte Spill
	movq	_atex_table@GOTPCREL(%rip), %rax
	movq	(%rax), %r11
	movq	_bg_pattern_cache@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	cmpl	$2, %r13d
	movl	$1, %r10d
	cmovgel	%r13d, %r10d
	movl	%r15d, %r8d
	movq	%rdx, %r15
	xorl	%r9d, %r9d
	jmp	LBB0_10
	.p2align	4, 0x90
LBB0_13:                                ##   in Loop: Header=BB0_10 Depth=1
                                        ## kill: def $eax killed $eax killed $rax
	cltd
	idivl	%r13d
	movslq	%edx, %rax
	movzwl	(%r12,%rax,4), %eax
	rolw	$8, %ax
	movzwl	%ax, %eax
	movl	%eax, %edx
	shrl	$11, %edx
	andl	$3, %edx
	movl	(%r11,%rdx,4), %edx
	shll	$6, %eax
	andl	$131008, %eax                   ## imm = 0x1FFC0
	orl	%r14d, %eax
	cltq
	movl	(%rsi,%rax,4), %ebx
	orl	%edx, %ebx
	movl	%ebx, (%rcx,%rdi,4)
	orl	4(%rsi,%rax,4), %edx
	movl	%edx, 4(%rcx,%rdi,4)
	incq	%r9
	cmpl	%r9d, %r10d
	je	LBB0_14
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	leaq	(%r9,%r9), %rdi
	leaq	(%r8,%r9), %rax
	cmpl	$24, %r9d
	jne	LBB0_13
## %bb.11:                              ##   in Loop: Header=BB0_10 Depth=1
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
	testb	$-128, (%rdx)
	je	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_10 Depth=1
	movq	_bitmap@GOTPCREL(%rip), %rdx
	cmpl	$193, (%rdx)
	movl	-48(%rbp), %edx                 ## 4-byte Reload
	cmovgel	-68(%rbp), %edx                 ## 4-byte Folded Reload
	movslq	%edx, %rdx
	leaq	(%r15,%rdx,4), %r12
	movl	-56(%rbp), %edx                 ## 4-byte Reload
	movl	%edx, %r14d
	jmp	LBB0_13
LBB0_14:
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_reg,8,3                        ## @reg
	.comm	_linebuf,8,3                    ## @linebuf
	.comm	_vscroll,4,2                    ## @vscroll
	.comm	_system_hw,8,3                  ## @system_hw
	.comm	_SYSTEM_SMS,8,3                 ## @SYSTEM_SMS
	.comm	_bitmap,4,2                     ## @bitmap
	.comm	_vram,8,3                       ## @vram
	.comm	_atex_table,8,3                 ## @atex_table
	.comm	_bg_pattern_cache,8,3           ## @bg_pattern_cache
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_render_bg_m4                   ; -- Begin function render_bg_m4
	.p2align	2
_render_bg_m4:                          ; @render_bg_m4
	.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	x26, x1
	mov	x19, x0
Lloh0:
	adrp	x20, _reg@GOTPAGE
Lloh1:
	ldr	x20, [x20, _reg@GOTPAGEOFF]
	ldr	x8, [x20]
	cmp	w0, #15
	b.gt	LBB0_3
; %bb.1:
	ldr	w9, [x8]
	tbz	w9, #6, LBB0_3
; %bb.2:
	mov	w24, #256
	b	LBB0_4
LBB0_3:
	ldr	w24, [x8, #32]
LBB0_4:
Lloh2:
	adrp	x9, _linebuf@GOTPAGE
Lloh3:
	ldr	x9, [x9, _linebuf@GOTPAGEOFF]
Lloh4:
	ldr	x9, [x9]
	ldr	x14, [x9]
Lloh5:
	adrp	x9, _vscroll@GOTPAGE
Lloh6:
	ldr	x9, [x9, _vscroll@GOTPAGEOFF]
Lloh7:
	ldr	w9, [x9]
	ldr	w8, [x8, #8]
	lsl	w8, w8, #10
	eor	w8, w8, #0xffffc3ff
Lloh8:
	adrp	x10, _system_hw@GOTPAGE
Lloh9:
	ldr	x10, [x10, _system_hw@GOTPAGEOFF]
Lloh10:
	ldr	x10, [x10]
Lloh11:
	adrp	x11, _SYSTEM_SMS@GOTPAGE
Lloh12:
	ldr	x11, [x11, _SYSTEM_SMS@GOTPAGEOFF]
Lloh13:
	ldr	x11, [x11]
	orr	w12, w8, #0x400
	cmp	x10, x11
	csel	w25, w12, w8, gt
Lloh14:
	adrp	x7, _bitmap@GOTPAGE
Lloh15:
	ldr	x7, [x7, _bitmap@GOTPAGEOFF]
	ldr	w8, [x7]
	mov	w10, #9363
	movk	w10, #37449, lsl #16
	add	w9, w9, w19
	smull	x10, w9, w10
	lsr	x10, x10, #32
	add	w10, w10, w9
	asr	w11, w10, #7
	add	w10, w11, w10, lsr #31
	mov	w11, #224
	msub	w10, w10, w11, w9
	lsl	w10, w10, #3
	mov	w11, #14336
	add	w11, w10, w11
	and	w11, w25, w11
	and	w11, w11, #0xffffffc0
	negs	w12, w9
	and	w12, w12, #0xff
	and	w9, w9, #0xff
	csneg	w9, w9, w12, mi
	mov	w12, #14080
	and	w12, w25, w12
	lsl	w9, w9, #3
	and	w13, w9, #0xffffffc0
	add	w12, w12, w13
	cmp	w8, #193
	csel	w28, w11, w12, lt
Lloh16:
	adrp	x13, _vram@GOTPAGE
Lloh17:
	ldr	x13, [x13, _vram@GOTPAGEOFF]
	csel	w23, w10, w9, lt
	ldr	x21, [x13]
	mov	w8, #256
	sub	w8, w8, w24
	asr	w22, w8, #3
	and	w2, w24, #0x7
	cbz	w2, LBB0_6
; %bb.5:
	mov	x27, x14
	add	x0, x14, #128
	mov	w1, #0
	bl	_memset
Lloh18:
	adrp	x13, _vram@GOTPAGE
Lloh19:
	ldr	x13, [x13, _vram@GOTPAGEOFF]
Lloh20:
	adrp	x7, _bitmap@GOTPAGE
Lloh21:
	ldr	x7, [x7, _bitmap@GOTPAGEOFF]
	add	w22, w22, #1
	cmp	w26, #8
	b.ge	LBB0_7
	b	LBB0_12
LBB0_6:
	mov	x27, x14
	cmp	w26, #8
	b.lt	LBB0_12
LBB0_7:
	mov	x8, #0
	mov	w9, #32
	bfxil	w9, w24, #0, #3
	add	x9, x27, w9, uxtw #2
	add	x10, x21, w28, sxtw #2
	and	w14, w23, #0x38
	asr	w11, w26, #3
	ldr	x12, [x20]
	ldr	x13, [x13]
	lsl	w17, w19, #3
	mov	w15, #14336
	add	w15, w17, w15
	and	w15, w25, w15
	and	w15, w15, #0xffffffc0
	mov	w16, #14080
	and	w16, w25, w16
	and	w0, w17, #0xffffffc0
	add	w16, w16, w0
	and	w17, w17, #0x38
Lloh22:
	adrp	x0, _atex_table@GOTPAGE
Lloh23:
	ldr	x0, [x0, _atex_table@GOTPAGEOFF]
Lloh24:
	ldr	x0, [x0]
Lloh25:
	adrp	x1, _bg_pattern_cache@GOTPAGE
Lloh26:
	ldr	x1, [x1, _bg_pattern_cache@GOTPAGEOFF]
Lloh27:
	ldr	x1, [x1]
	cmp	w11, #1
	csinc	w2, w11, wzr, gt
	lsl	x2, x2, #3
	b	LBB0_9
LBB0_8:                                 ;   in Loop: Header=BB0_9 Depth=1
	add	x3, x9, x8
	sdiv	w4, w22, w11
	msub	w4, w4, w11, w22
	ldr	w4, [x10, w4, sxtw #2]
	rev	w4, w4
	ubfx	w5, w4, #27, #2
	ldr	w5, [x0, w5, uxtw #2]
	lsr	w4, w4, #10
	and	w4, w4, #0x1ffc0
	orr	w4, w4, w14
	add	x4, x1, w4, sxtw #2
	ldr	w6, [x4]
	orr	w6, w6, w5
	str	w6, [x9, x8]
	ldr	w4, [x4, #4]
	orr	w4, w4, w5
	str	w4, [x3, #4]
	add	w22, w22, #1
	add	x8, x8, #8
	cmp	w2, w8
	b.eq	LBB0_12
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	cmp	w8, #192
	b.ne	LBB0_8
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	ldrb	w3, [x12]
	tbz	w3, #7, LBB0_8
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	w10, [x7]
	cmp	w10, #192
	csel	w10, w16, w15, gt
	add	x10, x13, w10, sxtw #2
	mov	x14, x17
	b	LBB0_8
LBB0_12:
	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
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.cfi_endproc
                                        ; -- End function
	.comm	_reg,8,3                        ; @reg
	.comm	_linebuf,8,3                    ; @linebuf
	.comm	_vscroll,4,2                    ; @vscroll
	.comm	_system_hw,8,3                  ; @system_hw
	.comm	_SYSTEM_SMS,8,3                 ; @SYSTEM_SMS
	.comm	_bitmap,4,2                     ; @bitmap
	.comm	_vram,8,3                       ; @vram
	.comm	_atex_table,8,3                 ; @atex_table
	.comm	_bg_pattern_cache,8,3           ; @bg_pattern_cache
.subsections_via_symbols
