#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*/ free(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcat_delim(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
void plGetName(const char *dir, const char *subdir, const char *filename,
               char **filespec) {
  int lfilespec;
  if (*filespec != NULL) {
    free((void *)*filespec);
    *filespec = NULL;
  };
  lfilespec = 10;
  lfilespec = strlen(dir) + strlen(subdir) + strlen(filename) + 10;
  *filespec = (char *)malloc(lfilespec);
  strcpy(*filespec, dir);
  if (*subdir != '\0') {
    strcat_delim(*filespec);
    strcat(*filespec, subdir);
  }
  if (*filename != '\0') {
    strcat_delim(*filespec);
    strcat(*filespec, filename);
  }
}


x86 assembly (clang, -O0):
<plGetName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     119d <plGetName+0x3d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0xa,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
add    $0xa,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1227 <plGetName+0xc7>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1060 <strcat_delim@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1253 <plGetName+0xf3>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1060 <strcat_delim@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plGetName>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rcx),%rdi
test   %rdi,%rdi
je     118b <plGetName+0x2b>
call   1030 <free@plt>
movq   $0x0,(%rbx)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %r13d,%ebp
lea    (%rax,%rbp,1),%edi
add    $0xa,%edi
call   1070 <malloc@plt>
mov    %rax,(%rbx)
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
cmpb   $0x0,(%r15)
je     11dd <plGetName+0x7d>
mov    (%rbx),%rdi
call   1060 <strcat_delim@plt>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
cmpb   $0x0,(%r14)
je     1204 <plGetName+0xa4>
mov    (%rbx),%rdi
call   1060 <strcat_delim@plt>
mov    (%rbx),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <strcat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @plGetName(i8* %0, i8* %1, i8* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8** %3, i8*** %8
%10 = load i8**, i8*** %8
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %4
%14 = load i8**, i8*** %8
%15 = load i8*, i8** %14
%16 = call i32 @free(i8* %15)
%17 = load i8**, i8*** %8
store i8* null, i8** %17
br label %18
18: ; preds = %13, %4
store i32 10, i32* %9
%19 = load i8*, i8** %5
%20 = call i32 @strlen(i8* %19)
%21 = load i8*, i8** %6
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %20, %22
%24 = load i8*, i8** %7
%25 = call i32 @strlen(i8* %24)
%26 = add nsw i32 %23, %25
%27 = add nsw i32 %26, 10
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
%31 = load i8**, i8*** %8
store i8* %30, i8** %31
%32 = load i8**, i8*** %8
%33 = load i8*, i8** %32
%34 = load i8*, i8** %5
%35 = call i32 @strcpy(i8* %33, i8* %34)
%36 = load i8*, i8** %6
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %18
%41 = load i8**, i8*** %8
%42 = load i8*, i8** %41
%43 = call i32 @strcat_delim(i8* %42)
%44 = load i8**, i8*** %8
%45 = load i8*, i8** %44
%46 = load i8*, i8** %6
%47 = call i32 @strcat(i8* %45, i8* %46)
br label %48
48: ; preds = %40, %18
%49 = load i8*, i8** %7
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %48
%54 = load i8**, i8*** %8
%55 = load i8*, i8** %54
%56 = call i32 @strcat_delim(i8* %55)
%57 = load i8**, i8*** %8
%58 = load i8*, i8** %57
%59 = load i8*, i8** %7
%60 = call i32 @strcat(i8* %58, i8* %59)
br label %61
61: ; preds = %53, %48
ret void
}

LLVM IR (-O2):
define void @plGetName(i8* %0, i8* %1, i8* %2, i8** nocapture %3) {
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @free(i8* %5)
store i8* null, i8** %3
br label %9
9: ; preds = %7, %4
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i32 @strlen(i8* %1)
%12 = tail call i32 @strlen(i8* %2)
%13 = add i32 %10, 10
%14 = add i32 %13, %11
%15 = add i32 %14, %12
%16 = tail call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %3
%18 = tail call i32 @strcpy(i8* %17, i8* %0)
%19 = load i8, i8* %1
%20 = icmp eq i8 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %9
%22 = load i8*, i8** %3
%23 = tail call i32 @strcat_delim(i8* %22)
%24 = load i8*, i8** %3
%25 = tail call i32 @strcat(i8* %24, i8* %1)
br label %26
26: ; preds = %21, %9
%27 = load i8, i8* %2
%28 = icmp eq i8 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = tail call i32 @strcat_delim(i8* %30)
%32 = load i8*, i8** %3
%33 = tail call i32 @strcat(i8* %32, i8* %2)
br label %34
34: ; preds = %29, %26
ret void
}