#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*/ parse_grid(int **);
int /*<<< orphan*/ printf(char *, float);
int prod(int **, int, int, int);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  int grid[20][20];
  parse_grid(grid);
  int high = 0;
  for (int y = 0, total = 0; y < 20; y++) {
    for (int x = 0; x < 20; x++) {
      if (y - 4 >= 0) {
        total = prod(grid, x, y, 1);
        if (total > high)
          high = total;
      }
      if (x + 4 < 20) {
        total = prod(grid, x, y, 2);
        if (total > high)
          high = total;
      }
      if (y + 4 < 20) {
        total = prod(grid, x, y, 3);
        if (total > high)
          high = total;
      }
      if (y + 4 < 20 && x + 4 < 20) {
        total = prod(grid, x, y, 4);
        if (total > high)
          high = total;
      }
      if (y - 4 >= 0 && x + 4 < 20) {
        total = prod(grid, x, y, 5);
        if (total > high)
          high = total;
      }
    }
  }
  float stop = timeit();
  printf("Answer: %d\n", high);
  printf("Time: %f\n", stop - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x680,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
lea    -0x660(%rbp),%rdi
call   1060 <parse_grid@plt>
movl   $0x0,-0x664(%rbp)
movl   $0x0,-0x668(%rbp)
movl   $0x0,-0x66c(%rbp)
cmpl   $0x14,-0x668(%rbp)
jge    13c1 <main+0x281>
movl   $0x0,-0x670(%rbp)
cmpl   $0x14,-0x670(%rbp)
jge    13a8 <main+0x268>
mov    -0x668(%rbp),%eax
sub    $0x4,%eax
cmp    $0x0,%eax
jl     120b <main+0xcb>
lea    -0x660(%rbp),%rdi
mov    -0x670(%rbp),%esi
mov    -0x668(%rbp),%edx
mov    $0x1,%ecx
call   1050 <prod@plt>
mov    %eax,-0x66c(%rbp)
mov    -0x66c(%rbp),%eax
cmp    -0x664(%rbp),%eax
jle    1206 <main+0xc6>
mov    -0x66c(%rbp),%eax
mov    %eax,-0x664(%rbp)
jmp    120b <main+0xcb>
mov    -0x670(%rbp),%eax
add    $0x4,%eax
cmp    $0x14,%eax
jge    1263 <main+0x123>
lea    -0x660(%rbp),%rdi
mov    -0x670(%rbp),%esi
mov    -0x668(%rbp),%edx
mov    $0x2,%ecx
call   1050 <prod@plt>
mov    %eax,-0x66c(%rbp)
mov    -0x66c(%rbp),%eax
cmp    -0x664(%rbp),%eax
jle    125e <main+0x11e>
mov    -0x66c(%rbp),%eax
mov    %eax,-0x664(%rbp)
jmp    1263 <main+0x123>
mov    -0x668(%rbp),%eax
add    $0x4,%eax
cmp    $0x14,%eax
jge    12bb <main+0x17b>
lea    -0x660(%rbp),%rdi
mov    -0x670(%rbp),%esi
mov    -0x668(%rbp),%edx
mov    $0x3,%ecx
call   1050 <prod@plt>
mov    %eax,-0x66c(%rbp)
mov    -0x66c(%rbp),%eax
cmp    -0x664(%rbp),%eax
jle    12b6 <main+0x176>
mov    -0x66c(%rbp),%eax
mov    %eax,-0x664(%rbp)
jmp    12bb <main+0x17b>
mov    -0x668(%rbp),%eax
add    $0x4,%eax
cmp    $0x14,%eax
jge    1325 <main+0x1e5>
mov    -0x670(%rbp),%eax
add    $0x4,%eax
cmp    $0x14,%eax
jge    1325 <main+0x1e5>
lea    -0x660(%rbp),%rdi
mov    -0x670(%rbp),%esi
mov    -0x668(%rbp),%edx
mov    $0x4,%ecx
call   1050 <prod@plt>
mov    %eax,-0x66c(%rbp)
mov    -0x66c(%rbp),%eax
cmp    -0x664(%rbp),%eax
jle    1320 <main+0x1e0>
mov    -0x66c(%rbp),%eax
mov    %eax,-0x664(%rbp)
jmp    1325 <main+0x1e5>
mov    -0x668(%rbp),%eax
sub    $0x4,%eax
cmp    $0x0,%eax
jl     138f <main+0x24f>
mov    -0x670(%rbp),%eax
add    $0x4,%eax
cmp    $0x14,%eax
jge    138f <main+0x24f>
lea    -0x660(%rbp),%rdi
mov    -0x670(%rbp),%esi
mov    -0x668(%rbp),%edx
mov    $0x5,%ecx
call   1050 <prod@plt>
mov    %eax,-0x66c(%rbp)
mov    -0x66c(%rbp),%eax
cmp    -0x664(%rbp),%eax
jle    138a <main+0x24a>
mov    -0x66c(%rbp),%eax
mov    %eax,-0x664(%rbp)
jmp    138f <main+0x24f>
jmp    1394 <main+0x254>
mov    -0x670(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x670(%rbp)
jmp    11a6 <main+0x66>
jmp    13ad <main+0x26d>
mov    -0x668(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x668(%rbp)
jmp    118f <main+0x4f>
mov    $0x0,%al
call   1040 <timeit@plt>
movss  %xmm0,-0x674(%rbp)
ff
cvtsi2ssl -0x664(%rbp),%xmm0
ff
lea    0xc21(%rip),%rdi
call   1030 <printf@plt>
movss  -0x674(%rbp),%xmm0
ff
subss  -0x14(%rbp),%xmm0
lea    0xc14(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x680,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x650,%rsp
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <timeit@plt>
movss  %xmm0,0xc(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1060 <parse_grid@plt>
xor    %r12d,%r12d
jmp    118e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    $0x14,%r15d
je     129c <main+0x15c>
xor    %ebp,%ebp
jmp    11ab <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%r12d
add    $0x1,%ebp
cmp    $0x14,%ebp
je     1180 <main+0x40>
cmp    $0x4,%r15d
jb     11ce <main+0x8e>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1050 <prod@plt>
cmp    %r12d,%eax
jg     11cb <main+0x8b>
mov    %r12d,%eax
mov    %eax,%r12d
cmp    $0xf,%ebp
ja     1270 <main+0x130>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    $0x2,%ecx
call   1050 <prod@plt>
mov    %eax,%ebx
cmp    %r12d,%eax
jg     11f3 <main+0xb3>
mov    %r12d,%ebx
cmp    $0x10,%r15d
jae    1231 <main+0xf1>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    $0x3,%ecx
call   1050 <prod@plt>
mov    %eax,%r12d
cmp    %ebx,%eax
jg     1215 <main+0xd5>
mov    %ebx,%r12d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    $0x4,%ecx
call   1050 <prod@plt>
mov    %eax,%ebx
cmp    %r12d,%eax
jg     1231 <main+0xf1>
mov    %r12d,%ebx
cmp    $0x4,%r15d
jb     11a0 <main+0x60>
cmp    $0xf,%ebp
ja     11a0 <main+0x60>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    $0x5,%ecx
call   1050 <prod@plt>
mov    %eax,%r12d
cmp    %ebx,%eax
jle    11a0 <main+0x60>
jmp    11a3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
cmp    $0xf,%r15d
ja     11a3 <main+0x63>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    $0x3,%ecx
call   1050 <prod@plt>
cmp    %r12d,%eax
jg     1294 <main+0x154>
mov    %r12d,%eax
mov    %eax,%r12d
jmp    11a3 <main+0x63>
xor    %eax,%eax
call   1040 <timeit@plt>
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %r12d,%xmm0
lea    0xd48(%rip),%rdi
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
lea    0xd3c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x650,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Answer: %d\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca [20 x [20 x i32]]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call float (...) @timeit()
store float %13, float* %6
%14 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %7, i64 0, i64 0
%15 = bitcast [20 x i32]* %14 to i32**
%16 = call i32 @parse_grid(i32** %15)
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %17
17: ; preds = %117, %2
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 20
br i1 %19, label %20, label %120
20: ; preds = %17
store i32 0, i32* %11
br label %21
21: ; preds = %113, %20
%22 = load i32, i32* %11
%23 = icmp slt i32 %22, 20
br i1 %23, label %24, label %116
24: ; preds = %21
%25 = load i32, i32* %9
%26 = sub nsw i32 %25, 4
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %24
%29 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %7, i64 0, i64 0
%30 = bitcast [20 x i32]* %29 to i32**
%31 = load i32, i32* %11
%32 = load i32, i32* %9
%33 = call i32 @prod(i32** %30, i32 %31, i32 %32, i32 1)
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = load i32, i32* %8
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = load i32, i32* %10
store i32 %38, i32* %8
br label %39
39: ; preds = %37, %28
br label %40
40: ; preds = %39, %24
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 4
%43 = icmp slt i32 %42, 20
br i1 %43, label %44, label %56
44: ; preds = %40
%45 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %7, i64 0, i64 0
%46 = bitcast [20 x i32]* %45 to i32**
%47 = load i32, i32* %11
%48 = load i32, i32* %9
%49 = call i32 @prod(i32** %46, i32 %47, i32 %48, i32 2)
store i32 %49, i32* %10
%50 = load i32, i32* %10
%51 = load i32, i32* %8
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %44
%54 = load i32, i32* %10
store i32 %54, i32* %8
br label %55
55: ; preds = %53, %44
br label %56
56: ; preds = %55, %40
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 4
%59 = icmp slt i32 %58, 20
br i1 %59, label %60, label %72
60: ; preds = %56
%61 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %7, i64 0, i64 0
%62 = bitcast [20 x i32]* %61 to i32**
%63 = load i32, i32* %11
%64 = load i32, i32* %9
%65 = call i32 @prod(i32** %62, i32 %63, i32 %64, i32 3)
store i32 %65, i32* %10
%66 = load i32, i32* %10
%67 = load i32, i32* %8
%68 = icmp sgt i32 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %60
%70 = load i32, i32* %10
store i32 %70, i32* %8
br label %71
71: ; preds = %69, %60
br label %72
72: ; preds = %71, %56
%73 = load i32, i32* %9
%74 = add nsw i32 %73, 4
%75 = icmp slt i32 %74, 20
br i1 %75, label %76, label %92
76: ; preds = %72
%77 = load i32, i32* %11
%78 = add nsw i32 %77, 4
%79 = icmp slt i32 %78, 20
br i1 %79, label %80, label %92
80: ; preds = %76
%81 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %7, i64 0, i64 0
%82 = bitcast [20 x i32]* %81 to i32**
%83 = load i32, i32* %11
%84 = load i32, i32* %9
%85 = call i32 @prod(i32** %82, i32 %83, i32 %84, i32 4)
store i32 %85, i32* %10
%86 = load i32, i32* %10
%87 = load i32, i32* %8
%88 = icmp sgt i32 %86, %87
br i1 %88, label %89, label %91
89: ; preds = %80
%90 = load i32, i32* %10
store i32 %90, i32* %8
br label %91
91: ; preds = %89, %80
br label %92
92: ; preds = %91, %76, %72
%93 = load i32, i32* %9
%94 = sub nsw i32 %93, 4
%95 = icmp sge i32 %94, 0
br i1 %95, label %96, label %112
96: ; preds = %92
%97 = load i32, i32* %11
%98 = add nsw i32 %97, 4
%99 = icmp slt i32 %98, 20
br i1 %99, label %100, label %112
100: ; preds = %96
%101 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %7, i64 0, i64 0
%102 = bitcast [20 x i32]* %101 to i32**
%103 = load i32, i32* %11
%104 = load i32, i32* %9
%105 = call i32 @prod(i32** %102, i32 %103, i32 %104, i32 5)
store i32 %105, i32* %10
%106 = load i32, i32* %10
%107 = load i32, i32* %8
%108 = icmp sgt i32 %106, %107
br i1 %108, label %109, label %111
109: ; preds = %100
%110 = load i32, i32* %10
store i32 %110, i32* %8
br label %111
111: ; preds = %109, %100
br label %112
112: ; preds = %111, %96, %92
br label %113
113: ; preds = %112
%114 = load i32, i32* %11
%115 = add nsw i32 %114, 1
store i32 %115, i32* %11
br label %21
116: ; preds = %21
br label %117
117: ; preds = %116
%118 = load i32, i32* %9
%119 = add nsw i32 %118, 1
store i32 %119, i32* %9
br label %17
120: ; preds = %17
%121 = call float (...) @timeit()
store float %121, float* %12
%122 = load i32, i32* %8
%123 = sitofp i32 %122 to float
%124 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %123)
%125 = load float, float* %12
%126 = load float, float* %6
%127 = fsub float %125, %126
%128 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %127)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Answer: %d\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x [20 x i32]]
%4 = tail call float (...) @timeit()
%5 = bitcast [20 x [20 x i32]]* %3 to i8*
%6 = bitcast [20 x [20 x i32]]* %3 to i32**
%7 = call i32 @parse_grid(i32** %6)
br label %8
8: ; preds = %2, %19
%9 = phi i32 [ 0, %2 ], [ %20, %19 ]
%10 = phi i32 [ 0, %2 ], [ %56, %19 ]
%11 = icmp ugt i32 %9, 3
%12 = icmp ult i32 %9, 16
br label %22
13: ; preds = %19
%14 = call float (...) @timeit()
%15 = sitofp i32 %56 to float
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), float %15)
%17 = fsub float %14, %4
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %17)
ret i32 0
19: ; preds = %55
%20 = add nuw nsw i32 %9, 1
%21 = icmp eq i32 %20, 20
br i1 %21, label %13, label %8
22: ; preds = %8, %55
%23 = phi i32 [ 0, %8 ], [ %57, %55 ]
%24 = phi i32 [ %10, %8 ], [ %56, %55 ]
br i1 %11, label %25, label %29
25: ; preds = %22
%26 = call i32 @prod(i32** %6, i32 %23, i32 %9, i32 1)
%27 = icmp sgt i32 %26, %24
%28 = select i1 %27, i32 %26, i32 %24
br label %29
29: ; preds = %25, %22
%30 = phi i32 [ %24, %22 ], [ %28, %25 ]
%31 = icmp ult i32 %23, 16
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = call i32 @prod(i32** %6, i32 %23, i32 %9, i32 2)
%34 = icmp sgt i32 %33, %30
%35 = select i1 %34, i32 %33, i32 %30
br i1 %12, label %41, label %48
36: ; preds = %29
br i1 %12, label %37, label %55
37: ; preds = %36
%38 = call i32 @prod(i32** %6, i32 %23, i32 %9, i32 3)
%39 = icmp sgt i32 %38, %30
%40 = select i1 %39, i32 %38, i32 %30
br label %55
41: ; preds = %32
%42 = call i32 @prod(i32** %6, i32 %23, i32 %9, i32 3)
%43 = icmp sgt i32 %42, %35
%44 = select i1 %43, i32 %42, i32 %35
%45 = call i32 @prod(i32** %6, i32 %23, i32 %9, i32 4)
%46 = icmp sgt i32 %45, %44
%47 = select i1 %46, i32 %45, i32 %44
br label %48
48: ; preds = %32, %41
%49 = phi i32 [ %47, %41 ], [ %35, %32 ]
%50 = select i1 %11, i1 %31, i1 false
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = call i32 @prod(i32** %6, i32 %23, i32 %9, i32 5)
%53 = icmp sgt i32 %52, %49
%54 = select i1 %53, i32 %52, i32 %49
br label %55
55: ; preds = %36, %37, %51, %48
%56 = phi i32 [ %49, %48 ], [ %54, %51 ], [ %40, %37 ], [ %30, %36 ]
%57 = add nuw nsw i32 %23, 1
%58 = icmp eq i32 %57, 20
br i1 %58, label %19, label %22
}