	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function console_handler
_console_handler:                       ## @console_handler
	.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
	subq	$32, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, %r14
	movl	%edx, %r15d
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -40(%rbp)
	movq	_TIOCGETA@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -52(%rbp)
	movq	_TIOCSETA@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -48(%rbp)
	movq	_TIOCGWINSZ@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)
	testl	%edx, %edx
	je	LBB0_3
## %bb.1:
	cmpl	$2, %r8d
	jne	LBB0_3
## %bb.2:
	movq	_BVM_CONS_SIG@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r14)
	jmp	LBB0_16
LBB0_3:
	testl	%r15d, %r15d
	je	LBB0_6
## %bb.4:
	cmpl	$1, %r8d
	jne	LBB0_6
## %bb.5:
	movl	$255, (%r14)
LBB0_16:
	xorl	%ebx, %ebx
LBB0_17:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-40(%rbp), %rax
	jne	LBB0_19
## %bb.18:
	movl	%ebx, %eax
	addq	$32, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_6:
	movl	$-1, %ebx
	cmpl	$4, %r8d
	jne	LBB0_17
## %bb.7:
	cmpb	$0, _console_handler.opened(%rip)
	jne	LBB0_13
## %bb.8:
	movq	_CAP_EVENT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_CAP_IOCTL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_CAP_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_CAP_WRITE@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	leaq	-56(%rbp), %rbx
	movq	%rbx, %rdi
	callq	_cap_rights_init
	movq	_STDIN_FILENO@GOTPCREL(%rip), %r12
	movl	(%r12), %edi
	movq	%rbx, %rsi
	callq	_caph_rights_limit
	cmpl	$-1, %eax
	jne	LBB0_10
## %bb.9:
	movq	_EX_OSERR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_errx
LBB0_10:
	movl	(%r12), %ebx
	leaq	-52(%rbp), %r12
	movq	%r12, %rdi
	callq	_nitems
	movl	%ebx, %edi
	movq	%r12, %rsi
	movl	%eax, %edx
	callq	_caph_ioctls_limit
	cmpl	$-1, %eax
	jne	LBB0_12
## %bb.11:
	movq	_EX_OSERR@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_errx
LBB0_12:
	xorl	%eax, %eax
	callq	_ttyopen
	movb	$1, _console_handler.opened(%rip)
LBB0_13:
	testl	%r15d, %r15d
	je	LBB0_15
## %bb.14:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_ttyread
	movl	%eax, (%r14)
	jmp	LBB0_17
LBB0_15:
	movl	(%r14), %edi
	callq	_ttywrite
	jmp	LBB0_16
