	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_WritePortalFile                ## -- Begin function WritePortalFile
	.p2align	4, 0x90
_WritePortalFile:                       ## @WritePortalFile
	.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	$1032, %rsp                     ## imm = 0x408
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_qprintf
	movq	(%rbx), %r14
	movq	_num_visclusters@GOTPCREL(%rip), %r12
	movl	$0, (%r12)
	movq	_num_visportals@GOTPCREL(%rip), %r15
	movl	$0, (%r15)
	movq	%r14, %rdi
	callq	_Tree_FreePortals_r
	movq	%rbx, %rdi
	callq	_MakeHeadnodePortals
	movq	%r14, %rdi
	callq	_CreateVisPortals_r
	movq	%r14, %rdi
	callq	_NumberLeafs_r
	movq	_source@GOTPCREL(%rip), %rax
	movq	(%rax), %rdx
	leaq	L_.str.1(%rip), %rsi
	leaq	-1072(%rbp), %rbx
	movq	%rbx, %rdi
	callq	_sprintf
	leaq	L_.str.2(%rip), %rdi
	movq	%rbx, %rsi
	callq	_printf
	leaq	L_.str.3(%rip), %rsi
	movq	%rbx, %rdi
	callq	_fopen
	movq	_pf@GOTPCREL(%rip), %r13
	movl	%eax, (%r13)
	testl	%eax, %eax
	jne	LBB0_2
## %bb.1:
	leaq	L_.str.4(%rip), %rdi
	leaq	-1072(%rbp), %rsi
	callq	_Error
	movl	(%r13), %eax
LBB0_2:
	movq	_PORTALFILE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rdx
	leaq	L_.str.5(%rip), %rsi
	movl	%eax, %edi
	xorl	%eax, %eax
	callq	_fprintf
	movl	(%r13), %edi
	movl	(%r12), %edx
	leaq	L_.str.6(%rip), %rbx
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	_fprintf
	movl	(%r13), %edi
	movl	(%r15), %edx
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	_fprintf
	movl	(%r12), %esi
	leaq	L_.str.7(%rip), %rdi
	xorl	%eax, %eax
	callq	_qprintf
	movl	(%r15), %esi
	leaq	L_.str.8(%rip), %rdi
	xorl	%eax, %eax
	callq	_qprintf
	movq	%r14, %rdi
	callq	_WritePortalFile_r
	movl	(%r13), %edi
	callq	_fclose
	movq	_clusterleaf@GOTPCREL(%rip), %rax
	movl	$1, (%rax)
	movq	%r14, %rdi
	callq	_SaveClusters_r
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_4
## %bb.3:
	addq	$1032, %rsp                     ## imm = 0x408
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"--- WritePortalFile ---\n"

	.comm	_num_visclusters,4,2            ## @num_visclusters
	.comm	_num_visportals,4,2             ## @num_visportals
L_.str.1:                               ## @.str.1
	.asciz	"%s.prt"

	.comm	_source,8,3                     ## @source
L_.str.2:                               ## @.str.2
	.asciz	"writing %s\n"

L_.str.3:                               ## @.str.3
	.asciz	"w"

	.comm	_pf,4,2                         ## @pf
L_.str.4:                               ## @.str.4
	.asciz	"Error opening %s"

L_.str.5:                               ## @.str.5
	.asciz	"%s\n"

	.comm	_PORTALFILE,8,3                 ## @PORTALFILE
L_.str.6:                               ## @.str.6
	.asciz	"%i\n"

L_.str.7:                               ## @.str.7
	.asciz	"%5i visclusters\n"

L_.str.8:                               ## @.str.8
	.asciz	"%5i visportals\n"

	.comm	_clusterleaf,4,2                ## @clusterleaf
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_WritePortalFile                ; -- Begin function WritePortalFile
	.p2align	2
_WritePortalFile:                       ; @WritePortalFile
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	sub	sp, sp, #1040
	mov	x20, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-56]
Lloh3:
	adrp	x0, l_.str@PAGE
Lloh4:
	add	x0, x0, l_.str@PAGEOFF
	bl	_qprintf
	ldr	x19, [x20]
Lloh5:
	adrp	x22, _num_visclusters@GOTPAGE
Lloh6:
	ldr	x22, [x22, _num_visclusters@GOTPAGEOFF]
	str	wzr, [x22]
Lloh7:
	adrp	x21, _num_visportals@GOTPAGE
Lloh8:
	ldr	x21, [x21, _num_visportals@GOTPAGEOFF]
	str	wzr, [x21]
	mov	x0, x19
	bl	_Tree_FreePortals_r
	mov	x0, x20
	bl	_MakeHeadnodePortals
	mov	x0, x19
	bl	_CreateVisPortals_r
	mov	x0, x19
	bl	_NumberLeafs_r
