#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 scalar_t__ ino_t;

/* Variables and functions */
int NAME_MAX;
int /*<<< orphan*/ chdir(char *);
scalar_t__ get_inode(char *);
int /*<<< orphan*/ inum_to_name(scalar_t__, char *, int);
int /*<<< orphan*/ printf(char *, char *);
void printpathto(ino_t this_node) {
  ino_t my_inode;
  char its_name[NAME_MAX];
  if (get_inode("..") != this_node) {
    chdir("..");
    inum_to_name(this_node, its_name, NAME_MAX);
    my_inode = get_inode(".");
    printpathto(my_inode);
    printf("/%s", its_name);
  }
}


x86 assembly (clang, -O0):
<printpathto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe71(%rip),%rdi
call   1030 <get_inode@plt>
cmp    -0x8(%rbp),%rax
je     11e9 <printpathto+0x99>
lea    0xe5b(%rip),%rdi
call   1040 <chdir@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdi
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
call   1060 <inum_to_name@plt>
lea    0xe3a(%rip),%rdi
call   1030 <get_inode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <printpathto@plt>
mov    -0x28(%rbp),%rsi
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printpathto>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e74(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe81(%rip),%rdi
call   1030 <get_inode@plt>
cmp    %r14,%rax
je     11c6 <printpathto+0x76>
lea    0xe70(%rip),%rdi
call   1040 <chdir@plt>
mov    (%r15),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <inum_to_name@plt>
lea    0xe57(%rip),%rdi
call   1030 <get_inode@plt>
mov    %rax,%rdi
call   1070 <printpathto@plt>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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