void insert3x3(int n, int i0, int j0, double *restrict a, double *restrict b) {
  int k0 = i0 + n * j0;
  int nm3 = n - 3;
  a += k0;
  *a++ = *b++;
  *a++ = *b++;
  *a++ = *b++;
  a += nm3;
  *a++ = *b++;
  *a++ = *b++;
  *a++ = *b++;
  a += nm3;
  *a++ = *b++;
  *a++ = *b++;
  *a = *b;
}


x86 assembly (clang, -O0):
<insert3x3>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert3x3>:
imul   %edi,%edx
add    %esi,%edx
movslq %edx,%rax
lea    (%rcx,%rax,8),%rdx
movups (%r8),%xmm0
movups %xmm0,(%rcx,%rax,8)
movsd  0x10(%r8),%xmm0
movslq %edi,%rsi
lea    -0x8(%rdx,%rsi,8),%rdi
movsd  %xmm0,0x10(%rcx,%rax,8)
movups 0x18(%r8),%xmm0
movups %xmm0,(%rdx,%rsi,8)
movsd  0x28(%r8),%xmm0
movsd  %xmm0,0x10(%rdx,%rsi,8)
movsd  0x30(%r8),%xmm0
movsd  %xmm0,0x8(%rdi,%rsi,8)
movsd  0x38(%r8),%xmm0
movsd  %xmm0,0x10(%rdi,%rsi,8)
movsd  0x40(%r8),%xmm0
movsd  %xmm0,0x18(%rdi,%rsi,8)
ret

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

LLVM IR (-O2):
define void @insert3x3(i32 %0, i32 %1, i32 %2, double* noalias nocapture writeonly %3, double* noalias nocapture %4) {
%6 = mul nsw i32 %2, %0
%7 = add nsw i32 %6, %1
%8 = add nsw i32 %0, -3
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds double, double* %3, i64 %9
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = getelementptr inbounds double, double* %4, i64 2
%13 = bitcast double* %4 to <2 x double>*
%14 = load <2 x double>, <2 x double>* %13
%15 = getelementptr inbounds double, double* %11, i64 1
%16 = bitcast double* %10 to <2 x double>*
store <2 x double> %14, <2 x double>* %16
%17 = getelementptr inbounds double, double* %4, i64 3
%18 = load double, double* %12
%19 = getelementptr inbounds double, double* %15, i64 1
store double %18, double* %15
%20 = sext i32 %8 to i64
%21 = getelementptr inbounds double, double* %19, i64 %20
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = getelementptr inbounds double, double* %4, i64 5
%24 = bitcast double* %17 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = getelementptr inbounds double, double* %22, i64 1
%27 = bitcast double* %21 to <2 x double>*
store <2 x double> %25, <2 x double>* %27
%28 = getelementptr inbounds double, double* %4, i64 6
%29 = load double, double* %23
%30 = getelementptr inbounds double, double* %26, i64 1
store double %29, double* %26
%31 = getelementptr inbounds double, double* %30, i64 %20
%32 = getelementptr inbounds double, double* %4, i64 7
%33 = load double, double* %28
%34 = getelementptr inbounds double, double* %31, i64 1
store double %33, double* %31
%35 = getelementptr inbounds double, double* %4, i64 8
%36 = load double, double* %32
%37 = getelementptr inbounds double, double* %34, i64 1
store double %36, double* %34
%38 = load double, double* %35
store double %38, double* %37
ret void
}