// File: /workspace/github_c_makefile_star2_O2/s3lase[P]v6shell/util.c
// Function: sbi_fd2
static int
sbi_fd2(int argc, char **argv)
{
	bool eopt;
	enum sbikey key;
	int efd, nfd, ofd, opt;
	char *file;

	setmyname(argv[0]);

	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:
			fd2_usage();
		}
	argc -= optind;
	argv += optind;
	if (argc < 1)
		fd2_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.
	 */
	key = cmd_lookup(argv[0]);
	if (IS_SBI(key))
		return uexec(key, argc, argv);

	(void)err_pexec(argv[0], argv);
	/*NOTREACHED*/
	return FC_ERR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
movq (%rsi), %rdi
callq 0x6487
xorl %r13d, %r13d
leaq 0x1fef(%rip), %r12      # 0x868b
movq 0x5935(%rip), %rbp      # 0xbfd8
xorl %r15d, %r15d
movl %ebx, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2350
cmpl $-0x1, %eax
je 0x66d4
cmpl $0x65, %eax
je 0x66cf
cmpl $0x66, %eax
je 0x66c9
callq 0x6a71
jmp 0x66a6
movq (%rbp), %r15
jmp 0x66a6
movb $0x1, %r13b
jmp 0x66a6
movq 0x58f5(%rip), %rax      # 0xbfd0
movslq (%rax), %r12
subl %r12d, %ebx
jg 0x66e8
callq 0x6a71
leaq (%r14,%r12,8), %r14
testq %r15, %r15
je 0x67b7
movq %r15, %rdi
movl $0x441, %esi            # imm = 0x441
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x2320
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x6733
callq 0x6455
leaq 0x1c1d(%rip), %rsi      # 0x8339
leaq 0x1e32(%rip), %r8       # 0x8555
pushq $0x7c
popq %rdi
movq %rax, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x6218
pushq $0x2
popq %rsi
movl %ebp, %edi
callq 0x2160
cmpl $-0x1, %eax
jne 0x676d
callq 0x6455
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x1be0(%rip), %rsi      # 0x833d
pushq $0x7c
popq %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6218
testb $0x1, %r13b
je 0x67ae
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
callq 0x2160
cmpl $-0x1, %eax
jne 0x67ae
callq 0x6455
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x1b9f(%rip), %rsi      # 0x833d
pushq $0x7c
popq %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6218
movl %ebp, %edi
callq 0x21d0
jmp 0x67fa
movzbl %r13b, %edi
andl $0x1, %edi
pushq $0x2
popq %rsi
subl %edi, %esi
incl %edi
callq 0x2160
cmpl $-0x1, %eax
jne 0x67fa
callq 0x6455
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x1b53(%rip), %rsi      # 0x833d
pushq $0x7c
popq %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x6218
movq (%r14), %rdi
callq 0x31a5
cmpl $0x9, %eax
ja 0x682b
movl $0x390, %ecx            # imm = 0x390
btl %eax, %ecx
jae 0x682b
movl %eax, %edi
movl %ebx, %esi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6510
movq (%r14), %rdi
movq %r14, %rsi
callq 0x76a8
pushq $0x7c
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq