#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 int /*<<< orphan*/ cwd;

/* Variables and functions */
int PATH_MAX;
char *_mmatic_strdup(void *, char const *, char *, int);
int /*<<< orphan*/ getcwd(char *, int);
char *mmatic_sprintf(void *, char *, int /*<<< orphan*/, char const *);
char *pjf_abspath(const char *path, void *mm) {
  char cwd[PATH_MAX];
  if (path[0] == '/')
    return _mmatic_strdup(
        ((void *)mm), (path),
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/pforemski/libpjf/refs/heads/master/lib.c",
        223);
  else
    return mmatic_sprintf(mm, "%s/%s", getcwd(cwd, sizeof(cwd)), path);
}


x86 assembly (clang, -O0):
<pjf_abspath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11a9 <pjf_abspath+0x79>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe71(%rip),%rdx
mov    $0xdf,%ecx
call   1050 <_mmatic_strdup@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    11e1 <pjf_abspath+0xb1>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,-0x48(%rbp)
mov    %eax,%esi
call   1040 <getcwd@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
lea    0xeb2(%rip),%rsi
call   1030 <mmatic_sprintf@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pjf_abspath>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eac(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
cmpb   $0x2f,(%rbx)
jne    117b <pjf_abspath+0x4b>
lea    0xe9d(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xdf,%ecx
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <_mmatic_strdup@plt>
call   1040 <getcwd@plt>
lea    0xefc(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <mmatic_sprintf@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pforemski/libpjf/refs/heads/master/lib.c\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @pjf_abspath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i32, i32* @PATH_MAX
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i8, i64 %10
store i64 %10, i64* %7
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = load i8*, i8** %4
%21 = call i8* @_mmatic_strdup(i8* %19, i8* %20, i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 223)
store i8* %21, i8** %3
store i32 1, i32* %8
br label %28
22: ; preds = %2
%23 = load i8*, i8** %5
%24 = trunc i64 %10 to i32
%25 = call i32 @getcwd(i8* %12, i32 %24)
%26 = load i8*, i8** %4
%27 = call i8* @mmatic_sprintf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8* %26)
store i8* %27, i8** %3
store i32 1, i32* %8
br label %28
28: ; preds = %22, %18
%29 = load i8*, i8** %6
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pforemski/libpjf/refs/heads/master/lib.c\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @pjf_abspath(i8* %0, i8* %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 47
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i8* @_mmatic_strdup(i8* %1, i8* %0, i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 223)
br label %13
10: ; preds = %2
%11 = call i32 @getcwd(i8* %5, i32 %3)
%12 = call i8* @mmatic_sprintf(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11, i8* %0)
br label %13
13: ; preds = %10, %8
%14 = phi i8* [ %9, %8 ], [ %12, %10 ]
ret i8* %14
}