	.file	"631937.c"
	.intel_syntax noprefix
	.text
	.data
	.align 32
	.type	dev_buff, @object
	.size	dev_buff, 4104
dev_buff:
	.string	"/dev/console"
	.zero	4091
	.text
	.globl	ttyname
	.type	ttyname, @function
ttyname:
.LFB0:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 16
	mov	DWORD PTR -4[rbp], edi
	mov	eax, DWORD PTR -4[rbp]
	mov	edi, eax
	mov	eax, 0
	call	_ttyslot
	test	eax, eax
	js	.L2
	lea	rax, dev_buff[rip]
	jmp	.L3
.L2:
	mov	eax, 0
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ttyname, .-ttyname
	.section	.rodata
.LC0:
	.string	"r"
.LC1:
	.string	"/etc/ttys"
	.text
	.globl	_ttyslot
	.type	_ttyslot, @function
_ttyslot:
.LFB1:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	push	r14
	push	r13
	push	r12
	push	rbx
	sub	rsp, 176
	.cfi_offset 14, -24
	.cfi_offset 13, -32
	.cfi_offset 12, -40
	.cfi_offset 3, -48
	mov	DWORD PTR -196[rbp], edi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -40[rbp], rax
	xor	eax, eax
	lea	rdx, -192[rbp]
	mov	eax, DWORD PTR -196[rbp]
	mov	rsi, rdx
	mov	edi, eax
	call	fstat@PLT
	test	eax, eax
	js	.L5
	lea	rsi, .LC0[rip]
	lea	rdi, .LC1[rip]
	call	fopen@PLT
	mov	rbx, rax
	test	rbx, rbx
	jne	.L6
.L5:
	mov	eax, -1
	jmp	.L13
.L6:
	mov	eax, DWORD PTR -168[rbp]
	mov	r14d, eax
	mov	r13, QWORD PTR -152[rbp]
	mov	r12d, 0
.L12:
	mov	rdi, rbx
	call	getc@PLT
	cmp	eax, 10
	je	.L8
	mov	rdi, rbx
	call	getc@PLT
	cmp	eax, 10
	je	.L8
	mov	rdi, rbx
	call	getc@PLT
	cmp	eax, 10
	je	.L8
	lea	rax, dev_buff[rip+5]
	mov	rdx, rbx
	mov	esi, 255
	mov	rdi, rax
	call	fgets@PLT
	test	rax, rax
	je	.L8
	mov	esi, 10
	lea	rdi, dev_buff[rip]
	call	strchr@PLT
	test	rax, rax
	jne	.L9
.L8:
	mov	r12d, -1
	jmp	.L10
.L9:
	mov	esi, 10
	lea	rdi, dev_buff[rip]
	call	strchr@PLT
	mov	BYTE PTR [rax], 0
	lea	rax, -192[rbp]
	mov	rsi, rax
	lea	rdi, dev_buff[rip]
	call	stat@PLT
	test	eax, eax
	js	.L11
	mov	edx, DWORD PTR -168[rbp]
	movsx	eax, r14w
	cmp	edx, eax
	jne	.L11
	mov	rax, QWORD PTR -152[rbp]
	cmp	r13, rax
	je	.L15
.L11:
	add	r12d, 1
	jmp	.L12
.L15:
	nop
.L10:
	mov	rdi, rbx
	call	fclose@PLT
	mov	eax, r12d
