void lprint_matrix(matrix, depth) double *matrix;
long depth;
{
  long i, j;
  for (i = 0; i < depth; i++) {
    for (j = 0; j < depth; j++) {
      printf("%5.2f ", (double)(matrix[i * depth + j]));
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<lprint_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11a0 <lprint_matrix+0x90>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1181 <lprint_matrix+0x71>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
imul   -0x10(%rbp),%rcx
add    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe97(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113e <lprint_matrix+0x2e>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <lprint_matrix+0x18>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lprint_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
jle    118e <lprint_matrix+0x6e>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x0(,%rsi,8),%r12
xor    %r13d,%r13d
lea    0xeb8(%rip),%r15
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rbx,%rbp,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1160 <lprint_matrix+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    %r12,%rbx
cmp    %r14,%r13
jne    1150 <lprint_matrix+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%5.2f \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @lprint_matrix(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store double* %0, double** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %7
7: ; preds = %31, %2
%8 = load i64, i64* %5
%9 = load i64, i64* %4
%10 = icmp slt i64 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
store i64 0, i64* %6
br label %12
12: ; preds = %26, %11
%13 = load i64, i64* %6
%14 = load i64, i64* %4
%15 = icmp slt i64 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load double*, double** %3
%18 = load i64, i64* %5
%19 = load i64, i64* %4
%20 = mul nsw i64 %18, %19
%21 = load i64, i64* %6
%22 = add nsw i64 %20, %21
%23 = getelementptr inbounds double, double* %17, i64 %22
%24 = load double, double* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %24)
br label %26
26: ; preds = %16
%27 = load i64, i64* %6
%28 = add nsw i64 %27, 1
store i64 %28, i64* %6
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i64, i64* %5
%33 = add nsw i64 %32, 1
store i64 %33, i64* %5
br label %7
34: ; preds = %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%5.2f \00"
define void @lprint_matrix(double* nocapture %0, i64 %1) {
%3 = icmp sgt i64 %1, 0
br i1 %3, label %4, label %19
4: ; preds = %2, %15
%5 = phi i64 [ %17, %15 ], [ 0, %2 ]
%6 = mul nsw i64 %5, %1
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %13, %7 ]
%9 = add nsw i64 %8, %6
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %11)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %1
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = tail call i32 @putchar(i32 10)
%17 = add nuw nsw i64 %5, 1
%18 = icmp eq i64 %17, %1
br i1 %18, label %19, label %4
19: ; preds = %15, %2
%20 = tail call i32 @putchar(i32 10)
ret void
}