	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_CountLightmaps                 ## -- Begin function CountLightmaps
	.p2align	4, 0x90
_CountLightmaps:                        ## @CountLightmaps
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_qprintf
	movq	_numDrawSurfaces@GOTPCREL(%rip), %r14
	movl	(%r14), %esi
	testl	%esi, %esi
	jle	LBB0_1
## %bb.2:
	movq	_drawSurfaces@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpl	$8, %esi
	jae	LBB0_4
## %bb.3:
	xorl	%ecx, %ecx
	jmp	LBB0_12
LBB0_1:
	movl	$1, %ebx
	jmp	LBB0_14
LBB0_4:
	movl	%esi, %ecx
	andl	$-8, %ecx
	leaq	-8(%rcx), %rdi
	movq	%rdi, %rdx
	shrq	$3, %rdx
	incq	%rdx
	movl	%edx, %ebx
	andl	$3, %ebx
	cmpq	$24, %rdi
	jae	LBB0_6
## %bb.5:
	pxor	%xmm0, %xmm0
	xorl	%edi, %edi
	pxor	%xmm1, %xmm1
	jmp	LBB0_8
LBB0_6:
	andq	$-4, %rdx
	pxor	%xmm0, %xmm0
	xorl	%edi, %edi
	pxor	%xmm1, %xmm1
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	movdqu	(%rax,%rdi,4), %xmm2
	pmaxsd	%xmm0, %xmm2
	movdqu	16(%rax,%rdi,4), %xmm0
	pmaxsd	%xmm1, %xmm0
	movdqu	32(%rax,%rdi,4), %xmm1
	movdqu	48(%rax,%rdi,4), %xmm3
	movdqu	64(%rax,%rdi,4), %xmm4
	pmaxsd	%xmm1, %xmm4
	pmaxsd	%xmm2, %xmm4
	movdqu	80(%rax,%rdi,4), %xmm2
	pmaxsd	%xmm3, %xmm2
	pmaxsd	%xmm0, %xmm2
	movdqu	96(%rax,%rdi,4), %xmm0
	pmaxsd	%xmm4, %xmm0
	movdqu	112(%rax,%rdi,4), %xmm1
	pmaxsd	%xmm2, %xmm1
	addq	$32, %rdi
	addq	$-4, %rdx
	jne	LBB0_7
LBB0_8:
	testq	%rbx, %rbx
	je	LBB0_11
## %bb.9:
	leaq	(%rax,%rdi,4), %rdx
	addq	$16, %rdx
	shlq	$5, %rbx
	xorl	%edi, %edi
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movdqu	-16(%rdx,%rdi), %xmm2
	pmaxsd	%xmm2, %xmm0
	movdqu	(%rdx,%rdi), %xmm2
	pmaxsd	%xmm2, %xmm1
	addq	$32, %rdi
	cmpq	%rdi, %rbx
	jne	LBB0_10
LBB0_11:
	pmaxsd	%xmm1, %xmm0
	pshufd	$238, %xmm0, %xmm1              ## xmm1 = xmm0[2,3,2,3]
	pmaxsd	%xmm0, %xmm1
	pshufd	$85, %xmm1, %xmm0               ## xmm0 = xmm1[1,1,1,1]
	pmaxsd	%xmm1, %xmm0
	movd	%xmm0, %ebx
	cmpq	%rsi, %rcx
	je	LBB0_13
	.p2align	4, 0x90
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movl	(%rax,%rcx,4), %edx
	cmpl	%ebx, %edx
	cmovgl	%edx, %ebx
	incq	%rcx
	cmpq	%rcx, %rsi
	jne	LBB0_12
LBB0_13:
	incl	%ebx
LBB0_14:
	movq	_LIGHTMAP_WIDTH@GOTPCREL(%rip), %rax
	movq	_LIGHTMAP_HEIGHT@GOTPCREL(%rip), %rcx
	movl	(%rax), %eax
	imull	%ebx, %eax
	imull	(%rcx), %eax
	leal	(%rax,%rax,2), %eax
	movq	_numLightBytes@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	movq	_MAX_MAP_LIGHTING@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jle	LBB0_16
## %bb.15:
	leaq	L_.str.1(%rip), %rdi
	callq	_Error
	movl	(%r14), %esi
LBB0_16:
	leaq	L_.str.2(%rip), %rdi
                                        ## kill: def $esi killed $esi killed $rsi
	xorl	%eax, %eax
	callq	_qprintf
	leaq	L_.str.3(%rip), %rdi
	movl	%ebx, %esi
	xorl	%eax, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_qprintf                        ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"--- CountLightmaps ---\n"

	.comm	_numDrawSurfaces,4,2            ## @numDrawSurfaces
	.comm	_drawSurfaces,8,3               ## @drawSurfaces
	.comm	_LIGHTMAP_WIDTH,4,2             ## @LIGHTMAP_WIDTH
	.comm	_LIGHTMAP_HEIGHT,4,2            ## @LIGHTMAP_HEIGHT
	.comm	_numLightBytes,4,2              ## @numLightBytes
	.comm	_MAX_MAP_LIGHTING,4,2           ## @MAX_MAP_LIGHTING
L_.str.1:                               ## @.str.1
	.asciz	"MAX_MAP_LIGHTING exceeded"

L_.str.2:                               ## @.str.2
	.asciz	"%5i drawSurfaces\n"

L_.str.3:                               ## @.str.3
	.asciz	"%5i lightmaps\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_CountLightmaps                 ; -- Begin function CountLightmaps
	.p2align	2
_CountLightmaps:                        ; @CountLightmaps
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.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
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_qprintf
Lloh2:
	adrp	x19, _numDrawSurfaces@GOTPAGE
Lloh3:
	ldr	x19, [x19, _numDrawSurfaces@GOTPAGEOFF]
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_3
; %bb.1:
Lloh4:
	adrp	x9, _drawSurfaces@GOTPAGE
Lloh5:
	ldr	x9, [x9, _drawSurfaces@GOTPAGEOFF]
Lloh6:
	ldr	x9, [x9]
	cmp	w8, #16
	b.hs	LBB0_4
; %bb.2:
	mov	x10, #0
	mov	w11, #0
	b	LBB0_7
LBB0_3:
	mov	w20, #1
	b	LBB0_10
LBB0_4:
	and	x10, x8, #0xfffffff0
	add	x11, x9, #32
	movi.2d	v0, #0000000000000000
	mov	x12, x10
	movi.2d	v1, #0000000000000000
	movi.2d	v2, #0000000000000000
	movi.2d	v3, #0000000000000000
LBB0_5:                                 ; =>This Inner Loop Header: Depth=1
	ldp	q4, q5, [x11, #-32]
	ldp	q6, q7, [x11], #64
	smax.4s	v0, v4, v0
	smax.4s	v1, v5, v1
	smax.4s	v2, v6, v2
	smax.4s	v3, v7, v3
	subs	x12, x12, #16
	b.ne	LBB0_5
; %bb.6:
	smax.4s	v0, v0, v1
	smax.4s	v0, v0, v2
	smax.4s	v0, v0, v3
	smaxv.4s	s0, v0
	fmov	w11, s0
	cmp	x10, x8
	b.eq	LBB0_9
LBB0_7:
	add	x9, x9, x10, lsl #2
	sub	x10, x8, x10
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w12, [x9], #4
	cmp	w12, w11
	csel	w11, w12, w11, gt
	subs	x10, x10, #1
	b.ne	LBB0_8
LBB0_9:
	add	w20, w11, #1
LBB0_10:
Lloh7:
	adrp	x9, _LIGHTMAP_WIDTH@GOTPAGE
Lloh8:
	ldr	x9, [x9, _LIGHTMAP_WIDTH@GOTPAGEOFF]
Lloh9:
	adrp	x10, _LIGHTMAP_HEIGHT@GOTPAGE
Lloh10:
	ldr	x10, [x10, _LIGHTMAP_HEIGHT@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
Lloh12:
	ldr	w10, [x10]
	mul	w9, w20, w9
	mul	w9, w9, w10
Lloh13:
	adrp	x10, _numLightBytes@GOTPAGE
Lloh14:
	ldr	x10, [x10, _numLightBytes@GOTPAGEOFF]
	add	w9, w9, w9, lsl #1
Lloh15:
	str	w9, [x10]
Lloh16:
	adrp	x10, _MAX_MAP_LIGHTING@GOTPAGE
Lloh17:
	ldr	x10, [x10, _MAX_MAP_LIGHTING@GOTPAGEOFF]
Lloh18:
	ldr	w10, [x10]
	cmp	w9, w10
	b.le	LBB0_12
; %bb.11:
Lloh19:
	adrp	x0, l_.str.1@PAGE
Lloh20:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_Error
	ldr	w8, [x19]
LBB0_12:
                                        ; kill: def $w8 killed $w8 killed $x8 def $x8
	str	x8, [sp]
Lloh21:
	adrp	x0, l_.str.2@PAGE
Lloh22:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_qprintf
	str	x20, [sp]
Lloh23:
	adrp	x0, l_.str.3@PAGE
Lloh24:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_qprintf
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotStr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh11
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"--- CountLightmaps ---\n"

	.comm	_numDrawSurfaces,4,2            ; @numDrawSurfaces
	.comm	_drawSurfaces,8,3               ; @drawSurfaces
	.comm	_LIGHTMAP_WIDTH,4,2             ; @LIGHTMAP_WIDTH
	.comm	_LIGHTMAP_HEIGHT,4,2            ; @LIGHTMAP_HEIGHT
	.comm	_numLightBytes,4,2              ; @numLightBytes
	.comm	_MAX_MAP_LIGHTING,4,2           ; @MAX_MAP_LIGHTING
l_.str.1:                               ; @.str.1
	.asciz	"MAX_MAP_LIGHTING exceeded"

l_.str.2:                               ; @.str.2
	.asciz	"%5i drawSurfaces\n"

l_.str.3:                               ; @.str.3
	.asciz	"%5i lightmaps\n"

.subsections_via_symbols
