#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 uint16_t;

/* Variables and functions */
int INT_MAX;
int Find_Shortest_Route(int **distances, int startNode,
                        uint16_t unvisitedMask) {
  int n, minDist, nextDist;
  unvisitedMask &= ~(1 << startNode);
  if (unvisitedMask == 0x0000)
    return distances[startNode][0];
  minDist = INT_MAX;
  for (n = 0; n < 16; n++) {
    if (unvisitedMask & (1 << n)) {
      nextDist = distances[startNode][n] +
                 Find_Shortest_Route(distances, n, unvisitedMask);
      if (nextDist < minDist)
        minDist = nextDist;
    }
  }
  return minDist;
}


x86 assembly (clang, -O0):
<Find_Shortest_Route>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1155 <Find_Shortest_Route+0x45>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11eb <Find_Shortest_Route+0xdb>
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11e5 <Find_Shortest_Route+0xd5>
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11d2 <Find_Shortest_Route+0xc2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <Find_Shortest_Route@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11cd <Find_Shortest_Route+0xbd>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11d2 <Find_Shortest_Route+0xc2>
jmp    11d7 <Find_Shortest_Route+0xc7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1168 <Find_Shortest_Route+0x58>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Find_Shortest_Route>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ecx
mov    %rdi,%r14
mov    $0xfffffffe,%r15d
rol    %cl,%r15d
and    %edx,%r15d
je     116f <Find_Shortest_Route+0x5f>
mov    0x2eb3(%rip),%rax
mov    (%rax),%r13d
movslq %ecx,%r12
xor    %ebp,%ebp
jmp    114a <Find_Shortest_Route+0x3a>
nop
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1179 <Find_Shortest_Route+0x69>
bt     %ebp,%r15d
jae    1140 <Find_Shortest_Route+0x30>
mov    (%r14,%r12,8),%rax
mov    (%rax,%rbp,4),%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <Find_Shortest_Route@plt>
add    %ebx,%eax
cmp    %r13d,%eax
cmovl  %eax,%r13d
jmp    1140 <Find_Shortest_Route+0x30>
movslq %ecx,%rax
mov    (%r14,%rax,8),%rax
mov    (%rax),%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32 @Find_Shortest_Route(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32** %0, i32*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %6
%12 = shl i32 1, %11
%13 = xor i32 %12, -1
%14 = load i32, i32* %7
%15 = and i32 %14, %13
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %3
%19 = load i32**, i32*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %19, i64 %21
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 0
%25 = load i32, i32* %24
store i32 %25, i32* %4
br label %64
26: ; preds = %3
%27 = load i32, i32* @INT_MAX
store i32 %27, i32* %9
store i32 0, i32* %8
br label %28
28: ; preds = %59, %26
%29 = load i32, i32* %8
%30 = icmp slt i32 %29, 16
br i1 %30, label %31, label %62
31: ; preds = %28
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = shl i32 1, %33
%35 = and i32 %32, %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %58
37: ; preds = %31
%38 = load i32**, i32*** %5
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32*, i32** %38, i64 %40
%42 = load i32*, i32** %41
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = load i32**, i32*** %5
%48 = load i32, i32* %8
%49 = load i32, i32* %7
%50 = call i32 @Find_Shortest_Route(i32** %47, i32 %48, i32 %49)
%51 = add nsw i32 %46, %50
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = load i32, i32* %9
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %57
55: ; preds = %37
%56 = load i32, i32* %10
store i32 %56, i32* %9
br label %57
57: ; preds = %55, %37
br label %58
58: ; preds = %57, %31
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %28
62: ; preds = %28
%63 = load i32, i32* %9
store i32 %63, i32* %4
br label %64
64: ; preds = %62, %18
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32 @Find_Shortest_Route(i32** nocapture %0, i32 %1, i32 %2) {
%4 = shl nuw i32 1, %1
%5 = xor i32 %4, -1
%6 = and i32 %5, %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = sext i32 %1 to i64
%10 = getelementptr inbounds i32*, i32** %0, i64 %9
%11 = load i32*, i32** %10
%12 = load i32, i32* %11
br label %36
13: ; preds = %3
%14 = load i32, i32* @INT_MAX
%15 = sext i32 %1 to i64
%16 = getelementptr inbounds i32*, i32** %0, i64 %15
br label %17
17: ; preds = %13, %32
%18 = phi i64 [ 0, %13 ], [ %34, %32 ]
%19 = phi i32 [ %14, %13 ], [ %33, %32 ]
%20 = trunc i64 %18 to i32
%21 = shl nuw nsw i32 1, %20
%22 = and i32 %21, %6
%23 = icmp eq i32 %22, 0
br i1 %23, label %32, label %24
24: ; preds = %17
%25 = load i32*, i32** %16
%26 = getelementptr inbounds i32, i32* %25, i64 %18
%27 = load i32, i32* %26
%28 = tail call i32 @Find_Shortest_Route(i32** %0, i32 %20, i32 %6)
%29 = add nsw i32 %28, %27
%30 = icmp slt i32 %29, %19
%31 = select i1 %30, i32 %29, i32 %19
br label %32
32: ; preds = %24, %17
%33 = phi i32 [ %19, %17 ], [ %31, %24 ]
%34 = add nuw nsw i64 %18, 1
%35 = icmp eq i64 %34, 16
br i1 %35, label %36, label %17
36: ; preds = %32, %8
%37 = phi i32 [ %12, %8 ], [ %33, %32 ]
ret i32 %37
}