#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 *, int);
void caminoDijkstra(int origen, int destino, int *p) {
  int k;
  printf("%d <- ", destino);
  k = p[destino];
  while (k != origen) {
    printf("%d <- ", k);
    k = p[k];
  }
  printf("%d\n", origen);
}


x86 assembly (clang, -O0):
<caminoDijkstra>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     116d <caminoDijkstra+0x5d>
mov    -0x14(%rbp),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
jmp    113f <caminoDijkstra+0x2f>
mov    -0x4(%rbp),%esi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<caminoDijkstra>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
movslq %ebp,%rax
mov    (%r14,%rax,4),%ebp
cmp    %ebx,%ebp
je     1155 <caminoDijkstra+0x45>
lea    0xec4(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
movslq %ebp,%rax
mov    (%r14,%rax,4),%ebp
cmp    %ebx,%ebp
jne    1140 <caminoDijkstra+0x30>
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%d <- \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @caminoDijkstra(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = load i32, i32* %5
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %6
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load i32, i32* %13
store i32 %14, i32* %7
br label %15
15: ; preds = %19, %3
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %7
br label %15
27: ; preds = %15
%28 = load i32, i32* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d <- \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @caminoDijkstra(i32 %0, i32 %1, i32* nocapture %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i32, i32* %2, i64 %5
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, %0
br i1 %8, label %16, label %9
9: ; preds = %3, %9
%10 = phi i32 [ %14, %9 ], [ %7, %3 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i32, i32* %2, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, %0
br i1 %15, label %16, label %9
16: ; preds = %9, %3
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %0)
ret void
}