	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function write_midi
_write_midi:                            ## @write_midi
	.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	%edx, %ebx
	testl	%edx, %edx
	setle	%al
	movq	_MIDI_OUT_BUFFER_SIZE@GOTPCREL(%rip), %rcx
	cmpl	%edx, (%rcx)
	movq	%rsi, %r15
	movq	%rdi, %r14
	setle	%cl
	orb	%al, %cl
	movzbl	%cl, %edi
	callq	_snd_BUG_ON
	testq	%rax, %rax
	je	LBB0_3
## %bb.1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_3:
	movq	%r14, %rdi
	callq	_wait_handshake
	testq	%rax, %rax
	je	LBB0_5
## %bb.4:
	movq	_EIO@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	movq	_CHI32_STATUS_REG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_get_dsp_register
	movq	_CHI32_STATUS_REG_HF4@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	je	LBB0_6
## %bb.7:
	movq	(%r14), %rax
	movq	(%rax), %rdi
	movl	%ebx, (%rdi)
	addq	$4, %rdi
	movq	%r15, %rsi
	movl	%ebx, %edx
	callq	_memcpy
	movq	(%r14), %rax
	movq	$0, 8(%rax)
	movq	%r14, %rdi
	callq	_clear_handshake
	movq	_DSP_VC_MIDI_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_send_vector
	movslq	%ebx, %rdi
	callq	_DE_MID
	jmp	LBB0_8
LBB0_6:
	xorl	%ebx, %ebx
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_MIDI_OUT_BUFFER_SIZE,4,2       ## @MIDI_OUT_BUFFER_SIZE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_EIO,4,2                        ## @EIO
	.comm	_CHI32_STATUS_REG,4,2           ## @CHI32_STATUS_REG
	.comm	_CHI32_STATUS_REG_HF4,4,2       ## @CHI32_STATUS_REG_HF4
	.comm	_DSP_VC_MIDI_WRITE,4,2          ## @DSP_VC_MIDI_WRITE
	.no_dead_strip	_write_midi
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function write_midi
_write_midi:                            ; @write_midi
	.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, x2
	mov	x21, x1
	mov	x20, x0
	cmp	w2, #1
Lloh0:
	adrp	x8, _MIDI_OUT_BUFFER_SIZE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MIDI_OUT_BUFFER_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	ccmp	w8, w2, #4, ge
	cset	w0, le
	bl	_snd_BUG_ON
	cbz	x0, LBB0_2
; %bb.1:
Lloh3:
	adrp	x8, _EINVAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_4
LBB0_2:
	mov	x0, x20
	bl	_wait_handshake
	cbz	x0, LBB0_6
; %bb.3:
Lloh5:
	adrp	x8, _EIO@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
LBB0_4:
	ldr	w8, [x8]
	neg	w19, w8
LBB0_5:
	mov	x0, x19
	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_6:
Lloh7:
	adrp	x8, _CHI32_STATUS_REG@GOTPAGE
Lloh8:
	ldr	x8, [x8, _CHI32_STATUS_REG@GOTPAGEOFF]
Lloh9:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_get_dsp_register
Lloh10:
	adrp	x8, _CHI32_STATUS_REG_HF4@GOTPAGE
Lloh11:
	ldr	x8, [x8, _CHI32_STATUS_REG_HF4@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_8
; %bb.7:
	ldr	x8, [x20]
	ldr	x0, [x8]
	str	w19, [x0], #4
	mov	x1, x21
	mov	x2, x19
	bl	_memcpy
	ldr	x8, [x20]
	str	xzr, [x8, #8]
	mov	x0, x20
	bl	_clear_handshake
Lloh13:
	adrp	x8, _DSP_VC_MIDI_WRITE@GOTPAGE
Lloh14:
	ldr	x8, [x8, _DSP_VC_MIDI_WRITE@GOTPAGEOFF]
Lloh15:
	ldr	w1, [x8]
	mov	x0, x20
	bl	_send_vector
	sxtw	x0, w19
	bl	_DE_MID
	b	LBB0_5
LBB0_8:
	mov	w19, #0
	b	LBB0_5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_MIDI_OUT_BUFFER_SIZE,4,2       ; @MIDI_OUT_BUFFER_SIZE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_EIO,4,2                        ; @EIO
	.comm	_CHI32_STATUS_REG,4,2           ; @CHI32_STATUS_REG
	.comm	_CHI32_STATUS_REG_HF4,4,2       ; @CHI32_STATUS_REG_HF4
	.comm	_DSP_VC_MIDI_WRITE,4,2          ; @DSP_VC_MIDI_WRITE
	.no_dead_strip	_write_midi
.subsections_via_symbols
