#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 */
scalar_t__ asprintf(char **, char *, char const *, char const *);
scalar_t__ path_is_absolute(char const *);
char *strdup(char const *);
char *path_make_absolute(const char *p, const char *prefix) {
  char *r;
  if (path_is_absolute(p) || !prefix)
    return strdup(p);
  if (asprintf(&r, "%s/%s", prefix, p) < 0)
    return NULL;
  return r;
}


x86 assembly (clang, -O0):
<path_make_absolute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <path_is_absolute@plt>
cmp    $0x0,%rax
jne    115e <path_make_absolute+0x2e>
cmpq   $0x0,-0x18(%rbp)
jne    1170 <path_make_absolute+0x40>
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11a7 <path_make_absolute+0x77>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x20(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <asprintf@plt>
cmp    $0x0,%rax
jge    119f <path_make_absolute+0x6f>
movq   $0x0,-0x8(%rbp)
jmp    11a7 <path_make_absolute+0x77>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_make_absolute>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <path_is_absolute@plt>
test   %r14,%r14
je     1169 <path_make_absolute+0x39>
test   %rax,%rax
jne    1169 <path_make_absolute+0x39>
lea    0xeb0(%rip),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <asprintf@plt>
test   %rax,%rax
js     1178 <path_make_absolute+0x48>
mov    (%rsp),%rax
jmp    117a <path_make_absolute+0x4a>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <strdup@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
define i8* @path_make_absolute(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i64 @path_is_absolute(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10, %2
%14 = load i8*, i8** %4
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %3
br label %24
16: ; preds = %10
%17 = load i8*, i8** %5
%18 = load i8*, i8** %4
%19 = call i64 @asprintf(i8** %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i8* null, i8** %3
br label %24
22: ; preds = %16
%23 = load i8*, i8** %6
store i8* %23, i8** %3
br label %24
24: ; preds = %22, %21, %13
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
define i8* @path_make_absolute(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i64 @path_is_absolute(i8* %0)
%6 = icmp eq i64 %5, 0
%7 = icmp ne i8* %1, null
%8 = and i1 %7, %6
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i8* @strdup(i8* %0)
br label %16
11: ; preds = %2
%12 = call i64 @asprintf(i8** %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%13 = icmp slt i64 %12, 0
%14 = load i8*, i8** %3
%15 = select i1 %13, i8* null, i8* %14
br label %16
16: ; preds = %11, %9
%17 = phi i8* [ %10, %9 ], [ %15, %11 ]
ret i8* %17
}