void line_plane(double v0[3], double a[3], int iplax, double plval, int *nint,
                double pt[3]) {
  int iax;
  if (a[iplax] == 0.0) {
    if (plval == v0[iplax])
      *nint = 2;
    else
      *nint = 0;
  } else {
    *nint = 1;
    for (iax = 0; iax < 3; ++iax) {
      if (iax == iplax)
        pt[iax] = plval;
      else
        pt[iax] = v0[iax] + ((a[iax] / a[iplax]) * (plval - v0[iplax]));
    }
  }
}


x86 assembly (clang, -O0):
<line_plane>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1178 <line_plane+0x78>
jp     1178 <line_plane+0x78>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jne    1169 <line_plane+0x69>
jp     1169 <line_plane+0x69>
mov    -0x28(%rbp),%rax
movl   $0x2,(%rax)
jmp    1173 <line_plane+0x73>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    121c <line_plane+0x11c>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    1217 <line_plane+0x117>
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11b6 <line_plane+0xb6>
movsd  -0x20(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1204 <line_plane+0x104>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  -0x20(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1209 <line_plane+0x109>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1189 <line_plane+0x89>
jmp    121c <line_plane+0x11c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_plane>:
movslq %edx,%rax
movsd  (%rsi,%rax,8),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    1128 <line_plane+0x28>
jp     1128 <line_plane+0x28>
movsd  (%rdi,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jne    115d <line_plane+0x5d>
jp     115d <line_plane+0x5d>
movl   $0x2,(%rcx)
ret
movl   $0x1,(%rcx)
test   %edx,%edx
je     1164 <line_plane+0x64>
movsd  (%rsi),%xmm2
divsd  %xmm1,%xmm2
movapd %xmm0,%xmm1
subsd  (%rdi,%rax,8),%xmm1
mulsd  %xmm2,%xmm1
addsd  (%rdi),%xmm1
movsd  %xmm1,(%r8)
cmp    $0x1,%edx
jne    1169 <line_plane+0x69>
movsd  %xmm0,0x8(%r8)
jmp    1190 <line_plane+0x90>
movl   $0x0,(%rcx)
ret
movsd  %xmm0,(%r8)
movsd  0x8(%rsi),%xmm1
divsd  (%rsi,%rax,8),%xmm1
movapd %xmm0,%xmm2
subsd  (%rdi,%rax,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  0x8(%rdi),%xmm2
movsd  %xmm2,0x8(%r8)
cmp    $0x2,%edx
je     11a8 <line_plane+0xa8>
movsd  0x10(%rsi),%xmm1
divsd  (%rsi,%rax,8),%xmm1
subsd  (%rdi,%rax,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  0x10(%rdi),%xmm0
movsd  %xmm0,0x10(%r8)
ret

LLVM IR (-O0):
define void @line_plane(double* %0, double* %1, i32 %2, double %3, i32* %4, double* %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32*
%12 = alloca double*
%13 = alloca i32
store double* %0, double** %7
store double* %1, double** %8
store i32 %2, i32* %9
store double %3, double* %10
store i32* %4, i32** %11
store double* %5, double** %12
%14 = load double*, double** %8
%15 = load i32, i32* %9
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %20, label %33
20: ; preds = %6
%21 = load double, double* %10
%22 = load double*, double** %7
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fcmp oeq double %21, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load i32*, i32** %11
store i32 2, i32* %29
br label %32
30: ; preds = %20
%31 = load i32*, i32** %11
store i32 0, i32* %31
br label %32
32: ; preds = %30, %28
br label %82
33: ; preds = %6
%34 = load i32*, i32** %11
store i32 1, i32* %34
store i32 0, i32* %13
br label %35
35: ; preds = %78, %33
%36 = load i32, i32* %13
%37 = icmp slt i32 %36, 3
br i1 %37, label %38, label %81
38: ; preds = %35
%39 = load i32, i32* %13
%40 = load i32, i32* %9
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load double, double* %10
%44 = load double*, double** %12
%45 = load i32, i32* %13
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %77
48: ; preds = %38
%49 = load double*, double** %7
%50 = load i32, i32* %13
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %8
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = load double*, double** %8
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
%63 = load double, double* %62
%64 = fdiv double %58, %63
%65 = load double, double* %10
%66 = load double*, double** %7
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = fsub double %65, %70
%72 = call double @llvm.fmuladd.f64(double %64, double %71, double %53)
%73 = load double*, double** %12
%74 = load i32, i32* %13
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
store double %72, double* %76
br label %77
77: ; preds = %48, %42
br label %78
78: ; preds = %77
%79 = load i32, i32* %13
%80 = add nsw i32 %79, 1
store i32 %80, i32* %13
br label %35
81: ; preds = %35
br label %82
82: ; preds = %81, %32
ret void
}

LLVM IR (-O2):
define void @line_plane(double* nocapture %0, double* nocapture %1, i32 %2, double %3, i32* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds double, double* %1, i64 %7
%9 = load double, double* %8
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = getelementptr inbounds double, double* %0, i64 %7
%13 = load double, double* %12
%14 = fcmp oeq double %13, %3
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 2, i32* %4
br label %56
16: ; preds = %11
store i32 0, i32* %4
br label %56
17: ; preds = %6
store i32 1, i32* %4
%18 = getelementptr inbounds double, double* %0, i64 %7
%19 = icmp eq i32 %2, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store double %3, double* %5
br label %31
21: ; preds = %17
%22 = load double, double* %0
%23 = load double, double* %1
%24 = fdiv double %23, %9
%25 = load double, double* %18
%26 = fsub double %3, %25
%27 = tail call double @llvm.fmuladd.f64(double %24, double %26, double %22)
store double %27, double* %5
%28 = icmp eq i32 %2, 1
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = getelementptr inbounds double, double* %5, i64 1
store double %3, double* %30
br label %43
31: ; preds = %21, %20
%32 = getelementptr inbounds double, double* %0, i64 1
%33 = load double, double* %32
%34 = getelementptr inbounds double, double* %1, i64 1
%35 = load double, double* %34
%36 = load double, double* %8
%37 = fdiv double %35, %36
%38 = load double, double* %18
%39 = fsub double %3, %38
%40 = tail call double @llvm.fmuladd.f64(double %37, double %39, double %33)
%41 = getelementptr inbounds double, double* %5, i64 1
store double %40, double* %41
%42 = icmp eq i32 %2, 2
br i1 %42, label %53, label %43
43: ; preds = %29, %31
%44 = getelementptr inbounds double, double* %0, i64 2
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %1, i64 2
%47 = load double, double* %46
%48 = load double, double* %8
%49 = fdiv double %47, %48
%50 = load double, double* %18
%51 = fsub double %3, %50
%52 = tail call double @llvm.fmuladd.f64(double %49, double %51, double %45)
br label %53
53: ; preds = %31, %43
%54 = phi double [ %52, %43 ], [ %3, %31 ]
%55 = getelementptr inbounds double, double* %5, i64 2
store double %54, double* %55
br label %56
56: ; preds = %53, %15, %16
ret void
}