	.file	"extr_emu8000_pcm.c_emu8k_pcm_prepare.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	emu8k_pcm_prepare, @function
emu8k_pcm_prepare:
.LFB0:
	.cfi_startproc
	endbr64
	push	r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	push	rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	push	rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	mov	rax, QWORD PTR [rdi]
	mov	rbx, rdi
	mov	edi, DWORD PTR 16[rax]
	mov	rbp, QWORD PTR 24[rax]
	call	calc_rate_offset@PLT
	movsx	rsi, DWORD PTR LOOP_BLANK_SIZE[rip]
	mov	rcx, QWORD PTR 40[rbp]
	mov	QWORD PTR 72[rbp], 0
	add	rax, 57344
	mov	QWORD PTR 64[rbp], 0
	mov	QWORD PTR 80[rbp], rax
	mov	rax, QWORD PTR [rbx]
	mov	rdx, QWORD PTR 8[rax]
	mov	QWORD PTR 32[rbp], rdx
	mov	edx, DWORD PTR 4[rax]
	mov	DWORD PTR 56[rbp], edx
	mov	edx, DWORD PTR [rax]
	mov	rax, QWORD PTR 48[rbp]
	mov	DWORD PTR 0[rbp], edx
	add	rax, rsi
	mov	QWORD PTR [rcx], rax
	cmp	edx, 1
	jle	.L2
	add	rax, QWORD PTR 32[rbp]
	add	rax, rsi
	mov	QWORD PTR 8[rcx], rax
	mov	rax, QWORD PTR 8[rbp]
	mov	QWORD PTR [rax], 255
.L10:
	mov	esi, DWORD PTR 16[rbp]
	test	esi, esi
	jne	.L3
	mov	rax, QWORD PTR 24[rbp]
	mov	edi, DWORD PTR [rax]
	call	snd_emux_terminate_all@PLT
	mov	rdi, QWORD PTR 24[rbp]
	mov	esi, DWORD PTR 0[rbp]
	call	emu8k_open_dram_for_pcm@PLT
	mov	r12d, eax
	test	eax, eax
	je	.L17
.L1:
	mov	eax, r12d
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	pop	rbp
	.cfi_def_cfa_offset 16
	pop	r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L17:
	.cfi_restore_state
	mov	DWORD PTR 16[rbp], 1
	mov	rdi, QWORD PTR 24[rbp]
	xor	esi, esi
	call	snd_emu8000_write_wait@PLT
	mov	rsi, QWORD PTR 48[rbp]
	mov	rdi, QWORD PTR 24[rbp]
	call	EMU8000_SMALW_WRITE@PLT
	mov	ecx, DWORD PTR LOOP_BLANK_SIZE[rip]
	test	ecx, ecx
	jle	.L5
	xor	ebx, ebx
	.p2align 4,,10
	.p2align 3
.L6:
	mov	rdi, QWORD PTR 24[rbp]
	xor	esi, esi
	add	ebx, 1
	call	EMU8000_SMLD_WRITE@PLT
	cmp	DWORD PTR LOOP_BLANK_SIZE[rip], ebx
	jg	.L6
.L5:
	mov	edx, DWORD PTR 0[rbp]
	test	edx, edx
	jle	.L3
	xor	r12d, r12d
	.p2align 4,,10
	.p2align 3
.L9:
	mov	rax, QWORD PTR 40[rbp]
	mov	rdi, QWORD PTR 24[rbp]
	mov	rsi, QWORD PTR 32[rbp]
	add	rsi, QWORD PTR [rax+r12*8]
	call	EMU8000_SMALW_WRITE@PLT
	mov	eax, DWORD PTR LOOP_BLANK_SIZE[rip]
	test	eax, eax
	jle	.L7
	xor	ebx, ebx
	.p2align 4,,10
	.p2align 3
.L8:
	mov	rdi, QWORD PTR 24[rbp]
	xor	esi, esi
	add	ebx, 1
	call	EMU8000_SMLD_WRITE@PLT
	cmp	DWORD PTR LOOP_BLANK_SIZE[rip], ebx
	jg	.L8
.L7:
	add	r12, 1
	cmp	DWORD PTR 0[rbp], r12d
	jg	.L9
.L3:
	xor	esi, esi
	mov	rdi, rbp
	xor	r12d, r12d
	call	setup_voice@PLT
	cmp	DWORD PTR 0[rbp], 1
	jle	.L1
	mov	rdi, rbp
	mov	esi, 1
	call	setup_voice@PLT
	mov	eax, r12d
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	pop	rbp
	.cfi_def_cfa_offset 16
	pop	r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	mov	rax, QWORD PTR 8[rbp]
	mov	DWORD PTR [rax], 128
	jmp	.L10
	.cfi_endproc
.LFE0:
	.size	emu8k_pcm_prepare, .-emu8k_pcm_prepare
	.comm	LOOP_BLANK_SIZE,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_emu8000_pcm.c_emu8k_pcm_prepare.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	emu8k_pcm_prepare, %function
emu8k_pcm_prepare:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	ldr	r3, [r0]
	push	{r4, r5, r6, r7, r8, lr}
	mov	r4, r0
	ldr	r0, [r3, #12]
	ldr	r5, [r3, #16]
	bl	calc_rate_offset
	mov	r1, #0
	ldr	r2, [r4]
	add	r0, r0, #57344
	ldr	r6, .L18
	ldr	ip, [r2]
	str	r0, [r5, #40]
	ldr	r0, [r2, #8]
	ldr	r2, [r2, #4]
	ldr	lr, [r6]
	ldr	r3, [r5, #24]
	str	r2, [r5, #28]
	ldr	r2, [r5, #20]
	add	r3, lr, r3
	cmp	ip, #1
	str	r0, [r5, #16]
	str	ip, [r5]
	str	r1, [r5, #36]
	str	r1, [r5, #32]
	str	r3, [r2]
	ble	.L2
	mov	ip, #255
	ldr	r0, [r5, #16]
	add	r3, r3, r0
	ldr	r0, [r5, #4]
	add	r3, r3, lr
	str	r3, [r2, #4]
	str	ip, [r0]
	str	r1, [r0, #4]
.L10:
	ldr	r3, [r5, #8]
	cmp	r3, #0
	bne	.L3
	ldr	r3, [r5, #12]
	ldr	r0, [r3]
	bl	snd_emux_terminate_all
	ldr	r1, [r5]
	ldr	r0, [r5, #12]
	bl	emu8k_open_dram_for_pcm
	subs	r4, r0, #0
	beq	.L17
.L1:
	mov	r0, r4
	pop	{r4, r5, r6, r7, r8, pc}
.L17:
	mov	r3, #1
	mov	r1, r4
	str	r3, [r5, #8]
	ldr	r0, [r5, #12]
	bl	snd_emu8000_write_wait
	ldr	r1, [r5, #24]
	ldr	r0, [r5, #12]
	bl	EMU8000_SMALW_WRITE
	ldr	r3, [r6]
	cmp	r3, #0
	ble	.L5
.L6:
	mov	r1, #0
	ldr	r0, [r5, #12]
	bl	EMU8000_SMLD_WRITE
	ldr	r3, [r6]
	add	r4, r4, #1
	cmp	r3, r4
	bgt	.L6
.L5:
	ldr	r3, [r5]
	cmp	r3, #0
	ble	.L3
	mov	r7, #0
.L9:
	ldr	r2, [r5, #20]
	ldr	r3, [r5, #16]
	ldr	r1, [r2, r7, lsl #2]
	ldr	r0, [r5, #12]
	add	r1, r1, r3
	bl	EMU8000_SMALW_WRITE
	ldr	r3, [r6]
	cmp	r3, #0
	ble	.L7
	mov	r4, #0
.L8:
	mov	r1, #0
	ldr	r0, [r5, #12]
	bl	EMU8000_SMLD_WRITE
	ldr	r3, [r6]
	add	r4, r4, #1
	cmp	r3, r4
	bgt	.L8
.L7:
	ldr	r3, [r5]
	add	r7, r7, #1
	cmp	r3, r7
	bgt	.L9
.L3:
	mov	r1, #0
	mov	r0, r5
	bl	setup_voice
	ldr	r3, [r5]
	cmp	r3, #1
	movle	r4, #0
	ble	.L1
	mov	r4, #0
	mov	r0, r5
	mov	r1, #1
	bl	setup_voice
	mov	r0, r4
	pop	{r4, r5, r6, r7, r8, pc}
.L2:
	mov	r2, #128
	ldr	r3, [r5, #4]
	str	r2, [r3]
	b	.L10
.L19:
	.align	2
.L18:
	.word	LOOP_BLANK_SIZE
	.size	emu8k_pcm_prepare, .-emu8k_pcm_prepare
	.comm	LOOP_BLANK_SIZE,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
