#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*/ maxDirectionalProduct(long ***, long *, int, int);
long maxProduct(long ***gridptr) {
  long **grid = *(gridptr);
  long max = 0;
  for (int y = 0; y < 20; y++) {
    for (int x = 0; x < 20; x++) {
      maxDirectionalProduct(gridptr, &max, x, y);
    }
  }
  return max;
}


x86 assembly (clang, -O0):
<maxProduct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    1185 <maxProduct+0x75>
movl   $0x0,-0x20(%rbp)
cmpl   $0x14,-0x20(%rbp)
jge    1172 <maxProduct+0x62>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    -0x18(%rbp),%rsi
call   1030 <maxDirectionalProduct@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1147 <maxProduct+0x37>
jmp    1177 <maxProduct+0x67>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1136 <maxProduct+0x26>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxProduct>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
xor    %ebp,%ebp
lea    0x8(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xb,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xd,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xe,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xf,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x11,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x12,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x13,%edx
mov    %ebp,%ecx
call   1030 <maxDirectionalProduct@plt>
add    $0x1,%ebp
cmp    $0x14,%ebp
jne    1130 <maxProduct+0x20>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @maxProduct(i64*** %0) {
%2 = alloca i64***
%3 = alloca i64**
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i64*** %0, i64**** %2
%7 = load i64***, i64**** %2
%8 = load i64**, i64*** %7
store i64** %8, i64*** %3
store i64 0, i64* %4
store i32 0, i32* %5
br label %9
9: ; preds = %25, %1
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %28
12: ; preds = %9
store i32 0, i32* %6
br label %13
13: ; preds = %21, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 20
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i64***, i64**** %2
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = call i32 @maxDirectionalProduct(i64*** %17, i64* %4, i32 %18, i32 %19)
br label %21
21: ; preds = %16
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %13
24: ; preds = %13
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %9
28: ; preds = %9
%29 = load i64, i64* %4
ret i64 %29
}

LLVM IR (-O2):
define i64 @maxProduct(i64*** %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
store i64 0, i64* %2
br label %4
4: ; preds = %1, %4
%5 = phi i32 [ 0, %1 ], [ %26, %4 ]
%6 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 0, i32 %5)
%7 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 1, i32 %5)
%8 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 2, i32 %5)
%9 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 3, i32 %5)
%10 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 4, i32 %5)
%11 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 5, i32 %5)
%12 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 6, i32 %5)
%13 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 7, i32 %5)
%14 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 8, i32 %5)
%15 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 9, i32 %5)
%16 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 10, i32 %5)
%17 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 11, i32 %5)
%18 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 12, i32 %5)
%19 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 13, i32 %5)
%20 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 14, i32 %5)
%21 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 15, i32 %5)
%22 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 16, i32 %5)
%23 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 17, i32 %5)
%24 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 18, i32 %5)
%25 = call i32 @maxDirectionalProduct(i64*** %0, i64* %2, i32 19, i32 %5)
%26 = add nuw nsw i32 %5, 1
%27 = icmp eq i32 %26, 20
br i1 %27, label %28, label %4
28: ; preds = %4
%29 = load i64, i64* %2
ret i64 %29
}