#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__ IsFullName(char const *);
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
void GetFullPath(char *dName, const char *sName) {
  char Buffer[256];
  if (IsFullName(sName)) {
    strcpy(dName, sName);
    return;
  }
  if (getcwd(Buffer, 256) == NULL) {
    perror("getcwd error");
    return;
  }
  sprintf(dName, "%s/%s", Buffer, sName);
}


x86 assembly (clang, -O0):
<GetFullPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <IsFullName@plt>
cmp    $0x0,%rax
je     1188 <GetFullPath+0x38>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11cf <GetFullPath+0x7f>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1050 <getcwd@plt>
cmp    $0x0,%rax
jne    11b4 <GetFullPath+0x64>
lea    0xe56(%rip),%rdi
call   1060 <perror@plt>
jmp    11cf <GetFullPath+0x7f>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe43(%rip),%rsi
call   1070 <sprintf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFullPath>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <IsFullName@plt>
test   %rax,%rax
je     1182 <GetFullPath+0x32>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x108,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
call   1050 <getcwd@plt>
test   %rax,%rax
je     11b4 <GetFullPath+0x64>
lea    0xe72(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1070 <sprintf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe45(%rip),%rdi
call   1060 <perror@plt>
jmp    11a9 <GetFullPath+0x59>

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

LLVM IR (-O2):
@.str = [13 x i8] c"getcwd error\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define void @GetFullPath(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @IsFullName(i8* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @strcpy(i8* %0, i8* %1)
br label %16
9: ; preds = %2
%10 = call i32* @getcwd(i8* %4, i32 256)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %1)
br label %16
16: ; preds = %14, %12, %7
ret void
}