	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_FindMiptex                     ## -- Begin function FindMiptex
	.p2align	4, 0x90
_FindMiptex:                            ## @FindMiptex
	.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	$1048, %rsp                     ## imm = 0x418
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	_nummiptex@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
	testl	%r12d, %r12d
	jle	LBB0_1
## %bb.2:
	movq	_textureref@GOTPCREL(%rip), %rax
	movq	(%rax), %rbx
	xorl	%r15d, %r15d
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%rbx), %rsi
	movq	%r14, %rdi
	callq	_strcmp
	testl	%eax, %eax
	je	LBB0_12
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	incq	%r15
	addq	$40, %rbx
	cmpq	%r15, %r12
	jne	LBB0_3
## %bb.5:
	movl	%r12d, %r15d
	jmp	LBB0_6
LBB0_1:
	xorl	%r15d, %r15d
LBB0_6:
	movq	_MAX_MAP_TEXTURES@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r12d
	jne	LBB0_8
## %bb.7:
	leaq	L_.str(%rip), %rdi
	callq	_Error
LBB0_8:
	movq	_textureref@GOTPCREL(%rip), %r12
	movq	(%r12), %rax
	movl	%r15d, %r13d
	leaq	(,%r13,4), %rcx
	addq	%r13, %rcx
	movq	%rcx, -1088(%rbp)               ## 8-byte Spill
	movq	(%rax,%rcx,8), %rdi
	movq	%r14, %rsi
	callq	_strcpy
	movq	_gamedir@GOTPCREL(%rip), %rax
	movq	(%rax), %rdx
	leaq	L_.str.1(%rip), %rsi
	leaq	-1072(%rbp), %rbx
	movq	%rbx, %rdi
	movq	%r14, %rcx
	callq	_sprintf
	leaq	-1080(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_TryLoadFile
	cmpl	$-1, %eax
	je	LBB0_10
## %bb.9:
	movq	-1080(%rbp), %rax
	movl	16(%rax), %edi
	callq	_LittleLong
	movq	(%r12), %rcx
	shlq	$3, %r13
	leaq	(,%r13,4), %rbx
	addq	%r13, %rbx
	movq	%rax, 32(%rcx,%rbx)
	movq	-1080(%rbp), %rax
	movl	12(%rax), %edi
	callq	_LittleLong
	movq	(%r12), %rcx
	movq	%rax, 24(%rcx,%rbx)
	movq	-1080(%rbp), %rax
	movl	8(%rax), %edi
	callq	_LittleLong
	movq	(%r12), %rcx
	movq	%rax, 16(%rcx,%rbx)
	movq	(%r12), %rax
	movq	8(%rax,%rbx), %rdi
	movq	-1080(%rbp), %rax
	movq	(%rax), %rsi
	callq	_strcpy
	movq	-1080(%rbp), %rdi
	callq	_FreeMemory
LBB0_10:
	movq	_nummiptex@GOTPCREL(%rip), %rax
	incl	(%rax)
	movq	(%r12), %rax
	movq	-1088(%rbp), %rcx               ## 8-byte Reload
	movq	8(%rax,%rcx,8), %rdi
	cmpb	$0, (%rdi)
	je	LBB0_12
## %bb.11:
	callq	_FindMiptex
LBB0_12:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_14
## %bb.13:
	movl	%r15d, %eax
	addq	$1048, %rsp                     ## imm = 0x418
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_14:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_nummiptex,4,2                  ## @nummiptex
	.comm	_textureref,8,3                 ## @textureref
	.comm	_MAX_MAP_TEXTURES,4,2           ## @MAX_MAP_TEXTURES
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"MAX_MAP_TEXTURES"

L_.str.1:                               ## @.str.1
	.asciz	"%stextures/%s.wal"

	.comm	_gamedir,8,3                    ## @gamedir
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_FindMiptex                     ; -- Begin function FindMiptex
	.p2align	2
_FindMiptex:                            ; @FindMiptex
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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 w27, -72
	.cfi_offset w28, -80
	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, #-72]
Lloh3:
	adrp	x21, _nummiptex@GOTPAGE
Lloh4:
	ldr	x21, [x21, _nummiptex@GOTPAGEOFF]
	ldr	w23, [x21]
Lloh5:
	adrp	x22, _textureref@GOTPAGE
Lloh6:
	ldr	x22, [x22, _textureref@GOTPAGEOFF]
	cmp	w23, #1
	b.lt	LBB0_5
; %bb.1:
	mov	x19, #0
	ldr	x24, [x22]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x1, [x24]
	mov	x0, x20
	bl	_strcmp
	cbz	w0, LBB0_12
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	add	x19, x19, #1
	add	x24, x24, #40
	cmp	x23, x19
	b.ne	LBB0_2
; %bb.4:
	mov	x19, x23
	b	LBB0_6
LBB0_5:
	mov	w19, #0
LBB0_6:
Lloh7:
	adrp	x8, _MAX_MAP_TEXTURES@GOTPAGE
Lloh8:
	ldr	x8, [x8, _MAX_MAP_TEXTURES@GOTPAGEOFF]
Lloh9:
	ldr	w8, [x8]
	cmp	w23, w8
	b.ne	LBB0_8
; %bb.7:
Lloh10:
	adrp	x0, l_.str@PAGE
Lloh11:
	add	x0, x0, l_.str@PAGEOFF
	bl	_Error
LBB0_8:
	ldr	x8, [x22]
	mov	w23, w19
	mov	w9, #40
	umull	x9, w19, w9
	ldr	x0, [x8, x9]
	mov	x1, x20
	bl	_strcpy
Lloh12:
	adrp	x8, _gamedir@GOTPAGE
Lloh13:
	ldr	x8, [x8, _gamedir@GOTPAGEOFF]
Lloh14:
	ldr	x2, [x8]
Lloh15:
	adrp	x1, l_.str.1@PAGE
Lloh16:
	add	x1, x1, l_.str.1@PAGEOFF
	add	x0, sp, #8
	mov	x3, x20
	bl	_sprintf
	add	x0, sp, #8
	mov	x1, sp
	bl	_TryLoadFile
	cmn	w0, #1
	b.eq	LBB0_10
; %bb.9:
	ldr	x8, [sp]
	ldr	w0, [x8, #16]
	bl	_LittleLong
	ldr	x8, [x22]
	add	x9, x23, x23, lsl #2
	lsl	x20, x9, #3
	add	x8, x8, x20
	str	x0, [x8, #32]
	ldr	x8, [sp]
	ldr	w0, [x8, #12]
	bl	_LittleLong
	ldr	x8, [x22]
	add	x8, x8, x20
	str	x0, [x8, #24]
	ldr	x8, [sp]
	ldr	w0, [x8, #8]
	bl	_LittleLong
	ldr	x8, [x22]
	add	x8, x8, x20
	str	x0, [x8, #16]
	ldr	x8, [x22]
	add	x8, x8, x20
	ldr	x0, [x8, #8]
	ldr	x8, [sp]
	ldr	x1, [x8]
	bl	_strcpy
	ldr	x0, [sp]
	bl	_FreeMemory
LBB0_10:
	ldr	w8, [x21]
	add	w8, w8, #1
	str	w8, [x21]
	ldr	x8, [x22]
	mov	w9, #40
	madd	x8, x23, x9, x8
	ldr	x0, [x8, #8]
	ldrb	w8, [x0]
	cbz	w8, LBB0_12
; %bb.11:
	bl	_FindMiptex
LBB0_12:
	ldur	x8, [x29, #-72]
Lloh17:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh18:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh19:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_14
; %bb.13:
	mov	x0, x19
	add	sp, sp, #1040
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #80             ; 16-byte Folded Reload
	ret
LBB0_14:
	bl	___stack_chk_fail
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_nummiptex,4,2                  ; @nummiptex
	.comm	_textureref,8,3                 ; @textureref
	.comm	_MAX_MAP_TEXTURES,4,2           ; @MAX_MAP_TEXTURES
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"MAX_MAP_TEXTURES"

l_.str.1:                               ; @.str.1
	.asciz	"%stextures/%s.wal"

	.comm	_gamedir,8,3                    ; @gamedir
.subsections_via_symbols
