	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function emu8k_pcm_prepare
_emu8k_pcm_prepare:                     ## @emu8k_pcm_prepare
	.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	%rdi, %r14
	movq	(%rdi), %rax
	movq	24(%rax), %r12
	movl	16(%rax), %edi
	callq	_calc_rate_offset
	addq	$57344, %rax                    ## imm = 0xE000
	movq	%rax, 80(%r12)
	xorps	%xmm0, %xmm0
	movups	%xmm0, 64(%r12)
	movq	(%r14), %rax
	movq	8(%rax), %rcx
	movq	%rcx, 32(%r12)
	movl	4(%rax), %ecx
	movl	%ecx, 56(%r12)
	movl	(%rax), %esi
	movl	%esi, (%r12)
	movq	_LOOP_BLANK_SIZE@GOTPCREL(%rip), %r15
	movslq	(%r15), %rcx
	movq	48(%r12), %rax
	addq	%rcx, %rax
	movq	40(%r12), %rdx
	movq	%rax, (%rdx)
	cmpl	$2, %esi
	jl	LBB0_2
## %bb.1:
	addq	%rcx, %rax
	addq	32(%r12), %rax
	movq	%rax, 8(%rdx)
	movq	8(%r12), %rax
	movq	$255, (%rax)
	cmpl	$0, 16(%r12)
	jne	LBB0_12
	jmp	LBB0_4
LBB0_2:
	movq	8(%r12), %rax
	movl	$128, (%rax)
	cmpl	$0, 16(%r12)
	je	LBB0_4
LBB0_12:
	xorl	%r14d, %r14d
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	_setup_voice
	cmpl	$2, (%r12)
	jl	LBB0_14
## %bb.13:
	movq	%r12, %rdi
	movl	$1, %esi
	callq	_setup_voice
	jmp	LBB0_14
LBB0_4:
	movq	24(%r12), %rax
	movl	(%rax), %edi
	callq	_snd_emux_terminate_all
	movq	24(%r12), %rdi
	movl	(%r12), %esi
	callq	_emu8k_open_dram_for_pcm
	movl	%eax, %r14d
	testl	%eax, %eax
	je	LBB0_5
LBB0_14:
	movl	%r14d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	movl	$1, 16(%r12)
	movq	24(%r12), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	_snd_emu8000_write_wait
	movq	24(%r12), %rdi
	movq	48(%r12), %rsi
	callq	_EMU8000_SMALW_WRITE
	cmpl	$0, (%r15)
	jle	LBB0_6
	.p2align	4, 0x90
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	24(%r12), %rdi
	xorl	%esi, %esi
	callq	_EMU8000_SMLD_WRITE
	incl	%r14d
	cmpl	(%r15), %r14d
	jl	LBB0_15
LBB0_6:
	cmpl	$0, (%r12)
	jle	LBB0_12
## %bb.7:
	xorl	%r14d, %r14d
	jmp	LBB0_8
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_8 Depth=1
	incq	%r14
	movslq	(%r12), %rax
	cmpq	%rax, %r14
	jge	LBB0_12
LBB0_8:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_10 Depth 2
	movq	40(%r12), %rax
	movq	24(%r12), %rdi
	movq	32(%r12), %rsi
	addq	(%rax,%r14,8), %rsi
	callq	_EMU8000_SMALW_WRITE
	cmpl	$0, (%r15)
	jle	LBB0_11
