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

	sh_init(argv[0]);
	if (argv[0] == NULL || *argv[0] == EOS)
		err(SH_ERR, FMT2S, getmyname(), ERR_ALINVAL);
	if (fd_type(FD0, FD_ISDIR))
		goto done;

	if (argc > 1 && *argv[1] == HYPHEN && argv[1][1] == 'v') {
		verbose_flag = true;
		av0p = argv[0], argv = &argv[1], argv[0] = av0p;
		argc--;
	}
	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) {
				shtype = ST_ONELINE;
				dolv  += 1;
				dolc  -= 1;
				argv2p = argv[2];
			} else if (argv[1][1] == 'i') {
				rcflag = DO_SYSTEM_OSHRC;
				shtype = ST_INTERACTIVE;
				if (!sh_on_tty())
					err(SH_ERR, FMT3S,
					    getmyname(), argv[1], ERR_NOTTY);
			} else if (argv[1][1] == 'l') {
				is_login = true;
				rcflag   = DO_SYSTEM_LOGIN;
				shtype   = ST_INTERACTIVE;
				if (!sh_on_tty())
					err(SH_ERR, FMT3S,
					    getmyname(), argv[1], ERR_NOTTY);
			} else if (argv[1][1] == 't')
				shtype = ST_ONELINE;
		} else {
			shtype = ST_COMMANDFILE;
			(void)close(FD0);
			if (open(argv[1], O_RDONLY) != FD0)
				err(SH_ERR,FMT3S,getmyname(),argv[1],ERR_OPEN);
			if (fd_type(FD0, FD_ISDIR))
				goto done;
		}
		fd_free();
	} else {
		dosigs = true;
		fd_free();
		if (sh_on_tty())
			shtype = ST_INTERACTIVE;
	}
	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) {
			if (sasignal(SIGTERM, SIG_IGN) == SIG_DFL)
				sig_child |= S_SIGTERM;
			if (rcflag == 0) {
				if (*argv[0] == HYPHEN) {
					is_login = true;
					rcflag   = DO_SYSTEM_LOGIN;
				} else
					rcflag   = DO_SYSTEM_OSHRC;
			}
			if (is_login)
				if (sasignal(SIGHUP, sighup) == SIG_IGN)
					(void)sasignal(SIGHUP, SIG_IGN);
			rc_init(&rcflag);
			hist_open();
		}
	}

	if (SHTYPE(ST_ONELINE))
		(void)rpx_line();
	else {
		/* Read and execute any rc init files if needed. */
		while (SHTYPE(ST_RCFILE)) {
			cmd_loop(!HALT);
			if (logout_now != 0) {
				logout_now = 0;
				if (is_login)
					goto logout;
				goto done;
			}
			rc_init(&rcflag);
		}

		/* Read and execute the shell's input. */
		cmd_loop(!HALT);
		if (logout_now != 0)
			logout_now = 0;

logout:
		/* Read and execute any rc logout files if needed. */
		rcflag = DO_SYSTEM_LOGOUT;
		rc_logout(&rcflag);
		while (SHTYPE(ST_RCFILE)) {
			cmd_loop(!HALT);
			if (logout_now != 0)
				logout_now = 0;
			rc_logout(&rcflag);
		}
	}

