void lib3ds_matrix_identity(float m[4][4]) {
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++)
      m[i][j] = 0.0;
  }
  for (i = 0; i < 4; i++)
    m[i][i] = 1.0;
}


x86 assembly (clang, -O0):
<lib3ds_matrix_identity>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    1166 <lib3ds_matrix_identity+0x66>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1153 <lib3ds_matrix_identity+0x53>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1120 <lib3ds_matrix_identity+0x20>
jmp    1158 <lib3ds_matrix_identity+0x58>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <lib3ds_matrix_identity+0xf>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11a5 <lib3ds_matrix_identity+0xa5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
movss  0xe6e(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <lib3ds_matrix_identity+0x6d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib3ds_matrix_identity>:
xorps  %xmm0,%xmm0
movups %xmm0,0x14(%rdi)
movups %xmm0,0x24(%rdi)
movups %xmm0,0x4(%rdi)
movq   $0x0,0x34(%rdi)
movl   $0x3f800000,(%rdi)
movl   $0x3f800000,0x14(%rdi)
movl   $0x3f800000,0x28(%rdi)
movl   $0x3f800000,0x3c(%rdi)
ret

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

LLVM IR (-O2):
define void @lib3ds_matrix_identity([4 x float]* nocapture writeonly %0) {
%2 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 0, i64 1
%3 = bitcast float* %2 to i8*
%4 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 0, i64 0
store float 1.000000e+00, float* %4
%5 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 1, i64 1
store float 1.000000e+00, float* %5
%6 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 2, i64 2
store float 1.000000e+00, float* %6
%7 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 3, i64 3
store float 1.000000e+00, float* %7
ret void
}