#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*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char const *);
char *yasm__getcwd();
int /*<<< orphan*/ yasm_xfree(char *);
char *yasm_xmalloc(scalar_t__);
char *yasm__abspath_unix(const char *path) {
  char *curdir, *abspath;
  static const char pathsep[2] = "/";
  curdir = yasm__getcwd();
  abspath = yasm_xmalloc(strlen(curdir) + strlen(path) + 2);
  strcpy(abspath, curdir);
  strcat(abspath, pathsep);
  strcat(abspath, path);
  yasm_xfree(curdir);
  return abspath;
}


x86 assembly (clang, -O0):
<yasm__abspath_unix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <yasm__getcwd@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1080 <yasm_xmalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1050 <yasm_xfree@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yasm__abspath_unix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1070 <yasm__getcwd@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%r15,%rax,1),%rdi
add    $0x2,%rdi
call   1080 <yasm_xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %r12,%rdi
call   1050 <yasm_xfree@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@yasm__abspath_unix.pathsep = internal constant [2 x i8] c"/\00"
define i8* @yasm__abspath_unix(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i8* (...) @yasm__getcwd()
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = load i8*, i8** %2
%9 = call i64 @strlen(i8* %8)
%10 = add nsw i64 %7, %9
%11 = add nsw i64 %10, 2
%12 = call i8* @yasm_xmalloc(i64 %11)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = load i8*, i8** %4
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @yasm__abspath_unix.pathsep, i64 0, i64 0))
%18 = load i8*, i8** %4
%19 = load i8*, i8** %2
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 @yasm_xfree(i8* %21)
%23 = load i8*, i8** %4
ret i8* %23
}

LLVM IR (-O2):
@yasm__abspath_unix.pathsep = internal constant [2 x i8] c"/\00"
define i8* @yasm__abspath_unix(i8* %0) {
%2 = tail call i8* (...) @yasm__getcwd()
%3 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add i64 %3, 2
%6 = add i64 %5, %4
%7 = tail call i8* @yasm_xmalloc(i64 %6)
%8 = tail call i32 @strcpy(i8* %7, i8* %2)
%9 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @yasm__abspath_unix.pathsep, i64 0, i64 0))
%10 = tail call i32 @strcat(i8* %7, i8* %0)
%11 = tail call i32 @yasm_xfree(i8* %2)
ret i8* %7
}