#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*/ print_vec(int, double *);
int /*<<< orphan*/ printf(char *);
void print_mat(int n, int m, double **A) {
  printf("[");
  if (n > 0)
    print_vec(m, A[0]);
  int row;
  for (row = 1; row < n; row++) {
    printf(",\n");
    print_vec(m, A[row]);
  }
  printf("]");
}


x86 assembly (clang, -O0):
<print_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    1157 <print_mat+0x37>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <print_vec@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1198 <print_mat+0x78>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <print_vec@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <print_mat+0x3e>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mat>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%r14d
mov    $0x5b,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    118d <print_mat+0x5d>
mov    (%r15),%rsi
mov    %r12d,%edi
call   1050 <print_vec@plt>
cmp    $0x1,%r14d
je     118d <print_mat+0x5d>
mov    %r14d,%ebx
mov    $0x1,%ebp
lea    0xe90(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
mov    (%r15,%rbp,8),%rsi
mov    %r12d,%edi
call   1050 <print_vec@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1170 <print_mat+0x40>
mov    $0x5d,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@str = [2 x i8] c",\00"
define void @print_mat(i32 %0, i32 %1, double** nocapture %2) {
%4 = tail call i32 @putchar(i32 91)
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = load double*, double** %2
%8 = tail call i32 @print_vec(i32 %1, double* %7)
%9 = icmp eq i32 %0, 1
br i1 %9, label %20, label %10
10: ; preds = %6
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 1, %10 ], [ %18, %12 ]
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%15 = getelementptr inbounds double*, double** %2, i64 %13
%16 = load double*, double** %15
%17 = tail call i32 @print_vec(i32 %1, double* %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12, %3, %6
%21 = tail call i32 @putchar(i32 93)
ret void
}