	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_SN76489_Write                  ## -- Begin function SN76489_Write
	.p2align	4, 0x90
_SN76489_Write:                         ## @SN76489_Write
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r14d
	movq	_SN76489@GOTPCREL(%rip), %r15
	cmpl	%edi, (%r15)
	jae	LBB0_2
## %bb.1:
	movl	%edi, %ebx
	callq	_SN76489_RunUntil
	movl	(%r15), %esi
	movq	_PSG_MCYCLES_RATIO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%esi, %ecx
	notl	%ecx
	addl	%ebx, %ecx
	addl	%edi, %ecx
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%edi
	subl	%edx, %esi
	addl	%ecx, %esi
	movl	%esi, (%r15)
LBB0_2:
	testb	$-128, %r14b
	jne	LBB0_3
## %bb.4:
	movl	4(%r15), %ecx
	cmpl	$7, %ecx
	jbe	LBB0_6
	jmp	LBB0_15
LBB0_3:
	movl	%r14d, %ecx
	shrl	$4, %ecx
	andl	$7, %ecx
	movl	%ecx, 4(%r15)
	cmpl	$7, %ecx
	ja	LBB0_15
LBB0_6:
	movl	%ecx, %eax
	leaq	LJTI0_0(%rip), %rdx
	movslq	(%rdx,%rax,4), %rsi
	addq	%rdx, %rsi
	jmpq	*%rsi
LBB0_7:
	movq	8(%r15), %rcx
	movl	(%rcx,%rax,4), %edx
	testb	$-128, %r14b
	jne	LBB0_8
## %bb.9:
	andl	$15, %edx
	andl	$63, %r14d
	shll	$4, %r14d
	jmp	LBB0_10
LBB0_11:
	andl	$15, %r14d
	movq	8(%r15), %rdx
	movl	%r14d, (%rdx,%rax,4)
	movq	_PSGVolumeValues@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%r14,4), %eax
	shrl	%ecx
	movq	16(%r15), %rdx
	movq	24(%r15), %rsi
	movq	(%rsi,%rcx,8), %rsi
	movl	(%rsi), %edi
	imull	%eax, %edi
	imulq	$1374389535, %rdi, %rdi         ## imm = 0x51EB851F
	shrq	$37, %rdi
	movq	(%rdx,%rcx,8), %rcx
	movl	%edi, (%rcx)
	imull	4(%rsi), %eax
	jmp	LBB0_14
LBB0_8:
	andl	$1008, %edx                     ## imm = 0x3F0
	andl	$15, %r14d
LBB0_10:
	orl	%edx, %r14d
	testl	%r14d, %r14d
	movl	$1, %edx
	cmovnel	%r14d, %edx
	movl	%edx, (%rcx,%rax,4)
	jmp	LBB0_15
LBB0_12:
	movl	%r14d, %eax
	andl	$15, %eax
	movq	8(%r15), %rcx
	movl	%eax, 24(%rcx)
	movq	_NoiseInitialState@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 36(%r15)
	andb	$3, %r14b
	movl	$16, %eax
	movl	%r14d, %ecx
	shll	%cl, %eax
	movl	%eax, 32(%r15)
	jmp	LBB0_15
LBB0_13:
	andl	$15, %r14d
	movq	8(%r15), %rax
	movl	%r14d, 28(%rax)
	movq	_PSGVolumeValues@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movl	(%rax,%r14,4), %eax
	movq	16(%r15), %rcx
	movq	24(%r15), %rdx
	movq	24(%rdx), %rdx
	movl	(%rdx), %esi
	imull	%eax, %esi
	imulq	$1374389535, %rsi, %rsi         ## imm = 0x51EB851F
	shrq	$37, %rsi
	movq	24(%rcx), %rcx
	movl	%esi, (%rcx)
	imull	4(%rdx), %eax
LBB0_14:
	imulq	$1374389535, %rax, %rax         ## imm = 0x51EB851F
	shrq	$37, %rax
	movl	%eax, 4(%rcx)
LBB0_15:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
	.p2align	2, 0x90
	.data_region jt32
.set L0_0_set_7, LBB0_7-LJTI0_0
.set L0_0_set_11, LBB0_11-LJTI0_0
.set L0_0_set_12, LBB0_12-LJTI0_0
.set L0_0_set_13, LBB0_13-LJTI0_0
LJTI0_0:
	.long	L0_0_set_7
	.long	L0_0_set_11
	.long	L0_0_set_7
	.long	L0_0_set_11
	.long	L0_0_set_7
	.long	L0_0_set_11
	.long	L0_0_set_12
	.long	L0_0_set_13
	.end_data_region
                                        ## -- End function
	.comm	_SN76489,40,3                   ## @SN76489
	.comm	_PSG_MCYCLES_RATIO,4,2          ## @PSG_MCYCLES_RATIO
	.comm	_PSGVolumeValues,8,3            ## @PSGVolumeValues
	.comm	_NoiseInitialState,4,2          ## @NoiseInitialState
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_SN76489_Write                  ; -- Begin function SN76489_Write
	.p2align	2
_SN76489_Write:                         ; @SN76489_Write
	.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	x19, x1
Lloh0:
	adrp	x21, _SN76489@GOTPAGE
Lloh1:
	ldr	x21, [x21, _SN76489@GOTPAGEOFF]
	ldr	w8, [x21]
	cmp	w8, w0
	b.hs	LBB0_2
