	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_R_AddWorldSurfaces             ## -- Begin function R_AddWorldSurfaces
	.p2align	4, 0x90
_R_AddWorldSurfaces:                    ## @R_AddWorldSurfaces
	.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	_r_drawworld@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpl	$0, (%rax)
	je	LBB0_18
## %bb.1:
	movq	_tr@GOTPCREL(%rip), %r14
	movq	_RDF_NOWORLDMODEL@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, 16(%r14)
	jne	LBB0_18
## %bb.2:
	movq	_REFENTITYNUM_WORLD@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r14)
	movq	_QSORT_REFENTITYNUM_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %eax
	movl	%eax, 4(%r14)
	movq	_VPF_DEPTHSHADOW@GOTPCREL(%rip), %r15
	movl	(%r15), %eax
	testl	%eax, 56(%r14)
	jne	LBB0_4
## %bb.3:
	xorl	%eax, %eax
	callq	_R_MarkLeaves
LBB0_4:
	movq	64(%r14), %rax
	movl	(%rax), %edi
	movl	4(%rax), %esi
	callq	_ClearBounds
	movq	24(%r14), %rcx
	movq	_MAX_DLIGHTS@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rcx
	jbe	LBB0_6
## %bb.5:
	movq	%rax, 24(%r14)
	movq	%rax, %rcx
LBB0_6:
	movq	32(%r14), %rdi
	movq	_MAX_DRAWN_PSHADOWS@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	%rax, %rdi
	jbe	LBB0_8
## %bb.7:
	movq	%rax, 32(%r14)
	movq	%rax, %rdi
LBB0_8:
	movl	56(%r14), %ebx
	movq	_VPF_FARPLANEFRUSTUM@GOTPCREL(%rip), %rax
	xorl	%esi, %esi
	testl	%ebx, (%rax)
	setne	%sil
	shll	$4, %esi
	orl	$15, %esi
	xorl	%r12d, %r12d
	movl	$0, %edx
	movl	$0, %eax
	testl	%ebx, (%r15)
	jne	LBB0_12
## %bb.9:
	movq	_VPF_SHADOWMAP@GOTPCREL(%rip), %r8
	movq	$-1, %rdx
                                        ## kill: def $cl killed $cl killed $rcx
	shlq	%cl, %rdx
	movq	$-1, %rax
	notl	%edx
	testl	%ebx, (%r8)
	je	LBB0_11
## %bb.10:
	xorl	%eax, %eax
	jmp	LBB0_12
LBB0_11:
	movl	%edi, %ecx
	shlq	%cl, %rax
	notl	%eax
LBB0_12:
	movq	48(%r14), %rcx
	movl	40(%rcx), %edi
                                        ## kill: def $edx killed $edx killed $rdx
	movl	%eax, %ecx
	callq	_R_RecursiveWorldNode
	movl	$0, 40(%r14)
	movq	48(%r14), %rax
	cmpl	$0, (%rax)
	jle	LBB0_17
## %bb.13:
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
	jmp	LBB0_14
	.p2align	4, 0x90
LBB0_16:                                ##   in Loop: Header=BB0_14 Depth=1
	incq	%rbx
	movslq	(%rax), %rcx
	cmpq	%rcx, %rbx
	jge	LBB0_17
LBB0_14:                                ## =>This Inner Loop Header: Depth=1
	movq	8(%rax), %rcx
	movq	(%rcx,%rbx,8), %rcx
	cmpq	8(%r14), %rcx
	jne	LBB0_16
## %bb.15:                              ##   in Loop: Header=BB0_14 Depth=1
	movq	32(%rax), %rdi
	addq	%rbx, %rdi
	movq	16(%rax), %rcx
	movq	24(%rax), %rax
	movl	(%rcx,%rbx,4), %esi
	movl	(%rax,%rbx,4), %edx
	callq	_R_AddWorldSurface
	movq	48(%r14), %rax
	movq	16(%rax), %rcx
	movl	40(%r14), %r12d
	orl	(%rcx,%rbx,4), %r12d
	movl	%r12d, 40(%r14)
	jmp	LBB0_16
