// File: bonetblai[P]mdp-engine/race/./parsing.h
// Function: grid_t::valid_path(short, short, short, short, short&, short&) const
int valid_path(short x1, short y1, short x2, short y2, short &ox, short &oy) const {
        assert(valid_pos(x1, y1));
        int rv = 0, ix = 0, lx = 0, iy = 0, ly = 0;

        if( (x1 != x2) && (y1 != y2) ) {
            float m = (float)(y2 - y1) / (float)(x2 - x1);
            float b = (float)(y1*x2 - y2*x1) / (float)(x2 - x1);
            int inc = (x2 - x1 > 0 ? 1 : -1);
            for( float x = x1; (x != x2 + inc) && (rv == 0); x += inc ) {
                float y = m*x + b;
                lx = ix;
                ly = iy;
                ix = (int)x;
                iy = (int)floor(y + 0.5);
                if( !valid_pos(ix, iy) )
                    rv = 1;
                else if( goal_pos(ix, iy) )
                    rv = 2;
            }
        } else if( (x1 != x2) && (y1 == y2) ) {
            ly = iy = (int)y1;
            int inc = (x2 - x1 > 0 ? 1 : -1);
            for( float x = x1; (x != x2 + inc) && (rv == 0); x += inc ) {
                lx = ix;
                ix = (int)x;
                if( !valid_pos(ix, iy) )
                    rv = 1;
                else if( goal_pos(ix, iy) )
                    rv = 2;
            }
        } else if( (x1 == x2) && (y1 != y2) ) {
            lx = ix = (int)x1;
            int inc = (y2 - y1 > 0 ? 1 : -1);
            for( float y = y1; (y != y2 + inc) && (rv == 0); y += inc ) {
                ly = iy;
                iy = (int)y;
                if( !valid_pos(ix, iy) )
                    rv = 1;
                else if( goal_pos(ix, iy) )
                    rv = 2;
            }
        }

        if( rv == 1 ) {
            ox = lx;
            oy = ly;
        } else if( rv == 2 ) {
            ox = ix;
            oy = iy;
        }
        return rv;
    }

