// File: /workspace/github_c_makefile_star2_O2/kasymovga[P]devilwm/screen.c
// Function: next_border
void next_border(Client *c, int dirx, int diry, int step_over, int *borderx, int *bordery) {
	Client * c_iter;
	struct list *iter;
	int tx, ty, c_iter_height, c_iter_width, c_iter_x, c_iter_y;
	int c_width = c->width + c->border * 2;
	int c_height = c->height + c->border * 2;
	int c_x = c->x - c->border;
	int c_y = c->y - c->border;
	int dummyx, dummyy;
	find_monitors(c);
	if (!borderx)
		borderx = &dummyx;

	if (!bordery)
		bordery = &dummyy;

	if (dirx > 0)
		*borderx = DisplayWidth(dpy, c->screen->screen);
	else
		*borderx = 0;

	if (diry > 0)
		*bordery = DisplayHeight(dpy, c->screen->screen);
	else
		*bordery = 0;

	if (dirx) {
		for (iter = clients_tab_order; iter; iter = iter->next) {
			c_iter =iter->data;
			if (c->screen != c_iter->screen || c_iter == c
#ifdef VWM
					|| c_iter->vdesk != c->vdesk
#endif
					)
				continue;

			c_iter_height = c_iter->height + c_iter->border * 2;
			c_iter_width = c_iter->width + c_iter->border * 2;
			c_iter_x = c_iter->x - c_iter->border;
			c_iter_y = c_iter->y - c_iter->border;
			if (
					(c_iter_y <= c_y            && c_iter_y + c_iter_height >= c_y           ) ||
					(c_iter_y <= c_y + c_height && c_iter_y + c_iter_height >= c_y + c_height) ||
					(c_iter_y >= c_y            && c_iter_y + c_iter_height <= c_y + c_height)
					) {
				if (dirx > 0) {
					tx = c_iter_x;
					if (tx - step_over >= c_x + c_width && tx < *borderx)
						*borderx = tx;

				} else {
					tx = c_iter_x + c_iter_width;
					if (tx + step_over <= c_x && tx > *borderx)
						*borderx = tx;

				}
			}
		}
		for (int i = 0; i < monitors_count; i++) {
			if (dirx > 0) {
				if (monitors[i].x + monitors[i].width > c_x + c_width && monitors[i].x + monitors[i].width < *borderx)
					*borderx = monitors[i].x + monitors[i].width;
			} else {
				if (monitors[i].x < c_x && monitors[i].x > *borderx)
					*borderx = monitors[i].x;
			}
		}
		if (dirx > 0)
			c_width = *borderx - c_x;
		else {
			c_width = c_width + c_x - *borderx;
			c_x = *borderx;
		}
	}
	if (diry) {
		for (iter = clients_tab_order; iter; iter = iter->next) {
			c_iter=iter->data;
			if (c->screen != c_iter->screen || c_iter == c
#ifdef VWM
					|| c_iter->vdesk != c->vdesk
#endif
			)
				continue;

			c_iter_height = c_iter->height + c_iter->border * 2;
			c_iter_width = c_iter->width + c_iter->border * 2;
			c_iter_x = c_iter->x - c_iter->border;
			c_iter_y = c_iter->y - c_iter->border;
			if (
					(c_iter_x <= c_x           && c_iter_x + c_iter_width >= c_x          ) ||
					(c_iter_x <= c_x + c_width && c_iter_x + c_iter_width >= c_x + c_width) ||
					(c_iter_x >= c_x           && c_iter_x + c_iter_width <= c_x + c_width)
					) {
				if (diry > 0) {
					ty = c_iter_y;
					if (ty - step_over >= c_y + c_height && ty < *bordery)
						*bordery = ty;
				} else {
					ty = c_iter_y + c_iter_height;
					if (ty + step_over <= c_y && ty > *bordery)
						*bordery = ty;
				}
			}
		}
		for (int i = 0; i < monitors_count; i++) {
			if (diry > 0) {
				if (monitors[i].y + monitors[i].height > c_y + c_height && monitors[i].y + monitors[i].height < *bordery)
					*bordery = monitors[i].y + monitors[i].height;
			} else {
				if (monitors[i].y < c_y && monitors[i].y > *bordery)
					*bordery = monitors[i].y;
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movq %r8, %r12
movq %rcx, 0x8(%rsp)
movl %edx, 0x14(%rsp)
movl %esi, %r13d
movq %rdi, %r15
movl 0x34(%rdi), %eax
movq %rax, 0x20(%rsp)
addl %eax, %eax
movl 0x2c(%rdi), %r14d
addl %eax, %r14d
addl 0x30(%rdi), %eax
movq %rax, 0x18(%rsp)
movl 0x24(%rdi), %eax
movl %eax, 0x4(%rsp)
movl 0x28(%rdi), %ebp
callq 0x72ec
testl %r13d, %r13d
jle 0x8329
leaq 0x551a(%rip), %rax      # 0xd828
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq 0x10(%r15), %rcx
movslq (%rcx), %rcx
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %eax
jmp 0x832b
xorl %eax, %eax
testq %r12, %r12
movl 0x14(%rsp), %r11d
movq 0x18(%rsp), %r9
movq %rbp, %r10
je 0x8341
movl %eax, (%r12)
testl %r11d, %r11d
movl 0x4(%rsp), %ebp
jle 0x836c
leaq 0x54d7(%rip), %rcx      # 0xd828
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq 0x10(%r15), %rdx
movslq (%rdx), %rdx
shlq $0x7, %rdx
movl 0x1c(%rcx,%rdx), %ecx
jmp 0x836e
xorl %ecx, %ecx
testq %rbx, %rbx
je 0x8375
movl %ecx, (%rbx)
movq 0x20(%rsp), %rcx
subl %ecx, %ebp
subl %ecx, %r10d
testl %r13d, %r13d
je 0x84ff
movl %ebp, %edx
movq %r10, %rbp
leal (%r10,%r9), %ecx
movl %edx, 0x4(%rsp)
addl %edx, %r14d
leaq 0x5441(%rip), %rdx      # 0xd7e0
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x8471
movq 0x8(%rdx), %r10
cmpq %r15, %r10
je 0x839f
movq 0x10(%r10), %rsi
cmpq %rsi, 0x10(%r15)
jne 0x839f
movl 0x78(%r10), %esi
cmpl 0x78(%r15), %esi
jne 0x839f
movl 0x34(%r10), %r8d
leal (%r8,%r8), %esi
movl 0x30(%r10), %r9d
addl %esi, %r9d
addl 0x2c(%r10), %esi
movl 0x24(%r10), %edi
movl 0x28(%r10), %r10d
subl %r8d, %r10d
addl %r10d, %r9d
cmpl %ebp, %r10d
jg 0x83f3
cmpl %ebp, %r9d
jge 0x8407
cmpl %ecx, %r10d
jg 0x83fd
cmpl %ecx, %r9d
jge 0x8407
cmpl %ebp, %r10d
jl 0x839f
cmpl %ecx, %r9d
jg 0x839f
subl %r8d, %edi
testl %r13d, %r13d
jle 0x8432
movl %edi, %esi
subl 0x8(%rsp), %esi
cmpl %r14d, %esi
jl 0x839f
testq %r12, %r12
je 0x845d
cmpl (%r12), %edi
jge 0x839f
movl %edi, (%r12)
jmp 0x839f
addl %edi, %esi
movq 0x8(%rsp), %rdi
addl %esi, %edi
cmpl 0x4(%rsp), %edi
jg 0x839f
testq %r12, %r12
je 0x8467
cmpl (%r12), %esi
jle 0x839f
movl %esi, (%r12)
jmp 0x839f
cmpl %eax, %edi
cmovll %edi, %eax
jmp 0x839f
cmpl %eax, %esi
cmovgl %esi, %eax
jmp 0x839f
movq 0x5400(%rip), %rcx      # 0xd878
addq $0x8, %rcx
xorl %edx, %edx
movq %rbp, %r10
movl 0x4(%rsp), %ebp
movslq 0x53f4(%rip), %rsi      # 0xd880
cmpq %rsi, %rdx
jge 0x84d7
movl -0x8(%rcx), %esi
testl %r13d, %r13d
jle 0x84ad
addl (%rcx), %esi
cmpl %r14d, %esi
jle 0x84ce
testq %r12, %r12
je 0x84c2
cmpl (%r12), %esi
jl 0x84bc
jmp 0x84ce
cmpl %ebp, %esi
jge 0x84ce
testq %r12, %r12
je 0x84c9
cmpl (%r12), %esi
jle 0x84ce
movl %esi, (%r12)
jmp 0x84ce
cmpl %eax, %esi
cmovll %esi, %eax
jmp 0x84ce
cmpl %eax, %esi
cmovgl %esi, %eax
incq %rdx
addq $0x10, %rcx
jmp 0x8485
testl %r13d, %r13d
movq 0x18(%rsp), %r9
jle 0x84f1
testq %r12, %r12
je 0x84ea
movl (%r12), %eax
subl %ebp, %eax
movl %eax, %r14d
jmp 0x84ff
testq %r12, %r12
je 0x84fa
movl (%r12), %eax
subl %eax, %r14d
movl %eax, %ebp
testl %r11d, %r11d
je 0x862c
addl %ebp, %r14d
addl %r10d, %r9d
leaq 0x52cb(%rip), %rax      # 0xd7e0
movq (%rax), %rax
testq %rax, %rax
je 0x85cc
movq 0x8(%rax), %rcx
cmpq %r15, %rcx
je 0x8515
movq 0x10(%rcx), %rdx
cmpq %rdx, 0x10(%r15)
jne 0x8515
movl 0x78(%rcx), %edx
cmpl 0x78(%r15), %edx
jne 0x8515
movl 0x34(%rcx), %esi
leal (%rsi,%rsi), %edi
movl 0x30(%rcx), %edx
addl %edi, %edx
addl 0x2c(%rcx), %edi
movl 0x24(%rcx), %r8d
movl 0x28(%rcx), %ecx
subl %esi, %r8d
addl %r8d, %edi
cmpl %ebp, %r8d
jg 0x8561
cmpl %ebp, %edi
jge 0x8575
cmpl %r14d, %r8d
jg 0x856b
cmpl %r14d, %edi
jge 0x8575
cmpl %ebp, %r8d
jl 0x8515
cmpl %r14d, %edi
jg 0x8515
subl %esi, %ecx
testl %r11d, %r11d
jle 0x859e
testq %rbx, %rbx
sete %dl
movl %ecx, %esi
subl 0x8(%rsp), %esi
cmpl %r9d, %esi
setl %sil
orb %dl, %sil
jne 0x8515
cmpl (%rbx), %ecx
jge 0x8515
jmp 0x85c5
testq %rbx, %rbx
sete %sil
addl %edx, %ecx
movq 0x8(%rsp), %rdx
addl %ecx, %edx
cmpl %r10d, %edx
setg %dl
orb %sil, %dl
jne 0x8515
cmpl (%rbx), %ecx
jle 0x8515
movl %ecx, (%rbx)
jmp 0x8515
movq 0x52a5(%rip), %rax      # 0xd878
addq $0x4, %rax
xorl %ecx, %ecx
movslq 0x52a0(%rip), %rdx      # 0xd880
cmpq %rdx, %rcx
jge 0x862c
testl %r11d, %r11d
jle 0x8608
testq %rbx, %rbx
sete %sil
movl 0x8(%rax), %edx
addl (%rax), %edx
cmpl %r9d, %edx
setle %dil
orb %sil, %dil
jne 0x8623
cmpl (%rbx), %edx
jl 0x8621
jmp 0x8623
testq %rbx, %rbx
sete %sil
movl (%rax), %edx
cmpl %r10d, %edx
setge %dil
orb %sil, %dil
jne 0x8623
cmpl (%rbx), %edx
jle 0x8623
movl %edx, (%rbx)
incq %rcx
addq $0x10, %rax
jmp 0x85d9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq