// File: /workspace/github_c_makefile_star2_O0/s3lase[P]v6shell/sh6.c
// Function: main
int
main(int argc, char **argv)
{
	bool dosigs = false;

	sh_init(argv[0]);
	if (argv[0] == NULL || *argv[0] == EOS)
		err(SH_ERR, FMT1S, ERR_ALINVAL);
	if (fd_isdir(FD0))
		goto done;

	if (argc > 1) {
		name = argv[1];
		dolv = &argv[1];
		dolc = argc - 1;
		if (*argv[1] == HYPHEN) {
			dosigs = true;
			if (argv[1][1] == 'c' && argc > 2) {
				dolv  += 1;
				dolc  -= 1;
				argv2p = argv[2];
			} else if (argv[1][1] == 't')
				one_line_flag = 2;
		} else {
			(void)close(FD0);
			if (open(argv[1], O_RDONLY) != FD0)
				err(SH_ERR, FMT2S, argv[1], ERR_OPEN);
			if (fd_isdir(FD0))
				goto done;
		}
	} else {
		dosigs = true;
		if (isatty(FD0) != 0 && isatty(FD2) != 0)
			prompt = (geteuid() != 0) ? "% " : "# ";
	}
	if (dosigs) {
		if (sasignal(SIGINT, SIG_IGN) == SIG_DFL)
			sig_child |= S_SIGINT;
		if (sasignal(SIGQUIT, SIG_IGN) == SIG_DFL)
			sig_child |= S_SIGQUIT;
		if (prompt != NULL)
			if (sasignal(SIGTERM, SIG_IGN) == SIG_DFL)
				sig_child |= S_SIGTERM;
	}
	fd_free();
	sh_magic();

loop:
	if (prompt != NULL)
		fd_print(FD2, "%s", prompt);
	rpx_line();
	goto loop;

done:
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2630
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x23ef
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2409
movl $0x2, %edi
leaq 0x430b(%rip), %rsi      # 0x6706
leaq 0x400a(%rip), %rdx      # 0x640c
movb $0x0, %al
callq 0x4590
xorl %edi, %edi
callq 0x2780
testb $0x1, %al
jne 0x2416
jmp 0x241b
jmp 0x2619
cmpl $0x1, -0x8(%rbp)
jle 0x2520
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x5d4c(%rip)      # 0x8180
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, 0x5d45(%rip)      # 0x8188
movl -0x8(%rbp), %eax
subl $0x1, %eax
movl %eax, 0x5d41(%rip)      # 0x8190
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x24cb
movb $0x1, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x63, %eax
jne 0x24ac
cmpl $0x2, -0x8(%rbp)
jle 0x24ac
movq 0x5d07(%rip), %rax      # 0x8188
addq $0x8, %rax
movq %rax, 0x5cfc(%rip)      # 0x8188
movl 0x5cfe(%rip), %eax      # 0x8190
subl $0x1, %eax
movl %eax, 0x5cf5(%rip)      # 0x8190
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x5cee(%rip)      # 0x8198
jmp 0x24c9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x74, %eax
jne 0x24c7
movl $0x2, 0x5cd9(%rip)      # 0x81a0
jmp 0x24c9
jmp 0x251e
xorl %edi, %edi
callq 0x2180
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x2230
cmpl $0x0, %eax
je 0x250a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movl $0x2, %edi
leaq 0x4206(%rip), %rsi      # 0x6702
leaq 0x3f1f(%rip), %rcx      # 0x6422
movb $0x0, %al
callq 0x4590
xorl %edi, %edi
callq 0x2780
testb $0x1, %al
jne 0x2517
jmp 0x251c
jmp 0x2619
jmp 0x251e
jmp 0x2564
movb $0x1, -0x11(%rbp)
xorl %edi, %edi
callq 0x20a0
cmpl $0x0, %eax
je 0x2562
movl $0x2, %edi
callq 0x20a0
cmpl $0x0, %eax
je 0x2562
callq 0x2170
movl %eax, %edx
leaq 0x3ee4(%rip), %rax      # 0x6431
leaq 0x3eda(%rip), %rcx      # 0x642e
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, 0x5c46(%rip)      # 0x81a8
jmp 0x2564
testb $0x1, -0x11(%rbp)
je 0x25e4
movl $0x2, %edi
movl $0x1, %esi
callq 0x5090
cmpq $0x0, %rax
jne 0x258e
movl 0x5c2b(%rip), %eax      # 0x81b0
orl $0x1, %eax
movl %eax, 0x5c22(%rip)      # 0x81b0
movl $0x3, %edi
movl $0x1, %esi
callq 0x5090
cmpq $0x0, %rax
jne 0x25b2
movl 0x5c07(%rip), %eax      # 0x81b0
orl $0x2, %eax
movl %eax, 0x5bfe(%rip)      # 0x81b0
cmpq $0x0, 0x5bee(%rip)      # 0x81a8
je 0x25e2
movl $0xf, %edi
movl $0x1, %esi
callq 0x5090
cmpq $0x0, %rax
jne 0x25e0
movl 0x5bd9(%rip), %eax      # 0x81b0
orl $0x4, %eax
movl %eax, 0x5bd0(%rip)      # 0x81b0
jmp 0x25e2
jmp 0x25e4
callq 0x27e0
callq 0x2840
cmpq $0x0, 0x5bb2(%rip)      # 0x81a8
je 0x2612
movq 0x5ba9(%rip), %rdx      # 0x81a8
movl $0x2, %edi
leaq 0x3e29(%rip), %rsi      # 0x6434
movb $0x0, %al
callq 0x47e0
callq 0x2910
jmp 0x25ee
movl 0x5b95(%rip), %eax      # 0x81b4
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)