#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__ Malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *wholeName(char *prefix, char *dname) {
  int len;
  char *name;
  if (prefix == NULL || *prefix == '\0') {
    name = (char *)Malloc(strlen(dname) + 1);
    if (name == NULL)
      return NULL;
    strcpy(name, dname);
  } else {
    len = strlen(prefix) + strlen(dname) + 1 + 1;
    name = (char *)Malloc(len);
    if (name == NULL)
      return NULL;
    strcpy(name, prefix);
    name[strlen(prefix)] = '/';
    strcpy(name + strlen(prefix) + 1, dname);
    name[len] = '\0';
  }
  return name;
}


x86 assembly (clang, -O0):
<wholeName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115b <wholeName+0x2b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    119c <wholeName+0x6c>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1030 <Malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118a <wholeName+0x5a>
movq   $0x0,-0x8(%rbp)
jmp    124b <wholeName+0x11b>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1243 <wholeName+0x113>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <Malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e5 <wholeName+0xb5>
movq   $0x0,-0x8(%rbp)
jmp    124b <wholeName+0x11b>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wholeName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
test   %rdi,%rdi
je     11aa <wholeName+0x7a>
mov    %rdi,%r15
cmpb   $0x0,(%rdi)
je     11aa <wholeName+0x7a>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%ebp
add    $0x2,%ebp
mov    %ebp,%edi
call   1030 <Malloc@plt>
test   %rax,%rax
je     11cf <wholeName+0x9f>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x2f,(%rbx,%rax,1)
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
jmp    11d1 <wholeName+0xa1>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1030 <Malloc@plt>
test   %rax,%rax
je     11cf <wholeName+0x9f>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
jmp    11d1 <wholeName+0xa1>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @wholeName(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4, %2
%8 = tail call i32 @strlen(i8* %1)
%9 = add nsw i32 %8, 1
%10 = tail call i64 @Malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = icmp eq i64 %10, 0
br i1 %12, label %35, label %13
13: ; preds = %7
%14 = tail call i32 @strcpy(i8* %11, i8* %1)
br label %35
15: ; preds = %4
%16 = tail call i32 @strlen(i8* %0)
%17 = tail call i32 @strlen(i8* %1)
%18 = add i32 %16, 2
%19 = add i32 %18, %17
%20 = tail call i64 @Malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
%22 = icmp eq i64 %20, 0
br i1 %22, label %35, label %23
23: ; preds = %15
%24 = tail call i32 @strcpy(i8* %21, i8* %0)
%25 = tail call i32 @strlen(i8* %0)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %21, i64 %26
store i8 47, i8* %27
%28 = tail call i32 @strlen(i8* %0)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %21, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = tail call i32 @strcpy(i8* %31, i8* %1)
%33 = sext i32 %19 to i64
%34 = getelementptr inbounds i8, i8* %21, i64 %33
store i8 0, i8* %34
br label %35
35: ; preds = %13, %23, %15, %7
%36 = phi i8* [ null, %7 ], [ null, %15 ], [ %11, %13 ], [ %21, %23 ]
ret i8* %36
}