// File: /workspace/github_c_makefile_star2_O1/mati75[P]evilwm/main.c
// Function: main
int main(int argc, char *argv[]) {
	struct sigaction act;
	int argn = 1, ret;
	Window old_current_window = None;

	act.sa_handler = handle_signal;
	sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	sigaction(SIGTERM, &act, NULL);
	sigaction(SIGINT, &act, NULL);
	sigaction(SIGHUP, &act, NULL);

	// Run until something signals to quit.
	wm_exit = 0;
	while (!wm_exit) {

		// Default options
		option = (struct options){0};
		for (unsigned i = 0; i < NUM_DEFAULT_OPTIONS; i++)
			xconfig_parse_line(evilwm_options, default_options[i]);

		// Read configuration file
		const char *home = getenv("HOME");
		if (home) {
			char *conffile = xmalloc(strlen(home) + sizeof(CONFIG_FILE) + 2);
			strcpy(conffile, home);
			strcat(conffile, "/" CONFIG_FILE);
			xconfig_parse_file(evilwm_options, conffile);
			free(conffile);
		}

		// Parse CLI options
		ret = xconfig_parse_cli(evilwm_options, argc, argv, &argn);
		if (ret == XCONFIG_MISSING_ARG) {
			fprintf(stderr, "%s: missing argument to `%s'\n", argv[0], argv[argn]);
			fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
			exit(1);
		} else if (ret == XCONFIG_BAD_OPTION) {
			if (0 == strcmp(argv[argn], "-h")
			    || 0 == strcmp(argv[argn], "--help")) {
				helptext();
				exit(0);
			} else if (0 == strcmp(argv[argn], "-V")
				   || 0 == strcmp(argv[argn], "--version")) {
				LOG_INFO("evilwm version " VERSION "\n");
				exit(0);
			} else {
				fprintf(stderr, "%s: unrecognised option '%s'\n", argv[0], argv[argn]);
				fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
				exit(1);
			}
		}

		bind_modifier("mask1", opt_grabmask1);
		bind_modifier("mask2", opt_grabmask2);
		bind_modifier("altmask", opt_altmask);

		bind_reset();
		while (opt_bind) {
			char *arg = opt_bind->data;
			opt_bind = list_delete(opt_bind, arg);
			char *ctlstr = strtok(arg, "=");
			if (!ctlstr) {
				free(arg);
				continue;
			}
			char *funcstr = strtok(NULL, "");
			bind_control(ctlstr, funcstr);
			free(arg);
		}

		// Open display only if not already open
		if (!display.dpy) {
			display_open();
		}

		// Manage all eligible clients across all screens
		display_manage_clients();

		// Restore "old current window", if known
		if (old_current_window != None) {
			struct client *c = find_client(old_current_window);
			if (c)
				select_client(c);
		}

		// Event loop will run until interrupted
		end_event_loop = 0;
		event_main_loop();

		// Record "old current window" across SIGHUPs
		old_current_window = current ? current->window : None;

		// Important to clean up anything now that might be reallocated
		// after rereading config, re-managing windows, etc.

		// Free any allocated strings in parsed options
		xconfig_free(evilwm_options);

		// Free application configuration
		while (applications) {
			struct application *app = applications->data;
			applications = list_delete(applications, app);
			if (app->res_name)
				free(app->res_name);
			if (app->res_class)
				free(app->res_class);
			free(app);
		}

		display_unmanage_clients();
		XSync(display.dpy, True);
	}

	// Close display
	display_close();

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, 0x8(%rsp)
movl %edi, 0x1c(%rsp)
leaq 0x4(%rsp), %rax
movl $0x1, (%rax)
leaq 0x354(%rip), %rax       # 0x8c10
leaq 0x28(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq %rbx, %rdi
callq 0x4690
movl $0x0, 0x80(%rbx)
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rbx
movl $0xf, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4400
movl $0x2, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4400
movl $0x1, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4400
movb $0x0, 0x7fdf(%rip)      # 0x108f8
leaq 0x3050(%rip), %r12      # 0xb970
leaq 0x7b89(%rip), %r15      # 0x104b0
leaq 0x39e3(%rip), %r13      # 0xc311
leaq 0x30e4(%rip), %r14      # 0xba19
xorps %xmm0, %xmm0
movups %xmm0, 0x7ff1(%rip)     # 0x10930
movups %xmm0, 0x7fda(%rip)     # 0x10920
movups %xmm0, 0x7fc3(%rip)     # 0x10910
movups %xmm0, 0x7fac(%rip)     # 0x10900
movq $0x0, 0x7fe1(%rip) # 0x10940
xorl %ebx, %ebx
movslq (%rbx,%r12), %rsi
addq %r12, %rsi
movq %r15, %rdi
callq 0x9b64
addq $0x4, %rbx
cmpq $0x20, %rbx
jne 0x8961
leaq 0x300f(%rip), %rdi      # 0xb990
callq 0x44a0
testq %rax, %rax
je 0x89df
movq %rax, %rbx
movq %rax, %rdi
callq 0x42f0
leaq 0xc(%rax), %rdi
callq 0xa0b0
movq %rax, %rbp
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4570
movq %rbp, %rdi
callq 0x42f0
movabsq $0x6d776c6976652e2f, %rcx # imm = 0x6D776C6976652E2F
movq %rcx, (%rbp,%rax)
movl $0x63726d, 0x7(%rbp,%rax) # imm = 0x63726D
movq %r15, %rdi
movq %rbp, %rsi
callq 0x9ea9
movq %rbp, %rdi
callq 0x42d0
movq %r15, %rdi
movl 0x1c(%rsp), %esi
movq 0x8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
callq 0x9f28
cmpl $0x1, %eax
je 0x8b80
cmpl $0x2, %eax
je 0x8bbb
movq 0x7f3a(%rip), %rsi      # 0x10948
leaq 0x260b(%rip), %rdi      # 0xb020
callq 0x4da5
movq 0x7f2f(%rip), %rsi      # 0x10950
leaq 0x25fe(%rip), %rdi      # 0xb026
callq 0x4da5
movq 0x7f24(%rip), %rsi      # 0x10958
leaq 0x25f1(%rip), %rdi      # 0xb02c
callq 0x4da5
callq 0x4a5c
movq 0x7f14(%rip), %rdi      # 0x10960
testq %rdi, %rdi
je 0x8a96
movq 0x8(%rdi), %rbx
movq %rbx, %rsi
callq 0x87d5
movq %rax, 0x7efc(%rip)      # 0x10960
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4580
testq %rax, %rax
je 0x8a8c
movq %rax, %rbp
xorl %edi, %edi
movq %r14, %rsi
callq 0x4580
movq %rbp, %rdi
movq %rax, %rsi
callq 0x4abe
movq %rbx, %rdi
callq 0x42d0
jmp 0x8a45
leaq 0x7c9b(%rip), %rbp      # 0x10738
cmpq $0x0, (%rbp)
jne 0x8aa9
callq 0x722c
callq 0x7519
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8aca
callq 0x53b0
testq %rax, %rax
je 0x8aca
movq %rax, %rdi
callq 0x5868
leaq 0x7e0b(%rip), %rax      # 0x108dc
movb $0x0, (%rax)
callq 0x7614
leaq 0x7c50(%rip), %rax      # 0x10730
movq (%rax), %rax
testq %rax, %rax
je 0x8af2
movq (%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x8afb
movq $0x0, 0x10(%rsp)
movq %r15, %rdi
callq 0xa03c
movq 0x7de6(%rip), %rdi      # 0x108f0
testq %rdi, %rdi
je 0x8b47
movq 0x8(%rdi), %rbx
movq %rbx, %rsi
callq 0x87d5
movq %rax, 0x7dce(%rip)      # 0x108f0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x8b2f
callq 0x42d0
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x8b3d
callq 0x42d0
movq %rbx, %rdi
callq 0x42d0
jmp 0x8b03
callq 0x75f6
movq (%rbp), %rdi
movl $0x1, %esi
callq 0x4500
cmpb $0x1, 0x7d97(%rip)      # 0x108f8
jne 0x8935
callq 0x7441
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x4(%rsp), %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %r14
leaq 0x2e50(%rip), %rsi      # 0xb9e5
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
je 0x8bb4
leaq 0x2e40(%rip), %rsi      # 0xb9e8
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
jne 0x8bca
callq 0x8c27
jmp 0x8bfc
leaq 0x4(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x48bb
leaq 0x2e1e(%rip), %rsi      # 0xb9ef
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
je 0x8bf0
leaq 0x2e0e(%rip), %rsi      # 0xb9f2
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
jne 0x8c03
leaq 0x36f7(%rip), %rdi      # 0xc2ee
callq 0x4130
xorl %edi, %edi
callq 0x4160
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x487a