#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 */
int /*<<< orphan*/ assert(int);
char *local_getFileStem(char const *, char *);
int local_getRequiredDigits(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, int);
int strlen(char *);
int /*<<< orphan*/ xfree(char *);
void *xmalloc(int);
char *xstrmerge(char *, char const *);
char **local_createFileNamesData(const char *pathToFiles,
                                 const char *fileNameSuffix, int numFiles) {
  char **fileNames;
  char *fileStem;
  char *thisFileStem;
  int digits;
  fileStem = local_getFileStem(pathToFiles, "PMcrs");
  thisFileStem = xmalloc(sizeof(char) * strlen(fileStem) + 7 + 1);
  digits = local_getRequiredDigits(numFiles);
  assert(numFiles > 0 && numFiles < 10000000);
  fileNames = xmalloc(sizeof(char *) * numFiles);
  for (int i = 0; i < numFiles; i++) {
    sprintf(thisFileStem, "%s%0*i", fileStem, digits, i);
    if (fileNameSuffix == NULL)
      fileNames[i] = xstrmerge(thisFileStem, ".DAT");
    else
      fileNames[i] = xstrmerge(thisFileStem, fileNameSuffix);
  }
  xfree(thisFileStem);
  xfree(fileStem);
  return fileNames;
}


x86 assembly (clang, -O0):
<local_createFileNamesData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1080 <local_getFileStem@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x7,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1060 <xmalloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <local_getRequiredDigits@plt>
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x39(%rbp)
jle    11f0 <local_createFileNamesData+0x70>
cmpl   $0x989680,-0x14(%rbp)
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    129c <local_createFileNamesData+0x11c>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
lea    0xdcd(%rip),%rsi
call   10a0 <sprintf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    126d <local_createFileNamesData+0xed>
mov    -0x30(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1050 <xstrmerge@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    1289 <local_createFileNamesData+0x109>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <xstrmerge@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    128e <local_createFileNamesData+0x10e>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1217 <local_createFileNamesData+0x97>
mov    -0x30(%rbp),%rdi
call   1040 <xfree@plt>
mov    -0x28(%rbp),%rdi
call   1040 <xfree@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_createFileNamesData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
lea    0xe69(%rip),%rsi
call   1080 <local_getFileStem@plt>
mov    %rax,(%rsp)
mov    %rax,%rdi
call   1030 <strlen@plt>
lea    0x8(%rax),%edi
call   1060 <xmalloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1090 <local_getRequiredDigits@plt>
mov    %eax,%r12d
lea    -0x1(%rbp),%eax
xor    %edi,%edi
cmp    $0x98967f,%eax
setb   %dil
call   1070 <assert@plt>
lea    0x0(,%rbp,8),%edi
call   1060 <xmalloc@plt>
mov    %rax,%r13
test   %ebp,%ebp
jle    1230 <local_createFileNamesData+0xb0>
mov    %ebp,%r14d
xor    %ebp,%ebp
jmp    1206 <local_createFileNamesData+0x86>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rsi
call   1050 <xstrmerge@plt>
mov    %rax,0x0(%r13,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
je     1230 <local_createFileNamesData+0xb0>
mov    %rbx,%rdi
lea    0xdf6(%rip),%rsi
mov    (%rsp),%rdx
mov    %r12d,%ecx
mov    %ebp,%r8d
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
test   %r15,%r15
jne    11f0 <local_createFileNamesData+0x70>
lea    0xddf(%rip),%rsi
jmp    11f3 <local_createFileNamesData+0x73>
mov    %rbx,%rdi
call   1040 <xfree@plt>
mov    (%rsp),%rdi
call   1040 <xfree@plt>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"PMcrs\00"
@.str.1 = [7 x i8] c"%s%0*i\00"
@.str.2 = [5 x i8] c".DAT\00"
define i8** @local_createFileNamesData(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%12 = load i8*, i8** %4
%13 = call i8* @local_getFileStem(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = mul i64 1, %16
%18 = add i64 %17, 7
%19 = add i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i8* @xmalloc(i32 %20)
store i8* %21, i8** %9
%22 = load i32, i32* %6
%23 = call i32 @local_getRequiredDigits(i32 %22)
store i32 %23, i32* %10
%24 = load i32, i32* %6
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 10000000
br label %29
29: ; preds = %26, %3
%30 = phi i1 [ false, %3 ], [ %28, %26 ]
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = mul i64 8, %34
%36 = trunc i64 %35 to i32
%37 = call i8* @xmalloc(i32 %36)
%38 = bitcast i8* %37 to i8**
store i8** %38, i8*** %7
store i32 0, i32* %11
br label %39
39: ; preds = %67, %29
%40 = load i32, i32* %11
%41 = load i32, i32* %6
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %70
43: ; preds = %39
%44 = load i8*, i8** %9
%45 = load i8*, i8** %8
%46 = load i32, i32* %10
%47 = load i32, i32* %11
%48 = call i32 @sprintf(i8* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %45, i32 %46, i32 %47)
%49 = load i8*, i8** %5
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %58
51: ; preds = %43
%52 = load i8*, i8** %9
%53 = call i8* @xstrmerge(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%54 = load i8**, i8*** %7
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
store i8* %53, i8** %57
br label %66
58: ; preds = %43
%59 = load i8*, i8** %9
%60 = load i8*, i8** %5
%61 = call i8* @xstrmerge(i8* %59, i8* %60)
%62 = load i8**, i8*** %7
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
store i8* %61, i8** %65
br label %66
66: ; preds = %58, %51
br label %67
67: ; preds = %66
%68 = load i32, i32* %11
%69 = add nsw i32 %68, 1
store i32 %69, i32* %11
br label %39
70: ; preds = %39
%71 = load i8*, i8** %9
%72 = call i32 @xfree(i8* %71)
%73 = load i8*, i8** %8
%74 = call i32 @xfree(i8* %73)
%75 = load i8**, i8*** %7
ret i8** %75
}

LLVM IR (-O2):
@.str = [6 x i8] c"PMcrs\00"
@.str.1 = [7 x i8] c"%s%0*i\00"
@.str.2 = [5 x i8] c".DAT\00"
define i8** @local_createFileNamesData(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @local_getFileStem(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %4)
%6 = add i32 %5, 8
%7 = tail call i8* @xmalloc(i32 %6)
%8 = tail call i32 @local_getRequiredDigits(i32 %2)
%9 = add i32 %2, -1
%10 = icmp ult i32 %9, 9999999
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = shl i32 %2, 3
%14 = tail call i8* @xmalloc(i32 %13)
%15 = bitcast i8* %14 to i8**
%16 = icmp sgt i32 %2, 0
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = icmp eq i8* %1, null
%19 = zext i32 %2 to i64
br label %23
20: ; preds = %31, %3
%21 = tail call i32 @xfree(i8* %7)
%22 = tail call i32 @xfree(i8* %4)
ret i8** %15
23: ; preds = %17, %31
%24 = phi i64 [ 0, %17 ], [ %34, %31 ]
%25 = trunc i64 %24 to i32
%26 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %8, i32 %25)
br i1 %18, label %27, label %29
27: ; preds = %23
%28 = tail call i8* @xstrmerge(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %31
29: ; preds = %23
%30 = tail call i8* @xstrmerge(i8* %7, i8* %1)
br label %31
31: ; preds = %27, %29
%32 = phi i8* [ %28, %27 ], [ %30, %29 ]
%33 = getelementptr inbounds i8*, i8** %15, i64 %24
store i8* %32, i8** %33
%34 = add nuw nsw i64 %24, 1
%35 = icmp eq i64 %34, %19
br i1 %35, label %20, label %23
}