#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double advect_sample(double const *const, int const, float, float);
void C_advect_velocity(double *v, const double *const v0,
                       const unsigned char *bound, int *advect_indexes,
                       double *advect_lerps, const int Nx, const int Ny,
                       const double dx, const double dy, const double dt) {
  int x, y, idx, xi, yi, iidx;
  int vyidx = Nx * Ny;
  float xa, ya, s, t;
#pragma omp for schedule(auto)
  for (x = 0; x < Nx; ++x) {
    for (y = 0; y < Ny; ++y) {
      idx = y + x * Ny;
      xa = (double)x - dt * v0[0 + idx] / dx;
      ya = (double)y - dt * v0[vyidx + idx] / dy;
      xa = xa < 0.0 ? 0.0 : (xa >= Nx - 1.01) ? (Nx - 1.01) : xa;
      ya = ya < 0.0 ? 0.0 : (ya >= Ny - 1.01) ? (Ny - 1.01) : ya;
      xi = (int)xa;
      yi = (int)ya;
      s = xa - (double)xi;
      t = ya - (double)yi;
      advect_indexes[0 + idx] = xi;
      advect_indexes[vyidx + idx] = yi;
      advect_lerps[0 + idx] = s;
      advect_lerps[vyidx + idx] = t;
      if (!bound[idx]) {
        iidx = yi + xi * Ny;
        v[0 + idx] = advect_sample(v0 + iidx, Ny, s, t);
        v[vyidx + idx] = advect_sample(v0 + vyidx + iidx, Ny, s, t);
      } else {
        v[0 + idx] = v0[0 + idx];
        v[vyidx + idx] = v0[vyidx + idx];
      }
    }
  }
}


x86 assembly (clang, -O0):
<C_advect_velocity>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
movsd  %xmm2,-0x48(%rbp)
mov    -0x2c(%rbp),%eax
imul   0x10(%rbp),%eax
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    14b2 <C_advect_velocity+0x3a2>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    149f <C_advect_velocity+0x38f>
mov    -0x50(%rbp),%eax
mov    -0x4c(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x54(%rbp)
cvtsi2sdl -0x4c(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
divsd  -0x38(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
divsd  -0x40(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x6c(%rbp)
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1203 <C_advect_velocity+0xf3>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1263 <C_advect_velocity+0x153>
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  0xde7(%rip),%xmm2
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     1245 <C_advect_velocity+0x135>
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xdcc(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1256 <C_advect_velocity+0x146>
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x68(%rbp)
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1297 <C_advect_velocity+0x187>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12fa <C_advect_velocity+0x1ea>
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl 0x10(%rbp),%xmm1
movsd  0xd53(%rip),%xmm2
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     12d9 <C_advect_velocity+0x1c9>
cvtsi2sdl 0x10(%rbp),%xmm0
movsd  0xd38(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    12ea <C_advect_velocity+0x1da>
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x6c(%rbp)
cvttss2si -0x68(%rbp),%eax
mov    %eax,-0x58(%rbp)
cvttss2si -0x6c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x70(%rbp)
movss  -0x6c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x74(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x5c(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
movss  -0x70(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x28(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    1444 <C_advect_velocity+0x334>
mov    -0x5c(%rbp),%eax
mov    -0x58(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x60(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
movss  -0x70(%rbp),%xmm0
movss  -0x74(%rbp),%xmm1
call   1030 <advect_sample@plt>
mov    -0x8(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rdi
movslq -0x64(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
movslq -0x60(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    0x10(%rbp),%esi
movss  -0x70(%rbp),%xmm0
movss  -0x74(%rbp),%xmm1
call   1030 <advect_sample@plt>
mov    -0x8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    148c <C_advect_velocity+0x37c>
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x54(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1491 <C_advect_velocity+0x381>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1169 <C_advect_velocity+0x59>
jmp    14a4 <C_advect_velocity+0x394>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1156 <C_advect_velocity+0x46>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C_advect_velocity>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rsi,0x28(%rsp)
mov    %rdi,0x8(%rsp)
test   %r9d,%r9d
jle    1490 <C_advect_velocity+0x380>
movapd %xmm1,%xmm8
mov    0x100(%rsp),%esi
mov    %esi,%eax
cvtsi2sd %r9d,%xmm9
movsd  0xeb1(%rip),%xmm1
addsd  %xmm1,%xmm9
cvtsd2ss %xmm9,%xmm11
imul   %r9d,%eax
cvtsi2sd %esi,%xmm12
addsd  %xmm1,%xmm12
cvtsd2ss %xmm12,%xmm6
cltq
mov    0x28(%rsp),%r13
lea    0x0(%r13,%rax,8),%rdi
movslq %esi,%rsi
mov    %r9d,%ebp
mov    %rbp,0x40(%rsp)
mov    %esi,%r9d
unpcklpd %xmm2,%xmm2
unpcklpd %xmm0,%xmm8
lea    0x0(,%rsi,8),%rbp
mov    %rbp,0x38(%rsp)
mov    %rsi,0x48(%rsp)
lea    0x0(,%rsi,4),%rsi
mov    %rsi,0x30(%rsp)
mov    0x8(%rsp),%rsi
lea    (%rsi,%rax,8),%r10
lea    (%rcx,%rax,4),%r11
lea    (%r8,%rax,8),%r14
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xorps  %xmm10,%xmm10
mov    %rdi,0x50(%rsp)
mov    %rdi,%r15
mov    %r13,%r12
movapd %xmm2,0xa0(%rsp)
movapd %xmm8,0x90(%rsp)
movsd  %xmm9,0x60(%rsp)
movss  %xmm11,0x1c(%rsp)
movsd  %xmm12,0x58(%rsp)
movss  %xmm6,0x18(%rsp)
jmp    1255 <C_advect_velocity+0x145>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%rdi
add    $0x1,%rdi
mov    0x38(%rsp),%rax
add    %rax,%r12
mov    0x30(%rsp),%rsi
add    %rsi,%rcx
add    %rax,%r8
add    0x48(%rsp),%rdx
add    %rax,0x8(%rsp)
add    %rax,%r10
add    %rax,%r15
add    %rsi,%r11
add    %rax,%r14
mov    %rdi,%rax
mov    %rdi,0x10(%rsp)
cmp    0x40(%rsp),%rdi
je     1490 <C_advect_velocity+0x380>
mov    0x100(%rsp),%eax
test   %eax,%eax
jle    1210 <C_advect_velocity+0x100>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x10(%rsp),%xmm0
unpcklpd %xmm0,%xmm7
xor    %ebx,%ebx
mov    %r8,0x88(%rsp)
mov    %rcx,0x80(%rsp)
mov    %rdx,0x78(%rsp)
mov    %r15,0x70(%rsp)
mov    %r12,0x68(%rsp)
movapd %xmm7,0xb0(%rsp)
jmp    1330 <C_advect_velocity+0x220>
nopl   0x0(%rax)
cvttss2si %xmm4,%eax
cvttss2si %xmm5,%esi
cvttps2dq %xmm4,%xmm1
cvtdq2pd %xmm1,%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm4,%xmm3
subsd  %xmm1,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
cvttps2dq %xmm5,%xmm1
cvtdq2pd %xmm1,%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm5,%xmm3
subsd  %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtsd2ss %xmm3,%xmm1
mov    %eax,(%rcx,%rbx,4)
mov    %esi,(%r11,%rbx,4)
xorps  %xmm3,%xmm3
cvtss2sd %xmm0,%xmm3
movsd  %xmm3,(%r8,%rbx,8)
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movsd  %xmm3,(%r14,%rbx,8)
cmpb   $0x0,(%rdx,%rbx,1)
je     13c0 <C_advect_velocity+0x2b0>
movsd  (%r12,%rbx,8),%xmm0
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%r10,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r9
je     1210 <C_advect_velocity+0x100>
movsd  (%r15,%rbx,8),%xmm0
movhpd (%r12,%rbx,8),%xmm0
mulpd  %xmm2,%xmm0
movapd %xmm7,%xmm1
cvtsi2sd %ebx,%xmm1
divpd  %xmm8,%xmm0
subpd  %xmm0,%xmm1
cvtpd2ps %xmm1,%xmm1
movapd %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
xorps  %xmm3,%xmm3
cvtss2sd %xmm0,%xmm3
ucomisd %xmm9,%xmm3
movaps %xmm11,%xmm3
jae    1372 <C_advect_velocity+0x262>
movaps %xmm0,%xmm3
movaps %xmm1,%xmm0
cmpltps %xmm10,%xmm0
unpcklps %xmm0,%xmm0
movmskpd %xmm0,%eax
xorps  %xmm5,%xmm5
xorps  %xmm4,%xmm4
test   $0x2,%al
jne    138e <C_advect_velocity+0x27e>
movaps %xmm3,%xmm4
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
ucomisd %xmm12,%xmm3
movaps %xmm6,%xmm3
jae    13a2 <C_advect_velocity+0x292>
movaps %xmm1,%xmm3
test   $0x1,%al
jne    12a0 <C_advect_velocity+0x190>
movaps %xmm3,%xmm5
jmp    12a0 <C_advect_velocity+0x190>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x100(%rsp),%r13d
imul   %r13d,%eax
add    %esi,%eax
movslq %eax,%rbp
mov    0x28(%rsp),%rax
lea    (%rax,%rbp,8),%rdi
mov    %r13d,%esi
mov    %r9,%r13
mov    %r10,%r12
mov    %r14,%r15
mov    %r11,%r14
movss  %xmm0,0x20(%rsp)
movss  %xmm1,0x24(%rsp)
call   1030 <advect_sample@plt>
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
mov    0x50(%rsp),%rax
lea    (%rax,%rbp,8),%rdi
mov    0x100(%rsp),%esi
movss  0x20(%rsp),%xmm0
movss  0x24(%rsp),%xmm1
call   1030 <advect_sample@plt>
movapd 0xb0(%rsp),%xmm7
xorps  %xmm10,%xmm10
mov    %r14,%r11
mov    %r15,%r14
mov    0x70(%rsp),%r15
mov    %r12,%r10
mov    0x68(%rsp),%r12
mov    %r13,%r9
movss  0x18(%rsp),%xmm6
movsd  0x58(%rsp),%xmm12
movss  0x1c(%rsp),%xmm11
movsd  0x60(%rsp),%xmm9
mov    0x78(%rsp),%rdx
mov    0x80(%rsp),%rcx
mov    0x88(%rsp),%r8
movapd 0x90(%rsp),%xmm8
movapd 0xa0(%rsp),%xmm2
jmp    131d <C_advect_velocity+0x20d>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @C_advect_velocity(double* %0, double* %1, i8* %2, i32* %3, double* %4, i32 %5, i32 %6, double %7, double %8, double %9) {
%11 = alloca double*
%12 = alloca double*
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca float
%29 = alloca float
%30 = alloca float
%31 = alloca float
store double* %0, double** %11
store double* %1, double** %12
store i8* %2, i8** %13
store i32* %3, i32** %14
store double* %4, double** %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store double %7, double* %18
store double %8, double* %19
store double %9, double* %20
%32 = load i32, i32* %16
%33 = load i32, i32* %17
%34 = mul nsw i32 %32, %33
store i32 %34, i32* %27
store i32 0, i32* %21
br label %35
35: ; preds = %241, %10
%36 = load i32, i32* %21
%37 = load i32, i32* %16
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %244
39: ; preds = %35
store i32 0, i32* %22
br label %40
40: ; preds = %237, %39
%41 = load i32, i32* %22
%42 = load i32, i32* %17
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %240
44: ; preds = %40
%45 = load i32, i32* %22
%46 = load i32, i32* %21
%47 = load i32, i32* %17
%48 = mul nsw i32 %46, %47
%49 = add nsw i32 %45, %48
store i32 %49, i32* %23
%50 = load i32, i32* %21
%51 = sitofp i32 %50 to double
%52 = load double, double* %20
%53 = load double*, double** %12
%54 = load i32, i32* %23
%55 = add nsw i32 0, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %53, i64 %56
%58 = load double, double* %57
%59 = fmul double %52, %58
%60 = load double, double* %18
%61 = fdiv double %59, %60
%62 = fsub double %51, %61
%63 = fptrunc double %62 to float
store float %63, float* %28
%64 = load i32, i32* %22
%65 = sitofp i32 %64 to double
%66 = load double, double* %20
%67 = load double*, double** %12
%68 = load i32, i32* %27
%69 = load i32, i32* %23
%70 = add nsw i32 %68, %69
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %67, i64 %71
%73 = load double, double* %72
%74 = fmul double %66, %73
%75 = load double, double* %19
%76 = fdiv double %74, %75
%77 = fsub double %65, %76
%78 = fptrunc double %77 to float
store float %78, float* %29
%79 = load float, float* %28
%80 = fpext float %79 to double
%81 = fcmp olt double %80, 0.000000e+00
br i1 %81, label %82, label %83
82: ; preds = %44
br label %99
83: ; preds = %44
%84 = load float, float* %28
%85 = fpext float %84 to double
%86 = load i32, i32* %16
%87 = sitofp i32 %86 to double
%88 = fsub double %87, 1.010000e+00
%89 = fcmp oge double %85, %88
br i1 %89, label %90, label %94
90: ; preds = %83
%91 = load i32, i32* %16
%92 = sitofp i32 %91 to double
%93 = fsub double %92, 1.010000e+00
br label %97
94: ; preds = %83
%95 = load float, float* %28
%96 = fpext float %95 to double
br label %97
97: ; preds = %94, %90
%98 = phi double [ %93, %90 ], [ %96, %94 ]
br label %99
99: ; preds = %97, %82
%100 = phi double [ 0.000000e+00, %82 ], [ %98, %97 ]
%101 = fptrunc double %100 to float
store float %101, float* %28
%102 = load float, float* %29
%103 = fpext float %102 to double
%104 = fcmp olt double %103, 0.000000e+00
br i1 %104, label %105, label %106
105: ; preds = %99
br label %122
106: ; preds = %99
%107 = load float, float* %29
%108 = fpext float %107 to double
%109 = load i32, i32* %17
%110 = sitofp i32 %109 to double
%111 = fsub double %110, 1.010000e+00
%112 = fcmp oge double %108, %111
br i1 %112, label %113, label %117
113: ; preds = %106
%114 = load i32, i32* %17
%115 = sitofp i32 %114 to double
%116 = fsub double %115, 1.010000e+00
br label %120
117: ; preds = %106
%118 = load float, float* %29
%119 = fpext float %118 to double
br label %120
120: ; preds = %117, %113
%121 = phi double [ %116, %113 ], [ %119, %117 ]
br label %122
122: ; preds = %120, %105
%123 = phi double [ 0.000000e+00, %105 ], [ %121, %120 ]
%124 = fptrunc double %123 to float
store float %124, float* %29
%125 = load float, float* %28
%126 = fptosi float %125 to i32
store i32 %126, i32* %24
%127 = load float, float* %29
%128 = fptosi float %127 to i32
store i32 %128, i32* %25
%129 = load float, float* %28
%130 = fpext float %129 to double
%131 = load i32, i32* %24
%132 = sitofp i32 %131 to double
%133 = fsub double %130, %132
%134 = fptrunc double %133 to float
store float %134, float* %30
%135 = load float, float* %29
%136 = fpext float %135 to double
%137 = load i32, i32* %25
%138 = sitofp i32 %137 to double
%139 = fsub double %136, %138
%140 = fptrunc double %139 to float
store float %140, float* %31
%141 = load i32, i32* %24
%142 = load i32*, i32** %14
%143 = load i32, i32* %23
%144 = add nsw i32 0, %143
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i32, i32* %142, i64 %145
store i32 %141, i32* %146
%147 = load i32, i32* %25
%148 = load i32*, i32** %14
%149 = load i32, i32* %27
%150 = load i32, i32* %23
%151 = add nsw i32 %149, %150
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i32, i32* %148, i64 %152
store i32 %147, i32* %153
%154 = load float, float* %30
%155 = fpext float %154 to double
%156 = load double*, double** %15
%157 = load i32, i32* %23
%158 = add nsw i32 0, %157
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds double, double* %156, i64 %159
store double %155, double* %160
%161 = load float, float* %31
%162 = fpext float %161 to double
%163 = load double*, double** %15
%164 = load i32, i32* %27
%165 = load i32, i32* %23
%166 = add nsw i32 %164, %165
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %163, i64 %167
store double %162, double* %168
%169 = load i8*, i8** %13
%170 = load i32, i32* %23
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8, i8* %169, i64 %171
%173 = load i8, i8* %172
%174 = icmp ne i8 %173, 0
br i1 %174, label %211, label %175
175: ; preds = %122
%176 = load i32, i32* %25
%177 = load i32, i32* %24
%178 = load i32, i32* %17
%179 = mul nsw i32 %177, %178
%180 = add nsw i32 %176, %179
store i32 %180, i32* %26
%181 = load double*, double** %12
%182 = load i32, i32* %26
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load i32, i32* %17
%186 = load float, float* %30
%187 = load float, float* %31
%188 = call double @advect_sample(double* %184, i32 %185, float %186, float %187)
%189 = load double*, double** %11
%190 = load i32, i32* %23
%191 = add nsw i32 0, %190
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds double, double* %189, i64 %192
store double %188, double* %193
%194 = load double*, double** %12
%195 = load i32, i32* %27
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds double, double* %194, i64 %196
%198 = load i32, i32* %26
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds double, double* %197, i64 %199
%201 = load i32, i32* %17
%202 = load float, float* %30
%203 = load float, float* %31
%204 = call double @advect_sample(double* %200, i32 %201, float %202, float %203)
%205 = load double*, double** %11
%206 = load i32, i32* %27
%207 = load i32, i32* %23
%208 = add nsw i32 %206, %207
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds double, double* %205, i64 %209
store double %204, double* %210
br label %236
211: ; preds = %122
%212 = load double*, double** %12
%213 = load i32, i32* %23
%214 = add nsw i32 0, %213
%215 = sext i32 %214 to i64
%216 = getelementptr inbounds double, double* %212, i64 %215
%217 = load double, double* %216
%218 = load double*, double** %11
%219 = load i32, i32* %23
%220 = add nsw i32 0, %219
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds double, double* %218, i64 %221
store double %217, double* %222
%223 = load double*, double** %12
%224 = load i32, i32* %27
%225 = load i32, i32* %23
%226 = add nsw i32 %224, %225
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds double, double* %223, i64 %227
%229 = load double, double* %228
%230 = load double*, double** %11
%231 = load i32, i32* %27
%232 = load i32, i32* %23
%233 = add nsw i32 %231, %232
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds double, double* %230, i64 %234
store double %229, double* %235
br label %236
236: ; preds = %211, %175
br label %237
237: ; preds = %236
%238 = load i32, i32* %22
%239 = add nsw i32 %238, 1
store i32 %239, i32* %22
br label %40
240: ; preds = %40
br label %241
241: ; preds = %240
%242 = load i32, i32* %21
%243 = add nsw i32 %242, 1
store i32 %243, i32* %21
br label %35
244: ; preds = %35
ret void
}

LLVM IR (-O2):
define void @C_advect_velocity(double* nocapture writeonly %0, double* %1, i8* nocapture %2, i32* nocapture writeonly %3, double* nocapture writeonly %4, i32 %5, i32 %6, double %7, double %8, double %9) {
%11 = icmp sgt i32 %5, 0
br i1 %11, label %12, label %107
12: ; preds = %10
%13 = mul nsw i32 %6, %5
%14 = icmp sgt i32 %6, 0
%15 = sitofp i32 %5 to double
%16 = fadd double %15, -1.010000e+00
%17 = fptrunc double %16 to float
%18 = sitofp i32 %6 to double
%19 = fadd double %18, -1.010000e+00
%20 = fptrunc double %19 to float
%21 = sext i32 %13 to i64
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = sext i32 %6 to i64
%24 = zext i32 %5 to i64
%25 = zext i32 %6 to i64
%26 = insertelement <2 x double> poison, double %9, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = insertelement <2 x double> poison, double %8, i64 0
%29 = insertelement <2 x double> %28, double %7, i64 1
br label %30
30: ; preds = %12, %104
%31 = phi i64 [ 0, %12 ], [ %105, %104 ]
br i1 %14, label %32, label %104
32: ; preds = %30
%33 = mul nsw i64 %31, %23
%34 = trunc i64 %31 to i32
%35 = sitofp i32 %34 to double
%36 = insertelement <2 x double> poison, double %35, i64 1
br label %37
37: ; preds = %32, %99
%38 = phi i64 [ 0, %32 ], [ %102, %99 ]
%39 = add nsw i64 %38, %33
%40 = getelementptr inbounds double, double* %1, i64 %39
%41 = load double, double* %40
%42 = trunc i64 %38 to i32
%43 = sitofp i32 %42 to double
%44 = add nsw i64 %39, %21
%45 = getelementptr inbounds double, double* %1, i64 %44
%46 = load double, double* %45
%47 = insertelement <2 x double> poison, double %46, i64 0
%48 = insertelement <2 x double> %47, double %41, i64 1
%49 = fmul <2 x double> %48, %27
%50 = fdiv <2 x double> %49, %29
%51 = insertelement <2 x double> %36, double %43, i64 0
%52 = fsub <2 x double> %51, %50
%53 = fptrunc <2 x double> %52 to <2 x float>
%54 = extractelement <2 x float> %53, i64 1
%55 = fpext float %54 to double
%56 = fcmp ole double %16, %55
%57 = select i1 %56, float %17, float %54
%58 = fcmp olt <2 x float> %53, zeroinitializer
%59 = extractelement <2 x i1> %58, i64 1
%60 = select i1 %59, float 0.000000e+00, float %57
%61 = extractelement <2 x float> %53, i64 0
%62 = fpext float %61 to double
%63 = fcmp ole double %19, %62
%64 = select i1 %63, float %20, float %61
%65 = extractelement <2 x i1> %58, i64 0
%66 = select i1 %65, float 0.000000e+00, float %64
%67 = fptosi float %60 to i32
%68 = fptosi float %66 to i32
%69 = fpext float %60 to double
%70 = sitofp i32 %67 to double
%71 = fsub double %69, %70
%72 = fptrunc double %71 to float
%73 = fpext float %66 to double
%74 = sitofp i32 %68 to double
%75 = fsub double %73, %74
%76 = fptrunc double %75 to float
%77 = getelementptr inbounds i32, i32* %3, i64 %39
store i32 %67, i32* %77
%78 = getelementptr inbounds i32, i32* %3, i64 %44
store i32 %68, i32* %78
%79 = fpext float %72 to double
%80 = getelementptr inbounds double, double* %4, i64 %39
store double %79, double* %80
%81 = fpext float %76 to double
%82 = getelementptr inbounds double, double* %4, i64 %44
store double %81, double* %82
%83 = getelementptr inbounds i8, i8* %2, i64 %39
%84 = load i8, i8* %83
%85 = icmp eq i8 %84, 0
br i1 %85, label %86, label %95
86: ; preds = %37
%87 = mul nsw i32 %67, %6
%88 = add nsw i32 %87, %68
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %1, i64 %89
%91 = tail call double @advect_sample(double* %90, i32 %6, float %72, float %76)
%92 = getelementptr inbounds double, double* %0, i64 %39
store double %91, double* %92
%93 = getelementptr inbounds double, double* %22, i64 %89
%94 = tail call double @advect_sample(double* %93, i32 %6, float %72, float %76)
br label %99
95: ; preds = %37
%96 = load double, double* %40
%97 = getelementptr inbounds double, double* %0, i64 %39
store double %96, double* %97
%98 = load double, double* %45
br label %99
99: ; preds = %86, %95
%100 = phi double [ %94, %86 ], [ %98, %95 ]
%101 = getelementptr inbounds double, double* %0, i64 %44
store double %100, double* %101
%102 = add nuw nsw i64 %38, 1
%103 = icmp eq i64 %102, %25
br i1 %103, label %104, label %37
104: ; preds = %99, %30
%105 = add nuw nsw i64 %31, 1
%106 = icmp eq i64 %105, %24
br i1 %106, label %107, label %30
107: ; preds = %104, %10
ret void
}