int main() {
  int i, j, n;
  int output[15 * 15];
  int output_count = 0;
  int check_output[15 * 15] = {
      0,  7,  38, 23, 14, 36, 3,  29, 7,  14, 28, 0,  31, 16, 7,  34, 31,
      28, 1,  39, 39, 25, 0,  32, 14, 3,  32, 9,  26, 43, 12, 14, 40, 0,
      21, 43, 15, 12, 15, 26, 40, 36, 48, 28, 0,  27, 43, 33, 12, 39, 36,
      22, 21, 29, 29, 0,  29, 6,  23, 40, 8,  4,  35, 20, 11, 33, 0,  26,
      5,  11, 30, 16, 47, 32, 23, 35, 23, 0,  17, 34, 28, 24, 55, 16, 8,
      35, 31, 28, 0,  38, 23, 19, 41, 16, 8,  35, 15, 28, 0,  0};
  initialise_board();
  start_trigger();
  for (n = 0; n < 4096 >> 9; ++n) {
    output_count = 0;
    for (j = 0; j < 15; j++) {
      for (i = 0; i < 15; i++) {
        output[output_count] = dijkstra(i, j);
        output_count++;
      }
    }
  }
  stop_trigger();
  int to_return = 0;
  for (i = 0; i < output_count; i++) {
    if (output[i] != check_output[i]) {
      to_return = -1;
      break;
    }
  }
  return to_return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x740,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3a4(%rbp)
lea    -0x730(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x384,%edx
call   1050 <memcpy@plt>
mov    $0x0,%al
call   1060 <initialise_board@plt>
mov    $0x0,%al
call   1030 <start_trigger@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    122f <main+0xdf>
movl   $0x0,-0x3a4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf,-0xc(%rbp)
jge    121c <main+0xcc>
movl   $0x0,-0x8(%rbp)
cmpl   $0xf,-0x8(%rbp)
jge    1209 <main+0xb9>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1070 <dijkstra@plt>
mov    %eax,%ecx
movslq -0x3a4(%rbp),%rax
mov    %ecx,-0x3a0(%rbp,%rax,4)
mov    -0x3a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c5 <main+0x75>
jmp    120e <main+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b4 <main+0x64>
jmp    1221 <main+0xd1>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1199 <main+0x49>
mov    $0x0,%al
call   1040 <stop_trigger@plt>
movl   $0x0,-0x734(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x3a4(%rbp),%eax
jge    1294 <main+0x144>
movslq -0x8(%rbp),%rax
mov    -0x3a0(%rbp,%rax,4),%eax
movslq -0x8(%rbp),%rcx
cmp    -0x730(%rbp,%rcx,4),%eax
je     1281 <main+0x131>
movl   $0xffffffff,-0x734(%rbp)
ff ff ff
jmp    1294 <main+0x144>
jmp    1286 <main+0x136>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1247 <main+0xf7>
mov    -0x734(%rbp),%eax
add    $0x740,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x388,%rsp
xor    %eax,%eax
call   1050 <initialise_board@plt>
xor    %eax,%eax
call   1030 <start_trigger@plt>
lea    0x38(%rsp),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x38(%rbp)
mov    $0x1,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x34(%rbp)
mov    $0x2,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x30(%rbp)
mov    $0x3,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x4,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x28(%rbp)
mov    $0x5,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x24(%rbp)
mov    $0x6,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x20(%rbp)
mov    $0x7,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x8,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x18(%rbp)
mov    $0x9,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x14(%rbp)
mov    $0xa,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x10(%rbp)
mov    $0xb,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0xc(%rbp)
mov    $0xc,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x8(%rbp)
mov    $0xd,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,-0x4(%rbp)
mov    $0xe,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <dijkstra@plt>
mov    %eax,0x0(%rbp)
add    $0x1,%ebx
add    $0x3c,%rbp
cmp    $0xf,%ebx
jne    1180 <main+0x40>
add    $0x1,%r15d
cmp    $0x8,%r15d
jne    1170 <main+0x30>
xor    %eax,%eax
call   1040 <stop_trigger@plt>
mov    $0x2,%ecx
lea    0xd53(%rip),%rdx
mov    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x8(%rsp,%rcx,4),%esi
cmp    -0x8(%rdx,%rcx,4),%esi
jne    12eb <main+0x1ab>
mov    -0x4(%rsp,%rcx,4),%esi
cmp    -0x4(%rdx,%rcx,4),%esi
jne    12eb <main+0x1ab>
mov    (%rsp,%rcx,4),%esi
cmp    (%rdx,%rcx,4),%esi
jne    12eb <main+0x1ab>
add    $0x3,%rcx
cmp    $0xe3,%rcx
jne    12c0 <main+0x180>
xor    %eax,%eax
add    $0x388,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.check_output = <{ [98 x i32], [127 x i32] }> <{ [98 x i32] [i32 0, i32 7, i32 38, i32 23, i32 14, i32 36, i32 3, i32 29, i32 7, i32 14, i32 28, i32 0, i32 31, i32 16, i32 7, i32 34, i32 31, i32 28, i32 1, i32 39, i32 39, i32 25, i32 0, i32 32, i32 14, i32 3, i32 32, i32 9, i32 26, i32 43, i32 12, i32 14, i32 40, i32 0, i32 21, i32 43, i32 15, i32 12, i32 15, i32 26, i32 40, i32 36, i32 48, i32 28, i32 0, i32 27, i32 43, i32 33, i32 12, i32 39, i32 36, i32 22, i32 21, i32 29, i32 29, i32 0, i32 29, i32 6, i32 23, i32 40, i32 8, i32 4, i32 35, i32 20, i32 11, i32 33, i32 0, i32 26, i32 5, i32 11, i32 30, i32 16, i32 47, i32 32, i32 23, i32 35, i32 23, i32 0, i32 17, i32 34, i32 28, i32 24, i32 55, i32 16, i32 8, i32 35, i32 31, i32 28, i32 0, i32 38, i32 23, i32 19, i32 41, i32 16, i32 8, i32 35, i32 15, i32 28], [127 x i32] zeroinitializer }>
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [225 x i32]
%6 = alloca i32
%7 = alloca [225 x i32]
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%9 = bitcast [225 x i32]* %7 to i8*
%10 = call i32 (...) @initialise_board()
%11 = call i32 (...) @start_trigger()
store i32 0, i32* %4
br label %12
12: ; preds = %40, %0
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %43
15: ; preds = %12
store i32 0, i32* %6
store i32 0, i32* %3
br label %16
16: ; preds = %36, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 15
br i1 %18, label %19, label %39
19: ; preds = %16
store i32 0, i32* %2
br label %20
20: ; preds = %32, %19
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 15
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [225 x i32], [225 x i32]* %5, i64 0, i64 %28
store i32 %26, i32* %29
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %32
32: ; preds = %23
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %20
35: ; preds = %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %16
39: ; preds = %16
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %12
43: ; preds = %12
%44 = call i32 (...) @stop_trigger()
store i32 0, i32* %8
store i32 0, i32* %2
br label %45
45: ; preds = %61, %43
%46 = load i32, i32* %2
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %64
49: ; preds = %45
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [225 x i32], [225 x i32]* %5, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [225 x i32], [225 x i32]* %7, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = icmp ne i32 %53, %57
br i1 %58, label %59, label %60
59: ; preds = %49
store i32 -1, i32* %8
br label %64
60: ; preds = %49
br label %61
61: ; preds = %60
%62 = load i32, i32* %2
%63 = add nsw i32 %62, 1
store i32 %63, i32* %2
br label %45
64: ; preds = %59, %45
%65 = load i32, i32* %8
ret i32 %65
}

LLVM IR (-O2):
@__const.main.check_output = <{ [98 x i32], [127 x i32] }> <{ [98 x i32] [i32 0, i32 7, i32 38, i32 23, i32 14, i32 36, i32 3, i32 29, i32 7, i32 14, i32 28, i32 0, i32 31, i32 16, i32 7, i32 34, i32 31, i32 28, i32 1, i32 39, i32 39, i32 25, i32 0, i32 32, i32 14, i32 3, i32 32, i32 9, i32 26, i32 43, i32 12, i32 14, i32 40, i32 0, i32 21, i32 43, i32 15, i32 12, i32 15, i32 26, i32 40, i32 36, i32 48, i32 28, i32 0, i32 27, i32 43, i32 33, i32 12, i32 39, i32 36, i32 22, i32 21, i32 29, i32 29, i32 0, i32 29, i32 6, i32 23, i32 40, i32 8, i32 4, i32 35, i32 20, i32 11, i32 33, i32 0, i32 26, i32 5, i32 11, i32 30, i32 16, i32 47, i32 32, i32 23, i32 35, i32 23, i32 0, i32 17, i32 34, i32 28, i32 24, i32 55, i32 16, i32 8, i32 35, i32 31, i32 28, i32 0, i32 38, i32 23, i32 19, i32 41, i32 16, i32 8, i32 35, i32 15, i32 28], [127 x i32] zeroinitializer }>
define i32 @main() {
%1 = alloca [225 x i32]
%2 = bitcast [225 x i32]* %1 to i8*
%3 = tail call i32 (...) @initialise_board()
%4 = tail call i32 (...) @start_trigger()
br label %5
5: ; preds = %0, %57
%6 = phi i32 [ 0, %0 ], [ %58, %57 ]
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %54, %7 ]
%9 = phi i32 [ 0, %5 ], [ %55, %7 ]
%10 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 0, i32 %9)
%11 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %8
store i32 %10, i32* %11
%12 = add nuw nsw i64 %8, 1
%13 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 1, i32 %9)
%14 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %12
store i32 %13, i32* %14
%15 = add nuw nsw i64 %8, 2
%16 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 2, i32 %9)
%17 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %15
store i32 %16, i32* %17
%18 = add nuw nsw i64 %8, 3
%19 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 3, i32 %9)
%20 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %18
store i32 %19, i32* %20
%21 = add nuw nsw i64 %8, 4
%22 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 4, i32 %9)
%23 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %21
store i32 %22, i32* %23
%24 = add nuw nsw i64 %8, 5
%25 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 5, i32 %9)
%26 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %24
store i32 %25, i32* %26
%27 = add nuw nsw i64 %8, 6
%28 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 6, i32 %9)
%29 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %27
store i32 %28, i32* %29
%30 = add nuw nsw i64 %8, 7
%31 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 7, i32 %9)
%32 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %30
store i32 %31, i32* %32
%33 = add nuw nsw i64 %8, 8
%34 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 8, i32 %9)
%35 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %33
store i32 %34, i32* %35
%36 = add nuw nsw i64 %8, 9
%37 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 9, i32 %9)
%38 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %36
store i32 %37, i32* %38
%39 = add nuw nsw i64 %8, 10
%40 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 10, i32 %9)
%41 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %39
store i32 %40, i32* %41
%42 = add nuw nsw i64 %8, 11
%43 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 11, i32 %9)
%44 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %42
store i32 %43, i32* %44
%45 = add nuw nsw i64 %8, 12
%46 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 12, i32 %9)
%47 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %45
store i32 %46, i32* %47
%48 = add nuw nsw i64 %8, 13
%49 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 13, i32 %9)
%50 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %48
store i32 %49, i32* %50
%51 = add nuw nsw i64 %8, 14
%52 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dijkstra to i32 (i32, i32, ...)*)(i32 14, i32 %9)
%53 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %51
store i32 %52, i32* %53
%54 = add nuw nsw i64 %8, 15
%55 = add nuw nsw i32 %9, 1
%56 = icmp eq i32 %55, 15
br i1 %56, label %57, label %7
57: ; preds = %7
%58 = add nuw nsw i32 %6, 1
%59 = icmp eq i32 %58, 8
br i1 %59, label %60, label %5
60: ; preds = %57
%61 = tail call i32 (...) @stop_trigger()
br label %79
62: ; preds = %79
%63 = add nuw nsw i64 %80, 1
%64 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = getelementptr inbounds [225 x i32], [225 x i32]* bitcast (<{ [98 x i32], [127 x i32] }>* @__const.main.check_output to [225 x i32]*), i64 0, i64 %63
%67 = load i32, i32* %66
%68 = icmp eq i32 %65, %67
br i1 %68, label %69, label %86
69: ; preds = %62
%70 = add nuw nsw i64 %80, 2
%71 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = getelementptr inbounds [225 x i32], [225 x i32]* bitcast (<{ [98 x i32], [127 x i32] }>* @__const.main.check_output to [225 x i32]*), i64 0, i64 %70
%74 = load i32, i32* %73
%75 = icmp eq i32 %72, %74
br i1 %75, label %76, label %86
76: ; preds = %69
%77 = add nuw nsw i64 %80, 3
%78 = icmp eq i64 %77, 225
br i1 %78, label %86, label %79
79: ; preds = %76, %60
%80 = phi i64 [ 0, %60 ], [ %77, %76 ]
%81 = getelementptr inbounds [225 x i32], [225 x i32]* %1, i64 0, i64 %80
%82 = load i32, i32* %81
%83 = getelementptr inbounds [225 x i32], [225 x i32]* bitcast (<{ [98 x i32], [127 x i32] }>* @__const.main.check_output to [225 x i32]*), i64 0, i64 %80
%84 = load i32, i32* %83
%85 = icmp eq i32 %82, %84
br i1 %85, label %62, label %86
86: ; preds = %76, %69, %62, %79
%87 = phi i32 [ -1, %79 ], [ -1, %62 ], [ -1, %69 ], [ 0, %76 ]
ret i32 %87
}