	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Q1_BSPBrushToMapBrush          ## -- Begin function Q1_BSPBrushToMapBrush
	.p2align	4, 0x90
_Q1_BSPBrushToMapBrush:                 ## @Q1_BSPBrushToMapBrush
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	callq	_CheckBSPBrush
	movq	_nummapbrushes@GOTPCREL(%rip), %r15
	movq	(%r15), %rax
	movq	_MAX_MAPFILE_BRUSHES@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jb	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rdi
	callq	_Error
	movq	(%r15), %rax
LBB0_2:
	movq	_mapbrushes@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	leaq	(%rax,%rax,4), %rdi
	movq	_brushsides@GOTPCREL(%rip), %r8
	movq	_nummapbrushsides@GOTPCREL(%rip), %r13
	movq	(%r13), %rcx
	shlq	$5, %rcx
	addq	(%r8), %rcx
	movq	%rcx, 16(%rsi,%rdi,8)
	movq	_entities@GOTPCREL(%rip), %rcx
	movslq	(%rcx), %rcx
	shlq	$4, %rcx
	movq	%r14, %rdx
	subq	%rcx, %rdx
	movq	%rdx, 32(%rsi,%rdi,8)
	subq	8(%r14), %rax
	movq	%rax, 24(%rsi,%rdi,8)
	movl	$4294967295, %eax               ## imm = 0xFFFFFFFF
	movq	%rax, (%rsi,%rdi,8)
	leaq	(%rsi,%rdi,8), %r11
	addq	$4, %r11
	movq	-56(%rbp), %r9                  ## 8-byte Reload
	movl	(%r9), %edx
	testl	%edx, %edx
	jle	LBB0_21
## %bb.3:
	movq	%r14, -88(%rbp)                 ## 8-byte Spill
	movq	%rsi, -80(%rbp)                 ## 8-byte Spill
	movq	%rdi, -72(%rbp)                 ## 8-byte Spill
	leaq	(%rsi,%rdi,8), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	_TEXINFO_NODE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	8(%r9), %rax
	xorl	%r14d, %r14d
	movq	_MAX_MAPFILE_BRUSHSIDES@GOTPCREL(%rip), %r15
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
	movq	%r11, -96(%rbp)                 ## 8-byte Spill
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_4 Depth=1
	incq	(%r13)
	movl	(%r11), %ecx
	incl	%ecx
	movl	%ecx, (%r11)
	movl	(%r9), %edx
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=1
	incq	%r12
	movslq	%edx, %rsi
	addq	$12, %r14
	cmpq	%rsi, %r12
	jge	LBB0_11
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	cmpl	$0, 8(%rax,%r14)
	je	LBB0_10
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	(%r13), %rcx
	cmpq	(%r15), %rcx
	jb	LBB0_7
## %bb.6:                               ##   in Loop: Header=BB0_4 Depth=1
	leaq	L_.str.1(%rip), %rdi
	movq	%r8, %r15
	callq	_Error
	movq	-96(%rbp), %r11                 ## 8-byte Reload
	movq	%r15, %r8
	movq	_MAX_MAPFILE_BRUSHSIDES@GOTPCREL(%rip), %r15
	movq	-56(%rbp), %r9                  ## 8-byte Reload
	movq	(%r13), %rcx
	movq	8(%r9), %rax
LBB0_7:                                 ##   in Loop: Header=BB0_4 Depth=1
	movq	(%r8), %rdx
	movl	4(%r9), %esi
	shlq	$5, %rcx
	movl	%esi, 24(%rdx,%rcx)
	movq	$0, 16(%rdx,%rcx)
	movl	4(%rax,%r14), %esi
	movl	%esi, 8(%rdx,%rcx)
	movl	(%rax,%r14), %esi
	movl	%esi, (%rdx,%rcx)
	cmpl	(%rbx), %esi
	je	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	_SFL_TEXTURED@GOTPCREL(%rip), %rdi
	movl	(%rdi), %edi
	orl	%edi, 4(%rdx,%rcx)
	movl	%esi, -44(%rbp)                 ## 4-byte Spill
	jmp	LBB0_9
