#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*/ DIR;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SEEK_CUR;
int S_IROTH;
int S_IRUSR;
int S_IWOTH;
int S_IWUSR;
size_t atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getZVMLogLevel();
int lseek(int, size_t, int /*<<< orphan*/);
scalar_t__ malloc(size_t);
int mymakedir(char *);
int open(char *, int, ...);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printstat(long, long, int, char *, char *);
int read(int, char *, size_t);
char *strstr(char *, char *);
int write(int, char *, int);
void newbufferedunpack(char *devname) {
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "s"
           " \n",
           "***ZVMLog", 2, "index pack device (input)", devname);
  };
  int fdinfile;
  char *dirName = (char *)"index";
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "s"
           " \n",
           "***ZVMLog", 2, "index directory name", dirName);
  };
  DIR *dir;
  dir = opendir(dirName);
  if (dir == NULL) {
    int result = mymakedir(dirName);
    if (result != 0)
      printf("*** ZVM Error can`t create directory %s\n", dirName);
  } else
    closedir(dir);
  int MAXREAD = 1024;
  char readbuf[MAXREAD];
  int letcount;
  letcount = 0;
  fdinfile = open(devname, O_RDONLY);
  if (fdinfile <= 0) {
    printf("*** ZVM error input indexpack file\n");
    return;
  }
  int bread = 1;
  long deltabytes = 0;
  long mainbytes = 0;
  int filecount = 0;
  char blocksizestr[10];
  size_t blocksize;
  if (getZVMLogLevel() >= 2) {
    printf("%s [LogLevel=%d] [%s], \t%"
           "zu"
           " \n",
           "***ZVMLog", 2, "read and write buff size", 1024 * 64);
  };
  while (bread > 0) {
    if (filecount > 50) {
      printf("Error unpack index files\n");
      break;
    }
    bread = read(fdinfile, blocksizestr, 10);
    if (bread <= 0) {
      break;
    }
    blocksizestr[10] = '\0';
    blocksize = atoi(blocksizestr);
    bread = read(fdinfile, readbuf, blocksize);
    readbuf[blocksize] = '\0';
    if (getZVMLogLevel() >= 2) {
      printf("%s [LogLevel=%d] [%s], \t%"
             "s"
             " \n",
             "***ZVMLog", 2, "file name", readbuf);
    };
    bread = read(fdinfile, blocksizestr, 10);
    blocksizestr[10] = '\0';
    blocksize = atoi(blocksizestr);
    if (getZVMLogLevel() >= 2) {
      printf("%s [LogLevel=%d] [%s], \t%"
             "zu"
             " \n",
             "***ZVMLog", 2, "file size", blocksize);
    };
    size_t filelen = 0;
    filelen = blocksize;
    int fdefile;
    fdefile = open(readbuf, O_WRONLY | O_CREAT | O_TRUNC,
                   S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
    if (fdefile <= 0) {
      printf(
          "*** ZVM Error open %s file for write. Increasing the current offset "
          "of the file descriptor on %zu bytes  and skip save this file.\n",
          readbuf, filelen);
      bread = lseek(fdinfile, filelen, SEEK_CUR);
      continue;
    }
    char *buff = NULL;
    size_t blockreadsize = 1024 * 64;
    int readb = 0;
    int writeb = 0;
    long countreadbytes = 0;
    long countwritebytes = 0;
    buff = (char *)malloc(blockreadsize * sizeof(char));
    if (filelen > 0) {
      if (blockreadsize > filelen)
        blockreadsize = filelen;
      int i = filelen / blockreadsize + 1;
      for (; i > 0; i--) {
        if (filelen < blockreadsize)
          blockreadsize = filelen;
        if (i == 1)
          blockreadsize = filelen - countreadbytes;
        readb = read(fdinfile, buff, blockreadsize);
        if (readb > 0)
          writeb = write(fdefile, buff, readb);
        else
          writeb = readb;
        countreadbytes += readb;
        countwritebytes += writeb;
      }
      readb = countreadbytes;
      writeb = countwritebytes;
    }
    char *indexnameptr = NULL;
    if ((indexnameptr = strstr(readbuf, "deltaindex")) != NULL)
      deltabytes += filelen;
    indexnameptr = NULL;
    if ((indexnameptr = strstr(readbuf, "mainindex")) != NULL)
      mainbytes += filelen;
    filecount++;
    free(buff);
    close(fdefile);
    if (readb != writeb)
      printf(
          "*** Warning while unpacking index file, readb = %d, writeb = %d\n",
          readb, writeb);
  }
  printstat(mainbytes, deltabytes, filecount, (char *)"mainindex",
            (char *)"deltaindex");
  close(fdinfile);
}


