	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_load_tga                       ## -- Begin function load_tga
	.p2align	4, 0x90
_load_tga:                              ## @load_tga
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %rbx
	leaq	L_.str(%rip), %rsi
	callq	_fopen
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r15
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_read_header
	testq	%rax, %rax
	jne	LBB0_11
## %bb.3:
	movq	(%rbx), %rax
	movq	_tga_type_true_color@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_11
## %bb.4:
	movl	16(%rbx), %r12d
	cmpl	$32, %r12d
	je	LBB0_6
## %bb.5:
	cmpl	$24, %r12d
	jne	LBB0_11
LBB0_6:
	shrl	$3, %r12d
	imull	20(%rbx), %r12d
	imull	24(%rbx), %r12d
	movl	%r12d, %edi
	callq	_malloc
	testq	%rax, %rax
	je	LBB0_11
## %bb.7:
	movq	%rax, %r14
	movq	8(%rbx), %rdx
	testq	%rdx, %rdx
	je	LBB0_9
## %bb.8:
	movq	_SEEK_CUR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_fseek
LBB0_9:
	movq	%r14, %rdi
	movl	$1, %esi
	movl	%r12d, %edx
	movq	%r15, %rcx
	callq	_fread
	cmpl	%r12d, %eax
	je	LBB0_12
## %bb.10:
	movq	%r14, %rdi
	callq	_free
LBB0_11:
	xorl	%r14d, %r14d
LBB0_12:
	movq	%r15, %rdi
	callq	_fclose
	jmp	LBB0_13
LBB0_1:
	xorl	%r14d, %r14d
LBB0_13:
	movq	%r14, %rax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"r"

	.comm	_tga_type_true_color,8,3        ## @tga_type_true_color
	.comm	_SEEK_CUR,4,2                   ## @SEEK_CUR
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_load_tga                       ; -- Begin function load_tga
	.p2align	2
_load_tga:                              ; @load_tga
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x21, x1
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fopen
	cbz	x0, LBB0_12
; %bb.1:
	mov	x19, x0
	mov	x1, x21
	bl	_read_header
	cbnz	x0, LBB0_10
; %bb.2:
	ldr	x8, [x21]
Lloh2:
	adrp	x9, _tga_type_true_color@GOTPAGE
Lloh3:
	ldr	x9, [x9, _tga_type_true_color@GOTPAGEOFF]
Lloh4:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_10
; %bb.3:
	ldr	w8, [x21, #16]
	cmp	w8, #32
	b.eq	LBB0_5
; %bb.4:
	cmp	w8, #24
	b.ne	LBB0_10
LBB0_5:
	ldp	w9, w10, [x21, #20]
	lsr	w8, w8, #3
	mul	w8, w9, w8
	mul	w22, w8, w10
	mov	x0, x22
	bl	_malloc
	mov	x20, x0
	cbz	x0, LBB0_11
; %bb.6:
	ldr	x2, [x21, #8]
	cbz	x2, LBB0_8
; %bb.7:
Lloh5:
	adrp	x8, _SEEK_CUR@GOTPAGE
Lloh6:
	ldr	x8, [x8, _SEEK_CUR@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_fseek
LBB0_8:
	mov	x0, x20
	mov	w1, #1
	mov	x2, x22
	mov	x3, x19
	bl	_fread
	cmp	w0, w22
	b.eq	LBB0_11
; %bb.9:
	mov	x0, x20
	bl	_free
LBB0_10:
	mov	x20, #0
LBB0_11:
	mov	x0, x19
	bl	_fclose
	b	LBB0_13
LBB0_12:
	mov	x20, #0
LBB0_13:
	mov	x0, x20
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"r"

	.comm	_tga_type_true_color,8,3        ; @tga_type_true_color
	.comm	_SEEK_CUR,4,2                   ; @SEEK_CUR
.subsections_via_symbols
