#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 dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ f_exists(char const *);
unsigned long f_size(char const *);
int f_type(char const *);
int /*<<< orphan*/ formatsize(char *, unsigned long);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ printf(char *, char const *, char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *);
int strlen(char const *);
void dig(const char *path) {
  DIR *dir;
  struct dirent *ent;
  int pathlen = strlen(path);
  unsigned long fSize = 0;
  char *fullpath;
  char weight[200] = "";
  char extra[200] = "";
  if (!f_exists(path)) {
    return;
  }
  if (f_type(path) == 1) {
    if ((dir = opendir(path)) != NULL) {
      while ((ent = readdir(dir)) != NULL) {
        if (ent->d_name[0] == '.' ||
            (ent->d_name[0] == '.' && ent->d_name[1] == '.'))
          continue;
        fullpath = malloc(pathlen + strlen(ent->d_name) + 2);
        if (fullpath == NULL)
          continue;
        sprintf(fullpath, "%s/%s", path, ent->d_name);
        dig(fullpath);
        free(fullpath);
      }
      closedir(dir);
    } else {
      return;
    }
  } else if (f_type(path) == 0) {
    fSize = f_size(path);
    if (fSize > 4294967295ul) {
      formatsize(weight, fSize);
      formatsize(extra, fSize - 4294967295ul);
      printf("%s\t[%s, -%s]\n", path, weight, extra);
    }
  }
}


