// File: /workspace/github_c_makefile_star2_O1/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 0x6b41
movq $0x0, (%rsp)
leaq 0x292c(%rip), %r12      # 0x9692
movq 0x526b(%rip), %rbp      # 0xbfd8
leaq 0x2923(%rip), %r13      # 0x9697
xorl %r15d, %r15d
movl %ebx, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2350
cmpl $-0x1, %eax
je 0x6dba
cmpl $0x65, %eax
je 0x6db2
cmpl $0x66, %eax
je 0x6dac
callq 0x6b0f
movl $0x7c, %edi
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x68c8
jmp 0x6d77
movq (%rbp), %r15
jmp 0x6d77
movb $0x1, %al
movq %rax, (%rsp)
jmp 0x6d77
movq 0x520f(%rip), %rax      # 0xbfd0
movslq (%rax), %r12
subl %r12d, %ebx
jg 0x6de4
callq 0x6b0f
leaq 0x28c2(%rip), %rsi      # 0x9697
movl $0x7c, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x68c8
leaq (%r14,%r12,8), %r14
testq %r15, %r15
je 0x6ebf
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 0x6e31
callq 0x6b0f
leaq 0x2521(%rip), %rsi      # 0x9339
leaq 0x273a(%rip), %r8       # 0x9559
movl $0x7c, %edi
movq %rax, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x68c8
movl %ebp, %edi
movl $0x2, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x6e6f
callq 0x6b0f
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x24e0(%rip), %rsi      # 0x933d
movl $0x7c, %edi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x68c8
testb $0x1, (%rsp)
je 0x6eb6
movl $0x2, %edi
movl $0x1, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x6eb6
callq 0x6b0f
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x2499(%rip), %rsi      # 0x933d
movl $0x7c, %edi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x68c8
movl %ebp, %edi
callq 0x21d0
jmp 0x6f06
movzbl (%rsp), %edi
andl $0x1, %edi
movl $0x2, %esi
subl %edi, %esi
incl %edi
callq 0x2160
cmpl $-0x1, %eax
jne 0x6f06
callq 0x6b0f
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x2449(%rip), %rsi      # 0x933d
movl $0x7c, %edi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x68c8
movq (%r14), %rdi
callq 0x3226
cmpl $0x9, %eax
ja 0x6f37
movl $0x390, %ecx            # imm = 0x390
btl %eax, %ecx
jae 0x6f37
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 0x6bcc
movq (%r14), %rdi
movq %r14, %rsi
callq 0x7fd9
movl $0x7c, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq