#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 dp(int **, int, int, int, int, int *);
int *malloc(int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int minPathSum(int **grid, int gridRowSize, int gridColSize) {
  int *dp_grid = malloc(sizeof(int) * gridRowSize * gridColSize);
  memset(dp_grid, 0, sizeof(int) * gridRowSize * gridColSize);
  return dp(grid, gridRowSize, gridColSize, gridColSize - 1, gridRowSize - 1,
            dp_grid);
}


x86 assembly (clang, -O0):
<minPathSum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
movslq -0x10(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
movslq -0x10(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    -0xc(%rbp),%r8d
sub    $0x1,%r8d
mov    -0x18(%rbp),%r9
call   1050 <dp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minPathSum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%r15
mov    %esi,%ebp
imul   %edx,%ebp
shl    $0x2,%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
lea    -0x1(%r14),%ecx
lea    -0x1(%rbx),%r8d
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r12,%r9
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <dp@plt>

LLVM IR (-O0):
define i32 @minPathSum(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32** %0, i32*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = mul i64 4, %9
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = mul i64 %10, %12
%14 = trunc i64 %13 to i32
%15 = call i32* @malloc(i32 %14)
store i32* %15, i32** %7
%16 = load i32*, i32** %7
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = mul i64 %19, %21
%23 = trunc i64 %22 to i32
%24 = call i32 @memset(i32* %16, i32 0, i32 %23)
%25 = load i32**, i32*** %4
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = load i32, i32* %6
%29 = sub nsw i32 %28, 1
%30 = load i32, i32* %5
%31 = sub nsw i32 %30, 1
%32 = load i32*, i32** %7
%33 = call i32 @dp(i32** %25, i32 %26, i32 %27, i32 %29, i32 %31, i32* %32)
ret i32 %33
}

LLVM IR (-O2):
define i32 @minPathSum(i32** %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 2
%5 = mul i32 %4, %2
%6 = tail call i32* @malloc(i32 %5)
%7 = tail call i32 @memset(i32* %6, i32 0, i32 %5)
%8 = add nsw i32 %2, -1
%9 = add nsw i32 %1, -1
%10 = tail call i32 @dp(i32** %0, i32 %1, i32 %2, i32 %8, i32 %9, i32* %6)
ret i32 %10
}