void copy(double a[4][4], double b[4][4]) {
  int i, j;
  for (i = 0; i < 4; ++i)
    for (j = 0; j < 4; ++j)
      a[i][j] = b[i][j];
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    117f <copy+0x7f>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    116c <copy+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1124 <copy+0x24>
jmp    1171 <copy+0x71>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <copy+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdi)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdi)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x10(%rdi)
movsd  0x18(%rsi),%xmm0
movsd  %xmm0,0x18(%rdi)
movsd  0x20(%rsi),%xmm0
movsd  %xmm0,0x20(%rdi)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rdi)
movsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x30(%rdi)
movsd  0x38(%rsi),%xmm0
movsd  %xmm0,0x38(%rdi)
movsd  0x40(%rsi),%xmm0
movsd  %xmm0,0x40(%rdi)
movsd  0x48(%rsi),%xmm0
movsd  %xmm0,0x48(%rdi)
movsd  0x50(%rsi),%xmm0
movsd  %xmm0,0x50(%rdi)
movsd  0x58(%rsi),%xmm0
movsd  %xmm0,0x58(%rdi)
movsd  0x60(%rsi),%xmm0
movsd  %xmm0,0x60(%rdi)
movsd  0x68(%rsi),%xmm0
movsd  %xmm0,0x68(%rdi)
movsd  0x70(%rsi),%xmm0
movsd  %xmm0,0x70(%rdi)
movsd  0x78(%rsi),%xmm0
movsd  %xmm0,0x78(%rdi)
ret

LLVM IR (-O0):
define void @copy([4 x double]* %0, [4 x double]* %1) {
%3 = alloca [4 x double]*
%4 = alloca [4 x double]*
%5 = alloca i32
%6 = alloca i32
store [4 x double]* %0, [4 x double]** %3
store [4 x double]* %1, [4 x double]** %4
store i32 0, i32* %5
br label %7
7: ; preds = %34, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %37
10: ; preds = %7
store i32 0, i32* %6
br label %11
11: ; preds = %30, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %33
14: ; preds = %11
%15 = load [4 x double]*, [4 x double]** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 %17
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x double], [4 x double]* %18, i64 0, i64 %20
%22 = load double, double* %21
%23 = load [4 x double]*, [4 x double]** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x double], [4 x double]* %23, i64 %25
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x double], [4 x double]* %26, i64 0, i64 %28
store double %22, double* %29
br label %30
30: ; preds = %14
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %11
33: ; preds = %11
br label %34
34: ; preds = %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %7
37: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @copy([4 x double]* nocapture writeonly %0, [4 x double]* nocapture %1) {
%3 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%4 = load double, double* %3
%5 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
store double %4, double* %5
%6 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 1
store double %7, double* %8
%9 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 2
%10 = load double, double* %9
%11 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 2
store double %10, double* %11
%12 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 3
%13 = load double, double* %12
%14 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 3
store double %13, double* %14
%15 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 0
%16 = load double, double* %15
%17 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
store double %16, double* %17
%18 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 1
%19 = load double, double* %18
%20 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 1
store double %19, double* %20
%21 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 2
%22 = load double, double* %21
%23 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 2
store double %22, double* %23
%24 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 3
%25 = load double, double* %24
%26 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 3
store double %25, double* %26
%27 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 0
%28 = load double, double* %27
%29 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
store double %28, double* %29
%30 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 1
%31 = load double, double* %30
%32 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
store double %31, double* %32
%33 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 2
%34 = load double, double* %33
%35 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 2
store double %34, double* %35
%36 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 3
%37 = load double, double* %36
%38 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 3
store double %37, double* %38
%39 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 0
%40 = load double, double* %39
%41 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
store double %40, double* %41
%42 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 1
%43 = load double, double* %42
%44 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 1
store double %43, double* %44
%45 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 2
%46 = load double, double* %45
%47 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 2
store double %46, double* %47
%48 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 3
%49 = load double, double* %48
%50 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 3
store double %49, double* %50
ret void
}