#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(int **mat, int row, int col) {
  printf("mat[%d][%d] = {\n", row, col);
  for (int i = 0; i < row; i++) {
    printf("{");
    for (int j = 0; j < col; j++) {
      if (j < col - 1)
        printf("%2d, ", mat[i][j]);
      else
        printf("%2d", mat[i][j]);
    }
    if (i < row - 1)
      printf("},\n");
    else
      printf("} ");
  }
  printf("}\n\n");
}


x86 assembly (clang, -O0):
<printMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121a <printMat+0x10a>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d5 <printMat+0xc5>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a1 <printMat+0x91>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <printMat+0xb2>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printMat+0xb7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <printMat+0x4e>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f9 <printMat+0xe9>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1207 <printMat+0xf7>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <printMat+0xfc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <printMat+0x2d>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    %esi,%r15d
mov    %rdi,%rbp
lea    0xeb5(%rip),%rdi
mov    %rdx,(%rsp)
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
jle    11fc <printMat+0xcc>
mov    (%rsp),%rcx
lea    -0x1(%rcx),%eax
lea    -0x1(%r15),%edx
mov    %rdx,0x10(%rsp)
movslq %eax,%r12
mov    %r15d,%eax
mov    %rax,0x8(%rsp)
mov    %ecx,%r15d
lea    0xe8d(%rip),%r13
xor    %ebx,%ebx
jmp    11a9 <printMat+0x79>
nopl   0x0(%rax,%rax,1)
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
je     11fc <printMat+0xcc>
mov    $0x7b,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%rsp)
jle    11e7 <printMat+0xb7>
xor    %r14d,%r14d
nopl   0x0(%rax)
cmp    %r12,%r14
mov    0x0(%rbp,%rbx,8),%rax
mov    (%rax,%r14,4),%esi
lea    0xe44(%rip),%rdi
cmovl  %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r15
jne    11c0 <printMat+0x90>
cmp    0x10(%rsp),%rbx
jae    1190 <printMat+0x60>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
jmp    119e <printMat+0x6e>
lea    0xe1b(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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