LBB0_19:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
.zerofill __DATA,__bss,_console_handler.opened,1,2 ## @console_handler.opened
	.comm	_TIOCGETA,4,2                   ## @TIOCGETA
	.comm	_TIOCSETA,4,2                   ## @TIOCSETA
	.comm	_TIOCGWINSZ,4,2                 ## @TIOCGWINSZ
	.comm	_BVM_CONS_SIG,4,2               ## @BVM_CONS_SIG
	.comm	_CAP_EVENT,4,2                  ## @CAP_EVENT
	.comm	_CAP_IOCTL,4,2                  ## @CAP_IOCTL
	.comm	_CAP_READ,4,2                   ## @CAP_READ
	.comm	_CAP_WRITE,4,2                  ## @CAP_WRITE
	.comm	_STDIN_FILENO,4,2               ## @STDIN_FILENO
	.comm	_EX_OSERR,4,2                   ## @EX_OSERR
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Unable to apply rights for sandbox"

	.no_dead_strip	_console_handler
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function console_handler
_console_handler:                       ; @console_handler
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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, x5
	mov	x20, x2
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [sp, #24]
Lloh3:
	adrp	x8, _TIOCGETA@GOTPAGE
Lloh4:
	ldr	x8, [x8, _TIOCGETA@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
Lloh6:
	adrp	x9, _TIOCSETA@GOTPAGE
Lloh7:
	ldr	x9, [x9, _TIOCSETA@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	stp	w8, w9, [sp, #12]
Lloh9:
	adrp	x8, _TIOCGWINSZ@GOTPAGE
Lloh10:
	ldr	x8, [x8, _TIOCGWINSZ@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	str	w8, [sp, #20]
	cbz	w2, LBB0_3
; %bb.1:
	cmp	w4, #2
	b.ne	LBB0_3
; %bb.2:
	mov	w0, #0
Lloh12:
	adrp	x8, _BVM_CONS_SIG@GOTPAGE
Lloh13:
	ldr	x8, [x8, _BVM_CONS_SIG@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	str	w8, [x19]
	b	LBB0_17
LBB0_3:
	cbz	w20, LBB0_6
; %bb.4:
	cmp	w4, #1
	b.ne	LBB0_6
; %bb.5:
	mov	w0, #0
	mov	w8, #255
	str	w8, [x19]
	b	LBB0_17
LBB0_6:
	cmp	w4, #4
	b.ne	LBB0_15
; %bb.7:
	adrp	x22, _console_handler.opened@PAGE
	ldrb	w8, [x22, _console_handler.opened@PAGEOFF]
	tbnz	w8, #0, LBB0_13
; %bb.8:
Lloh15:
	adrp	x8, _CAP_EVENT@GOTPAGE
Lloh16:
	ldr	x8, [x8, _CAP_EVENT@GOTPAGEOFF]
Lloh17:
	ldr	w1, [x8]
Lloh18:
	adrp	x8, _CAP_IOCTL@GOTPAGE
Lloh19:
	ldr	x8, [x8, _CAP_IOCTL@GOTPAGEOFF]
Lloh20:
	ldr	w2, [x8]
Lloh21:
	adrp	x8, _CAP_READ@GOTPAGE
Lloh22:
	ldr	x8, [x8, _CAP_READ@GOTPAGEOFF]
Lloh23:
	ldr	w3, [x8]
Lloh24:
	adrp	x8, _CAP_WRITE@GOTPAGE
Lloh25:
	ldr	x8, [x8, _CAP_WRITE@GOTPAGEOFF]
Lloh26:
	ldr	w4, [x8]
	add	x0, sp, #8
	bl	_cap_rights_init
Lloh27:
	adrp	x21, _STDIN_FILENO@GOTPAGE
Lloh28:
	ldr	x21, [x21, _STDIN_FILENO@GOTPAGEOFF]
	ldr	w0, [x21]
	add	x1, sp, #8
	bl	_caph_rights_limit
	cmn	w0, #1
	b.ne	LBB0_10
; %bb.9:
Lloh29:
	adrp	x8, _EX_OSERR@GOTPAGE
Lloh30:
	ldr	x8, [x8, _EX_OSERR@GOTPAGEOFF]
Lloh31:
	ldr	w0, [x8]
Lloh32:
	adrp	x1, l_.str@PAGE
Lloh33:
	add	x1, x1, l_.str@PAGEOFF
	bl	_errx
LBB0_10:
	ldr	w21, [x21]
	add	x0, sp, #12
	bl	_nitems
	mov	x2, x0
	add	x1, sp, #12
	mov	x0, x21
	bl	_caph_ioctls_limit
	cmn	w0, #1
	b.ne	LBB0_12
; %bb.11:
Lloh34:
	adrp	x8, _EX_OSERR@GOTPAGE
Lloh35:
	ldr	x8, [x8, _EX_OSERR@GOTPAGEOFF]
Lloh36:
	ldr	w0, [x8]
Lloh37:
	adrp	x1, l_.str@PAGE
Lloh38:
	add	x1, x1, l_.str@PAGEOFF
	bl	_errx
LBB0_12:
	bl	_ttyopen
	mov	w8, #1
	strb	w8, [x22, _console_handler.opened@PAGEOFF]
LBB0_13:
	cbz	w20, LBB0_16
; %bb.14:
	bl	_ttyread
	mov	x8, x0
	mov	w0, #0
	str	w8, [x19]
	b	LBB0_17
LBB0_15:
	mov	w0, #-1
	b	LBB0_17
LBB0_16:
	ldr	w0, [x19]
	bl	_ttywrite
	mov	w0, #0
LBB0_17:
	ldr	x8, [sp, #24]
Lloh39:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh40:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh41:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_19
; %bb.18:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_19:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpAdd	Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh39, Lloh40, Lloh41
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_console_handler.opened,1,2 ; @console_handler.opened
	.comm	_TIOCGETA,4,2                   ; @TIOCGETA
	.comm	_TIOCSETA,4,2                   ; @TIOCSETA
	.comm	_TIOCGWINSZ,4,2                 ; @TIOCGWINSZ
	.comm	_BVM_CONS_SIG,4,2               ; @BVM_CONS_SIG
	.comm	_CAP_EVENT,4,2                  ; @CAP_EVENT
	.comm	_CAP_IOCTL,4,2                  ; @CAP_IOCTL
	.comm	_CAP_READ,4,2                   ; @CAP_READ
	.comm	_CAP_WRITE,4,2                  ; @CAP_WRITE
	.comm	_STDIN_FILENO,4,2               ; @STDIN_FILENO
	.comm	_EX_OSERR,4,2                   ; @EX_OSERR
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Unable to apply rights for sandbox"

	.no_dead_strip	_console_handler
.subsections_via_symbols
