	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_load_texture_from_dds          ## -- Begin function load_texture_from_dds
	.p2align	4, 0x90
_load_texture_from_dds:                 ## @load_texture_from_dds
	.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	$88, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
                                        ## kill: def $r8d killed $r8d def $r8
	movq	%r8, -112(%rbp)                 ## 8-byte Spill
                                        ## kill: def $ecx killed $ecx def $rcx
	movq	%rcx, -104(%rbp)                ## 8-byte Spill
	movq	%rdx, -96(%rbp)                 ## 8-byte Spill
	movq	%rsi, %rbx
	movq	%rdi, -72(%rbp)                 ## 8-byte Spill
	movq	%r9, -48(%rbp)                  ## 8-byte Spill
	movq	(%r9), %rsi
	movq	_D3DRTYPE_TEXTURE@GOTPCREL(%rip), %rax
	movq	_D3DRTYPE_VOLUMETEXTURE@GOTPCREL(%rip), %rcx
	cmpq	(%rax), %rsi
	je	LBB0_4
## %bb.1:
	movq	_D3DRTYPE_CUBETEXTURE@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rsi
	je	LBB0_4
## %bb.2:
	cmpq	(%rcx), %rsi
	je	LBB0_4
## %bb.3:
	leaq	L_.str(%rip), %rdi
	callq	_WARN
	movq	_D3DXERR_INVALIDDATA@GOTPCREL(%rip), %rax
	jmp	LBB0_11
LBB0_4:
	movq	-48(%rbp), %r13                 ## 8-byte Reload
	movl	8(%r13), %r15d
	movl	12(%r13), %r12d
	movl	20(%r13), %r14d
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	callq	_IDirect3DTexture9_GetLevelCount
	movl	%r14d, %edi
	movl	%eax, %esi
	callq	_min
	movq	(%r13), %rcx
	movq	_D3DRTYPE_VOLUMETEXTURE@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	movl	$1, %ecx
	cmovnel	%eax, %ecx
	movl	%ecx, -52(%rbp)                 ## 4-byte Spill
	addl	16(%rbp), %ecx
	movl	%ecx, -56(%rbp)                 ## 4-byte Spill
	je	LBB0_10
## %bb.5:
	addq	$4, %rbx
	movl	16(%rbp), %eax
                                        ## kill: def $eax killed $eax def $rax
	negl	%eax
	movq	%rax, -88(%rbp)                 ## 8-byte Spill
	xorl	%r13d, %r13d
	jmp	LBB0_6
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=1
	movl	-60(%rbp), %eax
	leaq	(%rbx,%rax,4), %rbx
	shrl	%r15d
	movl	$1, %edi
	movl	%r15d, %esi
	callq	_max
	movl	%eax, %r15d
	shrl	%r12d
	movl	$1, %edi
	movl	%r12d, %esi
	callq	_max
	movl	%eax, %r12d
	incl	%r13d
	cmpl	%r13d, -56(%rbp)                ## 4-byte Folded Reload
	je	LBB0_10
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	16(%rax), %edi
	movl	%r15d, %esi
	movl	%r12d, %edx
	leaq	-64(%rbp), %rcx
	leaq	-60(%rbp), %r8
	callq	_calculate_dds_surface_size
	movl	%eax, %r14d
	movl	%eax, %edi
	callq	_FAILED
	testq	%rax, %rax
	jne	LBB0_12
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	cmpl	16(%rbp), %r13d
	jb	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_6 Depth=1
	leaq	-116(%rbp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	movl	%r15d, %ecx
	movl	%r12d, %r8d
	callq	_SetRect
	movq	-88(%rbp), %rax                 ## 8-byte Reload
	leal	(%rax,%r13), %esi
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	leaq	-80(%rbp), %rdx
	callq	_IDirect3DTexture9_GetSurfaceLevel
	movq	-80(%rbp), %rdi
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	movl	16(%rax), %r8d
	movl	-64(%rbp), %r9d
	movq	-96(%rbp), %rsi                 ## 8-byte Reload
	xorl	%edx, %edx
	movq	%rbx, %rcx
	pushq	-112(%rbp)                      ## 8-byte Folded Reload
	pushq	-104(%rbp)                      ## 8-byte Folded Reload
	pushq	%r14
	pushq	$0
	callq	_D3DXLoadSurfaceFromMemory
	addq	$32, %rsp
	movl	%eax, %r14d
	movq	-80(%rbp), %rdi
	callq	_IDirect3DSurface9_Release
	movl	%r14d, %edi
	callq	_FAILED
	testq	%rax, %rax
	je	LBB0_9
	jmp	LBB0_12
LBB0_10:
	movq	24(%rbp), %rax
	movl	-52(%rbp), %ecx                 ## 4-byte Reload
	subl	16(%rbp), %ecx
	movl	%ecx, (%rax)
	movq	_D3D_OK@GOTPCREL(%rip), %rax
LBB0_11:
	movl	(%rax), %r14d
LBB0_12:
	movl	%r14d, %eax
	addq	$88, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_D3DRTYPE_TEXTURE,8,3           ## @D3DRTYPE_TEXTURE
	.comm	_D3DRTYPE_CUBETEXTURE,8,3       ## @D3DRTYPE_CUBETEXTURE
	.comm	_D3DRTYPE_VOLUMETEXTURE,8,3     ## @D3DRTYPE_VOLUMETEXTURE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Trying to load a %u resource as a 2D texture, returning failure.\n"

	.comm	_D3DXERR_INVALIDDATA,4,2        ## @D3DXERR_INVALIDDATA
	.comm	_D3D_OK,4,2                     ## @D3D_OK
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_load_texture_from_dds          ; -- Begin function load_texture_from_dds
	.p2align	2
_load_texture_from_dds:                 ; @load_texture_from_dds
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #160
	.cfi_def_cfa_offset 160
	stp	x28, x27, [sp, #64]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #80]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #96]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #112]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #128]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #144]            ; 16-byte Folded Spill
	add	x29, sp, #144
	.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
	stp	w3, w4, [sp, #32]               ; 8-byte Folded Spill
	str	x2, [sp, #24]                   ; 8-byte Folded Spill
	mov	x28, x1
	ldr	x1, [x5]
Lloh0:
	adrp	x8, _D3DRTYPE_TEXTURE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _D3DRTYPE_TEXTURE@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
Lloh3:
	adrp	x9, _D3DRTYPE_CUBETEXTURE@GOTPAGE
Lloh4:
	ldr	x9, [x9, _D3DRTYPE_CUBETEXTURE@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
Lloh6:
	adrp	x22, _D3DRTYPE_VOLUMETEXTURE@GOTPAGE
Lloh7:
	ldr	x22, [x22, _D3DRTYPE_VOLUMETEXTURE@GOTPAGEOFF]
	ldr	x10, [x22]
	cmp	x1, x8
	ccmp	x1, x9, #4, ne
	ccmp	x1, x10, #4, ne
	b.ne	LBB0_7
; %bb.1:
	mov	x20, x6
	mov	x21, x5
	mov	x25, x0
	str	x7, [sp, #16]                   ; 8-byte Folded Spill
	ldp	w26, w27, [x5, #8]
	ldr	w19, [x5, #20]
	bl	_IDirect3DTexture9_GetLevelCount
	mov	x1, x0
	mov	x0, x19
	bl	_min
	ldr	x8, [x21]
	ldr	x9, [x22]
	cmp	x8, x9
	csinc	w8, w0, wzr, ne
	str	w8, [sp, #12]                   ; 4-byte Folded Spill
	adds	w22, w8, w20
	b.eq	LBB0_8
; %bb.2:
	mov	w23, #0
	add	x28, x28, #4
	neg	w24, w20
	b	LBB0_4
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	w8, [sp, #52]
	add	x28, x28, x8, lsl #2
	lsr	w1, w26, #1
	mov	w0, #1
	bl	_max
	mov	x26, x0
	lsr	w1, w27, #1
	mov	w0, #1
	bl	_max
	mov	x27, x0
	add	w23, w23, #1
	cmp	w22, w23
	b.eq	LBB0_8
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x21, #16]
	add	x3, sp, #56
	add	x4, sp, #52
	mov	x1, x26
	mov	x2, x27
	bl	_calculate_dds_surface_size
	mov	x19, x0
	bl	_FAILED
	cbnz	x0, LBB0_10
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	cmp	w23, w20
	b.lo	LBB0_3
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	add	x0, sp, #60
	mov	w1, #0
	mov	w2, #0
	mov	x3, x26
	mov	x4, x27
	bl	_SetRect
	add	w1, w24, w23
	add	x2, sp, #40
	mov	x0, x25
	bl	_IDirect3DTexture9_GetSurfaceLevel
	ldr	x0, [sp, #40]
	ldr	w4, [x21, #16]
	ldr	w5, [sp, #56]
	ldr	w9, [sp, #36]                   ; 4-byte Folded Reload
	ldr	w8, [sp, #32]                   ; 4-byte Folded Reload
	stp	w8, w9, [sp]
	add	x7, sp, #60
	ldr	x1, [sp, #24]                   ; 8-byte Folded Reload
	mov	x2, #0
	mov	x3, x28
	mov	x6, #0
	bl	_D3DXLoadSurfaceFromMemory
	mov	x19, x0
	ldr	x0, [sp, #40]
	bl	_IDirect3DSurface9_Release
	mov	x0, x19
	bl	_FAILED
	cbz	x0, LBB0_3
	b	LBB0_10
LBB0_7:
Lloh8:
	adrp	x0, l_.str@PAGE
Lloh9:
	add	x0, x0, l_.str@PAGEOFF
	bl	_WARN
Lloh10:
	adrp	x8, _D3DXERR_INVALIDDATA@GOTPAGE
Lloh11:
	ldr	x8, [x8, _D3DXERR_INVALIDDATA@GOTPAGEOFF]
	b	LBB0_9
LBB0_8:
	ldr	w8, [sp, #12]                   ; 4-byte Folded Reload
	sub	w8, w8, w20
	ldr	x9, [sp, #16]                   ; 8-byte Folded Reload
	str	w8, [x9]
Lloh12:
	adrp	x8, _D3D_OK@GOTPAGE
Lloh13:
	ldr	x8, [x8, _D3D_OK@GOTPAGEOFF]
LBB0_9:
	ldr	w19, [x8]
LBB0_10:
	mov	x0, x19
	ldp	x29, x30, [sp, #144]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #128]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #112]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #96]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #80]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #160
	ret
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_D3DRTYPE_TEXTURE,8,3           ; @D3DRTYPE_TEXTURE
	.comm	_D3DRTYPE_CUBETEXTURE,8,3       ; @D3DRTYPE_CUBETEXTURE
	.comm	_D3DRTYPE_VOLUMETEXTURE,8,3     ; @D3DRTYPE_VOLUMETEXTURE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Trying to load a %u resource as a 2D texture, returning failure.\n"

	.comm	_D3DXERR_INVALIDDATA,4,2        ; @D3DXERR_INVALIDDATA
	.comm	_D3D_OK,4,2                     ; @D3D_OK
.subsections_via_symbols
