#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*/ gsft_strlcpy(char *, char const *, size_t);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *, char const *);
void gsft_file_rel_to_abs(const char *path_rel, const char *path_root,
                          char *path_abs, size_t path_abs_len) {
  if (path_rel[0] != '.' || path_rel[1] != '/') {
    gsft_strlcpy(path_abs, path_rel, path_abs_len);
    return;
  }
  do {
    snprintf(path_abs, path_abs_len, "%s%s", path_root, &path_rel[2]);
    path_abs[path_abs_len - 1] = 0x00;
  } while (0);
  return;
}


x86 assembly (clang, -O0):
<gsft_file_rel_to_abs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1159 <gsft_file_rel_to_abs+0x39>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
je     116f <gsft_file_rel_to_abs+0x4f>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <gsft_strlcpy@plt>
jmp    11a9 <gsft_file_rel_to_abs+0x89>
jmp    1174 <gsft_file_rel_to_abs+0x54>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8
add    $0x2,%r8
lea    0xe71(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11a9 <gsft_file_rel_to_abs+0x89>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsft_file_rel_to_abs>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rdi,%r8
cmpb   $0x2e,(%rdi)
jne    1160 <gsft_file_rel_to_abs+0x40>
cmpb   $0x2f,0x1(%r8)
jne    1160 <gsft_file_rel_to_abs+0x40>
mov    %rsi,%rcx
add    $0x2,%r8
lea    0xeb9(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <snprintf@plt>
movb   $0x0,-0x1(%r14,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r8,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <gsft_strlcpy@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
define void @gsft_file_rel_to_abs(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 46
br i1 %13, label %20, label %14
14: ; preds = %4
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 47
br i1 %19, label %20, label %25
20: ; preds = %14, %4
%21 = load i8*, i8** %7
%22 = load i8*, i8** %5
%23 = load i64, i64* %8
%24 = call i32 @gsft_strlcpy(i8* %21, i8* %22, i64 %23)
br label %38
25: ; preds = %14
br label %26
26: ; preds = %25
%27 = load i8*, i8** %7
%28 = load i64, i64* %8
%29 = load i8*, i8** %6
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = call i32 @snprintf(i8* %27, i64 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %31)
%33 = load i8*, i8** %7
%34 = load i64, i64* %8
%35 = sub i64 %34, 1
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 0, i8* %36
br label %37
37: ; preds = %26
br label %38
38: ; preds = %37, %20
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
define void @gsft_file_rel_to_abs(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 46
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 47
br i1 %10, label %13, label %11
11: ; preds = %7, %4
%12 = tail call i32 @gsft_strlcpy(i8* %2, i8* %0, i64 %3)
br label %18
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %0, i64 2
%15 = tail call i32 @snprintf(i8* %2, i64 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %14)
%16 = add i64 %3, -1
%17 = getelementptr inbounds i8, i8* %2, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %13, %11
ret void
}