#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 uint8_t;
typedef scalar_t__ uint64_t;
struct winsize {
  int ws_col;
};
struct dirent {
  char *d_name;
};
typedef double clock_t;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ TIOCGWINSZ;
unsigned int atol(char *);
double clock();
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
scalar_t__ get_time();
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         struct winsize *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewinddir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdout;
size_t strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  unsigned int max = 0, iterations = 100;
  size_t j, term_size, counter = 1;
  const size_t max_seconds = 10;
  clock_t c0, c1, sum_c;
  struct dirent *dp;
  char buffer[256];
  struct winsize w;
  uint64_t t0, t1;
  double sum_t;
  DIR *dir;
  if (argc > 1) {
    iterations = atol(argv[1]);
  }
  fprintf(stdout, "[info] iteration count = %u\n", iterations);
  dir = opendir("./bin/");
  if (dir == NULL) {
    perror("opendir");
    exit(EXIT_FAILURE);
  }
  while ((dp = readdir(dir)) != NULL) {
    size_t len = strlen(dp->d_name);
    if (len > max) {
      max = len;
    }
  }
  rewinddir(dir);
  while ((dp = readdir(dir)) != NULL) {
    if (dp->d_name[0] == '.') {
      continue;
    }
    sprintf(buffer, "./bin/%s", dp->d_name);
    fprintf(stdout, "[info] wait %lu seconds to offload CPU", max_seconds);
    for (j = 0; j < max_seconds; j++) {
      fputc('.', stdout);
      fflush(stdout);
      sleep(1);
    }
    sum_c = sum_t = 0;
    fprintf(stdout, "[DONE]");
    for (j = 0; j < iterations; j++) {
      ioctl(0, TIOCGWINSZ, &w);
      term_size = w.ws_col - 18;
      fprintf(stdout, "\rprogress: [");
      uint8_t current = (j * term_size) / iterations;
      uint8_t progress = (j * 100) / iterations + 1;
      for (size_t i = 0; i < term_size; i++) {
        if (i <= current + 1) {
          fputc('#', stdout);
        } else {
          fputc('-', stdout);
        }
      }
      fprintf(stdout, "] %3u %%", progress);
      fflush(stdout);
      t0 = get_time();
      c0 = clock();
      system(buffer);
      t1 = get_time();
      c1 = clock();
      sum_t += (t1 - t0);
      sum_c += (c1 - c0);
    }
    fprintf(stdout, "%c[2K", 27);
    fprintf(stdout,
            "\r > %lu: prog '%*s' avg cpu time = %.4lf cycle, avg time = %.4lf "
            "µs\n",
            counter, max, dp->d_name, (double)sum_c / iterations,
            (double)sum_t / iterations);
    counter++;
  }
  closedir(dir);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
