	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal8,8byte_literals
	.p2align	3                               ## -- Begin function audio_mix_load_wav_file
LCPI0_0:
	.quad	0x4010000000000000              ## double 4
LCPI0_1:
	.quad	0x3ff0000000000000              ## double 1
	.section	__TEXT,__text,regular,pure_instructions
	.globl	_audio_mix_load_wav_file
	.p2align	4, 0x90
_audio_mix_load_wav_file:               ## @audio_mix_load_wav_file
	.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	%rbx
	subq	$56, %rsp
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r14d
	movq	%rdi, %rbx
	movl	$0, -28(%rbp)
	movq	$0, -40(%rbp)
	movl	$1, %edi
	movl	$104, %esi
	callq	_calloc
	testq	%rax, %rax
	je	LBB0_28
## %bb.1:
	movq	%rax, %r15
	leaq	-40(%rbp), %rsi
	leaq	-28(%rbp), %rdx
	movq	%rbx, %rdi
	callq	_filestream_read_file
	testl	%eax, %eax
	je	LBB0_2
## %bb.3:
	movl	%r14d, (%r15)
	movq	-40(%rbp), %rax
	movq	%rax, 96(%r15)
	movl	-28(%rbp), %eax
	movl	%eax, 88(%r15)
	movl	$40, %edi
	callq	_malloc
	movq	%rax, 80(%r15)
	movq	96(%r15), %rsi
	movl	88(%r15), %edx
	movq	%rax, %rdi
	callq	_rwav_load
	movq	_RWAV_ITERATE_ERROR@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_5
## %bb.4:
	leaq	L_str.3(%rip), %rdi
	callq	_puts
	jmp	LBB0_27
LBB0_2:
	leaq	L_str(%rip), %rdi
	callq	_puts
	jmp	LBB0_27
LBB0_5:
	movq	80(%r15), %rax
	movl	(%rax), %esi
	shll	$4, %esi
	movl	$128, %edi
	callq	_memalign_alloc
	movq	%rax, 8(%r15)
	movq	80(%r15), %rcx
	movl	4(%rcx), %edx
	movl	%edx, %esi
	andl	$-8, %esi
	cmpl	$16, %esi
	je	LBB0_15
## %bb.6:
	cmpl	$8, %esi
	jne	LBB0_26
## %bb.7:
	cmpl	$0, (%rcx)
	je	LBB0_22
## %bb.8:
	movl	$1, %r8d
	xorl	%esi, %esi
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movq	32(%rcx), %rdi
	movl	8(%rcx), %ecx
	imull	%esi, %ecx
	movl	(%rdi,%rcx,4), %ebx
	shll	$8, %ebx
	addl	$-32768, %ebx                   ## imm = 0x8000
	movslq	%ebx, %rbx
	leal	-1(%r8), %edx
	movq	%rbx, (%rax,%rdx,8)
	movq	80(%r15), %rax
	movl	8(%rax), %eax
	cmpl	$1, %eax
	je	LBB0_12
## %bb.10:                              ##   in Loop: Header=BB0_9 Depth=1
	cmpl	$2, %eax
	jne	LBB0_13
## %bb.11:                              ##   in Loop: Header=BB0_9 Depth=1
	movl	4(%rdi,%rcx,4), %eax
	shll	$8, %eax
	addl	$-32768, %eax                   ## imm = 0x8000
	movslq	%eax, %rbx
LBB0_12:                                ##   in Loop: Header=BB0_9 Depth=1
	movq	8(%r15), %rax
	movl	%r8d, %ecx
	movq	%rbx, (%rax,%rcx,8)
LBB0_13:                                ##   in Loop: Header=BB0_9 Depth=1
	incq	%rsi
	movq	80(%r15), %rcx
	movl	(%rcx), %eax
	cmpq	%rax, %rsi
	jae	LBB0_22
## %bb.14:                              ##   in Loop: Header=BB0_9 Depth=1
	movq	8(%r15), %rax
	addl	$2, %r8d
	jmp	LBB0_9
LBB0_15:
	movl	8(%rcx), %edx
	cmpl	$2, %edx
	je	LBB0_21
## %bb.16:
	cmpl	$1, %edx
	jne	LBB0_22
## %bb.17:
	cmpl	$0, (%rcx)
	je	LBB0_22
## %bb.18:
	movq	32(%rcx), %rcx
	movq	(%rcx), %rcx
	movq	%rcx, (%rax)
	movq	8(%r15), %rax
	movq	%rcx, 8(%rax)
	movq	80(%r15), %rcx
	cmpl	$2, (%rcx)
	jb	LBB0_22
