#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 /*<<< orphan*/ name;
typedef scalar_t__ ino_t;

/* Variables and functions */
int /*<<< orphan*/ chdir(char *);
scalar_t__ get_inode(char *);
int /*<<< orphan*/ inode_to_name(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
void print_path_to(ino_t this_inode) {
  ino_t my_inode;
  char name[256];
  if (get_inode("..") != this_inode) {
    chdir("..");
    strncpy(name, inode_to_name(this_inode), sizeof(name) - 1);
    my_inode = get_inode(".");
    print_path_to(my_inode);
    printf("/%s", name);
  } else {
    return;
  }
}


x86 assembly (clang, -O0):
<print_path_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <get_inode@plt>
cmp    -0x8(%rbp),%rax
je     11ec <print_path_to+0x8c>
lea    0xe74(%rip),%rdi
call   1060 <chdir@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <inode_to_name@plt>
mov    -0x118(%rbp),%rdi
mov    %eax,%esi
mov    $0xff,%edx
call   1030 <strncpy@plt>
lea    0xe3f(%rip),%rdi
call   1050 <get_inode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <print_path_to@plt>
lea    -0x110(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1070 <printf@plt>
jmp    11f1 <print_path_to+0x91>
jmp    11f1 <print_path_to+0x91>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_path_to>:
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
lea    0xe8e(%rip),%rdi
call   1050 <get_inode@plt>
cmp    %rbx,%rax
je     11c5 <print_path_to+0x65>
lea    0xe7d(%rip),%rdi
call   1060 <chdir@plt>
mov    %rbx,%rdi
call   1080 <inode_to_name@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xff,%edx
call   1030 <strncpy@plt>
lea    0xe58(%rip),%rdi
call   1050 <get_inode@plt>
mov    %rax,%rdi
call   1040 <print_path_to@plt>
lea    0xe46(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"..\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [4 x i8] c"/%s\00"
define void @print_path_to(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca [256 x i8]
store i64 %0, i64* %2
%5 = call i64 @get_inode(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i64, i64* %2
%7 = icmp ne i64 %5, %6
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%11 = load i64, i64* %2
%12 = call i32 @inode_to_name(i64 %11)
%13 = call i32 @strncpy(i8* %10, i32 %12, i32 255)
%14 = call i64 @get_inode(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i64 %14, i64* %3
%15 = load i64, i64* %3
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %19
18: ; preds = %1
br label %19
19: ; preds = %18, %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"..\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [4 x i8] c"/%s\00"
define void @print_path_to(i64 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @get_inode(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, %0
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @inode_to_name(i64 %0)
%9 = call i32 @strncpy(i8* %3, i32 %8, i32 255)
%10 = call i64 @get_inode(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %12
12: ; preds = %1, %6
ret void
}