// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x19(%rbp)
movb $0x0, -0x1a(%rbp)
callq 0x5990
movb $0x0, %al
callq 0x5eb0
movq 0x9d4f(%rip), %rax      # 0xdfb0
leaq 0x1e8(%rip), %rcx       # 0x4450
movq %rcx, (%rax)
movq 0x9d6e(%rip), %rax      # 0xdfe0
movl $0x0, (%rax)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x6347(%rip), %rdx      # 0xa5cd
callq 0x22d0
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x4351
movl -0x14(%rbp), %eax
movl %eax, -0x20(%rbp)
subl $0x63, %eax
je 0x42b8
jmp 0x42a4
movl -0x20(%rbp), %eax
subl $0x69, %eax
je 0x4329
jmp 0x42ae
movl -0x20(%rbp), %eax
subl $0x73, %eax
je 0x4323
jmp 0x432f
movl -0x8(%rbp), %edi
movq 0x9ce6(%rip), %rax      # 0xdfa8
subl (%rax), %edi
movq -0x10(%rbp), %rax
movq 0x9cd9(%rip), %rcx      # 0xdfa8
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rdx
movq 0x9cc2(%rip), %rax      # 0xdfa8
movslq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rdx
callq 0x6a50
movq 0x9cc4(%rip), %rax      # 0xdfc0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq 0x9cb6(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x2100
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x3bc0
jmp 0x4427
movb $0x1, -0x19(%rbp)
jmp 0x434c
movb $0x1, -0x1a(%rbp)
jmp 0x434c
leaq 0x629c(%rip), %rdi      # 0xa5d2
movb $0x0, %al
callq 0x8c20
movl $0x2, 0xa2d9(%rip)      # 0xe620
jmp 0x4427
jmp 0x4278
movq 0x9c50(%rip), %rax      # 0xdfa8
movl (%rax), %ecx
movl -0x8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x8(%rbp)
movq 0x9c3f(%rip), %rax      # 0xdfa8
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
callq 0x59b0
movb $0x0, %al
callq 0x27d0
cmpl $0x0, -0x8(%rbp)
je 0x43eb
testb $0x1, -0x19(%rbp)
jne 0x43eb
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x22c0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x43cf
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x6203(%rip), %rdi      # 0xa5bf
movb $0x0, %al
callq 0x8cf0
movl $0xffffffff, 0xa253(%rip) # imm = 0xFFFFFFFF
jmp 0x4427
movl -0x8(%rbp), %edi
subl $0x1, %edi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
callq 0x6a50
jmp 0x4406
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rax
movq -0x8(%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x6a50
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %edi
callq 0x2090
cmpl $0x0, %eax
je 0x4417
movb $0x1, -0x1a(%rbp)
movl -0x18(%rbp), %edi
movb -0x1a(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x3d60
movb $0x0, %al
callq 0x6af0
movb $0x0, %al
callq 0x5f00
movl 0xa1e5(%rip), %eax      # 0xe620
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)