// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movl %edi, %r14d
movl $0x0, 0xc(%rsp)
movq (%rsi), %r15
leaq 0x4190(%rip), %rdi      # 0x6685
callq 0x6b34
movq %r15, %rdi
callq 0x6b41
callq 0x2100
movl %eax, %edi
callq 0x6b95
callq 0x21c0
movl %eax, %ebp
movl %eax, 0x9d51(%rip)      # 0xc26c
callq 0x2150
cmpl %eax, %ebp
jne 0x2534
callq 0x22e0
movl %eax, %ebp
callq 0x22b0
cmpl %eax, %ebp
je 0x2556
callq 0x6b0f
leaq 0x6dfd(%rip), %rsi      # 0x933d
leaq 0x7044(%rip), %rcx      # 0x958b
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x68c8
leaq 0xa0(%rsp), %r15
leaq 0x703e(%rip), %r12      # 0x95a3
xorl %ebp, %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x2390
testl %eax, %eax
jns 0x25a0
callq 0x6b0f
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 0x68c8
incl %ebp
cmpl $0x3, %ebp
jne 0x2567
xorl %edi, %edi
movl $0xa, %esi
callq 0x2160
movl %eax, 0xedc3(%rip)      # 0x1137c
cmpl $-0x1, %eax
je 0x25d6
movl %eax, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
jne 0x2608
callq 0x6b0f
movq %rax, %r15
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x6fb2(%rip), %rsi      # 0x95a3
movl $0x2, %edi
movq %r15, %rdx
movl $0xa, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x68c8
movl 0xed6e(%rip), %edi      # 0x1137c
callq 0x2300
movq %rax, %r12
testq %rax, %rax
leaq 0x6cb3(%rip), %r15      # 0x92d3
cmoveq %r15, %r12
movq %r12, %rdi
callq 0x2130
leaq 0x1(%rax), %r13
movq %r13, %rdi
callq 0x42ee
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x22a0
movq %rbp, 0x9c08(%rip)      # 0xc258
movl 0x9c16(%rip), %edi      # 0xc26c
callq 0x2120
testq %rax, %rax
je 0x2663
movq (%rax), %r15
movq %r15, %rdi
callq 0x2130
leaq 0x1(%rax), %r12
movq %r12, %rdi
callq 0x42ee
movq %rax, %r13
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x22a0
movq %r13, 0x9bd1(%rip)      # 0xc260
movl $0x11, %edi
xorl %esi, %esi
callq 0x81f0
movq (%rbx), %rax
testq %rax, %rax
je 0x26a8
cmpb $0x0, (%rax)
jne 0x26ca
callq 0x6b0f
leaq 0x6c89(%rip), %rsi      # 0x933d
leaq 0x6b0d(%rip), %rcx      # 0x91c8
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x68c8
leaq 0xa0(%rsp), %rsi
xorl %edi, %edi
callq 0x2390
testl %eax, %eax
js 0x26f4
movl $0xf000, %eax           # imm = 0xF000
andl 0xb8(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x2ae1
cmpl $0x2, %r14d
jl 0x271e
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x271e
cmpb $0x76, 0x1(%rax)
jne 0x271e
movb $0x1, 0x9b10(%rip)      # 0xc220
movq (%rbx), %rax
movq %rax, 0x8(%rbx)
addq $0x8, %rbx
decl %r14d
cmpl $0x2, %r14d
jl 0x2792
leaq 0x8(%rbx), %r15
movq 0x8(%rbx), %rax
movq %rax, 0x9af5(%rip)      # 0xc228
movq %r15, 0x9af6(%rip)      # 0xc230
leal -0x1(%r14), %ecx
movl %ecx, 0x9af4(%rip)      # 0xc238
movb (%rax), %bpl
cmpb $0x2d, %bpl
jne 0x27b3
movb 0x1(%rax), %al
cmpl $0x2, %r14d
je 0x2829
cmpb $0x63, %al
jne 0x2829
movl $0x1, 0x9ad0(%rip)      # 0xc23c
leaq 0x10(%rbx), %rax
movq %rax, 0x9ab9(%rip)      # 0xc230
addl $-0x2, %r14d
movl %r14d, 0x9ab6(%rip)     # 0xc238
movq 0x10(%rbx), %rax
movq %rax, 0x9ab3(%rip)      # 0xc240
jmp 0x2898
callq 0x2b43
callq 0x2b22
testb %al, %al
je 0x28a7
movl $0x4, 0x9a8e(%rip)      # 0xc23c
jmp 0x28a7
movl $0x2, 0x9a7f(%rip)      # 0xc23c
xorl %edi, %edi
callq 0x21d0
movq (%r15), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x2320
testl %eax, %eax
je 0x27f9
callq 0x6b0f
movq (%r15), %rcx
leaq 0x6b56(%rip), %rsi      # 0x9339
leaq 0x6a01(%rip), %r8       # 0x91eb
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x68c8
leaq 0xa0(%rsp), %rsi
xorl %edi, %edi
callq 0x2390
testl %eax, %eax
js 0x2898
movl $0xf000, %eax           # imm = 0xF000
andl 0xb8(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x2ae1
jmp 0x2898
movzbl %al, %eax
cmpl $0x74, %eax
je 0x288e
cmpl $0x6c, %eax
je 0x2845
cmpl $0x69, %eax
jne 0x2898
movl $0x2, 0xc(%rsp)
jmp 0x2854
movb $0x1, 0x99fc(%rip)      # 0xc248
movl $0x1, 0xc(%rsp)
movl $0x4, 0x99de(%rip)      # 0xc23c
callq 0x2b22
testb %al, %al
jne 0x2898
callq 0x6b0f
movq (%r15), %rcx
leaq 0x6ac3(%rip), %rsi      # 0x9339
leaq 0x6961(%rip), %r8       # 0x91de
movl $0x2, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x68c8
jmp 0x2898
movl $0x1, 0x99a4(%rip)      # 0xc23c
callq 0x2b43
cmpb $0x2d, %bpl
jne 0x2a2a
movl $0x1, %esi
movl $0x2, %edi
callq 0x81f0
testq %rax, %rax
jne 0x28c2
orb $0x1, 0x998a(%rip)      # 0xc24c
movl $0x1, %esi
movl $0x3, %edi
callq 0x81f0
testq %rax, %rax
jne 0x28dd
orb $0x2, 0x996f(%rip)      # 0xc24c
movl 0x9959(%rip), %eax      # 0xc23c
andl $0x1f, %eax
cmpl $0x4, %eax
jne 0x2a2a
movl $0x1, %esi
movl $0xf, %edi
callq 0x81f0
testq %rax, %rax
jne 0x290a
orb $0x4, 0x9942(%rip)      # 0xc24c
cmpl $0x0, 0xc(%rsp)
jne 0x2932
movq (%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x292a
movb $0x1, 0x9928(%rip)      # 0xc248
movl $0x1, 0xc(%rsp)
jmp 0x2932
movl $0x2, 0xc(%rsp)
cmpb $0x1, 0x990f(%rip)      # 0xc248
jne 0x2961
leaq 0x257(%rip), %rsi       # 0x2b99
movl $0x1, %edi
callq 0x81f0
cmpq $0x1, %rax
jne 0x2961
movl $0x1, %esi
movl $0x1, %edi
callq 0x81f0
leaq 0xc(%rsp), %rdi
callq 0x2ba4
movl $0xffffffff, 0x9883(%rip) # imm = 0xFFFFFFFF
leaq 0x6cab(%rip), %rsi      # 0x9627
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
callq 0x672f
movq %rbx, %rdi
movl $0xc01, %esi            # imm = 0xC01
xorl %eax, %eax
callq 0x2320
cmpl $-0x1, %eax
je 0x2a2a
movl %eax, %ebx
leaq 0x10(%rsp), %rsi
movl %eax, %edi
callq 0x2390
testl %eax, %eax
js 0x2a18
movl $0xf000, %eax           # imm = 0xF000
andl 0x28(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x2a18
movl %ebx, %edi
movl $0xb, %esi
callq 0x2160
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x2a1c
movl %ebp, %edi
movl $0x4, %esi
movl $0x401, %edx            # imm = 0x401
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x2a1c
movl %ebp, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x2a1c
movl %ebx, %edi
callq 0x21d0
movl %ebp, 0x97e2(%rip)      # 0xc1f8
jmp 0x2a2a
movl %ebx, %edi
jmp 0x2a25
movl %ebx, %edi
callq 0x21d0
movl %ebp, %edi
callq 0x21d0
testb $0x1, 0x980b(%rip)      # 0xc23c
jne 0x2a7e
testb $0x8, 0x9802(%rip)      # 0xc23c
je 0x2a62
leaq 0xc(%rsp), %rbx
xorl %edi, %edi
callq 0x2f99
cmpl $0x0, 0x9801(%rip)      # 0xc250
jne 0x2a85
movq %rbx, %rdi
callq 0x2ba4
testb $0x8, 0x97dc(%rip)      # 0xc23c
jne 0x2a41
xorl %edi, %edi
callq 0x2f99
cmpl $0x0, 0x97e0(%rip)      # 0xc250
je 0x2a98
movl $0x0, 0x97d4(%rip)      # 0xc250
jmp 0x2a98
callq 0x2c96
jmp 0x2ae1
movl $0x0, 0x97c1(%rip)      # 0xc250
cmpb $0x0, 0x97b2(%rip)      # 0xc248
je 0x2ae1
leaq 0xc(%rsp), %rdi
movl $0x1, (%rdi)
callq 0x30d4
testb $0x8, 0x978d(%rip)      # 0xc23c
je 0x2ae1
leaq 0xc(%rsp), %rbx
xorl %edi, %edi
callq 0x2f99
cmpl $0x0, 0x978c(%rip)      # 0xc250
je 0x2ad0
movl $0x0, 0x9780(%rip)      # 0xc250
movq %rbx, %rdi
callq 0x30d4
testb $0x8, 0x975d(%rip)      # 0xc23c
jne 0x2ab6
movq 0x9770(%rip), %rdi      # 0xc258
testq %rdi, %rdi
je 0x2af2
callq 0x2050
movq 0x9767(%rip), %rdi      # 0xc260
testq %rdi, %rdi
je 0x2b03
callq 0x2050
xorl %edi, %edi
callq 0x315e
movl 0x9758(%rip), %eax      # 0xc268
addq $0x10a8, %rsp           # imm = 0x10A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq