// File: /workspace/github_c_makefile_star2_O2/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 0x3a8(%rip), %rax       # 0x86a8
leaq 0x28(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq %rbx, %rdi
callq 0x4690
andl $0x0, 0x80(%rbx)
xorl %ebp, %ebp
pushq $0xf
popq %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4400
pushq $0x2
popq %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4400
pushq $0x1
popq %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x4400
movb $0x0, 0x759b(%rip)      # 0xf8e8
leaq 0x714c(%rip), %r13      # 0xf4a0
leaq 0x2fb0(%rip), %r14      # 0xb30b
leaq 0x26b1(%rip), %r12      # 0xaa13
leaq 0x2607(%rip), %r15      # 0xa970
xorl %eax, %eax
testb $0x1, %bpl
jne 0x85a8
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x759c(%rip)     # 0xf920
movups %xmm0, 0x7585(%rip)     # 0xf910
movups %xmm0, 0x756e(%rip)     # 0xf900
movups %xmm0, 0x7557(%rip)     # 0xf8f0
andq $0x0, 0x758f(%rip)      # 0xf930
xorl %ebx, %ebx
cmpq $0x20, %rbx
je 0x83be
movslq (%rbx,%r15), %rsi
addq %r15, %rsi
movq %r13, %rdi
callq 0x94d0
addq $0x4, %rbx
jmp 0x83a3
leaq 0x25cb(%rip), %rdi      # 0xa990
callq 0x44a0
testq %rax, %rax
je 0x8423
movq %rax, %rbx
movq %rax, %rdi
callq 0x42f0
leaq 0xc(%rax), %rdi
callq 0x99bc
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 %r13, %rdi
movq %rbp, %rsi
callq 0x981f
movq %rbp, %rdi
callq 0x42d0
movq %r13, %rdi
movl 0x1c(%rsp), %esi
movq 0x8(%rsp), %rdx
leaq 0x4(%rsp), %rcx
callq 0x9889
cmpl $0x1, %eax
je 0x85c1
cmpl $0x2, %eax
je 0x85ff
movq 0x74e6(%rip), %rsi      # 0xf938
leaq 0x1bc7(%rip), %rdi      # 0xa020
callq 0x4b7b
movq 0x74db(%rip), %rsi      # 0xf940
leaq 0x1bba(%rip), %rdi      # 0xa026
callq 0x4b7b
movq 0x74d0(%rip), %rsi      # 0xf948
leaq 0x1bad(%rip), %rdi      # 0xa02c
callq 0x4b7b
callq 0x489c
movq 0x74c0(%rip), %rdi      # 0xf950
testq %rdi, %rdi
je 0x84da
movq 0x8(%rdi), %rbx
movq %rbx, %rsi
callq 0x824d
movq %rax, 0x74a8(%rip)      # 0xf950
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4580
testq %rax, %rax
je 0x84d0
movq %rax, %rbp
xorl %edi, %edi
movq %r12, %rsi
callq 0x4580
movq %rbp, %rdi
movq %rax, %rsi
callq 0x48f8
movq %rbx, %rdi
callq 0x42d0
jmp 0x8489
leaq 0x7247(%rip), %rax      # 0xf728
cmpq $0x0, (%rax)
jne 0x84ec
callq 0x6d8c
callq 0x708a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x850d
callq 0x50fc
testq %rax, %rax
je 0x850d
movq %rax, %rdi
callq 0x54cf
leaq 0x73b8(%rip), %rax      # 0xf8cc
movb $0x0, (%rax)
callq 0x7174
leaq 0x71fd(%rip), %rax      # 0xf720
movq (%rax), %rax
testq %rax, %rax
je 0x8535
movq (%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x853e
movq $0x0, 0x10(%rsp)
movq %r13, %rdi
callq 0x9952
movq 0x7393(%rip), %rdi      # 0xf8e0
testq %rdi, %rdi
je 0x8580
movq 0x8(%rdi), %rbx
movq %rbx, %rsi
callq 0x824d
movq %rax, 0x737b(%rip)      # 0xf8e0
movq (%rbx), %rdi
callq 0x42d0
movq 0x8(%rbx), %rdi
callq 0x42d0
movq %rbx, %rdi
callq 0x42d0
jmp 0x8546
callq 0x7156
leaq 0x719c(%rip), %rax      # 0xf728
movq (%rax), %rdi
pushq $0x1
popq %rsi
callq 0x4500
movb 0x734a(%rip), %bpl      # 0xf8e8
movq 0x10(%rsp), %rax
jmp 0x836b
callq 0x6fc9
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
movb (%r14), %bl
cmpb $0x2d, %bl
jne 0x85e5
cmpb $0x68, 0x1(%r14)
jne 0x85e5
cmpb $0x0, 0x2(%r14)
je 0x85f8
leaq 0x23f9(%rip), %rsi      # 0xa9e5
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
jne 0x8644
callq 0x86bf
jmp 0x8676
movq 0x69ea(%rip), %rbx      # 0xeff0
movq (%rbx), %rdi
movq 0x8(%rsp), %r14
movq (%r14), %rdx
movslq 0x4(%rsp), %rax
movq (%r14,%rax,8), %rcx
leaq 0x237f(%rip), %rsi      # 0xa9a0
xorl %eax, %eax
callq 0x4700
movq (%rbx), %rdi
movq (%r14), %rdx
leaq 0x2389(%rip), %rsi      # 0xa9be
xorl %eax, %eax
callq 0x4700
pushq $0x1
popq %rdi
callq 0x4160
cmpb $0x2d, %bl
jne 0x8657
cmpb $0x56, 0x1(%r14)
jne 0x8657
cmpb $0x0, 0x2(%r14)
je 0x866a
leaq 0x238e(%rip), %rsi      # 0xa9ec
movq %r14, %rdi
callq 0x4540
testl %eax, %eax
jne 0x867d
leaq 0x2c77(%rip), %rdi      # 0xb2e8
callq 0x4130
xorl %edi, %edi
callq 0x4160
movq 0x696c(%rip), %rbx      # 0xeff0
movq (%rbx), %rdi
movq 0x8(%rsp), %r15
movq (%r15), %rdx
leaq 0x2360(%rip), %rsi      # 0xa9f6
movq %r14, %rcx
xorl %eax, %eax
callq 0x4700
movq (%rbx), %rdi
movq (%r15), %rdx
jmp 0x862e