#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char const *, ...);
void floats_print_mat(const float *a, int nrows, int ncols, const char *fmt) {
  for (int i = 0; i < nrows * ncols; i++) {
    printf(fmt, a[i]);
    if ((i % ncols) == (ncols - 1))
      printf("\n");
  }
}


x86 assembly (clang, -O0):
<floats_print_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1191 <floats_print_mat+0x81>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cmp    %eax,%edx
jne    117e <floats_print_mat+0x6e>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1183 <floats_print_mat+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <floats_print_mat+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floats_print_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
imul   %edx,%esi
test   %esi,%esi
jle    1184 <floats_print_mat+0x64>
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rdi,%r15
lea    -0x1(%r12),%r13d
mov    %esi,%ebp
xor    %ebx,%ebx
jmp    1159 <floats_print_mat+0x39>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1184 <floats_print_mat+0x64>
movss  (%r15,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %ebx,%eax
cltd
idiv   %r12d
cmp    %r13d,%edx
jne    1150 <floats_print_mat+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <floats_print_mat+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @floats_print_mat(float* nocapture %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = mul i32 %2, %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = add nsw i32 %2, -1
%9 = zext i32 %5 to i64
br label %11
10: ; preds = %22, %4
ret void
11: ; preds = %7, %22
%12 = phi i64 [ 0, %7 ], [ %23, %22 ]
%13 = getelementptr inbounds float, float* %0, i64 %12
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %3, double %15)
%17 = trunc i64 %12 to i32
%18 = srem i32 %17, %2
%19 = icmp eq i32 %18, %8
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = tail call i32 @putchar(i32 10)
br label %22
22: ; preds = %11, %20
%23 = add nuw nsw i64 %12, 1
%24 = icmp eq i64 %23, %9
br i1 %24, label %10, label %11
}