makeident(a) double a[4][4];
{
  register int i, j;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++)
      a[i][j] = (i == j) ? 1.0 : 0.0;
}


x86 assembly (clang, -O0):
<makeident>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1195 <makeident+0x95>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1182 <makeident+0x82>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
movsd  0xec8(%rip),%xmm0
xorps  %xmm1,%xmm1
movsd  %xmm1,-0x28(%rbp)
cmp    %ecx,%eax
movsd  %xmm0,-0x20(%rbp)
je     1157 <makeident+0x57>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%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    1120 <makeident+0x20>
jmp    1187 <makeident+0x87>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <makeident+0xf>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeident>:
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rdi)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rdi)
movups %xmm0,0x18(%rdi)
mov    %rax,0x28(%rdi)
movups %xmm0,0x30(%rdi)
movups %xmm0,0x40(%rdi)
mov    %rax,0x50(%rdi)
movups %xmm0,0x58(%rdi)
movups %xmm0,0x68(%rdi)
mov    %rax,0x78(%rdi)
ret

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

LLVM IR (-O2):
define i32 @makeident([4 x double]* nocapture writeonly %0) {
%2 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
store double 1.000000e+00, double* %2
%3 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 1
%4 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 1
%5 = bitcast double* %3 to i8*
store double 1.000000e+00, double* %4
%6 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 2
%7 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 2
%8 = bitcast double* %6 to i8*
store double 1.000000e+00, double* %7
%9 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 3
%10 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 3
%11 = bitcast double* %9 to i8*
store double 1.000000e+00, double* %10
ret i32 undef
}