#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__ isAbsolutePath(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void adjustPath(char *dir, char *path, char *dst) {
  if (isAbsolutePath(path))
    strcpy(dst, path);
  else {
    if (strlen(dir) > 0) {
      strcpy(dst, dir);
      strcat(dst, "/");
      strcat(dst, path);
    } else
      strcpy(dst, path);
  }
}


x86 assembly (clang, -O0):
<adjustPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <isAbsolutePath@plt>
cmp    $0x0,%rax
je     1179 <adjustPath+0x39>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11cd <adjustPath+0x8d>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    11bb <adjustPath+0x7b>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
jmp    11c8 <adjustPath+0x88>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11cd <adjustPath+0x8d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjustPath>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1050 <isAbsolutePath@plt>
test   %rax,%rax
je     116b <adjustPath+0x2b>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    115b <adjustPath+0x1b>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe76(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <strcat@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define void @adjustPath(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = call i64 @isAbsolutePath(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i8*, i8** %6
%12 = load i8*, i8** %5
%13 = call i32 @strcpy(i8* %11, i8* %12)
br label %32
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i64 @strlen(i8* %15)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i8*, i8** %4
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = load i8*, i8** %6
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = load i8*, i8** %6
%25 = load i8*, i8** %5
%26 = call i32 @strcat(i8* %24, i8* %25)
br label %31
27: ; preds = %14
%28 = load i8*, i8** %6
%29 = load i8*, i8** %5
%30 = call i32 @strcpy(i8* %28, i8* %29)
br label %31
31: ; preds = %27, %18
br label %32
32: ; preds = %31, %10
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @adjustPath(i8* %0, i8* %1, i8* %2) {
%4 = tail call i64 @isAbsolutePath(i8* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @strcpy(i8* %2, i8* %1)
br label %17
8: ; preds = %3
%9 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i32 @strcpy(i8* %2, i8* %0)
%13 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @strcat(i8* %2, i8* %1)
br label %17
15: ; preds = %8
%16 = tail call i32 @strcpy(i8* %2, i8* %1)
br label %17
17: ; preds = %11, %15, %6
ret void
}