LBB0_11:
	movl	(%rbx), %edx
	cmpl	%edx, -44(%rbp)                 ## 4-byte Folded Reload
	movq	-88(%rbp), %r14                 ## 8-byte Reload
	movq	_nummapbrushes@GOTPCREL(%rip), %r15
	movq	-80(%rbp), %r8                  ## 8-byte Reload
	movq	-72(%rbp), %r10                 ## 8-byte Reload
	jne	LBB0_12
LBB0_21:
	movl	$0, (%r11)
	movq	_q1_numclipbrushes@GOTPCREL(%rip), %rax
	incl	(%rax)
LBB0_20:
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	testl	%ecx, %ecx
	movq	-64(%rbp), %r12                 ## 8-byte Reload
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	jle	LBB0_18
## %bb.13:
	movq	16(%r12), %rax
	movl	%ecx, %ecx
	shlq	$5, %rcx
	addq	$-32, %rcx
	xorl	%esi, %esi
	cmpl	%edx, (%rax,%rsi)
	jne	LBB0_16
	.p2align	4, 0x90
LBB0_15:
	movl	%edi, (%rax,%rsi)
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	cmpq	%rsi, %rcx
	je	LBB0_18
## %bb.17:                              ##   in Loop: Header=BB0_16 Depth=1
	movl	(%rbx), %edx
	addq	$32, %rsi
	cmpl	%edx, (%rax,%rsi)
	je	LBB0_15
	jmp	LBB0_16
LBB0_18:
	movl	4(%r9), %eax
	movl	%eax, 8(%r8,%r10,8)
	movq	_create_aas@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_19
## %bb.22:
	movq	%r12, %rdi
	movq	%r14, %rsi
	movl	$1, %edx
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_AAS_CreateMapBrushes           ## TAILCALL
LBB0_19:
	movq	%r12, %rdi
	callq	_MakeBrushWindings
	movq	%r12, %rdi
	callq	_AddBrushBevels
	incq	(%r15)
	incl	(%r14)
	jmp	LBB0_20
	.cfi_endproc
                                        ## -- End function
	.comm	_nummapbrushes,8,3              ## @nummapbrushes
	.comm	_MAX_MAPFILE_BRUSHES,8,3        ## @MAX_MAPFILE_BRUSHES
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"nummapbrushes == MAX_MAPFILE_BRUSHES"

	.comm	_mapbrushes,8,3                 ## @mapbrushes
	.comm	_brushsides,8,3                 ## @brushsides
	.comm	_nummapbrushsides,8,3           ## @nummapbrushsides
	.comm	_entities,4,2                   ## @entities
	.comm	_TEXINFO_NODE,4,2               ## @TEXINFO_NODE
	.comm	_MAX_MAPFILE_BRUSHSIDES,8,3     ## @MAX_MAPFILE_BRUSHSIDES
L_.str.1:                               ## @.str.1
	.asciz	"MAX_MAPFILE_BRUSHSIDES"

	.comm	_SFL_TEXTURED,4,2               ## @SFL_TEXTURED
	.comm	_q1_numclipbrushes,4,2          ## @q1_numclipbrushes
	.comm	_create_aas,8,3                 ## @create_aas
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Q1_BSPBrushToMapBrush          ; -- Begin function Q1_BSPBrushToMapBrush
	.p2align	2
_Q1_BSPBrushToMapBrush:                 ; @Q1_BSPBrushToMapBrush
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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	x22, x1
	mov	x20, x0
	bl	_CheckBSPBrush
Lloh0:
	adrp	x19, _nummapbrushes@GOTPAGE
Lloh1:
	ldr	x19, [x19, _nummapbrushes@GOTPAGEOFF]
	ldr	x11, [x19]
Lloh2:
	adrp	x8, _MAX_MAPFILE_BRUSHES@GOTPAGE
