void lin_fm(const double *u, double *p, const int *inl, const int len) {
  const double *s;
  int i, k, l, pos;
  for (i = 0; i < len; i++) {
    s = u + 6 * inl[i];
    pos = 0;
    for (k = 0; k < 3; k++) {
      for (l = 0; l < 3; l++) {
        *(p + pos) = *(s + k + 3) * (*(s + l));
        pos += len;
      }
    }
    p++;
  }
}


x86 assembly (clang, -O0):
<lin_fm>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d9 <lin_fm+0xd9>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
imul   $0x6,(%rcx,%rdx,4),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    11bf <lin_fm+0xbf>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11ac <lin_fm+0xac>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  0x18(%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1163 <lin_fm+0x63>
jmp    11b1 <lin_fm+0xb1>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1152 <lin_fm+0x52>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    111a <lin_fm+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<lin_fm>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
jle    1217 <lin_fm+0x117>
mov    %ecx,%eax
lea    (%rcx,%rcx,2),%ebx
movslq %ebx,%r12
lea    (%r12,%rax,1),%r15
lea    (%r15,%rax,1),%r14
add    %r14d,%ecx
movslq %ecx,%rcx
lea    (%rcx,%rax,1),%rbx
lea    (%rbx,%rax,1),%r9
lea    0x0(,%rax,4),%r8
lea    (%rsi,%r9,8),%r9
lea    (%rsi,%rbx,8),%r10
lea    (%rsi,%rcx,8),%r11
lea    (%rsi,%r14,8),%r14
lea    (%rsi,%r15,8),%r15
lea    (%rsi,%r12,8),%r12
lea    (%rsi,%rax,8),%r13
shl    $0x4,%rax
add    %rsi,%rax
xor    %ecx,%ecx
nopl   0x0(%rax)
movslq (%rdx,%rcx,1),%rbx
lea    (%rbx,%rbx,2),%rbx
shl    $0x4,%rbx
movsd  0x18(%rdi,%rbx,1),%xmm0
mulsd  (%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%rsi,%rcx,2)
movsd  0x18(%rdi,%rbx,1),%xmm0
mulsd  0x8(%rdi,%rbx,1),%xmm0
movsd  %xmm0,0x0(%r13,%rcx,2)
movsd  0x18(%rdi,%rbx,1),%xmm0
mulsd  0x10(%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%rax,%rcx,2)
movsd  0x20(%rdi,%rbx,1),%xmm0
mulsd  (%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%r12,%rcx,2)
movsd  0x20(%rdi,%rbx,1),%xmm0
mulsd  0x8(%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%r15,%rcx,2)
movsd  0x20(%rdi,%rbx,1),%xmm0
mulsd  0x10(%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%r14,%rcx,2)
movsd  0x28(%rdi,%rbx,1),%xmm0
mulsd  (%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%r11,%rcx,2)
movsd  0x28(%rdi,%rbx,1),%xmm0
mulsd  0x8(%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%r10,%rcx,2)
movsd  0x28(%rdi,%rbx,1),%xmm0
mulsd  0x10(%rdi,%rbx,1),%xmm0
movsd  %xmm0,(%r9,%rcx,2)
add    $0x4,%rcx
cmp    %rcx,%r8
jne    1160 <lin_fm+0x60>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @lin_fm(double* nocapture %0, double* nocapture writeonly %1, i32* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %70
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = zext i32 %3 to i64
%9 = shl nuw nsw i64 %7, 1
%10 = mul i32 %3, 3
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, %7
%13 = add nsw i64 %12, %7
%14 = trunc i64 %13 to i32
%15 = add i32 %14, %3
%16 = sext i32 %15 to i64
%17 = add nsw i64 %16, %7
%18 = add nsw i64 %17, %7
br label %19
19: ; preds = %6, %19
%20 = phi i64 [ 0, %6 ], [ %68, %19 ]
%21 = phi double* [ %1, %6 ], [ %67, %19 ]
%22 = getelementptr inbounds i32, i32* %2, i64 %20
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %0, i64 %25
%27 = getelementptr inbounds double, double* %26, i64 3
%28 = load double, double* %27
%29 = load double, double* %26
%30 = fmul double %28, %29
store double %30, double* %21
%31 = load double, double* %27
%32 = getelementptr inbounds double, double* %26, i64 1
%33 = load double, double* %32
%34 = fmul double %31, %33
%35 = getelementptr inbounds double, double* %21, i64 %7
store double %34, double* %35
%36 = load double, double* %27
%37 = getelementptr inbounds double, double* %26, i64 2
%38 = load double, double* %37
%39 = fmul double %36, %38
%40 = getelementptr inbounds double, double* %21, i64 %9
store double %39, double* %40
%41 = getelementptr inbounds double, double* %32, i64 3
%42 = load double, double* %41
%43 = load double, double* %26
%44 = fmul double %42, %43
%45 = getelementptr inbounds double, double* %21, i64 %11
store double %44, double* %45
%46 = load double, double* %41
%47 = load double, double* %32
%48 = fmul double %46, %47
%49 = getelementptr inbounds double, double* %21, i64 %12
store double %48, double* %49
%50 = load double, double* %41
%51 = load double, double* %37
%52 = fmul double %50, %51
%53 = getelementptr inbounds double, double* %21, i64 %13
store double %52, double* %53
%54 = getelementptr inbounds double, double* %37, i64 3
%55 = load double, double* %54
%56 = load double, double* %26
%57 = fmul double %55, %56
%58 = getelementptr inbounds double, double* %21, i64 %16
store double %57, double* %58
%59 = load double, double* %54
%60 = load double, double* %32
%61 = fmul double %59, %60
%62 = getelementptr inbounds double, double* %21, i64 %17
store double %61, double* %62
%63 = load double, double* %54
%64 = load double, double* %37
%65 = fmul double %63, %64
%66 = getelementptr inbounds double, double* %21, i64 %18
store double %65, double* %66
%67 = getelementptr inbounds double, double* %21, i64 1
%68 = add nuw nsw i64 %20, 1
%69 = icmp eq i64 %68, %8
br i1 %69, label %70, label %19
70: ; preds = %19, %4
ret void
}