#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 */
struct Point {
  int dummy;
};
struct Path {
  int dummy;
};
struct Cache {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ addPointToPath(struct Point *, struct Path **);
int /*<<< orphan*/ cachePathToPoint(struct Cache **, struct Point *, int);
struct Point *createNewPoint(int, int);
int getIsPointReachableFromCache(struct Cache **, struct Point *);
scalar_t__ isPathToPointCached(struct Cache **, struct Point *);
bool getPath(int rows, int cols, bool maze[rows][cols], int rowIndex,
             int colIndex, struct Path **path, struct Cache *cache[]) {
  if (rowIndex < 0 || colIndex < 0 || !maze[rowIndex][colIndex]) {
    return false;
  }
  struct Point *point = createNewPoint(rowIndex, colIndex);
  if (isPathToPointCached(cache, point)) {
    return getIsPointReachableFromCache(cache, point);
  }
  bool isAtOrigin = (rowIndex == 0) && (colIndex == 0);
  bool isPathReachable = false;
  if (isAtOrigin ||
      getPath(rows, cols, maze, rowIndex - 1, colIndex, path, cache) ||
      getPath(rows, cols, maze, rowIndex, colIndex - 1, path, cache)) {
    addPointToPath(point, path);
    isPathReachable = true;
  }
  cachePathToPoint(cache, point, isPathReachable);
  return isPathReachable;
}


x86 assembly (clang, -O0):
<getPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11c1 <getPath+0x61>
cmpl   $0x0,-0x20(%rbp)
jl     11c1 <getPath+0x61>
mov    -0x40(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11cd <getPath+0x6d>
movl   $0x0,-0x4(%rbp)
jmp    12c4 <getPath+0x164>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1080 <createNewPoint@plt>
mov    %rax,-0x30(%rbp)
mov    0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <isPathToPointCached@plt>
cmp    $0x0,%rax
je     1208 <getPath+0xa8>
mov    0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <getIsPointReachableFromCache@plt>
mov    %eax,-0x4(%rbp)
jmp    12c4 <getPath+0x164>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x41(%rbp)
jne    1221 <getPath+0xc1>
cmpl   $0x0,-0x20(%rbp)
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    129a <getPath+0x13a>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1070 <getPath@plt>
cmp    $0x0,%eax
jne    129a <getPath+0x13a>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
sub    $0x1,%r8d
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1070 <getPath@plt>
cmp    $0x0,%eax
je     12ae <getPath+0x14e>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <addPointToPath@plt>
movl   $0x1,-0x38(%rbp)
mov    0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1050 <cachePathToPoint@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %r15d,%r15d
mov    %r8d,%ebp
or     %ecx,%ebp
js     1267 <getPath+0x107>
mov    %r8d,%r12d
mov    %ecx,%ebx
mov    %esi,%r14d
mov    %esi,%eax
movslq %ecx,%rcx
imul   %rax,%rcx
lea    (%rdx,%rcx,4),%rax
movslq %r8d,%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1267 <getPath+0x107>
mov    %edi,0xc(%rsp)
mov    %rdx,0x18(%rsp)
mov    %r9,0x20(%rsp)
mov    0x60(%rsp),%r15
mov    %ebx,%edi
mov    %r12d,%esi
call   1080 <createNewPoint@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <isPathToPointCached@plt>
test   %rax,%rax
je     11e7 <getPath+0x87>
mov    %r15,%rdi
mov    %r13,%rsi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <getIsPointReachableFromCache@plt>
mov    %r15,0x10(%rsp)
test   %ebp,%ebp
mov    0x20(%rsp),%rbp
je     1246 <getPath+0xe6>
lea    -0x1(%rbx),%ecx
mov    0x10(%rsp),%rax
mov    %rax,(%rsp)
mov    0xc(%rsp),%edi
mov    %r14d,%esi
mov    0x18(%rsp),%rdx
mov    %r12d,%r8d
mov    %rbp,%r9
call   1070 <getPath@plt>
test   %eax,%eax
jne    1246 <getPath+0xe6>
add    $0xffffffff,%r12d
mov    0x10(%rsp),%rax
mov    %rax,(%rsp)
mov    0xc(%rsp),%edi
mov    %r14d,%esi
mov    0x18(%rsp),%rdx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    %rbp,%r9
call   1070 <getPath@plt>
test   %eax,%eax
je     1279 <getPath+0x119>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1030 <addPointToPath@plt>
mov    $0x1,%r15d
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1050 <cachePathToPoint@plt>
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
jmp    1257 <getPath+0xf7>

LLVM IR (-O0):
%struct.Path = type { i32 }
%struct.Cache = type { i32 }
%struct.Point = type { i32 }
define i32 @getPath(i32 %0, i32 %1, i32* %2, i32 %3, i32 %4, %struct.Path** %5, %struct.Cache** %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.Path**
%15 = alloca %struct.Cache**
%16 = alloca %struct.Point*
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32* %2, i32** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store %struct.Path** %5, %struct.Path*** %14
store %struct.Cache** %6, %struct.Cache*** %15
%19 = load i32, i32* %9
%20 = zext i32 %19 to i64
%21 = load i32, i32* %10
%22 = zext i32 %21 to i64
%23 = load i32, i32* %12
%24 = icmp slt i32 %23, 0
br i1 %24, label %39, label %25
25: ; preds = %7
%26 = load i32, i32* %13
%27 = icmp slt i32 %26, 0
br i1 %27, label %39, label %28
28: ; preds = %25
%29 = load i32*, i32** %11
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = mul nsw i64 %31, %22
%33 = getelementptr inbounds i32, i32* %29, i64 %32
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = load i32, i32* %36
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %28, %25, %7
store i32 0, i32* %8
br label %95
40: ; preds = %28
%41 = load i32, i32* %12
%42 = load i32, i32* %13
%43 = call %struct.Point* @createNewPoint(i32 %41, i32 %42)
store %struct.Point* %43, %struct.Point** %16
%44 = load %struct.Cache**, %struct.Cache*** %15
%45 = load %struct.Point*, %struct.Point** %16
%46 = call i64 @isPathToPointCached(%struct.Cache** %44, %struct.Point* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %40
%49 = load %struct.Cache**, %struct.Cache*** %15
%50 = load %struct.Point*, %struct.Point** %16
%51 = call i32 @getIsPointReachableFromCache(%struct.Cache** %49, %struct.Point* %50)
store i32 %51, i32* %8
br label %95
52: ; preds = %40
%53 = load i32, i32* %12
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* %13
%57 = icmp eq i32 %56, 0
br label %58
58: ; preds = %55, %52
%59 = phi i1 [ false, %52 ], [ %57, %55 ]
%60 = zext i1 %59 to i32
store i32 %60, i32* %17
store i32 0, i32* %18
%61 = load i32, i32* %17
%62 = icmp ne i32 %61, 0
br i1 %62, label %85, label %63
63: ; preds = %58
%64 = load i32, i32* %9
%65 = load i32, i32* %10
%66 = load i32*, i32** %11
%67 = load i32, i32* %12
%68 = sub nsw i32 %67, 1
%69 = load i32, i32* %13
%70 = load %struct.Path**, %struct.Path*** %14
%71 = load %struct.Cache**, %struct.Cache*** %15
%72 = call i32 @getPath(i32 %64, i32 %65, i32* %66, i32 %68, i32 %69, %struct.Path** %70, %struct.Cache** %71)
%73 = icmp ne i32 %72, 0
br i1 %73, label %85, label %74
74: ; preds = %63
%75 = load i32, i32* %9
%76 = load i32, i32* %10
%77 = load i32*, i32** %11
%78 = load i32, i32* %12
%79 = load i32, i32* %13
%80 = sub nsw i32 %79, 1
%81 = load %struct.Path**, %struct.Path*** %14
%82 = load %struct.Cache**, %struct.Cache*** %15
%83 = call i32 @getPath(i32 %75, i32 %76, i32* %77, i32 %78, i32 %80, %struct.Path** %81, %struct.Cache** %82)
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %74, %63, %58
%86 = load %struct.Point*, %struct.Point** %16
%87 = load %struct.Path**, %struct.Path*** %14
%88 = call i32 @addPointToPath(%struct.Point* %86, %struct.Path** %87)
store i32 1, i32* %18
br label %89
89: ; preds = %85, %74
%90 = load %struct.Cache**, %struct.Cache*** %15
%91 = load %struct.Point*, %struct.Point** %16
%92 = load i32, i32* %18
%93 = call i32 @cachePathToPoint(%struct.Cache** %90, %struct.Point* %91, i32 %92)
%94 = load i32, i32* %18
store i32 %94, i32* %8
br label %95
95: ; preds = %89, %48, %39
%96 = load i32, i32* %8
ret i32 %96
}

LLVM IR (-O2):
%struct.Path = type { i32 }
%struct.Cache = type { i32 }
%struct.Point = type { i32 }
define i32 @getPath(i32 %0, i32 %1, i32* %2, i32 %3, i32 %4, %struct.Path** %5, %struct.Cache** %6) {
%8 = or i32 %4, %3
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %40
10: ; preds = %7
%11 = zext i32 %1 to i64
%12 = sext i32 %3 to i64
%13 = mul nsw i64 %12, %11
%14 = getelementptr inbounds i32, i32* %2, i64 %13
%15 = sext i32 %4 to i64
%16 = getelementptr inbounds i32, i32* %14, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %40, label %19
19: ; preds = %10
%20 = tail call %struct.Point* @createNewPoint(i32 %3, i32 %4)
%21 = tail call i64 @isPathToPointCached(%struct.Cache** %6, %struct.Point* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @getIsPointReachableFromCache(%struct.Cache** %6, %struct.Point* %20)
br label %40
25: ; preds = %19
%26 = icmp eq i32 %8, 0
br i1 %26, label %35, label %27
27: ; preds = %25
%28 = add nsw i32 %3, -1
%29 = tail call i32 @getPath(i32 %0, i32 %1, i32* %2, i32 %28, i32 %4, %struct.Path** %5, %struct.Cache** %6)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = add nsw i32 %4, -1
%33 = tail call i32 @getPath(i32 %0, i32 %1, i32* %2, i32 %3, i32 %32, %struct.Path** %5, %struct.Cache** %6)
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31, %27, %25
%36 = tail call i32 @addPointToPath(%struct.Point* %20, %struct.Path** %5)
br label %37
37: ; preds = %35, %31
%38 = phi i32 [ 1, %35 ], [ 0, %31 ]
%39 = tail call i32 @cachePathToPoint(%struct.Cache** %6, %struct.Point* %20, i32 %38)
br label %40
40: ; preds = %23, %37, %7, %10
%41 = phi i32 [ 0, %10 ], [ 0, %7 ], [ %24, %23 ], [ %38, %37 ]
ret i32 %41
}