void f2(double **matrix) {
  int i;
  for (i = 0; i < 2; i++) {
    matrix[i][3] =
        (matrix[i + 1][2] - matrix[i][2]) / (matrix[i + 2][0] - matrix[i][0]);
  }
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1188 <f2+0x88>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
subsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
subsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  %xmm0,0x18(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <f2+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
mov    (%rdi),%rax
mov    0x8(%rdi),%rcx
movsd  0x10(%rcx),%xmm0
subsd  0x10(%rax),%xmm0
mov    0x10(%rdi),%rdx
movsd  (%rdx),%xmm1
subsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rax)
movsd  0x10(%rdx),%xmm0
subsd  0x10(%rcx),%xmm0
mov    0x18(%rdi),%rax
movsd  (%rax),%xmm1
subsd  (%rcx),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rcx)
ret

LLVM IR (-O0):
define void @f2(double** %0) {
%2 = alloca double**
%3 = alloca i32
store double** %0, double*** %2
store i32 0, i32* %3
br label %4
4: ; preds = %47, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %50
7: ; preds = %4
%8 = load double**, double*** %2
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double*, double** %8, i64 %11
%13 = load double*, double** %12
%14 = getelementptr inbounds double, double* %13, i64 2
%15 = load double, double* %14
%16 = load double**, double*** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double*, double** %16, i64 %18
%20 = load double*, double** %19
%21 = getelementptr inbounds double, double* %20, i64 2
%22 = load double, double* %21
%23 = fsub double %15, %22
%24 = load double**, double*** %2
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %24, i64 %27
%29 = load double*, double** %28
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = load double**, double*** %2
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double*, double** %32, i64 %34
%36 = load double*, double** %35
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = fsub double %31, %38
%40 = fdiv double %23, %39
%41 = load double**, double*** %2
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double*, double** %41, i64 %43
%45 = load double*, double** %44
%46 = getelementptr inbounds double, double* %45, i64 3
store double %40, double* %46
br label %47
47: ; preds = %7
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %4
50: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @f2(double** nocapture %0) {
%2 = getelementptr inbounds double*, double** %0, i64 1
%3 = load double*, double** %2
%4 = getelementptr inbounds double, double* %3, i64 2
%5 = load double, double* %4
%6 = load double*, double** %0
%7 = getelementptr inbounds double, double* %6, i64 2
%8 = load double, double* %7
%9 = fsub double %5, %8
%10 = getelementptr inbounds double*, double** %0, i64 2
%11 = load double*, double** %10
%12 = load double, double* %11
%13 = load double, double* %6
%14 = fsub double %12, %13
%15 = fdiv double %9, %14
%16 = getelementptr inbounds double, double* %6, i64 3
store double %15, double* %16
%17 = getelementptr inbounds double, double* %11, i64 2
%18 = load double, double* %17
%19 = load double, double* %4
%20 = fsub double %18, %19
%21 = getelementptr inbounds double*, double** %0, i64 3
%22 = load double*, double** %21
%23 = load double, double* %22
%24 = load double, double* %3
%25 = fsub double %23, %24
%26 = fdiv double %20, %25
%27 = getelementptr inbounds double, double* %3, i64 3
store double %26, double* %27
ret void
}