#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 */
struct pathnode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ freepath(struct pathnode *);
char *pathtostr(struct pathnode *);
struct pathnode *relpath(struct pathnode *, struct pathnode *);
struct pathnode *strtopath(char *);
char *str_relpath(char *f, char *t) {
  struct pathnode *p;
  struct pathnode *r;
  struct pathnode *q;
  char *w;
  p = strtopath(f);
  q = strtopath(t);
  r = relpath(strtopath(f), strtopath(t));
  w = pathtostr(r);
  freepath(p);
  freepath(q);
  freepath(r);
  return w;
}


x86 assembly (clang, -O0):
<str_relpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strtopath@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strtopath@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strtopath@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strtopath@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1030 <relpath@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <pathtostr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <freepath@plt>
mov    -0x28(%rbp),%rdi
call   1060 <freepath@plt>
mov    -0x20(%rbp),%rdi
call   1060 <freepath@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_relpath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strtopath@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <strtopath@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <strtopath@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strtopath@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <relpath@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <pathtostr@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1060 <freepath@plt>
mov    %r12,%rdi
call   1060 <freepath@plt>
mov    %rbx,%rdi
call   1060 <freepath@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pathnode = type { i32 }
define i8* @str_relpath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.pathnode*
%6 = alloca %struct.pathnode*
%7 = alloca %struct.pathnode*
%8 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call %struct.pathnode* @strtopath(i8* %9)
store %struct.pathnode* %10, %struct.pathnode** %5
%11 = load i8*, i8** %4
%12 = call %struct.pathnode* @strtopath(i8* %11)
store %struct.pathnode* %12, %struct.pathnode** %7
%13 = load i8*, i8** %3
%14 = call %struct.pathnode* @strtopath(i8* %13)
%15 = load i8*, i8** %4
%16 = call %struct.pathnode* @strtopath(i8* %15)
%17 = call %struct.pathnode* @relpath(%struct.pathnode* %14, %struct.pathnode* %16)
store %struct.pathnode* %17, %struct.pathnode** %6
%18 = load %struct.pathnode*, %struct.pathnode** %6
%19 = call i8* @pathtostr(%struct.pathnode* %18)
store i8* %19, i8** %8
%20 = load %struct.pathnode*, %struct.pathnode** %5
%21 = call i32 @freepath(%struct.pathnode* %20)
%22 = load %struct.pathnode*, %struct.pathnode** %7
%23 = call i32 @freepath(%struct.pathnode* %22)
%24 = load %struct.pathnode*, %struct.pathnode** %6
%25 = call i32 @freepath(%struct.pathnode* %24)
%26 = load i8*, i8** %8
ret i8* %26
}

LLVM IR (-O2):
%struct.pathnode = type { i32 }
define i8* @str_relpath(i8* %0, i8* %1) {
%3 = tail call %struct.pathnode* @strtopath(i8* %0)
%4 = tail call %struct.pathnode* @strtopath(i8* %1)
%5 = tail call %struct.pathnode* @strtopath(i8* %0)
%6 = tail call %struct.pathnode* @strtopath(i8* %1)
%7 = tail call %struct.pathnode* @relpath(%struct.pathnode* %5, %struct.pathnode* %6)
%8 = tail call i8* @pathtostr(%struct.pathnode* %7)
%9 = tail call i32 @freepath(%struct.pathnode* %3)
%10 = tail call i32 @freepath(%struct.pathnode* %4)
%11 = tail call i32 @freepath(%struct.pathnode* %7)
ret i8* %8
}