// File: /workspace/github_c_makefile_star2_O0/anachronic[P]st/st.c
// Function: selsnap
void
selsnap(int *x, int *y, int direction)
{
	int newx, newy, xt, yt;
	int rtop = 0, rbot = term.row - 1;
	int delim, prevdelim;
	const Glyph *gp, *prevgp;

	if (!IS_SET(MODE_ALTSCREEN))
		rtop += -term.histf + term.scr, rbot += term.scr;

	switch (sel.snap) {
	case SNAP_WORD:
		/*
		 * Snap around if the word wraps around at the end or
		 * beginning of a line.
		 */
		prevgp = &TLINE(*y)[*x];
		prevdelim = ISDELIM(prevgp->u);
		for (;;) {
			newx = *x + direction;
			newy = *y;
			if (!BETWEEN(newx, 0, term.col - 1)) {
				newy += direction;
				newx = (newx + term.col) % term.col;
				if (!BETWEEN(newy, rtop, rbot))
					break;

				if (direction > 0)
					yt = *y, xt = *x;
				else
					yt = newy, xt = newx;
				if (!(TLINE(yt)[xt].mode & ATTR_WRAP))
					break;
			}

			if (newx >= tlinelen(TLINE(newy)))
				break;

			gp = &TLINE(newy)[newx];
			delim = ISDELIM(gp->u);
			if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim ||
			    (delim && !(gp->u == ' ' && prevgp->u == ' '))))
				break;

			*x = newx;
			*y = newy;
			prevgp = gp;
			prevdelim = delim;
		}
		break;
	case SNAP_LINE:
		/*
		 * Snap around if the the previous line or the current one
		 * has set ATTR_WRAP at its end. Then the whole next or
		 * previous line will be selected.
		 */
		*x = (direction < 0) ? 0 : term.col - 1;
		if (direction < 0) {
			for (; *y > rtop; *y -= 1) {
				if (!tiswrapped(TLINE(*y-1)))
					break;
			}
		} else if (direction > 0) {
			for (; *y < rbot; *y += 1) {
				if (!tiswrapped(TLINE(*y)))
					break;
			}
		}
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x28(%rbp)
movl 0x1444d(%rip), %eax     # 0x1cee0
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl 0x1831d(%rip), %eax     # 0x20dbc
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x8ac7
xorl %eax, %eax
subl 0x182c5(%rip), %eax     # 0x20d74
addl 0x182c3(%rip), %eax     # 0x20d78
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl 0x182b7(%rip), %eax     # 0x20d78
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl 0x143eb(%rip), %eax     # 0x1ceb8
movl %eax, -0x4c(%rbp)
subl $0x1, %eax
je 0x8ae8
jmp 0x8ad7
movl -0x4c(%rbp), %eax
subl $0x2, %eax
je 0x8e21
jmp 0x8fb4
movq -0x10(%rbp), %rax
movl (%rax), %eax
cmpl 0x18284(%rip), %eax     # 0x20d78
jge 0x8b2d
movl 0x18274(%rip), %eax     # 0x20d70
movq -0x10(%rbp), %rcx
addl (%rcx), %eax
subl 0x18270(%rip), %eax     # 0x20d78
addl $0x1, %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x143be(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
jmp 0x8b4b
movq 0x143b4(%rip), %rax     # 0x1cee8
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl 0x18238(%rip), %ecx     # 0x20d78
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq (%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, (%rcx)
movb %al, -0x59(%rbp)
je 0x8b8e
leaq 0x11b4a(%rip), %rax     # 0x1a6c0
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movl (%rax), %esi
callq 0x5680
cmpq $0x0, %rax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
xorl %eax, %eax
cmpl -0x18(%rbp), %eax
jg 0x8bc9
movl -0x18(%rbp), %eax
movl 0x14326(%rip), %ecx     # 0x1cee4
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x8c9e
movl -0x14(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl 0x14309(%rip), %eax     # 0x1cee4
cltd
idivl 0x14302(%rip)           # 0x1cee4
movl %edx, -0x18(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x8bf5
movl -0x1c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jle 0x8bfa
jmp 0x8e1c
cmpl $0x0, -0x14(%rbp)
jle 0x8c14
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x8c20
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x1814f(%rip), %eax     # 0x20d78
jge 0x8c5f
movl 0x1813f(%rip), %eax     # 0x20d70
addl -0x24(%rbp), %eax
subl 0x1813e(%rip), %eax     # 0x20d78
addl $0x1, %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x1428c(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
jmp 0x8c7a
movq 0x14282(%rip), %rax     # 0x1cee8
movl -0x24(%rbp), %ecx
subl 0x18109(%rip), %ecx     # 0x20d78
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x4(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
jne 0x8c9c
jmp 0x8e1c
jmp 0x8c9e
movl -0x18(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x180cb(%rip), %eax     # 0x20d78
jge 0x8ce3
movl 0x180bb(%rip), %eax     # 0x20d70
addl -0x1c(%rbp), %eax
subl 0x180ba(%rip), %eax     # 0x20d78
addl $0x1, %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x14208(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
jmp 0x8cfe
movq 0x141fe(%rip), %rax     # 0x1cee8
movl -0x1c(%rbp), %ecx
subl 0x18085(%rip), %ecx     # 0x20d78
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x6750
movl %eax, %ecx
movl -0x6c(%rbp), %eax
cmpl %ecx, %eax
jl 0x8d15
jmp 0x8e1c
movl -0x1c(%rbp), %eax
cmpl 0x1805a(%rip), %eax     # 0x20d78
jge 0x8d54
movl 0x1804a(%rip), %eax     # 0x20d70
addl -0x1c(%rbp), %eax
subl 0x18049(%rip), %eax     # 0x20d78
addl $0x1, %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x14197(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
jmp 0x8d6f
movq 0x1418d(%rip), %rax     # 0x1cee8
movl -0x1c(%rbp), %ecx
subl 0x18014(%rip), %ecx     # 0x20d78
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movslq -0x18(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, (%rcx)
movb %al, -0x81(%rbp)
je 0x8db5
leaq 0x11926(%rip), %rax     # 0x1a6c0
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movl (%rax), %esi
callq 0x5680
cmpq $0x0, %rax
setne %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movzwl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x8df7
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jne 0x8df5
cmpl $0x0, -0x30(%rbp)
je 0x8df7
movq -0x40(%rbp), %rax
cmpl $0x20, (%rax)
jne 0x8df5
movq -0x48(%rbp), %rax
cmpl $0x20, (%rax)
je 0x8df7
jmp 0x8e1c
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x8b99
jmp 0x8fb4
cmpl $0x0, -0x14(%rbp)
jge 0x8e31
xorl %eax, %eax
movl %eax, -0x88(%rbp)
jmp 0x8e40
movl 0x140ad(%rip), %eax     # 0x1cee4
subl $0x1, %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x14(%rbp)
jge 0x8f05
jmp 0x8e58
movq -0x10(%rbp), %rax
movl (%rax), %eax
cmpl -0x28(%rbp), %eax
jle 0x8f00
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
cmpl 0x17f02(%rip), %eax     # 0x20d78
jge 0x8eb7
movl 0x17ef2(%rip), %eax     # 0x20d70
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
addl %ecx, %eax
subl 0x17ee9(%rip), %eax     # 0x20d78
addl $0x1, %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x14037(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x90(%rbp)
jmp 0x8edb
movq 0x1402a(%rip), %rax     # 0x1cee8
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
subl 0x17eab(%rip), %ecx     # 0x20d78
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x8fc0
cmpl $0x0, %eax
jne 0x8eee
jmp 0x8f00
jmp 0x8ef0
movq -0x10(%rbp), %rax
movl (%rax), %ecx
subl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x8e58
jmp 0x8fb2
cmpl $0x0, -0x14(%rbp)
jle 0x8fb0
jmp 0x8f11
movq -0x10(%rbp), %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jge 0x8fae
movq -0x10(%rbp), %rax
movl (%rax), %eax
cmpl 0x17e4c(%rip), %eax     # 0x20d78
jge 0x8f68
movl 0x17e3c(%rip), %eax     # 0x20d70
movq -0x10(%rbp), %rcx
addl (%rcx), %eax
subl 0x17e38(%rip), %eax     # 0x20d78
addl $0x1, %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x13f86(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x98(%rbp)
jmp 0x8f89
movq 0x13f79(%rip), %rax     # 0x1cee8
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl 0x17dfd(%rip), %ecx     # 0x20d78
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x8fc0
cmpl $0x0, %eax
jne 0x8f9c
jmp 0x8fae
jmp 0x8f9e
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x8f11
jmp 0x8fb0
jmp 0x8fb2
jmp 0x8fb4
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)