	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ttyflush                       ## -- Begin function ttyflush
	.p2align	4, 0x90
_ttyflush:                              ## @ttyflush
	.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
	movl	%edi, %r12d
	movq	_ttyoring@GOTPCREL(%rip), %r15
	movq	%r15, %rdi
	callq	_ring_full_count
	movl	%eax, %r14d
	movq	%r15, %rdi
	callq	_ring_full_consecutive
	movl	%eax, %r13d
	testl	%eax, %eax
	jle	LBB0_1
## %bb.6:
	testl	%r12d, %r12d
	je	LBB0_8
## %bb.7:
	xorl	%eax, %eax
	callq	_TerminalFlushOutput
	movl	%r13d, %ebx
	jmp	LBB0_9
LBB0_1:
	movl	%r13d, %eax
LBB0_2:
	xorl	%ebx, %ebx
	testl	%eax, %eax
	jns	LBB0_17
## %bb.3:
	movq	_errno@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	movq	_EAGAIN@GOTPCREL(%rip), %rdx
	movl	$-1, %eax
	cmpq	(%rdx), %rcx
	je	LBB0_20
## %bb.4:
	movq	_EINTR@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	je	LBB0_20
## %bb.5:
	movq	_ttyoring@GOTPCREL(%rip), %rbx
	movq	%rbx, %rdi
	callq	_ring_full_count
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ring_consumed
	xorl	%edi, %edi
	callq	_setconnmode
	xorl	%eax, %eax
	callq	_setcommandmode
	movq	_net@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_NetClose
	movq	_stderr@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_fprintf
	movl	$1, %edi
	callq	_exit
LBB0_8:
	movl	4(%r15), %edi
	movl	%r13d, %esi
	callq	_TerminalWrite
	movl	%eax, %ebx
	testl	%eax, %eax
	jle	LBB0_2
LBB0_9:
	movq	_termdata@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_11
## %bb.10:
	movl	4(%r15), %esi
	movl	$62, %edi
	movl	%ebx, %edx
	callq	_Dump
LBB0_11:
	cmpl	%ebx, %r13d
	jne	LBB0_16
## %bb.12:
	cmpl	%ebx, %r14d
	jle	LBB0_16
## %bb.13:
	movl	%r14d, %eax
	subl	%r13d, %eax
	testl	%r12d, %r12d
	jne	LBB0_15
## %bb.14:
	movl	(%r15), %edi
	movl	%eax, %esi
	callq	_TerminalWrite
LBB0_15:
	xorl	%ebx, %ebx
	testl	%eax, %eax
	cmovgl	%eax, %ebx
	addl	%r13d, %ebx
LBB0_16:
	movq	_ttyoring@GOTPCREL(%rip), %rdi
	movl	%ebx, %esi
	callq	_ring_consumed
LBB0_17:
	movl	%r14d, %eax
	subl	%ebx, %eax
	jne	LBB0_19
## %bb.18:
	xorl	%eax, %eax
	negl	%r14d
	sbbl	%eax, %eax
	jmp	LBB0_20
LBB0_19:
	incl	%eax
LBB0_20:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ttyoring,8,2                   ## @ttyoring
	.comm	_termdata,8,3                   ## @termdata
	.comm	_errno,8,3                      ## @errno
	.comm	_EAGAIN,8,3                     ## @EAGAIN
	.comm	_EINTR,8,3                      ## @EINTR
	.comm	_net,4,2                        ## @net
	.comm	_stderr,4,2                     ## @stderr
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Write error on local output.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ttyflush                       ; -- Begin function ttyflush
	.p2align	2
_ttyflush:                              ; @ttyflush
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	mov	x21, x0
Lloh0:
	adrp	x22, _ttyoring@GOTPAGE
Lloh1:
	ldr	x22, [x22, _ttyoring@GOTPAGEOFF]
	mov	x0, x22
	bl	_ring_full_count
	mov	x19, x0
	mov	x0, x22
	bl	_ring_full_consecutive
	mov	x20, x0
	cmp	w0, #1
	b.lt	LBB0_3
; %bb.1:
	cbz	w21, LBB0_6
; %bb.2:
	bl	_TerminalFlushOutput
	mov	x23, x20
	b	LBB0_7
LBB0_3:
	mov	x23, x20
LBB0_4:
	tbnz	w23, #31, LBB0_16
; %bb.5:
	mov	w23, #0
	b	LBB0_14
LBB0_6:
	ldr	w0, [x22, #4]
	mov	x1, x20
	bl	_TerminalWrite
	mov	x23, x0
	cmp	w0, #1
	b.lt	LBB0_4
LBB0_7:
Lloh2:
	adrp	x8, _termdata@GOTPAGE
Lloh3:
	ldr	x8, [x8, _termdata@GOTPAGEOFF]
Lloh4:
	ldr	x8, [x8]
	cbz	x8, LBB0_9
; %bb.8:
	ldr	w1, [x22, #4]
	mov	w0, #62
	mov	x2, x23
	bl	_Dump
LBB0_9:
	cmp	w20, w23
	ccmp	w19, w23, #4, eq
	b.le	LBB0_13
; %bb.10:
	sub	w1, w19, w20
	cbnz	w21, LBB0_12
; %bb.11:
	ldr	w0, [x22]
	bl	_TerminalWrite
	mov	x1, x0
LBB0_12:
	cmp	w1, #0
	csel	w8, w1, wzr, gt
	add	w23, w8, w20
LBB0_13:
Lloh5:
	adrp	x0, _ttyoring@GOTPAGE
Lloh6:
	ldr	x0, [x0, _ttyoring@GOTPAGEOFF]
	mov	x1, x23
	bl	_ring_consumed
LBB0_14:
	sub	w8, w19, w23
	cmp	w19, #0
	csetm	w9, ne
	cmp	w19, w23
	csinc	w0, w9, w8, eq
LBB0_15:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_16:
Lloh7:
	adrp	x8, _errno@GOTPAGE
Lloh8:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh9:
	ldr	x8, [x8]
Lloh10:
	adrp	x9, _EAGAIN@GOTPAGE
Lloh11:
	ldr	x9, [x9, _EAGAIN@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
Lloh13:
	adrp	x10, _EINTR@GOTPAGE
Lloh14:
	ldr	x10, [x10, _EINTR@GOTPAGEOFF]
Lloh15:
	ldr	x10, [x10]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_18
; %bb.17:
	mov	w0, #-1
	b	LBB0_15
LBB0_18:
Lloh16:
	adrp	x19, _ttyoring@GOTPAGE
Lloh17:
	ldr	x19, [x19, _ttyoring@GOTPAGEOFF]
	mov	x0, x19
	bl	_ring_full_count
	mov	x1, x0
	mov	x0, x19
	bl	_ring_consumed
	mov	w0, #0
	bl	_setconnmode
	bl	_setcommandmode
Lloh18:
	adrp	x8, _net@GOTPAGE
Lloh19:
	ldr	x8, [x8, _net@GOTPAGEOFF]
Lloh20:
	ldr	w0, [x8]
	bl	_NetClose
Lloh21:
	adrp	x8, _stderr@GOTPAGE
Lloh22:
	ldr	x8, [x8, _stderr@GOTPAGEOFF]
Lloh23:
	ldr	w0, [x8]
Lloh24:
	adrp	x1, l_.str@PAGE
Lloh25:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fprintf
	mov	w0, #1
	bl	_exit
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_ttyoring,8,2                   ; @ttyoring
	.comm	_termdata,8,3                   ; @termdata
	.comm	_errno,8,3                      ; @errno
	.comm	_EAGAIN,8,3                     ; @EAGAIN
	.comm	_EINTR,8,3                      ; @EINTR
	.comm	_net,4,2                        ; @net
	.comm	_stderr,4,2                     ; @stderr
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Write error on local output.\n"

.subsections_via_symbols
