#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
scalar_t__ min_child(int **, int, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  FILE *fd = fopen("../res/081.data", "r");
  int matrix[80][80];
  int i, j;
  for (i = 0; i < 80; ++i) {
    for (j = 0; j < 80; ++j) {
      if (fscanf(fd, "%d,", &matrix[i][j]) == EOF)
        return 1;
    }
  }
  fclose(fd);
  for (i = 80 - 1; i >= 0; --i) {
    for (j = 80 - 1; j >= 0; --j) {
      matrix[i][j] += min_child(matrix, i, j);
    }
  }
  printf("%d\n", matrix[0][0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6420,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x6414(%rbp)
cmpl   $0x50,-0x6414(%rbp)
jge    122b <main+0xdb>
movl   $0x0,-0x6418(%rbp)
cmpl   $0x50,-0x6418(%rbp)
jge    1212 <main+0xc2>
mov    -0x10(%rbp),%rdi
movslq -0x6414(%rbp),%rax
lea    -0x6410(%rbp),%rdx
imul   $0x140,%rax,%rax
add    %rax,%rdx
movslq -0x6418(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe3a(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e04(%rip),%rcx
cmp    (%rcx),%rax
jne    11f9 <main+0xa9>
movl   $0x1,-0x4(%rbp)
jmp    12ec <main+0x19c>
jmp    11fe <main+0xae>
mov    -0x6418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6418(%rbp)
jmp    119a <main+0x4a>
jmp    1217 <main+0xc7>
mov    -0x6414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6414(%rbp)
jmp    1183 <main+0x33>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x4f,-0x6414(%rbp)
cmpl   $0x0,-0x6414(%rbp)
jl     12d3 <main+0x183>
movl   $0x4f,-0x6418(%rbp)
cmpl   $0x0,-0x6418(%rbp)
jl     12ba <main+0x16a>
lea    -0x6410(%rbp),%rdi
mov    -0x6414(%rbp),%esi
mov    -0x6418(%rbp),%edx
call   1060 <min_child@plt>
mov    %rax,%rsi
movslq -0x6414(%rbp),%rcx
lea    -0x6410(%rbp),%rax
imul   $0x140,%rcx,%rcx
add    %rcx,%rax
movslq -0x6418(%rbp),%rcx
movslq (%rax,%rcx,4),%rdx
add    %rsi,%rdx
mov    %edx,(%rax,%rcx,4)
mov    -0x6418(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x6418(%rbp)
jmp    1255 <main+0x105>
jmp    12bf <main+0x16f>
mov    -0x6414(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x6414(%rbp)
jmp    123e <main+0xee>
mov    -0x6410(%rbp),%esi
lea    0xd36(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x6420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6408,%rsp
lea    0xe98(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%rbx
xor    %r12d,%r12d
lea    0xe8e(%rip),%r14
mov    0x2e5d(%rip),%r13
xor    %ebp,%ebp
nopl   (%rax)
lea    (%rbx,%rbp,1),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <fscanf@plt>
cmp    0x0(%r13),%rax
je     122b <main+0xdb>
add    $0x4,%rbp
cmp    $0x140,%rbp
jne    1190 <main+0x40>
add    $0x1,%r12
add    $0x140,%rbx
cmp    $0x50,%r12
jne    118b <main+0x3b>
mov    %r15,%rdi
call   1030 <fclose@plt>
lea    0x63fc(%rsp),%r15
mov    $0x4f,%ebx
mov    %rsp,%r14
nop
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x4f(%rbp),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <min_child@plt>
add    %eax,(%r15,%rbp,4)
add    $0xffffffffffffffff,%rbp
cmp    $0xffffffffffffffb0,%rbp
jne    11f0 <main+0xa0>
add    $0xfffffffffffffec0,%r15
sub    $0x1,%rbx
jae    11e0 <main+0x90>
mov    (%rsp),%esi
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1230 <main+0xe0>
mov    $0x1,%eax
add    $0x6408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"../res/081.data\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%d,\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [80 x [80 x i32]]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
store i32 0, i32* %4
br label %7
7: ; preds = %31, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 80
br i1 %9, label %10, label %34
10: ; preds = %7
store i32 0, i32* %5
br label %11
11: ; preds = %27, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 80
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32*, i32** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %3, i64 0, i64 %17
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [80 x i32], [80 x i32]* %18, i64 0, i64 %20
%22 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %21)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %14
store i32 1, i32* %1
br label %72
26: ; preds = %14
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %11
30: ; preds = %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %7
34: ; preds = %7
%35 = load i32*, i32** %2
%36 = call i32 @fclose(i32* %35)
store i32 79, i32* %4
br label %37
37: ; preds = %64, %34
%38 = load i32, i32* %4
%39 = icmp sge i32 %38, 0
br i1 %39, label %40, label %67
40: ; preds = %37
store i32 79, i32* %5
br label %41
41: ; preds = %60, %40
%42 = load i32, i32* %5
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %63
44: ; preds = %41
%45 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %3, i64 0, i64 0
%46 = bitcast [80 x i32]* %45 to i32**
%47 = load i32, i32* %4
%48 = load i32, i32* %5
%49 = call i64 @min_child(i32** %46, i32 %47, i32 %48)
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %3, i64 0, i64 %51
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [80 x i32], [80 x i32]* %52, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, %49
%59 = trunc i64 %58 to i32
store i32 %59, i32* %55
br label %60
60: ; preds = %44
%61 = load i32, i32* %5
%62 = add nsw i32 %61, -1
store i32 %62, i32* %5
br label %41
63: ; preds = %41
br label %64
64: ; preds = %63
%65 = load i32, i32* %4
%66 = add nsw i32 %65, -1
store i32 %66, i32* %4
br label %37
67: ; preds = %37
%68 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %3, i64 0, i64 0
%69 = getelementptr inbounds [80 x i32], [80 x i32]* %68, i64 0, i64 0
%70 = load i32, i32* %69
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %70)
store i32 0, i32* %1
br label %72
72: ; preds = %67, %25
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str = [16 x i8] c"../res/081.data\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%d,\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [80 x [80 x i32]]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = bitcast [80 x [80 x i32]]* %1 to i8*
br label %4
4: ; preds = %0, %15
%5 = phi i64 [ 0, %0 ], [ %16, %15 ]
br label %9
6: ; preds = %9
%7 = add nuw nsw i64 %10, 1
%8 = icmp eq i64 %7, 80
br i1 %8, label %15, label %9
9: ; preds = %4, %6
%10 = phi i64 [ 0, %4 ], [ %7, %6 ]
%11 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %1, i64 0, i64 %5, i64 %10
%12 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %41, label %6
15: ; preds = %6
%16 = add nuw nsw i64 %5, 1
%17 = icmp eq i64 %16, 80
br i1 %17, label %18, label %4
18: ; preds = %15
%19 = call i32 @fclose(i32* %2)
%20 = bitcast [80 x [80 x i32]]* %1 to i32**
br label %21
21: ; preds = %18, %34
%22 = phi i64 [ 79, %18 ], [ %35, %34 ]
%23 = trunc i64 %22 to i32
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ 79, %21 ], [ %32, %24 ]
%26 = trunc i64 %25 to i32
%27 = call i64 @min_child(i32** %20, i32 %23, i32 %26)
%28 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %1, i64 0, i64 %22, i64 %25
%29 = load i32, i32* %28
%30 = trunc i64 %27 to i32
%31 = add i32 %29, %30
store i32 %31, i32* %28
%32 = add nsw i64 %25, -1
%33 = icmp eq i64 %25, 0
br i1 %33, label %34, label %24
34: ; preds = %24
%35 = add nsw i64 %22, -1
%36 = icmp eq i64 %22, 0
br i1 %36, label %37, label %21
37: ; preds = %34
%38 = getelementptr inbounds [80 x [80 x i32]], [80 x [80 x i32]]* %1, i64 0, i64 0, i64 0
%39 = load i32, i32* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %9, %37
%42 = phi i32 [ 0, %37 ], [ 1, %9 ]
ret i32 %42
}