// File: /workspace/github_c_makefile_star2_O2/mati75[P]evilwm/client_move.c
// Function: client_maximise
void client_maximise(struct client *c, int action, int hv) {
	int monitor_x, monitor_y;
	int monitor_width, monitor_height;

	// Maximising to monitor or screen?
	if (hv & MAXIMISE_SCREEN) {
		monitor_x = monitor_y = 0;
		monitor_width = DisplayWidth(display.dpy, c->screen->screen);
		monitor_height = DisplayHeight(display.dpy, c->screen->screen);
	} else {
		struct monitor *monitor = client_monitor(c, NULL);
		monitor_x = monitor->x;
		monitor_y = monitor->y;
		monitor_width = monitor->width;
		monitor_height = monitor->height;
	}

	if (hv & MAXIMISE_HORZ) {
		if (c->oldw) {
			if (action == NET_WM_STATE_REMOVE || action == NET_WM_STATE_TOGGLE) {
				c->x = c->oldx;
				c->width = c->oldw;
				c->oldw = 0;
				XDeleteProperty(display.dpy, c->window, X_ATOM(_EVILWM_UNMAXIMISED_HORZ));
			}
		} else {
			if (action == NET_WM_STATE_ADD || action == NET_WM_STATE_TOGGLE) {
				unsigned long props[2];
				c->oldx = c->x;
				c->oldw = c->width;
				c->x = monitor_x;
				c->width = monitor_width;
				props[0] = c->oldx;
				props[1] = c->oldw;
				XChangeProperty(display.dpy, c->window, X_ATOM(_EVILWM_UNMAXIMISED_HORZ),
						XA_CARDINAL, 32, PropModeReplace,
						(unsigned char *)&props, 2);
			}
		}
	}
	if (hv & MAXIMISE_VERT) {
		if (c->oldh) {
			if (action == NET_WM_STATE_REMOVE || action == NET_WM_STATE_TOGGLE) {
				c->y = c->oldy;
				c->height = c->oldh;
				c->oldh = 0;
				XDeleteProperty(display.dpy, c->window, X_ATOM(_EVILWM_UNMAXIMISED_VERT));
			}
		} else {
			if (action == NET_WM_STATE_ADD || action == NET_WM_STATE_TOGGLE) {
				unsigned long props[2];
				c->oldy = c->y;
				c->oldh = c->height;
				c->y = monitor_y;
				c->height = monitor_height;
				props[0] = c->oldy;
				props[1] = c->oldh;
				XChangeProperty(display.dpy, c->window, X_ATOM(_EVILWM_UNMAXIMISED_VERT),
						XA_CARDINAL, 32, PropModeReplace,
						(unsigned char *)&props, 2);
			}
		}
	}
	_Bool change_border = 0;
	if (c->oldw && c->oldh) {
		// maximised - remove border
		if (c->border) {
			c->border = 0;
			change_border = 1;
		}
	} else {
		// not maximised - add border
		if (!c->border && c->normal_border) {
			c->border = c->normal_border;
			change_border = 1;
		}
	}
	if (change_border) {
		XSetWindowBorderWidth(display.dpy, c->parent, c->border);
		ewmh_set_net_frame_extents(c->window, c->border);
	}
	ewmh_set_net_wm_state(c);
	client_moveresizeraise(c);
	discard_enter_events(c);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
testb $0x4, %bpl
jne 0x650a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x511e
movl (%rax), %ecx
movl 0x4(%rax), %r15d
leaq 0x8(%rax), %rdx
addq $0xc, %rax
jmp 0x653a
leaq 0x9217(%rip), %rax      # 0xf728
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq 0x10(%rbx), %rcx
movslq (%rcx), %rcx
shlq $0x7, %rcx
leaq (%rax,%rcx), %rdx
addq $0x18, %rdx
addq %rcx, %rax
addq $0x1c, %rax
xorl %r15d, %r15d
xorl %ecx, %ecx
movl (%rax), %r12d
testb $0x1, %bpl
je 0x65ca
movl 0x48(%rbx), %eax
testl %eax, %eax
je 0x657c
testl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jne 0x65ca
movl 0x40(%rbx), %ecx
movl %ecx, 0x28(%rbx)
movl %eax, 0x30(%rbx)
andl $0x0, 0x48(%rbx)
leaq 0x91bd(%rip), %rax      # 0xf728
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x30(%rax), %rdx
callq 0x42e0
jmp 0x65ca
leal -0x1(%r14), %eax
cmpl $0x1, %eax
ja 0x65ca
movl (%rdx), %eax
movslq 0x28(%rbx), %rdx
movl %edx, 0x40(%rbx)
movslq 0x30(%rbx), %rsi
movl %esi, 0x48(%rbx)
movl %ecx, 0x28(%rbx)
movl %eax, 0x30(%rbx)
movq %rsp, %rax
movq %rdx, (%rax)
movq %rsi, 0x8(%rax)
leaq 0x917c(%rip), %rcx      # 0xf728
movq (%rbx), %rsi
movq (%rcx), %rdi
movq 0x30(%rcx), %rdx
pushq $0x6
popq %rcx
pushq $0x20
popq %r8
xorl %r9d, %r9d
pushq $0x2
pushq %rax
callq 0x4640
popq %rcx
popq %rdx
testb $0x2, %bpl
je 0x6658
movl 0x4c(%rbx), %eax
testl %eax, %eax
je 0x6609
testl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jne 0x6658
movl 0x44(%rbx), %ecx
movl %ecx, 0x2c(%rbx)
movl %eax, 0x34(%rbx)
andl $0x0, 0x4c(%rbx)
leaq 0x9130(%rip), %rax      # 0xf728
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x38(%rax), %rdx
callq 0x42e0
jmp 0x6658
decl %r14d
cmpl $0x1, %r14d
ja 0x6658
movslq 0x2c(%rbx), %rax
movl %eax, 0x44(%rbx)
movslq 0x34(%rbx), %rcx
movl %ecx, 0x4c(%rbx)
movl %r15d, 0x2c(%rbx)
movl %r12d, 0x34(%rbx)
movq %rsp, %r10
movq %rax, (%r10)
movq %rcx, 0x8(%r10)
leaq 0x90ef(%rip), %rax      # 0xf728
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x38(%rax), %rdx
pushq $0x6
popq %rcx
pushq $0x20
popq %r8
xorl %r9d, %r9d
pushq $0x2
pushq %r10
callq 0x4640
popq %rcx
popq %rdx
cmpl $0x0, 0x48(%rbx)
je 0x6672
cmpl $0x0, 0x4c(%rbx)
je 0x6672
cmpl $0x0, 0x3c(%rbx)
je 0x66a1
andl $0x0, 0x3c(%rbx)
xorl %edx, %edx
jmp 0x6682
cmpl $0x0, 0x3c(%rbx)
jne 0x66a1
movl 0x38(%rbx), %edx
testl %edx, %edx
je 0x66a1
movl %edx, 0x3c(%rbx)
leaq 0x909f(%rip), %rax      # 0xf728
movq (%rax), %rdi
movq 0x8(%rbx), %rsi
callq 0x45a0
movq (%rbx), %rdi
movslq 0x3c(%rbx), %rsi
callq 0x7dd8
movq %rbx, %rdi
callq 0x7b5e
movq %rbx, %rdi
callq 0x5e5f
movq %rbx, %rdi
callq 0x9438
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq