#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 *, float const);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
void mvMatPrint(const float *m, int dim) {
  int i, j;
  if (dim < 2 || dim > 4) {
    puts("mvVecPrint() : invalid dimension; must be 3 or 4");
    return;
  }
  puts("--------------------------------");
  for (i = 0; i < dim; i++) {
    for (j = 0; j < dim; j++) {
      printf(" %.2f\t", m[(j * dim) + i]);
    }
    putchar('\n');
  }
  puts("--------------------------------");
}


x86 assembly (clang, -O0):
<mvMatPrint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jl     1153 <mvMatPrint+0x23>
cmpl   $0x4,-0xc(%rbp)
jle    1164 <mvMatPrint+0x34>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
jmp    11ea <mvMatPrint+0xba>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <mvMatPrint+0xae>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c6 <mvMatPrint+0x96>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118a <mvMatPrint+0x5a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <mvMatPrint+0x47>
lea    0xe4c(%rip),%rdi
call   1040 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvMatPrint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
jae    114e <mvMatPrint+0x1e>
lea    0xeb4(%rip),%rdi
jmp    11c8 <mvMatPrint+0x98>
mov    %rdi,%r14
lea    0xed9(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%r12d
lea    0x0(,%r12,4),%rbx
xor    %ebp,%ebp
lea    0xee1(%rip),%r13
mov    %r12,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  (%r15),%xmm0
mov    %r13,%rdi
call   1050 <printf@plt>
add    %rbx,%r15
add    $0xffffffffffffffff,%r12
jne    1190 <mvMatPrint+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    $0x4,%r14
mov    (%rsp),%r12
cmp    %r12,%rbp
jne    1180 <mvMatPrint+0x50>
lea    0xe69(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"mvVecPrint() : invalid dimension; must be 3 or 4\00"
@.str.1 = [33 x i8] c"--------------------------------\00"
@.str.2 = [7 x i8] c" %.2f\09\00"
define void @mvMatPrint(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store float* %0, float** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %9, %2
%13 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %46
14: ; preds = %9
%15 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %16
16: ; preds = %41, %14
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %44
20: ; preds = %16
store i32 0, i32* %6
br label %21
21: ; preds = %36, %20
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load float*, float** %3
%27 = load i32, i32* %6
%28 = load i32, i32* %4
%29 = mul nsw i32 %27, %28
%30 = load i32, i32* %5
%31 = add nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %26, i64 %32
%34 = load float, float* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %34)
br label %36
36: ; preds = %25
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %21
39: ; preds = %21
%40 = call i32 @putchar(i8 signext 10)
br label %41
41: ; preds = %39
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %16
44: ; preds = %16
%45 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %44, %12
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"mvVecPrint() : invalid dimension; must be 3 or 4\00"
@.str.1 = [33 x i8] c"--------------------------------\00"
@.str.2 = [7 x i8] c" %.2f\09\00"
define void @mvMatPrint(float* nocapture %0, i32 %1) {
%3 = add i32 %1, -5
%4 = icmp ult i32 %3, -3
br i1 %4, label %24, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%7 = zext i32 %1 to i64
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %20, %5
%10 = phi i64 [ 0, %5 ], [ %22, %20 ]
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %18, %11 ]
%13 = mul nsw i64 %12, %7
%14 = add nuw nsw i64 %13, %10
%15 = getelementptr inbounds float, float* %0, i64 %14
%16 = load float, float* %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %16)
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %20, label %11
20: ; preds = %11
%21 = tail call i32 @putchar(i8 signext 10)
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %9
24: ; preds = %20, %2
%25 = phi i8* [ getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), %20 ]
%26 = tail call i32 @puts(i8* dereferenceable(1) %25)
ret void
}