#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 *, int);
int triangle_path(int **, int **, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char const *argv[]) {
  int case1[5][5] = {{6, -1, -1, -1, -1},
                     {1, 2, -1, -1, -1},
                     {3, 7, 4, -1, -1},
                     {9, 4, 1, 7, -1},
                     {2, 7, 5, 9, 4}};
  int case2[5][5] = {{1, -1, -1, -1, -1},
                     {2, 4, -1, -1, -1},
                     {8, 16, 8, -1, -1},
                     {32, 64, 32, 64, -1},
                     {128, 256, 128, 256, 128}};
  int cache1[5][5] = {{0}, {0}, {0}, {0}, {0}};
  int cache2[5][5] = {{0}, {0}, {0}, {0}, {0}};
  printf("%d\n", triangle_path(case1, cache1, 0, 0));
  printf("%d\n", triangle_path(case2, cache2, 0, 0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0xf0(%rbp),%rdi
lea    0xef4(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0x160(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x1d0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
lea    -0x160(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <triangle_path@plt>
mov    %eax,%esi
lea    0xf0b(%rip),%rdi
call   1040 <printf@plt>
lea    -0xf0(%rbp),%rdi
lea    -0x1d0(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <triangle_path@plt>
mov    %eax,%esi
lea    0xee6(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1c0,%rsp
mov    0xf32(%rip),%eax
mov    %eax,0x1b0(%rsp)
movaps 0xf14(%rip),%xmm0
movaps %xmm0,0x1a0(%rsp)
movaps 0xef5(%rip),%xmm0
movaps %xmm0,0x190(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x180(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x170(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x160(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
mov    0xf3b(%rip),%eax
mov    %eax,0x140(%rsp)
movaps 0xf1d(%rip),%xmm0
movaps %xmm0,0x130(%rsp)
movaps 0xefe(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xedf(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xea1(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0x150(%rsp),%rdi
lea    0x70(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <triangle_path@plt>
lea    0xe61(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xe0(%rsp),%rdi
mov    %rsp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <triangle_path@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.case1 = [5 x [5 x i32]] [[5 x i32] [i32 6, i32 -1, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 1, i32 2, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 3, i32 7, i32 4, i32 -1, i32 -1], [5 x i32] [i32 9, i32 4, i32 1, i32 7, i32 -1], [5 x i32] [i32 2, i32 7, i32 5, i32 9, i32 4]]
@__const.main.case2 = [5 x [5 x i32]] [[5 x i32] [i32 1, i32 -1, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 2, i32 4, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 8, i32 16, i32 8, i32 -1, i32 -1], [5 x i32] [i32 32, i32 64, i32 32, i32 64, i32 -1], [5 x i32] [i32 128, i32 256, i32 128, i32 256, i32 128]]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x [5 x i32]]
%7 = alloca [5 x [5 x i32]]
%8 = alloca [5 x [5 x i32]]
%9 = alloca [5 x [5 x i32]]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [5 x [5 x i32]]* %6 to i8*
%11 = bitcast [5 x [5 x i32]]* %7 to i8*
%12 = bitcast [5 x [5 x i32]]* %8 to i8*
%13 = bitcast [5 x [5 x i32]]* %9 to i8*
%14 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %6, i64 0, i64 0
%15 = bitcast [5 x i32]* %14 to i32**
%16 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %8, i64 0, i64 0
%17 = bitcast [5 x i32]* %16 to i32**
%18 = call i32 @triangle_path(i32** %15, i32** %17, i32 0, i32 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %7, i64 0, i64 0
%21 = bitcast [5 x i32]* %20 to i32**
%22 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %9, i64 0, i64 0
%23 = bitcast [5 x i32]* %22 to i32**
%24 = call i32 @triangle_path(i32** %21, i32** %23, i32 0, i32 0)
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.case1 = [5 x [5 x i32]] [[5 x i32] [i32 6, i32 -1, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 1, i32 2, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 3, i32 7, i32 4, i32 -1, i32 -1], [5 x i32] [i32 9, i32 4, i32 1, i32 7, i32 -1], [5 x i32] [i32 2, i32 7, i32 5, i32 9, i32 4]]
@__const.main.case2 = [5 x [5 x i32]] [[5 x i32] [i32 1, i32 -1, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 2, i32 4, i32 -1, i32 -1, i32 -1], [5 x i32] [i32 8, i32 16, i32 8, i32 -1, i32 -1], [5 x i32] [i32 32, i32 64, i32 32, i32 64, i32 -1], [5 x i32] [i32 128, i32 256, i32 128, i32 256, i32 128]]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x [5 x i32]]
%4 = alloca [5 x [5 x i32]]
%5 = alloca [5 x [5 x i32]]
%6 = alloca [5 x [5 x i32]]
%7 = bitcast [5 x [5 x i32]]* %3 to i8*
%8 = bitcast [5 x [5 x i32]]* %4 to i8*
%9 = bitcast [5 x [5 x i32]]* %5 to i8*
%10 = bitcast [5 x [5 x i32]]* %6 to i8*
%11 = bitcast [5 x [5 x i32]]* %3 to i32**
%12 = bitcast [5 x [5 x i32]]* %5 to i32**
%13 = call i32 @triangle_path(i32** %11, i32** %12, i32 0, i32 0)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = bitcast [5 x [5 x i32]]* %4 to i32**
%16 = bitcast [5 x [5 x i32]]* %6 to i32**
%17 = call i32 @triangle_path(i32** %15, i32** %16, i32 0, i32 0)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
ret i32 0
}