#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 */
char *malloc(size_t);
int /*<<< orphan*/ strcpy(char *, char const *);
size_t strlen(char const *);
char *path_name(const char *dir, const char *name) {
  size_t n = strlen(dir);
  char *ret = malloc(n + 14);
  strcpy(ret, dir);
  ret[n++] = '>';
  int i;
  for (i = 0; i < 11; i++) {
    if (name[i] != ' ') {
      if (i == 8)
        ret[n++] = '.';
      ret[n++] = name[i];
    }
  }
  ret[n] = 0;
  return ret;
}


x86 assembly (clang, -O0):
<path_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0xe,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
movb   $0x3e,(%rax,%rcx,1)
movl   $0x0,-0x24(%rbp)
cmpl   $0xb,-0x24(%rbp)
jge    11fd <path_name+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11ea <path_name+0xba>
cmpl   $0x8,-0x24(%rbp)
jne    11c9 <path_name+0x99>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
movb   $0x2e,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x18(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    11ef <path_name+0xbf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1189 <path_name+0x59>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %rax,%rbx
lea    0xe(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
movb   $0x3e,(%r15,%rbx,1)
add    $0x1,%rbx
mov    $0xfffffffffffffff5,%rax
jmp    117d <path_name+0x4d>
nop
mov    %cl,(%r15,%rbx,1)
add    $0x1,%rbx
inc    %rax
je     1199 <path_name+0x69>
movzbl 0xb(%r14,%rax,1),%ecx
cmp    $0x20,%cl
je     1178 <path_name+0x48>
cmp    $0xfffffffffffffffd,%rax
jne    1170 <path_name+0x40>
movb   $0x2e,(%r15,%rbx,1)
add    $0x1,%rbx
jmp    1170 <path_name+0x40>
movb   $0x0,(%r15,%rbx,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @path_name(i8* %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add i64 %3, 14
%5 = tail call i8* @malloc(i64 %4)
%6 = tail call i32 @strcpy(i8* %5, i8* %0)
%7 = add i64 %3, 1
%8 = getelementptr inbounds i8, i8* %5, i64 %3
store i8 62, i8* %8
br label %9
9: ; preds = %2, %24
%10 = phi i64 [ 0, %2 ], [ %26, %24 ]
%11 = phi i64 [ %7, %2 ], [ %25, %24 ]
%12 = getelementptr inbounds i8, i8* %1, i64 %10
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
br i1 %14, label %24, label %15
15: ; preds = %9
%16 = icmp eq i64 %10, 8
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = add i64 %11, 1
%19 = getelementptr inbounds i8, i8* %5, i64 %11
store i8 46, i8* %19
br label %20
20: ; preds = %17, %15
%21 = phi i64 [ %18, %17 ], [ %11, %15 ]
%22 = add i64 %21, 1
%23 = getelementptr inbounds i8, i8* %5, i64 %21
store i8 %13, i8* %23
br label %24
24: ; preds = %9, %20
%25 = phi i64 [ %22, %20 ], [ %11, %9 ]
%26 = add nuw nsw i64 %10, 1
%27 = icmp eq i64 %26, 11
br i1 %27, label %28, label %9
28: ; preds = %24
%29 = getelementptr inbounds i8, i8* %5, i64 %25
store i8 0, i8* %29
ret i8* %5
}