// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x8e70
movl $0x1, -0x24(%rbp)
movl $0x2, -0x1c(%rbp)
movb $0x0, -0x11(%rbp)
movq $0x0, -0x30(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x292b(%rip), %rdx      # 0xbb0e
callq 0x2350
movl %eax, -0x28(%rbp)
cmpl $-0x1, %eax
je 0x9224
movl -0x28(%rbp), %eax
movl %eax, -0x34(%rbp)
subl $0x65, %eax
je 0x9207
jmp 0x91fd
movl -0x34(%rbp), %eax
subl $0x66, %eax
je 0x920d
jmp 0x921d
movb $0x1, -0x11(%rbp)
jmp 0x9222
movq 0x4dc4(%rip), %rax      # 0xdfd8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x9222
callq 0x95e0
jmp 0x91d5
movq 0x4da5(%rip), %rax      # 0xdfd0
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movq 0x4d94(%rip), %rax      # 0xdfd0
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 0x925b
callq 0x95e0
cmpq $0x0, -0x30(%rbp)
je 0x9337
movq -0x30(%rbp), %rdi
movl $0x441, %esi            # imm = 0x441
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x2320
movl %eax, -0x20(%rbp)
cmpl $-0x1, %eax
jne 0x92a9
callq 0x8df0
movq %rax, %rdx
movq -0x30(%rbp), %rcx
movl $0x7c, %edi
leaq 0x2502(%rip), %rsi      # 0xb79d
leaq 0x271b(%rip), %r8       # 0xb9bd
movb $0x0, %al
callq 0x8af0
movl -0x20(%rbp), %edi
movl -0x1c(%rbp), %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x92e8
callq 0x8df0
movq %rax, -0x40(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x2380
movq -0x40(%rbp), %rdx
movq %rax, %rcx
movl $0x7c, %edi
leaq 0x24c0(%rip), %rsi      # 0xb7a1
movb $0x0, %al
callq 0x8af0
testb $0x1, -0x11(%rbp)
je 0x932d
movl -0x1c(%rbp), %edi
movl -0x24(%rbp), %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x932d
callq 0x8df0
movq %rax, -0x48(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x2380
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movl $0x7c, %edi
leaq 0x247b(%rip), %rsi      # 0xb7a1
movb $0x0, %al
callq 0x8af0
movl -0x20(%rbp), %edi
callq 0x21d0
jmp 0x938c
testb $0x1, -0x11(%rbp)
je 0x934b
movl $0x2, -0x24(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x24(%rbp), %edi
movl -0x1c(%rbp), %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x938a
callq 0x8df0
movq %rax, -0x50(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x2380
movq -0x50(%rbp), %rdx
movq %rax, %rcx
movl $0x7c, %edi
leaq 0x241e(%rip), %rsi      # 0xb7a1
movb $0x0, %al
callq 0x8af0
jmp 0x938c
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3540
movl %eax, -0x18(%rbp)
cmpl $0x4, -0x18(%rbp)
je 0x93b3
cmpl $0x7, -0x18(%rbp)
je 0x93b3
cmpl $0x8, -0x18(%rbp)
je 0x93b3
cmpl $0x9, -0x18(%rbp)
jne 0x93c7
movl -0x18(%rbp), %edi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x8f80
movl %eax, -0x4(%rbp)
jmp 0x93de
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0xaa10
movl $0x7c, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)