	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function UpdateSyncBuffer
_UpdateSyncBuffer:                      ## @UpdateSyncBuffer
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_PLATFORM_SoundLock
	movq	_sync_write_pos@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
	movq	_sync_read_pos@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	xorl	%eax, %eax
	callq	_Util_time
	movq	_last_audio_write_time@GOTPCREL(%rip), %rcx
	subl	(%rcx), %eax
	movq	_Sound_out@GOTPCREL(%rip), %r14
	imull	(%r14), %eax
	imull	4(%r14), %eax
	imull	8(%r14), %eax
	movl	%r13d, %ecx
	subl	%eax, %ecx
	cmovbl	%ebx, %ecx
	movq	_sync_est_fill@GOTPCREL(%rip), %rax
	movl	%ecx, (%rax)
	movq	_Atari800_turbo@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_2
## %bb.1:
	movq	_sync_max_fill@GOTPCREL(%rip), %rax
	cmpl	(%rax), %ecx
	ja	LBB0_9
LBB0_2:
	xorl	%eax, %eax
	callq	_POKEYSND_UpdateProcessBuffer
	movl	%eax, %r15d
	imull	8(%r14), %r15d
	movq	_sync_buffer_size@GOTPCREL(%rip), %r12
	movl	(%r12), %ebx
	movl	%ebx, %eax
	subl	%r13d, %eax
	movq	_sync_write_pos@GOTPCREL(%rip), %r13
	cmpl	%eax, %r15d
	jbe	LBB0_10
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	xorl	%eax, %eax
	callq	_PLATFORM_SoundUnlock
	xorps	%xmm0, %xmm0
	cvtsi2sdq	16(%r14), %xmm0
	movl	(%r14), %eax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	%xmm1, %xmm0
	callq	_Util_sleep
	xorl	%eax, %eax
	callq	_PLATFORM_SoundLock
	xorl	%eax, %eax
	callq	_WriteOut
	movl	(%r13), %ecx
	movq	_sync_read_pos@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	subl	%ecx, %eax
	movl	(%r12), %ebx
	addl	%ebx, %eax
	cmpl	%eax, %r15d
	ja	LBB0_3
	jmp	LBB0_4
LBB0_10:
	movl	(%r13), %ecx
LBB0_4:
	leal	(%rcx,%r15), %r14d
	movl	%r14d, %eax
	xorl	%edx, %edx
	divl	%ebx
	movl	%eax, %esi
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%ebx
	cmpl	%eax, %esi
	jne	LBB0_6
## %bb.5:
	movq	_sync_buffer@GOTPCREL(%rip), %rsi
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%ebx
	movl	%edx, %edi
	addq	(%rsi), %rdi
	movq	_POKEYSND_process_buffer@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	jmp	LBB0_7
LBB0_6:
	subl	%edx, %ebx
	movq	_sync_buffer@GOTPCREL(%rip), %rax
	movl	%edx, %edi
	addq	(%rax), %rdi
	movq	_POKEYSND_process_buffer@GOTPCREL(%rip), %r13
	movq	(%r13), %rsi
	movl	%ebx, %edx
	callq	_memcpy
	movq	_sync_buffer@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	movslq	%ebx, %rax
	movq	(%r13), %rsi
	movq	_sync_write_pos@GOTPCREL(%rip), %r13
	addq	%rax, %rsi
	subl	%eax, %r15d
LBB0_7:
	movl	%r15d, %edx
	callq	_memcpy
	movl	%r14d, (%r13)
	movl	(%r12), %eax
	movq	_sync_read_pos@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	addl	%eax, %ecx
	cmpl	%ecx, %r14d
	jbe	LBB0_9
## %bb.8:
	subl	%eax, %r14d
	movq	_sync_write_pos@GOTPCREL(%rip), %rax
	movl	%r14d, (%rax)
LBB0_9:
	xorl	%eax, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_PLATFORM_SoundUnlock           ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_sync_write_pos,4,2             ## @sync_write_pos
	.comm	_sync_read_pos,4,2              ## @sync_read_pos
	.comm	_last_audio_write_time,4,2      ## @last_audio_write_time
	.comm	_Sound_out,24,3                 ## @Sound_out
	.comm	_sync_est_fill,4,2              ## @sync_est_fill
	.comm	_Atari800_turbo,8,3             ## @Atari800_turbo
	.comm	_sync_max_fill,4,2              ## @sync_max_fill
	.comm	_sync_buffer_size,4,2           ## @sync_buffer_size
	.comm	_sync_buffer,8,3                ## @sync_buffer
	.comm	_POKEYSND_process_buffer,8,3    ## @POKEYSND_process_buffer
	.no_dead_strip	_UpdateSyncBuffer
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function UpdateSyncBuffer
_UpdateSyncBuffer:                      ; @UpdateSyncBuffer
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	bl	_PLATFORM_SoundLock
Lloh0:
	adrp	x21, _sync_write_pos@GOTPAGE
Lloh1:
	ldr	x21, [x21, _sync_write_pos@GOTPAGEOFF]
	ldr	w8, [x21]
Lloh2:
	adrp	x22, _sync_read_pos@GOTPAGE
Lloh3:
	ldr	x22, [x22, _sync_read_pos@GOTPAGEOFF]
	ldr	w9, [x22]
	sub	w24, w8, w9
	bl	_Util_time
