#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 dump_psimatrix(int **m, int dim) {
  int row, col;
  printf("{");
  for (row = 0; row < (dim - 1); row++) {
    printf("{");
    for (col = 0; col < (dim - 1); col++) {
      printf("%i,", m[row][col]);
    }
    printf("%i},\n", m[row][dim - 1]);
  }
  printf("{");
  for (col = 0; col < (dim - 1); col++) {
    printf("%i,", m[dim - 1][col]);
  }
  printf("%i}}", m[dim - 1][dim - 1]);
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_psimatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ce <dump_psimatrix+0xbe>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    119a <dump_psimatrix+0x8a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <dump_psimatrix+0x4a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <dump_psimatrix+0x24>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1228 <dump_psimatrix+0x118>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e3 <dump_psimatrix+0xd3>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_psimatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r13
mov    $0x7b,%edi
call   1030 <putchar@plt>
lea    -0x1(%rbx),%ebp
cmp    $0x1,%ebx
jle    11fd <dump_psimatrix+0xdd>
mov    %rbx,0x10(%rsp)
mov    %ebp,0xc(%rsp)
mov    %ebp,%ebx
lea    0xea5(%rip),%r15
lea    0xea2(%rip),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x7b,%edi
call   1030 <putchar@plt>
xor    %r14d,%r14d
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%r14,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1180 <dump_psimatrix+0x60>
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
jne    1170 <dump_psimatrix+0x50>
mov    $0x7b,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x10(%rsp)
mov    0xc(%rsp),%ebp
jle    1207 <dump_psimatrix+0xe7>
lea    0xe2d(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11e0 <dump_psimatrix+0xc0>
jmp    120a <dump_psimatrix+0xea>
mov    $0x7b,%edi
call   1030 <putchar@plt>
movslq %ebp,%rbx
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%rbx,4),%esi
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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