Lloh9:
	adrp	x8, _source@GOTPAGE
Lloh10:
	ldr	x8, [x8, _source@GOTPAGEOFF]
Lloh11:
	ldr	x2, [x8]
Lloh12:
	adrp	x1, l_.str.1@PAGE
Lloh13:
	add	x1, x1, l_.str.1@PAGEOFF
	add	x0, sp, #8
	bl	_sprintf
Lloh14:
	adrp	x0, l_.str.2@PAGE
Lloh15:
	add	x0, x0, l_.str.2@PAGEOFF
	add	x1, sp, #8
	bl	_printf
Lloh16:
	adrp	x1, l_.str.3@PAGE
Lloh17:
	add	x1, x1, l_.str.3@PAGEOFF
	add	x0, sp, #8
	bl	_fopen
Lloh18:
	adrp	x23, _pf@GOTPAGE
Lloh19:
	ldr	x23, [x23, _pf@GOTPAGEOFF]
	str	w0, [x23]
	cbnz	w0, LBB0_2
; %bb.1:
Lloh20:
	adrp	x0, l_.str.4@PAGE
Lloh21:
	add	x0, x0, l_.str.4@PAGEOFF
	add	x1, sp, #8
	bl	_Error
	ldr	w0, [x23]
LBB0_2:
Lloh22:
	adrp	x8, _PORTALFILE@GOTPAGE
Lloh23:
	ldr	x8, [x8, _PORTALFILE@GOTPAGEOFF]
Lloh24:
	ldr	x8, [x8]
	str	x8, [sp]
Lloh25:
	adrp	x1, l_.str.5@PAGE
Lloh26:
	add	x1, x1, l_.str.5@PAGEOFF
	bl	_fprintf
	ldr	w0, [x23]
	ldr	w8, [x22]
	str	x8, [sp]
Lloh27:
	adrp	x20, l_.str.6@PAGE
Lloh28:
	add	x20, x20, l_.str.6@PAGEOFF
	mov	x1, x20
	bl	_fprintf
	ldr	w0, [x23]
	ldr	w8, [x21]
	str	x8, [sp]
	mov	x1, x20
	bl	_fprintf
	ldr	w8, [x22]
	str	x8, [sp]
Lloh29:
	adrp	x0, l_.str.7@PAGE
Lloh30:
	add	x0, x0, l_.str.7@PAGEOFF
	bl	_qprintf
	ldr	w8, [x21]
	str	x8, [sp]
Lloh31:
	adrp	x0, l_.str.8@PAGE
Lloh32:
	add	x0, x0, l_.str.8@PAGEOFF
	bl	_qprintf
	mov	x0, x19
	bl	_WritePortalFile_r
	ldr	w0, [x23]
	bl	_fclose
Lloh33:
	adrp	x8, _clusterleaf@GOTPAGE
Lloh34:
	ldr	x8, [x8, _clusterleaf@GOTPAGEOFF]
	mov	w9, #1
Lloh35:
	str	w9, [x8]
	mov	x0, x19
	bl	_SaveClusters_r
	ldur	x8, [x29, #-56]
Lloh36:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh37:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh38:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_4
; %bb.3:
	add	sp, sp, #1040
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_4:
	bl	___stack_chk_fail
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpLdrGotStr	Lloh33, Lloh34, Lloh35
	.loh AdrpAdd	Lloh31, Lloh32
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"--- WritePortalFile ---\n"

	.comm	_num_visclusters,4,2            ; @num_visclusters
	.comm	_num_visportals,4,2             ; @num_visportals
l_.str.1:                               ; @.str.1
	.asciz	"%s.prt"

	.comm	_source,8,3                     ; @source
l_.str.2:                               ; @.str.2
	.asciz	"writing %s\n"

l_.str.3:                               ; @.str.3
	.asciz	"w"

	.comm	_pf,4,2                         ; @pf
l_.str.4:                               ; @.str.4
	.asciz	"Error opening %s"

l_.str.5:                               ; @.str.5
	.asciz	"%s\n"

	.comm	_PORTALFILE,8,3                 ; @PORTALFILE
l_.str.6:                               ; @.str.6
	.asciz	"%i\n"

l_.str.7:                               ; @.str.7
	.asciz	"%5i visclusters\n"

l_.str.8:                               ; @.str.8
	.asciz	"%5i visportals\n"

	.comm	_clusterleaf,4,2                ; @clusterleaf
.subsections_via_symbols
