// File: /workspace/github_c_makefile_star2_O3/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, 0x18(%rsp)
movl %edx, 0xc(%rsp)
movl %esi, %r13d
movq %rdi, %r15
movl 0x34(%rdi), %ebp
leal (,%rbp,2), %eax
movl 0x2c(%rdi), %ecx
addl %eax, %ecx
movq %rcx, 0x10(%rsp)
addl 0x30(%rdi), %eax
movq %rax, 0x20(%rsp)
movl 0x24(%rdi), %r14d
movl 0x28(%rdi), %eax
movq %rax, (%rsp)
callq 0x765c
testl %r13d, %r13d
jle 0x86d4
leaq 0x616f(%rip), %rax      # 0xe828
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq 0x10(%r15), %rcx
movslq (%rcx), %rcx
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %eax
jmp 0x86d6
xorl %eax, %eax
testq %r12, %r12
je 0x86df
movl %eax, (%r12)
cmpl $0x0, 0xc(%rsp)
jle 0x8708
leaq 0x613b(%rip), %rcx      # 0xe828
movq (%rcx), %rcx
movq 0xe8(%rcx), %rcx
movq 0x10(%r15), %rdx
movslq (%rdx), %rdx
shlq $0x7, %rdx
movl 0x1c(%rcx,%rdx), %ecx
jmp 0x870a
xorl %ecx, %ecx
testq %rbx, %rbx
je 0x8711
movl %ecx, (%rbx)
subl %ebp, %r14d
movq (%rsp), %rcx
subl %ebp, %ecx
movq %rcx, (%rsp)
testl %r13d, %r13d
je 0x889b
leaq 0x60b2(%rip), %rcx      # 0xe7e0
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x8817
movq 0x10(%r15), %rdx
movq 0x20(%rsp), %rsi
movq (%rsp), %rdi
addl %edi, %esi
movq 0x10(%rsp), %rdi
addl %r14d, %edi
movq 0x8(%rcx), %rbp
cmpq %r15, %rbp
je 0x880b
cmpq 0x10(%rbp), %rdx
jne 0x880b
movl 0x78(%rbp), %r8d
cmpl 0x78(%r15), %r8d
jne 0x880b
movl 0x34(%rbp), %r10d
leal (%r10,%r10), %r8d
movl 0x30(%rbp), %r11d
addl %r8d, %r11d
addl 0x2c(%rbp), %r8d
movl 0x24(%rbp), %r9d
movl 0x28(%rbp), %ebp
subl %r10d, %ebp
addl %ebp, %r11d
cmpl (%rsp), %ebp
jg 0x87a1
cmpl (%rsp), %r11d
jge 0x87b4
cmpl %esi, %ebp
jg 0x87aa
cmpl %esi, %r11d
jge 0x87b4
cmpl (%rsp), %ebp
jl 0x880b
cmpl %esi, %r11d
jg 0x880b
subl %r10d, %r9d
testl %r13d, %r13d
jle 0x87da
movl %r9d, %r8d
subl 0x18(%rsp), %r8d
cmpl %edi, %r8d
jl 0x880b
testq %r12, %r12
je 0x87fb
cmpl (%r12), %r9d
jge 0x880b
movl %r9d, (%r12)
jmp 0x880b
addl %r9d, %r8d
movq 0x18(%rsp), %r9
addl %r8d, %r9d
cmpl %r14d, %r9d
jg 0x880b
testq %r12, %r12
je 0x8804
cmpl (%r12), %r8d
jle 0x880b
movl %r8d, (%r12)
jmp 0x880b
cmpl %eax, %r9d
cmovll %r9d, %eax
jmp 0x880b
cmpl %eax, %r8d
cmovgl %r8d, %eax
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x8751
cmpl $0x0, 0x6062(%rip)      # 0xe880
jle 0x8885
movq 0x6051(%rip), %rcx      # 0xe878
movq 0x10(%rsp), %rdx
addl %r14d, %edx
addq $0x8, %rcx
xorl %esi, %esi
movl -0x8(%rcx), %edi
testl %r13d, %r13d
jle 0x8850
addl (%rcx), %edi
cmpl %edx, %edi
jle 0x8872
testq %r12, %r12
je 0x8866
cmpl (%r12), %edi
jl 0x8860
jmp 0x8872
cmpl %r14d, %edi
jge 0x8872
testq %r12, %r12
je 0x886d
cmpl (%r12), %edi
jle 0x8872
movl %edi, (%r12)
jmp 0x8872
cmpl %eax, %edi
cmovll %edi, %eax
jmp 0x8872
cmpl %eax, %edi
cmovgl %edi, %eax
incq %rsi
movslq 0x6004(%rip), %rdi      # 0xe880
addq $0x10, %rcx
cmpq %rdi, %rsi
jl 0x8835
testl %r13d, %r13d
jle 0x88a2
testq %r12, %r12
je 0x8893
movl (%r12), %eax
subl %r14d, %eax
movl %eax, %r13d
jmp 0x88b9
movq 0x10(%rsp), %r13
jmp 0x88b9
addl 0x10(%rsp), %r14d
testq %r12, %r12
je 0x88b0
movl (%r12), %eax
subl %eax, %r14d
movl %r14d, %r13d
movl %eax, %r14d
movl 0xc(%rsp), %r11d
testl %r11d, %r11d
movq 0x20(%rsp), %r12
je 0x8a10
leaq 0x5f0d(%rip), %rax      # 0xe7e0
movq (%rax), %rax
testq %rax, %rax
je 0x89a5
movq 0x10(%r15), %rcx
addl %r14d, %r13d
movq (%rsp), %rdx
addl %r12d, %edx
movq 0x8(%rax), %rsi
cmpq %r15, %rsi
je 0x8999
cmpq 0x10(%rsi), %rcx
jne 0x8999
movl 0x78(%rsi), %edi
cmpl 0x78(%r15), %edi
jne 0x8999
movl 0x34(%rsi), %r8d
leal (%r8,%r8), %r9d
movl 0x30(%rsi), %edi
addl %r9d, %edi
addl 0x2c(%rsi), %r9d
movl 0x24(%rsi), %r10d
movl 0x28(%rsi), %esi
subl %r8d, %r10d
addl %r10d, %r9d
cmpl %r14d, %r10d
jg 0x893a
cmpl %r14d, %r9d
jge 0x894e
cmpl %r13d, %r10d
jg 0x8944
cmpl %r13d, %r9d
jge 0x894e
cmpl %r14d, %r10d
jl 0x8999
cmpl %r13d, %r9d
jg 0x8999
subl %r8d, %esi
testl %r11d, %r11d
jle 0x8977
testq %rbx, %rbx
sete %dil
movl %esi, %r8d
subl 0x18(%rsp), %r8d
cmpl %edx, %r8d
setl %r8b
orb %dil, %r8b
jne 0x8999
cmpl (%rbx), %esi
jl 0x8997
jmp 0x8999
testq %rbx, %rbx
sete %r8b
addl %edi, %esi
movq 0x18(%rsp), %rdi
addl %esi, %edi
cmpl (%rsp), %edi
setg %dil
orb %r8b, %dil
jne 0x8999
cmpl (%rbx), %esi
jle 0x8999
movl %esi, (%rbx)
movq (%rax), %rax
testq %rax, %rax
jne 0x88ed
cmpl $0x0, 0x5ed4(%rip)      # 0xe880
jle 0x8a10
movq 0x5ec3(%rip), %rax      # 0xe878
addl (%rsp), %r12d
addq $0x4, %rax
xorl %ecx, %ecx
testl %r11d, %r11d
jle 0x89e2
testq %rbx, %rbx
sete %sil
movl 0x8(%rax), %edx
addl (%rax), %edx
cmpl %r12d, %edx
setle %dil
orb %sil, %dil
jne 0x89fd
cmpl (%rbx), %edx
jl 0x89fb
jmp 0x89fd
testq %rbx, %rbx
sete %sil
movl (%rax), %edx
cmpl (%rsp), %edx
setge %dil
orb %sil, %dil
jne 0x89fd
cmpl (%rbx), %edx
jle 0x89fd
movl %edx, (%rbx)
incq %rcx
movslq 0x5e79(%rip), %rdx      # 0xe880
addq $0x10, %rax
cmpq %rdx, %rcx
jl 0x89bf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq