// File: /workspace/github_c_makefile_star2_O3/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 0x6834
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5371
movl (%rax), %ecx
movl 0x4(%rax), %r15d
leaq 0x8(%rax), %rdx
addq $0xc, %rax
jmp 0x6864
leaq 0x8eed(%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 0x68fd
movl 0x48(%rbx), %eax
testl %eax, %eax
je 0x68a9
testl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jne 0x68fd
movl 0x40(%rbx), %ecx
movl %ecx, 0x28(%rbx)
movl %eax, 0x30(%rbx)
movl $0x0, 0x48(%rbx)
leaq 0x8e90(%rip), %rax      # 0xf728
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x30(%rax), %rdx
callq 0x42e0
jmp 0x68fd
leal -0x1(%r14), %eax
cmpl $0x1, %eax
ja 0x68fd
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 0x8e4f(%rip), %rcx      # 0xf728
movq (%rbx), %rsi
movq (%rcx), %rdi
movq 0x30(%rcx), %rdx
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
pushq $0x2
pushq %rax
callq 0x4640
addq $0x10, %rsp
testb $0x2, %bpl
je 0x6994
movl 0x4c(%rbx), %eax
testl %eax, %eax
je 0x693f
testl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jne 0x6994
movl 0x44(%rbx), %ecx
movl %ecx, 0x2c(%rbx)
movl %eax, 0x34(%rbx)
movl $0x0, 0x4c(%rbx)
leaq 0x8dfa(%rip), %rax      # 0xf728
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x38(%rax), %rdx
callq 0x42e0
jmp 0x6994
decl %r14d
cmpl $0x1, %r14d
ja 0x6994
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 0x8db9(%rip), %rax      # 0xf728
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x38(%rax), %rdx
movl $0x6, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
pushq $0x2
pushq %r10
callq 0x4640
addq $0x10, %rsp
cmpl $0x0, 0x48(%rbx)
je 0x69b1
cmpl $0x0, 0x4c(%rbx)
je 0x69b1
cmpl $0x0, 0x3c(%rbx)
je 0x69e0
movl $0x0, 0x3c(%rbx)
xorl %edx, %edx
jmp 0x69c1
cmpl $0x0, 0x3c(%rbx)
jne 0x69e0
movl 0x38(%rbx), %edx
testl %edx, %edx
je 0x69e0
movl %edx, 0x3c(%rbx)
leaq 0x8d60(%rip), %rax      # 0xf728
movq (%rax), %rdi
movq 0x8(%rbx), %rsi
callq 0x45a0
movq (%rbx), %rdi
movslq 0x3c(%rbx), %rsi
callq 0x81c9
movq %rbx, %rdi
callq 0x7f2c
movq %rbx, %rdi
callq 0x5611
movq %rbx, %rdi
callq 0x67ab
movq %rbx, %rdi
callq 0x9911
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq