// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
andl $0x0, 0x4(%rsp)
movq (%rsi), %r15
leaq 0x3b13(%rip), %rdi      # 0x6007
callq 0x647a
movq %r15, %rdi
callq 0x6487
callq 0x2100
movl %eax, %edi
callq 0x64d9
callq 0x21c0
movl %eax, %ebp
movl %eax, 0x9d52(%rip)      # 0xc26c
callq 0x2150
cmpl %eax, %ebp
jne 0x2533
callq 0x22e0
movl %eax, %ebp
callq 0x22b0
cmpl %eax, %ebp
je 0x2553
callq 0x6455
leaq 0x5dfe(%rip), %rsi      # 0x833d
leaq 0x6041(%rip), %rcx      # 0x8587
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6218
pushq $0x1
popq %rbp
leaq 0x6042(%rip), %r12      # 0x859f
pushq $0x2
popq %r15
xorl %r13d, %r13d
cmpl $0x3, %r13d
je 0x25a7
movl %r13d, %edi
movl %ebp, %esi
callq 0x2ab0
testb %al, %al
jne 0x25a2
callq 0x6455
movq %rax, %rbx
callq 0x2070
movl (%rax), %edi
callq 0x2380
movl %r15d, %edi
movq %r12, %rsi
movq %rbx, %rdx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x6218
incl %r13d
jmp 0x2564
pushq $0xa
popq %rsi
xorl %edi, %edi
callq 0x2160
movl %eax, 0xedc5(%rip)      # 0x1137c
cmpl $-0x1, %eax
je 0x25d0
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movl %eax, %edi
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
jne 0x25fe
callq 0x6455
movq %rax, %rbx
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x5fb4(%rip), %rsi      # 0x859f
pushq $0x2
popq %rdi
pushq $0xa
popq %rcx
movq %rbx, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x6218
movl 0xed78(%rip), %edi      # 0x1137c
callq 0x2300
testq %rax, %rax
leaq 0x5cc0(%rip), %r12      # 0x82d3
cmoveq %r12, %rax
movq %rax, %rdi
callq 0x52ee
movq %rax, 0x9c32(%rip)      # 0xc258
movl 0x9c40(%rip), %edi      # 0xc26c
callq 0x2120
testq %rax, %rax
je 0x2639
movq (%rax), %r12
movq %r12, %rdi
callq 0x52ee
movq %rax, 0x9c18(%rip)      # 0xc260
pushq $0x11
popq %rdi
xorl %esi, %esi
callq 0x789c
movq (%r14), %rax
testq %rax, %rax
je 0x265f
cmpb $0x0, (%rax)
jne 0x267f
callq 0x6455
leaq 0x5cd2(%rip), %rsi      # 0x833d
leaq 0x5b56(%rip), %rcx      # 0x81c8
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6218
xorl %edi, %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0x2ab0
testb %al, %al
jne 0x29c2
movq 0x8(%rsp), %rdx
cmpl $0x2, %edx
jl 0x26cb
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
jne 0x26f1
cmpb $0x76, 0x1(%rax)
jne 0x26f1
leaq 0x8(%r14), %r12
movb $0x1, 0x9b69(%rip)      # 0xc220
movq (%r14), %rax
movq %rax, 0x8(%r14)
decl %edx
cmpl $0x2, %edx
jb 0x26ce
movq 0x10(%r14), %rax
jmp 0x26f4
movq %r14, %r12
callq 0x2b4e
xorl %ebx, %ebx
callq 0x2b2f
testb %al, %al
je 0x27c7
movl $0x4, 0x9b50(%rip)      # 0xc23c
jmp 0x27c7
movq %r14, %r12
leaq 0x8(%r12), %r13
movq %rax, 0x9b28(%rip)      # 0xc228
movq %r13, 0x9b29(%rip)      # 0xc230
leal -0x1(%rdx), %ecx
movl %ecx, 0x9b28(%rip)      # 0xc238
movb (%rax), %r14b
cmpb $0x2d, %r14b
jne 0x275c
movb 0x1(%rax), %al
cmpl $0x2, %edx
je 0x2840
cmpb $0x63, %al
jne 0x2840
movl $0x1, 0x9b05(%rip)      # 0xc23c
leaq 0x10(%r12), %rax
movq %rax, 0x9aed(%rip)      # 0xc230
addl $-0x2, %edx
movl %edx, 0x9aec(%rip)      # 0xc238
movq 0x10(%r12), %rax
movq %rax, 0x9ae8(%rip)      # 0xc240
xorl %ebx, %ebx
jmp 0x27b8
movl $0x2, 0x9ad6(%rip)      # 0xc23c
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x21d0
movq (%r13), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2320
testl %eax, %eax
je 0x27a4
callq 0x6455
movq (%r13), %rcx
leaq 0x5ba9(%rip), %rsi      # 0x8339
leaq 0x5a54(%rip), %r8       # 0x81eb
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6218
xorl %edi, %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0x2ab0
testb %al, %al
jne 0x29c2
callq 0x2b4e
cmpb $0x2d, %r14b
jne 0x2985
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
callq 0x789c
testq %rax, %rax
jne 0x27de
orb $0x1, 0x9a6e(%rip)      # 0xc24c
pushq $0x3
popq %rdi
pushq $0x1
popq %rsi
callq 0x789c
testq %rax, %rax
jne 0x27f5
orb $0x2, 0x9a57(%rip)      # 0xc24c
movl 0x9a41(%rip), %eax      # 0xc23c
andl $0x1f, %eax
cmpl $0x4, %eax
jne 0x2985
pushq $0xf
popq %rdi
pushq $0x1
popq %rsi
callq 0x789c
testq %rax, %rax
jne 0x281e
orb $0x4, 0x9a2e(%rip)      # 0xc24c
testl %ebx, %ebx
jne 0x28b5
movq (%r12), %rax
cmpb $0x2d, (%rax)
jne 0x28ad
movb $0x1, 0x9a12(%rip)      # 0xc248
movl $0x1, 0x4(%rsp)
jmp 0x28be
movzbl %al, %eax
xorl %ebx, %ebx
cmpl $0x74, %eax
je 0x2aa1
cmpl $0x6c, %eax
je 0x2a54
cmpl $0x69, %eax
jne 0x27b8
movl $0x2, 0x4(%rsp)
movl $0x4, 0x99ca(%rip)      # 0xc23c
callq 0x2b2f
movl %r15d, %ebx
testb %al, %al
jne 0x27b8
callq 0x6455
movq (%r13), %rcx
leaq 0x5aa7(%rip), %rsi      # 0x8339
leaq 0x5945(%rip), %r8       # 0x81de
pushq $0x2
popq %rbx
movl %ebx, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6218
jmp 0x27b8
movl $0x2, 0x4(%rsp)
cmpb $0x1, 0x998c(%rip)      # 0xc248
jne 0x28de
leaq 0x2c8(%rip), %rsi       # 0x2b8d
pushq $0x1
popq %rdi
callq 0x789c
cmpq $0x1, %rax
jne 0x28de
pushq $0x1
popq %rdi
pushq $0x1
popq %rsi
callq 0x789c
leaq 0x4(%rsp), %rdi
callq 0x2b98
orl $-0x1, 0x9909(%rip)     # 0xc1f8
leaq 0x5d2d(%rip), %rsi      # 0x8623
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x60ab
movq %rbx, %rdi
movl $0xc01, %esi            # imm = 0xC01
xorl %eax, %eax
callq 0x2320
cmpl $-0x1, %eax
je 0x2985
movl %eax, %ebx
movl %eax, %edi
movl $0x8000, %esi           # imm = 0x8000
callq 0x2ab0
testb %al, %al
je 0x2973
pushq $0xb
popq %rsi
movl %ebx, %edi
callq 0x2160
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x2977
pushq $0x4
popq %rsi
movl %ebp, %edi
movl $0x401, %edx            # imm = 0x401
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x2977
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movl %ebp, %edi
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x2977
movl %ebx, %edi
callq 0x21d0
movl %ebp, 0x9887(%rip)      # 0xc1f8
jmp 0x2985
movl %ebx, %edi
jmp 0x2980
movl %ebx, %edi
callq 0x21d0
movl %ebp, %edi
callq 0x21d0
movl 0x98b1(%rip), %ebp      # 0xc23c
testb $0x1, %bpl
jne 0x29bd
leaq 0x4(%rsp), %rbx
xorl %edi, %edi
callq 0x2f36
movl 0x98ad(%rip), %eax      # 0xc250
testb $0x8, %bpl
je 0x29f9
testl %eax, %eax
jne 0x2a09
movq %rbx, %rdi
callq 0x2b98
movl 0x9881(%rip), %ebp      # 0xc23c
jmp 0x2996
callq 0x2c89
movq 0x988f(%rip), %rdi      # 0xc258
callq 0x2050
movq 0x988b(%rip), %rdi      # 0xc260
callq 0x2050
xorl %edi, %edi
callq 0x30f5
movl 0x9881(%rip), %eax      # 0xc268
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %eax, %eax
je 0x2a1c
movl $0x0, 0x9849(%rip)      # 0xc250
jmp 0x2a1c
movl $0x0, 0x983d(%rip)      # 0xc250
cmpb $0x0, 0x982e(%rip)      # 0xc248
je 0x29c2
leaq 0x4(%rsp), %rbx
movl $0x1, (%rbx)
movq %rbx, %rdi
callq 0x305e
testb $0x8, 0x9806(%rip)      # 0xc23c
je 0x29c2
xorl %edi, %edi
callq 0x2f36
cmpl $0x0, 0x980a(%rip)      # 0xc250
je 0x2a27
movl $0x0, 0x97fe(%rip)      # 0xc250
jmp 0x2a27
movb $0x1, 0x97ed(%rip)      # 0xc248
movl $0x1, 0x4(%rsp)
movl $0x4, 0x97cf(%rip)      # 0xc23c
callq 0x2b2f
testb %al, %al
jne 0x2a9a
callq 0x6455
movq (%r13), %rcx
leaq 0x58b3(%rip), %rsi      # 0x8339
leaq 0x5751(%rip), %r8       # 0x81de
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6218
movl %ebp, %ebx
jmp 0x27b8
movl $0x1, 0x9791(%rip)      # 0xc23c
jmp 0x27b8