	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Terrain_AddTexture             ## -- Begin function Terrain_AddTexture
	.p2align	4, 0x90
_Terrain_AddTexture:                    ## @Terrain_AddTexture
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	testq	%rdi, %rdi
	je	LBB0_7
## %bb.1:
	movq	_numtextures@GOTPCREL(%rip), %r8
	movslq	(%r8), %rax
	movl	%eax, %edx
	testq	%rax, %rax
	jle	LBB0_5
## %bb.2:
	movq	_textures@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	xorl	%ecx, %ecx
	.p2align	4, 0x90
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	cmpq	%rdi, (%rsi,%rcx,8)
	je	LBB0_7
## %bb.3:                               ##   in Loop: Header=BB0_4 Depth=1
	incq	%rcx
	cmpq	%rcx, %rdx
	jne	LBB0_4
LBB0_5:
	movq	_MAX_TERRAIN_TEXTURES@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jge	LBB0_8
## %bb.6:
	movq	_textures@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	incl	%edx
	movl	%edx, (%r8)
	movq	%rdi, (%rcx,%rax,8)
LBB0_7:
	popq	%rbp
	retq
LBB0_8:
	leaq	L_.str(%rip), %rdi
	popq	%rbp
	jmp	_Error                          ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_numtextures,4,2                ## @numtextures
	.comm	_textures,8,3                   ## @textures
	.comm	_MAX_TERRAIN_TEXTURES,4,2       ## @MAX_TERRAIN_TEXTURES
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Too many textures on terrain"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Terrain_AddTexture             ; -- Begin function Terrain_AddTexture
	.p2align	2
_Terrain_AddTexture:                    ; @Terrain_AddTexture
	.cfi_startproc
; %bb.0:
	cbz	x0, LBB0_7
; %bb.1:
Lloh0:
	adrp	x8, _numtextures@GOTPAGE
Lloh1:
	ldr	x8, [x8, _numtextures@GOTPAGEOFF]
	ldr	w9, [x8]
	cmp	w9, #1
	b.lt	LBB0_5
; %bb.2:
Lloh2:
	adrp	x10, _textures@GOTPAGE
Lloh3:
	ldr	x10, [x10, _textures@GOTPAGEOFF]
Lloh4:
	ldr	x10, [x10]
	mov	x11, x9
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x12, [x10]
	cmp	x12, x0
	b.eq	LBB0_7
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	add	x10, x10, #8
	subs	x11, x11, #1
	b.ne	LBB0_3
LBB0_5:
	sxtw	x10, w9
Lloh5:
	adrp	x11, _MAX_TERRAIN_TEXTURES@GOTPAGE
Lloh6:
	ldr	x11, [x11, _MAX_TERRAIN_TEXTURES@GOTPAGEOFF]
Lloh7:
	ldr	w11, [x11]
	cmp	w10, w11
	b.ge	LBB0_8
; %bb.6:
Lloh8:
	adrp	x11, _textures@GOTPAGE
Lloh9:
	ldr	x11, [x11, _textures@GOTPAGEOFF]
Lloh10:
	ldr	x11, [x11]
	add	w9, w9, #1
	str	w9, [x8]
	str	x0, [x11, x10, lsl #3]
LBB0_7:
	ret
LBB0_8:
Lloh11:
	adrp	x0, l_.str@PAGE
Lloh12:
	add	x0, x0, l_.str@PAGEOFF
	b	_Error
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.comm	_numtextures,4,2                ; @numtextures
	.comm	_textures,8,3                   ; @textures
	.comm	_MAX_TERRAIN_TEXTURES,4,2       ; @MAX_TERRAIN_TEXTURES
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Too many textures on terrain"

.subsections_via_symbols
