#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 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    114b <Find_Shortest_Route+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <Find_Shortest_Route+0xd1>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11db <Find_Shortest_Route+0xcb>
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11c8 <Find_Shortest_Route+0xb8>
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    11c3 <Find_Shortest_Route+0xb3>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11c8 <Find_Shortest_Route+0xb8>
jmp    11cd <Find_Shortest_Route+0xbd>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115e <Find_Shortest_Route+0x4e>
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    $0xfffffffe,%r15d
rol    %cl,%r15d
and    %edx,%r15d
je     116f <Find_Shortest_Route+0x5f>
mov    %rdi,%r14
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     1172 <Find_Shortest_Route+0x62>
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>
xor    %r13d,%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 %19
18: ; preds = %3
store i32 0, i32* %4
br label %57
19: ; preds = %3
%20 = load i32, i32* @INT_MAX
store i32 %20, i32* %9
store i32 0, i32* %8
br label %21
21: ; preds = %52, %19
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 16
br i1 %23, label %24, label %55
24: ; preds = %21
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = shl i32 1, %26
%28 = and i32 %25, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %51
30: ; preds = %24
%31 = load i32**, i32*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32*, i32** %31, i64 %33
%35 = load i32*, i32** %34
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = load i32**, i32*** %5
%41 = load i32, i32* %8
%42 = load i32, i32* %7
%43 = call i32 @Find_Shortest_Route(i32** %40, i32 %41, i32 %42)
%44 = add nsw i32 %39, %43
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = load i32, i32* %9
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %30
%49 = load i32, i32* %10
store i32 %49, i32* %9
br label %50
50: ; preds = %48, %30
br label %51
51: ; preds = %50, %24
br label %52
52: ; preds = %51
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %21
55: ; preds = %21
%56 = load i32, i32* %9
store i32 %56, i32* %4
br label %57
57: ; preds = %55, %18
%58 = load i32, i32* %4
ret i32 %58
}

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 %31, label %8
8: ; preds = %3
%9 = load i32, i32* @INT_MAX
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i32*, i32** %0, i64 %10
br label %12
12: ; preds = %8, %27
%13 = phi i64 [ 0, %8 ], [ %29, %27 ]
%14 = phi i32 [ %9, %8 ], [ %28, %27 ]
%15 = trunc i64 %13 to i32
%16 = shl nuw nsw i32 1, %15
%17 = and i32 %16, %6
%18 = icmp eq i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %12
%20 = load i32*, i32** %11
%21 = getelementptr inbounds i32, i32* %20, i64 %13
%22 = load i32, i32* %21
%23 = tail call i32 @Find_Shortest_Route(i32** %0, i32 %15, i32 %6)
%24 = add nsw i32 %23, %22
%25 = icmp slt i32 %24, %14
%26 = select i1 %25, i32 %24, i32 %14
br label %27
27: ; preds = %19, %12
%28 = phi i32 [ %14, %12 ], [ %26, %19 ]
%29 = add nuw nsw i64 %13, 1
%30 = icmp eq i64 %29, 16
br i1 %30, label %31, label %12
31: ; preds = %27, %3
%32 = phi i32 [ 0, %3 ], [ %28, %27 ]
ret i32 %32
}