// File: /workspace/github_c_makefile_star2_O0/bobrippling[P]tim/motion.c
// Function: m_findnext2
static int m_findnext2(const int ch, enum find_type ftype, unsigned repeat, window *win, point_t *to)
{
	list_t *l = window_current_line(win, false); /* fine - repeat handled */

	if(!l)
		return MOTION_FAILURE;

	point_t bpos = *win->ui_pos;

	if(!(ftype & F_REV)){
		bpos.x++;
		if((unsigned)bpos.x >= l->len_line)
			return MOTION_FAILURE;
	}else{
		if(l->len_line == 0)
			return MOTION_FAILURE;

		/* if we're after the actual length, move from logical to it */
		if((unsigned)bpos.x >= l->len_line)
			bpos.x = l->len_line;

		bpos.x--;

		if(bpos.x < 0)
			return MOTION_FAILURE;
	}

	repeat = DEFAULT_REPEAT(repeat);

	for(;;){
		char *p = l->line + bpos.x;

		p = strchrdir(p, ch, ftype & F_REV, l->line, l->len_line);

		if(!p)
			return MOTION_FAILURE;

		bpos.x = p - l->line;

		if(--repeat == 0){
			const int adj = ftype & F_TIL ? ftype & F_REV ? 1 : -1 : 0;

			*to = bpos;
			to->x += adj;
			break;
		}else{
			bpos.x += ftype & F_REV ? -1 : +1;
		}
	}

	return MOTION_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x13790
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xf97b
movl $0x0, -0x4(%rbp)
jmp 0xfb10
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl -0xc(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xf9b9
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jb 0xf9b7
movl $0x0, -0x4(%rbp)
jmp 0xfb10
jmp 0xfa05
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xf9d0
movl $0x0, -0x4(%rbp)
jmp 0xfb10
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jb 0xf9e8
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jge 0xfa03
movl $0x0, -0x4(%rbp)
jmp 0xfb10
jmp 0xfa05
cmpl $0x0, -0x10(%rbp)
je 0xfa13
movl -0x10(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xfa1d
movl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xfa1d
movl -0x40(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl -0x8(%rbp), %eax
movb %al, %dl
movl -0xc(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
movq -0x28(%rbp), %rsi
movq 0x8(%rsi), %r8
movsbl %dl, %esi
movzbl %al, %edx
andl $0x1, %edx
callq 0x104c0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xfa7e
movl $0x0, -0x4(%rbp)
jmp 0xfb10
movq -0x38(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movl %eax, -0x30(%rbp)
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
jne 0xfae8
movl -0xc(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xfac3
movl -0xc(%rbp), %edx
andl $0x2, %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x44(%rbp)
jmp 0xfaca
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0xfaca
movl -0x44(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x20(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0xfb09
movl -0xc(%rbp), %edx
andl $0x2, %edx
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x0, %edx
cmovnel %ecx, %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xfa23
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)