	.file	"extr_ctr_dsp_audio.c_ctr_dsp_audio_write.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	ctr_dsp_audio_write, @function
ctr_dsp_audio_write:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	mov	r13, rsi
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	mov	r12, rdx
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	rbp, r12
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	mov	rbx, rdi
	shr	rbp, 2
	sub	rsp, 8
	.cfi_def_cfa_offset 64
	mov	edi, DWORD PTR 16[rdi]
	call	ndspChnGetSamplePos@PLT
	mov	ecx, DWORD PTR [rbx]
	mov	esi, DWORD PTR CTR_DSP_AUDIO_COUNT[rip]
	mov	r8d, DWORD PTR CTR_DSP_AUDIO_COUNT_MASK[rip]
	mov	edx, eax
	sub	edx, ecx
	mov	edi, esi
	and	edx, r8d
	sar	edi, 2
	cmp	edx, edi
	jl	.L2
	mov	edi, ecx
	mov	r9d, esi
	sub	edi, eax
	sar	r9d, 4
	and	edi, r8d
	cmp	edi, r9d
	jge	.L11
.L2:
	cmp	QWORD PTR 24[rbx], 0
	jne	.L12
	.p2align 4,,10
	.p2align 3
.L7:
	mov	edi, 100000
	call	svcSleepThread@PLT
	mov	edi, DWORD PTR 16[rbx]
	call	ndspChnGetSamplePos@PLT
	movsx	rsi, DWORD PTR [rbx]
	mov	edi, DWORD PTR CTR_DSP_AUDIO_COUNT[rip]
	mov	r9d, DWORD PTR CTR_DSP_AUDIO_COUNT_MASK[rip]
	movsx	rdx, eax
	mov	rcx, rsi
	mov	r8d, edi
	add	rsi, rbp
	sub	rdx, rsi
	sar	r8d
	movsx	rsi, r9d
	and	rdx, rsi
	movsx	rsi, r8d
	cmp	rdx, rsi
	ja	.L7
	sar	edi, 4
	mov	esi, ecx
	sub	esi, edi
	mov	edx, esi
	sub	edx, eax
	mov	eax, edx
	and	eax, r9d
	cmp	r8d, eax
	jl	.L7
.L3:
	sal	ecx, 2
	mov	rdi, QWORD PTR 8[rbx]
	mov	rdx, QWORD PTR CTR_DSP_AUDIO_SIZE[rip]
	movsx	r14, ecx
	lea	r15, [r12+r14]
	add	rdi, r14
	cmp	r15, rdx
	jbe	.L5
	sub	rdx, r14
	mov	rsi, r13
	call	memcpy@PLT
	mov	rsi, QWORD PTR CTR_DSP_AUDIO_SIZE[rip]
	mov	rdi, QWORD PTR 8[rbx]
	sub	rsi, r14
	add	rdi, r14
	call	DSP_FlushDataCache@PLT
	mov	rsi, QWORD PTR CTR_DSP_AUDIO_SIZE[rip]
	mov	rdx, r15
	mov	rdi, QWORD PTR 8[rbx]
	sub	rdx, rsi
	sub	rsi, r14
	add	rsi, r13
	call	memcpy@PLT
	mov	rdi, QWORD PTR 8[rbx]
	mov	rsi, r15
	sub	rsi, QWORD PTR CTR_DSP_AUDIO_SIZE[rip]
	call	DSP_FlushDataCache@PLT
.L6:
	add	ebp, DWORD PTR [rbx]
	and	ebp, DWORD PTR CTR_DSP_AUDIO_COUNT_MASK[rip]
	mov	rax, r12
	mov	DWORD PTR [rbx], ebp
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	.cfi_restore_state
	mov	rsi, r13
	mov	rdx, r12
	call	memcpy@PLT
	mov	rdi, QWORD PTR 8[rbx]
	mov	rsi, r12
	add	rdi, r14
	call	DSP_FlushDataCache@PLT
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L12:
	sar	esi
	lea	ecx, [rsi+rax]
	and	ecx, r8d
	mov	DWORD PTR [rbx], ecx
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	movsx	rdx, edx
	cmp	rdx, rbp
	jnb	.L3
	cmp	QWORD PTR 24[rbx], 0
	je	.L7
	jmp	.L12
	.cfi_endproc
.LFE0:
	.size	ctr_dsp_audio_write, .-ctr_dsp_audio_write
	.comm	CTR_DSP_AUDIO_SIZE,8,8
	.comm	CTR_DSP_AUDIO_COUNT_MASK,4,4
	.comm	CTR_DSP_AUDIO_COUNT,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_ctr_dsp_audio.c_ctr_dsp_audio_write.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	ctr_dsp_audio_write, %function
ctr_dsp_audio_write:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r3, r4, r5, r6, r7, r8, r9, r10, fp, lr}
	mov	r4, r0
	ldr	r0, [r0, #8]
	mov	r7, r2
	mov	r8, r1
	bl	ndspChnGetSamplePos
	ldr	r9, .L14
	ldr	r1, [r4]
	ldr	r10, .L14+4
	ldr	r2, [r9]
	ldr	ip, [r10]
	sub	r3, r0, r1
	and	r3, r3, r2
	cmp	r3, ip, asr #2
	lsr	r5, r7, #2
	blt	.L2
	sub	lr, r1, r0
	and	lr, lr, r2
	cmp	lr, ip, asr #4
	bge	.L12
.L2:
	ldr	r3, [r4, #12]
	cmp	r3, #0
	ldreq	r6, .L14+8
	bne	.L13
.L8:
	mov	r0, r6
	bl	svcSleepThread
	ldr	r0, [r4, #8]
	bl	ndspChnGetSamplePos
	ldr	r1, [r4]
	ldr	r2, [r10]
	ldr	lr, [r9]
	add	r3, r1, r5
	sub	r3, r0, r3
	sub	ip, r1, r2, asr #4
	and	r3, r3, lr
	sub	r0, ip, r0
	cmp	r3, r2, asr #1
	and	r0, r0, lr
	asr	r2, r2, #1
	bhi	.L8
	cmp	r2, r0
	blt	.L8
.L3:
	ldr	r6, .L14+12
	ldr	r0, [r4, #4]
	ldr	r2, [r6]
	add	r10, r7, r1, lsl #2
	cmp	r10, r2
	add	r0, r0, r1, lsl #2
	lsl	fp, r1, #2
	bls	.L5
	sub	r2, r2, fp
	mov	r1, r8
	bl	memcpy
	ldr	r1, [r6]
	ldr	r0, [r4, #4]
	sub	r1, r1, fp
	add	r0, fp, r0
	bl	DSP_FlushDataCache
	ldr	r2, [r6]
	ldr	r0, [r4, #4]
	sub	r1, r2, fp
	add	r1, r8, r1
	sub	r2, r10, r2
	bl	memcpy
	ldr	r1, [r6]
	ldr	r0, [r4, #4]
	sub	r1, r10, r1
	bl	DSP_FlushDataCache
.L6:
	ldr	r2, [r4]
	ldr	r3, [r9]
	add	r5, r5, r2
	and	r5, r5, r3
	mov	r0, r7
	str	r5, [r4]
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L5:
	mov	r1, r8
	mov	r2, r7
	bl	memcpy
	ldr	r0, [r4, #4]
	mov	r1, r7
	add	r0, fp, r0
	bl	DSP_FlushDataCache
	b	.L6
.L13:
	add	r1, r0, ip, asr #1
	and	r1, r1, r2
	str	r1, [r4]
	b	.L3
.L12:
	cmp	r3, r5
	bcs	.L3
	ldr	r3, [r4, #12]
	cmp	r3, #0
	ldreq	r6, .L14+8
	beq	.L8
	b	.L13
.L15:
	.align	2
.L14:
	.word	CTR_DSP_AUDIO_COUNT_MASK
	.word	CTR_DSP_AUDIO_COUNT
	.word	100000
	.word	CTR_DSP_AUDIO_SIZE
	.size	ctr_dsp_audio_write, .-ctr_dsp_audio_write
	.comm	CTR_DSP_AUDIO_SIZE,4,4
	.comm	CTR_DSP_AUDIO_COUNT_MASK,4,4
	.comm	CTR_DSP_AUDIO_COUNT,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
