#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 */
struct dirent {
  scalar_t__ d_type;
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ DT_DIR;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int S_IROTH;
int S_IRUSR;
int S_IWOTH;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
int getZVMLogLevel();
size_t getfilesize_fd(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ printstat(long, long, int, char *, char *);
size_t read(int, char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
size_t strlen(char *);
char *strstr(char *, char *);
size_t write(int, char *, size_t);
void newbufferedpack(char *devname, char *dirname) {
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "s"
           " \n",
           "***ZVMLog", 2, "start packing", "OK");
  };
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "s"
           " \n",
           "***ZVMLog", 2, "device to pack (output)", devname);
  };
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "s"
           " \n",
           "***ZVMLog", 2, "path to files", dirname);
  };
  int fdpackfile;
  fdpackfile = open(devname, O_WRONLY | O_CREAT | O_TRUNC,
                    S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
  if (fdpackfile <= 0) {
    printf("*** ZVM Error open packfile (write)%s\n", devname);
    return;
  }
  char *indexpath;
  indexpath = dirname;
  DIR *dir;
  struct dirent *entry;
  dir = opendir(indexpath);
  char *newpath;
  if (!dir)
    printf("*** ZVM Error open DIR %s\n", indexpath);
  int blocksize = 1024 * 64;
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "d"
           " \n",
           "***ZVMLog", 2, "read and write block size", blocksize);
  };
  char *buff = NULL;
  buff = (char *)malloc(blocksize);
  long deltabytes = 0;
  long mainbytes = 0;
  int filecount = 0;
  while ((entry = readdir(dir))) {
    if (entry->d_type != DT_DIR) {
      size_t size;
      size_t bread = 0;
      size_t bwrite;
      size_t bytecount;
      bytecount = 0;
      newpath = (char *)malloc(strlen(entry->d_name) + strlen(indexpath) + 2);
      sprintf(newpath, "%s/%s", indexpath, entry->d_name);
      int fd;
      fd = open(newpath, O_RDONLY);
      size = getfilesize_fd(fd, NULL, 0);
      char tempstr[strlen(newpath) + 12];
      sprintf(tempstr, "%10zu%s%10zu", strlen(newpath), newpath, size);
      bwrite = write(fdpackfile, tempstr, strlen(tempstr));
      if (size > 0) {
        while ((bread = read(fd, buff, blocksize)) > 0) {
          bytecount += bread;
          bwrite = write(fdpackfile, buff, bread);
        }
      } else
        bytecount = 0;
      close(fd);
      if (getZVMLogLevel() >= 2) {
        printf("%s [LogLevel=%d] [%s], \t%"
               "s"
               " \n",
               "***ZVMLog", 2, "packed file name", newpath);
      };
      if (getZVMLogLevel() >= 2) {
        printf("%s [LogLevel=%d] [%s], \t%"
               "d"
               " \n",
               "***ZVMLog", 2, "packed file size", size);
      };
      char *indexnameptr = NULL;
      if ((indexnameptr = strstr(newpath, "deltaindex")) != NULL)
        deltabytes += size;
      indexnameptr = NULL;
      if ((indexnameptr = strstr(newpath, "mainindex")) != NULL)
        mainbytes += size;
      filecount++;
    }
  }
  free(buff);
  close(fdpackfile);
  printstat(mainbytes, deltabytes, filecount, (char *)"mainindex",
            (char *)"deltaindex");
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "s"
           " \n",
           "***ZVMLog", 2, "packed all files", "OK");
  };
}


