	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_YM2612Write_940                ## -- Begin function YM2612Write_940
	.p2align	4, 0x90
_YM2612Write_940:                       ## @YM2612Write_940
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	movl	%esi, %eax
	movl	%edi, %esi
	andl	$3, %esi
	cmpl	$2, %esi
	je	LBB0_7
## %bb.1:
	testl	%esi, %esi
	jne	LBB0_2
## %bb.3:
	movq	_addr_A1@GOTPCREL(%rip), %rcx
	cmpl	$0, (%rcx)
	movq	_ST_address@GOTPCREL(%rip), %rdi
	jne	LBB0_5
## %bb.4:
	cmpl	%eax, (%rdi)
	je	LBB0_19
LBB0_5:
	movl	%eax, (%rdi)
	movl	$0, (%rcx)
	movb	$1, %r10b
	cmpl	$42, %eax
	ja	LBB0_10
## %bb.6:
	movl	%eax, %r8d
	movabsq	$4879082848256, %rdi            ## imm = 0x47000000000
	btq	%r8, %rdi
	jb	LBB0_19
	jmp	LBB0_10
LBB0_7:
	movq	_addr_A1@GOTPCREL(%rip), %rcx
	cmpl	$1, (%rcx)
	movq	_ST_address@GOTPCREL(%rip), %rdi
	jne	LBB0_9
## %bb.8:
	cmpl	%eax, (%rdi)
	je	LBB0_19
LBB0_9:
	movl	%eax, (%rdi)
	movl	$1, (%rcx)
	movb	$1, %r10b
	jmp	LBB0_10
LBB0_2:
	xorl	%r10d, %r10d
LBB0_10:
	movq	_currentConfig@GOTPCREL(%rip), %rdi
	testb	$4, (%rdi)
	je	LBB0_19
## %bb.11:
	movq	_shared_ctl@GOTPCREL(%rip), %rdi
	movq	(%rdi), %rdi
	xorl	%ecx, %ecx
	cmpq	$0, 16(%rdi)
	sete	%cl
	movq	(%rdi,%rcx,8), %r9
	movq	_writebuff_ptr@GOTPCREL(%rip), %r8
	movl	(%r8), %edi
	testb	%r10b, %r10b
	jne	LBB0_16
## %bb.12:
	cmpl	$223, %edx
	jg	LBB0_16
## %bb.13:
	testl	%edi, %edi
	js	LBB0_16
## %bb.14:
	movq	_Pico@GOTPCREL(%rip), %rcx
	cmpq	$0, (%rcx)
	movl	$93, %r10d
	movl	$68, %ecx
	cmovel	%r10d, %ecx
	cmpl	%edx, %ecx
	jge	LBB0_16
## %bb.15:
	movzwl	%di, %ecx
	movl	%edi, %edx
	incl	%edx
	movl	%edx, (%r8)
	movl	$65534, (%r9,%rcx,4)            ## imm = 0xFFFE
	movl	$-2147483648, %edi              ## imm = 0x80000000
	orl	(%r8), %edi
	movl	%edi, (%r8)
LBB0_16:
	movzwl	%di, %ecx
	cmpl	$2046, %ecx                     ## imm = 0x7FE
	ja	LBB0_18
## %bb.17:
	shll	$8, %esi
	orl	%eax, %esi
	incl	%edi
	movl	%edi, (%r8)
	movl	%ecx, %eax
	movl	%esi, (%r9,%rax,4)
	jmp	LBB0_19
LBB0_18:
	leaq	L_.str(%rip), %rdi
	movl	%eax, %edx
	callq	_printf
LBB0_19:
	xorl	%eax, %eax
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_addr_A1,4,2                    ## @addr_A1
	.comm	_ST_address,4,2                 ## @ST_address
	.comm	_currentConfig,4,2              ## @currentConfig
	.comm	_shared_ctl,8,3                 ## @shared_ctl
	.comm	_writebuff_ptr,4,2              ## @writebuff_ptr
	.comm	_Pico,8,3                       ## @Pico
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"warning: writebuff_ptr > 2047 ([%i] %02x)\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_YM2612Write_940                ; -- Begin function YM2612Write_940
	.p2align	2
_YM2612Write_940:                       ; @YM2612Write_940
	.cfi_startproc
; %bb.0:
	stp	x29, x30, [sp, #-16]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	mov	x29, sp
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	mov	x8, x1
	and	w1, w0, #0x3
	cmp	w1, #2
	b.eq	LBB0_5
; %bb.1:
	cbnz	w1, LBB0_7
; %bb.2:
Lloh0:
	adrp	x9, _addr_A1@GOTPAGE
Lloh1:
	ldr	x9, [x9, _addr_A1@GOTPAGEOFF]
	ldr	w11, [x9]
Lloh2:
	adrp	x10, _ST_address@GOTPAGE
Lloh3:
	ldr	x10, [x10, _ST_address@GOTPAGEOFF]
	ldr	w12, [x10]
	cmp	w11, #0
	ccmp	w12, w8, #0, eq
	b.eq	LBB0_17
; %bb.3:
	str	w8, [x10]
	str	wzr, [x9]
	mov	w12, #1
	cmp	w8, #42
	b.hi	LBB0_8
; %bb.4:
	mov	w9, w8
	mov	w10, #1
	lsl	x9, x10, x9
	mov	x10, #4879082848256
	tst	x9, x10
	b.ne	LBB0_17
	b	LBB0_8
LBB0_5:
Lloh4:
	adrp	x9, _addr_A1@GOTPAGE
Lloh5:
	ldr	x9, [x9, _addr_A1@GOTPAGEOFF]
	ldr	w11, [x9]
Lloh6:
	adrp	x10, _ST_address@GOTPAGE
Lloh7:
	ldr	x10, [x10, _ST_address@GOTPAGEOFF]
	ldr	w12, [x10]
	cmp	w11, #1
	ccmp	w12, w8, #0, eq
	b.eq	LBB0_17
; %bb.6:
	str	w8, [x10]
	mov	w12, #1
	str	w12, [x9]
	b	LBB0_8
LBB0_7:
	mov	w12, #0
LBB0_8:
Lloh8:
	adrp	x9, _currentConfig@GOTPAGE
Lloh9:
	ldr	x9, [x9, _currentConfig@GOTPAGEOFF]
	ldrb	w9, [x9]
	tbz	w9, #2, LBB0_17
; %bb.9:
Lloh10:
	adrp	x9, _shared_ctl@GOTPAGE
Lloh11:
	ldr	x9, [x9, _shared_ctl@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
	ldr	x10, [x9, #16]
	cmp	x10, #0
	cset	w10, eq
	ldr	x9, [x9, w10, uxtw #3]
Lloh13:
	adrp	x10, _writebuff_ptr@GOTPAGE
Lloh14:
	ldr	x10, [x10, _writebuff_ptr@GOTPAGEOFF]
	ldr	w11, [x10]
	tbnz	w12, #0, LBB0_14
; %bb.10:
	cmp	w2, #223
	b.gt	LBB0_14
; %bb.11:
	tbnz	w11, #31, LBB0_14
; %bb.12:
Lloh15:
	adrp	x12, _Pico@GOTPAGE
Lloh16:
	ldr	x12, [x12, _Pico@GOTPAGEOFF]
Lloh17:
	ldr	x12, [x12]
	cmp	x12, #0
	mov	w12, #68
	mov	w13, #93
	csel	w12, w13, w12, eq
	cmp	w12, w2
	b.ge	LBB0_14
; %bb.13:
	add	w12, w11, #1
	str	w12, [x10]
	and	x11, x11, #0xffff
	mov	w12, #65534
	str	w12, [x9, x11, lsl #2]
	ldr	w11, [x10]
	orr	w11, w11, #0x80000000
	str	w11, [x10]
LBB0_14:
	and	w12, w11, #0xffff
	cmp	w12, #2046
	b.hi	LBB0_16
; %bb.15:
	orr	w8, w8, w1, lsl #8
	add	w11, w11, #1
	str	w11, [x10]
	str	w8, [x9, w12, uxtw #2]
	b	LBB0_17
LBB0_16:
Lloh18:
	adrp	x0, l_.str@PAGE
Lloh19:
	add	x0, x0, l_.str@PAGEOFF
	mov	x2, x8
	bl	_printf
LBB0_17:
	mov	w0, #0
	ldp	x29, x30, [sp], #16             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_addr_A1,4,2                    ; @addr_A1
	.comm	_ST_address,4,2                 ; @ST_address
	.comm	_currentConfig,4,2              ; @currentConfig
	.comm	_shared_ctl,8,3                 ; @shared_ctl
	.comm	_writebuff_ptr,4,2              ; @writebuff_ptr
	.comm	_Pico,8,3                       ; @Pico
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"warning: writebuff_ptr > 2047 ([%i] %02x)\n"

.subsections_via_symbols
