#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 longestIncreasingPath(int **, int, int);
void *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int n, m, i, j;
  n = m = 3;
  int **mat = malloc(n * sizeof(int *));
  for (i = 0; i < n; i++)
    mat[i] = malloc(m * sizeof(int));
  mat[0][0] = 3;
  mat[0][1] = 4;
  mat[0][2] = 5;
  mat[1][0] = 3;
  mat[1][1] = 2;
  mat[1][2] = 6;
  mat[2][0] = 2;
  mat[2][1] = 2;
  mat[2][2] = 1;
  printf("ans = %d\n", longestIncreasingPath(mat, n, m));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x3,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a6 <main+0x76>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116e <main+0x3e>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movl   $0x3,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movl   $0x5,0x8(%rax)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x3,(%rax)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x2,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x6,0x8(%rax)
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x2,(%rax)
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x2,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,0x8(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <longestIncreasingPath@plt>
mov    %eax,%esi
lea    0xdc1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rax,(%r14)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%r14)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,0x10(%r14)
movabs $0x400000003,%rcx
mov    %rcx,(%r15)
movl   $0x5,0x8(%r15)
movabs $0x200000003,%rcx
mov    %rcx,(%rbx)
movl   $0x6,0x8(%rbx)
movabs $0x200000002,%rcx
mov    %rcx,(%rax)
movl   $0x1,0x8(%rax)
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1050 <longestIncreasingPath@plt>
lea    0xe39(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"ans = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(24) i8* @malloc(i32 24)
%4 = bitcast i8* %3 to i32**
%5 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
%6 = bitcast i8* %3 to i8**
store i8* %5, i8** %6
%7 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
%8 = getelementptr inbounds i32*, i32** %4, i64 1
%9 = bitcast i32** %8 to i8**
store i8* %7, i8** %9
%10 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
%11 = getelementptr inbounds i32*, i32** %4, i64 2
%12 = bitcast i32** %11 to i8**
store i8* %10, i8** %12
%13 = bitcast i8* %5 to i32*
store i32 3, i32* %13
%14 = getelementptr inbounds i32, i32* %13, i64 1
store i32 4, i32* %14
%15 = getelementptr inbounds i32, i32* %13, i64 2
store i32 5, i32* %15
%16 = bitcast i8* %7 to i32*
store i32 3, i32* %16
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 2, i32* %17
%18 = getelementptr inbounds i32, i32* %16, i64 2
store i32 6, i32* %18
%19 = bitcast i8* %10 to i32*
store i32 2, i32* %19
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 2, i32* %20
%21 = getelementptr inbounds i32, i32* %19, i64 2
store i32 1, i32* %21
%22 = tail call i32 @longestIncreasingPath(i32** %4, i32 3, i32 3)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22)
ret i32 0
}