// File: /workspace/github_c_makefile_star2_O3/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 $0x10a8, %rsp           # imm = 0x10A8
movq %rsi, %r14
movl %edi, %ebx
movl $0x0, 0xc(%rsp)
movq (%rsi), %r15
leaq 0x410d(%rip), %rdi      # 0x6601
callq 0x6aac
movq %r15, %rdi
callq 0x6ab9
callq 0x2100
movl %eax, %edi
callq 0x6b0d
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 0x2555
callq 0x6a87
leaq 0x6df8(%rip), %rsi      # 0x9337
leaq 0x703b(%rip), %rcx      # 0x9581
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
leaq 0xa0(%rsp), %r15
leaq 0x7035(%rip), %r12      # 0x9599
xorl %ebp, %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x2390
testl %eax, %eax
jns 0x259f
callq 0x6a87
movq %rax, %r13
callq 0x2070
movl (%rax), %edi
callq 0x2380
movl $0x2, %edi
movq %r12, %rsi
movq %r13, %rdx
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x6840
incl %ebp
cmpl $0x3, %ebp
jne 0x2566
xorl %edi, %edi
movl $0xa, %esi
callq 0x2160
movl %eax, 0xedc4(%rip)      # 0x1137c
cmpl $-0x1, %eax
je 0x25d5
movl %eax, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
jne 0x2607
callq 0x6a87
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x6fa9(%rip), %rsi      # 0x9599
movl $0x2, %edi
movq %r15, %rdx
movl $0xa, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x6840
movl 0xed6f(%rip), %edi      # 0x1137c
callq 0x2300
movq %rax, %r12
testq %rax, %rax
leaq 0x6cb1(%rip), %r15      # 0x92d0
cmoveq %r15, %r12
movq %r12, %rdi
callq 0x2130
leaq 0x1(%rax), %r13
movq %r13, %rdi
callq 0x42b3
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x22a0
movq %rbp, 0x9c09(%rip)      # 0xc258
movl 0x9c17(%rip), %edi      # 0xc26c
callq 0x2120
testq %rax, %rax
je 0x2662
movq (%rax), %r15
movq %r15, %rdi
callq 0x2130
leaq 0x1(%rax), %r12
movq %r12, %rdi
callq 0x42b3
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x22a0
movq %r13, 0x9bd2(%rip)      # 0xc260
movl $0x11, %edi
xorl %esi, %esi
callq 0x8034
movq (%r14), %rax
testq %rax, %rax
je 0x26a7
cmpb $0x0, (%rax)
jne 0x26c9
callq 0x6a87
leaq 0x6c84(%rip), %rsi      # 0x9337
leaq 0x6b0e(%rip), %rcx      # 0x91c8
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
leaq 0xa0(%rsp), %rsi
xorl %edi, %edi
callq 0x2390
testl %eax, %eax
js 0x26f3
movl $0xf000, %eax           # imm = 0xF000
andl 0xb8(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x2a95
cmpl $0x2, %ebx
jl 0x2726
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
jne 0x2745
cmpb $0x76, 0x1(%rax)
jne 0x2745
leaq 0x8(%r14), %r15
movb $0x1, 0x9b0e(%rip)      # 0xc220
movq (%r14), %rax
movq %rax, 0x8(%r14)
decl %ebx
cmpl $0x2, %ebx
jb 0x2729
movq 0x10(%r14), %rax
jmp 0x2748
movq %r14, %r15
callq 0x2b5b
movb $0x1, %bl
callq 0x2b3a
testb %al, %al
je 0x27b0
movl $0x4, 0x9af9(%rip)      # 0xc23c
jmp 0x27b0
movq %r14, %r15
leaq 0x8(%r15), %r14
movq %rax, 0x9ad5(%rip)      # 0xc228
movq %r14, 0x9ad6(%rip)      # 0xc230
leal -0x1(%rbx), %ecx
movl %ecx, 0x9ad5(%rip)      # 0xc238
cmpb $0x2d, (%rax)
jne 0x283b
movb 0x1(%rax), %al
cmpl $0x2, %ebx
je 0x28b5
cmpb $0x63, %al
jne 0x28b5
movl $0x1, 0x9ab2(%rip)      # 0xc23c
leaq 0x10(%r15), %rax
movq %rax, 0x9a9b(%rip)      # 0xc230
addl $-0x2, %ebx
movl %ebx, 0x9a9a(%rip)      # 0xc238
movq 0x10(%r15), %rax
movq %rax, 0x9a97(%rip)      # 0xc240
movb $0x1, %bl
callq 0x2b5b
movl $0x1, %esi
movl $0x2, %edi
callq 0x8034
testq %rax, %rax
jne 0x27cb
orb $0x1, 0x9a81(%rip)      # 0xc24c
movl $0x1, %esi
movl $0x3, %edi
callq 0x8034
testq %rax, %rax
jne 0x27e6
orb $0x2, 0x9a66(%rip)      # 0xc24c
movl 0x9a50(%rip), %eax      # 0xc23c
andl $0x1f, %eax
cmpl $0x4, %eax
jne 0x29e2
movl $0x1, %esi
movl $0xf, %edi
callq 0x8034
testq %rax, %rax
jne 0x2813
orb $0x4, 0x9a39(%rip)      # 0xc24c
testb %bl, %bl
je 0x28ea
movq (%r15), %rax
cmpb $0x2d, (%rax)
jne 0x28e2
movb $0x1, 0x9a1a(%rip)      # 0xc248
movl $0x1, 0xc(%rsp)
jmp 0x28f3
movl $0x2, 0x99f7(%rip)      # 0xc23c
xorl %edi, %edi
callq 0x21d0
movq (%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2320
testl %eax, %eax
je 0x2881
callq 0x6a87
movq (%r14), %rcx
leaq 0x6ac8(%rip), %rsi      # 0x9333
leaq 0x6979(%rip), %r8       # 0x91eb
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
leaq 0xa0(%rsp), %rsi
xorl %edi, %edi
callq 0x2390
testl %eax, %eax
js 0x28ab
movl $0xf000, %eax           # imm = 0xF000
andl 0xb8(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x2a95
callq 0x2b5b
jmp 0x29e2
movzbl %al, %eax
movb $0x1, %bl
cmpl $0x74, %eax
je 0x2b2b
cmpl $0x6c, %eax
je 0x2ad6
cmpl $0x69, %eax
jne 0x27ab
movl $0x2, 0xc(%rsp)
jmp 0x2ae5
movl $0x2, 0xc(%rsp)
cmpb $0x1, 0x9957(%rip)      # 0xc248
jne 0x2919
leaq 0x2ca(%rip), %rsi       # 0x2bc4
movl $0x1, %edi
callq 0x8034
cmpq $0x1, %rax
jne 0x2919
movl $0x1, %esi
movl $0x1, %edi
callq 0x8034
leaq 0xc(%rsp), %rdi
callq 0x2bcf
movl $0xffffffff, 0x98cb(%rip) # imm = 0xFFFFFFFF
leaq 0x6ce9(%rip), %rsi      # 0x961d
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x66ab
movq %rbx, %rdi
movl $0xc01, %esi            # imm = 0xC01
xorl %eax, %eax
callq 0x2320
cmpl $-0x1, %eax
je 0x29e2
movl %eax, %ebx
leaq 0x10(%rsp), %rsi
movl %eax, %edi
callq 0x2390
testl %eax, %eax
js 0x29d0
movl $0xf000, %eax           # imm = 0xF000
andl 0x28(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x29d0
movl %ebx, %edi
movl $0xb, %esi
callq 0x2160
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x29d4
movl %ebp, %edi
movl $0x4, %esi
movl $0x401, %edx            # imm = 0x401
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x29d4
movl %ebp, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x29d4
movl %ebx, %edi
callq 0x21d0
movl %ebp, 0x982a(%rip)      # 0xc1f8
jmp 0x29e2
movl %ebx, %edi
jmp 0x29dd
movl %ebx, %edi
callq 0x21d0
movl %ebp, %edi
callq 0x21d0
movl 0x9854(%rip), %eax      # 0xc23c
testb $0x1, %al
jne 0x2a32
testb $0x8, %al
je 0x2a16
leaq 0xc(%rsp), %rbx
xorl %edi, %edi
callq 0x2fc5
cmpl $0x0, 0x984d(%rip)      # 0xc250
jne 0x2a39
movq %rbx, %rdi
callq 0x2bcf
testb $0x8, 0x9828(%rip)      # 0xc23c
jne 0x29f5
xorl %edi, %edi
callq 0x2fc5
cmpl $0x0, 0x982c(%rip)      # 0xc250
je 0x2a4c
movl $0x0, 0x9820(%rip)      # 0xc250
jmp 0x2a4c
callq 0x2cc2
jmp 0x2a95
movl $0x0, 0x980d(%rip)      # 0xc250
cmpb $0x0, 0x97fe(%rip)      # 0xc248
je 0x2a95
leaq 0xc(%rsp), %rdi
movl $0x1, (%rdi)
callq 0x3100
testb $0x8, 0x97d9(%rip)      # 0xc23c
je 0x2a95
leaq 0xc(%rsp), %rbx
xorl %edi, %edi
callq 0x2fc5
cmpl $0x0, 0x97d8(%rip)      # 0xc250
je 0x2a84
movl $0x0, 0x97cc(%rip)      # 0xc250
movq %rbx, %rdi
callq 0x3100
testb $0x8, 0x97a9(%rip)      # 0xc23c
jne 0x2a6a
movq 0x97bc(%rip), %rdi      # 0xc258
testq %rdi, %rdi
je 0x2aa6
callq 0x2050
movq 0x97b3(%rip), %rdi      # 0xc260
testq %rdi, %rdi
je 0x2ab7
callq 0x2050
xorl %edi, %edi
callq 0x3195
movl 0x97a4(%rip), %eax      # 0xc268
addq $0x10a8, %rsp           # imm = 0x10A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x976b(%rip)      # 0xc248
movl $0x1, 0xc(%rsp)
movl $0x4, 0x974d(%rip)      # 0xc23c
callq 0x2b3a
testb %al, %al
je 0x2aff
xorl %ebx, %ebx
jmp 0x27ab
callq 0x6a87
movq (%r14), %rcx
leaq 0x6825(%rip), %rsi      # 0x9333
leaq 0x66c9(%rip), %r8       # 0x91de
xorl %ebx, %ebx
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x6840
jmp 0x27ab
movl $0x1, 0x9707(%rip)      # 0xc23c
jmp 0x27ab