; %bb.1:
	mov	x20, x0
	bl	_SN76489_RunUntil
	ldr	w8, [x21]
Lloh2:
	adrp	x9, _PSG_MCYCLES_RATIO@GOTPAGE
Lloh3:
	ldr	x9, [x9, _PSG_MCYCLES_RATIO@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	mvn	w10, w8
	add	w10, w10, w20
	add	w10, w10, w9
	udiv	w11, w10, w9
	neg	w12, w10
	madd	w9, w11, w9, w12
	add	w8, w8, w9
	add	w8, w8, w10
	str	w8, [x21]
LBB0_2:
	tbnz	w19, #7, LBB0_4
; %bb.3:
	ldr	w8, [x21, #4]
	cmp	w8, #7
	b.ls	LBB0_5
	b	LBB0_10
LBB0_4:
	ubfx	w8, w19, #4, #3
	str	w8, [x21, #4]
	cmp	w8, #7
	b.hi	LBB0_10
LBB0_5:
	mov	w9, w8
Lloh5:
	adrp	x10, lJTI0_0@PAGE
Lloh6:
	add	x10, x10, lJTI0_0@PAGEOFF
	adr	x11, LBB0_6
	ldrb	w12, [x10, x9]
	add	x11, x11, x12, lsl #2
	br	x11
LBB0_6:
	ldr	x10, [x21, #8]
	ldr	w8, [x10, w8, uxtw #2]
	and	w11, w8, #0xf
	bfi	w11, w19, #4, #6
	and	w8, w8, #0x3f0
	bfxil	w8, w19, #0, #4
	tst	w19, #0x80
	csel	w8, w11, w8, eq
	cmp	w8, #0
	csinc	w8, w8, wzr, ne
	str	w8, [x10, x9, lsl #2]
	b	LBB0_10
LBB0_7:
	and	w9, w19, #0xf
	ldp	x10, x11, [x21, #8]
	str	w9, [x10, w8, uxtw #2]
Lloh7:
	adrp	x10, _PSGVolumeValues@GOTPAGE
Lloh8:
	ldr	x10, [x10, _PSGVolumeValues@GOTPAGEOFF]
Lloh9:
	ldr	x10, [x10]
	ldr	w9, [x10, w9, uxtw #2]
	lsr	w8, w8, #1
	ldr	x10, [x21, #24]
	lsl	x8, x8, #3
	ldr	x10, [x10, x8]
	ldr	w12, [x10]
	mul	w12, w12, w9
	mov	w13, #34079
	movk	w13, #20971, lsl #16
	umull	x12, w12, w13
	lsr	x12, x12, #37
	ldr	x8, [x11, x8]
	str	w12, [x8]
	ldr	w10, [x10, #4]
	mul	w9, w10, w9
	umull	x9, w9, w13
	lsr	x9, x9, #37
	str	w9, [x8, #4]
	b	LBB0_10
LBB0_8:
	and	w8, w19, #0xf
	ldr	x9, [x21, #8]
	str	w8, [x9, #24]
Lloh10:
	adrp	x8, _NoiseInitialState@GOTPAGE
Lloh11:
	ldr	x8, [x8, _NoiseInitialState@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	and	w9, w19, #0x3
	mov	w10, #16
	lsl	w9, w10, w9
	stp	w9, w8, [x21, #32]
	b	LBB0_10
LBB0_9:
	and	w8, w19, #0xf
Lloh13:
	adrp	x9, _PSGVolumeValues@GOTPAGE
Lloh14:
	ldr	x9, [x9, _PSGVolumeValues@GOTPAGEOFF]
	ldp	x10, x11, [x21, #8]
	str	w8, [x10, #28]
Lloh15:
	ldr	x9, [x9]
	ldr	w8, [x9, w8, uxtw #2]
	ldr	x9, [x21, #24]
	ldr	x9, [x9, #24]
	ldr	w10, [x9]
	mul	w10, w10, w8
	mov	w12, #34079
	movk	w12, #20971, lsl #16
	umull	x10, w10, w12
	lsr	x10, x10, #37
	ldr	x11, [x11, #24]
	str	w10, [x11]
	ldr	w9, [x9, #4]
	mul	w8, w9, w8
	umull	x8, w8, w12
	lsr	x8, x8, #37
	str	w8, [x11, #4]
LBB0_10:
	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
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
	.section	__TEXT,__const
lJTI0_0:
	.byte	(LBB0_6-LBB0_6)>>2
	.byte	(LBB0_7-LBB0_6)>>2
	.byte	(LBB0_6-LBB0_6)>>2
	.byte	(LBB0_7-LBB0_6)>>2
	.byte	(LBB0_6-LBB0_6)>>2
	.byte	(LBB0_7-LBB0_6)>>2
	.byte	(LBB0_8-LBB0_6)>>2
	.byte	(LBB0_9-LBB0_6)>>2
                                        ; -- End function
	.comm	_SN76489,40,3                   ; @SN76489
	.comm	_PSG_MCYCLES_RATIO,4,2          ; @PSG_MCYCLES_RATIO
	.comm	_PSGVolumeValues,8,3            ; @PSGVolumeValues
	.comm	_NoiseInitialState,4,2          ; @NoiseInitialState
.subsections_via_symbols
