	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_csndPlaySound_custom           ## -- Begin function csndPlaySound_custom
	.p2align	4, 0x90
_csndPlaySound_custom:                  ## @csndPlaySound_custom
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%r8d, %r15d
	movq	%rcx, -72(%rbp)                 ## 8-byte Spill
	movq	%rdx, -80(%rbp)                 ## 8-byte Spill
	movss	%xmm1, -60(%rbp)                ## 4-byte Spill
	movss	%xmm0, -56(%rbp)                ## 4-byte Spill
	movl	%esi, %r14d
	movq	_csndChannels@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movl	%edi, -48(%rbp)                 ## 4-byte Spill
	callq	_BIT
	testl	%ebx, %eax
	je	LBB0_1
## %bb.2:
	movl	%r15d, -52(%rbp)                ## 4-byte Spill
	movl	%r14d, %r12d
	shrl	$12, %r12d
	andl	$3, %r12d
	movl	%r14d, %r15d
	shrl	$10, %r15d
	movl	$0, -44(%rbp)                   ## 4-byte Folded Spill
	movl	$0, %r13d
	andl	$3, %r15d
	jne	LBB0_4
## %bb.3:
	movq	_SOUND_ONE_SHOT@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
LBB0_4:
	orl	%r14d, %r13d
	movq	_CSND_ENCODING_PSG@GOTPCREL(%rip), %rax
	movl	$0, %r14d
	cmpl	(%rax), %r12d
	movq	-80(%rbp), %rbx                 ## 8-byte Reload
	je	LBB0_12
## %bb.5:
	movl	$0, -44(%rbp)                   ## 4-byte Folded Spill
	movl	$0, %r14d
	testq	%rbx, %rbx
	je	LBB0_7
## %bb.6:
	movq	%rbx, %rdi
	callq	_osConvertVirtToPhys
	movl	%eax, %r14d
LBB0_7:
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	testq	%rdi, %rdi
	je	LBB0_9
## %bb.8:
	callq	_osConvertVirtToPhys
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
LBB0_9:
	testq	%rbx, %rbx
	je	LBB0_12
## %bb.10:
	movq	_CSND_ENCODING_ADPCM@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r12d
	jne	LBB0_12
## %bb.11:
	movl	-8(%rbx), %ecx
	movl	-48(%rbp), %edi                 ## 4-byte Reload
	xorl	%esi, %esi
	movl	%ecx, %edx
	callq	_CSND_SetAdpcmState
LBB0_12:
	andl	$65504, %r13d                   ## imm = 0xFFE0
	movq	_SOUND_ENABLE@GOTPCREL(%rip), %rax
	orl	(%rax), %r13d
	movl	-48(%rbp), %edi                 ## 4-byte Reload
	callq	_SOUND_CHANNEL
	movq	_CTR_CSND_TICKS_PER_SAMPLE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ebx
	shll	$16, %ebx
	orl	%eax, %ebx
	orl	%r13d, %ebx
	movss	-56(%rbp), %xmm0                ## 4-byte Reload
                                        ## xmm0 = mem[0],zero,zero,zero
	movss	-60(%rbp), %xmm1                ## 4-byte Reload
                                        ## xmm1 = mem[0],zero,zero,zero
	callq	_CSND_VOL
	movl	%ebx, %edi
	movl	%r14d, %esi
	movl	-44(%rbp), %r13d                ## 4-byte Reload
	movl	%r13d, %edx
	movl	-52(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %ecx
	movl	%eax, %r8d
	movl	%eax, %r9d
	callq	_CSND_SetChnRegs
	movq	_CSND_LOOPMODE_NORMAL@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	cmpl	(%rax), %r15d
	jne	LBB0_15
## %bb.13:
	cmpl	%r13d, %r14d
	jge	LBB0_15
## %bb.14:
	subl	%r13d, %ebx
	addl	%r14d, %ebx
	movl	-48(%rbp), %edi                 ## 4-byte Reload
	movl	$1, %esi
	movl	%r13d, %edx
	movl	%ebx, %ecx
	callq	_CSND_SetBlock
	jmp	LBB0_15
LBB0_1:
	movl	$1, %r12d
LBB0_15:
	movl	%r12d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_csndChannels,4,2               ## @csndChannels
	.comm	_SOUND_ONE_SHOT,4,2             ## @SOUND_ONE_SHOT
	.comm	_CSND_ENCODING_PSG,4,2          ## @CSND_ENCODING_PSG
	.comm	_CSND_ENCODING_ADPCM,4,2        ## @CSND_ENCODING_ADPCM
	.comm	_SOUND_ENABLE,4,2               ## @SOUND_ENABLE
	.comm	_CTR_CSND_TICKS_PER_SAMPLE,4,2  ## @CTR_CSND_TICKS_PER_SAMPLE
	.comm	_CSND_LOOPMODE_NORMAL,4,2       ## @CSND_LOOPMODE_NORMAL
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_csndPlaySound_custom           ; -- Begin function csndPlaySound_custom
	.p2align	2
_csndPlaySound_custom:                  ; @csndPlaySound_custom
	.cfi_startproc
; %bb.0:
	stp	d9, d8, [sp, #-112]!            ; 16-byte Folded Spill
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	.cfi_offset b8, -104
	.cfi_offset b9, -112
	mov	x19, x4
	mov	x24, x3
	mov	x23, x2
	fmov	s8, s1
	fmov	s9, s0
	mov	x25, x1
	mov	x20, x0
Lloh0:
	adrp	x8, _csndChannels@GOTPAGE
Lloh1:
	ldr	x8, [x8, _csndChannels@GOTPAGEOFF]
Lloh2:
	ldr	w21, [x8]
	bl	_BIT
	tst	w0, w21
	b.eq	LBB0_5
; %bb.1:
	mov	w22, #0
	mov	w21, #0
	ubfx	w27, w25, #12, #2
	ubfx	w26, w25, #10, #2
Lloh3:
	adrp	x8, _SOUND_ONE_SHOT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SOUND_ONE_SHOT@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	cmp	w26, #0
	csel	w8, w8, wzr, eq
	orr	w25, w8, w25
Lloh6:
	adrp	x8, _CSND_ENCODING_PSG@GOTPAGE
Lloh7:
	ldr	x8, [x8, _CSND_ENCODING_PSG@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	cmp	w27, w8
	b.eq	LBB0_10
; %bb.2:
	cbz	x23, LBB0_6
; %bb.3:
	mov	x0, x23
	bl	_osConvertVirtToPhys
	mov	x21, x0
	cbz	x24, LBB0_7
LBB0_4:
	mov	x0, x24
	bl	_osConvertVirtToPhys
	mov	x22, x0
	cbnz	x23, LBB0_8
	b	LBB0_10
LBB0_5:
	mov	w0, #1
	b	LBB0_13
LBB0_6:
	mov	w21, #0
	cbnz	x24, LBB0_4
LBB0_7:
	mov	w22, #0
	cbz	x23, LBB0_10
LBB0_8:
Lloh9:
	adrp	x8, _CSND_ENCODING_ADPCM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _CSND_ENCODING_ADPCM@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	cmp	w27, w8
	b.ne	LBB0_10
; %bb.9:
	ldur	w2, [x23, #-8]
	mov	x0, x20
	mov	w1, #0
	mov	x3, x2
	bl	_CSND_SetAdpcmState
LBB0_10:
	and	w23, w25, #0xffe0
Lloh12:
	adrp	x8, _SOUND_ENABLE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _SOUND_ENABLE@GOTPAGEOFF]
Lloh14:
	ldr	w24, [x8]
	mov	x0, x20
	bl	_SOUND_CHANNEL
Lloh15:
	adrp	x8, _CTR_CSND_TICKS_PER_SAMPLE@GOTPAGE
Lloh16:
	ldr	x8, [x8, _CTR_CSND_TICKS_PER_SAMPLE@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	orr	w9, w24, w23
	orr	w9, w9, w0
	orr	w23, w9, w8, lsl #16
	fmov	s0, s9
	fmov	s1, s8
	bl	_CSND_VOL
	mov	x4, x0
	mov	x0, x23
	mov	x1, x21
	mov	x2, x22
	mov	x3, x19
	mov	x5, x4
	bl	_CSND_SetChnRegs
Lloh18:
	adrp	x8, _CSND_LOOPMODE_NORMAL@GOTPAGE
Lloh19:
	ldr	x8, [x8, _CSND_LOOPMODE_NORMAL@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	cmp	w26, w8
	ccmp	w21, w22, #0, eq
	b.ge	LBB0_12
; %bb.11:
	sub	w8, w19, w22
	add	w3, w8, w21
	mov	x0, x20
	mov	w1, #1
	mov	x2, x22
	bl	_CSND_SetBlock
LBB0_12:
	mov	w0, #0
LBB0_13:
	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
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	ldp	d9, d8, [sp], #112              ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_csndChannels,4,2               ; @csndChannels
	.comm	_SOUND_ONE_SHOT,4,2             ; @SOUND_ONE_SHOT
	.comm	_CSND_ENCODING_PSG,4,2          ; @CSND_ENCODING_PSG
	.comm	_CSND_ENCODING_ADPCM,4,2        ; @CSND_ENCODING_ADPCM
	.comm	_SOUND_ENABLE,4,2               ; @SOUND_ENABLE
	.comm	_CTR_CSND_TICKS_PER_SAMPLE,4,2  ; @CTR_CSND_TICKS_PER_SAMPLE
	.comm	_CSND_LOOPMODE_NORMAL,4,2       ; @CSND_LOOPMODE_NORMAL
.subsections_via_symbols
