#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*/ sprintf(char *, char *, char const *, char *, char const *,
                           char *, char const *);
int strlen(char const *);
char *FileName(const char *dirname, const char *prefix, const char *name) {
  char *filename =
      (char *)malloc((dirname ? strlen(dirname) : 0) + 1 +
                     (prefix ? strlen(prefix) : 0) + 1 + strlen(name) + 1);
  sprintf(filename, "%s%s%s%s%s", dirname ? dirname : "", dirname ? "/" : "",
          prefix ? prefix : "", prefix ? "-" : "", name);
  return (filename);
}


x86 assembly (clang, -O0):
<FileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1160 <FileName+0x30>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
jmp    116a <FileName+0x3a>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    116a <FileName+0x3a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118f <FileName+0x5f>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    1199 <FileName+0x69>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    1199 <FileName+0x69>
mov    -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x3c(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11e1 <FileName+0xb1>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    11f1 <FileName+0xc1>
lea    0xe26(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    11f1 <FileName+0xc1>
mov    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xe0a(%rip),%rax
lea    0xe00(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     122f <FileName+0xff>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    123f <FileName+0x10f>
lea    0xdd8(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    123f <FileName+0x10f>
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%rdx
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%r8
mov    -0x10(%rbp),%rsi
lea    0xdb4(%rip),%r9
lea    0xdac(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%r9
mov    -0x18(%rbp),%rax
lea    0xd8c(%rip),%rsi
mov    %rax,(%rsp)
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileName>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     1158 <FileName+0x28>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
add    $0x3,%ebp
jmp    115d <FileName+0x2d>
mov    $0x3,%ebp
lea    0xeaa(%rip),%r13
test   %r14,%r14
je     117a <FileName+0x4a>
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0xe95(%rip),%r12
jmp    1182 <FileName+0x52>
xor    %eax,%eax
mov    %r13,%r12
mov    %r13,%r14
add    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
test   %rbx,%rbx
cmove  %r13,%rbx
mov    %rax,%rbp
lea    0xe65(%rip),%rcx
cmove  %r13,%rcx
mov    %r15,(%rsp)
lea    0xe4b(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r14,%r8
mov    %r12,%r9
call   1050 <sprintf@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s%s%s%s%s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c"-\00"
define i8* @FileName(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
br label %14
13: ; preds = %3
br label %14
14: ; preds = %13, %10
%15 = phi i32 [ %12, %10 ], [ 0, %13 ]
%16 = add nsw i32 %15, 1
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* %20)
br label %23
22: ; preds = %14
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %21, %19 ], [ 0, %22 ]
%25 = add nsw i32 %16, %24
%26 = add nsw i32 %25, 1
%27 = load i8*, i8** %6
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %26, %28
%30 = add nsw i32 %29, 1
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = load i8*, i8** %4
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %38
36: ; preds = %23
%37 = load i8*, i8** %4
br label %39
38: ; preds = %23
br label %39
39: ; preds = %38, %36
%40 = phi i8* [ %37, %36 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %38 ]
%41 = load i8*, i8** %4
%42 = icmp ne i8* %41, null
%43 = zext i1 %42 to i64
%44 = select i1 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%45 = load i8*, i8** %5
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %49
47: ; preds = %39
%48 = load i8*, i8** %5
br label %50
49: ; preds = %39
br label %50
50: ; preds = %49, %47
%51 = phi i8* [ %48, %47 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %49 ]
%52 = load i8*, i8** %5
%53 = icmp ne i8* %52, null
%54 = zext i1 %53 to i64
%55 = select i1 %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%56 = load i8*, i8** %6
%57 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %40, i8* %44, i8* %51, i8* %55, i8* %56)
%58 = load i8*, i8** %7
ret i8* %58
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s%s%s%s%s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c"-\00"
define i8* @FileName(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %0)
%7 = add i32 %6, 3
br label %8
8: ; preds = %3, %5
%9 = phi i32 [ %7, %5 ], [ 3, %3 ]
%10 = icmp eq i8* %1, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* %1)
br label %13
13: ; preds = %8, %11
%14 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %11 ]
%15 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %8 ], [ %1, %11 ]
%16 = phi i32 [ 0, %8 ], [ %12, %11 ]
%17 = tail call i32 @strlen(i8* %2)
%18 = add i32 %9, %16
%19 = add i32 %18, %17
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
%22 = select i1 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %0
%23 = select i1 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%24 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23, i8* %15, i8* %14, i8* %2)
ret i8* %21
}