done:
	xfree(tty);
	xfree(user);
	afree(NULL);
	return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x29a0
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2516
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2538
callq 0x8df0
movq %rax, %rdx
movl $0x2, %edi
leaq 0x9277(%rip), %rsi      # 0xb7a1
leaq 0x90fb(%rip), %rcx      # 0xb62c
movb $0x0, %al
callq 0x8af0
xorl %edi, %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0x2b90
testb $0x1, %al
jne 0x254a
jmp 0x254f
jmp 0x2971
cmpl $0x1, -0x8(%rbp)
jle 0x25a8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x25a8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x76, %eax
jne 0x25a8
movb $0x1, 0xbca3(%rip)      # 0xe220
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
cmpl $0x1, -0x8(%rbp)
jle 0x2793
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xbc67(%rip)      # 0xe228
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, 0xbc60(%rip)      # 0xe230
movl -0x8(%rbp), %eax
subl $0x1, %eax
movl %eax, 0xbc5c(%rip)      # 0xe238
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2722
movb $0x1, -0x1d(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x63, %eax
jne 0x264a
cmpl $0x2, -0x8(%rbp)
jle 0x264a
movl $0x1, 0xbc27(%rip)      # 0xe23c
movq 0xbc14(%rip), %rax      # 0xe230
addq $0x8, %rax
movq %rax, 0xbc09(%rip)      # 0xe230
movl 0xbc0b(%rip), %eax      # 0xe238
subl $0x1, %eax
movl %eax, 0xbc02(%rip)      # 0xe238
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xbbfb(%rip)      # 0xe240
jmp 0x2720
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x69, %eax
jne 0x26a1
movl $0x2, -0x1c(%rbp)
movl $0x4, 0xbbd0(%rip)      # 0xe23c
callq 0x2ca0
testb $0x1, %al
jne 0x269f
callq 0x8df0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movl $0x2, %edi
leaq 0x910c(%rip), %rsi      # 0xb79d
leaq 0x8faa(%rip), %r8       # 0xb642
movb $0x0, %al
callq 0x8af0
jmp 0x271e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x6c, %eax
jne 0x26ff
movb $0x1, 0xbb8f(%rip)      # 0xe248
movl $0x1, -0x1c(%rbp)
movl $0x4, 0xbb72(%rip)      # 0xe23c
callq 0x2ca0
testb $0x1, %al
jne 0x26fd
callq 0x8df0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movl $0x2, %edi
leaq 0x90ae(%rip), %rsi      # 0xb79d
leaq 0x8f4c(%rip), %r8       # 0xb642
movb $0x0, %al
callq 0x8af0
jmp 0x271c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x74, %eax
jne 0x271a
movl $0x1, 0xbb22(%rip)      # 0xe23c
jmp 0x271c
jmp 0x271e
jmp 0x2720
jmp 0x278c
movl $0x2, 0xbb10(%rip)      # 0xe23c
xorl %edi, %edi
callq 0x21d0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x2320
cmpl $0x0, %eax
je 0x2773
callq 0x8df0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movl $0x2, %edi
leaq 0x9038(%rip), %rsi      # 0xb79d
leaq 0x8ee3(%rip), %r8       # 0xb64f
movb $0x0, %al
callq 0x8af0
xorl %edi, %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0x2b90
testb $0x1, %al
jne 0x2785
jmp 0x278a
jmp 0x2971
jmp 0x278c
callq 0x2ce0
jmp 0x27b3
movb $0x1, -0x1d(%rbp)
callq 0x2ce0
callq 0x2ca0
testb $0x1, %al
jne 0x27a7
jmp 0x27b1
movl $0x4, 0xba8b(%rip)      # 0xe23c
jmp 0x27b3
testb $0x1, -0x1d(%rbp)
je 0x28ae
movl $0x2, %edi
movl $0x1, %esi
callq 0xac70
cmpq $0x0, %rax
jne 0x27e1
movl 0xba74(%rip), %eax      # 0xe24c
orl $0x1, %eax
movl %eax, 0xba6b(%rip)      # 0xe24c
movl $0x3, %edi
movl $0x1, %esi
callq 0xac70
cmpq $0x0, %rax
jne 0x2805
movl 0xba50(%rip), %eax      # 0xe24c
orl $0x2, %eax
movl %eax, 0xba47(%rip)      # 0xe24c
movl 0xba31(%rip), %eax      # 0xe23c
andl $0x1f, %eax
cmpl $0x4, %eax
jne 0x28ac
movl $0xf, %edi
movl $0x1, %esi
callq 0xac70
cmpq $0x0, %rax
jne 0x283b
movl 0xba1a(%rip), %eax      # 0xe24c
orl $0x4, %eax
movl %eax, 0xba11(%rip)      # 0xe24c
cmpl $0x0, -0x1c(%rbp)
jne 0x2869
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2860
movb $0x1, 0xb9f1(%rip)      # 0xe248
movl $0x1, -0x1c(%rbp)
jmp 0x2867
movl $0x2, -0x1c(%rbp)
jmp 0x2869
testb $0x1, 0xb9d8(%rip)      # 0xe248
je 0x289e
movl $0x1, %edi
leaq 0x4e2(%rip), %rsi       # 0x2d60
callq 0xac70
movl $0x1, %ecx
cmpq %rcx, %rax
jne 0x289c
movl $0x1, %edi
movl $0x1, %esi
callq 0xac70
jmp 0x289e
leaq -0x1c(%rbp), %rdi
callq 0x2d80
callq 0x2f00
jmp 0x28ae
movl 0xb988(%rip), %eax      # 0xe23c
andl $0x1, %eax
cmpl $0x0, %eax
je 0x28c6
callq 0x3010
jmp 0x296f
jmp 0x28c8
movl 0xb96e(%rip), %eax      # 0xe23c
andl $0x8, %eax
cmpl $0x0, %eax
je 0x290a
xorl %edi, %edi
callq 0x3240
movl 0xb96d(%rip), %eax      # 0xe250
cmpl $0x0, %eax
je 0x28ff
movl $0x0, 0xb95e(%rip)      # 0xe250
testb $0x1, 0xb94f(%rip)      # 0xe248
je 0x28fd
jmp 0x2928
jmp 0x2971
leaq -0x1c(%rbp), %rdi
callq 0x2d80
jmp 0x28c8
xorl %edi, %edi
callq 0x3240
movl 0xb939(%rip), %eax      # 0xe250
cmpl $0x0, %eax
je 0x2926
movl $0x0, 0xb92a(%rip)      # 0xe250
jmp 0x2928
movl $0x1, -0x1c(%rbp)
leaq -0x1c(%rbp), %rdi
callq 0x32f0
movl 0xb8fe(%rip), %eax      # 0xe23c
andl $0x8, %eax
cmpl $0x0, %eax
je 0x296d
xorl %edi, %edi
callq 0x3240
movl 0xb8fd(%rip), %eax      # 0xe250
cmpl $0x0, %eax
je 0x2962
movl $0x0, 0xb8ee(%rip)      # 0xe250
leaq -0x1c(%rbp), %rdi
callq 0x32f0
jmp 0x2938
jmp 0x296f
jmp 0x2971
movq 0xb8e0(%rip), %rdi      # 0xe258
callq 0x33f0
movq 0xb8dc(%rip), %rdi      # 0xe260
callq 0x33f0
xorl %eax, %eax
movl %eax, %edi
callq 0x3420
movl 0xb8d0(%rip), %eax      # 0xe268
addq $0x20, %rsp
popq %rbp
retq
nop