#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 stat {
  scalar_t__ st_size;
};
struct dirent {
  int d_type;
  int /*<<< orphan*/ d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
char **calloc(int, int);
int /*<<< orphan*/ chdir(char *);
void *malloc(int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stat(int /*<<< orphan*/, struct stat *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int strlen(int /*<<< orphan*/);
int main(int argc, char **argv) {
  DIR *wd;
  char *dir = ".";
  if (argc > 1)
    dir = argv[1];
  printf("Printing statistics for: %s\n", dir);
  chdir(dir);
  wd = opendir(dir);
  struct dirent *entry = malloc(sizeof(struct dirent));
  struct stat *sb = malloc(sizeof(struct stat));
  int size = 0;
  char **dirs = calloc(64, sizeof(char *));
  char **regs = calloc(64, sizeof(char *));
  int x = 0;
  int y = 0;
  while ((entry = readdir(wd))) {
    if (entry->d_type == 4) {
      dirs[x] = malloc(strlen(entry->d_name));
      strcpy(dirs[x++], entry->d_name);
    } else {
      stat(entry->d_name, sb);
      size += sb->st_size;
      regs[y] = malloc(strlen(entry->d_name));
      strcpy(regs[y++], entry->d_name);
    }
  }
  char **prefixes = calloc(5, sizeof(char *));
  prefixes[0] = "";
  prefixes[1] = "kilo";
  prefixes[2] = "mega";
  prefixes[3] = "giga";
  prefixes[4] = "tera";
  int rounds = 0;
  while (size / 1024 > 1) {
    rounds++;
    size /= 1024;
  }
  printf("Amount of bytes read: %d %sbytes\n", size, prefixes[rounds]);
  int i = 0;
  int j = 0;
  printf("Directories:\n");
  while (dirs[i]) {
    printf("\t");
    printf("%s", dirs[i++]);
    printf("\n");
  }
  printf("Regular files:\n");
  while (regs[j]) {
    printf("\t");
    printf("%s", regs[j++]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11c7 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <chdir@plt>
mov    -0x20(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x18(%rbp)
mov    $0x8,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x8,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x40,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x40,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     131d <main+0x18d>
mov    -0x28(%rbp),%rax
cmpl   $0x4,(%rax)
jne    12b3 <main+0x123>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <strlen@plt>
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x4c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
call   1030 <strcpy@plt>
jmp    1318 <main+0x188>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x30(%rbp),%rsi
call   1090 <stat@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
movslq -0x34(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <strlen@plt>
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x50(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
call   1030 <strcpy@plt>
jmp    1246 <main+0xb6>
mov    $0x5,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
lea    0xd29(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rax
lea    0xcd6(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x58(%rbp),%rax
lea    0xccc(%rip),%rcx
mov    %rcx,0x10(%rax)
mov    -0x58(%rbp),%rax
lea    0xcc2(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x58(%rbp),%rax
lea    0xcb8(%rip),%rcx
mov    %rcx,0x20(%rax)
movl   $0x0,-0x5c(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
cmp    $0x1,%eax
jle    13b1 <main+0x221>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
jmp    1381 <main+0x1f1>
mov    -0x34(%rbp),%esi
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rax
movslq -0x60(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1442 <main+0x2b2>
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rax
mov    -0x60(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x60(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc3d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    13ea <main+0x25a>
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rax
movslq -0x64(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     14a8 <main+0x318>
lea    0xbf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rax
mov    -0x64(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x64(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xbd7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbc5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1450 <main+0x2c0>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     11c9 <main+0x19>
mov    0x8(%rsi),%rbx
jmp    11d0 <main+0x20>
lea    0xe30(%rip),%rbx
lea    0xe2b(%rip),%rdi
movl   $0x0,0x4(%rsp)
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1080 <chdir@plt>
mov    %rbx,%rdi
call   1060 <opendir@plt>
mov    %rax,%rbx
mov    $0x8,%edi
call   10d0 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x40,%edi
mov    $0x8,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
mov    $0x40,%edi
mov    $0x8,%esi
call   10a0 <calloc@plt>
mov    %rax,%r15
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     12e0 <main+0x130>
mov    %rax,%rbx
xor    %r12d,%r12d
xor    %ebp,%ebp
movl   $0x0,0x4(%rsp)
jmp    12bd <main+0x10d>
nopw   0x0(%rax,%rax,1)
mov    %r15,%r13
mov    %r12,%r15
mov    0x8(%rsp),%r12
mov    %r12,%rsi
call   10b0 <stat@plt>
mov    0x4(%rsp),%eax
add    (%r12),%eax
mov    %eax,0x4(%rsp)
mov    %r15,%r12
mov    %r13,%r15
mov    0x4(%rbx),%edi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,%rdi
movslq %r12d,%r12
mov    %rax,0x0(%r13,%r12,8)
add    $0x1,%r12d
mov    0x4(%rbx),%esi
call   1040 <strcpy@plt>
mov    0x10(%rsp),%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12e0 <main+0x130>
mov    0x4(%rbx),%edi
cmpl   $0x4,(%rbx)
jne    1260 <main+0xb0>
call   1070 <strlen@plt>
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,%rdi
movslq %ebp,%rbp
mov    %rax,(%r14,%rbp,8)
add    $0x1,%ebp
jmp    12a3 <main+0xf3>
mov    $0x5,%edi
mov    $0x8,%esi
call   10a0 <calloc@plt>
lea    0xd28(%rip),%rdx
mov    %rdx,(%rax)
lea    0xd1f(%rip),%rcx
mov    %rcx,0x8(%rax)
lea    0xd19(%rip),%rcx
mov    %rcx,0x10(%rax)
lea    0xd13(%rip),%rcx
mov    %rcx,0x18(%rax)
lea    0xd0d(%rip),%rcx
mov    %rcx,0x20(%rax)
mov    0x4(%rsp),%esi
cmp    $0x800,%esi
jl     1354 <main+0x1a4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %esi,%ecx
shr    $0xa,%esi
add    $0x8,%rax
cmp    $0x1fffff,%ecx
ja     1340 <main+0x190>
mov    (%rax),%rdx
lea    0xcd8(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xcef(%rip),%rdi
call   1050 <puts@plt>
mov    (%r14),%rbp
test   %rbp,%rbp
je     13bd <main+0x20d>
add    $0x8,%r14
lea    0xcd4(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r14),%rbp
add    $0x8,%r14
test   %rbp,%rbp
jne    1390 <main+0x1e0>
lea    0xca1(%rip),%rdi
call   1050 <puts@plt>
mov    (%r15),%rbp
test   %rbp,%rbp
je     140d <main+0x25d>
add    $0x8,%r15
lea    0xc79(%rip),%rbx
nopl   0x0(%rax)
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r15),%rbp
add    $0x8,%r15
test   %rbp,%rbp
jne    13e0 <main+0x230>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32, i32 }
%struct.stat = type { i64 }
@.str = [2 x i8] c".\00"
@.str.1 = [29 x i8] c"Printing statistics for: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [5 x i8] c"kilo\00"
@.str.4 = [5 x i8] c"mega\00"
@.str.5 = [5 x i8] c"giga\00"
@.str.6 = [5 x i8] c"tera\00"
@.str.7 = [34 x i8] c"Amount of bytes read: %d %sbytes\0A\00"
@.str.8 = [14 x i8] c"Directories:\0A\00"
@.str.9 = [2 x i8] c"\09\00"
@.str.10 = [3 x i8] c"%s\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [16 x i8] c"Regular files:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca %struct.dirent*
%9 = alloca %struct.stat*
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8**
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %7
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %7
br label %25
25: ; preds = %21, %2
%26 = load i8*, i8** %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %7
%29 = call i32 @chdir(i8* %28)
%30 = load i8*, i8** %7
%31 = call i32* @opendir(i8* %30)
store i32* %31, i32** %6
%32 = call i8* @malloc(i32 8)
%33 = bitcast i8* %32 to %struct.dirent*
store %struct.dirent* %33, %struct.dirent** %8
%34 = call i8* @malloc(i32 8)
%35 = bitcast i8* %34 to %struct.stat*
store %struct.stat* %35, %struct.stat** %9
store i32 0, i32* %10
%36 = call i8** @calloc(i32 64, i32 8)
store i8** %36, i8*** %11
%37 = call i8** @calloc(i32 64, i32 8)
store i8** %37, i8*** %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %38
38: ; preds = %99, %25
%39 = load i32*, i32** %6
%40 = call %struct.dirent* @readdir(i32* %39)
store %struct.dirent* %40, %struct.dirent** %8
%41 = icmp ne %struct.dirent* %40, null
br i1 %41, label %42, label %100
42: ; preds = %38
%43 = load %struct.dirent*, %struct.dirent** %8
%44 = getelementptr inbounds %struct.dirent, %struct.dirent* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 4
br i1 %46, label %47, label %67
47: ; preds = %42
%48 = load %struct.dirent*, %struct.dirent** %8
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = call i32 @strlen(i32 %50)
%52 = call i8* @malloc(i32 %51)
%53 = load i8**, i8*** %11
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
store i8* %52, i8** %56
%57 = load i8**, i8*** %11
%58 = load i32, i32* %13
%59 = add nsw i32 %58, 1
store i32 %59, i32* %13
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8*, i8** %57, i64 %60
%62 = load i8*, i8** %61
%63 = load %struct.dirent*, %struct.dirent** %8
%64 = getelementptr inbounds %struct.dirent, %struct.dirent* %63, i32 0, i32 1
%65 = load i32, i32* %64
%66 = call i32 @strcpy(i8* %62, i32 %65)
br label %99
67: ; preds = %42
%68 = load %struct.dirent*, %struct.dirent** %8
%69 = getelementptr inbounds %struct.dirent, %struct.dirent* %68, i32 0, i32 1
%70 = load i32, i32* %69
%71 = load %struct.stat*, %struct.stat** %9
%72 = call i32 @stat(i32 %70, %struct.stat* %71)
%73 = load %struct.stat*, %struct.stat** %9
%74 = getelementptr inbounds %struct.stat, %struct.stat* %73, i32 0, i32 0
%75 = load i64, i64* %74
%76 = load i32, i32* %10
%77 = sext i32 %76 to i64
%78 = add nsw i64 %77, %75
%79 = trunc i64 %78 to i32
store i32 %79, i32* %10
%80 = load %struct.dirent*, %struct.dirent** %8
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 1
%82 = load i32, i32* %81
%83 = call i32 @strlen(i32 %82)
%84 = call i8* @malloc(i32 %83)
%85 = load i8**, i8*** %12
%86 = load i32, i32* %14
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %85, i64 %87
store i8* %84, i8** %88
%89 = load i8**, i8*** %12
%90 = load i32, i32* %14
%91 = add nsw i32 %90, 1
store i32 %91, i32* %14
%92 = sext i32 %90 to i64
%93 = getelementptr inbounds i8*, i8** %89, i64 %92
%94 = load i8*, i8** %93
%95 = load %struct.dirent*, %struct.dirent** %8
%96 = getelementptr inbounds %struct.dirent, %struct.dirent* %95, i32 0, i32 1
%97 = load i32, i32* %96
%98 = call i32 @strcpy(i8* %94, i32 %97)
br label %99
99: ; preds = %67, %47
br label %38
100: ; preds = %38
%101 = call i8** @calloc(i32 5, i32 8)
store i8** %101, i8*** %15
%102 = load i8**, i8*** %15
%103 = getelementptr inbounds i8*, i8** %102, i64 0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %103
%104 = load i8**, i8*** %15
%105 = getelementptr inbounds i8*, i8** %104, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %105
%106 = load i8**, i8*** %15
%107 = getelementptr inbounds i8*, i8** %106, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %107
%108 = load i8**, i8*** %15
%109 = getelementptr inbounds i8*, i8** %108, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %109
%110 = load i8**, i8*** %15
%111 = getelementptr inbounds i8*, i8** %110, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %111
store i32 0, i32* %16
br label %112
112: ; preds = %116, %100
%113 = load i32, i32* %10
%114 = sdiv i32 %113, 1024
%115 = icmp sgt i32 %114, 1
br i1 %115, label %116, label %121
116: ; preds = %112
%117 = load i32, i32* %16
%118 = add nsw i32 %117, 1
store i32 %118, i32* %16
%119 = load i32, i32* %10
%120 = sdiv i32 %119, 1024
store i32 %120, i32* %10
br label %112
121: ; preds = %112
%122 = load i32, i32* %10
%123 = load i8**, i8*** %15
%124 = load i32, i32* %16
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8*, i8** %123, i64 %125
%127 = load i8*, i8** %126
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %122, i8* %127)
store i32 0, i32* %17
store i32 0, i32* %18
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %130
130: ; preds = %137, %121
%131 = load i8**, i8*** %11
%132 = load i32, i32* %17
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8*, i8** %131, i64 %133
%135 = load i8*, i8** %134
%136 = icmp ne i8* %135, null
br i1 %136, label %137, label %147
137: ; preds = %130
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%139 = load i8**, i8*** %11
%140 = load i32, i32* %17
%141 = add nsw i32 %140, 1
store i32 %141, i32* %17
%142 = sext i32 %140 to i64
%143 = getelementptr inbounds i8*, i8** %139, i64 %142
%144 = load i8*, i8** %143
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %144)
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %130
147: ; preds = %130
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %149
149: ; preds = %156, %147
%150 = load i8**, i8*** %12
%151 = load i32, i32* %18
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8*, i8** %150, i64 %152
%154 = load i8*, i8** %153
%155 = icmp ne i8* %154, null
br i1 %155, label %156, label %166
156: ; preds = %149
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%158 = load i8**, i8*** %12
%159 = load i32, i32* %18
%160 = add nsw i32 %159, 1
store i32 %160, i32* %18
%161 = sext i32 %159 to i64
%162 = getelementptr inbounds i8*, i8** %158, i64 %161
%163 = load i8*, i8** %162
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %163)
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %149
166: ; preds = %149
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.dirent = type { i32, i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [29 x i8] c"Printing statistics for: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [5 x i8] c"kilo\00"
@.str.4 = [5 x i8] c"mega\00"
@.str.5 = [5 x i8] c"giga\00"
@.str.6 = [5 x i8] c"tera\00"
@.str.7 = [34 x i8] c"Amount of bytes read: %d %sbytes\0A\00"
@.str.10 = [3 x i8] c"%s\00"
@str = [13 x i8] c"Directories:\00"
@str.13 = [15 x i8] c"Regular files:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %4, %2
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = tail call i32 @chdir(i8* %8)
%11 = tail call i32* @opendir(i8* %8)
%12 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%13 = bitcast i8* %12 to %struct.stat*
%14 = tail call i8** @calloc(i32 64, i32 8)
%15 = tail call i8** @calloc(i32 64, i32 8)
%16 = tail call %struct.dirent* @readdir(i32* %11)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %56, label %18
18: ; preds = %7
%19 = getelementptr inbounds %struct.stat, %struct.stat* %13, i64 0, i32 0
br label %20
20: ; preds = %18, %47
%21 = phi %struct.dirent* [ %16, %18 ], [ %54, %47 ]
%22 = phi i32 [ 0, %18 ], [ %51, %47 ]
%23 = phi i32 [ 0, %18 ], [ %50, %47 ]
%24 = phi i32 [ 0, %18 ], [ %49, %47 ]
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i64 0, i32 0
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 4
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i64 0, i32 1
%29 = load i32, i32* %28
br i1 %27, label %30, label %36
30: ; preds = %20
%31 = tail call i32 @strlen(i32 %29)
%32 = tail call i8* @malloc(i32 %31)
%33 = sext i32 %23 to i64
%34 = getelementptr inbounds i8*, i8** %14, i64 %33
store i8* %32, i8** %34
%35 = add nsw i32 %23, 1
br label %47
36: ; preds = %20
%37 = tail call i32 @stat(i32 %29, %struct.stat* %13)
%38 = load i64, i64* %19
%39 = trunc i64 %38 to i32
%40 = add i32 %24, %39
%41 = load i32, i32* %28
%42 = tail call i32 @strlen(i32 %41)
%43 = tail call i8* @malloc(i32 %42)
%44 = sext i32 %22 to i64
%45 = getelementptr inbounds i8*, i8** %15, i64 %44
store i8* %43, i8** %45
%46 = add nsw i32 %22, 1
br label %47
47: ; preds = %36, %30
%48 = phi i8* [ %43, %36 ], [ %32, %30 ]
%49 = phi i32 [ %40, %36 ], [ %24, %30 ]
%50 = phi i32 [ %23, %36 ], [ %35, %30 ]
%51 = phi i32 [ %46, %36 ], [ %22, %30 ]
%52 = load i32, i32* %28
%53 = tail call i32 @strcpy(i8* %48, i32 %52)
%54 = tail call %struct.dirent* @readdir(i32* %11)
%55 = icmp eq %struct.dirent* %54, null
br i1 %55, label %56, label %20
56: ; preds = %47, %7
%57 = phi i32 [ 0, %7 ], [ %49, %47 ]
%58 = tail call i8** @calloc(i32 5, i32 8)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %58
%59 = getelementptr inbounds i8*, i8** %58, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %59
%60 = getelementptr inbounds i8*, i8** %58, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %60
%61 = getelementptr inbounds i8*, i8** %58, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %61
%62 = getelementptr inbounds i8*, i8** %58, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %62
%63 = icmp sgt i32 %57, 2047
br i1 %63, label %64, label %74
64: ; preds = %56, %64
%65 = phi i32 [ %68, %64 ], [ 0, %56 ]
%66 = phi i32 [ %67, %64 ], [ %57, %56 ]
%67 = lshr i32 %66, 10
%68 = add nuw nsw i32 %65, 1
%69 = icmp ugt i32 %66, 2097151
br i1 %69, label %64, label %70
70: ; preds = %64
%71 = zext i32 %68 to i64
%72 = getelementptr inbounds i8*, i8** %58, i64 %71
%73 = load i8*, i8** %72
br label %74
74: ; preds = %56, %70
%75 = phi i8* [ %73, %70 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %56 ]
%76 = phi i32 [ %67, %70 ], [ %57, %56 ]
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %76, i8* %75)
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%79 = load i8*, i8** %14
%80 = icmp eq i8* %79, null
br i1 %80, label %91, label %81
81: ; preds = %74, %81
%82 = phi i64 [ %85, %81 ], [ 0, %74 ]
%83 = phi i8* [ %89, %81 ], [ %79, %74 ]
%84 = tail call i32 @putchar(i32 9)
%85 = add nuw i64 %82, 1
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %83)
%87 = tail call i32 @putchar(i32 10)
%88 = getelementptr inbounds i8*, i8** %14, i64 %85
%89 = load i8*, i8** %88
%90 = icmp eq i8* %89, null
br i1 %90, label %91, label %81
91: ; preds = %81, %74
%92 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%93 = load i8*, i8** %15
%94 = icmp eq i8* %93, null
br i1 %94, label %105, label %95
95: ; preds = %91, %95
%96 = phi i64 [ %99, %95 ], [ 0, %91 ]
%97 = phi i8* [ %103, %95 ], [ %93, %91 ]
%98 = tail call i32 @putchar(i32 9)
%99 = add nuw i64 %96, 1
%100 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %97)
%101 = tail call i32 @putchar(i32 10)
%102 = getelementptr inbounds i8*, i8** %15, i64 %99
%103 = load i8*, i8** %102
%104 = icmp eq i8* %103, null
br i1 %104, label %105, label %95
105: ; preds = %95, %91
ret i32 0
}