.L13:
	mov	rcx, QWORD PTR -40[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	add	rsp, 176
	pop	rbx
	pop	r12
	pop	r13
	pop	r14
	pop	rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	_ttyslot, .-_ttyslot
	.ident	"GCC: (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 6
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"631937.c"
	.text
	.data
	.align	2
	.type	dev_buff, %object
	.size	dev_buff, 4104
dev_buff:
	.ascii	"/dev/console\000"
	.space	4091
	.text
	.align	2
	.global	ttyname
	.syntax unified
	.arm
	.fpu softvfp
	.type	ttyname, %function
ttyname:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{fp, lr}
	add	fp, sp, #4
	sub	sp, sp, #8
	str	r0, [fp, #-8]
	ldr	r0, [fp, #-8]
	bl	_ttyslot
	mov	r3, r0
	cmp	r3, #0
	blt	.L2
	ldr	r3, .L4
	b	.L3
.L2:
	mov	r3, #0
.L3:
	mov	r0, r3
	sub	sp, fp, #4
	@ sp needed
	pop	{fp, pc}
.L5:
	.align	2
.L4:
	.word	dev_buff
	.size	ttyname, .-ttyname
	.section	.rodata
	.align	2
.LC0:
	.ascii	"r\000"
	.align	2
.LC1:
	.ascii	"/etc/ttys\000"
	.align	2
.LC2:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	_ttyslot
	.syntax unified
	.arm
	.fpu softvfp
	.type	_ttyslot, %function
_ttyslot:
	@ args = 0, pretend = 0, frame = 104
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, fp, lr}
	add	fp, sp, #24
	sub	sp, sp, #108
	str	r0, [fp, #-128]
	ldr	r3, .L18
	ldr	r3, [r3]
	str	r3, [fp, #-32]
	mov	r3,#0
	sub	r3, fp, #124
	mov	r1, r3
	ldr	r0, [fp, #-128]
	bl	fstat
	mov	r3, r0
	cmp	r3, #0
	blt	.L7
	ldr	r1, .L18+4
	ldr	r0, .L18+8
	bl	fopen
	mov	r4, r0
	cmp	r4, #0
	bne	.L8
.L7:
	mvn	r3, #0
	b	.L15
.L8:
	ldr	r3, [fp, #-108]
	lsl	r3, r3, #16
	asr	r8, r3, #16
	sub	r7, fp, #92
	ldmia	r7, {r6-r7}
	mov	r5, #0
.L14:
	mov	r0, r4
	bl	getc
	mov	r3, r0
	cmp	r3, #10
	beq	.L10
	mov	r0, r4
	bl	getc
	mov	r3, r0
	cmp	r3, #10
	beq	.L10
	mov	r0, r4
	bl	getc
	mov	r3, r0
	cmp	r3, #10
	beq	.L10
	ldr	r3, .L18+12
	mov	r2, r4
	mov	r1, #255
	mov	r0, r3
	bl	fgets
	mov	r3, r0
	cmp	r3, #0
	beq	.L10
	mov	r1, #10
	ldr	r0, .L18+16
	bl	strchr
	mov	r3, r0
	cmp	r3, #0
	bne	.L11
.L10:
	mvn	r5, #0
	b	.L12
.L11:
	mov	r1, #10
	ldr	r0, .L18+16
	bl	strchr
	mov	r3, r0
	mov	r2, #0
	strb	r2, [r3]
	sub	r3, fp, #124
	mov	r1, r3
	ldr	r0, .L18+16
	bl	stat
	mov	r3, r0
	cmp	r3, #0
	blt	.L13
	ldr	r3, [fp, #-108]
	mov	r2, r8
	cmp	r3, r2
	bne	.L13
	sub	r3, fp, #92
	ldmia	r3, {r2-r3}
	cmp	r7, r3
	cmpeq	r6, r2
	beq	.L17
.L13:
	add	r5, r5, #1
	b	.L14
.L17:
	nop
.L12:
	mov	r0, r4
	bl	fclose
	mov	r3, r5
.L15:
	ldr	r2, .L18
	ldr	r1, [r2]
	ldr	r2, [fp, #-32]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L16
	bl	__stack_chk_fail
.L16:
	mov	r0, r3
	sub	sp, fp, #24
	@ sp needed
	pop	{r4, r5, r6, r7, r8, fp, pc}
.L19:
	.align	2
.L18:
	.word	.LC2
	.word	.LC0
	.word	.LC1
	.word	dev_buff+5
	.word	dev_buff
	.size	_ttyslot, .-_ttyslot
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
