	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_CreateTerrainSurface           ## -- Begin function CreateTerrainSurface
	.p2align	4, 0x90
_CreateTerrainSurface:                  ## @CreateTerrainSurface
	.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	$24, %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, %r15
	xorl	%eax, %eax
	callq	_AllocDrawSurf
	movq	%rax, %rbx
	movq	_qtrue@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 40(%rbx)
	movq	%r14, 32(%rbx)
	movq	$-1, (%rbx)
	movl	(%r15), %edi
	movl	%edi, 8(%rbx)
	movl	4(%r15), %eax
	movl	%eax, 12(%rbx)
	callq	_malloc
	movq	%rax, 24(%rbx)
	movl	(%r15), %edx
	movl	16(%r15), %esi
	movq	%rax, %rdi
	callq	_memcpy
	movl	4(%r15), %edi
	shll	$5, %edi
	callq	_malloc
	movq	%rax, 16(%rbx)
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	movl	4(%r15), %edx
	shll	$5, %edx
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	_memset
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	cmpl	$0, 12(%rbx)
	jle	LBB0_12
## %bb.1:
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movq	16(%rax), %r12
	xorl	%ecx, %ecx
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_2 Depth=1
	movl	8(%r12), %edi
	movl	%edi, %esi
	callq	_VectorNormalize
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	incq	%rcx
	addq	$32, %r12
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movslq	12(%rax), %rax
	cmpq	%rax, %rcx
	jge	LBB0_12
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_4 Depth 2
                                        ##       Child Loop BB0_6 Depth 3
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	8(%r14), %rax
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	leaq	(,%rcx,8), %rcx
	leaq	(%rcx,%rcx,2), %rbx
	movl	16(%rax,%rbx), %edi
	movl	24(%r12), %esi
	callq	_VectorCopy
	movq	8(%r14), %rax
	movq	8(%rax,%rbx), %rcx
	movl	(%rcx), %edx
	movq	16(%r12), %rsi
	movl	%edx, (%rsi)
	movl	4(%rcx), %ecx
	movl	%ecx, 4(%rsi)
	movq	(%r12), %rcx
	movabsq	$1095216660735, %rdx            ## imm = 0xFF000000FF
	movq	%rdx, (%rcx)
	movl	$255, 8(%rcx)
	movq	(%rax,%rbx), %rax
	movl	12(%rax), %eax
	movl	%eax, 12(%rcx)
	movl	8(%r12), %edi
	callq	_VectorClear
	movq	_numsurfaces@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	testl	%ecx, %ecx
	jle	LBB0_11
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	_surfaces@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	xorl	%r15d, %r15d
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_4 Depth=2
	movq	_numsurfaces@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=2
	incq	%r15
	movslq	%ecx, %rdx
	cmpq	%rdx, %r15
	jge	LBB0_11
LBB0_4:                                 ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Loop Header: Depth=2
                                        ##       Child Loop BB0_6 Depth 3
	movq	%r15, %r13
	shlq	$4, %r13
	cmpl	$0, (%rax,%r13)
	jle	LBB0_10
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=2
	movq	8(%rax,%r13), %rbx
	xorl	%r14d, %r14d
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_6 Depth=3
	incl	%r14d
	addq	$32, %rbx
	movq	_surfaces@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpl	(%rax,%r13), %r14d
	jge	LBB0_9
LBB0_6:                                 ##   Parent Loop BB0_2 Depth=1
                                        ##     Parent Loop BB0_4 Depth=2
                                        ## =>    This Inner Loop Header: Depth=3
	movq	_qfalse@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	_CompareVert
	testq	%rax, %rax
	je	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=3
	movl	8(%r12), %edi
	movl	8(%rbx), %esi
	movl	%edi, %edx
	callq	_VectorAdd
	jmp	LBB0_8
LBB0_12:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_qtrue,4,2                      ## @qtrue
	.comm	_numsurfaces,4,2                ## @numsurfaces
	.comm	_surfaces,8,3                   ## @surfaces
	.comm	_qfalse,4,2                     ## @qfalse
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_CreateTerrainSurface           ; -- Begin function CreateTerrainSurface
	.p2align	2
