// File: /workspace/github_c_makefile_star2_O2/ebiggers[P]mysh/mysh_main.c
// Function: main
int main(int argc, char **argv)
{
	int c;
	int in_fd;
	bool from_stdin = false;
	bool interactive = false;

	remove_sigint_handler();
	init_param_map();

#ifdef WITH_READLINE
	/* getc() will return EOF on interrupt, instead of retrying like the
	 * default rl_getc().  This makes readline() return when an interrupt
	 * occurs, which allows the shell to handle SIGINT better.  Similarly,
	 * rl_catch_signals is set to 0 to prevent readline from catching the
	 * SIGINT signal before the shell does.  This is not the only solution:
	 * another would be to have readline handle SIGINT, then pass it onto
	 * the shell, which then does a longjmp() back to the main loop.  I
	 * didn't do it this way because using longjmp() correctly is very
	 * tricky. */
	rl_getc_function = mysh_getc;
	rl_catch_signals = 0;
#endif

	while ((c = getopt(argc, argv, "c:is")) != -1) {
		switch (c) {
		case 'c':
			/* execute string provided on the command line */
			set_positional_params(argc - optind, argv[optind - 1],
					      (const char * const *)&argv[optind]);
			execute_full_shell_input(optarg, strlen(optarg));
			goto out;
		case 's':
			/* read from stdin */
			from_stdin = true;
			break;
		case 'i':
			interactive = true;
			break;
		default:
			mysh_error("invalid option");
			mysh_last_exit_status = 2;
			goto out;
		}
	}
	argc -= optind;
	argv += optind;

	source_myshrc();
	(void)set_pwd();

	if (argc && !from_stdin) {
		in_fd = open(argv[0], O_RDONLY);
		if (in_fd < 0) {
			mysh_error_with_errno("can't open %s", argv[0]);
			mysh_last_exit_status = -1;
			goto out;
		}
		set_positional_params(argc - 1, argv[0], (const char * const *)(argv + 1));
	} else {
		set_positional_params(argc, argv[-1], (const char * const *)argv);
		in_fd = STDIN_FILENO;
	}
	if (isatty(in_fd))
		interactive = true;

	read_loop(in_fd, interactive);
out:
	destroy_positional_params();
	destroy_param_map();
	return mysh_last_exit_status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
callq 0x42a5
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x45b2
leaq 0x150(%rip), %rax       # 0x38a4
movq 0x7885(%rip), %rcx      # 0xafe0
andl $0x0, (%rcx)
movq 0x784b(%rip), %rcx      # 0xafb0
movq %rax, (%rcx)
leaq 0x3d3e(%rip), %r15      # 0x74ad
xorl %r12d, %r12d
movl %r12d, %ecx
movl %ecx, %r12d
movl %ebx, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x22d0
movb $0x1, %cl
cmpl $0x69, %eax
je 0x3775
cmpl $-0x1, %eax
je 0x37dd
cmpl $0x73, %eax
jne 0x379b
movb $0x1, %r13b
jmp 0x3772
cmpl $0x63, %eax
jne 0x380c
movq 0x7801(%rip), %rax      # 0xafa8
movslq (%rax), %rax
subl %eax, %ebx
leaq (%r14,%rax,8), %rdx
movq -0x8(%rdx), %rsi
movl %ebx, %edi
callq 0x4ca0
movq 0x77fe(%rip), %rax      # 0xafc0
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x2100
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3180
jmp 0x3867
movq 0x77c4(%rip), %rax      # 0xafa8
movslq (%rax), %r15
callq 0x42ad
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2657
subl %r15d, %ebx
leaq (%r14,%r15,8), %r14
sete %al
orb %r13b, %al
testb $0x1, %al
je 0x3826
movq -0x8(%r14), %rsi
jmp 0x3841
leaq 0x3c9f(%rip), %rdi      # 0x74b2
xorl %eax, %eax
callq 0x5ef8
movl $0x2, 0x79fc(%rip)      # 0xb220
jmp 0x3867
movq (%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x22c0
testl %eax, %eax
js 0x388a
movl %eax, %ebp
decl %ebx
movq (%r14), %rsi
addq $0x8, %r14
movl %ebx, %edi
movq %r14, %rdx
callq 0x4ca0
movl %ebp, %edi
callq 0x2090
testl %eax, %eax
setne %al
orb %r12b, %al
movzbl %al, %esi
andl $0x1, %esi
movl %ebp, %edi
callq 0x329c
xorl %eax, %eax
callq 0x4d10
xorl %eax, %eax
callq 0x4650
movl 0x79a5(%rip), %eax      # 0xb220
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rsi
leaq 0x3c0b(%rip), %rdi      # 0x749f
xorl %eax, %eax
callq 0x5fb7
orl $-0x1, 0x797e(%rip)     # 0xb220
jmp 0x3867