// File: /workspace/github_c_makefile_star2_O0/s3lase[P]v6shell/fd2.c
// Function: main
int
main(int argc, char **argv)
{
	bool eopt;
	int efd, fd, nfd, ofd, opt;
	char *file;

	setmyerrexit(&ut_errexit);
	setmyname(argv[0]);
	setmypid(getpid());

	/*
	 * Set-ID execution is not supported.
	 */
	if (geteuid() != getuid() || getegid() != getgid())
		err(FC_ERR, FMT2S, getmyname(), ERR_SETID);

	/*
	 * File descriptors 0, 1, and 2 must be open.
	 */
	for (fd = 0; fd < 3; fd++)
		if (!fd_isopen(fd))
			err(FC_ERR, "%s: %u: %s\n",
			    getmyname(), (unsigned)fd, strerror(errno));

	ofd = FD1, efd = FD2;
	eopt = false, file = NULL;
	while ((opt = getopt(argc, argv, ":ef:")) != -1)
		switch (opt) {
		case 'e':
			eopt = true;
			break;
		case 'f':
			file = optarg;
			break;
		default:
			usage();
		}
	argc -= optind;
	argv += optind;
	if (argc < 1)
		usage();

	if (file != NULL) {
		if ((nfd = open(file, O_WRONLY|O_APPEND|O_CREAT, 0666)) == -1)
			err(FC_ERR, FMT3S, getmyname(), file, ERR_CREATE);
		if (dup2(nfd, efd) == -1)
			err(FC_ERR, FMT2S, getmyname(), strerror(errno));
		if (eopt && dup2(efd, ofd) == -1)
			err(FC_ERR, FMT2S, getmyname(), strerror(errno));
		(void)close(nfd);
	} else {
		if (eopt)
			ofd = FD2, efd = FD1;
		if (dup2(ofd, efd) == -1)
			err(FC_ERR, FMT2S, getmyname(), strerror(errno));
	}

	/*
	 * Try to execute the specified command.
	 */
	(void)err_pexec(argv[0], argv);
	/*NOTREACHED*/
	return FC_ERR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x773(%rip), %rdi       # 0x1a70
callq 0x1980
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x19a0
callq 0x10b0
movl %eax, %edi
callq 0x1a50
callq 0x1110
movl %eax, -0x34(%rbp)
callq 0x10d0
movl %eax, %ecx
movl -0x34(%rbp), %eax
cmpl %ecx, %eax
jne 0x1346
callq 0x1180
movl %eax, -0x38(%rbp)
callq 0x1160
movl %eax, %ecx
movl -0x38(%rbp), %eax
cmpl %ecx, %eax
je 0x1368
callq 0x1920
movq %rax, %rdx
movl $0x7c, %edi
leaq 0x1dda(%rip), %rsi      # 0x3134
leaq 0x1da6(%rip), %rcx      # 0x3107
movb $0x0, %al
callq 0x1620
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x13c6
movl -0x1c(%rbp), %edi
callq 0x15c0
testb $0x1, %al
jne 0x13b9
callq 0x1920
movq %rax, -0x48(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
callq 0x1060
movl (%rax), %edi
callq 0x11c0
movq -0x48(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movq %rax, %r8
movl $0x7c, %edi
leaq 0x1d6d(%rip), %rsi      # 0x311f
movb $0x0, %al
callq 0x1620
jmp 0x13bb
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x136f
movl $0x1, -0x24(%rbp)
movl $0x2, -0x18(%rbp)
movb $0x0, -0x11(%rbp)
movq $0x0, -0x30(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1d3d(%rip), %rdx      # 0x312b
callq 0x11a0
movl %eax, -0x28(%rbp)
cmpl $-0x1, %eax
je 0x142f
movl -0x28(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $0x65, %eax
je 0x1412
jmp 0x1408
movl -0x4c(%rbp), %eax
subl $0x66, %eax
je 0x1418
jmp 0x1428
movb $0x1, -0x11(%rbp)
jmp 0x142d
movq 0x3bb9(%rip), %rax      # 0x4fd8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x142d
callq 0x15f0
jmp 0x13e0
movq 0x3b9a(%rip), %rax      # 0x4fd0
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movq 0x3b89(%rip), %rax      # 0x4fd0
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x1, -0x8(%rbp)
jge 0x1466
callq 0x15f0
cmpq $0x0, -0x30(%rbp)
je 0x1542
movq -0x30(%rbp), %rdi
movl $0x441, %esi            # imm = 0x441
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x1190
movl %eax, -0x20(%rbp)
cmpl $-0x1, %eax
jne 0x14b4
callq 0x1920
movq %rax, %rdx
movq -0x30(%rbp), %rcx
movl $0x7c, %edi
leaq 0x1c8a(%rip), %rsi      # 0x3130
leaq 0x1c8f(%rip), %r8       # 0x313c
movb $0x0, %al
callq 0x1620
movl -0x20(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x10e0
cmpl $-0x1, %eax
jne 0x14f3
callq 0x1920
movq %rax, -0x58(%rbp)
callq 0x1060
movl (%rax), %edi
callq 0x11c0
movq -0x58(%rbp), %rdx
movq %rax, %rcx
movl $0x7c, %edi
leaq 0x1c48(%rip), %rsi      # 0x3134
movb $0x0, %al
callq 0x1620
testb $0x1, -0x11(%rbp)
je 0x1538
movl -0x18(%rbp), %edi
movl -0x24(%rbp), %esi
callq 0x10e0
cmpl $-0x1, %eax
jne 0x1538
callq 0x1920
movq %rax, -0x60(%rbp)
callq 0x1060
movl (%rax), %edi
callq 0x11c0
movq -0x60(%rbp), %rdx
movq %rax, %rcx
movl $0x7c, %edi
leaq 0x1c03(%rip), %rsi      # 0x3134
movb $0x0, %al
callq 0x1620
movl -0x20(%rbp), %edi
callq 0x1120
jmp 0x1597
testb $0x1, -0x11(%rbp)
je 0x1556
movl $0x2, -0x24(%rbp)
movl $0x1, -0x18(%rbp)
movl -0x24(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x10e0
cmpl $-0x1, %eax
jne 0x1595
callq 0x1920
movq %rax, -0x68(%rbp)
callq 0x1060
movl (%rax), %edi
callq 0x11c0
movq -0x68(%rbp), %rdx
movq %rax, %rcx
movl $0x7c, %edi
leaq 0x1ba6(%rip), %rsi      # 0x3134
movb $0x0, %al
callq 0x1620
jmp 0x1597
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x1ec0
movl $0x7c, %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)