_CreateTerrainSurface:                  ; @CreateTerrainSurface
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	d9, d8, [sp, #16]               ; 16-byte Folded Spill
	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
	.cfi_offset b8, -104
	.cfi_offset b9, -112
	mov	x21, x1
	mov	x19, x0
	bl	_AllocDrawSurf
	mov	x20, x0
Lloh0:
	adrp	x8, _qtrue@GOTPAGE
Lloh1:
	ldr	x8, [x8, _qtrue@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	str	w8, [x0, #40]
	str	x21, [x0, #32]
	movi.2d	v0, #0xffffffffffffffff
	str	d0, [x0]
	ldr	d0, [x19]
	str	d0, [x0, #8]
	fmov	w0, s0
	bl	_malloc
	str	x0, [x20, #24]
	ldr	w1, [x19, #16]
	ldr	w2, [x19]
	bl	_memcpy
	ldr	w8, [x19, #4]
	lsl	w0, w8, #5
	bl	_malloc
	str	x0, [x20, #16]
	ldr	w8, [x19, #4]
	lsl	w2, w8, #5
	mov	w1, #0
	bl	_memset
	str	x20, [sp, #8]                   ; 8-byte Folded Spill
	ldr	w8, [x20, #12]
	cmp	w8, #1
	b.lt	LBB0_12
; %bb.1:
	mov	x23, #0
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	ldr	x21, [x8, #16]
	movi	d8, #0x0000ff000000ff
Lloh3:
	adrp	x25, _numsurfaces@GOTPAGE
Lloh4:
	ldr	x25, [x25, _numsurfaces@GOTPAGEOFF]
Lloh5:
	adrp	x26, _surfaces@GOTPAGE
Lloh6:
	ldr	x26, [x26, _surfaces@GOTPAGEOFF]
Lloh7:
	adrp	x27, _qfalse@GOTPAGE
Lloh8:
	ldr	x27, [x27, _qfalse@GOTPAGEOFF]
	b	LBB0_3
LBB0_2:                                 ;   in Loop: Header=BB0_3 Depth=1
	ldr	w0, [x21, #8]
	mov	x1, x0
	bl	_VectorNormalize
	add	x23, x23, #1
	add	x21, x21, #32
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	ldrsw	x8, [x8, #12]
	cmp	x23, x8
	b.ge	LBB0_12
LBB0_3:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_7 Depth 2
                                        ;       Child Loop BB0_10 Depth 3
	ldr	x8, [x19, #8]
	add	x9, x23, x23, lsl #1
	lsl	x20, x9, #3
	add	x8, x8, x20
	ldr	w0, [x8, #16]
	ldr	w1, [x21, #24]
	bl	_VectorCopy
	ldr	x8, [x19, #8]
	add	x8, x8, x20
	ldp	x8, x9, [x8]
	ldr	w10, [x9]
	ldr	x11, [x21, #16]
	str	w10, [x11]
	ldr	w9, [x9, #4]
	str	w9, [x11, #4]
	ldr	x9, [x21]
	str	d8, [x9]
	mov	w10, #255
	str	w10, [x9, #8]
	ldr	w8, [x8, #12]
	str	w8, [x9, #12]
	ldr	w0, [x21, #8]
	bl	_VectorClear
	ldr	w9, [x25]
	cmp	w9, #1
	b.lt	LBB0_2
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	mov	x28, #0
	ldr	x8, [x26]
	b	LBB0_7
LBB0_5:                                 ;   in Loop: Header=BB0_7 Depth=2
	ldr	w9, [x25]
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=2
	add	x28, x28, #1
	cmp	x28, w9, sxtw
	b.ge	LBB0_2
LBB0_7:                                 ;   Parent Loop BB0_3 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_10 Depth 3
	lsl	x24, x28, #4
	ldr	w10, [x8, x24]
	cmp	w10, #1
	b.lt	LBB0_6
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=2
	mov	w20, #0
	add	x8, x8, x28, lsl #4
	ldr	x22, [x8, #8]
	b	LBB0_10
LBB0_9:                                 ;   in Loop: Header=BB0_10 Depth=3
	add	w20, w20, #1
	add	x22, x22, #32
	ldr	x8, [x26]
	ldr	w9, [x8, x24]
	cmp	w20, w9
	b.ge	LBB0_5
LBB0_10:                                ;   Parent Loop BB0_3 Depth=1
                                        ;     Parent Loop BB0_7 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	ldr	w2, [x27]
	mov	x0, x21
	mov	x1, x22
	bl	_CompareVert
	cbz	x0, LBB0_9
; %bb.11:                               ;   in Loop: Header=BB0_10 Depth=3
	ldr	w0, [x21, #8]
	ldr	w1, [x22, #8]
	mov	x2, x0
	bl	_VectorAdd
	b	LBB0_9
LBB0_12:
	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
	ldp	d9, d8, [sp, #16]               ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.comm	_qtrue,4,2                      ; @qtrue
	.comm	_numsurfaces,4,2                ; @numsurfaces
	.comm	_surfaces,8,3                   ; @surfaces
	.comm	_qfalse,4,2                     ; @qfalse
.subsections_via_symbols
