int calc(int x, int y) {
  int distance[11][11] = {
      {0, 996, 723, 890, 1286, 305, 564, 245, 424, 1026, 884},
      {-1, 0, 750, 104, 286, 711, 576, 747, 590, 505, 543},
      {-1, -1, 0, 668, 979, 593, 224, 515, 194, 534, 905},
      {-1, -1, -1, 0, 316, 607, 472, 645, 502, 434, 467},
      {
          -1,
          -1,
          -1,
          -1,
          0,
          890,
          769,
          938,
          757,
          750,
          400,
      },
      {-1, -1, -1, -1, -1, 0, 386, 106, 315, 832, 559},
      {-1, -1, -1, -1, -1, -1, 0, 348, 112, 447, 681},
      {-1, -1, -1, -1, -1, -1, -1, 0, 249, 799, 665},
      {-1, -1, -1, -1, -1, -1, -1, -1, 0, 497, 665},
      {-1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 901},
      {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0}};
  if (distance[x][y] == -1) {
    return distance[y][x];
  } else
    return distance[x][y];
}


x86 assembly (clang, -O0):
<calc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x1f0(%rbp),%rdi
lea    0xed1(%rip),%rsi
mov    $0x1e4,%edx
call   1030 <memcpy@plt>
movslq -0x8(%rbp),%rcx
lea    -0x1f0(%rbp),%rax
imul   $0x2c,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    117a <calc+0x6a>
movslq -0xc(%rbp),%rcx
lea    -0x1f0(%rbp),%rax
imul   $0x2c,%rcx,%rcx
add    %rcx,%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <calc+0x86>
movslq -0x8(%rbp),%rcx
lea    -0x1f0(%rbp),%rax
imul   $0x2c,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc>:
movslq %edi,%rcx
movslq %esi,%rsi
imul   $0x2c,%rcx,%rax
lea    0xeef(%rip),%rdx
add    %rdx,%rax
mov    (%rax,%rsi,4),%eax
cmp    $0xffffffff,%eax
je     111d <calc+0x1d>
ret
imul   $0x2c,%rsi,%rax
add    %rax,%rdx
mov    (%rdx,%rcx,4),%eax
ret

LLVM IR (-O0):
@__const.calc.distance = [11 x [11 x i32]] [[11 x i32] [i32 0, i32 996, i32 723, i32 890, i32 1286, i32 305, i32 564, i32 245, i32 424, i32 1026, i32 884], [11 x i32] [i32 -1, i32 0, i32 750, i32 104, i32 286, i32 711, i32 576, i32 747, i32 590, i32 505, i32 543], [11 x i32] [i32 -1, i32 -1, i32 0, i32 668, i32 979, i32 593, i32 224, i32 515, i32 194, i32 534, i32 905], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 0, i32 316, i32 607, i32 472, i32 645, i32 502, i32 434, i32 467], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 890, i32 769, i32 938, i32 757, i32 750, i32 400], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 386, i32 106, i32 315, i32 832, i32 559], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 348, i32 112, i32 447, i32 681], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 249, i32 799, i32 665], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 497, i32 665], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 901], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0]]
define i32 @calc(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [11 x [11 x i32]]
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = bitcast [11 x [11 x i32]]* %6 to i8*
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [11 x [11 x i32]], [11 x [11 x i32]]* %6, i64 0, i64 %9
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [11 x i32], [11 x i32]* %10, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %24
16: ; preds = %2
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [11 x [11 x i32]], [11 x [11 x i32]]* %6, i64 0, i64 %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [11 x i32], [11 x i32]* %19, i64 0, i64 %21
%23 = load i32, i32* %22
store i32 %23, i32* %3
br label %32
24: ; preds = %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [11 x [11 x i32]], [11 x [11 x i32]]* %6, i64 0, i64 %26
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [11 x i32], [11 x i32]* %27, i64 0, i64 %29
%31 = load i32, i32* %30
store i32 %31, i32* %3
br label %32
32: ; preds = %24, %16
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@__const.calc.distance = [11 x [11 x i32]] [[11 x i32] [i32 0, i32 996, i32 723, i32 890, i32 1286, i32 305, i32 564, i32 245, i32 424, i32 1026, i32 884], [11 x i32] [i32 -1, i32 0, i32 750, i32 104, i32 286, i32 711, i32 576, i32 747, i32 590, i32 505, i32 543], [11 x i32] [i32 -1, i32 -1, i32 0, i32 668, i32 979, i32 593, i32 224, i32 515, i32 194, i32 534, i32 905], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 0, i32 316, i32 607, i32 472, i32 645, i32 502, i32 434, i32 467], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 890, i32 769, i32 938, i32 757, i32 750, i32 400], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 386, i32 106, i32 315, i32 832, i32 559], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 348, i32 112, i32 447, i32 681], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 249, i32 799, i32 665], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 497, i32 665], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0, i32 901], [11 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 0]]
define i32 @calc(i32 %0, i32 %1) {
%3 = sext i32 %0 to i64
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds [11 x [11 x i32]], [11 x [11 x i32]]* @__const.calc.distance, i64 0, i64 %3, i64 %4
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = getelementptr inbounds [11 x [11 x i32]], [11 x [11 x i32]]* @__const.calc.distance, i64 0, i64 %4, i64 %3
%10 = load i32, i32* %9
br label %11
11: ; preds = %2, %8
%12 = phi i32 [ %10, %8 ], [ %6, %2 ]
ret i32 %12
}