void print_mat_float(int m, int n, float *a, int a_row_stride,
                     int a_col_stride) {
  int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      printf("%f ", a[(i)*a_row_stride + (j)*a_col_stride]);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_mat_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a7 <print_mat_float+0x97>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118b <print_mat_float+0x7b>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
mov    -0x20(%rbp),%edx
imul   -0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1143 <print_mat_float+0x33>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1130 <print_mat_float+0x20>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mat_float>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,0xc(%rsp)
test   %edi,%edi
jle    11be <print_mat_float+0x9e>
mov    %rdx,%r12
movslq %r8d,%rbx
movslq %ecx,%rax
mov    %edi,%ecx
mov    %rcx,0x18(%rsp)
mov    0xc(%rsp),%ecx
mov    %rcx,0x10(%rsp)
shl    $0x2,%rax
mov    %rax,0x20(%rsp)
shl    $0x2,%rbx
xor    %r14d,%r14d
lea    0xe96(%rip),%rbp
jmp    118a <print_mat_float+0x6a>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
add    0x20(%rsp),%r12
cmp    0x18(%rsp),%r14
je     11be <print_mat_float+0x9e>
cmpl   $0x0,0xc(%rsp)
jle    1170 <print_mat_float+0x50>
mov    0x10(%rsp),%r13
mov    %r12,%r15
nopl   0x0(%rax)
movss  (%r15),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    %rbx,%r15
add    $0xffffffffffffffff,%r13
jne    11a0 <print_mat_float+0x80>
jmp    1170 <print_mat_float+0x50>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%f \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_mat_float(i32 %0, i32 %1, float* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store float* %2, float** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %13
13: ; preds = %41, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
store i32 0, i32* %12
br label %18
18: ; preds = %36, %17
%19 = load i32, i32* %12
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load float*, float** %8
%24 = load i32, i32* %11
%25 = load i32, i32* %9
%26 = mul nsw i32 %24, %25
%27 = load i32, i32* %12
%28 = load i32, i32* %10
%29 = mul nsw i32 %27, %28
%30 = add nsw i32 %26, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %23, i64 %31
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %34)
br label %36
36: ; preds = %22
%37 = load i32, i32* %12
%38 = add nsw i32 %37, 1
store i32 %38, i32* %12
br label %18
39: ; preds = %18
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %13
44: ; preds = %13
%45 = 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 = [4 x i8] c"%f \00"
define void @print_mat_float(i32 %0, i32 %1, float* nocapture %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %31
7: ; preds = %5
%8 = icmp sgt i32 %1, 0
%9 = sext i32 %4 to i64
%10 = sext i32 %3 to i64
%11 = zext i32 %0 to i64
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %7, %27
%14 = phi i64 [ 0, %7 ], [ %29, %27 ]
br i1 %8, label %15, label %27
15: ; preds = %13
%16 = mul nsw i64 %14, %10
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %25, %17 ]
%19 = mul nsw i64 %18, %9
%20 = add nsw i64 %19, %16
%21 = getelementptr inbounds float, float* %2, i64 %20
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %23)
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %17
27: ; preds = %17, %13
%28 = tail call i32 @putchar(i32 10)
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %11
br i1 %30, label %31, label %13
31: ; preds = %27, %5
%32 = tail call i32 @putchar(i32 10)
ret void
}