x86 assembly (clang, -O0):
<newbufferedunpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1234 <newbufferedunpack+0x44>
mov    -0x8(%rbp),%r8
lea    0xde6(%rip),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x2,%edx
lea    0xdfa(%rip),%rcx
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xf55(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1274 <newbufferedunpack+0x84>
mov    -0x18(%rbp),%r8
lea    0xda6(%rip),%rdi
lea    0xdbc(%rip),%rsi
mov    $0x2,%edx
lea    0xdd4(%rip),%rcx
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12b9 <newbufferedunpack+0xc9>
mov    -0x18(%rbp),%rdi
call   10d0 <mymakedir@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12b4 <newbufferedunpack+0xc4>
mov    -0x18(%rbp),%rsi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12c2 <newbufferedunpack+0xd2>
mov    -0x20(%rbp),%rdi
call   10a0 <closedir@plt>
movl   $0x400,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1334 <newbufferedunpack+0x144>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x40(%rbp)
jmp    17bf <newbufferedunpack+0x5cf>
movl   $0x1,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1389 <newbufferedunpack+0x199>
lea    0xd3a(%rip),%rdi
lea    0xcad(%rip),%rsi
mov    $0x2,%edx
lea    0xd45(%rip),%rcx
mov    $0x10000,%r8d
mov    $0x0,%al
call   1070 <printf@plt>
jmp    138e <newbufferedunpack+0x19e>
cmpl   $0x0,-0x44(%rbp)
jle    1792 <newbufferedunpack+0x5a2>
cmpl   $0x32,-0x5c(%rbp)
jle    13b5 <newbufferedunpack+0x1c5>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1792 <newbufferedunpack+0x5a2>
mov    -0xc(%rbp),%edi
lea    -0x66(%rbp),%rsi
mov    $0xa,%edx
call   10b0 <read@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jg     13d8 <newbufferedunpack+0x1e8>
jmp    1792 <newbufferedunpack+0x5a2>
movb   $0x0,-0x5c(%rbp)
lea    -0x66(%rbp),%rdi
call   10f0 <atoi@plt>
mov    -0xc0(%rbp),%rsi
mov    %rax,-0x70(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x70(%rbp),%rdx
call   10b0 <read@plt>
mov    %eax,%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,-0x44(%rbp)
mov    -0x70(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1448 <newbufferedunpack+0x258>
mov    -0xc0(%rbp),%r8
lea    0xbd2(%rip),%rdi
lea    0xbe8(%rip),%rsi
mov    $0x2,%edx
lea    0xcb3(%rip),%rcx
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x66(%rbp),%rsi
mov    $0xa,%edx
call   10b0 <read@plt>
mov    %eax,-0x44(%rbp)
movb   $0x0,-0x5c(%rbp)
lea    -0x66(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %rax,-0x70(%rbp)
mov    $0x0,%al
call   1100 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     14a2 <newbufferedunpack+0x2b2>
mov    -0x70(%rbp),%r8
lea    0xc1b(%rip),%rdi
lea    0xb8e(%rip),%rsi
mov    $0x2,%edx
lea    0xc63(%rip),%rcx
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc0(%rbp),%rdi
movq   $0x0,-0x78(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2ae0(%rip),%rax
mov    (%rax),%esi
mov    0x2b2f(%rip),%rax
or     (%rax),%esi
mov    0x2b1e(%rip),%rax
or     (%rax),%esi
mov    0x2add(%rip),%rax
mov    (%rax),%edx
mov    0x2ab4(%rip),%rax
or     (%rax),%edx
mov    0x2ac3(%rip),%rax
or     (%rax),%edx
mov    0x2ad2(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10e0 <open@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jg     1542 <newbufferedunpack+0x352>
mov    -0xc0(%rbp),%rsi
mov    -0x78(%rbp),%rdx
lea    0xbea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    0x2aa5(%rip),%rax
mov    (%rax),%edx
call   1080 <lseek@plt>
mov    %eax,-0x44(%rbp)
jmp    138e <newbufferedunpack+0x19e>
movq   $0x0,-0x88(%rbp)
movq   $0x10000,-0x90(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movq   $0x0,-0xa0(%rbp)
movq   $0x0,-0xa8(%rbp)
mov    -0x90(%rbp),%rdi
shl    $0x0,%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x78(%rbp)
jbe    16ce <newbufferedunpack+0x4de>
mov    -0x90(%rbp),%rax
cmp    -0x78(%rbp),%rax
jbe    15c0 <newbufferedunpack+0x3d0>
mov    -0x78(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x78(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x90(%rbp)
add    $0x1,%rax
mov    %eax,-0xac(%rbp)
cmpl   $0x0,-0xac(%rbp)
jle    16b4 <newbufferedunpack+0x4c4>
mov    -0x78(%rbp),%rax
cmp    -0x90(%rbp),%rax
jae    1602 <newbufferedunpack+0x412>
mov    -0x78(%rbp),%rax
mov    %rax,-0x90(%rbp)
cmpl   $0x1,-0xac(%rbp)
jne    1621 <newbufferedunpack+0x431>
mov    -0x78(%rbp),%rax
sub    -0xa0(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rdx
call   10b0 <read@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jle    166a <newbufferedunpack+0x47a>
mov    -0x7c(%rbp),%edi
mov    -0x88(%rbp),%rsi
mov    -0x94(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x98(%rbp)
jmp    1676 <newbufferedunpack+0x486>
mov    -0x94(%rbp),%eax
mov    %eax,-0x98(%rbp)
movslq -0x94(%rbp),%rax
add    -0xa0(%rbp),%rax
mov    %rax,-0xa0(%rbp)
movslq -0x98(%rbp),%rax
add    -0xa8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xac(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xac(%rbp)
jmp    15d9 <newbufferedunpack+0x3e9>
mov    -0xa0(%rbp),%rax
mov    %eax,-0x94(%rbp)
mov    -0xa8(%rbp),%rax
mov    %eax,-0x98(%rbp)
mov    -0xc0(%rbp),%rdi
movq   $0x0,-0xb8(%rbp)
lea    0xaa4(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0xb8(%rbp)
cmp    $0x0,%rax
je     1709 <newbufferedunpack+0x519>
mov    -0x78(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0xc0(%rbp),%rdi
movq   $0x0,-0xb8(%rbp)
lea    0xa74(%rip),%rsi
call   1110 <strstr@plt>
mov    %rax,-0xb8(%rbp)
cmp    $0x0,%rax
je     1744 <newbufferedunpack+0x554>
mov    -0x78(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x7c(%rbp),%edi
call   1090 <close@plt>
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
je     178d <newbufferedunpack+0x59d>
mov    -0x94(%rbp),%esi
mov    -0x98(%rbp),%edx
lea    0xa1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    138e <newbufferedunpack+0x19e>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x5c(%rbp),%edx
lea    0x9f2(%rip),%rcx
lea    0x9e0(%rip),%r8
call   1060 <printstat@plt>
mov    -0xc(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newbufferedunpack>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1110 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1244 <newbufferedunpack+0x44>
lea    0xdd9(%rip),%rdi
lea    0xdef(%rip),%rsi
lea    0xdf2(%rip),%rcx
mov    $0x2,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1110 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1278 <newbufferedunpack+0x78>
lea    0xda9(%rip),%rdi
lea    0xdbf(%rip),%rsi
lea    0xddc(%rip),%rcx
lea    0xee6(%rip),%r8
mov    $0x2,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xed3(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1293 <newbufferedunpack+0x93>
mov    %rax,%rdi
call   10b0 <closedir@plt>
jmp    12b8 <newbufferedunpack+0xb8>
lea    0xeb8(%rip),%rdi
call   10e0 <mymakedir@plt>
test   %eax,%eax
je     12b8 <newbufferedunpack+0xb8>
lea    0xdac(%rip),%rdi
lea    0xea1(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rsp,%r12
add    $0xfffffffffffffc00,%r12
mov    %r12,%rsp
mov    0x2d04(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   10f0 <open@plt>
test   %eax,%eax
jle    1615 <newbufferedunpack+0x415>
mov    %eax,%r15d
xor    %eax,%eax
call   1110 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     1316 <newbufferedunpack+0x116>
lea    0xd89(%rip),%rdi
lea    0xd20(%rip),%rsi
lea    0xd99(%rip),%rcx
mov    $0x2,%edx
mov    $0x10000,%r8d
xor    %eax,%eax
call   1080 <printf@plt>
lea    -0x52(%rbp),%r14
xor    %r13d,%r13d
xor    %eax,%eax
mov    %rax,-0x68(%rbp)
xor    %eax,%eax
mov    %rax,-0x60(%rbp)
mov    %r15d,-0x48(%rbp)
mov    %r12,-0x40(%rbp)
jmp    1374 <newbufferedunpack+0x174>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xd83(%rip),%rdi
mov    %r12,%rsi
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c79(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
call   1090 <lseek@plt>
test   %eax,%eax
jle    163b <newbufferedunpack+0x43b>
cmp    $0x33,%r13d
jge    162f <newbufferedunpack+0x42f>
mov    $0xa,%edx
mov    %r15d,%edi
mov    %r14,%rsi
call   10c0 <read@plt>
test   %eax,%eax
jle    163b <newbufferedunpack+0x43b>
movb   $0x0,-0x48(%rbp)
mov    %r14,%rdi
call   1100 <atoi@plt>
mov    %rax,%rbx
mov    %r15d,%edi
mov    %r12,%rsi
mov    %rax,%rdx
call   10c0 <read@plt>
movb   $0x0,(%r12,%rbx,1)
xor    %eax,%eax
call   1110 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     13e8 <newbufferedunpack+0x1e8>
lea    0xc35(%rip),%rdi
lea    0xc4b(%rip),%rsi
mov    $0x2,%edx
lea    0xcd8(%rip),%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edx
mov    %r15d,%edi
mov    %r14,%rsi
call   10c0 <read@plt>
mov    %eax,%ebx
movb   $0x0,-0x48(%rbp)
mov    %r14,%rdi
call   1100 <atoi@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
call   1110 <getZVMLogLevel@plt>
cmp    $0x2,%eax
jl     143b <newbufferedunpack+0x23b>
lea    0xc62(%rip),%rdi
lea    0xbf9(%rip),%rsi
mov    $0x2,%edx
lea    0xc90(%rip),%rcx
mov    -0x30(%rbp),%r8
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2bb6(%rip),%rax
mov    (%rax),%esi
mov    0x2b55(%rip),%rax
or     (%rax),%esi
mov    0x2b9c(%rip),%rax
or     (%rax),%esi
mov    0x2b3b(%rip),%rax
mov    (%rax),%edx
mov    0x2b52(%rip),%rax
or     (%rax),%edx
mov    0x2b41(%rip),%rax
or     (%rax),%edx
mov    0x2b50(%rip),%rax
or     (%rax),%edx
mov    %r12,%rdi
xor    %eax,%eax
call   10f0 <open@plt>
mov    %eax,-0x38(%rbp)
test   %eax,%eax
jle    1340 <newbufferedunpack+0x140>
mov    $0x10000,%edi
call   10d0 <malloc@plt>
mov    -0x30(%rbp),%rcx
test   %rcx,%rcx
mov    %rax,-0x70(%rbp)
mov    %r13d,-0x44(%rbp)
mov    %ebx,-0x34(%rbp)
je     1570 <newbufferedunpack+0x370>
mov    %rax,%rsi
cmp    $0x10000,%rcx
mov    $0x10000,%r12d
cmovb  %rcx,%r12
mov    %rcx,%rax
shr    $0x20,%rax
je     1577 <newbufferedunpack+0x377>
mov    %rcx,%rax
xor    %edx,%edx
div    %r12
mov    %rax,%r13
cmp    $0x7ffffffe,%r13d
ja     158e <newbufferedunpack+0x38e>
add    $0x1,%r13d
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    152b <newbufferedunpack+0x32b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15d,%eax
movslq %r15d,%rcx
add    %rcx,%r14
mov    %eax,%eax
mov    -0x78(%rbp),%rbx
add    %rax,%rbx
lea    -0x1(%r13),%eax
cmp    $0x1,%r13d
mov    %eax,%r13d
mov    -0x48(%rbp),%r15d
mov    -0x30(%rbp),%rcx
mov    -0x70(%rbp),%rsi
jle    1593 <newbufferedunpack+0x393>
mov    %rbx,-0x78(%rbp)
cmp    %r12,%rcx
mov    %r12,%rax
cmovb  %rcx,%rax
mov    %rcx,%r12
sub    %r14,%r12
cmp    $0x1,%r13d
cmovne %rax,%r12
mov    %r15d,%edi
mov    %rsi,%rbx
mov    %r12,%rdx
call   10c0 <read@plt>
mov    %eax,%r15d
test   %eax,%eax
jle    1500 <newbufferedunpack+0x300>
mov    -0x38(%rbp),%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <write@plt>
jmp    1503 <newbufferedunpack+0x303>
nopl   0x0(%rax)
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    1597 <newbufferedunpack+0x397>
mov    %ecx,%eax
xor    %edx,%edx
div    %r12d
mov    %eax,%r13d
cmp    $0x7ffffffe,%r13d
jbe    14ea <newbufferedunpack+0x2ea>
xor    %r14d,%r14d
xor    %ebx,%ebx
mov    -0x40(%rbp),%r12
mov    %r12,%rdi
lea    0xbac(%rip),%rsi
call   1120 <strstr@plt>
test   %rax,%rax
mov    -0x30(%rbp),%r13
cmovne %r13,%rax
add    %rax,-0x60(%rbp)
mov    %r12,%rdi
lea    0xb99(%rip),%rsi
call   1120 <strstr@plt>
test   %rax,%rax
cmove  %rax,%r13
add    %r13,-0x68(%rbp)
mov    -0x44(%rbp),%r13d
add    $0x1,%r13d
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
cmp    %ebx,%r14d
je     1600 <newbufferedunpack+0x400>
lea    0xb6e(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    -0x52(%rbp),%r14
mov    -0x34(%rbp),%eax
mov    -0x40(%rbp),%r12
test   %eax,%eax
jg     1374 <newbufferedunpack+0x174>
jmp    163b <newbufferedunpack+0x43b>
lea    0xba0(%rip),%rdi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
lea    0xb6d(%rip),%rdi
call   1040 <puts@plt>
lea    0xb16(%rip),%rcx
lea    0xb04(%rip),%r8
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %r13d,%edx
call   1070 <printstat@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"%s [LogLevel=%d] [%s], \09%s \0A\00"
@.str.1 = [10 x i8] c"***ZVMLog\00"
@.str.2 = [26 x i8] c"index pack device (input)\00"
@.str.3 = [6 x i8] c"index\00"
@.str.4 = [21 x i8] c"index directory name\00"
@.str.5 = [41 x i8] c"*** ZVM Error can`t create directory %s\0A\00"
@O_RDONLY = global i32 0
@.str.6 = [36 x i8] c"*** ZVM error input indexpack file\0A\00"
@.str.7 = [30 x i8] c"%s [LogLevel=%d] [%s], \09%zu \0A\00"
@.str.8 = [25 x i8] c"read and write buff size\00"
@.str.9 = [26 x i8] c"Error unpack index files\0A\00"
@.str.10 = [10 x i8] c"file name\00"
@.str.11 = [10 x i8] c"file size\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.12 = [131 x i8] c"*** ZVM Error open %s file for write. Increasing the current offset of the file descriptor on %zu bytes and skip save this file.\0A\00"
@SEEK_CUR = global i32 0
@.str.13 = [11 x i8] c"deltaindex\00"
@.str.14 = [10 x i8] c"mainindex\00"
@.str.15 = [65 x i8] c"*** Warning while unpacking index file, readb = %d, writeb = %d\0A\00"
define void @newbufferedunpack(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
%16 = alloca [10 x i8]
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i32
%23 = alloca i32
%24 = alloca i64
%25 = alloca i64
%26 = alloca i32
%27 = alloca i8*
store i8* %0, i8** %2
%28 = call i32 (...) @getZVMLogLevel()
%29 = icmp sge i32 %28, 2
br i1 %29, label %30, label %33
30: ; preds = %1
%31 = load i8*, i8** %2
%32 = call i32 (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 ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %4
%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*, ...) @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 ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %33
%40 = load i8*, i8** %4
%41 = call i32* @opendir(i8* %40)
store i32* %41, i32** %5
%42 = load i32*, i32** %5
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %53
44: ; preds = %39
%45 = load i8*, i8** %4
%46 = call i32 @mymakedir(i8* %45)
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i8*, i8** %4
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %49, %44
br label %56
53: ; preds = %39
%54 = load i32*, i32** %5
%55 = call i32 @closedir(i32* %54)
br label %56
56: ; preds = %53, %52
store i32 1024, i32* %7
%57 = load i32, i32* %7
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %8
%60 = alloca i8, i64 %58
store i64 %58, i64* %9
store i32 0, i32* %10
%61 = load i8*, i8** %2
%62 = load i32, i32* @O_RDONLY
%63 = call i32 (i8*, i32, ...) @open(i8* %61, i32 %62)
store i32 %63, i32* %3
%64 = load i32, i32* %3
%65 = icmp sle i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %56
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %11
br label %240
68: ; preds = %56
store i32 1, i32* %12
store i64 0, i64* %13
store i64 0, i64* %14
store i32 0, i32* %15
%69 = call i32 (...) @getZVMLogLevel()
%70 = icmp sge i32 %69, 2
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 65536)
br label %73
73: ; preds = %71, %68
br label %74
74: ; preds = %232, %131, %73
%75 = load i32, i32* %12
%76 = icmp sgt i32 %75, 0
br i1 %76, label %77, label %233
77: ; preds = %74
%78 = load i32, i32* %15
%79 = icmp sgt i32 %78, 50
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %233
82: ; preds = %77
%83 = load i32, i32* %3
%84 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%85 = call i32 @read(i32 %83, i8* %84, i64 10)
store i32 %85, i32* %12
%86 = load i32, i32* %12
%87 = icmp sle i32 %86, 0
br i1 %87, label %88, label %89
88: ; preds = %82
br label %233
89: ; preds = %82
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 10
store i8 0, i8* %90
%91 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%92 = call i64 @atoi(i8* %91)
store i64 %92, i64* %17
%93 = load i32, i32* %3
%94 = load i64, i64* %17
%95 = call i32 @read(i32 %93, i8* %60, i64 %94)
store i32 %95, i32* %12
%96 = load i64, i64* %17
%97 = getelementptr inbounds i8, i8* %60, i64 %96
store i8 0, i8* %97
%98 = call i32 (...) @getZVMLogLevel()
%99 = icmp sge i32 %98, 2
br i1 %99, label %100, label %102
100: ; preds = %89
%101 = call i32 (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 ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %60)
br label %102
102: ; preds = %100, %89
%103 = load i32, i32* %3
%104 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%105 = call i32 @read(i32 %103, i8* %104, i64 10)
store i32 %105, i32* %12
%106 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 10
store i8 0, i8* %106
%107 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%108 = call i64 @atoi(i8* %107)
store i64 %108, i64* %17
%109 = call i32 (...) @getZVMLogLevel()
%110 = icmp sge i32 %109, 2
br i1 %110, label %111, label %114
111: ; preds = %102
%112 = load i64, i64* %17
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i64 %112)
br label %114
114: ; preds = %111, %102
store i64 0, i64* %18
%115 = load i64, i64* %17
store i64 %115, i64* %18
%116 = load i32, i32* @O_WRONLY
%117 = load i32, i32* @O_CREAT
%118 = or i32 %116, %117
%119 = load i32, i32* @O_TRUNC
%120 = or i32 %118, %119
%121 = load i32, i32* @S_IROTH
%122 = load i32, i32* @S_IWOTH
%123 = or i32 %121, %122
%124 = load i32, i32* @S_IRUSR
%125 = or i32 %123, %124
%126 = load i32, i32* @S_IWUSR
%127 = or i32 %125, %126
%128 = call i32 (i8*, i32, ...) @open(i8* %60, i32 %120, i32 %127)
store i32 %128, i32* %19
%129 = load i32, i32* %19
%130 = icmp sle i32 %129, 0
br i1 %130, label %131, label %138
131: ; preds = %114
%132 = load i64, i64* %18
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.12, i64 0, i64 0), i8* %60, i64 %132)
%134 = load i32, i32* %3
%135 = load i64, i64* %18
%136 = load i32, i32* @SEEK_CUR
%137 = call i32 @lseek(i32 %134, i64 %135, i32 %136)
store i32 %137, i32* %12
br label %74
138: ; preds = %114
store i8* null, i8** %20
store i64 65536, i64* %21
store i32 0, i32* %22
store i32 0, i32* %23
store i64 0, i64* %24
store i64 0, i64* %25
%139 = load i64, i64* %21
%140 = mul i64 %139, 1
%141 = call i64 @malloc(i64 %140)
%142 = inttoptr i64 %141 to i8*
store i8* %142, i8** %20
%143 = load i64, i64* %18
%144 = icmp ugt i64 %143, 0
br i1 %144, label %145, label %204
145: ; preds = %138
%146 = load i64, i64* %21
%147 = load i64, i64* %18
%148 = icmp ugt i64 %146, %147
br i1 %148, label %149, label %151
149: ; preds = %145
%150 = load i64, i64* %18
store i64 %150, i64* %21
br label %151
151: ; preds = %149, %145
%152 = load i64, i64* %18
%153 = load i64, i64* %21
%154 = udiv i64 %152, %153
%155 = add i64 %154, 1
%156 = trunc i64 %155 to i32
store i32 %156, i32* %26
br label %157
157: ; preds = %196, %151
%158 = load i32, i32* %26
%159 = icmp sgt i32 %158, 0
br i1 %159, label %160, label %199
160: ; preds = %157
%161 = load i64, i64* %18
%162 = load i64, i64* %21
%163 = icmp ult i64 %161, %162
br i1 %163, label %164, label %166
164: ; preds = %160
%165 = load i64, i64* %18
store i64 %165, i64* %21
br label %166
166: ; preds = %164, %160
%167 = load i32, i32* %26
%168 = icmp eq i32 %167, 1
br i1 %168, label %169, label %173
169: ; preds = %166
%170 = load i64, i64* %18
%171 = load i64, i64* %24
%172 = sub i64 %170, %171
store i64 %172, i64* %21
br label %173
173: ; preds = %169, %166
%174 = load i32, i32* %3
%175 = load i8*, i8** %20
%176 = load i64, i64* %21
%177 = call i32 @read(i32 %174, i8* %175, i64 %176)
store i32 %177, i32* %22
%178 = load i32, i32* %22
%179 = icmp sgt i32 %178, 0
br i1 %179, label %180, label %185
180: ; preds = %173
%181 = load i32, i32* %19
%182 = load i8*, i8** %20
%183 = load i32, i32* %22
%184 = call i32 @write(i32 %181, i8* %182, i32 %183)
store i32 %184, i32* %23
br label %187
185: ; preds = %173
%186 = load i32, i32* %22
store i32 %186, i32* %23
br label %187
187: ; preds = %185, %180
%188 = load i32, i32* %22
%189 = sext i32 %188 to i64
%190 = load i64, i64* %24
%191 = add nsw i64 %190, %189
store i64 %191, i64* %24
%192 = load i32, i32* %23
%193 = sext i32 %192 to i64
%194 = load i64, i64* %25
%195 = add nsw i64 %194, %193
store i64 %195, i64* %25
br label %196
196: ; preds = %187
%197 = load i32, i32* %26
%198 = add nsw i32 %197, -1
store i32 %198, i32* %26
br label %157
199: ; preds = %157
%200 = load i64, i64* %24
%201 = trunc i64 %200 to i32
store i32 %201, i32* %22
%202 = load i64, i64* %25
%203 = trunc i64 %202 to i32
store i32 %203, i32* %23
br label %204
204: ; preds = %199, %138
store i8* null, i8** %27
%205 = call i8* @strstr(i8* %60, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
store i8* %205, i8** %27
%206 = icmp ne i8* %205, null
br i1 %206, label %207, label %211
207: ; preds = %204
%208 = load i64, i64* %18
%209 = load i64, i64* %13
%210 = add i64 %209, %208
store i64 %210, i64* %13
br label %211
211: ; preds = %207, %204
store i8* null, i8** %27
%212 = call i8* @strstr(i8* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
store i8* %212, i8** %27
%213 = icmp ne i8* %212, null
br i1 %213, label %214, label %218
214: ; preds = %211
%215 = load i64, i64* %18
%216 = load i64, i64* %14
%217 = add i64 %216, %215
store i64 %217, i64* %14
br label %218
218: ; preds = %214, %211
%219 = load i32, i32* %15
%220 = add nsw i32 %219, 1
store i32 %220, i32* %15
%221 = load i8*, i8** %20
%222 = call i32 @free(i8* %221)
%223 = load i32, i32* %19
%224 = call i32 @close(i32 %223)
%225 = load i32, i32* %22
%226 = load i32, i32* %23
%227 = icmp ne i32 %225, %226
br i1 %227, label %228, label %232
228: ; preds = %218
%229 = load i32, i32* %22
%230 = load i32, i32* %23
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.15, i64 0, i64 0), i32 %229, i32 %230)
br label %232
232: ; preds = %228, %218
br label %74
233: ; preds = %88, %80, %74
%234 = load i64, i64* %14
%235 = load i64, i64* %13
%236 = load i32, i32* %15
%237 = call i32 @printstat(i64 %234, i64 %235, i32 %236, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%238 = load i32, i32* %3
%239 = call i32 @close(i32 %238)
store i32 0, i32* %11
br label %240
240: ; preds = %233, %66
%241 = load i8*, i8** %8
%242 = load i32, i32* %11
switch i32 %242, label %244 [
i32 0, label %243
i32 1, label %243
]
243: ; preds = %240, %240
ret void
244: ; preds = %240
unreachable
}

LLVM IR (-O2):
@.str = [29 x i8] c"%s [LogLevel=%d] [%s], \09%s \0A\00"
@.str.1 = [10 x i8] c"***ZVMLog\00"
@.str.2 = [26 x i8] c"index pack device (input)\00"
@.str.3 = [6 x i8] c"index\00"
@.str.4 = [21 x i8] c"index directory name\00"
@.str.5 = [41 x i8] c"*** ZVM Error can`t create directory %s\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [30 x i8] c"%s [LogLevel=%d] [%s], \09%zu \0A\00"
@.str.8 = [25 x i8] c"read and write buff size\00"
@.str.10 = [10 x i8] c"file name\00"
@.str.11 = [10 x i8] c"file size\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.12 = [131 x i8] c"*** ZVM Error open %s file for write. Increasing the current offset of the file descriptor on %zu bytes and skip save this file.\0A\00"
@SEEK_CUR = global i32 0
@.str.13 = [11 x i8] c"deltaindex\00"
@.str.14 = [10 x i8] c"mainindex\00"
@.str.15 = [65 x i8] c"*** Warning while unpacking index file, readb = %d, writeb = %d\0A\00"
@str = [25 x i8] c"Error unpack index files\00"
@str.16 = [35 x i8] c"*** ZVM error input indexpack file\00"
define void @newbufferedunpack(i8* %0) {
%2 = alloca [10 x i8]
%3 = tail call i32 (...) @getZVMLogLevel()
%4 = icmp sgt i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %1
%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*, ...) @printf(i8* dereferenceable(1) 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 ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = tail call i32 @mymakedir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %22
20: ; preds = %12
%21 = tail call i32 @closedir(i32* %13)
br label %22
22: ; preds = %15, %18, %20
%23 = alloca [1024 x i8]
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %23, i64 0, i64 0
%25 = load i32, i32* @O_RDONLY
%26 = tail call i32 (i8*, i32, ...) @open(i8* %0, i32 %25)
%27 = icmp slt i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.16, i64 0, i64 0))
br label %150
30: ; preds = %22
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%32 = tail call i32 (...) @getZVMLogLevel()
%33 = icmp sgt i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 65536)
br label %36
36: ; preds = %34, %30
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 10
br label %38
38: ; preds = %36, %138
%39 = phi i32 [ 0, %36 ], [ %142, %138 ]
%40 = phi i64 [ 0, %36 ], [ %141, %138 ]
%41 = phi i64 [ 0, %36 ], [ %140, %138 ]
%42 = icmp sgt i32 %39, 50
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %144
45: ; preds = %38
%46 = call i32 @read(i32 %26, i8* %31, i64 10)
%47 = icmp slt i32 %46, 1
br i1 %47, label %144, label %48
48: ; preds = %45
store i8 0, i8* %37
%49 = call i64 @atoi(i8* %31)
%50 = call i32 @read(i32 %26, i8* %24, i64 %49)
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %23, i64 0, i64 %49
store i8 0, i8* %51
%52 = call i32 (...) @getZVMLogLevel()
%53 = icmp sgt i32 %52, 1
br i1 %53, label %54, label %56
54: ; preds = %48
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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 ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %24)
br label %56
56: ; preds = %54, %48
%57 = call i32 @read(i32 %26, i8* %31, i64 10)
store i8 0, i8* %37
%58 = call i64 @atoi(i8* %31)
%59 = call i32 (...) @getZVMLogLevel()
%60 = icmp sgt i32 %59, 1
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i64 %58)
br label %63
63: ; preds = %61, %56
%64 = load i32, i32* @O_WRONLY
%65 = load i32, i32* @O_CREAT
%66 = or i32 %65, %64
%67 = load i32, i32* @O_TRUNC
%68 = or i32 %66, %67
%69 = load i32, i32* @S_IROTH
%70 = load i32, i32* @S_IWOTH
%71 = or i32 %70, %69
%72 = load i32, i32* @S_IRUSR
%73 = or i32 %71, %72
%74 = load i32, i32* @S_IWUSR
%75 = or i32 %73, %74
%76 = call i32 (i8*, i32, ...) @open(i8* %24, i32 %68, i32 %75)
%77 = icmp slt i32 %76, 1
br i1 %77, label %78, label %82
78: ; preds = %63
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([131 x i8], [131 x i8]* @.str.12, i64 0, i64 0), i8* %24, i64 %58)
%80 = load i32, i32* @SEEK_CUR
%81 = call i32 @lseek(i32 %26, i64 %58, i32 %80)
br label %138
82: ; preds = %63
%83 = call i64 @malloc(i64 65536)
%84 = inttoptr i64 %83 to i8*
%85 = icmp eq i64 %58, 0
br i1 %85, label %121, label %86
86: ; preds = %82
%87 = icmp ult i64 %58, 65536
%88 = select i1 %87, i64 %58, i64 65536
%89 = udiv i64 %58, %88
%90 = trunc i64 %89 to i32
%91 = icmp ult i32 %90, 2147483647
br i1 %91, label %92, label %116
92: ; preds = %86
%93 = add nuw nsw i32 %90, 1
br label %94
94: ; preds = %92, %108
%95 = phi i32 [ %114, %108 ], [ %93, %92 ]
%96 = phi i64 [ %113, %108 ], [ 0, %92 ]
%97 = phi i64 [ %111, %108 ], [ 0, %92 ]
%98 = phi i64 [ %103, %108 ], [ %88, %92 ]
%99 = icmp ult i64 %58, %98
%100 = select i1 %99, i64 %58, i64 %98
%101 = icmp eq i32 %95, 1
%102 = sub i64 %58, %97
%103 = select i1 %101, i64 %102, i64 %100
%104 = call i32 @read(i32 %26, i8* %84, i64 %103)
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %94
%107 = call i32 @write(i32 %76, i8* %84, i32 %104)
br label %108
108: ; preds = %94, %106
%109 = phi i32 [ %107, %106 ], [ %104, %94 ]
%110 = sext i32 %104 to i64
%111 = add nsw i64 %97, %110
%112 = zext i32 %109 to i64
%113 = add i64 %96, %112
%114 = add nsw i32 %95, -1
%115 = icmp sgt i32 %95, 1
br i1 %115, label %94, label %116
116: ; preds = %108, %86
%117 = phi i64 [ 0, %86 ], [ %111, %108 ]
%118 = phi i64 [ 0, %86 ], [ %113, %108 ]
%119 = trunc i64 %117 to i32
%120 = trunc i64 %118 to i32
br label %121
121: ; preds = %116, %82
%122 = phi i32 [ %119, %116 ], [ 0, %82 ]
%123 = phi i32 [ %120, %116 ], [ 0, %82 ]
%124 = call i8* @strstr(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%125 = icmp eq i8* %124, null
%126 = select i1 %125, i64 0, i64 %58
%127 = add i64 %126, %41
%128 = call i8* @strstr(i8* %24, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
%129 = icmp eq i8* %128, null
%130 = select i1 %129, i64 0, i64 %58
%131 = add i64 %130, %40
%132 = add nsw i32 %39, 1
%133 = call i32 @free(i8* %84)
%134 = call i32 @close(i32 %76)
%135 = icmp eq i32 %122, %123
br i1 %135, label %138, label %136
136: ; preds = %121
%137 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.15, i64 0, i64 0), i32 %122, i32 %123)
br label %138
138: ; preds = %121, %136, %78
%139 = phi i32 [ %81, %78 ], [ %57, %136 ], [ %57, %121 ]
%140 = phi i64 [ %41, %78 ], [ %127, %136 ], [ %127, %121 ]
%141 = phi i64 [ %40, %78 ], [ %131, %136 ], [ %131, %121 ]
%142 = phi i32 [ %39, %78 ], [ %132, %136 ], [ %132, %121 ]
%143 = icmp sgt i32 %139, 0
br i1 %143, label %38, label %144
144: ; preds = %45, %138, %43
%145 = phi i64 [ %41, %43 ], [ %140, %138 ], [ %41, %45 ]
%146 = phi i64 [ %40, %43 ], [ %141, %138 ], [ %40, %45 ]
%147 = phi i32 [ %39, %43 ], [ %142, %138 ], [ %39, %45 ]
%148 = call i32 @printstat(i64 %146, i64 %145, i32 %147, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
%149 = call i32 @close(i32 %26)
br label %150
150: ; preds = %144, %28
ret void
}