#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 u_int;
typedef char u_char;
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ chdir(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int fwrite(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putfile(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ read_err();
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ std_err();
int /*<<< orphan*/ stdout;
int strlen(char *);
int /*<<< orphan*/ write_err();
void pack(u_char *list, u_char *indir, u_char *output) {
  struct stat xstat;
  FILE *fd, *fdl;
  u_int id, attr, num, name, off, size, curroff, headsize;
  u_char buff[512], *fname, *p;
  printf("- open input listfile:       %s\n", list);
  fdl = fopen(list, "rb");
  if (!fdl)
    std_err();
  printf("- create output PAK file:    %s\n", output);
  fd = fopen(output, "wb");
  if (!fd)
    std_err();
  printf("- enter in input directory:  %s\n", indir);
  if (chdir(indir) < 0)
    std_err();
  if (!fgets(buff, sizeof(buff) - 1, fdl))
    read_err();
  for (p = buff; *p > '\r'; p++)
    ;
  *p = 0;
  ;
  sscanf(buff, "%08x", &id);
  printf("- ID:                        0x%08x\n", id);
  if (fwrite((void *)&id, 4, 1, fd) != 1)
    write_err();
  if (!fgets(buff, sizeof(buff) - 1, fdl))
    read_err();
  for (p = buff; *p > '\r'; p++)
    ;
  *p = 0;
  ;
  sscanf(buff, "%08x", &num);
  printf("- Number of files:           0x%08x\n", num);
  if (fwrite((void *)&num, 4, 1, fd) != 1)
    write_err();
  if (!fgets(buff, sizeof(buff) - 1, fdl))
    read_err();
  for (p = buff; *p > '\r'; p++)
    ;
  *p = 0;
  ;
  sscanf(buff, "%08x", &headsize);
  printf("- Header size:               0x%08x\n", headsize);
  fputs("\n"
        "Filesize     Offset   Filename\n"
        "----------------------------------------------------------------------"
        "--------\n",
        stdout);
  off = headsize;
  while (num--) {
    if (!fgets(buff, sizeof(buff) - 1, fdl))
      read_err();
    for (p = buff; *p > '\r'; p++)
      ;
    *p = 0;
    ;
    sscanf(buff, "%08x", &attr);
    for (p = buff; *p && (*p != ' '); p++)
      ;
    fname = p + 1;
    name = strlen(fname);
    if (fwrite((void *)&name, 4, 1, fd) != 1)
      write_err();
    printf("                      %s\r", fname);
    if (fwrite(fname, name, 1, fd) != 1)
      write_err();
    for (p = fname; *p; p++) {
      if (*p == '\\')
        *p = '/';
    }
    if (!memcmp(fname, "..", 2))
      fname += 3;
    off -= headsize;
    if (fwrite((void *)&off, 4, 1, fd) != 1)
      write_err();
    if (stat(fname, &xstat) < 0)
      std_err();
    size = xstat.st_size;
    printf("%-12lu ", xstat.st_size);
    size += 4;
    if (fwrite((void *)&size, 4, 1, fd) != 1)
      write_err();
    size -= 4;
    printf("%08x\n", off);
    off += headsize;
    curroff = ftell(fd);
    if (fseek(fd, off, SEEK_SET) < 0)
      std_err();
    if (fwrite((void *)&attr, 4, 1, fd) != 1)
      write_err();
    putfile(fname, fd, size);
    off = ftell(fd);
    if (fseek(fd, curroff, SEEK_SET) < 0)
      std_err();
  }
  fclose(fd);
  fclose(fdl);
}


x86 assembly (clang, -O0):
<pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    125f <pack+0x4f>
mov    $0x0,%al
call   1130 <std_err@plt>
mov    -0x18(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1297 <pack+0x87>
mov    $0x0,%al
call   1130 <std_err@plt>
mov    -0x10(%rbp),%rsi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <chdir@plt>
cmp    $0x0,%rax
jge    12c3 <pack+0xb3>
mov    $0x0,%al
call   1130 <std_err@plt>
lea    -0x250(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x1ff,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%eax
jne    12e8 <pack+0xd8>
mov    $0x0,%al
call   1040 <read_err@plt>
lea    -0x250(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x260(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jle    1325 <pack+0x115>
jmp    130e <pack+0xfe>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
jmp    12f6 <pack+0xe6>
mov    -0x260(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x250(%rbp),%rdi
lea    0xd2c(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   10e0 <sscanf@plt>
mov    -0x34(%rbp),%esi
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x34(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     137e <pack+0x16e>
mov    $0x0,%al
call   1120 <write_err@plt>
lea    -0x250(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x1ff,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%eax
jne    13a3 <pack+0x193>
mov    $0x0,%al
call   1040 <read_err@plt>
lea    -0x250(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x260(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jle    13e0 <pack+0x1d0>
jmp    13c9 <pack+0x1b9>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
jmp    13b1 <pack+0x1a1>
mov    -0x260(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x250(%rbp),%rdi
lea    0xc71(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   10e0 <sscanf@plt>
mov    -0x3c(%rbp),%esi
lea    0xc88(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x3c(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1439 <pack+0x229>
mov    $0x0,%al
call   1120 <write_err@plt>
lea    -0x250(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x1ff,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%eax
jne    145e <pack+0x24e>
mov    $0x0,%al
call   1040 <read_err@plt>
lea    -0x250(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x260(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jle    149b <pack+0x28b>
jmp    1484 <pack+0x274>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
jmp    146c <pack+0x25c>
mov    -0x260(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x250(%rbp),%rdi
lea    0xbb6(%rip),%rsi
lea    -0x50(%rbp),%rdx
call   10e0 <sscanf@plt>
mov    -0x50(%rbp),%esi
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2b04(%rip),%rax
mov    (%rax),%esi
lea    0xc00(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x50(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x3c(%rbp)
cmp    $0x0,%eax
je     185c <pack+0x64c>
lea    -0x250(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x1ff,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%eax
jne    1521 <pack+0x311>
mov    $0x0,%al
call   1040 <read_err@plt>
lea    -0x250(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x260(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jle    155e <pack+0x34e>
jmp    1547 <pack+0x337>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
jmp    152f <pack+0x31f>
mov    -0x260(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x250(%rbp),%rdi
lea    0xaf3(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   10e0 <sscanf@plt>
lea    -0x250(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x260(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x261(%rbp)
je     15be <pack+0x3ae>
mov    -0x260(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x261(%rbp)
mov    -0x261(%rbp),%al
test   $0x1,%al
jne    15d1 <pack+0x3c1>
jmp    15ed <pack+0x3dd>
jmp    15d6 <pack+0x3c6>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
jmp    158d <pack+0x37d>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x258(%rbp)
mov    -0x258(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1635 <pack+0x425>
mov    $0x0,%al
call   1120 <write_err@plt>
mov    -0x258(%rbp),%rsi
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x258(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1672 <pack+0x462>
mov    $0x0,%al
call   1120 <write_err@plt>
mov    -0x258(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x260(%rbp),%rax
cmpb   $0x0,(%rax)
je     16c9 <pack+0x4b9>
mov    -0x260(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    16ad <pack+0x49d>
mov    -0x260(%rbp),%rax
movb   $0x2f,(%rax)
jmp    16b2 <pack+0x4a2>
mov    -0x260(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x260(%rbp)
jmp    1680 <pack+0x470>
mov    -0x258(%rbp),%rdi
lea    0xa90(%rip),%rsi
mov    $0x2,%edx
call   1090 <memcmp@plt>
cmp    $0x0,%eax
jne    16fc <pack+0x4ec>
mov    -0x258(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x258(%rbp)
mov    -0x50(%rbp),%ecx
mov    -0x44(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
lea    -0x44(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     172e <pack+0x51e>
mov    $0x0,%al
call   1120 <write_err@plt>
mov    -0x258(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10d0 <stat@plt>
cmp    $0x0,%rax
jge    174f <pack+0x53f>
mov    $0x0,%al
call   1130 <std_err@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%esi
lea    0xa0b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x48(%rbp)
lea    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1796 <pack+0x586>
mov    $0x0,%al
call   1120 <write_err@plt>
mov    -0x48(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%esi
lea    0x8e4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x50(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    0x280d(%rip),%rax
mov    (%rax),%edx
call   10f0 <fseek@plt>
cmp    $0x0,%rax
jge    17eb <pack+0x5db>
mov    $0x0,%al
call   1130 <std_err@plt>
lea    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1812 <pack+0x602>
mov    $0x0,%al
call   1120 <write_err@plt>
mov    -0x258(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%edx
call   10b0 <putfile@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    0x27a1(%rip),%rax
mov    (%rax),%edx
call   10f0 <fseek@plt>
cmp    $0x0,%rax
jge    1857 <pack+0x647>
mov    $0x0,%al
call   1130 <std_err@plt>
jmp    14e8 <pack+0x2d8>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pack>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xdcf(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xddf(%rip),%rsi
mov    %rbp,%rdi
call   1100 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
jne    125b <pack+0x4b>
xor    %eax,%eax
call   1130 <std_err@plt>
lea    0xdc2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd2(%rip),%rsi
mov    %rbx,%rdi
call   1100 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    128a <pack+0x7a>
xor    %eax,%eax
call   1130 <std_err@plt>
lea    0xdb7(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
call   1060 <chdir@plt>
test   %rax,%rax
jns    12af <pack+0x9f>
xor    %eax,%eax
call   1130 <std_err@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
mov    0x10(%rsp),%rdx
call   10a0 <fgets@plt>
test   %eax,%eax
jne    12e0 <pack+0xd0>
xor    %eax,%eax
call   1040 <read_err@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0xd,(%rbx)
lea    0x1(%rbx),%rbx
jg     12e0 <pack+0xd0>
movb   $0x0,-0x1(%rbx)
lea    0xd75(%rip),%rsi
lea    0x30(%rsp),%rdi
lea    0x28(%rsp),%rbx
mov    %rbx,%rdx
call   10e0 <sscanf@plt>
mov    0x28(%rsp),%esi
lea    0xd5d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1339 <pack+0x129>
xor    %eax,%eax
call   1120 <write_err@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
mov    0x10(%rsp),%rdx
call   10a0 <fgets@plt>
test   %eax,%eax
jne    1360 <pack+0x150>
xor    %eax,%eax
call   1040 <read_err@plt>
nopl   0x0(%rax,%rax,1)
cmpb   $0xd,(%rbx)
lea    0x1(%rbx),%rbx
jg     1360 <pack+0x150>
movb   $0x0,-0x1(%rbx)
lea    0xcf5(%rip),%rsi
lea    0x30(%rsp),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rdx
call   10e0 <sscanf@plt>
mov    0xc(%rsp),%esi
lea    0xd02(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     13b9 <pack+0x1a9>
xor    %eax,%eax
call   1120 <write_err@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
mov    0x10(%rsp),%rdx
call   10a0 <fgets@plt>
test   %eax,%eax
jne    13e0 <pack+0x1d0>
xor    %eax,%eax
call   1040 <read_err@plt>
nopl   0x0(%rax,%rax,1)
cmpb   $0xd,(%rbx)
lea    0x1(%rbx),%rbx
jg     13e0 <pack+0x1d0>
movb   $0x0,-0x1(%rbx)
lea    0xc75(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
call   10e0 <sscanf@plt>
mov    (%rsp),%esi
lea    0xcaa(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2bbc(%rip),%rax
mov    (%rax),%esi
lea    0xcb8(%rip),%rdi
call   1080 <fputs@plt>
mov    (%rsp),%eax
mov    %eax,0x4(%rsp)
subl   $0x1,0xc(%rsp)
jae    145c <pack+0x24c>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <fclose@plt>
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x2c(%rsp),%r15
jmp    14b2 <pack+0x2a2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   10b0 <putfile@plt>
mov    %r14,%rdi
call   10c0 <ftell@plt>
mov    %eax,0x4(%rsp)
mov    0x2b50(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %r12d,%esi
call   10f0 <fseek@plt>
test   %rax,%rax
js     16c0 <pack+0x4b0>
subl   $0x1,0xc(%rsp)
lea    0x30(%rsp),%rbx
jb     1438 <pack+0x228>
mov    %rbx,%rdi
mov    $0x1ff,%esi
mov    0x10(%rsp),%rdx
call   10a0 <fgets@plt>
test   %eax,%eax
jne    14cf <pack+0x2bf>
xor    %eax,%eax
call   1040 <read_err@plt>
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0xd,(%rax)
lea    0x1(%rax),%rax
jg     14e0 <pack+0x2d0>
movb   $0x0,-0x1(%rax)
mov    %rbx,%rdi
lea    0xb72(%rip),%rsi
mov    %r15,%rdx
call   10e0 <sscanf@plt>
lea    0x34(%rsp),%rbp
testb  $0xdf,-0x4(%rbp)
je     151a <pack+0x30a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
testb  $0xdf,-0x4(%rbp)
jne    1510 <pack+0x300>
lea    -0x3(%rbp),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,0x1c(%rsp)
lea    0x1c(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     154d <pack+0x33d>
xor    %eax,%eax
call   1120 <write_err@plt>
lea    0xbf9(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %r12,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     157e <pack+0x36e>
xor    %eax,%eax
call   1120 <write_err@plt>
mov    %r12,%rax
jmp    1597 <pack+0x387>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x2f,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x5c,%cl
je     1590 <pack+0x380>
test   %cl,%cl
jne    1593 <pack+0x383>
mov    %r12,%rdi
lea    0xbba(%rip),%rsi
mov    $0x2,%edx
call   1090 <memcmp@plt>
test   %eax,%eax
cmovne %r12,%rbp
mov    (%rsp),%eax
sub    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     15e7 <pack+0x3d7>
xor    %eax,%eax
call   1120 <write_err@plt>
mov    %rbp,%rdi
lea    0x20(%rsp),%rsi
call   10d0 <stat@plt>
test   %rax,%rax
jns    1600 <pack+0x3f0>
xor    %eax,%eax
call   1130 <std_err@plt>
mov    0x20(%rsp),%ebx
lea    0xb5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x4,%ebx
mov    %ebx,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     163e <pack+0x42e>
xor    %eax,%eax
call   1120 <write_err@plt>
mov    0x8(%rsp),%ebx
add    $0xfffffffc,%ebx
mov    %ebx,0x8(%rsp)
mov    0x4(%rsp),%r13d
lea    0xa38(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    (%rsp),%r13d
mov    %r14,%rdi
call   10c0 <ftell@plt>
mov    %eax,%r12d
mov    0x296b(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    %r13d,%esi
call   10f0 <fseek@plt>
test   %rax,%rax
jns    168e <pack+0x47e>
xor    %eax,%eax
call   1130 <std_err@plt>
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1110 <fwrite@plt>
cmp    $0x1,%eax
je     1470 <pack+0x260>
xor    %eax,%eax
call   1120 <write_err@plt>
jmp    1470 <pack+0x260>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1130 <std_err@plt>
jmp    14a6 <pack+0x296>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [33 x i8] c"- open input listfile: %s\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [33 x i8] c"- create output PAK file: %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [33 x i8] c"- enter in input directory: %s\0A\00"
@.str.5 = [5 x i8] c"%08x\00"
@.str.6 = [37 x i8] c"- ID: 0x%08x\0A\00"
@.str.7 = [37 x i8] c"- Number of files: 0x%08x\0A\00"
@.str.8 = [37 x i8] c"- Header size: 0x%08x\0A\00"
@.str.9 = [112 x i8] c"\0AFilesize Offset Filename\0A------------------------------------------------------------------------------\0A\00"
@stdout = global i32 0
@.str.10 = [26 x i8] c" %s\0D\00"
@.str.11 = [3 x i8] c"..\00"
@.str.12 = [8 x i8] c"%-12lu \00"
@.str.13 = [6 x i8] c"%08x\0A\00"
@SEEK_SET = global i32 0
define void @pack(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [512 x i8]
%19 = alloca i8*
%20 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%21 = load i8*, i8** %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %4
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %9
%25 = load i32*, i32** %9
%26 = icmp ne i32* %25, null
br i1 %26, label %29, label %27
27: ; preds = %3
%28 = call i32 (...) @std_err()
br label %29
29: ; preds = %27, %3
%30 = load i8*, i8** %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %6
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %33, i32** %8
%34 = load i32*, i32** %8
%35 = icmp ne i32* %34, null
br i1 %35, label %38, label %36
36: ; preds = %29
%37 = call i32 (...) @std_err()
br label %38
38: ; preds = %36, %29
%39 = load i8*, i8** %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %5
%42 = call i64 @chdir(i8* %41)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 (...) @std_err()
br label %46
46: ; preds = %44, %38
%47 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%48 = load i32*, i32** %9
%49 = call i32 @fgets(i8* %47, i32 511, i32* %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = call i32 (...) @read_err()
br label %53
53: ; preds = %51, %46
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
store i8* %54, i8** %20
br label %55
55: ; preds = %61, %53
%56 = load i8*, i8** %20
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp sgt i32 %58, 13
br i1 %59, label %60, label %64
60: ; preds = %55
br label %61
61: ; preds = %60
%62 = load i8*, i8** %20
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %20
br label %55
64: ; preds = %55
%65 = load i8*, i8** %20
store i8 0, i8* %65
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%67 = call i32 @sscanf(i8* %66, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %10)
%68 = load i32, i32* %10
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %68)
%70 = bitcast i32* %10 to i8*
%71 = load i32*, i32** %8
%72 = call i32 @fwrite(i8* %70, i32 4, i32 1, i32* %71)
%73 = icmp ne i32 %72, 1
br i1 %73, label %74, label %76
74: ; preds = %64
%75 = call i32 (...) @write_err()
br label %76
76: ; preds = %74, %64
%77 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%78 = load i32*, i32** %9
%79 = call i32 @fgets(i8* %77, i32 511, i32* %78)
%80 = icmp ne i32 %79, 0
br i1 %80, label %83, label %81
81: ; preds = %76
%82 = call i32 (...) @read_err()
br label %83
83: ; preds = %81, %76
%84 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
store i8* %84, i8** %20
br label %85
85: ; preds = %91, %83
%86 = load i8*, i8** %20
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp sgt i32 %88, 13
br i1 %89, label %90, label %94
90: ; preds = %85
br label %91
91: ; preds = %90
%92 = load i8*, i8** %20
%93 = getelementptr inbounds i8, i8* %92, i32 1
store i8* %93, i8** %20
br label %85
94: ; preds = %85
%95 = load i8*, i8** %20
store i8 0, i8* %95
%96 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%97 = call i32 @sscanf(i8* %96, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %12)
%98 = load i32, i32* %12
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %98)
%100 = bitcast i32* %12 to i8*
%101 = load i32*, i32** %8
%102 = call i32 @fwrite(i8* %100, i32 4, i32 1, i32* %101)
%103 = icmp ne i32 %102, 1
br i1 %103, label %104, label %106
104: ; preds = %94
%105 = call i32 (...) @write_err()
br label %106
106: ; preds = %104, %94
%107 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%108 = load i32*, i32** %9
%109 = call i32 @fgets(i8* %107, i32 511, i32* %108)
%110 = icmp ne i32 %109, 0
br i1 %110, label %113, label %111
111: ; preds = %106
%112 = call i32 (...) @read_err()
br label %113
113: ; preds = %111, %106
%114 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
store i8* %114, i8** %20
br label %115
115: ; preds = %121, %113
%116 = load i8*, i8** %20
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = icmp sgt i32 %118, 13
br i1 %119, label %120, label %124
120: ; preds = %115
br label %121
121: ; preds = %120
%122 = load i8*, i8** %20
%123 = getelementptr inbounds i8, i8* %122, i32 1
store i8* %123, i8** %20
br label %115
124: ; preds = %115
%125 = load i8*, i8** %20
store i8 0, i8* %125
%126 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%127 = call i32 @sscanf(i8* %126, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %17)
%128 = load i32, i32* %17
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %128)
%130 = load i32, i32* @stdout
%131 = call i32 @fputs(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.9, i64 0, i64 0), i32 %130)
%132 = load i32, i32* %17
store i32 %132, i32* %14
br label %133
133: ; preds = %289, %124
%134 = load i32, i32* %12
%135 = add nsw i32 %134, -1
store i32 %135, i32* %12
%136 = icmp ne i32 %134, 0
br i1 %136, label %137, label %290
137: ; preds = %133
%138 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%139 = load i32*, i32** %9
%140 = call i32 @fgets(i8* %138, i32 511, i32* %139)
%141 = icmp ne i32 %140, 0
br i1 %141, label %144, label %142
142: ; preds = %137
%143 = call i32 (...) @read_err()
br label %144
144: ; preds = %142, %137
%145 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
store i8* %145, i8** %20
br label %146
146: ; preds = %152, %144
%147 = load i8*, i8** %20
%148 = load i8, i8* %147
%149 = sext i8 %148 to i32
%150 = icmp sgt i32 %149, 13
br i1 %150, label %151, label %155
151: ; preds = %146
br label %152
152: ; preds = %151
%153 = load i8*, i8** %20
%154 = getelementptr inbounds i8, i8* %153, i32 1
store i8* %154, i8** %20
br label %146
155: ; preds = %146
%156 = load i8*, i8** %20
store i8 0, i8* %156
%157 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%158 = call i32 @sscanf(i8* %157, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %11)
%159 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
store i8* %159, i8** %20
br label %160
160: ; preds = %173, %155
%161 = load i8*, i8** %20
%162 = load i8, i8* %161
%163 = sext i8 %162 to i32
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %170
165: ; preds = %160
%166 = load i8*, i8** %20
%167 = load i8, i8* %166
%168 = sext i8 %167 to i32
%169 = icmp ne i32 %168, 32
br label %170
170: ; preds = %165, %160
%171 = phi i1 [ false, %160 ], [ %169, %165 ]
br i1 %171, label %172, label %176
172: ; preds = %170
br label %173
173: ; preds = %172
%174 = load i8*, i8** %20
%175 = getelementptr inbounds i8, i8* %174, i32 1
store i8* %175, i8** %20
br label %160
176: ; preds = %170
%177 = load i8*, i8** %20
%178 = getelementptr inbounds i8, i8* %177, i64 1
store i8* %178, i8** %19
%179 = load i8*, i8** %19
%180 = call i32 @strlen(i8* %179)
store i32 %180, i32* %13
%181 = bitcast i32* %13 to i8*
%182 = load i32*, i32** %8
%183 = call i32 @fwrite(i8* %181, i32 4, i32 1, i32* %182)
%184 = icmp ne i32 %183, 1
br i1 %184, label %185, label %187
185: ; preds = %176
%186 = call i32 (...) @write_err()
br label %187
187: ; preds = %185, %176
%188 = load i8*, i8** %19
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %188)
%190 = load i8*, i8** %19
%191 = load i32, i32* %13
%192 = load i32*, i32** %8
%193 = call i32 @fwrite(i8* %190, i32 %191, i32 1, i32* %192)
%194 = icmp ne i32 %193, 1
br i1 %194, label %195, label %197
195: ; preds = %187
%196 = call i32 (...) @write_err()
br label %197
197: ; preds = %195, %187
%198 = load i8*, i8** %19
store i8* %198, i8** %20
br label %199
199: ; preds = %211, %197
%200 = load i8*, i8** %20
%201 = load i8, i8* %200
%202 = icmp ne i8 %201, 0
br i1 %202, label %203, label %214
203: ; preds = %199
%204 = load i8*, i8** %20
%205 = load i8, i8* %204
%206 = sext i8 %205 to i32
%207 = icmp eq i32 %206, 92
br i1 %207, label %208, label %210
208: ; preds = %203
%209 = load i8*, i8** %20
store i8 47, i8* %209
br label %210
210: ; preds = %208, %203
br label %211
211: ; preds = %210
%212 = load i8*, i8** %20
%213 = getelementptr inbounds i8, i8* %212, i32 1
store i8* %213, i8** %20
br label %199
214: ; preds = %199
%215 = load i8*, i8** %19
%216 = call i32 @memcmp(i8* %215, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%217 = icmp ne i32 %216, 0
br i1 %217, label %221, label %218
218: ; preds = %214
%219 = load i8*, i8** %19
%220 = getelementptr inbounds i8, i8* %219, i64 3
store i8* %220, i8** %19
br label %221
221: ; preds = %218, %214
%222 = load i32, i32* %17
%223 = load i32, i32* %14
%224 = sub nsw i32 %223, %222
store i32 %224, i32* %14
%225 = bitcast i32* %14 to i8*
%226 = load i32*, i32** %8
%227 = call i32 @fwrite(i8* %225, i32 4, i32 1, i32* %226)
%228 = icmp ne i32 %227, 1
br i1 %228, label %229, label %231
229: ; preds = %221
%230 = call i32 (...) @write_err()
br label %231
231: ; preds = %229, %221
%232 = load i8*, i8** %19
%233 = call i64 @stat(i8* %232, %struct.stat* %7)
%234 = icmp slt i64 %233, 0
br i1 %234, label %235, label %237
235: ; preds = %231
%236 = call i32 (...) @std_err()
br label %237
237: ; preds = %235, %231
%238 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%239 = load i32, i32* %238
store i32 %239, i32* %15
%240 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%241 = load i32, i32* %240
%242 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 %241)
%243 = load i32, i32* %15
%244 = add nsw i32 %243, 4
store i32 %244, i32* %15
%245 = bitcast i32* %15 to i8*
%246 = load i32*, i32** %8
%247 = call i32 @fwrite(i8* %245, i32 4, i32 1, i32* %246)
%248 = icmp ne i32 %247, 1
br i1 %248, label %249, label %251
249: ; preds = %237
%250 = call i32 (...) @write_err()
br label %251
251: ; preds = %249, %237
%252 = load i32, i32* %15
%253 = sub nsw i32 %252, 4
store i32 %253, i32* %15
%254 = load i32, i32* %14
%255 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %254)
%256 = load i32, i32* %17
%257 = load i32, i32* %14
%258 = add nsw i32 %257, %256
store i32 %258, i32* %14
%259 = load i32*, i32** %8
%260 = call i32 @ftell(i32* %259)
store i32 %260, i32* %16
%261 = load i32*, i32** %8
%262 = load i32, i32* %14
%263 = load i32, i32* @SEEK_SET
%264 = call i64 @fseek(i32* %261, i32 %262, i32 %263)
%265 = icmp slt i64 %264, 0
br i1 %265, label %266, label %268
266: ; preds = %251
%267 = call i32 (...) @std_err()
br label %268
268: ; preds = %266, %251
%269 = bitcast i32* %11 to i8*
%270 = load i32*, i32** %8
%271 = call i32 @fwrite(i8* %269, i32 4, i32 1, i32* %270)
%272 = icmp ne i32 %271, 1
br i1 %272, label %273, label %275
273: ; preds = %268
%274 = call i32 (...) @write_err()
br label %275
275: ; preds = %273, %268
%276 = load i8*, i8** %19
%277 = load i32*, i32** %8
%278 = load i32, i32* %15
%279 = call i32 @putfile(i8* %276, i32* %277, i32 %278)
%280 = load i32*, i32** %8
%281 = call i32 @ftell(i32* %280)
store i32 %281, i32* %14
%282 = load i32*, i32** %8
%283 = load i32, i32* %16
%284 = load i32, i32* @SEEK_SET
%285 = call i64 @fseek(i32* %282, i32 %283, i32 %284)
%286 = icmp slt i64 %285, 0
br i1 %286, label %287, label %289
287: ; preds = %275
%288 = call i32 (...) @std_err()
br label %289
289: ; preds = %287, %275
br label %133
290: ; preds = %133
%291 = load i32*, i32** %8
%292 = call i32 @fclose(i32* %291)
%293 = load i32*, i32** %9
%294 = call i32 @fclose(i32* %293)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [33 x i8] c"- open input listfile: %s\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [33 x i8] c"- create output PAK file: %s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [33 x i8] c"- enter in input directory: %s\0A\00"
@.str.5 = [5 x i8] c"%08x\00"
@.str.6 = [37 x i8] c"- ID: 0x%08x\0A\00"
@.str.7 = [37 x i8] c"- Number of files: 0x%08x\0A\00"
@.str.8 = [37 x i8] c"- Header size: 0x%08x\0A\00"
@.str.9 = [112 x i8] c"\0AFilesize Offset Filename\0A------------------------------------------------------------------------------\0A\00"
@stdout = global i32 0
@.str.10 = [26 x i8] c" %s\0D\00"
@.str.11 = [3 x i8] c"..\00"
@.str.12 = [8 x i8] c"%-12lu \00"
@.str.13 = [6 x i8] c"%08x\0A\00"
@SEEK_SET = global i32 0
define void @pack(i8* %0, i8* %1, i8* %2) {
%4 = alloca %struct.stat
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [512 x i8]
%13 = bitcast %struct.stat* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i32* %10 to i8*
%20 = bitcast i32* %11 to i8*
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%23 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %3
%26 = tail call i32 (...) @std_err()
br label %27
27: ; preds = %25, %3
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%29 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 (...) @std_err()
br label %33
33: ; preds = %31, %27
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%35 = tail call i64 @chdir(i8* %1)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = tail call i32 (...) @std_err()
br label %39
39: ; preds = %37, %33
%40 = call i32 @fgets(i8* %21, i32 511, i32* %23)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 (...) @read_err()
br label %44
44: ; preds = %42, %39
br label %45
45: ; preds = %44, %45
%46 = phi i8* [ %49, %45 ], [ %21, %44 ]
%47 = load i8, i8* %46
%48 = icmp sgt i8 %47, 13
%49 = getelementptr inbounds i8, i8* %46, i64 1
br i1 %48, label %45, label %50
50: ; preds = %45
store i8 0, i8* %46
%51 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%52 = load i32, i32* %5
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = call i32 @fwrite(i8* %14, i32 4, i32 1, i32* %29)
%55 = icmp eq i32 %54, 1
br i1 %55, label %58, label %56
56: ; preds = %50
%57 = call i32 (...) @write_err()
br label %58
58: ; preds = %56, %50
%59 = call i32 @fgets(i8* %21, i32 511, i32* %23)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 (...) @read_err()
br label %63
63: ; preds = %61, %58
br label %64
64: ; preds = %63, %64
%65 = phi i8* [ %68, %64 ], [ %21, %63 ]
%66 = load i8, i8* %65
%67 = icmp sgt i8 %66, 13
%68 = getelementptr inbounds i8, i8* %65, i64 1
br i1 %67, label %64, label %69
69: ; preds = %64
store i8 0, i8* %65
%70 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %7)
%71 = load i32, i32* %7
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %71)
%73 = call i32 @fwrite(i8* %16, i32 4, i32 1, i32* %29)
%74 = icmp eq i32 %73, 1
br i1 %74, label %77, label %75
75: ; preds = %69
%76 = call i32 (...) @write_err()
br label %77
77: ; preds = %75, %69
%78 = call i32 @fgets(i8* %21, i32 511, i32* %23)
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (...) @read_err()
br label %82
82: ; preds = %80, %77
br label %83
83: ; preds = %82, %83
%84 = phi i8* [ %87, %83 ], [ %21, %82 ]
%85 = load i8, i8* %84
%86 = icmp sgt i8 %85, 13
%87 = getelementptr inbounds i8, i8* %84, i64 1
br i1 %86, label %83, label %88
88: ; preds = %83
store i8 0, i8* %84
%89 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %11)
%90 = load i32, i32* %11
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %90)
%92 = load i32, i32* @stdout
%93 = call i32 @fputs(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.9, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %11
store i32 %94, i32* %9
%95 = load i32, i32* %7
%96 = add nsw i32 %95, -1
store i32 %96, i32* %7
%97 = icmp eq i32 %95, 0
br i1 %97, label %194, label %98
98: ; preds = %88
%99 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %100
100: ; preds = %98, %190
%101 = call i32 @fgets(i8* %21, i32 511, i32* %23)
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %100
%104 = call i32 (...) @read_err()
br label %105
105: ; preds = %103, %100
br label %106
106: ; preds = %105, %106
%107 = phi i8* [ %110, %106 ], [ %21, %105 ]
%108 = load i8, i8* %107
%109 = icmp sgt i8 %108, 13
%110 = getelementptr inbounds i8, i8* %107, i64 1
br i1 %109, label %106, label %111
111: ; preds = %106
store i8 0, i8* %107
%112 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %6)
br label %113
113: ; preds = %116, %111
%114 = phi i8* [ %21, %111 ], [ %117, %116 ]
%115 = load i8, i8* %114
switch i8 %115, label %116 [
i8 0, label %118
i8 32, label %118
]
116: ; preds = %113
%117 = getelementptr inbounds i8, i8* %114, i64 1
br label %113
118: ; preds = %113, %113
%119 = getelementptr inbounds i8, i8* %114, i64 1
%120 = call i32 @strlen(i8* %119)
store i32 %120, i32* %8
%121 = call i32 @fwrite(i8* %17, i32 4, i32 1, i32* %29)
%122 = icmp eq i32 %121, 1
br i1 %122, label %125, label %123
123: ; preds = %118
%124 = call i32 (...) @write_err()
br label %125
125: ; preds = %123, %118
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %119)
%127 = load i32, i32* %8
%128 = call i32 @fwrite(i8* %119, i32 %127, i32 1, i32* %29)
%129 = icmp eq i32 %128, 1
br i1 %129, label %132, label %130
130: ; preds = %125
%131 = call i32 (...) @write_err()
br label %132
132: ; preds = %130, %125
br label %133
133: ; preds = %132, %137
%134 = phi i8* [ %138, %137 ], [ %119, %132 ]
%135 = load i8, i8* %134
switch i8 %135, label %137 [
i8 0, label %139
i8 92, label %136
]
136: ; preds = %133
store i8 47, i8* %134
br label %137
137: ; preds = %133, %136
%138 = getelementptr inbounds i8, i8* %134, i64 1
br label %133
139: ; preds = %133
%140 = call i32 @memcmp(i8* %119, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 2)
%141 = icmp eq i32 %140, 0
%142 = getelementptr inbounds i8, i8* %114, i64 4
%143 = select i1 %141, i8* %142, i8* %119
%144 = load i32, i32* %11
%145 = load i32, i32* %9
%146 = sub nsw i32 %145, %144
store i32 %146, i32* %9
%147 = call i32 @fwrite(i8* %18, i32 4, i32 1, i32* %29)
%148 = icmp eq i32 %147, 1
br i1 %148, label %151, label %149
149: ; preds = %139
%150 = call i32 (...) @write_err()
br label %151
151: ; preds = %149, %139
%152 = call i64 @stat(i8* %143, %struct.stat* %4)
%153 = icmp slt i64 %152, 0
br i1 %153, label %154, label %156
154: ; preds = %151
%155 = call i32 (...) @std_err()
br label %156
156: ; preds = %154, %151
%157 = load i32, i32* %99
%158 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 %157)
%159 = add nsw i32 %157, 4
store i32 %159, i32* %10
%160 = call i32 @fwrite(i8* %19, i32 4, i32 1, i32* %29)
%161 = icmp eq i32 %160, 1
br i1 %161, label %164, label %162
162: ; preds = %156
%163 = call i32 (...) @write_err()
br label %164
164: ; preds = %162, %156
%165 = load i32, i32* %10
%166 = add nsw i32 %165, -4
store i32 %166, i32* %10
%167 = load i32, i32* %9
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i32 %167)
%169 = load i32, i32* %11
%170 = add nsw i32 %169, %167
%171 = call i32 @ftell(i32* %29)
%172 = load i32, i32* @SEEK_SET
%173 = call i64 @fseek(i32* %29, i32 %170, i32 %172)
%174 = icmp slt i64 %173, 0
br i1 %174, label %175, label %177
175: ; preds = %164
%176 = call i32 (...) @std_err()
br label %177
177: ; preds = %175, %164
%178 = call i32 @fwrite(i8* %15, i32 4, i32 1, i32* %29)
%179 = icmp eq i32 %178, 1
br i1 %179, label %182, label %180
180: ; preds = %177
%181 = call i32 (...) @write_err()
br label %182
182: ; preds = %180, %177
%183 = call i32 @putfile(i8* %143, i32* %29, i32 %166)
%184 = call i32 @ftell(i32* %29)
store i32 %184, i32* %9
%185 = load i32, i32* @SEEK_SET
%186 = call i64 @fseek(i32* %29, i32 %171, i32 %185)
%187 = icmp slt i64 %186, 0
br i1 %187, label %188, label %190
188: ; preds = %182
%189 = call i32 (...) @std_err()
br label %190
190: ; preds = %188, %182
%191 = load i32, i32* %7
%192 = add nsw i32 %191, -1
store i32 %192, i32* %7
%193 = icmp eq i32 %191, 0
br i1 %193, label %194, label %100
194: ; preds = %190, %88
%195 = call i32 @fclose(i32* %29)
%196 = call i32 @fclose(i32* %23)
ret void
}