x86 assembly (clang, -O0):
<dig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1080 <memset@plt>
lea    -0x1d0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1080 <memset@plt>
mov    -0x8(%rbp),%rdi
call   10d0 <f_exists@plt>
cmp    $0x0,%eax
jne    1240 <dig+0x60>
jmp    13ca <dig+0x1ea>
mov    -0x8(%rbp),%rdi
call   1090 <f_type@plt>
cmp    $0x1,%eax
jne    1347 <dig+0x167>
mov    -0x8(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     133d <dig+0x15d>
jmp    126e <dig+0x8e>
mov    -0x10(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     132f <dig+0x14f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     12bf <dig+0xdf>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    12c4 <dig+0xe4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    12c4 <dig+0xe4>
jmp    126e <dig+0x8e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x1d4(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
mov    -0x1d4(%rbp),%edi
add    %eax,%edi
add    $0x2,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12fd <dig+0x11d>
jmp    126e <dig+0x8e>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    0xced(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   10f0 <dig@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    126e <dig+0x8e>
mov    -0x10(%rbp),%rdi
call   10a0 <closedir@plt>
jmp    1342 <dig+0x162>
jmp    13ca <dig+0x1ea>
jmp    13ca <dig+0x1ea>
mov    -0x8(%rbp),%rdi
call   1090 <f_type@plt>
cmp    $0x0,%eax
jne    13c5 <dig+0x1e5>
mov    -0x8(%rbp),%rdi
call   1040 <f_size@plt>
mov    %rax,-0x28(%rbp)
mov    $0xffffffff,%eax
cmp    %rax,-0x28(%rbp)
jbe    13c0 <dig+0x1e0>
lea    -0x100(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10e0 <formatsize@plt>
lea    -0x1d0(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movabs $0xffffffff,%rax
sub    %rax,%rsi
call   10e0 <formatsize@plt>
mov    -0x8(%rbp),%rsi
lea    -0x100(%rbp),%rdx
lea    -0x1d0(%rbp),%rcx
lea    0xc4b(%rip),%rdi
call   1070 <printf@plt>
jmp    13c5 <dig+0x1e5>
jmp    13ca <dig+0x1ea>
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dig>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
mov    %rdi,%r15
call   1060 <strlen@plt>
mov    %eax,%r14d
xorps  %xmm0,%xmm0
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movq   $0x0,0x190(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
mov    %r15,%rdi
call   10c0 <f_exists@plt>
test   %eax,%eax
je     13bf <dig+0x1ef>
mov    %r15,%rdi
call   1080 <f_type@plt>
mov    %r15,%rdi
cmp    $0x1,%eax
jne    1365 <dig+0x195>
call   1050 <opendir@plt>
test   %rax,%rax
je     13bf <dig+0x1ef>
mov    %rax,%r13
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     13d1 <dig+0x201>
mov    %rax,%rbx
add    $0x2,%r14d
lea    0xcfe(%rip),%r12
jmp    1324 <dig+0x154>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     13d1 <dig+0x201>
mov    (%rbx),%rdi
cmpb   $0x2e,(%rdi)
je     1310 <dig+0x140>
call   1060 <strlen@plt>
lea    (%rax,%r14,1),%edi
call   10b0 <malloc@plt>
test   %rax,%rax
je     1310 <dig+0x140>
mov    %rax,%rbp
mov    (%rbx),%rcx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   10e0 <dig@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    1310 <dig+0x140>
call   1080 <f_type@plt>
test   %eax,%eax
jne    13bf <dig+0x1ef>
mov    %r15,%rdi
call   1040 <f_size@plt>
mov    %rax,%rbx
shr    $0x20,%rax
je     13bf <dig+0x1ef>
lea    0xd0(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <formatsize@plt>
movabs $0xffffffff00000001,%rsi
ff ff ff
add    %rbx,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10d0 <formatsize@plt>
lea    0xc55(%rip),%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1070 <printf@plt>
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <closedir@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [14 x i8] c"%s\09[%s, -%s]\0A\00"
define void @dig(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca %struct.dirent*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
%8 = alloca [200 x i8]
%9 = alloca [200 x i8]
store i8* %0, i8** %2
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %5
store i64 0, i64* %6
%12 = bitcast [200 x i8]* %8 to i8*
%13 = bitcast [200 x i8]* %9 to i8*
%14 = load i8*, i8** %2
%15 = call i32 @f_exists(i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %1
br label %106
18: ; preds = %1
%19 = load i8*, i8** %2
%20 = call i32 @f_type(i8* %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %83
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = call i32* @opendir(i8* %23)
store i32* %24, i32** %3
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %81
26: ; preds = %22
br label %27
27: ; preds = %68, %67, %55, %26
%28 = load i32*, i32** %3
%29 = call %struct.dirent* @readdir(i32* %28)
store %struct.dirent* %29, %struct.dirent** %4
%30 = icmp ne %struct.dirent* %29, null
br i1 %30, label %31, label %78
31: ; preds = %27
%32 = load %struct.dirent*, %struct.dirent** %4
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %32, i32 0, i32 0
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 46
br i1 %38, label %55, label %39
39: ; preds = %31
%40 = load %struct.dirent*, %struct.dirent** %4
%41 = getelementptr inbounds %struct.dirent, %struct.dirent* %40, i32 0, i32 0
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i64 0
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 46
br i1 %46, label %47, label %56
47: ; preds = %39
%48 = load %struct.dirent*, %struct.dirent** %4
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 46
br i1 %54, label %55, label %56
55: ; preds = %47, %31
br label %27
56: ; preds = %47, %39
%57 = load i32, i32* %5
%58 = load %struct.dirent*, %struct.dirent** %4
%59 = getelementptr inbounds %struct.dirent, %struct.dirent* %58, i32 0, i32 0
%60 = load i8*, i8** %59
%61 = call i32 @strlen(i8* %60)
%62 = add nsw i32 %57, %61
%63 = add nsw i32 %62, 2
%64 = call i8* @malloc(i32 %63)
store i8* %64, i8** %7
%65 = load i8*, i8** %7
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %68
67: ; preds = %56
br label %27
68: ; preds = %56
%69 = load i8*, i8** %7
%70 = load i8*, i8** %2
%71 = load %struct.dirent*, %struct.dirent** %4
%72 = getelementptr inbounds %struct.dirent, %struct.dirent* %71, i32 0, i32 0
%73 = load i8*, i8** %72
%74 = call i32 @sprintf(i8* %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %70, i8* %73)
%75 = load i8*, i8** %7
%76 = load i8*, i8** %7
%77 = call i32 @free(i8* %76)
br label %27
78: ; preds = %27
%79 = load i32*, i32** %3
%80 = call i32 @closedir(i32* %79)
br label %82
81: ; preds = %22
br label %106
82: ; preds = %78
br label %106
83: ; preds = %18
%84 = load i8*, i8** %2
%85 = call i32 @f_type(i8* %84)
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %105
87: ; preds = %83
%88 = load i8*, i8** %2
%89 = call i64 @f_size(i8* %88)
store i64 %89, i64* %6
%90 = load i64, i64* %6
%91 = icmp ugt i64 %90, 4294967295
br i1 %91, label %92, label %104
92: ; preds = %87
%93 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%94 = load i64, i64* %6
%95 = call i32 @formatsize(i8* %93, i64 %94)
%96 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%97 = load i64, i64* %6
%98 = sub i64 %97, 4294967295
%99 = call i32 @formatsize(i8* %96, i64 %98)
%100 = load i8*, i8** %2
%101 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%102 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%103 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %100, i8* %101, i8* %102)
br label %104
104: ; preds = %92, %87
br label %105
105: ; preds = %104, %83
br label %106
106: ; preds = %17, %81, %105, %82
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [14 x i8] c"%s\09[%s, -%s]\0A\00"
define void @dig(i8* %0) {
%2 = alloca [200 x i8]
%3 = alloca [200 x i8]
%4 = tail call i32 @strlen(i8* %0)
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @f_exists(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %51, label %9
9: ; preds = %1
%10 = tail call i32 @f_type(i8* %0)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %40
12: ; preds = %9
%13 = tail call i32* @opendir(i8* %0)
%14 = icmp eq i32* %13, null
br i1 %14, label %51, label %15
15: ; preds = %12
%16 = tail call %struct.dirent* @readdir(i32* %13)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %38, label %18
18: ; preds = %15
%19 = add i32 %4, 2
br label %20
20: ; preds = %18, %35
%21 = phi %struct.dirent* [ %16, %18 ], [ %36, %35 ]
%22 = getelementptr inbounds %struct.dirent, %struct.dirent* %21, i64 0, i32 0
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 46
br i1 %25, label %35, label %26
26: ; preds = %20
%27 = tail call i32 @strlen(i8* %23)
%28 = add i32 %19, %27
%29 = tail call i8* @malloc(i32 %28)
%30 = icmp eq i8* %29, null
br i1 %30, label %35, label %31
31: ; preds = %26
%32 = load i8*, i8** %22
%33 = tail call i32 @sprintf(i8* %29, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %32)
tail call void @dig(i8* %29)
%34 = tail call i32 @free(i8* %29)
br label %35
35: ; preds = %31, %26, %20
%36 = tail call %struct.dirent* @readdir(i32* %13)
%37 = icmp eq %struct.dirent* %36, null
br i1 %37, label %38, label %20
38: ; preds = %35, %15
%39 = tail call i32 @closedir(i32* %13)
br label %51
40: ; preds = %9
%41 = tail call i32 @f_type(i8* %0)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = tail call i64 @f_size(i8* %0)
%45 = icmp ugt i64 %44, 4294967295
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = call i32 @formatsize(i8* %5, i64 %44)
%48 = add i64 %44, -4294967295
%49 = call i32 @formatsize(i8* %6, i64 %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %5, i8* %6)
br label %51
51: ; preds = %38, %43, %46, %40, %12, %1
ret void
}