x86 assembly (clang, -O0):
<newbufferedpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     123b <newbufferedpack+0x4b>
lea    0xde6(%rip),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x2,%edx
lea    0xdfa(%rip),%rcx
lea    0xe01(%rip),%r8
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1270 <newbufferedpack+0x80>
mov    -0x8(%rbp),%r8
lea    0xdaa(%rip),%rdi
lea    0xdc0(%rip),%rsi
mov    $0x2,%edx
lea    0xdcf(%rip),%rcx
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     12a5 <newbufferedpack+0xb5>
mov    -0x10(%rbp),%r8
lea    0xd75(%rip),%rdi
lea    0xd8b(%rip),%rsi
mov    $0x2,%edx
lea    0xdb2(%rip),%rcx
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
mov    0x2d3f(%rip),%rax
or     (%rax),%esi
mov    0x2d2e(%rip),%rax
or     (%rax),%esi
mov    0x2ced(%rip),%rax
mov    (%rax),%edx
mov    0x2cc4(%rip),%rax
or     (%rax),%edx
mov    0x2cd3(%rip),%rax
or     (%rax),%edx
mov    0x2cea(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1313 <newbufferedpack+0x123>
mov    -0x8(%rbp),%rsi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    16de <newbufferedpack+0x4ee>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1345 <newbufferedpack+0x155>
mov    -0x20(%rbp),%rsi
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x10000,-0x3c(%rbp)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1381 <newbufferedpack+0x191>
mov    -0x3c(%rbp),%r8d
lea    0xd39(%rip),%rdi
lea    0xcaf(%rip),%rsi
mov    $0x2,%edx
lea    0xd43(%rip),%rcx
mov    $0x0,%al
call   1090 <printf@plt>
movq   $0x0,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
call   10d0 <malloc@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x28(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1677 <newbufferedpack+0x487>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    0x2bef(%rip),%rcx
cmp    (%rcx),%rax
je     1672 <newbufferedpack+0x482>
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x80(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <strlen@plt>
mov    %rax,-0xc0(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
mov    %ecx,%edx
mov    %eax,%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x2(%rax,%rcx,1),%edi
call   10d0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xc9a(%rip),%rsi
xor    %eax,%eax
mov    %eax,-0xb0(%rbp)
mov    %al,-0xb1(%rbp)
call   10f0 <sprintf@plt>
mov    -0xb1(%rbp),%al
mov    -0x38(%rbp),%rdi
mov    0x2b77(%rip),%rcx
mov    (%rcx),%esi
call   10e0 <open@plt>
mov    -0xb0(%rbp),%edx
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%edi
mov    %edx,%esi
call   1040 <getfilesize_fd@plt>
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rdx
mov    %rdx,%rax
add    $0xc,%rax
mov    %rsp,%rcx
mov    %rcx,-0x90(%rbp)
add    $0x1b,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x98(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %rax,%rdx
mov    -0x38(%rbp),%rcx
mov    -0x68(%rbp),%r8
lea    0xbfa(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,-0xac(%rbp)
call   1070 <strlen@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    %rax,%rdx
call   1050 <write@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x68(%rbp)
jbe    1572 <newbufferedpack+0x382>
jmp    1528 <newbufferedpack+0x338>
mov    -0x84(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   10b0 <read@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jbe    156d <newbufferedpack+0x37d>
mov    -0x70(%rbp),%rax
add    -0x80(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x70(%rbp),%rdx
call   1050 <write@plt>
mov    %rax,-0x78(%rbp)
jmp    1528 <newbufferedpack+0x338>
jmp    157a <newbufferedpack+0x38a>
movq   $0x0,-0x80(%rbp)
mov    -0x84(%rbp),%edi
call   10a0 <close@plt>
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     15ba <newbufferedpack+0x3ca>
mov    -0x38(%rbp),%r8
lea    0xa60(%rip),%rdi
lea    0xa76(%rip),%rsi
mov    $0x2,%edx
lea    0xb37(%rip),%rcx
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     15ef <newbufferedpack+0x3ff>
mov    -0x68(%rbp),%r8
lea    0xacb(%rip),%rdi
lea    0xa41(%rip),%rsi
mov    $0x2,%edx
lea    0xb13(%rip),%rcx
mov    $0x0,%al
call   1090 <printf@plt>
movq   $0x0,-0xa0(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xb07(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0xa0(%rbp)
cmp    $0x0,%rax
je     1627 <newbufferedpack+0x437>
mov    -0x68(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
movq   $0x0,-0xa0(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xada(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0xa0(%rbp)
cmp    $0x0,%rax
je     165f <newbufferedpack+0x46f>
mov    -0x68(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,%rsp
jmp    13ac <newbufferedpack+0x1bc>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x5c(%rbp),%edx
lea    0xa7d(%rip),%rcx
lea    0xa6b(%rip),%r8
call   1080 <printstat@plt>
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     16de <newbufferedpack+0x4ee>
lea    0x943(%rip),%rdi
lea    0x959(%rip),%rsi
mov    $0x2,%edx
lea    0xa51(%rip),%rcx
lea    0x95e(%rip),%r8
mov    $0x0,%al
call   1090 <printf@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newbufferedpack>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,-0x38(%rbp)
mov    %rdi,%rbx
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     123c <newbufferedpack+0x4c>
lea    0xde5(%rip),%rdi
lea    0xdfb(%rip),%rsi
lea    0xdfe(%rip),%rcx
lea    0xe05(%rip),%r8
mov    $0x2,%edx
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     126c <newbufferedpack+0x7c>
lea    0xdb1(%rip),%rdi
lea    0xdc7(%rip),%rsi
lea    0xddb(%rip),%rcx
mov    $0x2,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     129d <newbufferedpack+0xad>
lea    0xd81(%rip),%rdi
lea    0xd97(%rip),%rsi
lea    0xdc3(%rip),%rcx
mov    $0x2,%edx
mov    -0x38(%rbp),%r8
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2cfc(%rip),%rax
mov    0x2d4d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d3a(%rip),%rax
or     (%rax),%esi
mov    0x2cf9(%rip),%rax
mov    0x2cd2(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cdf(%rip),%rax
or     (%rax),%edx
mov    0x2cf6(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   10e0 <open@plt>
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
jle    1555 <newbufferedpack+0x365>
mov    -0x38(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1314 <newbufferedpack+0x124>
lea    0xd7c(%rip),%rdi
mov    -0x38(%rbp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %r15d,%r15d
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     134a <newbufferedpack+0x15a>
lea    0xd76(%rip),%rdi
lea    0xcec(%rip),%rsi
lea    0xd85(%rip),%rcx
mov    $0x2,%edx
mov    $0x10000,%r8d
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x10000,%edi
call   10d0 <malloc@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1574 <newbufferedpack+0x384>
mov    %rax,%rbx
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
xor    %r12d,%r12d
xor    %r15d,%r15d
mov    %r14,-0x48(%rbp)
jmp    13d7 <newbufferedpack+0x1e7>
nopl   (%rax)
mov    %r12,%rdi
lea    0xd82(%rip),%rsi
call   1110 <strstr@plt>
test   %rax,%rax
cmovne %r14,%rax
add    %rax,-0x40(%rbp)
mov    %r12,%rdi
lea    0xd73(%rip),%rsi
call   1110 <strstr@plt>
test   %rax,%rax
cmove  %rax,%r14
mov    -0x58(%rbp),%r12
add    %r14,%r12
add    $0x1,%r15d
mov    -0x50(%rbp),%rsp
mov    -0x48(%rbp),%r14
mov    %r14,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     157d <newbufferedpack+0x38d>
mov    (%rbx),%rax
mov    0x2bdf(%rip),%rcx
cmp    (%rcx),%rax
je     13c3 <newbufferedpack+0x1d3>
mov    %r12,-0x58(%rbp)
mov    %r15,-0x60(%rbp)
mov    0x8(%rbx),%rdi
call   1070 <strlen@plt>
mov    %rax,%r14
mov    -0x38(%rbp),%r15
mov    %r15,%rdi
call   1070 <strlen@plt>
lea    (%rax,%r14,1),%edi
add    $0x2,%edi
call   10d0 <malloc@plt>
mov    %rax,%r12
mov    0x8(%rbx),%rcx
mov    %rax,%rdi
lea    0xcb4(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    0x2ba4(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   10e0 <open@plt>
mov    %eax,%r15d
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <getfilesize_fd@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %rsp,-0x50(%rbp)
add    $0x1b,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %rbx,%rdi
lea    0xc5d(%rip),%rsi
mov    %rax,%rdx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
mov    %edi,%ebx
mov    %rax,%rdx
call   1050 <write@plt>
test   %r14,%r14
je     14e0 <newbufferedpack+0x2f0>
nopl   (%rax)
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x10000,%edx
call   10b0 <read@plt>
test   %rax,%rax
je     14e0 <newbufferedpack+0x2f0>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %rax,%rdx
call   1050 <write@plt>
jmp    14b0 <newbufferedpack+0x2c0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
call   10a0 <close@plt>
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1518 <newbufferedpack+0x328>
lea    0xb05(%rip),%rdi
lea    0xb1b(%rip),%rsi
mov    $0x2,%edx
lea    0xbdc(%rip),%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
mov    -0x60(%rbp),%r15
jl     1380 <newbufferedpack+0x190>
lea    0xb6d(%rip),%rdi
lea    0xae3(%rip),%rsi
mov    $0x2,%edx
lea    0xbb5(%rip),%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1380 <newbufferedpack+0x190>
lea    0xb02(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <printf@plt>
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
mov    %r13,%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%edi
call   10a0 <close@plt>
lea    0xb83(%rip),%rcx
lea    0xb71(%rip),%r8
mov    %r12,%rdi
mov    -0x40(%rbp),%rsi
mov    %r15d,%edx
call   1080 <printstat@plt>
xor    %eax,%eax
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     15ec <newbufferedpack+0x3fc>
lea    0xa43(%rip),%rdi
lea    0xa59(%rip),%rsi
lea    0xb56(%rip),%rcx
lea    0xa63(%rip),%r8
mov    $0x2,%edx
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <printf@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
@.str = [29 x i8] c"%s [LogLevel=%d] [%s], \09%s \0A\00"
@.str.1 = [10 x i8] c"***ZVMLog\00"
@.str.2 = [14 x i8] c"start packing\00"
@.str.3 = [3 x i8] c"OK\00"
@.str.4 = [24 x i8] c"device to pack (output)\00"
@.str.5 = [14 x i8] c"path to files\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.6 = [39 x i8] c"*** ZVM Error open packfile (write)%s\0A\00"
@.str.7 = [27 x i8] c"*** ZVM Error open DIR %s\0A\00"
@.str.8 = [29 x i8] c"%s [LogLevel=%d] [%s], \09%d \0A\00"
@.str.9 = [26 x i8] c"read and write block size\00"
@DT_DIR = global i64 0
@.str.10 = [6 x i8] c"%s/%s\00"
@O_RDONLY = global i32 0
@.str.11 = [13 x i8] c"%10zu%s%10zu\00"
@.str.12 = [17 x i8] c"packed file name\00"
@.str.13 = [17 x i8] c"packed file size\00"
@.str.14 = [11 x i8] c"deltaindex\00"
@.str.15 = [10 x i8] c"mainindex\00"
@.str.16 = [17 x i8] c"packed all files\00"
define void @newbufferedpack(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.dirent*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%23 = call i32 (...) @getZVMLogLevel()
%24 = icmp sge i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %2
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %2
%28 = call i32 (...) @getZVMLogLevel()
%29 = icmp sge i32 %28, 2
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %27
%34 = call i32 (...) @getZVMLogLevel()
%35 = icmp sge i32 %34, 2
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %4
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %33
%40 = load i8*, i8** %3
%41 = load i32, i32* @O_WRONLY
%42 = load i32, i32* @O_CREAT
%43 = or i32 %41, %42
%44 = load i32, i32* @O_TRUNC
%45 = or i32 %43, %44
%46 = load i32, i32* @S_IROTH
%47 = load i32, i32* @S_IWOTH
%48 = or i32 %46, %47
%49 = load i32, i32* @S_IRUSR
%50 = or i32 %48, %49
%51 = load i32, i32* @S_IWUSR
%52 = or i32 %50, %51
%53 = call i32 (i8*, i32, ...) @open(i8* %40, i32 %45, i32 %52)
store i32 %53, i32* %5
%54 = load i32, i32* %5
%55 = icmp sle i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %39
%57 = load i8*, i8** %3
%58 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %57)
br label %191
59: ; preds = %39
%60 = load i8*, i8** %4
store i8* %60, i8** %6
%61 = load i8*, i8** %6
%62 = call i32* @opendir(i8* %61)
store i32* %62, i32** %7
%63 = load i32*, i32** %7
%64 = icmp ne i32* %63, null
br i1 %64, label %68, label %65
65: ; preds = %59
%66 = load i8*, i8** %6
%67 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %65, %59
store i32 65536, i32* %10
%69 = call i32 (...) @getZVMLogLevel()
%70 = icmp sge i32 %69, 2
br i1 %70, label %71, label %74
71: ; preds = %68
%72 = load i32, i32* %10
%73 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %71, %68
store i8* null, i8** %11
%75 = load i32, i32* %10
%76 = call i64 @malloc(i32 %75)
%77 = inttoptr i64 %76 to i8*
store i8* %77, i8** %11
store i64 0, i64* %12
store i64 0, i64* %13
store i32 0, i32* %14
br label %78
78: ; preds = %177, %74
%79 = load i32*, i32** %7
%80 = call %struct.dirent* @readdir(i32* %79)
store %struct.dirent* %80, %struct.dirent** %8
%81 = icmp ne %struct.dirent* %80, null
br i1 %81, label %82, label %178
82: ; preds = %78
%83 = load %struct.dirent*, %struct.dirent** %8
%84 = getelementptr inbounds %struct.dirent, %struct.dirent* %83, i32 0, i32 0
%85 = load i64, i64* %84
%86 = load i64, i64* @DT_DIR
%87 = icmp ne i64 %85, %86
br i1 %87, label %88, label %177
88: ; preds = %82
store i64 0, i64* %16
store i64 0, i64* %18
%89 = load %struct.dirent*, %struct.dirent** %8
%90 = getelementptr inbounds %struct.dirent, %struct.dirent* %89, i32 0, i32 1
%91 = load i8*, i8** %90
%92 = call i64 @strlen(i8* %91)
%93 = load i8*, i8** %6
%94 = call i64 @strlen(i8* %93)
%95 = add i64 %92, %94
%96 = add i64 %95, 2
%97 = trunc i64 %96 to i32
%98 = call i64 @malloc(i32 %97)
%99 = inttoptr i64 %98 to i8*
store i8* %99, i8** %9
%100 = load i8*, i8** %9
%101 = load i8*, i8** %6
%102 = load %struct.dirent*, %struct.dirent** %8
%103 = getelementptr inbounds %struct.dirent, %struct.dirent* %102, i32 0, i32 1
%104 = load i8*, i8** %103
%105 = call i32 (i8*, i8*, ...) @sprintf(i8* %100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %101, i8* %104)
%106 = load i8*, i8** %9
%107 = load i32, i32* @O_RDONLY
%108 = call i32 (i8*, i32, ...) @open(i8* %106, i32 %107)
store i32 %108, i32* %19
%109 = load i32, i32* %19
%110 = call i64 @getfilesize_fd(i32 %109, i32* null, i32 0)
store i64 %110, i64* %15
%111 = load i8*, i8** %9
%112 = call i64 @strlen(i8* %111)
%113 = add i64 %112, 12
%114 = call i8* @llvm.stacksave()
store i8* %114, i8** %20
%115 = alloca i8, i64 %113
store i64 %113, i64* %21
%116 = load i8*, i8** %9
%117 = call i64 @strlen(i8* %116)
%118 = load i8*, i8** %9
%119 = load i64, i64* %15
%120 = call i32 (i8*, i8*, ...) @sprintf(i8* %115, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i64 %117, i8* %118, i64 %119)
%121 = load i32, i32* %5
%122 = call i64 @strlen(i8* %115)
%123 = call i64 @write(i32 %121, i8* %115, i64 %122)
store i64 %123, i64* %17
%124 = load i64, i64* %15
%125 = icmp ugt i64 %124, 0
br i1 %125, label %126, label %142
126: ; preds = %88
br label %127
127: ; preds = %133, %126
%128 = load i32, i32* %19
%129 = load i8*, i8** %11
%130 = load i32, i32* %10
%131 = call i64 @read(i32 %128, i8* %129, i32 %130)
store i64 %131, i64* %16
%132 = icmp ugt i64 %131, 0
br i1 %132, label %133, label %141
133: ; preds = %127
%134 = load i64, i64* %16
%135 = load i64, i64* %18
%136 = add i64 %135, %134
store i64 %136, i64* %18
%137 = load i32, i32* %5
%138 = load i8*, i8** %11
%139 = load i64, i64* %16
%140 = call i64 @write(i32 %137, i8* %138, i64 %139)
store i64 %140, i64* %17
br label %127
141: ; preds = %127
br label %143
142: ; preds = %88
store i64 0, i64* %18
br label %143
143: ; preds = %142, %141
%144 = load i32, i32* %19
%145 = call i32 @close(i32 %144)
%146 = call i32 (...) @getZVMLogLevel()
%147 = icmp sge i32 %146, 2
br i1 %147, label %148, label %151
148: ; preds = %143
%149 = load i8*, i8** %9
%150 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i8* %149)
br label %151
151: ; preds = %148, %143
%152 = call i32 (...) @getZVMLogLevel()
%153 = icmp sge i32 %152, 2
br i1 %153, label %154, label %157
154: ; preds = %151
%155 = load i64, i64* %15
%156 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %155)
br label %157
157: ; preds = %154, %151
store i8* null, i8** %22
%158 = load i8*, i8** %9
%159 = call i8* @strstr(i8* %158, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
store i8* %159, i8** %22
%160 = icmp ne i8* %159, null
br i1 %160, label %161, label %165
161: ; preds = %157
%162 = load i64, i64* %15
%163 = load i64, i64* %12
%164 = add i64 %163, %162
store i64 %164, i64* %12
br label %165
165: ; preds = %161, %157
store i8* null, i8** %22
%166 = load i8*, i8** %9
%167 = call i8* @strstr(i8* %166, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
store i8* %167, i8** %22
%168 = icmp ne i8* %167, null
br i1 %168, label %169, label %173
169: ; preds = %165
%170 = load i64, i64* %15
%171 = load i64, i64* %13
%172 = add i64 %171, %170
store i64 %172, i64* %13
br label %173
173: ; preds = %169, %165
%174 = load i32, i32* %14
%175 = add nsw i32 %174, 1
store i32 %175, i32* %14
%176 = load i8*, i8** %20
br label %177
177: ; preds = %173, %82
br label %78
178: ; preds = %78
%179 = load i8*, i8** %11
%180 = call i32 @free(i8* %179)
%181 = load i32, i32* %5
%182 = call i32 @close(i32 %181)
%183 = load i64, i64* %13
%184 = load i64, i64* %12
%185 = load i32, i32* %14
%186 = call i32 @printstat(i64 %183, i64 %184, i32 %185, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%187 = call i32 (...) @getZVMLogLevel()
%188 = icmp sge i32 %187, 2
br i1 %188, label %189, label %191
189: ; preds = %178
%190 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %191
191: ; preds = %56, %189, %178
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i64, i8* }
@.str = [29 x i8] c"%s [LogLevel=%d] [%s], \09%s \0A\00"
@.str.1 = [10 x i8] c"***ZVMLog\00"
@.str.2 = [14 x i8] c"start packing\00"
@.str.3 = [3 x i8] c"OK\00"
@.str.4 = [24 x i8] c"device to pack (output)\00"
@.str.5 = [14 x i8] c"path to files\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.6 = [39 x i8] c"*** ZVM Error open packfile (write)%s\0A\00"
@.str.7 = [27 x i8] c"*** ZVM Error open DIR %s\0A\00"
@.str.8 = [29 x i8] c"%s [LogLevel=%d] [%s], \09%d \0A\00"
@.str.9 = [26 x i8] c"read and write block size\00"
@DT_DIR = global i64 0
@.str.10 = [6 x i8] c"%s/%s\00"
@O_RDONLY = global i32 0
@.str.11 = [13 x i8] c"%10zu%s%10zu\00"
@.str.12 = [17 x i8] c"packed file name\00"
@.str.13 = [17 x i8] c"packed file size\00"
@.str.14 = [11 x i8] c"deltaindex\00"
@.str.15 = [10 x i8] c"mainindex\00"
@.str.16 = [17 x i8] c"packed all files\00"
define void @newbufferedpack(i8* %0, i8* %1) {
%3 = tail call i32 (...) @getZVMLogLevel()
%4 = icmp sgt i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 (...) @getZVMLogLevel()
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %10, %7
%13 = tail call i32 (...) @getZVMLogLevel()
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %1)
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* @O_WRONLY
%19 = load i32, i32* @O_CREAT
%20 = or i32 %19, %18
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IROTH
%24 = load i32, i32* @S_IWOTH
%25 = or i32 %24, %23
%26 = load i32, i32* @S_IRUSR
%27 = or i32 %25, %26
%28 = load i32, i32* @S_IWUSR
%29 = or i32 %27, %28
%30 = tail call i32 (i8*, i32, ...) @open(i8* %0, i32 %22, i32 %29)
%31 = icmp slt i32 %30, 1
br i1 %31, label %32, label %34
32: ; preds = %17
%33 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %128
34: ; preds = %17
%35 = tail call i32* @opendir(i8* %1)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %1)
br label %39
39: ; preds = %37, %34
%40 = tail call i32 (...) @getZVMLogLevel()
%41 = icmp sgt i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 65536)
br label %44
44: ; preds = %42, %39
%45 = tail call i64 @malloc(i32 65536)
%46 = inttoptr i64 %45 to i8*
%47 = tail call %struct.dirent* @readdir(i32* %35)
%48 = icmp eq %struct.dirent* %47, null
br i1 %48, label %117, label %49
49: ; preds = %44, %111
%50 = phi %struct.dirent* [ %115, %111 ], [ %47, %44 ]
%51 = phi i64 [ %114, %111 ], [ 0, %44 ]
%52 = phi i64 [ %113, %111 ], [ 0, %44 ]
%53 = phi i32 [ %112, %111 ], [ 0, %44 ]
%54 = getelementptr inbounds %struct.dirent, %struct.dirent* %50, i64 0, i32 0
%55 = load i64, i64* %54
%56 = load i64, i64* @DT_DIR
%57 = icmp eq i64 %55, %56
br i1 %57, label %111, label %58
58: ; preds = %49
%59 = getelementptr inbounds %struct.dirent, %struct.dirent* %50, i64 0, i32 1
%60 = load i8*, i8** %59
%61 = tail call i64 @strlen(i8* dereferenceable(1) %60)
%62 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%63 = add i64 %62, %61
%64 = trunc i64 %63 to i32
%65 = add i32 %64, 2
%66 = tail call i64 @malloc(i32 %65)
%67 = inttoptr i64 %66 to i8*
%68 = load i8*, i8** %59
%69 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %67, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %1, i8* %68)
%70 = load i32, i32* @O_RDONLY
%71 = tail call i32 (i8*, i32, ...) @open(i8* %67, i32 %70)
%72 = tail call i64 @getfilesize_fd(i32 %71, i32* null, i32 0)
%73 = tail call i64 @strlen(i8* dereferenceable(1) %67)
%74 = add i64 %73, 12
%75 = tail call i8* @llvm.stacksave()
%76 = alloca i8, i64 %74
%77 = tail call i64 @strlen(i8* dereferenceable(1) %67)
%78 = call i32 (i8*, i8*, ...) @sprintf(i8* %76, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i64 %77, i8* %67, i64 %72)
%79 = call i64 @strlen(i8* %76)
%80 = call i64 @write(i32 %30, i8* %76, i64 %79)
%81 = icmp eq i64 %72, 0
br i1 %81, label %90, label %82
82: ; preds = %58
%83 = tail call i64 @read(i32 %71, i8* %46, i32 65536)
%84 = icmp eq i64 %83, 0
br i1 %84, label %90, label %85
85: ; preds = %82, %85
%86 = phi i64 [ %88, %85 ], [ %83, %82 ]
%87 = tail call i64 @write(i32 %30, i8* %46, i64 %86)
%88 = tail call i64 @read(i32 %71, i8* %46, i32 65536)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %85
90: ; preds = %85, %82, %58
%91 = tail call i32 @close(i32 %71)
%92 = tail call i32 (...) @getZVMLogLevel()
%93 = icmp sgt i32 %92, 1
br i1 %93, label %94, label %96
94: ; preds = %90
%95 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i8* %67)
br label %96
96: ; preds = %94, %90
%97 = tail call i32 (...) @getZVMLogLevel()
%98 = icmp sgt i32 %97, 1
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %72)
br label %101
101: ; preds = %99, %96
%102 = tail call i8* @strstr(i8* dereferenceable(1) %67, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%103 = icmp eq i8* %102, null
%104 = select i1 %103, i64 0, i64 %72
%105 = add i64 %104, %51
%106 = tail call i8* @strstr(i8* dereferenceable(1) %67, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%107 = icmp eq i8* %106, null
%108 = select i1 %107, i64 0, i64 %72
%109 = add i64 %108, %52
%110 = add nsw i32 %53, 1
tail call void @llvm.stackrestore(i8* %75)
br label %111
111: ; preds = %101, %49
%112 = phi i32 [ %110, %101 ], [ %53, %49 ]
%113 = phi i64 [ %109, %101 ], [ %52, %49 ]
%114 = phi i64 [ %105, %101 ], [ %51, %49 ]
%115 = tail call %struct.dirent* @readdir(i32* %35)
%116 = icmp eq %struct.dirent* %115, null
br i1 %116, label %117, label %49
117: ; preds = %111, %44
%118 = phi i32 [ 0, %44 ], [ %112, %111 ]
%119 = phi i64 [ 0, %44 ], [ %113, %111 ]
%120 = phi i64 [ 0, %44 ], [ %114, %111 ]
%121 = tail call i32 @free(i8* %46)
%122 = tail call i32 @close(i32 %30)
%123 = tail call i32 @printstat(i64 %119, i64 %120, i32 %118, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%124 = tail call i32 (...) @getZVMLogLevel()
%125 = icmp sgt i32 %124, 1
br i1 %125, label %126, label %128
126: ; preds = %117
%127 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %128
128: ; preds = %117, %126, %32
ret void
}