LBB0_17:
	notl	%r12d
	movl	%r12d, 40(%r14)
LBB0_18:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_r_drawworld,8,3                ## @r_drawworld
	.comm	_tr,72,3                        ## @tr
	.comm	_RDF_NOWORLDMODEL,4,2           ## @RDF_NOWORLDMODEL
	.comm	_REFENTITYNUM_WORLD,4,2         ## @REFENTITYNUM_WORLD
	.comm	_QSORT_REFENTITYNUM_SHIFT,4,2   ## @QSORT_REFENTITYNUM_SHIFT
	.comm	_VPF_DEPTHSHADOW,4,2            ## @VPF_DEPTHSHADOW
	.comm	_MAX_DLIGHTS,8,3                ## @MAX_DLIGHTS
	.comm	_MAX_DRAWN_PSHADOWS,8,3         ## @MAX_DRAWN_PSHADOWS
	.comm	_VPF_FARPLANEFRUSTUM,4,2        ## @VPF_FARPLANEFRUSTUM
	.comm	_VPF_SHADOWMAP,4,2              ## @VPF_SHADOWMAP
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_R_AddWorldSurfaces             ; -- Begin function R_AddWorldSurfaces
	.p2align	2
_R_AddWorldSurfaces:                    ; @R_AddWorldSurfaces
	.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
Lloh0:
	adrp	x8, _r_drawworld@GOTPAGE