// Assembly:
subq $0x68, %rsp
movw %r8w, %ax
movq 0x70(%rsp), %r8
movq %rdi, 0x60(%rsp)
movw %si, 0x5e(%rsp)
movw %dx, 0x5c(%rsp)
movw %cx, 0x5a(%rsp)
movw %ax, 0x58(%rsp)
movq %r9, 0x50(%rsp)
movq 0x60(%rsp), %rdi
movq %rdi, 0x10(%rsp)
movswl 0x5e(%rsp), %esi
movswl 0x5c(%rsp), %edx
callq 0xee20
testb $0x1, %al
jne 0xefaa
jmp 0xefac
jmp 0xefcb
leaq 0x463ae(%rip), %rdi     # 0x55361
leaq 0x463b9(%rip), %rsi     # 0x55373
movl $0x36, %edx
leaq 0x463b9(%rip), %rcx     # 0x5537f
callq 0x61c0
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movswl 0x5e(%rsp), %eax
movswl 0x5a(%rsp), %ecx
cmpl %ecx, %eax
je 0xf18c
movswl 0x5c(%rsp), %eax
movswl 0x58(%rsp), %ecx
cmpl %ecx, %eax
je 0xf18c
movswl 0x58(%rsp), %eax
movswl 0x5c(%rsp), %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm0
movswl 0x5a(%rsp), %eax
movswl 0x5e(%rsp), %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x38(%rsp)
movswl 0x5c(%rsp), %edx
movswl 0x5a(%rsp), %eax
imull %eax, %edx
movswl 0x58(%rsp), %esi
movswl 0x5e(%rsp), %ecx
imull %ecx, %esi
subl %esi, %edx
cvtsi2ss %edx, %xmm0
subl %ecx, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x34(%rsp)
movswl 0x5a(%rsp), %eax
movswl 0x5e(%rsp), %ecx
subl %ecx, %eax
setg %al
movzbl %al, %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
movl %eax, 0x30(%rsp)
movswl 0x5e(%rsp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x2c(%rsp)
movss 0x2c(%rsp), %xmm0
movswl 0x5a(%rsp), %eax
addl 0x30(%rsp), %eax
cvtsi2ss %eax, %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm0
movb %al, 0xf(%rsp)
jne 0xf0be
jp 0xf0be
jmp 0xf0ca
cmpl $0x0, 0x4c(%rsp)
sete %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xf0d7
jmp 0xf187
movss 0x38(%rsp), %xmm0
mulss 0x2c(%rsp), %xmm0
addss 0x34(%rsp), %xmm0
movss %xmm0, 0x28(%rsp)
movl 0x48(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x40(%rsp), %eax
movl %eax, 0x3c(%rsp)
cvttss2si 0x2c(%rsp), %eax
movl %eax, 0x48(%rsp)
movss 0x28(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x45f05(%rip), %xmm1    # 0x55020
addsd %xmm1, %xmm0
callq 0x6500
movq 0x10(%rsp), %rdi
cvttsd2si %xmm0, %eax
movl %eax, 0x40(%rsp)
movl 0x48(%rsp), %esi
movl 0x40(%rsp), %edx
callq 0xee20
testb $0x1, %al
jne 0xf14c
movl $0x1, 0x4c(%rsp)
jmp 0xf16e
movq 0x10(%rsp), %rdi
movl 0x48(%rsp), %esi
movl 0x40(%rsp), %edx
callq 0xe960
testb $0x1, %al
jne 0xf164
jmp 0xf16c
movl $0x2, 0x4c(%rsp)
jmp 0xf16e
jmp 0xf170
cvtsi2ssl 0x30(%rsp), %xmm0
addss 0x2c(%rsp), %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0xf09c
jmp 0xf399
movswl 0x5e(%rsp), %eax
movswl 0x5a(%rsp), %ecx
cmpl %ecx, %eax
je 0xf292
movswl 0x5c(%rsp), %eax
movswl 0x58(%rsp), %ecx
cmpl %ecx, %eax
jne 0xf292
movswl 0x5c(%rsp), %eax
movl %eax, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
movswl 0x5a(%rsp), %eax
movswl 0x5e(%rsp), %ecx
subl %ecx, %eax
setg %al
movzbl %al, %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
movl %eax, 0x24(%rsp)
movswl 0x5e(%rsp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x20(%rsp), %xmm0
movswl 0x5a(%rsp), %eax
addl 0x24(%rsp), %eax
cvtsi2ss %eax, %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm0
movb %al, 0xe(%rsp)
jne 0xf20a
jp 0xf20a
jmp 0xf216
cmpl $0x0, 0x4c(%rsp)
sete %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xf220
jmp 0xf28d
movq 0x10(%rsp), %rdi
movl 0x48(%rsp), %eax
movl %eax, 0x44(%rsp)
cvttss2si 0x20(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %esi
movl 0x40(%rsp), %edx
callq 0xee20
testb $0x1, %al
jne 0xf252
movl $0x1, 0x4c(%rsp)
jmp 0xf274
movq 0x10(%rsp), %rdi
movl 0x48(%rsp), %esi
movl 0x40(%rsp), %edx
callq 0xe960
testb $0x1, %al
jne 0xf26a
jmp 0xf272
movl $0x2, 0x4c(%rsp)
jmp 0xf274
jmp 0xf276
cvtsi2ssl 0x24(%rsp), %xmm0
addss 0x20(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
jmp 0xf1e8
jmp 0xf397
movswl 0x5e(%rsp), %eax
movswl 0x5a(%rsp), %ecx
cmpl %ecx, %eax
jne 0xf395
movswl 0x5c(%rsp), %eax
movswl 0x58(%rsp), %ecx
cmpl %ecx, %eax
je 0xf395
movswl 0x5e(%rsp), %eax
movl %eax, 0x48(%rsp)
movl %eax, 0x44(%rsp)
movswl 0x58(%rsp), %eax
movswl 0x5c(%rsp), %ecx
subl %ecx, %eax
setg %al
movzbl %al, %ecx
movl %ecx, %eax
leal -0x1(%rax,%rax), %eax
movl %eax, 0x1c(%rsp)
movswl 0x5c(%rsp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x18(%rsp)
movss 0x18(%rsp), %xmm0
movswl 0x58(%rsp), %eax
addl 0x1c(%rsp), %eax
cvtsi2ss %eax, %xmm1
xorl %eax, %eax
ucomiss %xmm1, %xmm0
movb %al, 0xd(%rsp)
jne 0xf310
jp 0xf310
jmp 0xf31c
cmpl $0x0, 0x4c(%rsp)
sete %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
testb $0x1, %al
jne 0xf326
jmp 0xf393
movq 0x10(%rsp), %rdi
movl 0x40(%rsp), %eax
movl %eax, 0x3c(%rsp)
cvttss2si 0x18(%rsp), %eax
movl %eax, 0x40(%rsp)
movl 0x48(%rsp), %esi
movl 0x40(%rsp), %edx
callq 0xee20
testb $0x1, %al
jne 0xf358
movl $0x1, 0x4c(%rsp)
jmp 0xf37a
movq 0x10(%rsp), %rdi
movl 0x48(%rsp), %esi
movl 0x40(%rsp), %edx
callq 0xe960
testb $0x1, %al
jne 0xf370
jmp 0xf378
movl $0x2, 0x4c(%rsp)
jmp 0xf37a
jmp 0xf37c
cvtsi2ssl 0x1c(%rsp), %xmm0
addss 0x18(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0xf2ee
jmp 0xf395
jmp 0xf397
jmp 0xf399
cmpl $0x1, 0x4c(%rsp)
jne 0xf3c0
movl 0x44(%rsp), %eax
movw %ax, %cx
movq 0x50(%rsp), %rax
movw %cx, (%rax)
movl 0x3c(%rsp), %eax
movw %ax, %cx
movq 0x70(%rsp), %rax
movw %cx, (%rax)
jmp 0xf3e7
cmpl $0x2, 0x4c(%rsp)
jne 0xf3e5
movl 0x48(%rsp), %eax
movw %ax, %cx
movq 0x50(%rsp), %rax
movw %cx, (%rax)
movl 0x40(%rsp), %eax
movw %ax, %cx
movq 0x70(%rsp), %rax
movw %cx, (%rax)
jmp 0xf3e7
movl 0x4c(%rsp), %eax
addq $0x68, %rsp
retq