	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ttyname_r                      ## -- Begin function ttyname_r
	.p2align	4, 0x90
_ttyname_r:                             ## @ttyname_r
	.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
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %rbx
	movq	%rsi, %r15
	leaq	-56(%rbp), %rsi
	callq	_fstat
	movl	$-1, %r12d
	testl	%eax, %eax
	js	LBB0_7
## %bb.1:
	movq	_O_RDONLY@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str(%rip), %rdi
	callq	_open
	testl	%eax, %eax
	js	LBB0_7
## %bb.2:
	movl	%eax, %r13d
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movq	-56(%rbp), %r14
	leaq	-72(%rbp), %r12
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Inner Loop Header: Depth=1
	movl	%r13d, %edi
	movq	%r12, %rsi
	movl	$16, %edx
	callq	_getdents
	movl	%eax, %ebx
	cmpl	$1, %eax
	jne	LBB0_6
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	cmpq	%r14, -72(%rbp)
	jne	LBB0_3
## %bb.5:
	movq	-64(%rbp), %rcx
	leaq	L_.str.1(%rip), %rdx
	movq	%r15, %rdi
	movq	-48(%rbp), %rsi                 ## 8-byte Reload
	callq	_snprintf
LBB0_6:
	xorl	%r12d, %r12d
	cmpl	$1, %ebx
	setne	%r12b
	movl	%r13d, %edi
	callq	_close
	negl	%r12d
LBB0_7:
	movl	%r12d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"/device/terminal"

	.comm	_O_RDONLY,4,2                   ## @O_RDONLY
L_.str.1:                               ## @.str.1
	.asciz	"/device/terminal/%s"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ttyname_r                      ; -- Begin function ttyname_r
	.p2align	2
_ttyname_r:                             ; @ttyname_r
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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	x19, x2
	mov	x20, x1
	add	x1, sp, #24
	bl	_fstat
	tbnz	w0, #31, LBB0_7
; %bb.1:
Lloh0:
	adrp	x8, _O_RDONLY@GOTPAGE
Lloh1:
	ldr	x8, [x8, _O_RDONLY@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
Lloh3:
	adrp	x0, l_.str@PAGE
Lloh4:
	add	x0, x0, l_.str@PAGEOFF
	bl	_open
	tbnz	w0, #31, LBB0_7
; %bb.2:
	mov	x21, x0
	ldr	x23, [sp, #24]
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	add	x1, sp, #8
	mov	x0, x21
	mov	w2, #16
	bl	_getdents
	mov	x22, x0
	cmp	w0, #1
	b.ne	LBB0_6
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	ldr	x8, [sp, #8]
	cmp	x8, x23
	b.ne	LBB0_3
; %bb.5:
	ldr	x3, [sp, #16]
Lloh5:
	adrp	x2, l_.str.1@PAGE
Lloh6:
	add	x2, x2, l_.str.1@PAGEOFF
	mov	x0, x20
	mov	x1, x19
	bl	_snprintf
LBB0_6:
	mov	x0, x21
	bl	_close
	cmp	w22, #1
	csetm	w0, ne
	b	LBB0_8
LBB0_7:
	mov	w0, #-1
LBB0_8:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #96
	ret
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"/device/terminal"

	.comm	_O_RDONLY,4,2                   ; @O_RDONLY
l_.str.1:                               ; @.str.1
	.asciz	"/device/terminal/%s"

.subsections_via_symbols
