// File: /workspace/github_c_makefile_star2_O1/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 0x698b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x53e4
movl (%rax), %ecx
movl 0x4(%rax), %r15d
leaq 0x8(%rax), %rdx
addq $0xc, %rax
jmp 0x69bb
leaq 0x9da6(%rip), %rax      # 0x10738
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 0x6a54
movl 0x48(%rbx), %eax
testl %eax, %eax
je 0x6a00
testl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jne 0x6a54
movl 0x40(%rbx), %ecx
movl %ecx, 0x28(%rbx)
movl %eax, 0x30(%rbx)
movl $0x0, 0x48(%rbx)
leaq 0x9d49(%rip), %rax      # 0x10738
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x30(%rax), %rdx
callq 0x42e0
jmp 0x6a54
leal -0x1(%r14), %eax
cmpl $0x1, %eax
ja 0x6a54
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 0x9d08(%rip), %rcx      # 0x10738
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 0x6aeb
movl 0x4c(%rbx), %eax
testl %eax, %eax
je 0x6a96
testl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jne 0x6aeb
movl 0x44(%rbx), %ecx
movl %ecx, 0x2c(%rbx)
movl %eax, 0x34(%rbx)
movl $0x0, 0x4c(%rbx)
leaq 0x9cb3(%rip), %rax      # 0x10738
movq (%rbx), %rsi
movq (%rax), %rdi
movq 0x38(%rax), %rdx
callq 0x42e0
jmp 0x6aeb
decl %r14d
cmpl $0x1, %r14d
ja 0x6aeb
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 0x9c72(%rip), %rax      # 0x10738
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 0x6b06
cmpl $0x0, 0x4c(%rbx)
je 0x6b06
cmpl $0x0, 0x3c(%rbx)
je 0x6b38
movl $0x0, 0x3c(%rbx)
jmp 0x6b16
cmpl $0x0, 0x3c(%rbx)
jne 0x6b38
movl 0x38(%rbx), %eax
testl %eax, %eax
je 0x6b38
movl %eax, 0x3c(%rbx)
leaq 0x9c1b(%rip), %rax      # 0x10738
movq (%rax), %rdi
movq 0x8(%rbx), %rsi
movl 0x3c(%rbx), %edx
callq 0x45a0
movq (%rbx), %rdi
movslq 0x3c(%rbx), %rsi
callq 0x8322
movq %rbx, %rdi
callq 0x8090
movq %rbx, %rdi
callq 0x56e7
movq %rbx, %rdi
callq 0x6902
movq %rbx, %rdi
callq 0x9ac4
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq