	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Sound_Setup                    ## -- Begin function Sound_Setup
	.p2align	4, 0x90
_Sound_Setup:                           ## @Sound_Setup
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_POKEYSND_enable_new_pokey@GOTPCREL(%rip), %r15
	cmpq	$0, (%r15)
	movq	_Sound_desired@GOTPCREL(%rip), %r14
	movl	(%r14), %eax
	je	LBB0_2
## %bb.1:
	movl	$8192, %ecx                     ## imm = 0x2000
	cmpl	$8192, %eax                     ## imm = 0x2000
	jl	LBB0_4
LBB0_2:
	movl	$1000, %ecx                     ## imm = 0x3E8
	cmpl	$1000, %eax                     ## imm = 0x3E8
	jl	LBB0_4
## %bb.3:
	movl	$65535, %ecx                    ## imm = 0xFFFF
	cmpl	$65536, %eax                    ## imm = 0x10000
	jb	LBB0_5
LBB0_4:
	movl	%ecx, (%r14)
LBB0_5:
	movl	4(%r14), %ecx
	testl	%ecx, %ecx
	je	LBB0_10
## %bb.6:
	movl	%ecx, %eax
	cmpl	$1, %ecx
	je	LBB0_9
## %bb.7:
	movl	$1, %eax
	movl	%ecx, %edx
	movl	%ecx, %esi
	.p2align	4, 0x90
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	shrl	%esi
	addl	%eax, %eax
	cmpl	$3, %edx
	movl	%esi, %edx
	ja	LBB0_8
LBB0_9:
	cmpl	%ecx, %eax
	setb	%cl
	shll	%cl, %eax
	cmpl	$17, %eax
	movl	$16, %ecx
	cmovael	%eax, %ecx
	movl	%ecx, 4(%r14)
LBB0_10:
	movl	(%r14), %eax
	movl	4(%r14), %ecx
	movq	8(%r14), %rdx
	movq	_Sound_out@GOTPCREL(%rip), %rbx
	movl	%eax, (%rbx)
	movl	%ecx, 4(%rbx)
	movq	%rdx, 8(%rbx)
	movq	%rbx, %rdi
	callq	_PLATFORM_SoundSetup
	movq	_Sound_enabled@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	movq	_FALSE@GOTPCREL(%rip), %r12
	testl	%eax, %eax
	je	LBB0_21
## %bb.11:
	cmpq	$0, (%r15)
	setne	%al
	movl	(%rbx), %esi
	cmpl	$8192, %esi                     ## imm = 0x2000
	setl	%cl
	testb	%cl, %al
	jne	LBB0_14
## %bb.12:
	cmpl	$1000, %esi                     ## imm = 0x3E8
	jl	LBB0_14
## %bb.13:
	cmpl	$65536, %esi                    ## imm = 0x10000
	jge	LBB0_14
## %bb.16:
	movl	8(%rbx), %esi
	movq	_MAX_CHANNELS@GOTPCREL(%rip), %rax
	cmpl	(%rax), %esi
	jle	LBB0_18
## %bb.17:
	leaq	L_.str.1(%rip), %rdi
	jmp	LBB0_15
LBB0_14:
	leaq	L_.str(%rip), %rdi
LBB0_15:
	callq	_Log_print
	xorl	%eax, %eax
	callq	_Sound_Exit
	jmp	LBB0_21
LBB0_18:
	xorl	%eax, %eax
	cmpl	$2, %esi
	sete	%al
	movq	_POKEYSND_stereo_enabled@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	movq	_process_buffer@GOTPCREL(%rip), %r15
	movl	(%r15), %edi
	callq	_free
	movl	8(%rbx), %edi
	imull	4(%rbx), %edi
	imull	12(%rbx), %edi
	movq	_process_buffer_size@GOTPCREL(%rip), %rax
	movl	%edi, (%rax)
	callq	_Util_malloc
	movl	%eax, (%r15)
	movq	_POKEYSND_FREQ_17_EXACT@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	(%rbx), %esi
	movl	8(%rbx), %edx
	xorl	%ecx, %ecx
	cmpl	$2, 12(%rbx)
	jne	LBB0_20
## %bb.19:
	movq	_POKEYSND_BIT16@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
LBB0_20:
	callq	_POKEYSND_Init
	movl	(%rbx), %eax
	movl	%eax, (%r14)
	movq	8(%rbx), %rax
	movq	%rax, 8(%r14)
	movq	_TRUE@GOTPCREL(%rip), %r12
	movl	(%r12), %eax
	movq	_paused@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
LBB0_21:
	movl	(%r12), %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_POKEYSND_enable_new_pokey,8,3  ## @POKEYSND_enable_new_pokey
	.comm	_Sound_desired,16,2             ## @Sound_desired
	.comm	_Sound_out,16,2                 ## @Sound_out
	.comm	_Sound_enabled,4,2              ## @Sound_enabled
	.comm	_FALSE,4,2                      ## @FALSE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%d frequency not supported"

	.comm	_MAX_CHANNELS,4,2               ## @MAX_CHANNELS
L_.str.1:                               ## @.str.1
	.asciz	"%d channels not supported"

	.comm	_POKEYSND_stereo_enabled,4,2    ## @POKEYSND_stereo_enabled
	.comm	_process_buffer,4,2             ## @process_buffer
	.comm	_process_buffer_size,4,2        ## @process_buffer_size
	.comm	_POKEYSND_FREQ_17_EXACT,4,2     ## @POKEYSND_FREQ_17_EXACT
	.comm	_POKEYSND_BIT16,4,2             ## @POKEYSND_BIT16
	.comm	_TRUE,4,2                       ## @TRUE
	.comm	_paused,4,2                     ## @paused
	.comm	_Sound_latency,4,2              ## @Sound_latency
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Sound_Setup                    ; -- Begin function Sound_Setup
	.p2align	2
_Sound_Setup:                           ; @Sound_Setup
	.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
Lloh0:
	adrp	x21, _POKEYSND_enable_new_pokey@GOTPAGE
Lloh1:
	ldr	x21, [x21, _POKEYSND_enable_new_pokey@GOTPAGEOFF]
	ldr	x9, [x21]
Lloh2:
	adrp	x20, _Sound_desired@GOTPAGE
Lloh3:
	ldr	x20, [x20, _Sound_desired@GOTPAGEOFF]
	ldr	w8, [x20]
	cbz	x9, LBB0_3
; %bb.1:
	cmp	w8, #2, lsl #12                 ; =8192
	b.ge	LBB0_3
; %bb.2:
	mov	w8, #8192
	b	LBB0_7
LBB0_3:
	cmp	w8, #1000
	b.ge	LBB0_5
; %bb.4:
	mov	w8, #1000
	b	LBB0_7
LBB0_5:
	cmp	w8, #16, lsl #12                ; =65536
	b.lo	LBB0_8
; %bb.6:
	mov	w8, #65535
LBB0_7:
	str	w8, [x20]
LBB0_8:
	ldr	w8, [x20, #4]
	cbz	w8, LBB0_14
; %bb.9:
	cmp	w8, #1
	b.ne	LBB0_11
; %bb.10:
	mov	x9, x8
	b	LBB0_13
LBB0_11:
	mov	w9, #1
	mov	x10, x8
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	lsr	w11, w10, #1
	lsl	w9, w9, #1
	cmp	w10, #3
	mov	x10, x11
	b.hi	LBB0_12
LBB0_13:
	cmp	w9, w8
	cset	w8, lo
	lsl	w8, w9, w8
	mov	w9, #16
	cmp	w8, #16
	csel	w8, w8, w9, hi
	str	w8, [x20, #4]
LBB0_14:
	ldr	q0, [x20]
Lloh4:
	adrp	x19, _Sound_out@GOTPAGE
Lloh5:
	ldr	x19, [x19, _Sound_out@GOTPAGEOFF]
	str	q0, [x19]
	mov	x0, x19
	bl	_PLATFORM_SoundSetup
Lloh6:
	adrp	x8, _Sound_enabled@GOTPAGE
Lloh7:
	ldr	x8, [x8, _Sound_enabled@GOTPAGEOFF]
Lloh8:
	str	w0, [x8]
	cbz	w0, LBB0_22
; %bb.15:
	ldr	x8, [x21]
	ldr	w1, [x19]
	cmp	w1, #2, lsl #12                 ; =8192
	ccmp	x8, #0, #4, lt
	b.ne	LBB0_20
; %bb.16:
	cmp	w1, #1000
	b.lt	LBB0_20
; %bb.17:
	cmp	w1, #16, lsl #12                ; =65536
	b.ge	LBB0_20
; %bb.18:
	ldr	w1, [x19, #8]
Lloh9:
	adrp	x8, _MAX_CHANNELS@GOTPAGE
Lloh10:
	ldr	x8, [x8, _MAX_CHANNELS@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	cmp	w1, w8
	b.le	LBB0_24
; %bb.19:
Lloh12:
	adrp	x0, l_.str.1@PAGE
Lloh13:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_21
LBB0_20:
Lloh14:
	adrp	x0, l_.str@PAGE
Lloh15:
	add	x0, x0, l_.str@PAGEOFF
LBB0_21:
	bl	_Log_print
	bl	_Sound_Exit
LBB0_22:
Lloh16:
	adrp	x8, _FALSE@GOTPAGE
Lloh17:
	ldr	x8, [x8, _FALSE@GOTPAGEOFF]
LBB0_23:
	ldr	w0, [x8]
	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
LBB0_24:
	cmp	w1, #2
	cset	w8, eq
Lloh18:
	adrp	x9, _POKEYSND_stereo_enabled@GOTPAGE
Lloh19:
	ldr	x9, [x9, _POKEYSND_stereo_enabled@GOTPAGEOFF]
Lloh20:
	str	w8, [x9]
Lloh21:
	adrp	x21, _process_buffer@GOTPAGE
Lloh22:
	ldr	x21, [x21, _process_buffer@GOTPAGEOFF]
	ldr	w0, [x21]
	bl	_free
	ldp	w8, w9, [x19, #4]
	mul	w8, w9, w8
	ldr	w9, [x19, #12]
	mul	w0, w8, w9
Lloh23:
	adrp	x8, _process_buffer_size@GOTPAGE
Lloh24:
	ldr	x8, [x8, _process_buffer_size@GOTPAGEOFF]
Lloh25:
	str	w0, [x8]
	bl	_Util_malloc
	str	w0, [x21]
Lloh26:
	adrp	x8, _POKEYSND_FREQ_17_EXACT@GOTPAGE
Lloh27:
	ldr	x8, [x8, _POKEYSND_FREQ_17_EXACT@GOTPAGEOFF]
Lloh28:
	ldr	w0, [x8]
	ldr	w1, [x19]
	ldp	w2, w8, [x19, #8]
Lloh29:
	adrp	x9, _POKEYSND_BIT16@GOTPAGE
Lloh30:
	ldr	x9, [x9, _POKEYSND_BIT16@GOTPAGEOFF]
Lloh31:
	ldr	w9, [x9]
	cmp	w8, #2
	csel	w3, w9, wzr, eq
	bl	_POKEYSND_Init
	ldr	w8, [x19]
	str	w8, [x20]
	ldr	d0, [x19, #8]
	str	d0, [x20, #8]
Lloh32:
	adrp	x8, _TRUE@GOTPAGE
Lloh33:
	ldr	x8, [x8, _TRUE@GOTPAGEOFF]
	ldr	w9, [x8]
Lloh34:
	adrp	x10, _paused@GOTPAGE
Lloh35:
	ldr	x10, [x10, _paused@GOTPAGEOFF]
Lloh36:
	str	w9, [x10]
	b	LBB0_23
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotStr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGotStr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGot	Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotStr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpLdrGotStr	Lloh18, Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_POKEYSND_enable_new_pokey,8,3  ; @POKEYSND_enable_new_pokey
	.comm	_Sound_desired,16,2             ; @Sound_desired
	.comm	_Sound_out,16,2                 ; @Sound_out
	.comm	_Sound_enabled,4,2              ; @Sound_enabled
	.comm	_FALSE,4,2                      ; @FALSE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%d frequency not supported"

	.comm	_MAX_CHANNELS,4,2               ; @MAX_CHANNELS
l_.str.1:                               ; @.str.1
	.asciz	"%d channels not supported"

	.comm	_POKEYSND_stereo_enabled,4,2    ; @POKEYSND_stereo_enabled
	.comm	_process_buffer,4,2             ; @process_buffer
	.comm	_process_buffer_size,4,2        ; @process_buffer_size
	.comm	_POKEYSND_FREQ_17_EXACT,4,2     ; @POKEYSND_FREQ_17_EXACT
	.comm	_POKEYSND_BIT16,4,2             ; @POKEYSND_BIT16
	.comm	_TRUE,4,2                       ; @TRUE
	.comm	_paused,4,2                     ; @paused
	.comm	_Sound_latency,4,2              ; @Sound_latency
.subsections_via_symbols