## %bb.19:
	movl	$1, %eax
	movl	$3, %edx
	.p2align	4, 0x90
LBB0_20:                                ## =>This Inner Loop Header: Depth=1
	movq	8(%r15), %rsi
	movq	32(%rcx), %rcx
	movq	(%rcx,%rax,8), %rcx
	leal	-1(%rdx), %edi
	movq	%rcx, (%rsi,%rdi,8)
	movq	8(%r15), %rsi
	movl	%edx, %edi
	movq	%rcx, (%rsi,%rdi,8)
	incq	%rax
	movq	80(%r15), %rcx
	movl	(%rcx), %esi
	addl	$2, %edx
	cmpq	%rsi, %rax
	jb	LBB0_20
	jmp	LBB0_22
LBB0_26:
	leal	7(%rdx), %esi
	testl	%edx, %edx
	cmovnsl	%edx, %esi
	sarl	$3, %esi
	leaq	L_.str.2(%rip), %rdi
	xorl	%eax, %eax
	callq	_printf
LBB0_27:
	movq	%r15, %rdi
	callq	_audio_mix_free_chunk
LBB0_28:
	xorl	%r15d, %r15d
LBB0_29:
	movq	%r15, %rax
	addq	$56, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_21:
	movq	32(%rcx), %rsi
	movl	24(%rcx), %edx
	movq	%rax, %rdi
	callq	_memcpy
	movq	80(%r15), %rcx
LBB0_22:
	movsd	16(%rcx), %xmm1                 ## xmm1 = mem[0],zero
	cvttsd2si	%xmm1, %eax
	cmpl	%r14d, %eax
	je	LBB0_29
## %bb.23:
	movl	$1, 16(%r15)
	cvtsi2sd	%r14d, %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, 24(%r15)
	leaq	64(%r15), %rdi
	movq	%r15, %rsi
	addq	$72, %rsi
	movq	_RESAMPLER_QUALITY_DONTCARE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	xorl	%edx, %edx
	callq	_retro_resampler_realloc
	cmpq	$0, 72(%r15)
	je	LBB0_29
## %bb.24:
	cmpq	$0, 64(%r15)
	je	LBB0_29
## %bb.25:
	movq	80(%r15), %rax
	movl	(%rax), %eax
	addl	%eax, %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	24(%r15), %xmm0
	mulsd	LCPI0_0(%rip), %xmm0
	cvttsd2si	%xmm0, %esi
	movl	$128, %edi
	callq	_memalign_alloc
	movq	%rax, 32(%r15)
	movq	80(%r15), %rax
	movl	(%rax), %eax
	leal	(%rax,%rax,2), %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%eax, %xmm0
	mulsd	24(%r15), %xmm0
	mulsd	LCPI0_0(%rip), %xmm0
	cvttsd2si	%xmm0, %esi
	movl	$128, %edi
	callq	_memalign_alloc
	movq	%rax, 40(%r15)
	movq	8(%r15), %rsi
	movq	32(%r15), %rdi
	movq	80(%r15), %rax
	movl	(%rax), %edx
	addl	%edx, %edx
	movsd	LCPI0_1(%rip), %xmm0            ## xmm0 = mem[0],zero
	callq	_convert_s16_to_float
	movupd	32(%r15), %xmm0
	movapd	%xmm0, -80(%rbp)
	movq	80(%r15), %rax
	movl	(%rax), %eax
	movl	%eax, -64(%rbp)
	movl	$0, -60(%rbp)
	cvttsd2si	24(%r15), %eax
	movl	%eax, -56(%rbp)
	movq	64(%r15), %rdi
	movq	72(%r15), %rax
	leaq	-80(%rbp), %rsi
	callq	*(%rax)
	movl	-60(%rbp), %esi
	shll	$4, %esi
	movl	$128, %edi
	callq	_memalign_alloc
	movq	%rax, 48(%r15)
	movl	-60(%rbp), %edx
	movl	%edx, 56(%r15)
	movq	40(%r15), %rsi
	addl	%edx, %edx
	movq	%rax, %rdi
	callq	_convert_float_to_s16
	jmp	LBB0_29
	.cfi_endproc
                                        ## -- End function
	.comm	_RWAV_ITERATE_ERROR,8,3         ## @RWAV_ITERATE_ERROR
	.section	__TEXT,__cstring,cstring_literals
L_.str.2:                               ## @.str.2
	.asciz	"error: we don't support a sample size of %d\n"

	.comm	_RESAMPLER_QUALITY_DONTCARE,4,2 ## @RESAMPLER_QUALITY_DONTCARE
L_str:                                  ## @str
	.asciz	"Could not open WAV file for reading."

L_str.3:                                ## @str.3
	.asciz	"error: could not load WAV file"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_audio_mix_load_wav_file        ; -- Begin function audio_mix_load_wav_file
	.p2align	2
_audio_mix_load_wav_file:               ; @audio_mix_load_wav_file
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x20, x1
	mov	x21, x0
	stur	wzr, [x29, #-36]
	str	xzr, [sp, #48]
	mov	w0, #1
	mov	w1, #104
	bl	_calloc
	mov	x19, x0
	cbz	x0, LBB0_23
; %bb.1:
	add	x1, sp, #48
	sub	x2, x29, #36
	mov	x0, x21
	bl	_filestream_read_file
	cbz	w0, LBB0_4
; %bb.2:
	str	w20, [x19]
	ldr	x8, [sp, #48]
	str	x8, [x19, #96]
	ldur	w8, [x29, #-36]
	str	w8, [x19, #88]
	mov	w0, #40
	bl	_malloc
	str	x0, [x19, #80]
	ldr	x1, [x19, #96]
	ldr	w2, [x19, #88]
	bl	_rwav_load
Lloh0:
	adrp	x8, _RWAV_ITERATE_ERROR@GOTPAGE
Lloh1:
	ldr	x8, [x8, _RWAV_ITERATE_ERROR@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	cmp	x0, x8
	b.ne	LBB0_5
; %bb.3:
Lloh3:
	adrp	x0, l_str.3@PAGE
Lloh4:
	add	x0, x0, l_str.3@PAGEOFF
	bl	_puts
	b	LBB0_22
LBB0_4:
Lloh5:
	adrp	x0, l_str@PAGE
Lloh6:
	add	x0, x0, l_str@PAGEOFF
	bl	_puts
	b	LBB0_22
LBB0_5:
	ldr	x8, [x19, #80]
	ldr	w8, [x8]
	lsl	w1, w8, #4
	mov	w0, #128
	bl	_memalign_alloc
	str	x0, [x19, #8]
	ldr	x8, [x19, #80]
	ldr	w9, [x8, #4]
	and	w10, w9, #0xfffffff8
	cmp	w10, #16
	b.eq	LBB0_15
; %bb.6:
	cmp	w10, #8
	b.ne	LBB0_21
; %bb.7:
	ldr	w9, [x8]
	cbz	w9, LBB0_25
; %bb.8:
	mov	x9, #0
	mov	w10, #1
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x11, [x8, #32]
	ldr	w8, [x8, #8]
	mul	w8, w8, w9
	add	x8, x11, w8, uxtw #2
	ldr	w11, [x8]
	lsl	w11, w11, #8
	sub	w11, w11, #8, lsl #12           ; =32768
	sxtw	x11, w11
	sub	w12, w10, #1
	str	x11, [x0, w12, uxtw #3]
	ldr	x12, [x19, #80]
	ldr	w12, [x12, #8]
	cmp	w12, #1
	b.eq	LBB0_12
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	cmp	w12, #2
	b.ne	LBB0_13
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	w8, [x8, #4]
	lsl	w8, w8, #8
	sub	w8, w8, #8, lsl #12             ; =32768
	sxtw	x11, w8
LBB0_12:                                ;   in Loop: Header=BB0_9 Depth=1
	ldr	x8, [x19, #8]
	str	x11, [x8, w10, uxtw #3]
LBB0_13:                                ;   in Loop: Header=BB0_9 Depth=1
	add	x9, x9, #1
	ldr	x8, [x19, #80]
	ldr	w11, [x8]
	cmp	x9, x11
	b.hs	LBB0_25
; %bb.14:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	x0, [x19, #8]
	add	w10, w10, #2
	b	LBB0_9
LBB0_15:
	ldr	w9, [x8, #8]
	cmp	w9, #2
	b.eq	LBB0_24
; %bb.16:
	cmp	w9, #1
	b.ne	LBB0_25
; %bb.17:
	ldr	w9, [x8]
	cbz	w9, LBB0_25
; %bb.18:
	ldr	x8, [x8, #32]
	ldr	x8, [x8]
	str	x8, [x0]
	ldr	x9, [x19, #8]
	str	x8, [x9, #8]
	ldr	x8, [x19, #80]
	ldr	w9, [x8]
	cmp	w9, #2
	b.lo	LBB0_25
; %bb.19:
	mov	w9, #3
	mov	w10, #1
LBB0_20:                                ; =>This Inner Loop Header: Depth=1
	ldr	x11, [x19, #8]
	ldr	x8, [x8, #32]
	ldr	x8, [x8, x10, lsl #3]
	sub	w12, w9, #1
	str	x8, [x11, w12, uxtw #3]
	ldr	x11, [x19, #8]
	str	x8, [x11, w9, uxtw #3]
	add	x10, x10, #1
	ldr	x8, [x19, #80]
	ldr	w11, [x8]
	add	w9, w9, #2
	cmp	x10, x11
	b.lo	LBB0_20
	b	LBB0_25
LBB0_21:
	add	w8, w9, #7
	cmp	w9, #0
	csel	w8, w8, w9, lt
	asr	w8, w8, #3
	str	x8, [sp]
Lloh7:
	adrp	x0, l_.str.2@PAGE
Lloh8:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_printf
LBB0_22:
	mov	x0, x19
	bl	_audio_mix_free_chunk
	mov	x19, #0
LBB0_23:
	mov	x0, x19
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_24:
	ldr	x1, [x8, #32]
	ldr	w2, [x8, #24]
	bl	_memcpy
	ldr	x8, [x19, #80]
LBB0_25:
	ldr	d0, [x8, #16]
	fcvtzs	w8, d0
	cmp	w8, w20
	b.eq	LBB0_23
; %bb.26:
	mov	w8, #1
	str	w8, [x19, #16]
	scvtf	d1, w20
	fdiv	d0, d1, d0
	str	d0, [x19, #24]
	add	x0, x19, #64
	add	x1, x19, #72
Lloh9:
	adrp	x8, _RESAMPLER_QUALITY_DONTCARE@GOTPAGE
Lloh10:
	ldr	x8, [x8, _RESAMPLER_QUALITY_DONTCARE@GOTPAGEOFF]
Lloh11:
	ldr	w3, [x8]
	mov	x2, #0
	bl	_retro_resampler_realloc
	ldr	x8, [x19, #72]
	cbz	x8, LBB0_23
; %bb.27:
	ldr	x8, [x19, #64]
	cbz	x8, LBB0_23
; %bb.28:
	ldr	x8, [x19, #80]
	ldr	w8, [x8]
	lsl	w8, w8, #1
	scvtf	d0, w8
	ldr	d1, [x19, #24]
	fmul	d0, d1, d0
	fcvtzs	w1, d0, #2
	mov	w0, #128
	bl	_memalign_alloc
	str	x0, [x19, #32]
	ldr	x8, [x19, #80]
	ldr	w8, [x8]
	add	w8, w8, w8, lsl #1
	scvtf	d0, w8
	ldr	d1, [x19, #24]
	fmul	d0, d1, d0
	fcvtzs	w1, d0, #2
	mov	w0, #128
	bl	_memalign_alloc
	str	x0, [x19, #40]
	ldr	x0, [x19, #32]
	ldr	x1, [x19, #8]
	ldr	x8, [x19, #80]
	ldr	w8, [x8]
	lsl	w2, w8, #1
	fmov	d0, #1.00000000
	bl	_convert_s16_to_float
	ldp	x8, x9, [x19, #32]
	stp	x8, x9, [sp, #16]
	ldr	x8, [x19, #80]
	ldr	w8, [x8]
	stp	w8, wzr, [sp, #32]
	ldr	d0, [x19, #24]
	fcvtzs	w8, d0
	str	w8, [sp, #40]
	ldp	x0, x8, [x19, #64]
	ldr	x8, [x8]
	add	x1, sp, #16
	blr	x8
	ldr	w8, [sp, #36]
	lsl	w1, w8, #4
	mov	w0, #128
	bl	_memalign_alloc
	str	x0, [x19, #48]
	ldr	w8, [sp, #36]
	str	w8, [x19, #56]
	ldr	x1, [x19, #40]
	lsl	w2, w8, #1
	bl	_convert_float_to_s16
	b	LBB0_23
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_RWAV_ITERATE_ERROR,8,3         ; @RWAV_ITERATE_ERROR
	.section	__TEXT,__cstring,cstring_literals
l_.str.2:                               ; @.str.2
	.asciz	"error: we don't support a sample size of %d\n"

	.comm	_RESAMPLER_QUALITY_DONTCARE,4,2 ; @RESAMPLER_QUALITY_DONTCARE
l_str:                                  ; @str
	.asciz	"Could not open WAV file for reading."

l_str.3:                                ; @str.3
	.asciz	"error: could not load WAV file"

.subsections_via_symbols
