#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 S_IROTH;
int S_IRUSR;
int S_IWOTH;
int S_IWUSR;
long atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ isspace(char);
scalar_t__ malloc(int);
int mymakedir(char *);
int open(char *, int, ...);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
char *strstr(char *, char *);
int write(int, char *, int);
void unpackindex_fd(char *devname) {
  int fdinfile;
  char *dirName = (char *)"index";
  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;
  }
  char c;
  int bread;
  bread = 1;
  long deltabytes = 0;
  long mainbytes = 0;
  int filecount = 0;
  while (bread > 0) {
    letcount = 0;
    bread = read(fdinfile, &c, 1);
    if (bread == 0) {
      close(fdinfile);
      return;
    }
    if (c != '{') {
      printf("Error *\n");
      close(fdinfile);
      return;
    }
    bread = read(fdinfile, &c, 1);
    while (!isspace(c) && bread >= 0) {
      readbuf[letcount++] = c;
      bread = read(fdinfile, &c, 1);
    }
    readbuf[letcount] = '\0';
    long filelen = 0;
    filelen = atoi(readbuf);
    letcount = 0;
    bread = read(fdinfile, &c, 1);
    while (c != '\n') {
      readbuf[letcount++] = c;
      bread = read(fdinfile, &c, 1);
    }
    readbuf[--letcount] = '\0';
    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\n", readbuf);
      close(fdinfile);
      return;
    }
    char *buff = NULL;
    int blocksize = 1024 * 64;
    int readb = 0;
    int writeb = 0;
    long countreadbytes = 0;
    long countwritebytes = 0;
    buff = (char *)malloc(blocksize * sizeof(char));
    if (filelen > 0) {
      if (blocksize > filelen)
        blocksize = filelen;
      int i = filelen / blocksize + 1;
      for (; i > 0; i--) {
        if (filelen < blocksize)
          blocksize = filelen;
        if (i == 1)
          blocksize = filelen - countreadbytes;
        readb = read(fdinfile, buff, blocksize);
        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);
    bread = read(fdinfile, &c, 1);
    int loopcount = 0;
    while (c != '\n') {
      loopcount++;
      bread = read(fdinfile, &c, 1);
    }
  }
  close(fdinfile);
}


x86 assembly (clang, -O0):
<unpackindex_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    122f <unpackindex_fd+0x5f>
mov    -0x18(%rbp),%rdi
call   10c0 <mymakedir@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     122a <unpackindex_fd+0x5a>
mov    -0x18(%rbp),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1238 <unpackindex_fd+0x68>
mov    -0x20(%rbp),%rdi
call   1080 <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,-0xb8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     12aa <unpackindex_fd+0xda>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x40(%rbp)
jmp    173a <unpackindex_fd+0x56a>
movl   $0x1,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
cmpl   $0x0,-0x48(%rbp)
jle    172b <unpackindex_fd+0x55b>
movl   $0x0,-0x3c(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jne    130b <unpackindex_fd+0x13b>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x40(%rbp)
jmp    173a <unpackindex_fd+0x56a>
movsbl -0x41(%rbp),%eax
cmp    $0x7b,%eax
je     133a <unpackindex_fd+0x16a>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x40(%rbp)
jmp    173a <unpackindex_fd+0x56a>
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
movsbl -0x41(%rbp),%edi
call   1090 <isspace@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xb9(%rbp)
jne    1377 <unpackindex_fd+0x1a7>
cmpl   $0x0,-0x48(%rbp)
setge  %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    138a <unpackindex_fd+0x1ba>
jmp    13be <unpackindex_fd+0x1ee>
mov    -0xb8(%rbp),%rax
mov    -0x41(%rbp),%dl
mov    -0x3c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x3c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
jmp    134e <unpackindex_fd+0x17e>
mov    -0xb8(%rbp),%rdi
movslq -0x3c(%rbp),%rax
movb   $0x0,(%rdi,%rax,1)
movq   $0x0,-0x68(%rbp)
call   10e0 <atoi@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
movsbl -0x41(%rbp),%eax
cmp    $0xa,%eax
je     143a <unpackindex_fd+0x26a>
mov    -0xb8(%rbp),%rax
mov    -0x41(%rbp),%dl
mov    -0x3c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x3c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
jmp    13f9 <unpackindex_fd+0x229>
mov    -0xb8(%rbp),%rdi
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
cltq
movb   $0x0,(%rdi,%rax,1)
mov    0x2b51(%rip),%rax
mov    (%rax),%esi
mov    0x2b98(%rip),%rax
or     (%rax),%esi
mov    0x2b87(%rip),%rax
or     (%rax),%esi
mov    0x2b4e(%rip),%rax
mov    (%rax),%edx
mov    0x2b25(%rip),%rax
or     (%rax),%edx
mov    0x2b34(%rip),%rax
or     (%rax),%edx
mov    0x2b43(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jg     14cc <unpackindex_fd+0x2fc>
mov    -0xb8(%rbp),%rsi
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x40(%rbp)
jmp    173a <unpackindex_fd+0x56a>
movq   $0x0,-0x78(%rbp)
movl   $0x10000,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0x98(%rbp)
movslq -0x7c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x68(%rbp)
jle    161d <unpackindex_fd+0x44d>
movslq -0x7c(%rbp),%rax
cmp    -0x68(%rbp),%rax
jle    1535 <unpackindex_fd+0x365>
mov    -0x68(%rbp),%rax
mov    %eax,-0x7c(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x7c(%rbp),%rcx
cqto
idiv   %rcx
add    $0x1,%rax
mov    %eax,-0x9c(%rbp)
cmpl   $0x0,-0x9c(%rbp)
jle    1606 <unpackindex_fd+0x436>
mov    -0x68(%rbp),%rax
movslq -0x7c(%rbp),%rcx
cmp    %rcx,%rax
jge    1571 <unpackindex_fd+0x3a1>
mov    -0x68(%rbp),%rax
mov    %eax,-0x7c(%rbp)
cmpl   $0x1,-0x9c(%rbp)
jne    158c <unpackindex_fd+0x3bc>
mov    -0x68(%rbp),%rax
sub    -0x90(%rbp),%rax
mov    %eax,-0x7c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    -0x7c(%rbp),%edx
call   10a0 <read@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0x0,-0x80(%rbp)
jle    15c2 <unpackindex_fd+0x3f2>
mov    -0x6c(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x84(%rbp)
jmp    15cb <unpackindex_fd+0x3fb>
mov    -0x80(%rbp),%eax
mov    %eax,-0x84(%rbp)
movslq -0x80(%rbp),%rax
add    -0x90(%rbp),%rax
mov    %rax,-0x90(%rbp)
movslq -0x84(%rbp),%rax
add    -0x98(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x9c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x9c(%rbp)
jmp    154c <unpackindex_fd+0x37c>
mov    -0x90(%rbp),%rax
mov    %eax,-0x80(%rbp)
mov    -0x98(%rbp),%rax
mov    %eax,-0x84(%rbp)
mov    -0xb8(%rbp),%rdi
movq   $0x0,-0xa8(%rbp)
lea    0xa46(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0xa8(%rbp)
cmp    $0x0,%rax
je     1658 <unpackindex_fd+0x488>
mov    -0x68(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0xb8(%rbp),%rdi
movq   $0x0,-0xa8(%rbp)
lea    0xa16(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,-0xa8(%rbp)
cmp    $0x0,%rax
je     1693 <unpackindex_fd+0x4c3>
mov    -0x68(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x6c(%rbp),%edi
call   1070 <close@plt>
mov    -0x80(%rbp),%eax
cmp    -0x84(%rbp),%eax
je     16d3 <unpackindex_fd+0x503>
mov    -0x80(%rbp),%esi
mov    -0x84(%rbp),%edx
lea    0x9c5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
movl   $0x0,-0xac(%rbp)
movsbl -0x41(%rbp),%eax
cmp    $0xa,%eax
je     1726 <unpackindex_fd+0x556>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,-0x48(%rbp)
jmp    16f1 <unpackindex_fd+0x521>
jmp    12c8 <unpackindex_fd+0xf8>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpackindex_fd>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
lea    0xe15(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     11ff <unpackindex_fd+0x2f>
mov    %rax,%rdi
call   1090 <closedir@plt>
jmp    1224 <unpackindex_fd+0x54>
lea    0xdfa(%rip),%rdi
call   10d0 <mymakedir@plt>
test   %eax,%eax
je     1224 <unpackindex_fd+0x54>
lea    0xdf0(%rip),%rdi
lea    0xde3(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%r12
add    $0xfffffffffffffc00,%r12
mov    %r12,%rsp
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   10e0 <open@plt>
test   %eax,%eax
jle    150c <unpackindex_fd+0x33c>
mov    %eax,%r13d
lea    -0x29(%rbp),%r14
mov    %r12,-0x40(%rbp)
mov    %eax,-0x34(%rbp)
jmp    1268 <unpackindex_fd+0x98>
nopl   0x0(%rax)
test   %eax,%eax
jle    1532 <unpackindex_fd+0x362>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %eax,%eax
je     1532 <unpackindex_fd+0x362>
cmpb   $0x7b,-0x29(%rbp)
jne    1526 <unpackindex_fd+0x356>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    %eax,%ebx
mov    -0x29(%rbp),%r15b
movsbl %r15b,%edi
call   10a0 <isspace@plt>
test   %ebx,%ebx
js     1300 <unpackindex_fd+0x130>
mov    $0x0,%ebx
test   %eax,%eax
jne    1314 <unpackindex_fd+0x144>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15b,(%r12,%rbx,1)
add    $0x1,%rbx
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    %eax,%r14d
movzbl -0x29(%rbp),%r15d
movsbl %r15b,%edi
call   10a0 <isspace@plt>
test   %r14d,%r14d
js     1310 <unpackindex_fd+0x140>
test   %eax,%eax
lea    -0x29(%rbp),%r14
je     12c0 <unpackindex_fd+0xf0>
jmp    1314 <unpackindex_fd+0x144>
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
jmp    1314 <unpackindex_fd+0x144>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x29(%rbp),%r14
mov    %ebx,%eax
movb   $0x0,(%r12,%rax,1)
mov    %r12,%rdi
call   10f0 <atoi@plt>
mov    %rax,%r15
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    -0x29(%rbp),%al
xor    %ebx,%ebx
cmp    $0xa,%al
je     1360 <unpackindex_fd+0x190>
nop
mov    %al,(%r12,%rbx,1)
add    $0x1,%rbx
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
movzbl -0x29(%rbp),%eax
cmp    $0xa,%al
jne    1340 <unpackindex_fd+0x170>
add    $0xffffffff,%ebx
movslq %ebx,%rax
mov    0x2c8b(%rip),%rcx
mov    (%rcx),%esi
mov    0x2c32(%rip),%rcx
or     (%rcx),%esi
mov    0x2c71(%rip),%rcx
or     (%rcx),%esi
movb   $0x0,(%r12,%rax,1)
mov    0x2c13(%rip),%rax
mov    (%rax),%edx
mov    0x2c2a(%rip),%rax
or     (%rax),%edx
mov    0x2c19(%rip),%rax
or     (%rax),%edx
mov    0x2c28(%rip),%rax
or     (%rax),%edx
mov    %r12,%rdi
xor    %eax,%eax
call   10e0 <open@plt>
mov    %eax,-0x30(%rbp)
test   %eax,%eax
jle    1548 <unpackindex_fd+0x378>
mov    $0x10000,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
test   %r15,%r15
jle    1490 <unpackindex_fd+0x2c0>
cmp    $0x10000,%r15
mov    $0x10000,%r13d
cmovb  %r15,%r13
mov    %r15,%rax
shr    $0x20,%rax
je     14a0 <unpackindex_fd+0x2d0>
mov    %r15,%rax
xor    %edx,%edx
div    %r13
cmp    $0x7ffffffe,%eax
ja     14b3 <unpackindex_fd+0x2e3>
mov    %r15,-0x50(%rbp)
add    $0x1,%eax
xor    %ebx,%ebx
xor    %r15d,%r15d
mov    %r14,-0x48(%rbp)
jmp    144d <unpackindex_fd+0x27d>
nopl   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%edi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <write@plt>
mov    %r12d,%ecx
add    %rcx,%r15
mov    %eax,%eax
mov    -0x60(%rbp),%rbx
add    %rax,%rbx
mov    -0x58(%rbp),%rcx
lea    -0x1(%rcx),%eax
cmp    $0x1,%ecx
mov    -0x48(%rbp),%r14
jle    14b8 <unpackindex_fd+0x2e8>
mov    %rbx,-0x60(%rbp)
movslq %r13d,%rdx
mov    -0x50(%rbp),%rbx
cmp    %rdx,%rbx
cmovl  %ebx,%edx
mov    %ebx,%r13d
sub    %r15d,%r13d
mov    %rax,-0x58(%rbp)
cmp    $0x1,%eax
cmovne %edx,%r13d
mov    -0x34(%rbp),%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   10b0 <read@plt>
mov    %eax,%r12d
test   %eax,%eax
jg     1420 <unpackindex_fd+0x250>
mov    %r12d,%eax
jmp    142e <unpackindex_fd+0x25e>
nopl   0x0(%rax)
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    14c0 <unpackindex_fd+0x2f0>
nopw   0x0(%rax,%rax,1)
mov    %r15d,%eax
xor    %edx,%edx
div    %r13d
cmp    $0x7ffffffe,%eax
jbe    1406 <unpackindex_fd+0x236>
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    -0x40(%rbp),%r12
mov    -0x34(%rbp),%r13d
mov    %r14,%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%edi
call   1080 <close@plt>
cmp    %ebx,%r15d
je     14e8 <unpackindex_fd+0x318>
lea    0xb79(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
lea    -0x29(%rbp),%r14
nop
mov    %r14,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmpb   $0xa,-0x29(%rbp)
je     1260 <unpackindex_fd+0x90>
mov    %r13d,%edi
jmp    14f0 <unpackindex_fd+0x320>
lea    0xb8b(%rip),%rdi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
lea    0xb69(%rip),%rdi
call   1040 <puts@plt>
mov    %r13d,%edi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <close@plt>
lea    0xae0(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
call   1080 <close@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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