#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void drawAllPaths(int src, int *st, int ncities) {
  int path[ncities];
  int i, currVertex, c;
  for (i = 0; i < ncities; i++) {
    c = 0;
    currVertex = i;
    while (st[currVertex] != -1 && currVertex != src && c < ncities) {
      path[c++] = currVertex;
      currVertex = st[currVertex];
    }
    if (st[currVertex] == -1 || c >= ncities) {
      printf("no path found\n");
    } else {
      path[c] = src;
      for (currVertex = c; currVertex >= 0; currVertex--) {
        printf("[%d]", path[currVertex]);
        if (currVertex > 0) {
          printf("->");
        }
      }
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<drawAllPaths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128c <drawAllPaths+0x17c>
movl   $0x0,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rcx
movslq -0x30(%rbp),%rdx
xor    %eax,%eax
cmpl   $0xffffffff,(%rcx,%rdx,4)
mov    %al,-0x41(%rbp)
je     119d <drawAllPaths+0x8d>
mov    -0x30(%rbp),%ecx
xor    %eax,%eax
cmp    -0x4(%rbp),%ecx
mov    %al,-0x41(%rbp)
je     119d <drawAllPaths+0x8d>
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
setl   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11ad <drawAllPaths+0x9d>
jmp    11d8 <drawAllPaths+0xc8>
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x30(%rbp)
jmp    1169 <drawAllPaths+0x59>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     11f6 <drawAllPaths+0xe6>
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1209 <drawAllPaths+0xf9>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1279 <drawAllPaths+0x169>
mov    -0x40(%rbp),%rax
mov    -0x4(%rbp),%edx
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     126b <drawAllPaths+0x15b>
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1258 <drawAllPaths+0x148>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <drawAllPaths+0x14d>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    121d <drawAllPaths+0x10d>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127e <drawAllPaths+0x16e>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1150 <drawAllPaths+0x40>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawAllPaths>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r13d
mov    %rsp,%r12
lea    0xf(,%r13,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
test   %edx,%edx
jle    1276 <drawAllPaths+0x146>
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %edi,%eax
mov    %rax,-0x40(%rbp)
xor    %ecx,%ecx
mov    %rsi,-0x38(%rbp)
mov    %edi,-0x2c(%rbp)
jmp    119d <drawAllPaths+0x6d>
nopl   0x0(%rax,%rax,1)
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
mov    -0x48(%rbp),%rcx
add    $0x1,%rcx
cmp    %r13,%rcx
je     1276 <drawAllPaths+0x146>
mov    (%rbx,%rcx,4),%eax
cmp    $0xffffffff,%eax
mov    %rcx,-0x48(%rbp)
je     1210 <drawAllPaths+0xe0>
cmp    -0x40(%rbp),%rcx
je     1210 <drawAllPaths+0xe0>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,(%r12,%r15,4)
mov    %eax,%ecx
add    $0x1,%r15
cltq
mov    (%rbx,%rax,4),%eax
cmp    $0xffffffff,%eax
je     11de <drawAllPaths+0xae>
cmp    %r14d,%ecx
je     11de <drawAllPaths+0xae>
cmp    %r13,%r15
jb     11c0 <drawAllPaths+0x90>
cmp    $0xffffffff,%eax
je     1180 <drawAllPaths+0x50>
cmp    %r13,%r15
jae    1180 <drawAllPaths+0x50>
mov    %r14d,(%r12,%r15,4)
test   $0x80000000,%r15d
lea    0xe06(%rip),%r14
lea    0xe04(%rip),%rbx
je     122e <drawAllPaths+0xfe>
jmp    125f <drawAllPaths+0x12f>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0xffffffff,%eax
je     1180 <drawAllPaths+0x50>
mov    %r14d,(%r12)
xor    %r15d,%r15d
lea    0xdd9(%rip),%r14
lea    0xdd7(%rip),%rbx
mov    %r14,%rdi
mov    -0x2c(%rbp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15,%r15
je     125f <drawAllPaths+0x12f>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x4(%r12,%r15,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%r15
jne    1240 <drawAllPaths+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rbx
mov    -0x2c(%rbp),%r14d
jmp    118c <drawAllPaths+0x5c>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"no path found\0A\00"
@.str.1 = [5 x i8] c"[%d]\00"
@.str.2 = [3 x i8] c"->\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @drawAllPaths(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%12 = load i32, i32* %6
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %7
%15 = alloca i32, i64 %13
store i64 %13, i64* %8
store i32 0, i32* %9
br label %16
16: ; preds = %89, %3
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %92
20: ; preds = %16
store i32 0, i32* %11
%21 = load i32, i32* %9
store i32 %21, i32* %10
br label %22
22: ; preds = %39, %20
%23 = load i32*, i32** %5
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, -1
br i1 %28, label %29, label %37
29: ; preds = %22
%30 = load i32, i32* %10
%31 = load i32, i32* %4
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* %11
%35 = load i32, i32* %6
%36 = icmp slt i32 %34, %35
br label %37
37: ; preds = %33, %29, %22
%38 = phi i1 [ false, %29 ], [ false, %22 ], [ %36, %33 ]
br i1 %38, label %39, label %50
39: ; preds = %37
%40 = load i32, i32* %10
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i32, i32* %15, i64 %43
store i32 %40, i32* %44
%45 = load i32*, i32** %5
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
store i32 %49, i32* %10
br label %22
50: ; preds = %37
%51 = load i32*, i32** %5
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = icmp eq i32 %55, -1
br i1 %56, label %61, label %57
57: ; preds = %50
%58 = load i32, i32* %11
%59 = load i32, i32* %6
%60 = icmp sge i32 %58, %59
br i1 %60, label %61, label %63
61: ; preds = %57, %50
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %88
63: ; preds = %57
%64 = load i32, i32* %4
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %15, i64 %66
store i32 %64, i32* %67
%68 = load i32, i32* %11
store i32 %68, i32* %10
br label %69
69: ; preds = %83, %63
%70 = load i32, i32* %10
%71 = icmp sge i32 %70, 0
br i1 %71, label %72, label %86
72: ; preds = %69
%73 = load i32, i32* %10
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %15, i64 %74
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %76)
%78 = load i32, i32* %10
%79 = icmp sgt i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %72
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %82
82: ; preds = %80, %72
br label %83
83: ; preds = %82
%84 = load i32, i32* %10
%85 = add nsw i32 %84, -1
store i32 %85, i32* %10
br label %69
86: ; preds = %69
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %88
88: ; preds = %86, %61
br label %89
89: ; preds = %88
%90 = load i32, i32* %9
%91 = add nsw i32 %90, 1
store i32 %91, i32* %9
br label %16
92: ; preds = %16
%93 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"[%d]\00"
@.str.2 = [3 x i8] c"->\00"
@str = [14 x i8] c"no path found\00"
define void @drawAllPaths(i32 %0, i32* nocapture %1, i32 %2) {
%4 = zext i32 %2 to i64
%5 = alloca i32, i64 %4
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %63
7: ; preds = %3
%8 = zext i32 %2 to i64
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %7, %60
%11 = phi i64 [ 0, %7 ], [ %61, %60 ]
%12 = getelementptr inbounds i32, i32* %1, i64 %11
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, -1
%15 = icmp ne i64 %11, %9
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %36
17: ; preds = %10
%18 = trunc i64 %11 to i32
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %23, %19 ]
%21 = phi i32 [ %13, %17 ], [ %27, %19 ]
%22 = phi i32 [ %18, %17 ], [ %21, %19 ]
%23 = add nuw nsw i64 %20, 1
%24 = getelementptr inbounds i32, i32* %5, i64 %20
store i32 %22, i32* %24
%25 = sext i32 %21 to i64
%26 = getelementptr inbounds i32, i32* %1, i64 %25
%27 = load i32, i32* %26
%28 = icmp ne i32 %27, -1
%29 = icmp ne i32 %21, %0
%30 = select i1 %28, i1 %29, i1 false
%31 = icmp ult i64 %23, %8
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %19, label %33
33: ; preds = %19
%34 = icmp ne i32 %27, -1
%35 = select i1 %34, i1 %31, i1 false
br i1 %35, label %41, label %39
36: ; preds = %10
%37 = icmp eq i32 %13, -1
br i1 %37, label %39, label %38
38: ; preds = %36
store i32 %0, i32* %5
br label %46
39: ; preds = %36, %33
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %60
41: ; preds = %33
%42 = and i64 %23, 4294967295
%43 = getelementptr inbounds i32, i32* %5, i64 %42
store i32 %0, i32* %43
%44 = and i64 %23, 2147483648
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %58
46: ; preds = %38, %41
%47 = phi i64 [ 0, %38 ], [ %42, %41 ]
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%49 = icmp eq i64 %47, 0
br i1 %49, label %58, label %50
50: ; preds = %46, %50
%51 = phi i64 [ %53, %50 ], [ %47, %46 ]
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%53 = add nsw i64 %51, -1
%54 = getelementptr inbounds i32, i32* %5, i64 %53
%55 = load i32, i32* %54
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %55)
%57 = icmp eq i64 %53, 0
br i1 %57, label %58, label %50
58: ; preds = %50, %46, %41
%59 = tail call i32 @putchar(i32 10)
br label %60
60: ; preds = %39, %58
%61 = add nuw nsw i64 %11, 1
%62 = icmp eq i64 %61, %4
br i1 %62, label %63, label %10
63: ; preds = %60, %3
ret void
}