movq   $0x1,-0x30(%rbp)
movq   $0xa,-0x38(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1261 <main+0x51>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atol@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
lea    0xd9b(%rip),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x188(%rbp)
cmpq   $0x0,-0x188(%rbp)
jne    12b6 <main+0xa6>
lea    0xd81(%rip),%rdi
call   1100 <perror@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
jmp    12bb <main+0xab>
mov    -0x188(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     130a <main+0xfa>
mov    -0x58(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x190(%rbp)
mov    -0x190(%rbp),%rax
mov    -0x14(%rbp),%ecx
cmp    %rcx,%rax
jbe    1305 <main+0xf5>
mov    -0x190(%rbp),%rax
mov    %eax,-0x14(%rbp)
jmp    12bb <main+0xab>
mov    -0x188(%rbp),%rdi
call   1080 <rewinddir@plt>
mov    -0x188(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     1622 <main+0x412>
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1348 <main+0x138>
jmp    1316 <main+0x106>
lea    -0x160(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    (%rax),%rdx
lea    0xccf(%rip),%rsi
call   1110 <sprintf@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
lea    0xcc3(%rip),%rsi
mov    $0xa,%edx
mov    $0x0,%al
call   10c0 <fprintf@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0xa,-0x20(%rbp)
jae    13cd <main+0x1bd>
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1386 <main+0x176>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x180(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    0x2bf1(%rip),%rax
mov    (%rax),%edi
lea    0xc6c(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
cmp    %rcx,%rax
jae    15ac <main+0x39c>
mov    0x2baa(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x168(%rbp),%rdx
call   1070 <ioctl@plt>
mov    -0x168(%rbp),%eax
sub    $0x12,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
lea    0xc1e(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x20(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    -0x18(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x194(%rbp)
imul   $0x64,-0x20(%rbp),%rax
mov    -0x18(%rbp),%ecx
xor    %edx,%edx
div    %rcx
add    $0x1,%rax
mov    %eax,-0x198(%rbp)
movq   $0x0,-0x1a0(%rbp)
mov    -0x1a0(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    14f9 <main+0x2e9>
mov    -0x1a0(%rbp),%rax
mov    -0x194(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
ja     14ca <main+0x2ba>
mov    0x2b1f(%rip),%rax
mov    (%rax),%esi
mov    $0x23,%edi
call   10a0 <fputc@plt>
jmp    14dd <main+0x2cd>
mov    0x2b07(%rip),%rax
mov    (%rax),%esi
mov    $0x2d,%edi
call   10a0 <fputc@plt>
jmp    14e2 <main+0x2d2>
mov    -0x1a0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1a0(%rbp)
jmp    1485 <main+0x275>
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
mov    -0x198(%rbp),%edx
lea    0xb61(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2abb(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush@plt>
mov    $0x0,%al
call   10b0 <get_time@plt>
mov    %rax,-0x170(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x40(%rbp)
lea    -0x160(%rbp),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   10b0 <get_time@plt>
mov    %rax,-0x178(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x178(%rbp),%rax
sub    -0x170(%rbp),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x180(%rbp),%xmm0
ff
movsd  %xmm0,-0x180(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    13ff <main+0x1ef>
mov    0x2a25(%rip),%rax
mov    %rax,-0x1a8(%rbp)
mov    (%rax),%edi
lea    0xab6(%rip),%rsi
xor    %eax,%eax
mov    $0x1b,%edx
call   10c0 <fprintf@plt>
mov    -0x1a8(%rbp),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x58(%rbp),%rax
mov    (%rax),%r8
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm2
divsd  %xmm2,%xmm0
movsd  -0x180(%rbp),%xmm1
ff
divsd  %xmm2,%xmm1
lea    0xa75(%rip),%rsi
mov    $0x2,%al
call   10c0 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1316 <main+0x106>
mov    -0x188(%rbp),%rdi
call   1090 <closedir@plt>
mov    0x299b(%rip),%rax
mov    (%rax),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    $0x64,%r15d
cmp    $0x2,%edi
jl     1238 <main+0x28>
mov    0x8(%rsi),%rdi
call   10f0 <atol@plt>
mov    %eax,%r15d
mov    0x2d99(%rip),%r14
mov    (%r14),%edi
lea    0xdb7(%rip),%rsi
xor    %ebp,%ebp
mov    %r15d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    0xdc1(%rip),%rdi
call   1040 <opendir@plt>
test   %rax,%rax
je     16ac <main+0x49c>
mov    %rax,%r12
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     12a2 <main+0x92>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %ebx,%eax
cmp    %rax,%rbp
cmovbe %ebx,%ebp
mov    %r12,%rdi
call   10d0 <readdir@plt>
mov    %ebp,%ebx
test   %rax,%rax
jne    1280 <main+0x70>
mov    %r12,%rdi
call   1080 <rewinddir@plt>
mov    %r15d,%eax
mov    %rax,(%rsp)
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x48(%rsp)
lea    0xd69(%rip),%rbx
mov    $0x1,%eax
mov    %rax,0x28(%rsp)
nopl   (%rax)
mov    %r12,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     1689 <main+0x479>
mov    (%rax),%rdx
cmpb   $0x2e,(%rdx)
je     12d0 <main+0xc0>
mov    %rax,0x30(%rsp)
mov    %rbp,0x38(%rsp)
mov    %r12,0x40(%rsp)
lea    0x50(%rsp),%rdi
mov    %rbx,%rsi
call   1110 <sprintf@plt>
mov    (%r14),%edi
mov    $0xa,%edx
lea    0xd21(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%esi
mov    $0x2e,%edi
call   10a0 <fputc@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
mov    (%r14),%edi
lea    0xc01(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r15d,0x24(%rsp)
xorpd  %xmm0,%xmm0
test   %r15d,%r15d
je     1602 <main+0x3f2>
movsd  %xmm0,0x10(%rsp)
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    151f <main+0x30f>
nopl   0x0(%rax)
mov    (%r14),%edi
lea    0xbd6(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    (%r14),%edi
call   10e0 <fflush@plt>
xor    %eax,%eax
call   10b0 <get_time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
movsd  %xmm0,0x18(%rsp)
lea    0x50(%rsp),%rdi
call   1060 <system@plt>
xor    %eax,%eax
call   10b0 <get_time@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rbp
xorps  %xmm1,%xmm1
cvtsi2sd %rbp,%xmm1
movsd  0x10(%rsp),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
subsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
add    $0x1,%r12
cmp    (%rsp),%r12
je     1612 <main+0x402>
mov    0x2a9a(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    0x20(%rsp),%rdx
call   1070 <ioctl@plt>
movslq 0x20(%rsp),%rbx
add    $0xffffffffffffffee,%rbx
mov    (%r14),%edi
lea    0xb1c(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
imul   $0x64,%r12,%rax
mov    %rax,%rcx
shr    $0x20,%rcx
je     1570 <main+0x360>
xor    %edx,%edx
divq   (%rsp)
jmp    1575 <main+0x365>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
divl   (%rsp)
add    $0x1,%eax
mov    %rax,0x18(%rsp)
test   %ebx,%ebx
mov    0x2a52(%rip),%r14
je     1490 <main+0x280>
mov    %r12,%rax
imul   %rbx,%rax
mov    %rax,%rcx
shr    $0x20,%rcx
je     15b0 <main+0x3a0>
xor    %edx,%edx
divq   (%rsp)
jmp    15b5 <main+0x3a5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edx,%edx
divl   (%rsp)
add    $0x1,%eax
movslq %eax,%rbp
cmp    $0x2,%rbx
mov    $0x1,%eax
cmovb  %rax,%rbx
xor    %r13d,%r13d
mov    $0x2d,%r15d
mov    0x2a00(%rip),%r14
nopl   0x0(%rax,%rax,1)
cmp    %rbp,%r13
mov    (%r14),%esi
mov    $0x23,%edi
cmova  %r15d,%edi
call   10a0 <fputc@plt>
add    $0x1,%r13
cmp    %r13,%rbx
jne    15e0 <main+0x3d0>
jmp    1490 <main+0x280>
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    (%r14),%edi
lea    0xa5d(%rip),%rsi
mov    $0x1b,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    (%r14),%edi
mov    0x30(%rsp),%rax
mov    (%rax),%r8
movsd  0x48(%rsp),%xmm2
movsd  0x8(%rsp),%xmm0
divsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm2,%xmm1
lea    0xa2b(%rip),%rsi
mov    0x28(%rsp),%rbx
mov    %rbx,%rdx
mov    0x38(%rsp),%rbp
mov    %ebp,%ecx
mov    $0x2,%al
call   10c0 <fprintf@plt>
add    $0x1,%rbx
mov    %rbx,0x28(%rsp)
mov    0x24(%rsp),%r15d
mov    0x40(%rsp),%r12
lea    0x9a8(%rip),%rbx
jmp    12d0 <main+0xc0>
mov    %r12,%rdi
call   1090 <closedir@plt>
mov    0x2938(%rip),%rax
mov    (%rax),%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x971(%rip),%rdi
call   1100 <perror@plt>
mov    0x2921(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.winsize = type { i32 }
@stdout = global i32 0
@.str = [29 x i8] c"[info] iteration count = %u\0A\00"
@.str.1 = [7 x i8] c"./bin/\00"
@.str.2 = [8 x i8] c"opendir\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [9 x i8] c"./bin/%s\00"
@.str.4 = [39 x i8] c"[info] wait %lu seconds to offload CPU\00"
@.str.5 = [7 x i8] c"[DONE]\00"
@TIOCGWINSZ = global i32 0
@.str.6 = [13 x i8] c"\0Dprogress: [\00"
@.str.7 = [9 x i8] c"] %3u %%\00"
@.str.8 = [6 x i8] c"%c[2K\00"
@.str.9 = [70 x i8] c"\0D > %lu: prog '%*s' avg cpu time = %.4lf cycle, avg time = %.4lf \C2\B5s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca %struct.dirent*
%16 = alloca [256 x i8]
%17 = alloca %struct.winsize
%18 = alloca i64
%19 = alloca i64
%20 = alloca double
%21 = alloca i32*
%22 = alloca i64
%23 = alloca i32
%24 = alloca i32
%25 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 100, i32* %7
store i64 1, i64* %10
store i64 10, i64* %11
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %33
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atol(i8* %31)
store i32 %32, i32* %7
br label %33
33: ; preds = %28, %2
%34 = load i32, i32* @stdout
%35 = load i32, i32* %7
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %21
%38 = load i32*, i32** %21
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %33
br label %45
45: ; preds = %61, %44
%46 = load i32*, i32** %21
%47 = call %struct.dirent* @readdir(i32* %46)
store %struct.dirent* %47, %struct.dirent** %15
%48 = icmp ne %struct.dirent* %47, null
br i1 %48, label %49, label %62
49: ; preds = %45
%50 = load %struct.dirent*, %struct.dirent** %15
%51 = getelementptr inbounds %struct.dirent, %struct.dirent* %50, i32 0, i32 0
%52 = load i8*, i8** %51
%53 = call i64 @strlen(i8* %52)
store i64 %53, i64* %22
%54 = load i64, i64* %22
%55 = load i32, i32* %6
%56 = zext i32 %55 to i64
%57 = icmp ugt i64 %54, %56
br i1 %57, label %58, label %61
58: ; preds = %49
%59 = load i64, i64* %22
%60 = trunc i64 %59 to i32
store i32 %60, i32* %6
br label %61
61: ; preds = %58, %49
br label %45
62: ; preds = %45
%63 = load i32*, i32** %21
%64 = call i32 @rewinddir(i32* %63)
br label %65
65: ; preds = %175, %77, %62
%66 = load i32*, i32** %21
%67 = call %struct.dirent* @readdir(i32* %66)
store %struct.dirent* %67, %struct.dirent** %15
%68 = icmp ne %struct.dirent* %67, null
br i1 %68, label %69, label %195
69: ; preds = %65
%70 = load %struct.dirent*, %struct.dirent** %15
%71 = getelementptr inbounds %struct.dirent, %struct.dirent* %70, i32 0, i32 0
%72 = load i8*, i8** %71
%73 = getelementptr inbounds i8, i8* %72, i64 0
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 46
br i1 %76, label %77, label %78
77: ; preds = %69
br label %65
78: ; preds = %69
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%80 = load %struct.dirent*, %struct.dirent** %15
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 0
%82 = load i8*, i8** %81
%83 = call i32 @sprintf(i8* %79, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %82)
%84 = load i32, i32* @stdout
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i64 10)
store i64 0, i64* %8
br label %86
86: ; preds = %95, %78
%87 = load i64, i64* %8
%88 = icmp ult i64 %87, 10
br i1 %88, label %89, label %98
89: ; preds = %86
%90 = load i32, i32* @stdout
%91 = call i32 @fputc(i8 signext 46, i32 %90)
%92 = load i32, i32* @stdout
%93 = call i32 @fflush(i32 %92)
%94 = call i32 @sleep(i32 1)
br label %95
95: ; preds = %89
%96 = load i64, i64* %8
%97 = add i64 %96, 1
store i64 %97, i64* %8
br label %86
98: ; preds = %86
store double 0.000000e+00, double* %20
store double 0.000000e+00, double* %14
%99 = load i32, i32* @stdout
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i64 0, i64* %8
br label %101
101: ; preds = %172, %98
%102 = load i64, i64* %8
%103 = load i32, i32* %7
%104 = zext i32 %103 to i64
%105 = icmp ult i64 %102, %104
br i1 %105, label %106, label %175
106: ; preds = %101
%107 = load i32, i32* @TIOCGWINSZ
%108 = call i32 @ioctl(i32 0, i32 %107, %struct.winsize* %17)
%109 = getelementptr inbounds %struct.winsize, %struct.winsize* %17, i32 0, i32 0
%110 = load i32, i32* %109
%111 = sub nsw i32 %110, 18
%112 = sext i32 %111 to i64
store i64 %112, i64* %9
%113 = load i32, i32* @stdout
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%115 = load i64, i64* %8
%116 = load i64, i64* %9
%117 = mul i64 %115, %116
%118 = load i32, i32* %7
%119 = zext i32 %118 to i64
%120 = udiv i64 %117, %119
%121 = trunc i64 %120 to i32
store i32 %121, i32* %23
%122 = load i64, i64* %8
%123 = mul i64 %122, 100
%124 = load i32, i32* %7
%125 = zext i32 %124 to i64
%126 = udiv i64 %123, %125
%127 = add i64 %126, 1
%128 = trunc i64 %127 to i32
store i32 %128, i32* %24
store i64 0, i64* %25
br label %129
129: ; preds = %146, %106
%130 = load i64, i64* %25
%131 = load i64, i64* %9
%132 = icmp ult i64 %130, %131
br i1 %132, label %133, label %149
133: ; preds = %129
%134 = load i64, i64* %25
%135 = load i32, i32* %23
%136 = add nsw i32 %135, 1
%137 = sext i32 %136 to i64
%138 = icmp ule i64 %134, %137
br i1 %138, label %139, label %142
139: ; preds = %133
%140 = load i32, i32* @stdout
%141 = call i32 @fputc(i8 signext 35, i32 %140)
br label %145
142: ; preds = %133
%143 = load i32, i32* @stdout
%144 = call i32 @fputc(i8 signext 45, i32 %143)
br label %145
145: ; preds = %142, %139
br label %146
146: ; preds = %145
%147 = load i64, i64* %25
%148 = add i64 %147, 1
store i64 %148, i64* %25
br label %129
149: ; preds = %129
%150 = load i32, i32* @stdout
%151 = load i32, i32* %24
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %151)
%153 = load i32, i32* @stdout
%154 = call i32 @fflush(i32 %153)
%155 = call i64 (...) @get_time()
store i64 %155, i64* %18
%156 = call double (...) @clock()
store double %156, double* %12
%157 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%158 = call i32 @system(i8* %157)
%159 = call i64 (...) @get_time()
store i64 %159, i64* %19
%160 = call double (...) @clock()
store double %160, double* %13
%161 = load i64, i64* %19
%162 = load i64, i64* %18
%163 = sub nsw i64 %161, %162
%164 = sitofp i64 %163 to double
%165 = load double, double* %20
%166 = fadd double %165, %164
store double %166, double* %20
%167 = load double, double* %13
%168 = load double, double* %12
%169 = fsub double %167, %168
%170 = load double, double* %14
%171 = fadd double %170, %169
store double %171, double* %14
br label %172
172: ; preds = %149
%173 = load i64, i64* %8
%174 = add i64 %173, 1
store i64 %174, i64* %8
br label %101
175: ; preds = %101
%176 = load i32, i32* @stdout
%177 = call i32 (i32, i8*, ...) @fprintf(i32 %176, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 27)
%178 = load i32, i32* @stdout
%179 = load i64, i64* %10
%180 = load i32, i32* %6
%181 = load %struct.dirent*, %struct.dirent** %15
%182 = getelementptr inbounds %struct.dirent, %struct.dirent* %181, i32 0, i32 0
%183 = load i8*, i8** %182
%184 = load double, double* %14
%185 = load i32, i32* %7
%186 = uitofp i32 %185 to double
%187 = fdiv double %184, %186
%188 = load double, double* %20
%189 = load i32, i32* %7
%190 = uitofp i32 %189 to double
%191 = fdiv double %188, %190
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %178, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.9, i64 0, i64 0), i64 %179, i32 %180, i8* %183, double %187, double %191)
%193 = load i64, i64* %10
%194 = add i64 %193, 1
store i64 %194, i64* %10
br label %65
195: ; preds = %65
%196 = load i32*, i32** %21
%197 = call i32 @closedir(i32* %196)
%198 = load i32, i32* @EXIT_SUCCESS
ret i32 %198
}

LLVM IR (-O2):
%struct.winsize = type { i32 }
%struct.dirent = type { i8* }
@stdout = global i32 0
@.str = [29 x i8] c"[info] iteration count = %u\0A\00"
@.str.1 = [7 x i8] c"./bin/\00"
@.str.2 = [8 x i8] c"opendir\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [9 x i8] c"./bin/%s\00"
@.str.4 = [39 x i8] c"[info] wait %lu seconds to offload CPU\00"
@.str.5 = [7 x i8] c"[DONE]\00"
@TIOCGWINSZ = global i32 0
@.str.6 = [13 x i8] c"\0Dprogress: [\00"
@.str.7 = [9 x i8] c"] %3u %%\00"
@.str.8 = [6 x i8] c"%c[2K\00"
@.str.9 = [70 x i8] c"\0D > %lu: prog '%*s' avg cpu time = %.4lf cycle, avg time = %.4lf \C2\B5s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca %struct.winsize
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.winsize* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atol(i8* %10)
br label %12
12: ; preds = %8, %2
%13 = phi i32 [ %11, %8 ], [ 100, %2 ]
%14 = load i32, i32* @stdout
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = tail call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = tail call %struct.dirent* @readdir(i32* %16)
%20 = icmp eq %struct.dirent* %19, null
br i1 %20, label %37, label %25
21: ; preds = %12
%22 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %18, %25
%26 = phi %struct.dirent* [ %35, %25 ], [ %19, %18 ]
%27 = phi i32 [ %34, %25 ], [ 0, %18 ]
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %26, i64 0, i32 0
%29 = load i8*, i8** %28
%30 = tail call i64 @strlen(i8* dereferenceable(1) %29)
%31 = zext i32 %27 to i64
%32 = icmp ugt i64 %30, %31
%33 = trunc i64 %30 to i32
%34 = select i1 %32, i32 %33, i32 %27
%35 = tail call %struct.dirent* @readdir(i32* %16)
%36 = icmp eq %struct.dirent* %35, null
br i1 %36, label %37, label %25
37: ; preds = %25, %18
%38 = phi i32 [ 0, %18 ], [ %34, %25 ]
%39 = tail call i32 @rewinddir(i32* %16)
%40 = zext i32 %13 to i64
%41 = icmp eq i32 %13, 0
%42 = getelementptr inbounds %struct.winsize, %struct.winsize* %4, i64 0, i32 0
%43 = uitofp i32 %13 to double
br label %44
44: ; preds = %159, %37
%45 = phi i64 [ %169, %159 ], [ 1, %37 ]
br label %46
46: ; preds = %44, %49
%47 = call %struct.dirent* @readdir(i32* %16)
%48 = icmp eq %struct.dirent* %47, null
br i1 %48, label %170, label %49
49: ; preds = %46
%50 = getelementptr inbounds %struct.dirent, %struct.dirent* %47, i64 0, i32 0
%51 = load i8*, i8** %50
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 46
br i1 %53, label %46, label %54
54: ; preds = %49
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %47, i64 0, i32 0
%56 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%57 = load i32, i32* @stdout
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i64 10)
%59 = load i32, i32* @stdout
%60 = call i32 @fputc(i8 signext 46, i32 %59)
%61 = load i32, i32* @stdout
%62 = call i32 @fflush(i32 %61)
%63 = call i32 @sleep(i32 1)
%64 = load i32, i32* @stdout
%65 = call i32 @fputc(i8 signext 46, i32 %64)
%66 = load i32, i32* @stdout
%67 = call i32 @fflush(i32 %66)
%68 = call i32 @sleep(i32 1)
%69 = load i32, i32* @stdout
%70 = call i32 @fputc(i8 signext 46, i32 %69)
%71 = load i32, i32* @stdout
%72 = call i32 @fflush(i32 %71)
%73 = call i32 @sleep(i32 1)
%74 = load i32, i32* @stdout
%75 = call i32 @fputc(i8 signext 46, i32 %74)
%76 = load i32, i32* @stdout
%77 = call i32 @fflush(i32 %76)
%78 = call i32 @sleep(i32 1)
%79 = load i32, i32* @stdout
%80 = call i32 @fputc(i8 signext 46, i32 %79)
%81 = load i32, i32* @stdout
%82 = call i32 @fflush(i32 %81)
%83 = call i32 @sleep(i32 1)
%84 = load i32, i32* @stdout
%85 = call i32 @fputc(i8 signext 46, i32 %84)
%86 = load i32, i32* @stdout
%87 = call i32 @fflush(i32 %86)
%88 = call i32 @sleep(i32 1)
%89 = load i32, i32* @stdout
%90 = call i32 @fputc(i8 signext 46, i32 %89)
%91 = load i32, i32* @stdout
%92 = call i32 @fflush(i32 %91)
%93 = call i32 @sleep(i32 1)
%94 = load i32, i32* @stdout
%95 = call i32 @fputc(i8 signext 46, i32 %94)
%96 = load i32, i32* @stdout
%97 = call i32 @fflush(i32 %96)
%98 = call i32 @sleep(i32 1)
%99 = load i32, i32* @stdout
%100 = call i32 @fputc(i8 signext 46, i32 %99)
%101 = load i32, i32* @stdout
%102 = call i32 @fflush(i32 %101)
%103 = call i32 @sleep(i32 1)
%104 = load i32, i32* @stdout
%105 = call i32 @fputc(i8 signext 46, i32 %104)
%106 = load i32, i32* @stdout
%107 = call i32 @fflush(i32 %106)
%108 = call i32 @sleep(i32 1)
%109 = load i32, i32* @stdout
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br i1 %41, label %159, label %111
111: ; preds = %54, %134
%112 = phi i64 [ %149, %134 ], [ 0, %54 ]
%113 = phi double [ %146, %134 ], [ 0.000000e+00, %54 ]
%114 = phi double [ %148, %134 ], [ 0.000000e+00, %54 ]
%115 = load i32, i32* @TIOCGWINSZ
%116 = call i32 @ioctl(i32 0, i32 %115, %struct.winsize* %4)
%117 = load i32, i32* %42
%118 = add nsw i32 %117, -18
%119 = sext i32 %118 to i64
%120 = load i32, i32* @stdout
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%122 = mul nuw nsw i64 %112, 100
%123 = udiv i64 %122, %40
%124 = trunc i64 %123 to i32
%125 = add i32 %124, 1
%126 = icmp eq i32 %118, 0
br i1 %126, label %134, label %127
127: ; preds = %111
%128 = mul i64 %112, %119
%129 = udiv i64 %128, %40
%130 = shl i64 %129, 32
%131 = add i64 %130, 4294967296
%132 = ashr exact i64 %131, 32
%133 = call i64 @llvm.umax.i64(i64 %119, i64 1)
br label %151
134: ; preds = %151, %111
%135 = load i32, i32* @stdout
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %125)
%137 = load i32, i32* @stdout
%138 = call i32 @fflush(i32 %137)
%139 = call i64 (...) @get_time()
%140 = call double (...) @clock()
%141 = call i32 @system(i8* %5)
%142 = call i64 (...) @get_time()
%143 = call double (...) @clock()
%144 = sub nsw i64 %142, %139
%145 = sitofp i64 %144 to double
%146 = fadd double %113, %145
%147 = fsub double %143, %140
%148 = fadd double %114, %147
%149 = add nuw nsw i64 %112, 1
%150 = icmp eq i64 %149, %40
br i1 %150, label %159, label %111
151: ; preds = %127, %151
%152 = phi i64 [ 0, %127 ], [ %157, %151 ]
%153 = icmp ugt i64 %152, %132
%154 = load i32, i32* @stdout
%155 = select i1 %153, i8 45, i8 35
%156 = call i32 @fputc(i8 signext %155, i32 %154)
%157 = add nuw i64 %152, 1
%158 = icmp eq i64 %157, %133
br i1 %158, label %134, label %151
159: ; preds = %134, %54
%160 = phi double [ 0.000000e+00, %54 ], [ %148, %134 ]
%161 = phi double [ 0.000000e+00, %54 ], [ %146, %134 ]
%162 = load i32, i32* @stdout
%163 = call i32 (i32, i8*, ...) @fprintf(i32 %162, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 27)
%164 = load i32, i32* @stdout
%165 = load i8*, i8** %55
%166 = fdiv double %160, %43
%167 = fdiv double %161, %43
%168 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.9, i64 0, i64 0), i64 %45, i32 %38, i8* %165, double %166, double %167)
%169 = add i64 %45, 1
br label %44
170: ; preds = %46
%171 = call i32 @closedir(i32* %16)
%172 = load i32, i32* @EXIT_SUCCESS
ret i32 %172
}