// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %r9, %rbx
movq %r8, %r12
movq %rcx, 0x20(%rsp)
movl %edx, 0x14(%rsp)
movl %esi, %r13d
movq %rdi, %r15
movl 0x34(%rdi), %ebp
leal (,%rbp,2), %eax
movl 0x2c(%rdi), %ecx
addl %eax, %ecx
movq %rcx, 0x18(%rsp)
addl 0x30(%rdi), %eax
movq %rax, 0x30(%rsp)
movl 0x24(%rdi), %r14d
movl 0x28(%rdi), %eax
movq %rax, 0x8(%rsp)
callq 0x7698
testl %r13d, %r13d
jle 0x86ec
leaq 0x6157(%rip), %rax      # 0xe828
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq 0x10(%r15), %rcx
movslq (%rcx), %rcx
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %ecx
jmp 0x86ee
xorl %ecx, %ecx
testq %r12, %r12
je 0x86f7
movl %ecx, (%r12)
cmpl $0x0, 0x14(%rsp)
jle 0x8720
leaq 0x6123(%rip), %rax      # 0xe828
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq 0x10(%r15), %rdx
movslq (%rdx), %rdx
shlq $0x7, %rdx
movl 0x1c(%rax,%rdx), %eax
jmp 0x8722
xorl %eax, %eax
testq %rbx, %rbx
je 0x8729
movl %eax, (%rbx)
subl %ebp, %r14d
movq 0x8(%rsp), %rdx
subl %ebp, %edx
movq %rdx, 0x8(%rsp)
testl %r13d, %r13d
je 0x885a
leaq 0x6098(%rip), %rdx      # 0xe7e0
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x8864
movq 0x10(%r15), %rsi
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %r8
addl %r8d, %edi
movq 0x18(%rsp), %r8
addl %r14d, %r8d
movl %r8d, 0x2c(%rsp)
movq 0x8(%rdx), %r8
cmpq %r15, %r8
je 0x8846
cmpq 0x10(%r8), %rsi
jne 0x8846
movl 0x78(%r8), %r9d
cmpl 0x78(%r15), %r9d
jne 0x8846
movl 0x34(%r8), %r11d
leal (%r11,%r11), %r9d
movl 0x30(%r8), %ebp
addl %r9d, %ebp
addl 0x2c(%r8), %r9d
movl 0x24(%r8), %r10d
movl 0x28(%r8), %r8d
subl %r11d, %r8d
addl %r8d, %ebp
cmpl 0x8(%rsp), %r8d
jg 0x87c5
cmpl 0x8(%rsp), %ebp
jge 0x87d9
cmpl %edi, %r8d
jg 0x87ce
cmpl %edi, %ebp
jge 0x87d9
cmpl 0x8(%rsp), %r8d
jl 0x8846
cmpl %edi, %ebp
jg 0x8846
subl %r11d, %r10d
testl %r13d, %r13d
jle 0x8812
movl %r10d, %r8d
subl 0x20(%rsp), %r8d
cmpl 0x2c(%rsp), %r8d
jl 0x8846
movl %ecx, %r8d
testq %r12, %r12
je 0x87fc
movl (%r12), %r8d
cmpl %r8d, %r10d
movl %r10d, %r9d
cmovgel %ecx, %r9d
testq %r12, %r12
je 0x8849
cmpl %r8d, %r10d
jl 0x8842
jmp 0x8849
addl %r9d, %r10d
movq 0x20(%rsp), %r8
addl %r10d, %r8d
cmpl %r14d, %r8d
jg 0x8846
movl %ecx, %r8d
testq %r12, %r12
je 0x882e
movl (%r12), %r8d
cmpl %r8d, %r10d
movl %r10d, %r9d
cmovlel %ecx, %r9d
testq %r12, %r12
je 0x8849
cmpl %r8d, %r10d
jle 0x8849
movl %r10d, (%r12)
movl %ecx, %r9d
movq (%rdx), %rdx
movl %r9d, %ecx
testq %rdx, %rdx
jne 0x8772
jmp 0x8867
movq 0x18(%rsp), %r13
jmp 0x8930
movl %ecx, %r9d
cmpl $0x0, 0x6012(%rip)      # 0xe880
jle 0x8900
movq 0x5ffd(%rip), %rcx      # 0xe878
movq 0x18(%rsp), %rdx
addl %r14d, %edx
addq $0x8, %rcx
xorl %esi, %esi
movl -0x8(%rcx), %r8d
testl %r13d, %r13d
jle 0x88bc
addl (%rcx), %r8d
cmpl %edx, %r8d
jle 0x88e5
movl %r9d, %r10d
testq %r12, %r12
je 0x88a6
movl (%r12), %r10d
cmpl %r10d, %r8d
movl %r8d, %edi
cmovgel %r9d, %edi
testq %r12, %r12
je 0x88e8
cmpl %r10d, %r8d
jl 0x88e1
jmp 0x88e8
cmpl %r14d, %r8d
jge 0x88e5
movl %r9d, %r10d
testq %r12, %r12
je 0x88cd
movl (%r12), %r10d
cmpl %r10d, %r8d
movl %r8d, %edi
cmovlel %r9d, %edi
testq %r12, %r12
je 0x88e8
cmpl %r10d, %r8d
jle 0x88e8
movl %r8d, (%r12)
movl %r9d, %edi
incq %rsi
movslq 0x5f8e(%rip), %r8       # 0xe880
addq $0x10, %rcx
movl %edi, %r9d
cmpq %r8, %rsi
jl 0x8889
jmp 0x8903
movl %r9d, %edi
testl %r13d, %r13d
jle 0x8919
testq %r12, %r12
je 0x8911
movl (%r12), %edi
subl %r14d, %edi
movl %edi, %r13d
jmp 0x8930
addl 0x18(%rsp), %r14d
testq %r12, %r12
je 0x8927
movl (%r12), %edi
subl %edi, %r14d
movl %r14d, %r13d
movl %edi, %r14d
movl 0x14(%rsp), %ebp
testl %ebp, %ebp
movq 0x30(%rsp), %r12
je 0x8ac5
leaq 0x5e98(%rip), %rcx      # 0xe7e0
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x8a3d
movq 0x10(%r15), %rdx
addl %r14d, %r13d
movq 0x8(%rsp), %rsi
addl %r12d, %esi
movq 0x8(%rcx), %r8
cmpq %r15, %r8
je 0x8a2b
cmpq 0x10(%r8), %rdx
jne 0x8a2b
movl 0x78(%r8), %edi
cmpl 0x78(%r15), %edi
jne 0x8a2b
movl 0x34(%r8), %r9d
leal (%r9,%r9), %r10d
movl 0x30(%r8), %edi
addl %r10d, %edi
addl 0x2c(%r8), %r10d
movl 0x24(%r8), %r11d
movl 0x28(%r8), %r8d
subl %r9d, %r11d
addl %r11d, %r10d
cmpl %r14d, %r11d
jg 0x89b3
cmpl %r14d, %r10d
jge 0x89c7
cmpl %r13d, %r11d
jg 0x89bd
cmpl %r13d, %r10d
jge 0x89c7
cmpl %r14d, %r11d
jl 0x8a2b
cmpl %r13d, %r10d
jg 0x8a2b
subl %r9d, %r8d
testl %ebp, %ebp
jle 0x89f9
movl %r8d, %edi
subl 0x20(%rsp), %edi
cmpl %esi, %edi
jl 0x8a2b
movl %eax, %r9d
testq %rbx, %rbx
je 0x89e4
movl (%rbx), %r9d
cmpl %r9d, %r8d
movl %r8d, %edi
cmovgel %eax, %edi
testq %rbx, %rbx
je 0x8a2d
cmpl %r9d, %r8d
jl 0x8a28
jmp 0x8a2d
addl %edi, %r8d
movq 0x20(%rsp), %rdi
addl %r8d, %edi
cmpl 0x8(%rsp), %edi
jg 0x8a2b
movl %eax, %r9d
testq %rbx, %rbx
je 0x8a15
movl (%rbx), %r9d
cmpl %r9d, %r8d
movl %r8d, %edi
cmovlel %eax, %edi
testq %rbx, %rbx
je 0x8a2d
cmpl %r9d, %r8d
jle 0x8a2d
movl %r8d, (%rbx)
movl %eax, %edi
movq (%rcx), %rcx
movl %edi, %eax
testq %rcx, %rcx
jne 0x8963
jmp 0x8a3f
movl %eax, %edi
cmpl $0x0, 0x5e3a(%rip)      # 0xe880
jle 0x8ac5
movq 0x5e29(%rip), %rax      # 0xe878
addl 0x8(%rsp), %r12d
addq $0x4, %rax
xorl %ecx, %ecx
testl %ebp, %ebp
jle 0x8a87
movl 0x8(%rax), %edx
addl (%rax), %edx
cmpl %r12d, %edx
jle 0x8aae
movl %edi, %r8d
testq %rbx, %rbx
je 0x8a73
movl (%rbx), %r8d
cmpl %r8d, %edx
movl %edx, %esi
cmovgel %edi, %esi
testq %rbx, %rbx
je 0x8ab0
cmpl %r8d, %edx
jl 0x8aac
jmp 0x8ab0
movl (%rax), %edx
cmpl 0x8(%rsp), %edx
jge 0x8aae
movl %edi, %r8d
testq %rbx, %rbx
je 0x8a9a
movl (%rbx), %r8d
cmpl %r8d, %edx
movl %edx, %esi
cmovlel %edi, %esi
testq %rbx, %rbx
je 0x8ab0
cmpl %r8d, %edx
jle 0x8ab0
movl %edx, (%rbx)
movl %edi, %esi
incq %rcx
movslq 0x5dc6(%rip), %rdx      # 0xe880
addq $0x10, %rax
movl %esi, %edi
cmpq %rdx, %rcx
jl 0x8a5a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq