void vk_rtv(double vk[4], double rtv[4][4]) {
  int i, j;
  double v[4];
  for (i = 1; i <= 3; i++) {
    v[i] = 0.0;
    for (j = 1; j <= 3; j++) {
      v[i] = v[i] + vk[j] * rtv[j][i];
    }
  }
  for (i = 1; i <= 3; i++)
    vk[i] = v[i];
}


x86 assembly (clang, -O0):
<vk_rtv>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     119d <vk_rtv+0x9d>
movslq -0x14(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp,%rax,8)
movl   $0x1,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jg     118a <vk_rtv+0x8a>
movslq -0x14(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <vk_rtv+0x31>
jmp    118f <vk_rtv+0x8f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <vk_rtv+0x13>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     11d3 <vk_rtv+0xd3>
movslq -0x14(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <vk_rtv+0xa4>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vk_rtv>:
movsd  0x8(%rdi),%xmm2
movsd  0x10(%rdi),%xmm1
movsd  0x18(%rdi),%xmm0
movapd %xmm2,%xmm3
unpcklpd %xmm2,%xmm3
movupd 0x28(%rsi),%xmm4
mulpd  %xmm3,%xmm4
movupd 0x48(%rsi),%xmm3
movupd 0x68(%rsi),%xmm5
xorpd  %xmm6,%xmm6
addpd  %xmm4,%xmm6
movapd %xmm1,%xmm4
unpcklpd %xmm1,%xmm4
mulpd  %xmm3,%xmm4
addpd  %xmm6,%xmm4
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
mulpd  %xmm5,%xmm3
addpd  %xmm4,%xmm3
mulsd  0x38(%rsi),%xmm2
xorpd  %xmm4,%xmm4
addsd  %xmm2,%xmm4
mulsd  0x58(%rsi),%xmm1
mulsd  0x78(%rsi),%xmm0
addsd  %xmm4,%xmm1
addsd  %xmm1,%xmm0
movupd %xmm3,0x8(%rdi)
movsd  %xmm0,0x18(%rdi)
ret

LLVM IR (-O0):
define void @vk_rtv(double* %0, [4 x double]* %1) {
%3 = alloca double*
%4 = alloca [4 x double]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4 x double]
store double* %0, double** %3
store [4 x double]* %1, [4 x double]** %4
store i32 1, i32* %5
br label %8
8: ; preds = %44, %2
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 3
br i1 %10, label %11, label %47
11: ; preds = %8
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %13
store double 0.000000e+00, double* %14
store i32 1, i32* %6
br label %15
15: ; preds = %40, %11
%16 = load i32, i32* %6
%17 = icmp sle i32 %16, 3
br i1 %17, label %18, label %43
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %3
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load [4 x double]*, [4 x double]** %4
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x double], [4 x double]* %28, i64 %30
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [4 x double], [4 x double]* %31, i64 0, i64 %33
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double %27, double %35, double %22)
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %38
store double %36, double* %39
br label %40
40: ; preds = %18
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %15
43: ; preds = %15
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %8
47: ; preds = %8
store i32 1, i32* %5
br label %48
48: ; preds = %60, %47
%49 = load i32, i32* %5
%50 = icmp sle i32 %49, 3
br i1 %50, label %51, label %63
51: ; preds = %48
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 %53
%55 = load double, double* %54
%56 = load double*, double** %3
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %55, double* %59
br label %60
60: ; preds = %51
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %48
63: ; preds = %48
ret void
}

LLVM IR (-O2):
define void @vk_rtv(double* nocapture %0, [4 x double]* nocapture %1) {
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 1
%6 = getelementptr inbounds double, double* %0, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 1
%9 = getelementptr inbounds double, double* %0, i64 3
%10 = load double, double* %9
%11 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 1
%12 = bitcast double* %5 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = insertelement <2 x double> poison, double %4, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %13, <2 x double> zeroinitializer)
%17 = bitcast double* %8 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = insertelement <2 x double> poison, double %7, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %18, <2 x double> %16)
%22 = bitcast double* %11 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = insertelement <2 x double> poison, double %10, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %23, <2 x double> %21)
%27 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 3
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %4, double %28, double 0.000000e+00)
%30 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 3
%31 = load double, double* %30
%32 = tail call double @llvm.fmuladd.f64(double %7, double %31, double %29)
%33 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 3
%34 = load double, double* %33
%35 = tail call double @llvm.fmuladd.f64(double %10, double %34, double %32)
%36 = bitcast double* %3 to <2 x double>*
store <2 x double> %26, <2 x double>* %36
store double %35, double* %9
ret void
}