	.file	"265982.c"
	.intel_syntax noprefix
	.text
	.section	.rodata
.LC0:
	.string	"TERM=emterm"
.LC1:
	.string	"/dev/"
	.text
	.globl	setup_tty
	.type	setup_tty, @function
setup_tty:
.LFB6:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	sub	rsp, 4096
	or	QWORD PTR [rsp], 0
	sub	rsp, 48
	mov	QWORD PTR -4136[rbp], rdi
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -8[rbp], rax
	xor	eax, eax
	lea	rdi, .LC0[rip]
	call	putenv@PLT
	mov	rax, QWORD PTR -4136[rbp]
	movzx	eax, BYTE PTR [rax]
	test	al, al
	je	.L2
	lea	rax, -4112[rbp]
	mov	edx, 4096
	lea	rsi, .LC1[rip]
	mov	rdi, rax
	call	strncpy@PLT
	mov	rdx, QWORD PTR -4136[rbp]
	lea	rax, -4112[rbp]
	mov	rsi, rdx
	mov	rdi, rax
	call	strcat@PLT
	lea	rax, -4112[rbp]
	mov	esi, 2
	mov	rdi, rax
	mov	eax, 0
	call	open@PLT
	mov	DWORD PTR -4116[rbp], eax
	cmp	DWORD PTR -4116[rbp], -1
	jne	.L3
	call	diag_fd@PLT
	mov	DWORD PTR -4116[rbp], eax
	jmp	.L3
.L2:
	call	diag_fd@PLT
	mov	DWORD PTR -4116[rbp], eax
.L3:
	cmp	DWORD PTR -4116[rbp], 0
	jns	.L4
	mov	eax, DWORD PTR -4116[rbp]
	jmp	.L7
.L4:
	mov	eax, DWORD PTR -4116[rbp]
	mov	esi, 0
	mov	edi, eax
	call	dup2@PLT
	mov	eax, DWORD PTR -4116[rbp]
	mov	esi, 1
	mov	edi, eax
	call	dup2@PLT
	mov	eax, DWORD PTR -4116[rbp]
	mov	esi, 2
	mov	edi, eax
	call	dup2@PLT
	cmp	DWORD PTR -4116[rbp], 2
	jle	.L6
	mov	eax, DWORD PTR -4116[rbp]
	mov	edi, eax
	call	close@PLT
.L6:
	mov	eax, 0
.L7:
	mov	rcx, QWORD PTR -8[rbp]
	sub	rcx, QWORD PTR fs:40
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	setup_tty, .-setup_tty
	.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	"265982.c"
	.text
	.section	.rodata
	.align	2
.LC0:
	.ascii	"TERM=emterm\000"
	.align	2
.LC1:
	.ascii	"/dev/\000"
	.align	2
.LC2:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	setup_tty
	.syntax unified
	.arm
	.fpu softvfp
	.type	setup_tty, %function
setup_tty:
	@ args = 0, pretend = 0, frame = 4112
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, fp, lr}
	add	fp, sp, #8
	sub	sp, sp, #4096
	sub	sp, sp, #20
	sub	r3, fp, #4096
	sub	r3, r3, #12
	str	r0, [r3, #-12]
	ldr	r3, .L9
	ldr	r3, [r3]
	str	r3, [fp, #-16]
	mov	r3,#0
	ldr	r0, .L9+4
	bl	putenv
	sub	r3, fp, #4096
	sub	r3, r3, #12
	ldr	r3, [r3, #-12]
	ldrb	r3, [r3]	@ zero_extendqisi2
	cmp	r3, #0
	beq	.L2
	sub	r3, fp, #4096
	sub	r3, r3, #12
	sub	r3, r3, #4
	mov	r2, #4096
	ldr	r1, .L9+8
	mov	r0, r3
	bl	strncpy
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r2, r3
	sub	r3, fp, #4096
	sub	r3, r3, #12
	sub	r3, r3, #4
	ldr	r1, [r2, #-12]
	mov	r0, r3
	bl	strcat
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r4, r3
	sub	r3, fp, #4096
	sub	r3, r3, #12
	sub	r3, r3, #4
	mov	r1, #2
	mov	r0, r3
	bl	open
	str	r0, [r4, #-8]
	sub	r3, fp, #4096
	sub	r3, r3, #12
	ldr	r3, [r3, #-8]
	cmn	r3, #1
	bne	.L3
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r4, r3
	bl	diag_fd
	str	r0, [r4, #-8]
	b	.L3
.L2:
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r4, r3
	bl	diag_fd
	str	r0, [r4, #-8]
.L3:
	sub	r3, fp, #4096
	sub	r3, r3, #12
	ldr	r3, [r3, #-8]
	cmp	r3, #0
	bge	.L4
	sub	r3, fp, #4096
	sub	r3, r3, #12
	ldr	r3, [r3, #-8]
	b	.L7
.L4:
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r1, #0
	ldr	r0, [r3, #-8]
	bl	dup2
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r1, #1
	ldr	r0, [r3, #-8]
	bl	dup2
	sub	r3, fp, #4096
	sub	r3, r3, #12
	mov	r1, #2
	ldr	r0, [r3, #-8]
	bl	dup2
	sub	r3, fp, #4096
	sub	r3, r3, #12
	ldr	r3, [r3, #-8]
	cmp	r3, #2
	ble	.L6
	sub	r3, fp, #4096
	sub	r3, r3, #12
	ldr	r0, [r3, #-8]
	bl	close
.L6:
	mov	r3, #0
.L7:
	ldr	r2, .L9
	ldr	r1, [r2]
	ldr	r2, [fp, #-16]
	eors	r1, r2, r1
	mov	r2, #0
	beq	.L8
	bl	__stack_chk_fail
.L8:
	mov	r0, r3
	sub	sp, fp, #8
	@ sp needed
	pop	{r4, fp, pc}
.L10:
	.align	2
.L9:
	.word	.LC2
	.word	.LC0
	.word	.LC1
	.size	setup_tty, .-setup_tty
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
