#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 *, ...);
void PrintMat(const char *name, float A[], int rows, int cols) {
  printf("%s:\n", name);
  int i;
  int j;
  for (i = 0; i < rows; i++) {
    for (j = 0; j < cols; j++) {
      printf("%.2f\t", A[cols * i + j]);
      if (j == cols - 1)
        printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<PrintMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cb <PrintMat+0xbb>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b8 <PrintMat+0xa8>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11a5 <PrintMat+0x95>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <PrintMat+0x9a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <PrintMat+0x42>
jmp    11bd <PrintMat+0xad>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <PrintMat+0x2f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintMat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,(%rsp)
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
jle    11ce <PrintMat+0xae>
mov    (%rsp),%rax
lea    -0x1(%rax),%ebp
cltq
mov    %r15d,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r14d
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
xor    %r13d,%r13d
lea    0xe8c(%rip),%r15
jmp    1190 <PrintMat+0x70>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
add    0x10(%rsp),%rbx
cmp    0x8(%rsp),%r13
je     11ce <PrintMat+0xae>
cmpl   $0x0,(%rsp)
jle    1180 <PrintMat+0x60>
xor    %r12d,%r12d
jmp    11a9 <PrintMat+0x89>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12,%r14
je     1180 <PrintMat+0x60>
movss  (%rbx,%r12,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    %r12,%rbp
jne    11a0 <PrintMat+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <PrintMat+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [6 x i8] c"%.2f\09\00"
define void @PrintMat(i8* %0, float* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %34
7: ; preds = %4
%8 = icmp sgt i32 %3, 0
%9 = add nsw i32 %3, -1
%10 = zext i32 %9 to i64
%11 = sext i32 %3 to i64
%12 = zext i32 %2 to i64
%13 = zext i32 %3 to i64
br label %14
14: ; preds = %7, %31
%15 = phi i64 [ 0, %7 ], [ %32, %31 ]
br i1 %8, label %16, label %31
16: ; preds = %14
%17 = mul nsw i64 %15, %11
br label %18
18: ; preds = %16, %28
%19 = phi i64 [ 0, %16 ], [ %29, %28 ]
%20 = add nsw i64 %19, %17
%21 = getelementptr inbounds float, float* %1, i64 %20
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %23)
%25 = icmp eq i64 %19, %10
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = tail call i32 @putchar(i32 10)
br label %28
28: ; preds = %18, %26
%29 = add nuw nsw i64 %19, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %31, label %18
31: ; preds = %28, %14
%32 = add nuw nsw i64 %15, 1
%33 = icmp eq i64 %32, %12
br i1 %33, label %34, label %14
34: ; preds = %31, %4
ret void
}