## %bb.9:                               ##   in Loop: Header=BB0_8 Depth=1
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_10:                                ##   Parent Loop BB0_8 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	24(%r12), %rdi
	xorl	%esi, %esi
	callq	_EMU8000_SMLD_WRITE
	incl	%ebx
	cmpl	(%r15), %ebx
	jl	LBB0_10
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_LOOP_BLANK_SIZE,4,2            ## @LOOP_BLANK_SIZE
	.no_dead_strip	_emu8k_pcm_prepare
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function emu8k_pcm_prepare
_emu8k_pcm_prepare:                     ; @emu8k_pcm_prepare
	.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	x20, x0
	ldr	x8, [x0]
	ldr	x19, [x8, #24]
	ldr	w0, [x8, #16]
	bl	_calc_rate_offset
	add	x8, x0, #14, lsl #12            ; =57344
	stp	xzr, x8, [x19, #72]
	str	xzr, [x19, #64]
	ldr	x8, [x20]
	ldr	x9, [x8, #8]
	str	x9, [x19, #32]
	ldp	w11, w9, [x8]
	str	w9, [x19, #56]
	str	w11, [x19]
Lloh0:
	adrp	x20, _LOOP_BLANK_SIZE@GOTPAGE
Lloh1:
	ldr	x20, [x20, _LOOP_BLANK_SIZE@GOTPAGEOFF]
	ldrsw	x9, [x20]
	ldp	x8, x10, [x19, #40]
	add	x10, x10, x9
	str	x10, [x8]
	cmp	w11, #2
	b.lt	LBB0_2
; %bb.1:
	ldr	x11, [x19, #32]
	add	x9, x10, x9
	add	x9, x9, x11
	str	x9, [x8, #8]
	ldr	x8, [x19, #8]
	movi	d0, #0x000000000000ff
	str	d0, [x8]
	ldr	w8, [x19, #16]
	cbnz	w8, LBB0_3
	b	LBB0_5
LBB0_2:
	ldr	x8, [x19, #8]
	mov	w9, #128
	str	w9, [x8]
	ldr	w8, [x19, #16]
	cbz	w8, LBB0_5
LBB0_3:
	mov	x0, x19
	mov	w1, #0
	bl	_setup_voice
	mov	w0, #0
	ldr	w8, [x19]
	cmp	w8, #1
	b.le	LBB0_6
; %bb.4:
	mov	x0, x19
	mov	w1, #1
	bl	_setup_voice
	mov	w0, #0
	b	LBB0_6
LBB0_5:
	ldr	x8, [x19, #24]
	ldr	w0, [x8]
	bl	_snd_emux_terminate_all
	ldr	x0, [x19, #24]
	ldr	w1, [x19]
	bl	_emu8k_open_dram_for_pcm
	cbz	w0, LBB0_7
LBB0_6:
	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
LBB0_7:
	mov	w8, #1
	str	w8, [x19, #16]
	ldr	x0, [x19, #24]
	mov	w1, #0
	bl	_snd_emu8000_write_wait
	ldr	x0, [x19, #24]
	ldr	x1, [x19, #48]
	bl	_EMU8000_SMALW_WRITE
	ldr	w8, [x20]
	cmp	w8, #1
	b.lt	LBB0_10
; %bb.8:
	mov	w21, #0
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x0, [x19, #24]
	mov	w1, #0
	bl	_EMU8000_SMLD_WRITE
	add	w21, w21, #1
	ldr	w8, [x20]
	cmp	w21, w8
	b.lt	LBB0_9
LBB0_10:
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_3
; %bb.11:
	mov	x21, #0
	b	LBB0_13
LBB0_12:                                ;   in Loop: Header=BB0_13 Depth=1
	add	x21, x21, #1
	ldrsw	x8, [x19]
	cmp	x21, x8
	b.ge	LBB0_3
LBB0_13:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_15 Depth 2
	ldp	x9, x8, [x19, #32]
	ldr	x8, [x8, x21, lsl #3]
	ldr	x0, [x19, #24]
	add	x1, x9, x8
	bl	_EMU8000_SMALW_WRITE
	ldr	w8, [x20]
	cmp	w8, #1
	b.lt	LBB0_12
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=1
	mov	w22, #0
LBB0_15:                                ;   Parent Loop BB0_13 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	x0, [x19, #24]
	mov	w1, #0
	bl	_EMU8000_SMLD_WRITE
	add	w22, w22, #1
	ldr	w8, [x20]
	cmp	w22, w8
	b.lt	LBB0_15
	b	LBB0_12
	.loh AdrpLdrGot	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
	.comm	_LOOP_BLANK_SIZE,4,2            ; @LOOP_BLANK_SIZE
	.no_dead_strip	_emu8k_pcm_prepare
.subsections_via_symbols