Lloh4:
	adrp	x8, _last_audio_write_time@GOTPAGE
Lloh5:
	ldr	x8, [x8, _last_audio_write_time@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	sub	w8, w0, w8
Lloh7:
	adrp	x20, _Sound_out@GOTPAGE
Lloh8:
	ldr	x20, [x20, _Sound_out@GOTPAGEOFF]
	ldp	w9, w10, [x20]
	mul	w8, w8, w9
	mul	w8, w8, w10
	ldr	w9, [x20, #8]
	mul	w8, w8, w9
	subs	w8, w24, w8
	csel	w8, wzr, w8, lo
Lloh9:
	adrp	x9, _sync_est_fill@GOTPAGE
Lloh10:
	ldr	x9, [x9, _sync_est_fill@GOTPAGEOFF]
Lloh11:
	str	w8, [x9]
Lloh12:
	adrp	x9, _Atari800_turbo@GOTPAGE
Lloh13:
	ldr	x9, [x9, _Atari800_turbo@GOTPAGEOFF]
Lloh14:
	ldr	x9, [x9]
	cbz	x9, LBB0_2
; %bb.1:
Lloh15:
	adrp	x9, _sync_max_fill@GOTPAGE
Lloh16:
	ldr	x9, [x9, _sync_max_fill@GOTPAGEOFF]
Lloh17:
	ldr	w9, [x9]
	cmp	w8, w9
	b.hi	LBB0_10
LBB0_2:
	bl	_POKEYSND_UpdateProcessBuffer
	ldr	w8, [x20, #8]
	mul	w19, w8, w0
Lloh18:
	adrp	x23, _sync_buffer_size@GOTPAGE
Lloh19:
	ldr	x23, [x23, _sync_buffer_size@GOTPAGEOFF]
	ldr	w8, [x23]
	sub	w9, w8, w24
	cmp	w19, w9
	b.ls	LBB0_4
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	bl	_PLATFORM_SoundUnlock
	ldr	d0, [x20, #16]
	scvtf	d0, d0
	ldr	s1, [x20]
	ucvtf	d1, d1
	fdiv	d0, d0, d1
	bl	_Util_sleep
	bl	_PLATFORM_SoundLock
	bl	_WriteOut
	ldr	w9, [x21]
	ldr	w10, [x22]
	ldr	w8, [x23]
	sub	w10, w10, w9
	add	w10, w10, w8
	cmp	w19, w10
	b.hi	LBB0_3
	b	LBB0_5
LBB0_4:
	ldr	w9, [x21]
LBB0_5:
	add	w24, w9, w19
	udiv	w11, w24, w8
	udiv	w10, w9, w8
	cmp	w11, w10
	b.ne	LBB0_7
; %bb.6:
Lloh20:
	adrp	x11, _sync_buffer@GOTPAGE
Lloh21:
	ldr	x11, [x11, _sync_buffer@GOTPAGEOFF]
Lloh22:
	ldr	x11, [x11]
	msub	w8, w10, w8, w9
	add	x0, x11, x8
Lloh23:
	adrp	x8, _POKEYSND_process_buffer@GOTPAGE
Lloh24:
	ldr	x8, [x8, _POKEYSND_process_buffer@GOTPAGEOFF]
Lloh25:
	ldr	x1, [x8]
	mov	x2, x19
	b	LBB0_8
LBB0_7:
	msub	w9, w10, w8, w9
Lloh26:
	adrp	x25, _sync_buffer@GOTPAGE
Lloh27:
	ldr	x25, [x25, _sync_buffer@GOTPAGEOFF]
	sub	w20, w8, w9
	ldr	x8, [x25]
	add	x0, x8, x9
Lloh28:
	adrp	x26, _POKEYSND_process_buffer@GOTPAGE
Lloh29:
	ldr	x26, [x26, _POKEYSND_process_buffer@GOTPAGEOFF]
	ldr	x1, [x26]
	mov	x2, x20
	bl	_memcpy
	ldr	x0, [x25]
	ldr	x8, [x26]
	add	x1, x8, w20, sxtw
	sub	w2, w19, w20
LBB0_8:
	bl	_memcpy
	str	w24, [x21]
	ldr	w9, [x22]
	ldr	w8, [x23]
	add	w9, w8, w9
	cmp	w24, w9
	b.ls	LBB0_10
; %bb.9:
	sub	w8, w24, w8
	str	w8, [x21]
LBB0_10:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	b	_PLATFORM_SoundUnlock
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotStr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh28, Lloh29
	.loh AdrpLdrGot	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.comm	_sync_write_pos,4,2             ; @sync_write_pos
	.comm	_sync_read_pos,4,2              ; @sync_read_pos
	.comm	_last_audio_write_time,4,2      ; @last_audio_write_time
	.comm	_Sound_out,24,3                 ; @Sound_out
	.comm	_sync_est_fill,4,2              ; @sync_est_fill
	.comm	_Atari800_turbo,8,3             ; @Atari800_turbo
	.comm	_sync_max_fill,4,2              ; @sync_max_fill
	.comm	_sync_buffer_size,4,2           ; @sync_buffer_size
	.comm	_sync_buffer,8,3                ; @sync_buffer
	.comm	_POKEYSND_process_buffer,8,3    ; @POKEYSND_process_buffer
	.no_dead_strip	_UpdateSyncBuffer
.subsections_via_symbols