Lloh1:
	ldr	x8, [x8, _r_drawworld@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	ldr	w8, [x8]
	cbz	w8, LBB0_20
; %bb.1:
Lloh3:
	adrp	x19, _tr@GOTPAGE
Lloh4:
	ldr	x19, [x19, _tr@GOTPAGEOFF]
	ldr	w8, [x19, #16]
Lloh5:
	adrp	x9, _RDF_NOWORLDMODEL@GOTPAGE
Lloh6:
	ldr	x9, [x9, _RDF_NOWORLDMODEL@GOTPAGEOFF]
Lloh7:
	ldr	w9, [x9]
	tst	w9, w8
	b.ne	LBB0_20
; %bb.2:
Lloh8:
	adrp	x8, _REFENTITYNUM_WORLD@GOTPAGE
Lloh9:
	ldr	x8, [x8, _REFENTITYNUM_WORLD@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
Lloh11:
	adrp	x9, _QSORT_REFENTITYNUM_SHIFT@GOTPAGE
Lloh12:
	ldr	x9, [x9, _QSORT_REFENTITYNUM_SHIFT@GOTPAGEOFF]
Lloh13:
	ldr	w9, [x9]
	lsl	w9, w8, w9
	stp	w8, w9, [x19]
	ldr	w8, [x19, #56]
Lloh14:
	adrp	x20, _VPF_DEPTHSHADOW@GOTPAGE
Lloh15:
	ldr	x20, [x20, _VPF_DEPTHSHADOW@GOTPAGEOFF]
	ldr	w9, [x20]
	tst	w9, w8
	b.ne	LBB0_4
; %bb.3:
	bl	_R_MarkLeaves
LBB0_4:
	ldr	x8, [x19, #64]
	ldp	w0, w1, [x8]
	bl	_ClearBounds
	ldr	x8, [x19, #24]
Lloh16:
	adrp	x9, _MAX_DLIGHTS@GOTPAGE
Lloh17:
	ldr	x9, [x9, _MAX_DLIGHTS@GOTPAGEOFF]
Lloh18:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ls	LBB0_6
; %bb.5:
	str	x9, [x19, #24]
	mov	x8, x9
LBB0_6:
	ldr	x9, [x19, #32]
Lloh19:
	adrp	x10, _MAX_DRAWN_PSHADOWS@GOTPAGE
Lloh20:
	ldr	x10, [x10, _MAX_DRAWN_PSHADOWS@GOTPAGEOFF]
Lloh21:
	ldr	x10, [x10]
	cmp	x9, x10
	b.ls	LBB0_8
; %bb.7:
	str	x10, [x19, #32]
	mov	x9, x10
LBB0_8:
	ldr	w10, [x19, #56]
Lloh22:
	adrp	x11, _VPF_FARPLANEFRUSTUM@GOTPAGE
Lloh23:
	ldr	x11, [x11, _VPF_FARPLANEFRUSTUM@GOTPAGEOFF]
Lloh24:
	ldr	w11, [x11]
	tst	w11, w10
	mov	w11, #31
	mov	w12, #15
	csel	w1, w12, w11, eq
	ldr	w11, [x20]
	tst	w11, w10
	b.eq	LBB0_10
; %bb.9:
	mov	w2, #0
	mov	w3, #0
	b	LBB0_13
LBB0_10:
Lloh25:
	adrp	x11, _VPF_SHADOWMAP@GOTPAGE
Lloh26:
	ldr	x11, [x11, _VPF_SHADOWMAP@GOTPAGEOFF]
Lloh27:
	ldr	w12, [x11]
	mov	x11, #-1
	lsl	x8, x11, x8
	mvn	w2, w8
	tst	w12, w10
	b.eq	LBB0_12
; %bb.11:
	mov	w3, #0
	b	LBB0_13
LBB0_12:
	lsl	x8, x11, x9
	mvn	w3, w8
LBB0_13:
	ldr	x8, [x19, #48]
	ldr	w0, [x8, #40]
	bl	_R_RecursiveWorldNode
	str	wzr, [x19, #40]
	ldr	x8, [x19, #48]
	ldr	w9, [x8]
	cmp	w9, #1
	b.lt	LBB0_18
; %bb.14:
	mov	w9, #0
	mov	x20, #0
	b	LBB0_16
LBB0_15:                                ;   in Loop: Header=BB0_16 Depth=1
	add	x20, x20, #1
	ldrsw	x10, [x8]
	cmp	x20, x10
	b.ge	LBB0_19
LBB0_16:                                ; =>This Inner Loop Header: Depth=1
	ldr	x10, [x8, #8]
	ldr	x10, [x10, x20, lsl #3]
	ldr	x11, [x19, #8]
	cmp	x10, x11
	b.ne	LBB0_15
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	x9, [x8, #32]
	add	x0, x20, x9
	lsl	x21, x20, #2
	ldp	x9, x8, [x8, #16]
	ldr	w1, [x9, x21]
	ldr	w2, [x8, x21]
	bl	_R_AddWorldSurface
	ldr	x8, [x19, #48]
	ldr	x9, [x8, #16]
	ldr	w9, [x9, x21]
	ldr	w10, [x19, #40]
	orr	w9, w10, w9
	str	w9, [x19, #40]
	b	LBB0_15
LBB0_18:
	mov	w9, #0
LBB0_19:
	mvn	w8, w9
	str	w8, [x19, #40]
LBB0_20:
	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 AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.comm	_r_drawworld,8,3                ; @r_drawworld
	.comm	_tr,72,3                        ; @tr
	.comm	_RDF_NOWORLDMODEL,4,2           ; @RDF_NOWORLDMODEL
	.comm	_REFENTITYNUM_WORLD,4,2         ; @REFENTITYNUM_WORLD
	.comm	_QSORT_REFENTITYNUM_SHIFT,4,2   ; @QSORT_REFENTITYNUM_SHIFT
	.comm	_VPF_DEPTHSHADOW,4,2            ; @VPF_DEPTHSHADOW
	.comm	_MAX_DLIGHTS,8,3                ; @MAX_DLIGHTS
	.comm	_MAX_DRAWN_PSHADOWS,8,3         ; @MAX_DRAWN_PSHADOWS
	.comm	_VPF_FARPLANEFRUSTUM,4,2        ; @VPF_FARPLANEFRUSTUM
	.comm	_VPF_SHADOWMAP,4,2              ; @VPF_SHADOWMAP
.subsections_via_symbols
