#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 */
scalar_t__ EOF;
int *malloc(int);
int maxDL(int *);
int maxDR(int *);
int maxLR(int *);
int maxUD(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ scanf(char *, int *);
int main(int argc, char **argv) {
  int array[20][20];
  int *tst = malloc(400 * sizeof(int));
  int n;
  int p = 0;
  while (EOF != scanf("%d", &n)) {
    tst[p] = n;
    p++;
  }
  puts("\n");
  for (int i = 0; i < 400; i++) {
    if (tst[i] == 0)
      printf("00 ");
    else if (tst[i] < 10)
      printf("0%i ", tst[i]);
    else
      printf("%i ", tst[i]);
    if ((i + 1) % 20 == 0)
      puts("");
  }
  printf("maxLR: %i\n", maxLR(tst));
  printf("maxUD: %i\n", maxUD(tst));
  printf("maxDR: %i\n", maxDR(tst));
  printf("maxDL: %i\n", maxDL(tst));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x670,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x640,%edi
call   1080 <malloc@plt>
mov    %rax,-0x658(%rbp)
movl   $0x0,-0x660(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x670(%rbp)
lea    0xe34(%rip),%rdi
lea    -0x65c(%rbp),%rsi
call   1090 <scanf@plt>
mov    %rax,%rcx
mov    -0x670(%rbp),%rax
cmp    %rcx,%rax
je     1216 <main+0x96>
mov    -0x65c(%rbp),%edx
mov    -0x658(%rbp),%rax
movslq -0x660(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x660(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x660(%rbp)
jmp    11b4 <main+0x34>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x664(%rbp)
cmpl   $0x190,-0x664(%rbp)
jge    1306 <main+0x186>
mov    -0x658(%rbp),%rax
movslq -0x664(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1267 <main+0xe7>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c7 <main+0x147>
mov    -0x658(%rbp),%rax
movslq -0x664(%rbp),%rcx
cmpl   $0xa,(%rax,%rcx,4)
jge    12a3 <main+0x123>
mov    -0x658(%rbp),%rax
movslq -0x664(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c2 <main+0x142>
mov    -0x658(%rbp),%rax
movslq -0x664(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c7 <main+0x147>
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12ed <main+0x16d>
lea    0xd39(%rip),%rdi
call   1030 <puts@plt>
jmp    12f2 <main+0x172>
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    122c <main+0xac>
mov    -0x658(%rbp),%rdi
call   1070 <maxLR@plt>
mov    %eax,%esi
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x658(%rbp),%rdi
call   10a0 <maxUD@plt>
mov    %eax,%esi
lea    0xce0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x658(%rbp),%rdi
call   1050 <maxDR@plt>
mov    %eax,%esi
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x658(%rbp),%rdi
call   1060 <maxDL@plt>
mov    %eax,%esi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x670,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x640,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    0x2e39(%rip),%r12
mov    (%r12),%rbp
lea    0xe46(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10a0 <scanf@plt>
cmp    %rax,%rbp
je     11ff <main+0x6f>
lea    0xe30(%rip),%r14
lea    0x4(%rsp),%r15
mov    %r13,%rbp
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
mov    %eax,0x0(%rbp)
mov    (%r12),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <scanf@plt>
add    $0x4,%rbp
cmp    %rax,%rbx
jne    11e0 <main+0x50>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r12w
lea    0xdec(%rip),%r14
xor    %ebx,%ebx
jmp    1230 <main+0xa0>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
mov    %rbp,%rbx
cmp    $0x190,%rbp
je     12a4 <main+0x114>
movzwl %r12w,%eax
imul   $0xcccd,%eax,%r15d
shr    $0x14,%r15d
mov    0x0(%r13,%rbx,4),%esi
test   %esi,%esi
je     1260 <main+0xd0>
cmp    $0x9,%esi
jg     1270 <main+0xe0>
lea    0xdb3(%rip),%rdi
jmp    1277 <main+0xe7>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    127e <main+0xee>
nopl   0x0(%rax)
lea    0xd91(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%r15,%r15,4),%eax
lea    -0x1(,%rax,4),%eax
movzwl %ax,%eax
lea    0x1(%rbx),%rbp
cmp    %bx,%ax
jne    1220 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1220 <main+0x90>
mov    %r13,%rdi
call   1080 <maxLR@plt>
lea    0xd59(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   10b0 <maxUD@plt>
lea    0xd4c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1060 <maxDR@plt>
lea    0xd3f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1070 <maxDL@plt>
lea    0xd32(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"00 \00"
@.str.3 = [5 x i8] c"0%i \00"
@.str.4 = [4 x i8] c"%i \00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [11 x i8] c"maxLR: %i\0A\00"
@.str.7 = [11 x i8] c"maxUD: %i\0A\00"
@.str.8 = [11 x i8] c"maxDR: %i\0A\00"
@.str.9 = [11 x i8] c"maxDL: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x [20 x i32]]
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @malloc(i32 1600)
store i32* %11, i32** %7
store i32 0, i32* %9
br label %12
12: ; preds = %16, %2
%13 = load i64, i64* @EOF
%14 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* %8
%18 = load i32*, i32** %7
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
store i32 %23, i32* %9
br label %12
24: ; preds = %12
%25 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %10
br label %26
26: ; preds = %68, %24
%27 = load i32, i32* %10
%28 = icmp slt i32 %27, 400
br i1 %28, label %29, label %71
29: ; preds = %26
%30 = load i32*, i32** %7
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %60
38: ; preds = %29
%39 = load i32*, i32** %7
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = icmp slt i32 %43, 10
br i1 %44, label %45, label %52
45: ; preds = %38
%46 = load i32*, i32** %7
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %50)
br label %59
52: ; preds = %38
%53 = load i32*, i32** %7
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %52, %45
br label %60
60: ; preds = %59, %36
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
%63 = srem i32 %62, 20
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
br label %67
67: ; preds = %65, %60
br label %68
68: ; preds = %67
%69 = load i32, i32* %10
%70 = add nsw i32 %69, 1
store i32 %70, i32* %10
br label %26
71: ; preds = %26
%72 = load i32*, i32** %7
%73 = call i32 @maxLR(i32* %72)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %73)
%75 = load i32*, i32** %7
%76 = call i32 @maxUD(i32* %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %76)
%78 = load i32*, i32** %7
%79 = call i32 @maxDR(i32* %78)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %79)
%81 = load i32*, i32** %7
%82 = call i32 @maxDL(i32* %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"00 \00"
@.str.3 = [5 x i8] c"0%i \00"
@.str.4 = [4 x i8] c"%i \00"
@.str.6 = [11 x i8] c"maxLR: %i\0A\00"
@.str.7 = [11 x i8] c"maxUD: %i\0A\00"
@.str.8 = [11 x i8] c"maxDR: %i\0A\00"
@.str.9 = [11 x i8] c"maxDL: %i\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32* @malloc(i32 1600)
%5 = bitcast i32* %3 to i8*
%6 = load i64, i64* @EOF
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = icmp eq i64 %6, %7
br i1 %8, label %17, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %13, %9 ], [ 0, %2 ]
%11 = load i32, i32* %3
%12 = getelementptr inbounds i32, i32* %4, i64 %10
store i32 %11, i32* %12
%13 = add nuw i64 %10, 1
%14 = load i64, i64* @EOF
%15 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %9
17: ; preds = %9, %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
19: ; preds = %48
%20 = call i32 @maxLR(i32* %4)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%22 = call i32 @maxUD(i32* %4)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%24 = call i32 @maxDR(i32* %4)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %24)
%26 = call i32 @maxDL(i32* %4)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %26)
ret i32 0
28: ; preds = %17, %48
%29 = phi i64 [ 0, %17 ], [ %42, %48 ]
%30 = getelementptr inbounds i32, i32* %4, i64 %29
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %41
35: ; preds = %28
%36 = icmp slt i32 %31, 10
br i1 %36, label %37, label %39
37: ; preds = %35
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %41
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %41
41: ; preds = %37, %39, %33
%42 = add nuw nsw i64 %29, 1
%43 = trunc i64 %42 to i16
%44 = urem i16 %43, 20
%45 = icmp eq i16 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = call i32 @putchar(i32 10)
br label %48
48: ; preds = %41, %46
%49 = icmp eq i64 %42, 400
br i1 %49, label %19, label %28
}