#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 */
typedef int /*<<< orphan*/ parts;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ printf(char *, char const *, char const *, char *);
scalar_t__ strcmp(char *, char const *);
char *tf_makename(char const *, char const *);
int main(void) {
  static const char *parts[] = {
      "",
      0,
      "/",
      "",
      "",
      "/",
      "/",
      "",
      "/",
      "/",
      "",
      "/",
      "",
      "file",
      "/file",
      "/",
      "file",
      "/file",
      "/",
      "file",
      "/file",
      "/dir",
      "file",
      "/dir/file",
      "/dir",
      "/file",
      "/file",
      "/dir/",
      "file",
      "/dir/file",
      "/dir/",
      "/file",
      "/file",
      "/dir/",
      "/file/",
      "/file",
      "dir/",
      "/file/",
      "/file",
      "dir",
      "file",
      "/dir/file",
      "/dir/",
      "/file/",
      "/file",
      "/dir/../newdir",
      "file",
      "/newdir/file",
      "/../newdir",
      "file",
      "/newdir/file",
      "/dir/olddir",
      "..",
      "/dir",
      "/dir/olddir",
      "../newdir",
      "/dir/newdir",
  };
  static int num = sizeof(parts) / sizeof(*parts);
  int i;
  for (i = 0; i < num; i += 3) {
    const char *dir = parts[i];
    const char *file = parts[i + 1];
    const char *expected = parts[i + 2];
    char *buf = tf_makename(dir, file);
    printf("test_makename: dir='%s' filename='%s' => '%s'\n", dir, file, buf);
    assert(strcmp(buf, expected) == 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    0x30b9(%rip),%eax
jge    11fd <main+0xbd>
movslq -0x8(%rbp),%rcx
lea    0x2ee0(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2ec8(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
movslq %eax,%rcx
lea    0x2eb0(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <tf_makename@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xfffffffffffffffd,%rbp
lea    0x2af7(%rip),%r14
nopl   0x0(%rax)
mov    0x18(%r14,%rbp,8),%r13
mov    0x20(%r14,%rbp,8),%r15
mov    0x28(%r14,%rbp,8),%r12
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <tf_makename@plt>
mov    %rax,%rbx
lea    0xecf(%rip),%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %rax,%rcx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
add    $0x3,%rbp
cmp    $0x36,%rbp
jb     1160 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.parts = internal global [57 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0)]
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [5 x i8] c"file\00"
@.str.3 = [6 x i8] c"/file\00"
@.str.4 = [5 x i8] c"/dir\00"
@.str.5 = [10 x i8] c"/dir/file\00"
@.str.6 = [6 x i8] c"/dir/\00"
@.str.7 = [7 x i8] c"/file/\00"
@.str.8 = [5 x i8] c"dir/\00"
@.str.9 = [4 x i8] c"dir\00"
@.str.10 = [15 x i8] c"/dir/../newdir\00"
@.str.11 = [13 x i8] c"/newdir/file\00"
@.str.12 = [11 x i8] c"/../newdir\00"
@.str.13 = [12 x i8] c"/dir/olddir\00"
@.str.14 = [3 x i8] c"..\00"
@.str.15 = [10 x i8] c"../newdir\00"
@.str.16 = [12 x i8] c"/dir/newdir\00"
@main.num = internal global i32 57
@.str.17 = [47 x i8] c"test_makename: dir='%s' filename='%s' => '%s'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %39, %0
%8 = load i32, i32* %2
%9 = load i32, i32* @main.num
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %42
11: ; preds = %7
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [57 x i8*], [57 x i8*]* @main.parts, i64 0, i64 %13
%15 = load i8*, i8** %14
store i8* %15, i8** %3
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [57 x i8*], [57 x i8*]* @main.parts, i64 0, i64 %18
%20 = load i8*, i8** %19
store i8* %20, i8** %4
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [57 x i8*], [57 x i8*]* @main.parts, i64 0, i64 %23
%25 = load i8*, i8** %24
store i8* %25, i8** %5
%26 = load i8*, i8** %3
%27 = load i8*, i8** %4
%28 = call i8* @tf_makename(i8* %26, i8* %27)
store i8* %28, i8** %6
%29 = load i8*, i8** %3
%30 = load i8*, i8** %4
%31 = load i8*, i8** %6
%32 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.17, i64 0, i64 0), i8* %29, i8* %30, i8* %31)
%33 = load i8*, i8** %6
%34 = load i8*, i8** %5
%35 = call i64 @strcmp(i8* %33, i8* %34)
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
br label %39
39: ; preds = %11
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 3
store i32 %41, i32* %2
br label %7
42: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@main.parts = internal unnamed_addr constant [57 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0)]
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [5 x i8] c"file\00"
@.str.3 = [6 x i8] c"/file\00"
@.str.4 = [5 x i8] c"/dir\00"
@.str.5 = [10 x i8] c"/dir/file\00"
@.str.6 = [6 x i8] c"/dir/\00"
@.str.7 = [7 x i8] c"/file/\00"
@.str.8 = [5 x i8] c"dir/\00"
@.str.9 = [4 x i8] c"dir\00"
@.str.10 = [15 x i8] c"/dir/../newdir\00"
@.str.11 = [13 x i8] c"/newdir/file\00"
@.str.12 = [11 x i8] c"/../newdir\00"
@.str.13 = [12 x i8] c"/dir/olddir\00"
@.str.14 = [3 x i8] c"..\00"
@.str.15 = [10 x i8] c"../newdir\00"
@.str.16 = [12 x i8] c"/dir/newdir\00"
@.str.17 = [47 x i8] c"test_makename: dir='%s' filename='%s' => '%s'\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %17, %1 ]
%3 = getelementptr inbounds [57 x i8*], [57 x i8*]* @main.parts, i64 0, i64 %2
%4 = load i8*, i8** %3
%5 = add nuw nsw i64 %2, 1
%6 = getelementptr inbounds [57 x i8*], [57 x i8*]* @main.parts, i64 0, i64 %5
%7 = load i8*, i8** %6
%8 = add nuw nsw i64 %2, 2
%9 = getelementptr inbounds [57 x i8*], [57 x i8*]* @main.parts, i64 0, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i8* @tf_makename(i8* %4, i8* %7)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.17, i64 0, i64 0), i8* %4, i8* %7, i8* %11)
%13 = tail call i64 @strcmp(i8* %11, i8* %10)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = add nuw nsw i64 %2, 3
%18 = icmp ult i64 %2, 54
br i1 %18, label %1, label %19
19: ; preds = %1
ret i32 0
}