#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 *local_getFileStem(char const *, char *);
int /*<<< orphan*/ xfree(char *);
char *xstrmerge(char *, char const *);
char *local_createFileNameHeader(const char *pathToFiles,
                                 const char *fileNameSuffix) {
  char *fileName;
  char *fileStem;
  fileStem = local_getFileStem(pathToFiles, "PMcrd");
  if (fileNameSuffix == NULL)
    fileName = xstrmerge(fileStem, ".DAT");
  else
    fileName = xstrmerge(fileStem, fileNameSuffix);
  xfree(fileStem);
  return fileName;
}


x86 assembly (clang, -O0):
<local_createFileNameHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <local_getFileStem@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1178 <local_createFileNameHeader+0x48>
mov    -0x20(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <xstrmerge@plt>
mov    %rax,-0x18(%rbp)
jmp    1189 <local_createFileNameHeader+0x59>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <xstrmerge@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <xfree@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_createFileNameHeader>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xec2(%rip),%rsi
call   1050 <local_getFileStem@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1153 <local_createFileNameHeader+0x23>
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    115d <local_createFileNameHeader+0x2d>
lea    0xeac(%rip),%rsi
mov    %r14,%rdi
call   1040 <xstrmerge@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <xfree@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"PMcrd\00"
@.str.1 = [5 x i8] c".DAT\00"
define i8* @local_createFileNameHeader(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @local_getFileStem(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %6
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %6
%13 = call i8* @xstrmerge(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %5
br label %18
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = load i8*, i8** %4
%17 = call i8* @xstrmerge(i8* %15, i8* %16)
store i8* %17, i8** %5
br label %18
18: ; preds = %14, %11
%19 = load i8*, i8** %6
%20 = call i32 @xfree(i8* %19)
%21 = load i8*, i8** %5
ret i8* %21
}

LLVM IR (-O2):
@.str = [6 x i8] c"PMcrd\00"
@.str.1 = [5 x i8] c".DAT\00"
define i8* @local_createFileNameHeader(i8* %0, i8* %1) {
%3 = tail call i8* @local_getFileStem(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i8* @xstrmerge(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %2
%8 = tail call i8* @xstrmerge(i8* %3, i8* %1)
br label %9
9: ; preds = %7, %5
%10 = phi i8* [ %6, %5 ], [ %8, %7 ]
%11 = tail call i32 @xfree(i8* %3)
ret i8* %10
}