#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*/ is_relpath(char const *);
char *scwd();
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
const char *absolute_path(const char *path) {
  static char abspath[256];
  if (!is_relpath(path))
    return path;
  snprintf(abspath, 256, "%s/%s", scwd(), path);
  return abspath;
}


x86 assembly (clang, -O0):
<absolute_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <is_relpath@plt>
cmp    $0x0,%eax
jne    115b <absolute_path+0x2b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <absolute_path+0x5c>
mov    $0x0,%al
call   1030 <scwd@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%r8
lea    0x2ee0(%rip),%rdi
mov    $0x100,%esi
lea    0xe84(%rip),%rdx
call   1040 <snprintf@plt>
lea    0x2ec8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<absolute_path>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <is_relpath@plt>
test   %eax,%eax
je     116b <absolute_path+0x3b>
xor    %eax,%eax
call   1030 <scwd@plt>
lea    0x2f02(%rip),%r14
lea    0xeab(%rip),%rdx
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rax,%rcx
mov    %rbx,%r8
call   1040 <snprintf@plt>
mov    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@absolute_path.abspath = internal global [256 x i8] zeroinitializer
@.str = [6 x i8] c"%s/%s\00"
define i8* @absolute_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @is_relpath(i8* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
store i8* %8, i8** %2
br label %13
9: ; preds = %1
%10 = call i8* (...) @scwd()
%11 = load i8*, i8** %3
%12 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @absolute_path.abspath, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @absolute_path.abspath, i64 0, i64 0), i8** %2
br label %13
13: ; preds = %9, %7
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@absolute_path.abspath = internal global [256 x i8] zeroinitializer
@.str = [6 x i8] c"%s/%s\00"
define i8* @absolute_path(i8* %0) {
%2 = tail call i32 @is_relpath(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i8* (...) @scwd()
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @absolute_path.abspath, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %0)
br label %7
7: ; preds = %1, %4
%8 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @absolute_path.abspath, i64 0, i64 0), %4 ], [ %0, %1 ]
ret i8* %8
}