(bind-func fluid-advect
(lambda (b:i64 d:double* d0:double* velocx:double* velocy:double* dt:double Ny:i64 N:i64)
(let ((n-1 (i64tod (- N 1)))
(ny-1 (i64tod (- Ny 1)))
(dtx (* dt n-1))
(dty (* dt ny-1))
(jfloat 0.0) (ifloat 0.0)
(s0 0.0) (s1 0.0) (t0 0.0) (t1 0.0)
(i0 0.0) (i0i 0) (i1 0.0) (i1i 0)
(j0 0.0) (j0i 0) (j1 0.0) (j1i 0)
(j:i64 0) (i:i64 0)
(tmp1 0.0) (tmp2 0.0) (tmp3 0.0)
(x 0.0) (y 0.0) (z 0.0)
(Nfloat (i64tod N))
(NYfloat (i64tod N)))
(dotimes (j (- Ny 2))
(set! jfloat (+ jfloat 1.0))
(set! ifloat 0.0)
(dotimes (i (- N 2))
(set! ifloat (+ ifloat 1.0))
(set! tmp1 (* dtx (pref velocx (+ (+ i 1) (* (+ j 1) N)))))
(set! tmp2 (* dty (pref velocy (+ (+ i 1) (* (+ j 1) N)))))
(set! x (- ifloat tmp1))
(set! y (- jfloat tmp2))