#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*/ PRNT(char *, ...);
int strlen(char const *);
void printMat(const double *A, const int n, const int m, const char *nm) {
  int c, r, i, sl = strlen(nm);
  ;
  PRNT("%s= [", nm);
  for (r = 0; r < n; r++) {
    for (c = 0; c < m; c++) {
      PRNT("%g", A[r + n * c]);
      if (c < (m - 1)) {
        PRNT(", ");
      } else {
        if (r < (n - 1)) {
          PRNT("\n   ");
          for (i = 0; i < sl; i++)
            PRNT(" ");
        } else {
          PRNT("]\n");
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<printMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <PRNT@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1250 <printMat+0x130>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    123d <printMat+0x11d>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1040 <PRNT@plt>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11c4 <printMat+0xa4>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <PRNT@plt>
jmp    122a <printMat+0x10a>
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1217 <printMat+0xf7>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <PRNT@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1212 <printMat+0xf2>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <PRNT@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ea <printMat+0xca>
jmp    1225 <printMat+0x105>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <PRNT@plt>
jmp    122a <printMat+0x10a>
jmp    122f <printMat+0x10f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <printMat+0x4e>
jmp    1242 <printMat+0x122>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <printMat+0x3b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdx,0x8(%rsp)
mov    %esi,%ebx
mov    %rdi,0x20(%rsp)
mov    %rcx,%rdi
call   1030 <strlen@plt>
mov    %eax,0x4(%rsp)
lea    0xeb0(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <PRNT@plt>
test   %ebx,%ebx
jle    1232 <printMat+0x112>
mov    %rbx,%rdx
mov    0x8(%rsp),%rcx
lea    -0x1(%rcx),%eax
mov    %edx,%esi
mov    %rsi,0x10(%rsp)
add    $0xffffffff,%edx
mov    %rdx,0x18(%rsp)
movslq %eax,%r12
mov    %ecx,%r15d
lea    0xe86(%rip),%r14
xor    %ebp,%ebp
jmp    119f <printMat+0x7f>
nopl   (%rax)
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     1232 <printMat+0x112>
cmpl   $0x0,0x8(%rsp)
jle    1190 <printMat+0x70>
xor    %ebx,%ebx
jmp    11d5 <printMat+0xb5>
nopw   0x0(%rax,%rax,1)
cmp    %r12,%rbx
lea    0xe57(%rip),%rdi
lea    0xe48(%rip),%rax
cmovl  %rax,%rdi
xor    %eax,%eax
call   1040 <PRNT@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
je     1190 <printMat+0x70>
mov    %rbx,%rax
imul   0x10(%rsp),%rax
add    %rbp,%rax
mov    0x20(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
lea    0xe14(%rip),%rdi
mov    $0x1,%al
call   1040 <PRNT@plt>
cmp    %r12,%rbx
jl     11b0 <printMat+0x90>
cmp    0x18(%rsp),%rbp
jae    11b0 <printMat+0x90>
lea    0xe00(%rip),%rdi
xor    %eax,%eax
call   1040 <PRNT@plt>
cmpl   $0x0,0x4(%rsp)
jle    11cc <printMat+0xac>
mov    0x4(%rsp),%r13d
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <PRNT@plt>
add    $0xffffffff,%r13d
jne    1220 <printMat+0x100>
jmp    11cc <printMat+0xac>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s= [\00"
@.str.1 = [3 x i8] c"%g\00"
@.str.2 = [3 x i8] c", \00"
@.str.3 = [5 x i8] c"\0A \00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c"]\0A\00"
define void @printMat(double* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%13 = load i8*, i8** %8
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %12
%15 = load i8*, i8** %8
%16 = call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %10
br label %17
17: ; preds = %68, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %71
21: ; preds = %17
store i32 0, i32* %9
br label %22
22: ; preds = %64, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %67
26: ; preds = %22
%27 = load double*, double** %5
%28 = load i32, i32* %10
%29 = load i32, i32* %6
%30 = load i32, i32* %9
%31 = mul nsw i32 %29, %30
%32 = add nsw i32 %28, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %27, i64 %33
%35 = load double, double* %34
%36 = call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %35)
%37 = load i32, i32* %9
%38 = load i32, i32* %7
%39 = sub nsw i32 %38, 1
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %43
41: ; preds = %26
%42 = call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %63
43: ; preds = %26
%44 = load i32, i32* %10
%45 = load i32, i32* %6
%46 = sub nsw i32 %45, 1
%47 = icmp slt i32 %44, %46
br i1 %47, label %48, label %60
48: ; preds = %43
%49 = call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %11
br label %50
50: ; preds = %56, %48
%51 = load i32, i32* %11
%52 = load i32, i32* %12
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 1
store i32 %58, i32* %11
br label %50
59: ; preds = %50
br label %62
60: ; preds = %43
%61 = call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60, %59
br label %63
63: ; preds = %62, %41
br label %64
64: ; preds = %63
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %22
67: ; preds = %22
br label %68
68: ; preds = %67
%69 = load i32, i32* %10
%70 = add nsw i32 %69, 1
store i32 %70, i32* %10
br label %17
71: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s= [\00"
@.str.1 = [3 x i8] c"%g\00"
@.str.2 = [3 x i8] c", \00"
@.str.3 = [5 x i8] c"\0A \00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c"]\0A\00"
define void @printMat(double* nocapture %0, i32 %1, i32 %2, i8* %3) {
%5 = tail call i32 @strlen(i8* %3)
%6 = tail call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %47
8: ; preds = %4
%9 = icmp sgt i32 %2, 0
%10 = add nsw i32 %2, -1
%11 = add nsw i32 %1, -1
%12 = icmp sgt i32 %5, 0
%13 = zext i32 %1 to i64
%14 = sext i32 %10 to i64
%15 = zext i32 %11 to i64
%16 = zext i32 %1 to i64
%17 = zext i32 %2 to i64
br label %18
18: ; preds = %8, %44
%19 = phi i64 [ 0, %8 ], [ %45, %44 ]
br i1 %9, label %20, label %44
20: ; preds = %18
%21 = icmp uge i64 %19, %15
br label %22
22: ; preds = %20, %41
%23 = phi i64 [ 0, %20 ], [ %42, %41 ]
%24 = mul nsw i64 %23, %13
%25 = add nuw nsw i64 %24, %19
%26 = getelementptr inbounds double, double* %0, i64 %25
%27 = load double, double* %26
%28 = tail call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = icmp slt i64 %23, %14
%30 = select i1 %29, i1 true, i1 %21
br i1 %30, label %38, label %31
31: ; preds = %22
%32 = tail call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br i1 %12, label %33, label %41
33: ; preds = %31, %33
%34 = phi i32 [ %36, %33 ], [ 0, %31 ]
%35 = tail call i32 (i8*, ...) @PRNT(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = add nuw nsw i32 %34, 1
%37 = icmp eq i32 %36, %5
br i1 %37, label %41, label %33
38: ; preds = %22
%39 = select i1 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0)
%40 = tail call i32 (i8*, ...) @PRNT(i8* %39)
br label %41
41: ; preds = %33, %38, %31
%42 = add nuw nsw i64 %23, 1
%43 = icmp eq i64 %42, %17
br i1 %43, label %44, label %22
44: ; preds = %41, %18
%45 = add nuw nsw i64 %19, 1
%46 = icmp eq i64 %45, %16
br i1 %46, label %47, label %18
47: ; preds = %44, %4
ret void
}