#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct stat {
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  int /*<<< orphan*/ d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ S_IRWXU;
scalar_t__ S_ISREG(int /*<<< orphan*/);
int asprintf(char **, char *, char *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int link(char *, char *);
char **malloc(unsigned int);
int mkdir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned long, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int rename(char *, char *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int rmdir(char *);
int stat(int /*<<< orphan*/, struct stat *);
char *strdup(int /*<<< orphan*/);
int unlink(char *);
int main() {
  unsigned nfiles, i;
  char **filenames;
  struct dirent *dirent;
  DIR *dir;
  struct timeval tv1, tv2;
  unsigned long usecs;
  int err;
  dir = opendir(".");
  nfiles = 0;
  while ((dirent = readdir(dir)) != NULL) {
    struct stat stbuf;
    err = stat(dirent->d_name, &stbuf);
    if (err < 0)
      continue;
    if (S_ISREG(stbuf.st_mode))
      nfiles++;
  }
  printf("Found %u files to tag\n", nfiles);
  filenames = malloc(nfiles * sizeof(*filenames));
  if (!filenames)
    exit(EXIT_FAILURE);
  rewinddir(dir);
  i = 0;
  while ((dirent = readdir(dir)) != NULL) {
    struct stat stbuf;
    err = stat(dirent->d_name, &stbuf);
    if (err < 0)
      continue;
    if (S_ISREG(stbuf.st_mode))
      filenames[i++] = strdup(dirent->d_name);
  }
  closedir(dir);
  err = mkdir("perfs_tmp_tag1", S_IRWXU);
  if (err < 0) {
    perror("mkdir");
    exit(EXIT_FAILURE);
  }
  err = mkdir("perfs_tmp_tag2", S_IRWXU);
  if (err < 0) {
    perror("mkdir");
    exit(EXIT_FAILURE);
  }
  gettimeofday(&tv1, NULL);
  for (i = 0; i < nfiles; i++) {
    char *linkname;
    err = asprintf(&linkname,
                   "perfs_tmp_tag1"
                   "/%s",
                   filenames[i]);
    assert(err >= 0);
    err = link(filenames[i], linkname);
    if (err < 0) {
      perror("link");
      exit(EXIT_FAILURE);
    }
    free(linkname);
    if (!(i & (i + 1))) {
      gettimeofday(&tv2, NULL);
      usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
      printf("%lu usecs for tagging %u files\n", usecs, i + 1);
    }
  }
  gettimeofday(&tv2, NULL);
  usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  printf("%lu usecs for tagging all %u files\n", usecs, nfiles);
  gettimeofday(&tv1, NULL);
  dir = opendir("perfs_tmp_tag1");
  assert(dir);
  while ((dirent = readdir(dir)) != NULL) {
    struct stat stbuf;
    err = stat(dirent->d_name, &stbuf);
    if (err < 0)
      perror("stat");
  }
  gettimeofday(&tv2, NULL);
  usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  printf("%lu usecs for listing and stat'ing all %u files\n", usecs, nfiles);
  gettimeofday(&tv1, NULL);
  for (i = 0; i < nfiles; i++) {
    char *oldlinkname, *newlinkname;
    err = asprintf(&oldlinkname,
                   "perfs_tmp_tag1"
                   "/%s",
                   filenames[(i + nfiles / 4) % nfiles]);
    assert(err >= 0);
    err = asprintf(&newlinkname,
                   "perfs_tmp_tag2"
                   "/%s",
                   filenames[(i + nfiles / 4) % nfiles]);
    assert(err >= 0);
    err = rename(oldlinkname, newlinkname);
    if (err < 0) {
      perror("rename");
      exit(EXIT_FAILURE);
    }
    free(oldlinkname);
    free(newlinkname);
    if (!(i & (i + 1))) {
      gettimeofday(&tv2, NULL);
      usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
      printf("%lu usecs for replacing tag %u files\n", usecs, i + 1);
    }
  }
  gettimeofday(&tv2, NULL);
  usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  printf("%lu usecs for tagging all %u files\n", usecs, nfiles);
  gettimeofday(&tv1, NULL);
  for (i = 0; i < nfiles; i++) {
    char *linkname;
    err = asprintf(&linkname,
                   "perfs_tmp_tag2"
                   "/%s",
                   filenames[(i + nfiles / 2) % nfiles]);
    assert(err >= 0);
    err = unlink(linkname);
    if (err < 0) {
      perror("unlink");
      exit(EXIT_FAILURE);
    }
    free(linkname);
    if (!(i & (i + 1))) {
      gettimeofday(&tv2, NULL);
      usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
      printf("%lu usecs for untagging %u files\n", usecs, i + 1);
    }
  }
  gettimeofday(&tv2, NULL);
  usecs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  printf("%lu usecs for untagging all %u files\n", usecs, nfiles);
  err = rmdir("perfs_tmp_tag1");
  if (err < 0) {
    perror("rmdir");
    exit(EXIT_FAILURE);
  }
  err = rmdir("perfs_tmp_tag2");
  if (err < 0) {
    perror("rmdir");
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xda7(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x28(%rbp),%rdi
call   10f0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12c1 <main+0x81>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
call   10d0 <stat@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    12a1 <main+0x61>
jmp    1269 <main+0x29>
mov    -0x48(%rbp),%edi
call   10e0 <S_ISREG@plt>
cmp    $0x0,%rax
je     12bc <main+0x7c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1269 <main+0x29>
mov    -0x8(%rbp),%eax
mov    %eax,%esi
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1100 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12ff <main+0xbf>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <rewinddir@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x28(%rbp),%rdi
call   10f0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1381 <main+0x141>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
call   10d0 <stat@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1347 <main+0x107>
jmp    130f <main+0xcf>
mov    -0x50(%rbp),%edi
call   10e0 <S_ISREG@plt>
cmp    $0x0,%rax
je     137c <main+0x13c>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1160 <strdup@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
mov    %ecx,%ecx
mov    %rdx,(%rax,%rcx,8)
jmp    130f <main+0xcf>
mov    -0x28(%rbp),%rdi
call   10b0 <closedir@plt>
mov    0x2c57(%rip),%rax
mov    (%rax),%esi
lea    0xc7f(%rip),%rdi
call   1050 <mkdir@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    13c6 <main+0x186>
lea    0xc75(%rip),%rdi
call   1120 <perror@plt>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%esi
lea    0xc58(%rip),%rdi
call   1050 <mkdir@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1402 <main+0x1c2>
lea    0xc39(%rip),%rdi
call   1120 <perror@plt>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    14fb <main+0x2bb>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    (%rax,%rcx,8),%rdx
lea    -0x58(%rbp),%rdi
lea    0xc05(%rip),%rsi
call   1110 <asprintf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x58(%rbp),%rsi
call   1140 <link@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    148c <main+0x24c>
lea    0xc91(%rip),%rdi
call   1120 <perror@plt>
mov    0x2b53(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    14e8 <main+0x2a8>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
lea    0xb6e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14ed <main+0x2ad>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1416 <main+0x1d6>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xb3f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
lea    0xace(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%edi
call   10c0 <assert@plt>
mov    -0x28(%rbp),%rdi
call   10f0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     15a3 <main+0x363>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   10d0 <stat@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    159e <main+0x35e>
lea    0xafa(%rip),%rdi
call   1120 <perror@plt>
jmp    155f <main+0x31f>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xac0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    173d <main+0x4fd>
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x2,%ecx
add    %ecx,%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    -0x88(%rbp),%rax
mov    %edx,%ecx
mov    (%rax,%rcx,8),%rdx
lea    -0x68(%rbp),%rdi
lea    0xa0b(%rip),%rsi
call   1110 <asprintf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x2,%ecx
add    %ecx,%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    -0x80(%rbp),%rax
mov    %edx,%ecx
mov    (%rax,%rcx,8),%rdx
lea    -0x70(%rbp),%rdi
lea    0xa51(%rip),%rsi
call   1110 <asprintf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1130 <rename@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    16c5 <main+0x485>
lea    0xa29(%rip),%rdi
call   1120 <perror@plt>
mov    0x291a(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    172a <main+0x4ea>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
lea    0x9bf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    172f <main+0x4ef>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    15f3 <main+0x3b3>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0x8fd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1884 <main+0x644>
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x1,%ecx
add    %ecx,%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    -0x90(%rbp),%rax
mov    %edx,%ecx
mov    (%rax,%rcx,8),%rdx
lea    -0x78(%rbp),%rdi
lea    0x8fd(%rip),%rsi
call   1110 <asprintf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    -0x78(%rbp),%rdi
call   1040 <unlink@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1815 <main+0x5d5>
lea    0x906(%rip),%rdi
call   1120 <perror@plt>
mov    0x27ca(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    1871 <main+0x631>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
lea    0x8a5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1876 <main+0x636>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    178d <main+0x54d>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x34(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0x878(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0x752(%rip),%rdi
call   1070 <rmdir@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    18f3 <main+0x6b3>
lea    0x877(%rip),%rdi
call   1120 <perror@plt>
mov    0x26ec(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
lea    0x734(%rip),%rdi
call   1070 <rmdir@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1926 <main+0x6e6>
lea    0x844(%rip),%rdi
call   1120 <perror@plt>
mov    0x26b9(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
mov    0x26a3(%rip),%rax
mov    (%rax),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xdab(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   10f0 <readdir@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12ac <main+0x6c>
mov    %rsp,%r14
jmp    128d <main+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10f0 <readdir@plt>
test   %rax,%rax
je     12ac <main+0x6c>
mov    (%rax),%edi
mov    %r14,%rsi
call   10d0 <stat@plt>
test   %eax,%eax
js     1280 <main+0x40>
mov    (%rsp),%edi
call   10e0 <S_ISREG@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
jmp    1280 <main+0x40>
mov    %ebp,%esi
lea    0xd4d(%rip),%rdi
mov    %rsi,0x20(%rsp)
xor    %eax,%eax
call   1080 <printf@plt>
shl    $0x3,%ebp
mov    %ebp,%edi
call   1100 <malloc@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     1828 <main+0x5e8>
mov    %r15,%rdi
call   10a0 <rewinddir@plt>
mov    %r15,%rdi
call   10f0 <readdir@plt>
test   %rax,%rax
je     1344 <main+0x104>
mov    %rax,%rbp
xor    %ebx,%ebx
mov    %rsp,%r12
jmp    1310 <main+0xd0>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10f0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1344 <main+0x104>
mov    0x0(%rbp),%edi
mov    %r12,%rsi
call   10d0 <stat@plt>
test   %eax,%eax
js     1300 <main+0xc0>
mov    (%rsp),%edi
call   10e0 <S_ISREG@plt>
test   %rax,%rax
je     1300 <main+0xc0>
mov    0x0(%rbp),%edi
call   1160 <strdup@plt>
mov    %ebx,%ecx
add    $0x1,%ebx
mov    0x28(%rsp),%rdx
mov    %rax,(%rdx,%rcx,8)
jmp    1300 <main+0xc0>
mov    %r15,%rdi
call   10b0 <closedir@plt>
mov    0x2c95(%rip),%rbx
mov    (%rbx),%esi
lea    0xcbd(%rip),%rdi
call   1050 <mkdir@plt>
test   %eax,%eax
js     1836 <main+0x5f6>
mov    (%rbx),%esi
lea    0xcbc(%rip),%rdi
call   1050 <mkdir@plt>
test   %eax,%eax
mov    0x20(%rsp),%r15
js     1836 <main+0x5f6>
mov    %rsp,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
test   %r15,%r15
je     146c <main+0x22c>
mov    (%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x14(%rsp)
neg    %r15
mov    $0x1,%ebx
lea    0xc88(%rip),%r12
lea    0x18(%rsp),%r14
jmp    13d6 <main+0x196>
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
je     145d <main+0x21d>
mov    0x28(%rsp),%rax
mov    -0x8(%rax,%rbx,8),%r13
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1110 <asprintf@plt>
not    %eax
shr    $0x1f,%eax
mov    %eax,%edi
call   10c0 <assert@plt>
mov    0x18(%rsp),%rsi
mov    %r13,%rdi
call   1140 <link@plt>
test   %eax,%eax
js     180a <main+0x5ca>
lea    -0x1(%rbx),%rbp
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
test   %ebp,%ebx
jne    13c0 <main+0x180>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0xf4240,%eax,%eax
sub    0x14(%rsp),%ecx
add    %eax,%ecx
movslq %ecx,%rsi
lea    0xc00(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    13c0 <main+0x180>
mov    0x20(%rsp),%r15
mov    0x14(%rsp),%ebx
mov    0x10(%rsp),%ebp
jmp    1473 <main+0x233>
mov    (%rsp),%ebp
mov    0x4(%rsp),%ebx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    %ebp,%eax
mov    0xc(%rsp),%ecx
sub    %ebx,%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
movslq %eax,%rsi
lea    0xbd2(%rip),%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
lea    0xb61(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   10c0 <assert@plt>
mov    %rbx,%rdi
call   10f0 <readdir@plt>
test   %rax,%rax
je     1515 <main+0x2d5>
lea    0x18(%rsp),%rbp
lea    0xbb3(%rip),%r12
jmp    14fd <main+0x2bd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   10f0 <readdir@plt>
test   %rax,%rax
je     1515 <main+0x2d5>
mov    (%rax),%edi
mov    %rbp,%rsi
call   10d0 <stat@plt>
test   %eax,%eax
jns    14f0 <main+0x2b0>
mov    %r12,%rdi
call   1120 <perror@plt>
jmp    14f0 <main+0x2b0>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    (%rsp),%eax
imul   $0xf4240,%eax,%eax
sub    0x4(%rsp),%ecx
add    %eax,%ecx
movslq %ecx,%rsi
lea    0xb56(%rip),%rdi
mov    0x20(%rsp),%rbx
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
test   %rbx,%rbx
je     166c <main+0x42c>
mov    %ebx,%r15d
shr    $0x2,%r15d
mov    (%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x14(%rsp)
lea    0xb49(%rip),%r13
lea    0x30(%rsp),%r14
xor    %ebp,%ebp
jmp    15a1 <main+0x361>
nopl   0x0(%rax)
mov    %r12d,%ebp
mov    0x20(%rsp),%rbx
cmp    %r12d,%ebx
je     1661 <main+0x421>
lea    (%r15,%rbp,1),%eax
xor    %edx,%edx
div    %ebx
mov    0x28(%rsp),%rax
mov    (%rax,%rdx,8),%rbx
lea    0x18(%rsp),%rdi
lea    0xa7f(%rip),%rsi
mov    %rbx,%rdx
call   1110 <asprintf@plt>
not    %eax
shr    $0x1f,%eax
mov    %eax,%edi
call   10c0 <assert@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1110 <asprintf@plt>
not    %eax
shr    $0x1f,%eax
mov    %eax,%edi
call   10c0 <assert@plt>
mov    0x18(%rsp),%rdi
mov    0x30(%rsp),%rsi
call   1130 <rename@plt>
test   %eax,%eax
js     1813 <main+0x5d3>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
lea    0x1(%rbp),%r12d
test   %ebp,%r12d
jne    1590 <main+0x350>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0xf4240,%eax,%eax
sub    0x14(%rsp),%ecx
add    %eax,%ecx
movslq %ecx,%rsi
lea    0xa90(%rip),%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1590 <main+0x350>
mov    0x14(%rsp),%r14d
mov    0x10(%rsp),%ebp
jmp    1674 <main+0x434>
mov    (%rsp),%ebp
mov    0x4(%rsp),%r14d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    %ebp,%eax
mov    0xc(%rsp),%ecx
sub    %r14d,%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
movslq %eax,%rsi
lea    0x9d0(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
test   %rbx,%rbx
je     1796 <main+0x556>
mov    %ebx,%r14d
shr    %r14d
mov    (%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x14(%rsp)
lea    0x9f2(%rip),%r13
lea    0x18(%rsp),%rbp
xor    %r15d,%r15d
jmp    1701 <main+0x4c1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%r15d
mov    0x20(%rsp),%rbx
cmp    %r12d,%ebx
je     178b <main+0x54b>
lea    (%r14,%r15,1),%eax
xor    %edx,%edx
div    %ebx
mov    0x28(%rsp),%rax
mov    (%rax,%rdx,8),%rdx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1110 <asprintf@plt>
not    %eax
shr    $0x1f,%eax
mov    %eax,%edi
call   10c0 <assert@plt>
mov    0x18(%rsp),%rdi
call   1040 <unlink@plt>
test   %eax,%eax
js     181c <main+0x5dc>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
lea    0x1(%r15),%r12d
test   %r15d,%r12d
jne    16f0 <main+0x4b0>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    0x10(%rsp),%eax
imul   $0xf4240,%eax,%eax
sub    0x14(%rsp),%ecx
add    %eax,%ecx
movslq %ecx,%rsi
lea    0x993(%rip),%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    16f0 <main+0x4b0>
mov    0x14(%rsp),%r14d
mov    0x10(%rsp),%ebp
jmp    179e <main+0x55e>
mov    (%rsp),%ebp
mov    0x4(%rsp),%r14d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    %ebp,%eax
mov    0xc(%rsp),%ecx
sub    %r14d,%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
movslq %eax,%rsi
lea    0x968(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x840(%rip),%rdi
call   1070 <rmdir@plt>
test   %eax,%eax
js     183f <main+0x5ff>
lea    0x845(%rip),%rdi
call   1070 <rmdir@plt>
test   %eax,%eax
js     183f <main+0x5ff>
mov    0x27d7(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8f9(%rip),%rdi
jmp    1823 <main+0x5e3>
lea    0x8c1(%rip),%rdi
jmp    1823 <main+0x5e3>
lea    0x8e5(%rip),%rdi
call   1120 <perror@plt>
mov    0x27a9(%rip),%rax
mov    (%rax),%edi
call   1150 <exit@plt>
lea    0x7eb(%rip),%rdi
jmp    1823 <main+0x5e3>
lea    0x911(%rip),%rdi
jmp    1823 <main+0x5e3>

LLVM IR (-O0):
%struct.dirent = type { i32 }
%struct.timeval = type { i32, i32 }
%struct.stat = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [23 x i8] c"Found %u files to tag\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [15 x i8] c"perfs_tmp_tag1\00"
@S_IRWXU = global i32 0
@.str.3 = [6 x i8] c"mkdir\00"
@.str.4 = [15 x i8] c"perfs_tmp_tag2\00"
@.str.5 = [18 x i8] c"perfs_tmp_tag1/%s\00"
@.str.6 = [5 x i8] c"link\00"
@.str.7 = [32 x i8] c"%lu usecs for tagging %u files\0A\00"
@.str.8 = [36 x i8] c"%lu usecs for tagging all %u files\0A\00"
@.str.9 = [5 x i8] c"stat\00"
@.str.10 = [49 x i8] c"%lu usecs for listing and stat'ing all %u files\0A\00"
@.str.11 = [18 x i8] c"perfs_tmp_tag2/%s\00"
@.str.12 = [7 x i8] c"rename\00"
@.str.13 = [38 x i8] c"%lu usecs for replacing tag %u files\0A\00"
@.str.14 = [7 x i8] c"unlink\00"
@.str.15 = [34 x i8] c"%lu usecs for untagging %u files\0A\00"
@.str.16 = [38 x i8] c"%lu usecs for untagging all %u files\0A\00"
@.str.17 = [6 x i8] c"rmdir\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.dirent*
%6 = alloca i32*
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca i64
%10 = alloca i32
%11 = alloca %struct.stat
%12 = alloca %struct.stat
%13 = alloca i8*
%14 = alloca %struct.stat
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
store i32 0, i32* %1
%18 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %6
store i32 0, i32* %2
br label %19
19: ; preds = %39, %30, %0
%20 = load i32*, i32** %6
%21 = call %struct.dirent* @readdir(i32* %20)
store %struct.dirent* %21, %struct.dirent** %5
%22 = icmp ne %struct.dirent* %21, null
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load %struct.dirent*, %struct.dirent** %5
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 @stat(i32 %26, %struct.stat* %11)
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
br label %19
31: ; preds = %23
%32 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i64 @S_ISREG(i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32, i32* %2
%38 = add i32 %37, 1
store i32 %38, i32* %2
br label %39
39: ; preds = %36, %31
br label %19
40: ; preds = %19
%41 = load i32, i32* %2
%42 = zext i32 %41 to i64
%43 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %42)
%44 = load i32, i32* %2
%45 = zext i32 %44 to i64
%46 = mul i64 %45, 8
%47 = trunc i64 %46 to i32
%48 = call i8** @malloc(i32 %47)
store i8** %48, i8*** %4
%49 = load i8**, i8*** %4
%50 = icmp ne i8** %49, null
br i1 %50, label %54, label %51
51: ; preds = %40
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %40
%55 = load i32*, i32** %6
%56 = call i32 @rewinddir(i32* %55)
store i32 0, i32* %3
br label %57
57: ; preds = %84, %68, %54
%58 = load i32*, i32** %6
%59 = call %struct.dirent* @readdir(i32* %58)
store %struct.dirent* %59, %struct.dirent** %5
%60 = icmp ne %struct.dirent* %59, null
br i1 %60, label %61, label %85
61: ; preds = %57
%62 = load %struct.dirent*, %struct.dirent** %5
%63 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i32 0, i32 0
%64 = load i32, i32* %63
%65 = call i32 @stat(i32 %64, %struct.stat* %12)
store i32 %65, i32* %10
%66 = load i32, i32* %10
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %61
br label %57
69: ; preds = %61
%70 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%71 = load i32, i32* %70
%72 = call i64 @S_ISREG(i32 %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %84
74: ; preds = %69
%75 = load %struct.dirent*, %struct.dirent** %5
%76 = getelementptr inbounds %struct.dirent, %struct.dirent* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = call i8* @strdup(i32 %77)
%79 = load i8**, i8*** %4
%80 = load i32, i32* %3
%81 = add i32 %80, 1
store i32 %81, i32* %3
%82 = zext i32 %80 to i64
%83 = getelementptr inbounds i8*, i8** %79, i64 %82
store i8* %78, i8** %83
br label %84
84: ; preds = %74, %69
br label %57
85: ; preds = %57
%86 = load i32*, i32** %6
%87 = call i32 @closedir(i32* %86)
%88 = load i32, i32* @S_IRWXU
%89 = call i32 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %88)
store i32 %89, i32* %10
%90 = load i32, i32* %10
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %85
%93 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 @exit(i32 %94)
unreachable
96: ; preds = %85
%97 = load i32, i32* @S_IRWXU
%98 = call i32 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %97)
store i32 %98, i32* %10
%99 = load i32, i32* %10
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %96
%102 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @exit(i32 %103)
unreachable
105: ; preds = %96
%106 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
store i32 0, i32* %3
br label %107
107: ; preds = %163, %105
%108 = load i32, i32* %3
%109 = load i32, i32* %2
%110 = icmp ult i32 %108, %109
br i1 %110, label %111, label %166
111: ; preds = %107
%112 = load i8**, i8*** %4
%113 = load i32, i32* %3
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds i8*, i8** %112, i64 %114
%116 = load i8*, i8** %115
%117 = call i32 @asprintf(i8** %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %116)
store i32 %117, i32* %10
%118 = load i32, i32* %10
%119 = icmp sge i32 %118, 0
%120 = zext i1 %119 to i32
%121 = call i32 @assert(i32 %120)
%122 = load i8**, i8*** %4
%123 = load i32, i32* %3
%124 = zext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %122, i64 %124
%126 = load i8*, i8** %125
%127 = load i8*, i8** %13
%128 = call i32 @link(i8* %126, i8* %127)
store i32 %128, i32* %10
%129 = load i32, i32* %10
%130 = icmp slt i32 %129, 0
br i1 %130, label %131, label %135
131: ; preds = %111
%132 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%133 = load i32, i32* @EXIT_FAILURE
%134 = call i32 @exit(i32 %133)
unreachable
135: ; preds = %111
%136 = load i8*, i8** %13
%137 = call i32 @free(i8* %136)
%138 = load i32, i32* %3
%139 = load i32, i32* %3
%140 = add i32 %139, 1
%141 = and i32 %138, %140
%142 = icmp ne i32 %141, 0
br i1 %142, label %162, label %143
143: ; preds = %135
%144 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%145 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%146 = load i32, i32* %145
%147 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%148 = load i32, i32* %147
%149 = sub nsw i32 %146, %148
%150 = mul nsw i32 %149, 1000000
%151 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%152 = load i32, i32* %151
%153 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%154 = load i32, i32* %153
%155 = sub nsw i32 %152, %154
%156 = add nsw i32 %150, %155
%157 = sext i32 %156 to i64
store i64 %157, i64* %9
%158 = load i64, i64* %9
%159 = load i32, i32* %3
%160 = add i32 %159, 1
%161 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i64 %158, i32 %160)
br label %162
162: ; preds = %143, %135
br label %163
163: ; preds = %162
%164 = load i32, i32* %3
%165 = add i32 %164, 1
store i32 %165, i32* %3
br label %107
166: ; preds = %107
%167 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%168 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%169 = load i32, i32* %168
%170 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%171 = load i32, i32* %170
%172 = sub nsw i32 %169, %171
%173 = mul nsw i32 %172, 1000000
%174 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%175 = load i32, i32* %174
%176 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%177 = load i32, i32* %176
%178 = sub nsw i32 %175, %177
%179 = add nsw i32 %173, %178
%180 = sext i32 %179 to i64
store i64 %180, i64* %9
%181 = load i64, i64* %9
%182 = load i32, i32* %2
%183 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 %181, i32 %182)
%184 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%185 = call i32* @opendir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32* %185, i32** %6
%186 = load i32*, i32** %6
%187 = ptrtoint i32* %186 to i32
%188 = call i32 @assert(i32 %187)
br label %189
189: ; preds = %202, %166
%190 = load i32*, i32** %6
%191 = call %struct.dirent* @readdir(i32* %190)
store %struct.dirent* %191, %struct.dirent** %5
%192 = icmp ne %struct.dirent* %191, null
br i1 %192, label %193, label %203
193: ; preds = %189
%194 = load %struct.dirent*, %struct.dirent** %5
%195 = getelementptr inbounds %struct.dirent, %struct.dirent* %194, i32 0, i32 0
%196 = load i32, i32* %195
%197 = call i32 @stat(i32 %196, %struct.stat* %14)
store i32 %197, i32* %10
%198 = load i32, i32* %10
%199 = icmp slt i32 %198, 0
br i1 %199, label %200, label %202
200: ; preds = %193
%201 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %202
202: ; preds = %200, %193
br label %189
203: ; preds = %189
%204 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%205 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%206 = load i32, i32* %205
%207 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%208 = load i32, i32* %207
%209 = sub nsw i32 %206, %208
%210 = mul nsw i32 %209, 1000000
%211 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%212 = load i32, i32* %211
%213 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%214 = load i32, i32* %213
%215 = sub nsw i32 %212, %214
%216 = add nsw i32 %210, %215
%217 = sext i32 %216 to i64
store i64 %217, i64* %9
%218 = load i64, i64* %9
%219 = load i32, i32* %2
%220 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i64 %218, i32 %219)
%221 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
store i32 0, i32* %3
br label %222
222: ; preds = %296, %203
%223 = load i32, i32* %3
%224 = load i32, i32* %2
%225 = icmp ult i32 %223, %224
br i1 %225, label %226, label %299
226: ; preds = %222
%227 = load i8**, i8*** %4
%228 = load i32, i32* %3
%229 = load i32, i32* %2
%230 = udiv i32 %229, 4
%231 = add i32 %228, %230
%232 = load i32, i32* %2
%233 = urem i32 %231, %232
%234 = zext i32 %233 to i64
%235 = getelementptr inbounds i8*, i8** %227, i64 %234
%236 = load i8*, i8** %235
%237 = call i32 @asprintf(i8** %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %236)
store i32 %237, i32* %10
%238 = load i32, i32* %10
%239 = icmp sge i32 %238, 0
%240 = zext i1 %239 to i32
%241 = call i32 @assert(i32 %240)
%242 = load i8**, i8*** %4
%243 = load i32, i32* %3
%244 = load i32, i32* %2
%245 = udiv i32 %244, 4
%246 = add i32 %243, %245
%247 = load i32, i32* %2
%248 = urem i32 %246, %247
%249 = zext i32 %248 to i64
%250 = getelementptr inbounds i8*, i8** %242, i64 %249
%251 = load i8*, i8** %250
%252 = call i32 @asprintf(i8** %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i8* %251)
store i32 %252, i32* %10
%253 = load i32, i32* %10
%254 = icmp sge i32 %253, 0
%255 = zext i1 %254 to i32
%256 = call i32 @assert(i32 %255)
%257 = load i8*, i8** %15
%258 = load i8*, i8** %16
%259 = call i32 @rename(i8* %257, i8* %258)
store i32 %259, i32* %10
%260 = load i32, i32* %10
%261 = icmp slt i32 %260, 0
br i1 %261, label %262, label %266
262: ; preds = %226
%263 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%264 = load i32, i32* @EXIT_FAILURE
%265 = call i32 @exit(i32 %264)
unreachable
266: ; preds = %226
%267 = load i8*, i8** %15
%268 = call i32 @free(i8* %267)
%269 = load i8*, i8** %16
%270 = call i32 @free(i8* %269)
%271 = load i32, i32* %3
%272 = load i32, i32* %3
%273 = add i32 %272, 1
%274 = and i32 %271, %273
%275 = icmp ne i32 %274, 0
br i1 %275, label %295, label %276
276: ; preds = %266
%277 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%278 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%279 = load i32, i32* %278
%280 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%281 = load i32, i32* %280
%282 = sub nsw i32 %279, %281
%283 = mul nsw i32 %282, 1000000
%284 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%285 = load i32, i32* %284
%286 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%287 = load i32, i32* %286
%288 = sub nsw i32 %285, %287
%289 = add nsw i32 %283, %288
%290 = sext i32 %289 to i64
store i64 %290, i64* %9
%291 = load i64, i64* %9
%292 = load i32, i32* %3
%293 = add i32 %292, 1
%294 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i64 %291, i32 %293)
br label %295
295: ; preds = %276, %266
br label %296
296: ; preds = %295
%297 = load i32, i32* %3
%298 = add i32 %297, 1
store i32 %298, i32* %3
br label %222
299: ; preds = %222
%300 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%301 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%302 = load i32, i32* %301
%303 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%304 = load i32, i32* %303
%305 = sub nsw i32 %302, %304
%306 = mul nsw i32 %305, 1000000
%307 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%308 = load i32, i32* %307
%309 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%310 = load i32, i32* %309
%311 = sub nsw i32 %308, %310
%312 = add nsw i32 %306, %311
%313 = sext i32 %312 to i64
store i64 %313, i64* %9
%314 = load i64, i64* %9
%315 = load i32, i32* %2
%316 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 %314, i32 %315)
%317 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
store i32 0, i32* %3
br label %318
318: ; preds = %374, %299
%319 = load i32, i32* %3
%320 = load i32, i32* %2
%321 = icmp ult i32 %319, %320
br i1 %321, label %322, label %377
322: ; preds = %318
%323 = load i8**, i8*** %4
%324 = load i32, i32* %3
%325 = load i32, i32* %2
%326 = udiv i32 %325, 2
%327 = add i32 %324, %326
%328 = load i32, i32* %2
%329 = urem i32 %327, %328
%330 = zext i32 %329 to i64
%331 = getelementptr inbounds i8*, i8** %323, i64 %330
%332 = load i8*, i8** %331
%333 = call i32 @asprintf(i8** %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i8* %332)
store i32 %333, i32* %10
%334 = load i32, i32* %10
%335 = icmp sge i32 %334, 0
%336 = zext i1 %335 to i32
%337 = call i32 @assert(i32 %336)
%338 = load i8*, i8** %17
%339 = call i32 @unlink(i8* %338)
store i32 %339, i32* %10
%340 = load i32, i32* %10
%341 = icmp slt i32 %340, 0
br i1 %341, label %342, label %346
342: ; preds = %322
%343 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%344 = load i32, i32* @EXIT_FAILURE
%345 = call i32 @exit(i32 %344)
unreachable
346: ; preds = %322
%347 = load i8*, i8** %17
%348 = call i32 @free(i8* %347)
%349 = load i32, i32* %3
%350 = load i32, i32* %3
%351 = add i32 %350, 1
%352 = and i32 %349, %351
%353 = icmp ne i32 %352, 0
br i1 %353, label %373, label %354
354: ; preds = %346
%355 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%356 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%357 = load i32, i32* %356
%358 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%359 = load i32, i32* %358
%360 = sub nsw i32 %357, %359
%361 = mul nsw i32 %360, 1000000
%362 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%363 = load i32, i32* %362
%364 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%365 = load i32, i32* %364
%366 = sub nsw i32 %363, %365
%367 = add nsw i32 %361, %366
%368 = sext i32 %367 to i64
store i64 %368, i64* %9
%369 = load i64, i64* %9
%370 = load i32, i32* %3
%371 = add i32 %370, 1
%372 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i64 %369, i32 %371)
br label %373
373: ; preds = %354, %346
br label %374
374: ; preds = %373
%375 = load i32, i32* %3
%376 = add i32 %375, 1
store i32 %376, i32* %3
br label %318
377: ; preds = %318
%378 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%379 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%380 = load i32, i32* %379
%381 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%382 = load i32, i32* %381
%383 = sub nsw i32 %380, %382
%384 = mul nsw i32 %383, 1000000
%385 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%386 = load i32, i32* %385
%387 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%388 = load i32, i32* %387
%389 = sub nsw i32 %386, %388
%390 = add nsw i32 %384, %389
%391 = sext i32 %390 to i64
store i64 %391, i64* %9
%392 = load i64, i64* %9
%393 = load i32, i32* %2
%394 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.16, i64 0, i64 0), i64 %392, i32 %393)
%395 = call i32 @rmdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 %395, i32* %10
%396 = load i32, i32* %10
%397 = icmp slt i32 %396, 0
br i1 %397, label %398, label %402
398: ; preds = %377
%399 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%400 = load i32, i32* @EXIT_FAILURE
%401 = call i32 @exit(i32 %400)
unreachable
402: ; preds = %377
%403 = call i32 @rmdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 %403, i32* %10
%404 = load i32, i32* %10
%405 = icmp slt i32 %404, 0
br i1 %405, label %406, label %410
406: ; preds = %402
%407 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%408 = load i32, i32* @EXIT_FAILURE
%409 = call i32 @exit(i32 %408)
unreachable
410: ; preds = %402
%411 = load i32, i32* @EXIT_SUCCESS
ret i32 %411
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.stat = type { i32 }
%struct.dirent = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [23 x i8] c"Found %u files to tag\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [15 x i8] c"perfs_tmp_tag1\00"
@S_IRWXU = global i32 0
@.str.3 = [6 x i8] c"mkdir\00"
@.str.4 = [15 x i8] c"perfs_tmp_tag2\00"
@.str.5 = [18 x i8] c"perfs_tmp_tag1/%s\00"
@.str.6 = [5 x i8] c"link\00"
@.str.7 = [32 x i8] c"%lu usecs for tagging %u files\0A\00"
@.str.8 = [36 x i8] c"%lu usecs for tagging all %u files\0A\00"
@.str.9 = [5 x i8] c"stat\00"
@.str.10 = [49 x i8] c"%lu usecs for listing and stat'ing all %u files\0A\00"
@.str.11 = [18 x i8] c"perfs_tmp_tag2/%s\00"
@.str.12 = [7 x i8] c"rename\00"
@.str.13 = [38 x i8] c"%lu usecs for replacing tag %u files\0A\00"
@.str.14 = [7 x i8] c"unlink\00"
@.str.15 = [34 x i8] c"%lu usecs for untagging %u files\0A\00"
@.str.16 = [38 x i8] c"%lu usecs for untagging all %u files\0A\00"
@.str.17 = [6 x i8] c"rmdir\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = alloca i8*
%6 = alloca %struct.stat
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = bitcast %struct.timeval* %1 to i8*
%11 = bitcast %struct.timeval* %2 to i8*
%12 = tail call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call %struct.dirent* @readdir(i32* %12)
%14 = icmp eq %struct.dirent* %13, null
br i1 %14, label %35, label %15
15: ; preds = %0
%16 = bitcast %struct.stat* %3 to i8*
%17 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
br label %18
18: ; preds = %15, %31
%19 = phi %struct.dirent* [ %13, %15 ], [ %33, %31 ]
%20 = phi i32 [ 0, %15 ], [ %32, %31 ]
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i64 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 @stat(i32 %22, %struct.stat* %3)
%24 = icmp slt i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = load i32, i32* %17
%27 = call i64 @S_ISREG(i32 %26)
%28 = icmp ne i64 %27, 0
%29 = zext i1 %28 to i32
%30 = add i32 %20, %29
br label %31
31: ; preds = %18, %25
%32 = phi i32 [ %30, %25 ], [ %20, %18 ]
%33 = call %struct.dirent* @readdir(i32* %12)
%34 = icmp eq %struct.dirent* %33, null
br i1 %34, label %35, label %18
35: ; preds = %31, %0
%36 = phi i32 [ 0, %0 ], [ %32, %31 ]
%37 = zext i32 %36 to i64
%38 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %37)
%39 = shl i32 %36, 3
%40 = call i8** @malloc(i32 %39)
%41 = icmp eq i8** %40, null
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %35
%46 = call i32 @rewinddir(i32* %12)
%47 = call %struct.dirent* @readdir(i32* %12)
%48 = icmp eq %struct.dirent* %47, null
br i1 %48, label %73, label %49
49: ; preds = %45
%50 = bitcast %struct.stat* %4 to i8*
%51 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %52
52: ; preds = %49, %69
%53 = phi %struct.dirent* [ %47, %49 ], [ %71, %69 ]
%54 = phi i32 [ 0, %49 ], [ %70, %69 ]
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %53, i64 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @stat(i32 %56, %struct.stat* %4)
%58 = icmp slt i32 %57, 0
br i1 %58, label %69, label %59
59: ; preds = %52
%60 = load i32, i32* %51
%61 = call i64 @S_ISREG(i32 %60)
%62 = icmp eq i64 %61, 0
br i1 %62, label %69, label %63
63: ; preds = %59
%64 = load i32, i32* %55
%65 = call i8* @strdup(i32 %64)
%66 = add i32 %54, 1
%67 = zext i32 %54 to i64
%68 = getelementptr inbounds i8*, i8** %40, i64 %67
store i8* %65, i8** %68
br label %69
69: ; preds = %59, %63, %52
%70 = phi i32 [ %54, %52 ], [ %66, %63 ], [ %54, %59 ]
%71 = call %struct.dirent* @readdir(i32* %12)
%72 = icmp eq %struct.dirent* %71, null
br i1 %72, label %73, label %52
73: ; preds = %69, %45
%74 = call i32 @closedir(i32* %12)
%75 = load i32, i32* @S_IRWXU
%76 = call i32 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %73
%79 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %73
%83 = load i32, i32* @S_IRWXU
%84 = call i32 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %83)
%85 = icmp slt i32 %84, 0
br i1 %85, label %86, label %90
86: ; preds = %82
%87 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%88 = load i32, i32* @EXIT_FAILURE
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %82
%91 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%92 = icmp eq i32 %36, 0
br i1 %92, label %93, label %98
93: ; preds = %90
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%97 = load i32, i32* %96
br label %141
98: ; preds = %90
%99 = bitcast i8** %5 to i8*
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%101 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%102 = load i32, i32* %101
%103 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%104 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%105 = load i32, i32* %104
br label %106
106: ; preds = %98, %139
%107 = phi i64 [ 0, %98 ], [ %124, %139 ]
%108 = getelementptr inbounds i8*, i8** %40, i64 %107
%109 = load i8*, i8** %108
%110 = call i32 @asprintf(i8** %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %109)
%111 = xor i32 %110, -1
%112 = lshr i32 %111, 31
%113 = call i32 @assert(i32 %112)
%114 = load i8*, i8** %5
%115 = call i32 @link(i8* %109, i8* %114)
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %121
117: ; preds = %106
%118 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %106
%122 = load i8*, i8** %5
%123 = call i32 @free(i8* %122)
%124 = add nuw nsw i64 %107, 1
%125 = and i64 %124, %107
%126 = trunc i64 %125 to i32
%127 = icmp eq i32 %126, 0
br i1 %127, label %128, label %139
128: ; preds = %121
%129 = trunc i64 %124 to i32
%130 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%131 = load i32, i32* %100
%132 = sub nsw i32 %131, %102
%133 = mul nsw i32 %132, 1000000
%134 = load i32, i32* %103
%135 = sub i32 %134, %105
%136 = add nsw i32 %135, %133
%137 = sext i32 %136 to i64
%138 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i64 %137, i32 %129)
br label %139
139: ; preds = %128, %121
%140 = icmp eq i64 %124, %37
br i1 %140, label %141, label %106
141: ; preds = %139, %93
%142 = phi i32 [ %97, %93 ], [ %105, %139 ]
%143 = phi i32 [ %95, %93 ], [ %102, %139 ]
%144 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%145 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%146 = load i32, i32* %145
%147 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%148 = sub nsw i32 %146, %143
%149 = mul nsw i32 %148, 1000000
%150 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%151 = load i32, i32* %150
%152 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%153 = sub i32 %151, %142
%154 = add nsw i32 %153, %149
%155 = sext i32 %154 to i64
%156 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 %155, i32 %36)
%157 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%158 = call i32* @opendir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%159 = ptrtoint i32* %158 to i64
%160 = trunc i64 %159 to i32
%161 = call i32 @assert(i32 %160)
%162 = call %struct.dirent* @readdir(i32* %158)
%163 = icmp eq %struct.dirent* %162, null
br i1 %163, label %177, label %164
164: ; preds = %141
%165 = bitcast %struct.stat* %6 to i8*
br label %166
166: ; preds = %164, %174
%167 = phi %struct.dirent* [ %162, %164 ], [ %175, %174 ]
%168 = getelementptr inbounds %struct.dirent, %struct.dirent* %167, i64 0, i32 0
%169 = load i32, i32* %168
%170 = call i32 @stat(i32 %169, %struct.stat* %6)
%171 = icmp slt i32 %170, 0
br i1 %171, label %172, label %174
172: ; preds = %166
%173 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %174
174: ; preds = %172, %166
%175 = call %struct.dirent* @readdir(i32* %158)
%176 = icmp eq %struct.dirent* %175, null
br i1 %176, label %177, label %166
177: ; preds = %174, %141
%178 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%179 = load i32, i32* %145
%180 = load i32, i32* %147
%181 = sub nsw i32 %179, %180
%182 = mul nsw i32 %181, 1000000
%183 = load i32, i32* %150
%184 = load i32, i32* %152
%185 = sub i32 %183, %184
%186 = add nsw i32 %185, %182
%187 = sext i32 %186 to i64
%188 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0), i64 %187, i32 %36)
%189 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br i1 %92, label %190, label %193
190: ; preds = %177
%191 = load i32, i32* %147
%192 = load i32, i32* %152
br label %242
193: ; preds = %177
%194 = bitcast i8** %7 to i8*
%195 = bitcast i8** %8 to i8*
%196 = lshr i32 %36, 2
%197 = load i32, i32* %147
%198 = load i32, i32* %152
br label %199
199: ; preds = %193, %240
%200 = phi i32 [ 0, %193 ], [ %227, %240 ]
%201 = add i32 %200, %196
%202 = urem i32 %201, %36
%203 = zext i32 %202 to i64
%204 = getelementptr inbounds i8*, i8** %40, i64 %203
%205 = load i8*, i8** %204
%206 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %205)
%207 = xor i32 %206, -1
%208 = lshr i32 %207, 31
%209 = call i32 @assert(i32 %208)
%210 = call i32 @asprintf(i8** %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i8* %205)
%211 = xor i32 %210, -1
%212 = lshr i32 %211, 31
%213 = call i32 @assert(i32 %212)
%214 = load i8*, i8** %7
%215 = load i8*, i8** %8
%216 = call i32 @rename(i8* %214, i8* %215)
%217 = icmp slt i32 %216, 0
br i1 %217, label %218, label %222
218: ; preds = %199
%219 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%220 = load i32, i32* @EXIT_FAILURE
%221 = call i32 @exit(i32 %220)
unreachable
222: ; preds = %199
%223 = load i8*, i8** %7
%224 = call i32 @free(i8* %223)
%225 = load i8*, i8** %8
%226 = call i32 @free(i8* %225)
%227 = add nuw i32 %200, 1
%228 = and i32 %227, %200
%229 = icmp eq i32 %228, 0
br i1 %229, label %230, label %240
230: ; preds = %222
%231 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%232 = load i32, i32* %145
%233 = sub nsw i32 %232, %197
%234 = mul nsw i32 %233, 1000000
%235 = load i32, i32* %150
%236 = sub i32 %235, %198
%237 = add nsw i32 %236, %234
%238 = sext i32 %237 to i64
%239 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i64 %238, i32 %227)
br label %240
240: ; preds = %230, %222
%241 = icmp eq i32 %227, %36
br i1 %241, label %242, label %199
242: ; preds = %240, %190
%243 = phi i32 [ %192, %190 ], [ %198, %240 ]
%244 = phi i32 [ %191, %190 ], [ %197, %240 ]
%245 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%246 = load i32, i32* %145
%247 = sub nsw i32 %246, %244
%248 = mul nsw i32 %247, 1000000
%249 = load i32, i32* %150
%250 = sub i32 %249, %243
%251 = add nsw i32 %250, %248
%252 = sext i32 %251 to i64
%253 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 %252, i32 %36)
%254 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br i1 %92, label %255, label %258
255: ; preds = %242
%256 = load i32, i32* %147
%257 = load i32, i32* %152
br label %299
258: ; preds = %242
%259 = bitcast i8** %9 to i8*
%260 = lshr i32 %36, 1
%261 = load i32, i32* %147
%262 = load i32, i32* %152
br label %263
263: ; preds = %258, %297
%264 = phi i32 [ 0, %258 ], [ %284, %297 ]
%265 = add i32 %264, %260
%266 = urem i32 %265, %36
%267 = zext i32 %266 to i64
%268 = getelementptr inbounds i8*, i8** %40, i64 %267
%269 = load i8*, i8** %268
%270 = call i32 @asprintf(i8** %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i8* %269)
%271 = xor i32 %270, -1
%272 = lshr i32 %271, 31
%273 = call i32 @assert(i32 %272)
%274 = load i8*, i8** %9
%275 = call i32 @unlink(i8* %274)
%276 = icmp slt i32 %275, 0
br i1 %276, label %277, label %281
277: ; preds = %263
%278 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%279 = load i32, i32* @EXIT_FAILURE
%280 = call i32 @exit(i32 %279)
unreachable
281: ; preds = %263
%282 = load i8*, i8** %9
%283 = call i32 @free(i8* %282)
%284 = add nuw i32 %264, 1
%285 = and i32 %284, %264
%286 = icmp eq i32 %285, 0
br i1 %286, label %287, label %297
287: ; preds = %281
%288 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%289 = load i32, i32* %145
%290 = sub nsw i32 %289, %261
%291 = mul nsw i32 %290, 1000000
%292 = load i32, i32* %150
%293 = sub i32 %292, %262
%294 = add nsw i32 %293, %291
%295 = sext i32 %294 to i64
%296 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i64 %295, i32 %284)
br label %297
297: ; preds = %287, %281
%298 = icmp eq i32 %284, %36
br i1 %298, label %299, label %263
299: ; preds = %297, %255
%300 = phi i32 [ %257, %255 ], [ %262, %297 ]
%301 = phi i32 [ %256, %255 ], [ %261, %297 ]
%302 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%303 = load i32, i32* %145
%304 = sub nsw i32 %303, %301
%305 = mul nsw i32 %304, 1000000
%306 = load i32, i32* %150
%307 = sub i32 %306, %300
%308 = add nsw i32 %307, %305
%309 = sext i32 %308 to i64
%310 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.16, i64 0, i64 0), i64 %309, i32 %36)
%311 = call i32 @rmdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%312 = icmp slt i32 %311, 0
br i1 %312, label %313, label %317
313: ; preds = %299
%314 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%315 = load i32, i32* @EXIT_FAILURE
%316 = call i32 @exit(i32 %315)
unreachable
317: ; preds = %299
%318 = call i32 @rmdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%319 = icmp slt i32 %318, 0
br i1 %319, label %320, label %324
320: ; preds = %317
%321 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%322 = load i32, i32* @EXIT_FAILURE
%323 = call i32 @exit(i32 %322)
unreachable
324: ; preds = %317
%325 = load i32, i32* @EXIT_SUCCESS
ret i32 %325
}