int F_edgeBlendTriDrv(int index[2], double *L, double drv[]) {
  double r, s;
  drv[0] = drv[1] = 0.0;
  r = L[0];
  s = L[1];
  if ((index[0] == 0 && index[1] == 1) || (index[0] == 1 && index[1] == 0)) {
    drv[0] = -2.0 * s;
    drv[1] = -2.0 * r;
  } else if ((index[0] == 1 && index[1] == 2) ||
             (index[0] == 2 && index[1] == 1)) {
    drv[0] = 2.0 * s;
    drv[1] = -2.0 + 2.0 * r + 4.0 * s;
  } else if ((index[0] == 2 && index[1] == 0) ||
             (index[0] == 0 && index[1] == 2)) {
    drv[0] = 4.0 * r - 2.0 + 2.0 * s;
    drv[1] = 2.0 * r;
  } else
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<F_edgeBlendTriDrv>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    115d <F_edgeBlendTriDrv+0x5d>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0x4(%rax)
je     1178 <F_edgeBlendTriDrv+0x78>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jne    11a8 <F_edgeBlendTriDrv+0xa8>
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    11a8 <F_edgeBlendTriDrv+0xa8>
movsd  0xe90(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe7b(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    12c4 <F_edgeBlendTriDrv+0x1c4>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jne    11c3 <F_edgeBlendTriDrv+0xc3>
mov    -0x10(%rbp),%rax
cmpl   $0x2,0x4(%rax)
je     11de <F_edgeBlendTriDrv+0xde>
mov    -0x10(%rbp),%rax
cmpl   $0x2,(%rax)
jne    122b <F_edgeBlendTriDrv+0x12b>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0x4(%rax)
jne    122b <F_edgeBlendTriDrv+0x12b>
movsd  0xe1a(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm1
movsd  0xe0c(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xdf3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    12bf <F_edgeBlendTriDrv+0x1bf>
mov    -0x10(%rbp),%rax
cmpl   $0x2,(%rax)
jne    1246 <F_edgeBlendTriDrv+0x146>
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x4(%rax)
je     1261 <F_edgeBlendTriDrv+0x161>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    12ae <F_edgeBlendTriDrv+0x1ae>
mov    -0x10(%rbp),%rax
cmpl   $0x2,0x4(%rax)
jne    12ae <F_edgeBlendTriDrv+0x1ae>
movsd  -0x28(%rbp),%xmm1
movsd  0xd9a(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xd96(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd65(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    12ba <F_edgeBlendTriDrv+0x1ba>
movl   $0x0,-0x4(%rbp)
jmp    12cb <F_edgeBlendTriDrv+0x1cb>
jmp    12bf <F_edgeBlendTriDrv+0x1bf>
jmp    12c4 <F_edgeBlendTriDrv+0x1c4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<F_edgeBlendTriDrv>:
xorps  %xmm0,%xmm0
movups %xmm0,(%rdx)
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
mov    (%rdi),%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
je     112f <F_edgeBlendTriDrv+0x2f>
cmp    $0x1,%ecx
je     113d <F_edgeBlendTriDrv+0x3d>
test   %ecx,%ecx
jne    112e <F_edgeBlendTriDrv+0x2e>
mov    0x4(%rdi),%ecx
cmp    $0x1,%ecx
je     1149 <F_edgeBlendTriDrv+0x49>
cmp    $0x2,%ecx
je     115f <F_edgeBlendTriDrv+0x5f>
ret
mov    0x4(%rdi),%ecx
test   %ecx,%ecx
je     115f <F_edgeBlendTriDrv+0x5f>
cmp    $0x1,%ecx
je     1185 <F_edgeBlendTriDrv+0x85>
jmp    112e <F_edgeBlendTriDrv+0x2e>
mov    0x4(%rdi),%ecx
cmp    $0x2,%ecx
je     1185 <F_edgeBlendTriDrv+0x85>
test   %ecx,%ecx
jne    112e <F_edgeBlendTriDrv+0x2e>
movsd  0xeaf(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,(%rdx)
mulsd  %xmm2,%xmm0
jmp    11a9 <F_edgeBlendTriDrv+0xa9>
movsd  0xea1(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe8d(%rip),%xmm2
addsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rdx)
addsd  %xmm0,%xmm0
jmp    11a9 <F_edgeBlendTriDrv+0xa9>
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm0
addsd  0xe67(%rip),%xmm0
movsd  %xmm2,(%rdx)
mulsd  0xe63(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rdx)
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @F_edgeBlendTriDrv(i32* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
store i32* %0, i32** %5
store double* %1, double** %6
store double* %2, double** %7
%10 = load double*, double** %7
%11 = getelementptr inbounds double, double* %10, i64 1
store double 0.000000e+00, double* %11
%12 = load double*, double** %7
%13 = getelementptr inbounds double, double* %12, i64 0
store double 0.000000e+00, double* %13
%14 = load double*, double** %6
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
store double %16, double* %8
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
store double %19, double* %9
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %3
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 1
br i1 %28, label %39, label %29
29: ; preds = %24, %3
%30 = load i32*, i32** %5
%31 = getelementptr inbounds i32, i32* %30, i64 0
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %48
34: ; preds = %29
%35 = load i32*, i32** %5
%36 = getelementptr inbounds i32, i32* %35, i64 1
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %34, %24
%40 = load double, double* %9
%41 = fmul double -2.000000e+00, %40
%42 = load double*, double** %7
%43 = getelementptr inbounds double, double* %42, i64 0
store double %41, double* %43
%44 = load double, double* %8
%45 = fmul double -2.000000e+00, %44
%46 = load double*, double** %7
%47 = getelementptr inbounds double, double* %46, i64 1
store double %45, double* %47
br label %113
48: ; preds = %34, %29
%49 = load i32*, i32** %5
%50 = getelementptr inbounds i32, i32* %49, i64 0
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %58
53: ; preds = %48
%54 = load i32*, i32** %5
%55 = getelementptr inbounds i32, i32* %54, i64 1
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 2
br i1 %57, label %68, label %58
58: ; preds = %53, %48
%59 = load i32*, i32** %5
%60 = getelementptr inbounds i32, i32* %59, i64 0
%61 = load i32, i32* %60
%62 = icmp eq i32 %61, 2
br i1 %62, label %63, label %79
63: ; preds = %58
%64 = load i32*, i32** %5
%65 = getelementptr inbounds i32, i32* %64, i64 1
%66 = load i32, i32* %65
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %79
68: ; preds = %63, %53
%69 = load double, double* %9
%70 = fmul double 2.000000e+00, %69
%71 = load double*, double** %7
%72 = getelementptr inbounds double, double* %71, i64 0
store double %70, double* %72
%73 = load double, double* %8
%74 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %73, double -2.000000e+00)
%75 = load double, double* %9
%76 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %75, double %74)
%77 = load double*, double** %7
%78 = getelementptr inbounds double, double* %77, i64 1
store double %76, double* %78
br label %112
79: ; preds = %63, %58
%80 = load i32*, i32** %5
%81 = getelementptr inbounds i32, i32* %80, i64 0
%82 = load i32, i32* %81
%83 = icmp eq i32 %82, 2
br i1 %83, label %84, label %89
84: ; preds = %79
%85 = load i32*, i32** %5
%86 = getelementptr inbounds i32, i32* %85, i64 1
%87 = load i32, i32* %86
%88 = icmp eq i32 %87, 0
br i1 %88, label %99, label %89
89: ; preds = %84, %79
%90 = load i32*, i32** %5
%91 = getelementptr inbounds i32, i32* %90, i64 0
%92 = load i32, i32* %91
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %110
94: ; preds = %89
%95 = load i32*, i32** %5
%96 = getelementptr inbounds i32, i32* %95, i64 1
%97 = load i32, i32* %96
%98 = icmp eq i32 %97, 2
br i1 %98, label %99, label %110
99: ; preds = %94, %84
%100 = load double, double* %8
%101 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %100, double -2.000000e+00)
%102 = load double, double* %9
%103 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %102, double %101)
%104 = load double*, double** %7
%105 = getelementptr inbounds double, double* %104, i64 0
store double %103, double* %105
%106 = load double, double* %8
%107 = fmul double 2.000000e+00, %106
%108 = load double*, double** %7
%109 = getelementptr inbounds double, double* %108, i64 1
store double %107, double* %109
br label %111
110: ; preds = %94, %89
store i32 0, i32* %4
br label %114
111: ; preds = %99
br label %112
112: ; preds = %111, %68
br label %113
113: ; preds = %112, %39
store i32 1, i32* %4
br label %114
114: ; preds = %113, %110
%115 = load i32, i32* %4
ret i32 %115
}

LLVM IR (-O2):
define i32 @F_edgeBlendTriDrv(i32* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %2, i64 1
%5 = bitcast double* %2 to i8*
%6 = load double, double* %1
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = load i32, i32* %0
switch i32 %9, label %32 [
i32 0, label %10
i32 1, label %13
i32 2, label %19
]
10: ; preds = %3
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
switch i32 %12, label %32 [
i32 1, label %16
i32 2, label %26
]
13: ; preds = %3
%14 = getelementptr inbounds i32, i32* %0, i64 1
%15 = load i32, i32* %14
switch i32 %15, label %32 [
i32 0, label %16
i32 2, label %22
]
16: ; preds = %10, %13
%17 = fmul double %8, -2.000000e+00
store double %17, double* %2
%18 = fmul double %6, -2.000000e+00
br label %30
19: ; preds = %3
%20 = getelementptr inbounds i32, i32* %0, i64 1
%21 = load i32, i32* %20
switch i32 %21, label %32 [
i32 1, label %22
i32 0, label %26
]
22: ; preds = %19, %13
%23 = fmul double %8, 2.000000e+00
store double %23, double* %2
%24 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double -2.000000e+00)
%25 = tail call double @llvm.fmuladd.f64(double %8, double 4.000000e+00, double %24)
br label %30
26: ; preds = %10, %19
%27 = tail call double @llvm.fmuladd.f64(double %6, double 4.000000e+00, double -2.000000e+00)
%28 = tail call double @llvm.fmuladd.f64(double %8, double 2.000000e+00, double %27)
store double %28, double* %2
%29 = fmul double %6, 2.000000e+00
br label %30
30: ; preds = %22, %26, %16
%31 = phi double [ %18, %16 ], [ %29, %26 ], [ %25, %22 ]
store double %31, double* %4
br label %32
32: ; preds = %30, %10, %19, %13, %3
%33 = phi i32 [ 0, %3 ], [ 0, %13 ], [ 0, %19 ], [ 0, %10 ], [ 1, %30 ]
ret i32 %33
}