Lloh3:
	ldr	x8, [x8, _MAX_MAPFILE_BRUSHES@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	cmp	x11, x8
	b.lo	LBB0_2
; %bb.1:
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	bl	_Error
	ldr	x11, [x19]
LBB0_2:
Lloh7:
	adrp	x8, _mapbrushes@GOTPAGE
Lloh8:
	ldr	x8, [x8, _mapbrushes@GOTPAGEOFF]
Lloh9:
	ldr	x12, [x8]
	mov	w8, #40
	madd	x21, x11, x8, x12
Lloh10:
	adrp	x23, _brushsides@GOTPAGE
Lloh11:
	ldr	x23, [x23, _brushsides@GOTPAGEOFF]
	ldr	x8, [x23]
Lloh12:
	adrp	x25, _nummapbrushsides@GOTPAGE
Lloh13:
	ldr	x25, [x25, _nummapbrushsides@GOTPAGEOFF]
	ldr	x9, [x25]
	add	x8, x8, x9, lsl #5
	mov	x9, x21
	str	x8, [x9, #16]!
	str	x9, [sp]                        ; 8-byte Folded Spill
Lloh14:
	adrp	x8, _entities@GOTPAGE
Lloh15:
	ldr	x8, [x8, _entities@GOTPAGEOFF]
Lloh16:
	ldrsw	x8, [x8]
	sub	x8, x22, x8, lsl #4
	ldr	x9, [x22, #8]
	sub	x9, x11, x9
	stp	x9, x8, [x21, #24]
	add	x19, x21, #4
	movi	d0, #0x000000ffffffff
	str	d0, [x21]
	ldr	w10, [x20]
	cmp	w10, #1
	b.lt	LBB0_12
; %bb.3:
	stp	x12, x11, [sp, #8]              ; 16-byte Folded Spill
	str	x22, [sp, #24]                  ; 8-byte Folded Spill
	mov	x28, #0
	mov	w9, #0
	mov	x24, #0
Lloh17:
	adrp	x26, _TEXINFO_NODE@GOTPAGE
Lloh18:
	ldr	x26, [x26, _TEXINFO_NODE@GOTPAGEOFF]
	ldr	w27, [x26]
	ldr	x8, [x20, #8]
Lloh19:
	adrp	x22, _MAX_MAPFILE_BRUSHSIDES@GOTPAGE
Lloh20:
	ldr	x22, [x22, _MAX_MAPFILE_BRUSHSIDES@GOTPAGEOFF]
	b	LBB0_6
LBB0_4:                                 ;   in Loop: Header=BB0_6 Depth=1
	ldr	x9, [x25]
	add	x9, x9, #1
	str	x9, [x25]
	ldr	w9, [x19]
	add	w9, w9, #1
	str	w9, [x19]
	ldr	w10, [x20]
LBB0_5:                                 ;   in Loop: Header=BB0_6 Depth=1
	add	x24, x24, #1
	add	x28, x28, #12
	cmp	x24, w10, sxtw
	b.ge	LBB0_11
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	add	x11, x8, x28
	ldr	w11, [x11, #8]
	cbz	w11, LBB0_5
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=1
	ldr	x9, [x25]
	ldr	x10, [x22]
	cmp	x9, x10
	b.lo	LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_6 Depth=1
Lloh21:
	adrp	x0, l_.str.1@PAGE
Lloh22:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_Error
	ldr	x9, [x25]
	ldr	x8, [x20, #8]
LBB0_9:                                 ;   in Loop: Header=BB0_6 Depth=1
	ldr	x10, [x23]
	ldr	w11, [x20, #4]
	add	x9, x10, x9, lsl #5
	str	w11, [x9, #24]
	str	xzr, [x9, #16]
	add	x10, x8, x28
	ldp	w10, w11, [x10]
	str	w11, [x9, #8]
	str	w10, [x9]
	ldr	w11, [x26]
	cmp	w10, w11
	b.eq	LBB0_4
; %bb.10:                               ;   in Loop: Header=BB0_6 Depth=1
Lloh23:
	adrp	x11, _SFL_TEXTURED@GOTPAGE
Lloh24:
	ldr	x11, [x11, _SFL_TEXTURED@GOTPAGEOFF]
Lloh25:
	ldr	w11, [x11]
	ldr	w12, [x9, #4]
	orr	w11, w12, w11
	str	w11, [x9, #4]
	mov	x27, x10
	b	LBB0_4
LBB0_11:
	ldr	w8, [x26]
	cmp	w27, w8
	ldp	x12, x22, [sp, #16]             ; 16-byte Folded Reload
	ldr	x13, [sp, #8]                   ; 8-byte Folded Reload
	b.ne	LBB0_14
LBB0_12:
	str	wzr, [x19]
Lloh26:
	adrp	x8, _q1_numclipbrushes@GOTPAGE
Lloh27:
	ldr	x8, [x8, _q1_numclipbrushes@GOTPAGEOFF]
	ldr	w9, [x8]
	add	w9, w9, #1
	str	w9, [x8]
LBB0_13:
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_14:
	cmp	w9, #1
	b.lt	LBB0_20
; %bb.15:
	ldr	x10, [sp]                       ; 8-byte Folded Reload
	ldr	x10, [x10]
	mov	w9, w9
LBB0_16:                                ; =>This Inner Loop Header: Depth=1
	sub	x9, x9, #1
	ldr	w11, [x10]
	cmp	w11, w8
	b.ne	LBB0_18
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=1
	str	w27, [x10]
LBB0_18:                                ;   in Loop: Header=BB0_16 Depth=1
	cbz	x9, LBB0_20
; %bb.19:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	w8, [x26]
	add	x10, x10, #32
	b	LBB0_16
LBB0_20:
	ldr	w8, [x20, #4]
	mov	w9, #40
	madd	x9, x12, x9, x13
	str	w8, [x9, #8]
Lloh28:
	adrp	x8, _create_aas@GOTPAGE
Lloh29:
	ldr	x8, [x8, _create_aas@GOTPAGEOFF]
Lloh30:
	ldr	x8, [x8]
	cbz	x8, LBB0_22
; %bb.21:
	mov	x0, x21
	mov	x1, x22
	mov	w2, #1
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	b	_AAS_CreateMapBrushes
LBB0_22:
	mov	x0, x21
	bl	_MakeBrushWindings
	mov	x0, x21
	bl	_AddBrushBevels
Lloh31:
	adrp	x9, _nummapbrushes@GOTPAGE
Lloh32:
	ldr	x9, [x9, _nummapbrushes@GOTPAGEOFF]
	ldr	x8, [x9]
	add	x8, x8, #1
	str	x8, [x9]
	ldr	w8, [x22]
	add	w8, w8, #1
	str	w8, [x22]
	b	LBB0_13
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh31, Lloh32
	.cfi_endproc
                                        ; -- End function
	.comm	_nummapbrushes,8,3              ; @nummapbrushes
	.comm	_MAX_MAPFILE_BRUSHES,8,3        ; @MAX_MAPFILE_BRUSHES
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"nummapbrushes == MAX_MAPFILE_BRUSHES"

	.comm	_mapbrushes,8,3                 ; @mapbrushes
	.comm	_brushsides,8,3                 ; @brushsides
	.comm	_nummapbrushsides,8,3           ; @nummapbrushsides
	.comm	_entities,4,2                   ; @entities
	.comm	_TEXINFO_NODE,4,2               ; @TEXINFO_NODE
	.comm	_MAX_MAPFILE_BRUSHSIDES,8,3     ; @MAX_MAPFILE_BRUSHSIDES
l_.str.1:                               ; @.str.1
	.asciz	"MAX_MAPFILE_BRUSHSIDES"

	.comm	_SFL_TEXTURED,4,2               ; @SFL_TEXTURED
	.comm	_q1_numclipbrushes,4,2          ; @q1_numclipbrushes
	.comm	_create_aas,8,3                 ; @create_aas
.subsections_via_symbols
