decompiled_code:
_BOOL8 __fastcall file_exists(const char *a1)
{
int v1; // edx
_BOOL8 result; // rax
struct stat64 v3; // [rsp+0h] [rbp-98h] BYREF

v1 = get_file_info(a1, &v3);
result = 0LL;
if ( v1 >= 0 )
result = (v3.st_mode & 0xF000) == 0x8000;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(const char *a1)
{
int v1; // edx
_BOOL8 result; // rax
struct stat64 v3; // [rsp+0h] [rbp-98h] BYREF

v1 = func7(a1, &v3);
result = 0LL;
if ( v1 >= 0 )
result = (v3.st_mode & 0xF000) == 0x8000;
return result;
}

original_code:
int file_exists(const char * path)
{
  struct stat pathinfo;
  int rv = get_file_info(path, &pathinfo);
  if (rv < 0) { return 0; }
  if (((((pathinfo.st_mode)) & 0170000) == (0100000))) {
    return 1;
  }
  return 0;
}

canonical_original_code:
int file_exists(char *path)
{
  struct stat pathinfo;
  int rv = get_file_info(path, &pathinfo);
  if (rv < 0) { return 0; }
  if (((((pathinfo.st_mode)) & 0170000) == (0100000))) {
    return 1;
  }
  return 0;
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


repo: jvirkki/dupd

decompiled_code:
__int64 __fastcall read_file_bytes(const char *a1, void *a2, size_t a3, __off64_t a4, ssize_t *a5)
{
int v8; // eax
int v9; // ebx
ssize_t v10; // rax
unsigned int v11; // ebp
const char *v13; // rax
const char *v14; // rax

*a5 = 0LL;
v8 = open64(a1, 0);
if ( v8 < 0 )
{
if ( log_level > 2 )
{
pthread_mutex_lock(&logger_lock);
v13 = get_thread_name();
printf("%s", v13);
printf("Error opening [%s]\n", a1);
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
}
++s_files_cant_read;
v11 = -1;
}
else
{
v9 = v8;
if ( a4 && a4 != lseek64(v8, a4, 0) )
{
if ( log_level > 2 )
{
pthread_mutex_lock(&logger_lock);
v14 = get_thread_name();
printf("%s", v14);
printf("Error seeking [%s]\n", a1);
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
}
exit(1);
}
if ( !a3 )
{
printf("error: requested zero bytes from [%s] (skip=%lu)\n", a1, a4);
exit(1);
}
v10 = read(v9, a2, a3);
if ( v10 < 0 )
{
++s_files_cant_read;
v11 = -1;
}
else
{
*a5 = v10;
stats_total_bytes_read += v10;
v11 = 0;
}
close(v9);
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1, void *a2, size_t a3, __off64_t a4, ssize_t *a5)
{
int v8; // eax
int v9; // ebx
ssize_t v10; // rax
unsigned int v11; // ebp
const char *v13; // rax
const char *v14; // rax

*a5 = 0LL;
v8 = open64(a1, 0);
if ( v8 < 0 )
{
if ( log_level > 2 )
{
pthread_mutex_lock(&logger_lock);
v13 = func6();
printf("%s", v13);
printf("Error opening [%s]\n", a1);
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
}
++s_files_cant_read;
v11 = -1;
}
else
{
v9 = v8;
if ( a4 && a4 != lseek64(v8, a4, 0) )
{
if ( log_level > 2 )
{
pthread_mutex_lock(&logger_lock);
v14 = func6();
printf("%s", v14);
printf("Error seeking [%s]\n", a1);
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
}
exit(1);
}
if ( !a3 )
{
printf("error: requested zero bytes from [%s] (skip=%lu)\n", a1, a4);
exit(1);
}
v10 = read(v9, a2, a3);
if ( v10 < 0 )
{
++s_files_cant_read;
v11 = -1;
}
else
{
*a5 = v10;
stats_total_bytes_read += v10;
v11 = 0;
}
close(v9);
}
return v11;
}

original_code:
int read_file_bytes(char * path, char * output,
                    uint64_t bytes, uint64_t skip, uint64_t * bytes_read)
{
  *bytes_read = 0;
  int file = open(path, 00);
  if (file < 0) {
    if (3 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("Error opening [%s]\n", path); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
    s_files_cant_read++;
    return(-1);
  }
  if (skip > 0) {
    uint64_t pos = lseek(file, skip, 0);
    if (pos != skip) {
      if (3 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("Error seeking [%s]\n", path); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
      exit(1);
    }
  }
  if (bytes == 0) {
    printf("error: requested zero bytes from [%s] (skip=%" "l" "u" ")\n",
           path, skip);
    exit(1);
  }
  int rv = 0;
  ssize_t got = read(file, output, bytes);
  if (got >= 0) {
    *bytes_read = got;
    stats_total_bytes_read += *bytes_read;
  } else {
    rv = -1;
    s_files_cant_read++;
  }
  close(file);
  return rv;
}

canonical_original_code:
int read_file_bytes(char *path, char *output, unsigned long bytes, unsigned long skip, unsigned long *bytes_read)
{
  *bytes_read = 0;
  int file = open(path, 00);
  if (file < 0) {
    if (3 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("Error opening [%s]\n", path); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
    s_files_cant_read++;
    return(-1);
  }
  if (skip > 0) {
    unsigned long pos = lseek(file, skip, 0);
    if (pos != skip) {
      if (3 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("Error seeking [%s]\n", path); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
      exit(1);
    }
  }
  if (bytes == 0) {
    printf("error: requested zero bytes from [%s] (skip=%" "l" "u" ")\n",
           path, skip);
    exit(1);
  }
  int rv = 0;
  long got = read(file, output, bytes);
  if (got >= 0) {
    *bytes_read = got;
    stats_total_bytes_read += *bytes_read;
  } else {
    rv = -1;
    s_files_cant_read++;
  }
  close(file);
  return rv;
}

variable_types:
path
char *

variable_types:
output
char *

variable_types:
bytes
unsigned long

variable_types:
skip
unsigned long

variable_types: file int

variable_types:
pos
unsigned long

variable_types: rv int

variable_types: got long

return_type: int


decompiled_code:
size_t __fastcall linux_strlcpy(char *dest, char *src, size_t n)
{
size_t v4; // rax
size_t v5; // rbx

v4 = strlen(src);
v5 = v4;
if ( v4 >= n )
{
printf("error: strlcpy: src too big: %d >= %d\n", (unsigned int)v4, (unsigned int)n);
exit(1);
}
strncpy(dest, src, n);
return v5;
}

canonical_decompiled_code:
size_t __fastcall func11(char *dest, char *src, size_t n)
{
size_t v4; // rax
size_t v5; // rbx

v4 = strlen(src);
v5 = v4;
if ( v4 >= n )
{
printf("error: strlcpy: src too big: %d >= %d\n", (unsigned int)v4, (unsigned int)n);
exit(1);
}
strncpy(dest, src, n);
return v5;
}

original_code:
size_t linux_strlcpy(char *dst, const char *src, size_t dstsize)
{
  size_t n = strlen(src);
  if (n >= dstsize) {
    printf("error: strlcpy: src too big: %d >= %d\n", (int)n, (int)dstsize);
    exit(1);
  }
  strncpy(dst, src, dstsize);
  return n;
}

canonical_original_code:
unsigned long linux_strlcpy(char *dst, char *src, unsigned long dstsize)
{
  unsigned long n = strlen(src);
  if (n >= dstsize) {
    printf("error: strlcpy: src too big: %d >= %d\n", (int)n, (int)dstsize);
    exit(1);
  }
  strncpy(dst, src, dstsize);
  return n;
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
dstsize
unsigned long

variable_types:
n
unsigned long

return_type: unsigned long


decompiled_code:
int __fastcall dump_block_list(const char *a1, unsigned __int8 *a2)
{
int result; // eax
_QWORD *v3; // rbx
int v4; // ebp

if ( a2 )
{
result = printf("%sBLOCK LIST: count=%d\n", a1, *a2);
if ( *a2 )
{
v3 = a2 + 8;
v4 = 0;
do
{
printf("%s[%d] start_pos: %lu , len: %lu , block: %lu\n", a1, (unsigned int)v4++, *v3, v3[1], v3[2]);
v3 += 3;
result = *a2;
}
while ( result > v4 );
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(const char *a1, unsigned __int8 *a2)
{
int result; // eax
_QWORD *v3; // rbx
int v4; // ebp

if ( a2 )
{
result = printf("%sBLOCK LIST: count=%d\n", a1, *a2);
if ( *a2 )
{
v3 = a2 + 8;
v4 = 0;
do
{
printf("%s[%d] start_pos: %lu , len: %lu , block: %lu\n", a1, (unsigned int)v4++, *v3, v3[1], v3[2]);
v3 += 3;
result = *a2;
}
while ( result > v4 );
}
}
return result;
}

original_code:
void dump_block_list(const char * prefix, struct block_list * bl)
{
  if (bl == ((void *)0)) { return; }
  printf("%sBLOCK LIST: count=%d\n", prefix, bl->count);
  for (int n = 0; n < bl->count; n++) {
    printf("%s[%d] "
           "start_pos: %" "l" "u" " ,  len: %" "l" "u" " , block: %" "l" "u""\n",
           prefix, n,
           bl->entry[n].start_pos, bl->entry[n].len, bl->entry[n].block);
  }
}

canonical_original_code:
void dump_block_list(char *prefix, struct block_list *bl)
{
  if (bl == ((void *)0)) { return; }
  printf("%sBLOCK LIST: count=%d\n", prefix, bl->count);
  for (int n = 0; n < bl->count; n++) {
    printf("%s[%d] "
           "start_pos: %" "l" "u" " ,  len: %" "l" "u" " , block: %" "l" "u""\n",
           prefix, n,
           bl->entry[n].start_pos, bl->entry[n].len, bl->entry[n].block);
  }
}

variable_types:
prefix
char *

variable_types: struct block_list { unsigned char count; struct block_list_entry { unsigned long start_pos; unsigned long len; unsigned long block; } entry[]; } *

variable_types: n int

return_type: void

user_defined_types: struct block_list { unsigned char count; struct block_list_entry entry[]; }


decompiled_code:
void *fiemap_alloc()
{
_DWORD *v0; // rbx
void *result; // rax

v0 = malloc(0x37E8uLL);
result = memset(v0, 0, 0x37E8uLL);
v0[6] = 255;
return result;
}

canonical_decompiled_code:
void *func13()
{
_DWORD *v0; // rbx
void *result; // rax

v0 = malloc(0x37E8uLL);
result = memset(v0, 0, 0x37E8uLL);
v0[6] = 255;
return result;
}

original_code:
void * fiemap_alloc()
{
  struct fiemap * fiemap;
  int fiesize = sizeof(struct fiemap) + 255 * sizeof(struct fiemap_extent);
  fiemap = (struct fiemap *)malloc(fiesize);
  memset(fiemap, 0, fiesize);
  fiemap->fm_start = 0;
  fiemap->fm_length = 0;
  fiemap->fm_flags = 0;
  fiemap->fm_extent_count = 255;
  fiemap->fm_mapped_extents = 0;
  return (void *)fiemap;
}

canonical_original_code:
void *fiemap_alloc()
{
  struct fiemap *fiemap;
  int fiesize = sizeof(struct fiemap) + 255 * sizeof(struct fiemap_extent);
  fiemap = (struct fiemap *)malloc(fiesize);
  memset(fiemap, 0, fiesize);
  fiemap->fm_start = 0;
  fiemap->fm_length = 0;
  fiemap->fm_flags = 0;
  fiemap->fm_extent_count = 255;
  fiemap->fm_mapped_extents = 0;
  return (void *)fiemap;
}

variable_types: struct fiemap { unsigned long long fm_start; unsigned long long fm_length; unsigned int fm_flags; unsigned int fm_mapped_extents; unsigned int fm_extent_count; unsigned int fm_reserved; struct fiemap_extent { unsigned long long fe_logical; unsigned long long fe_physical; unsigned long long fe_length; unsigned long long fe_reserved64[2]; unsigned int fe_flags; unsigned int fe_reserved[3]; } fm_extents[]; } *

variable_types: fiesize int

return_type: void *

user_defined_types: struct fiemap { unsigned long long fm_start; unsigned long long fm_length; unsigned int fm_flags; unsigned int fm_mapped_extents; unsigned int fm_extent_count; unsigned int fm_reserved; struct fiemap_extent fm_extents[]; }


decompiled_code:
__int64 get_file_limit()
{
__int64 result; // rax
const char *v1; // rax
struct rlimit64 v2; // [rsp+0h] [rbp-18h] BYREF

if ( getrlimit64(RLIMIT_NOFILE, &v2) )
{
result = 200LL;
if ( log_level > 3 )
{
pthread_mutex_lock(&logger_lock);
v1 = get_thread_name();
printf("%s", v1);
puts("Unable get file limit, guessing...");
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
result = 200LL;
}
}
else
{
if ( v2.rlim_cur < v2.rlim_max )
{
v2.rlim_cur = v2.rlim_max;
setrlimit64(RLIMIT_NOFILE, &v2);
getrlimit64(RLIMIT_NOFILE, &v2);
}
result = LODWORD(v2.rlim_cur);
}
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 result; // rax
const char *v1; // rax
struct rlimit64 v2; // [rsp+0h] [rbp-18h] BYREF

if ( getrlimit64(RLIMIT_NOFILE, &v2) )
{
result = 200LL;
if ( log_level > 3 )
{
pthread_mutex_lock(&logger_lock);
v1 = func6();
printf("%s", v1);
puts("Unable get file limit, guessing...");
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
result = 200LL;
}
}
else
{
if ( v2.rlim_cur < v2.rlim_max )
{
v2.rlim_cur = v2.rlim_max;
setrlimit64(RLIMIT_NOFILE, &v2);
getrlimit64(RLIMIT_NOFILE, &v2);
}
result = LODWORD(v2.rlim_cur);
}
return result;
}

original_code:
int get_file_limit()
{
  struct rlimit rlim;
  if (getrlimit(RLIMIT_NOFILE, &rlim)) {
    if (4 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("Unable get file limit, guessing...\n"); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
    return 200;
  }
  if (rlim.rlim_cur < rlim.rlim_max) {
    rlim.rlim_cur = rlim.rlim_max;
    setrlimit(RLIMIT_NOFILE, &rlim);
    getrlimit(RLIMIT_NOFILE, &rlim);
  }
  return rlim.rlim_cur;
}

variable_types: struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; }


decompiled_code:
unsigned int __fastcall d_mutex_lock(pthread_mutex_t *a1, const char *a2)
{
unsigned int result; // eax

result = pthread_mutex_lock(a1);
if ( result )
{
printf("error: %s: pthread_mutex_lock == %d\n", a2, result);
exit(1);
}
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func0(pthread_mutex_t *a1, const char *a2)
{
unsigned int result; // eax

result = pthread_mutex_lock(a1);
if ( result )
{
printf("error: %s: pthread_mutex_lock == %d\n", a2, result);
exit(1);
}
return result;
}

original_code:
static inline void d_mutex_lock(pthread_mutex_t * mutex, char * line)
{
  int rv = pthread_mutex_lock(mutex);
  if (rv != 0) {
    printf("error: %s: pthread_mutex_lock == %d\n", line, rv);
    exit(1);
  }
}

canonical_original_code:
static inline void d_mutex_lock(union pthread_mutex_t *mutex, char *line)
{
  int rv = pthread_mutex_lock(mutex);
  if (rv != 0) {
    printf("error: %s: pthread_mutex_lock == %d\n", line, rv);
    exit(1);
  }
}

variable_types: union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *

variable_types:
line
char *

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
unsigned int __fastcall d_mutex_unlock(pthread_mutex_t *a1)
{
unsigned int result; // eax

result = pthread_mutex_unlock(a1);
if ( result )
{
printf("error: pthread_mutex_unlock == %d\n", result);
exit(1);
}
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func1(pthread_mutex_t *a1)
{
unsigned int result; // eax

result = pthread_mutex_unlock(a1);
if ( result )
{
printf("error: pthread_mutex_unlock == %d\n", result);
exit(1);
}
return result;
}

original_code:
static inline void d_mutex_unlock(pthread_mutex_t * mutex)
{
  int rv = pthread_mutex_unlock(mutex);
  if (rv != 0) {
    printf("error: pthread_mutex_unlock == %d\n", rv);
    exit(1);
  }
}

canonical_original_code:
static inline void d_mutex_unlock(union pthread_mutex_t *mutex)
{
  int rv = pthread_mutex_unlock(mutex);
  if (rv != 0) {
    printf("error: pthread_mutex_unlock == %d\n", rv);
    exit(1);
  }
}

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
int report_stats()
{
int result; // eax
unsigned int v1; // ebx
__int64 v2; // rdx
__int64 v3; // rax
int v4; // ebp
int v5; // er12
char v6[56]; // [rsp+0h] [rbp-38h] BYREF

if ( log_level > 0 )
{
putchar(10);
v3 = get_current_time_millis();
time_string(v6, 20LL, v3 - stats_main_start);
printf(
"Total duplicates: %d files in %d groups in %s\n",
(unsigned int)s_files_completed_dups,
(unsigned int)stats_duplicate_groups,
v6);
if ( stats_duplicate_files > 0 )
puts("Run 'dupd report' to list duplicates.");
}
result = s_files_too_small + s_files_skip_notfile;
v1 = s_total_files_seen
- (s_files_too_small
+ s_files_skip_notfile)
- s_files_skip_error
- s_files_skip_badsep
- s_files_hl_skip;
if ( log_level > 1 )
{
v4 = s_files_in_sizetree;
v5 = s_files_processed;
putchar(10);
printf("Total files seen: %u\n", (unsigned int)s_total_files_seen);
printf(
" (too small: %u, not file: %u, errors: %u, skip: %u, hl_skip: %u)\n",
(unsigned int)s_files_too_small,
(unsigned int)s_files_skip_notfile,
(unsigned int)s_files_skip_error,
(unsigned int)s_files_skip_badsep,
(unsigned int)s_files_hl_skip);
printf("Files queued for processing: %u in %u sets\n", v1, (unsigned int)s_stats_size_list_count);
printf(" (files with unique size: %u)\n", (unsigned int)(v4 - v5));
printf("Total files to process: %u\n", (unsigned int)s_files_processed);
printf(" Duplicate files: %u\n", (unsigned int)s_files_completed_dups);
printf(" Unique files: %u\n", (unsigned int)s_files_completed_unique);
result = printf(" Unable to read: %u\n", (unsigned int)s_files_cant_read);
if ( hardlink_is_unique )
result = printf(" Skipped hardlinks: %u\n", (unsigned int)s_files_hl_skip);
}
v2 = (unsigned int)(s_files_in_sizetree - s_files_hl_skip);
if ( (_DWORD)v2 != v1 )
{
printf("error: mismatch files_accepted: %u != files in sizetree: %u\n", v1, v2);
exit(1);
}
return result;
}

canonical_decompiled_code:
int func2()
{
int result; // eax
unsigned int v1; // ebx
__int64 v2; // rdx
__int64 v3; // rax
int v4; // ebp
int v5; // er12
char v6[56]; // [rsp+0h] [rbp-38h] BYREF

if ( log_level > 0 )
{
putchar(10);
v3 = get_current_time_millis();
time_string(v6, 20LL, v3 - stats_main_start);
printf(
"Total duplicates: %d files in %d groups in %s\n",
(unsigned int)s_files_completed_dups,
(unsigned int)stats_duplicate_groups,
v6);
if ( stats_duplicate_files > 0 )
puts("Run 'dupd report' to list duplicates.");
}
result = s_files_too_small + s_files_skip_notfile;
v1 = s_total_files_seen
- (s_files_too_small
+ s_files_skip_notfile)
- s_files_skip_error
- s_files_skip_badsep
- s_files_hl_skip;
if ( log_level > 1 )
{
v4 = s_files_in_sizetree;
v5 = s_files_processed;
putchar(10);
printf("Total files seen: %u\n", (unsigned int)s_total_files_seen);
printf(
" (too small: %u, not file: %u, errors: %u, skip: %u, hl_skip: %u)\n",
(unsigned int)s_files_too_small,
(unsigned int)s_files_skip_notfile,
(unsigned int)s_files_skip_error,
(unsigned int)s_files_skip_badsep,
(unsigned int)s_files_hl_skip);
printf("Files queued for processing: %u in %u sets\n", v1, (unsigned int)s_stats_size_list_count);
printf(" (files with unique size: %u)\n", (unsigned int)(v4 - v5));
printf("Total files to process: %u\n", (unsigned int)s_files_processed);
printf(" Duplicate files: %u\n", (unsigned int)s_files_completed_dups);
printf(" Unique files: %u\n", (unsigned int)s_files_completed_unique);
result = printf(" Unable to read: %u\n", (unsigned int)s_files_cant_read);
if ( hardlink_is_unique )
result = printf(" Skipped hardlinks: %u\n", (unsigned int)s_files_hl_skip);
}
v2 = (unsigned int)(s_files_in_sizetree - s_files_hl_skip);
if ( (_DWORD)v2 != v1 )
{
printf("error: mismatch files_accepted: %u != files in sizetree: %u\n", v1, v2);
exit(1);
}
return result;
}

original_code:
void report_stats()
{
  if (log_level >= 1) {
    printf("\n");
    char timebuf[20];
    time_string(timebuf, 20, get_current_time_millis() - stats_main_start);
    printf("Total duplicates: %d files in %d groups in %s\n",
           s_files_completed_dups, stats_duplicate_groups, timebuf);
    if (stats_duplicate_files > 0) {
      printf("Run 'dupd report' to list duplicates.\n");
    }
  }
  uint32_t files_accepted = s_total_files_seen - s_files_too_small -
    s_files_skip_notfile - s_files_skip_error - s_files_skip_badsep -
    s_files_hl_skip;
  uint32_t unique_files = s_files_in_sizetree - s_files_processed;
  if (log_level >= 2) {
    printf("\n");
    printf("Total files seen: %" "u" "\n", s_total_files_seen);
    printf(" (too small: %" "u" ", not file: %"
           "u" ", errors: %" "u" ", skip: %" "u" ", hl_skip: %"
           "u" ")\n",
           s_files_too_small, s_files_skip_notfile,
           s_files_skip_error, s_files_skip_badsep, s_files_hl_skip);
    printf("Files queued for processing: %" "u" " in %" "u" " sets\n",
           files_accepted, s_stats_size_list_count);
    printf(" (files with unique size: %" "u" ")\n", unique_files);
    printf("Total files to process: %" "u" "\n", s_files_processed);
    printf(" Duplicate files: %" "u" "\n", s_files_completed_dups);
    printf(" Unique files: %" "u" "\n", s_files_completed_unique);
    printf(" Unable to read: %" "u" "\n", s_files_cant_read);
    if (hardlink_is_unique) {
      printf(" Skipped hardlinks: %" "u" "\n", s_files_hl_skip);
    }
  }
  if (files_accepted != s_files_in_sizetree - s_files_hl_skip) {
    printf("error: mismatch files_accepted: %" "u"
           " != files in sizetree: %" "u" "\n",
           files_accepted, s_files_in_sizetree - s_files_hl_skip);
    exit(1);
  }
}

canonical_original_code:
void report_stats()
{
  if (log_level >= 1) {
    printf("\n");
    char timebuf[20];
    time_string(timebuf, 20, get_current_time_millis() - stats_main_start);
    printf("Total duplicates: %d files in %d groups in %s\n",
           s_files_completed_dups, stats_duplicate_groups, timebuf);
    if (stats_duplicate_files > 0) {
      printf("Run 'dupd report' to list duplicates.\n");
    }
  }
  unsigned int files_accepted = s_total_files_seen - s_files_too_small -
    s_files_skip_notfile - s_files_skip_error - s_files_skip_badsep -
    s_files_hl_skip;
  unsigned int unique_files = s_files_in_sizetree - s_files_processed;
  if (log_level >= 2) {
    printf("\n");
    printf("Total files seen: %" "u" "\n", s_total_files_seen);
    printf(" (too small: %" "u" ", not file: %"
           "u" ", errors: %" "u" ", skip: %" "u" ", hl_skip: %"
           "u" ")\n",
           s_files_too_small, s_files_skip_notfile,
           s_files_skip_error, s_files_skip_badsep, s_files_hl_skip);
    printf("Files queued for processing: %" "u" " in %" "u" " sets\n",
           files_accepted, s_stats_size_list_count);
    printf(" (files with unique size: %" "u" ")\n", unique_files);
    printf("Total files to process: %" "u" "\n", s_files_processed);
    printf(" Duplicate files: %" "u" "\n", s_files_completed_dups);
    printf(" Unique files: %" "u" "\n", s_files_completed_unique);
    printf(" Unable to read: %" "u" "\n", s_files_cant_read);
    if (hardlink_is_unique) {
      printf(" Skipped hardlinks: %" "u" "\n", s_files_hl_skip);
    }
  }
  if (files_accepted != s_files_in_sizetree - s_files_hl_skip) {
    printf("error: mismatch files_accepted: %" "u"
           " != files in sizetree: %" "u" "\n",
           files_accepted, s_files_in_sizetree - s_files_hl_skip);
    exit(1);
  }
}

variable_types:
timebuf
char [20]


decompiled_code:
unsigned int __fastcall inc_stats_read_buffers_allocated(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v5; // rax
int v6; // eax
char v7[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_read_buffers_allocated += a3;
if ( trace_file_fd > 0 )
{
v5 = get_current_time_millis();
v6 = snprintf(v7, 0x50uLL, "%lu A RB %u %lu\n", v5 - stats_main_start, a3, stats_read_buffers_allocated);
write(trace_file_fd, v7, v6);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func4(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v5; // rax
int v6; // eax
char v7[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_read_buffers_allocated += a3;
if ( trace_file_fd > 0 )
{
v5 = get_current_time_millis();
v6 = snprintf(v7, 0x50uLL, "%lu A RB %u %lu\n", v5 - stats_main_start, a3, stats_read_buffers_allocated);
write(trace_file_fd, v7, v6);
}
return func1(&stats_lock);
}

original_code:
void inc_stats_read_buffers_allocated(char * path,
                                      uint64_t size, uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_read_buffers_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A RB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_read_buffers_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void inc_stats_read_buffers_allocated(char *path, unsigned long size, unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_read_buffers_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A RB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_read_buffers_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

variable_types:
path
char *

variable_types:
size
unsigned long

variable_types:
bytes
unsigned int

variable_types:
line
char [80]

variable_types:
t
unsigned long


decompiled_code:
unsigned int __fastcall dec_stats_read_buffers_allocated(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v5; // rax
int v6; // eax
char v7[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "decreasing buffers");
stats_read_buffers_allocated -= a3;
if ( trace_file_fd > 0 )
{
v5 = get_current_time_millis();
v6 = snprintf(v7, 0x50uLL, "%lu F RB %u %lu\n", v5 - stats_main_start, a3, stats_read_buffers_allocated);
write(trace_file_fd, v7, v6);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func5(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v5; // rax
int v6; // eax
char v7[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "decreasing buffers");
stats_read_buffers_allocated -= a3;
if ( trace_file_fd > 0 )
{
v5 = get_current_time_millis();
v6 = snprintf(v7, 0x50uLL, "%lu F RB %u %lu\n", v5 - stats_main_start, a3, stats_read_buffers_allocated);
write(trace_file_fd, v7, v6);
}
return func1(&stats_lock);
}

original_code:
void dec_stats_read_buffers_allocated(char * path,
                                      uint64_t size, uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "decreasing buffers");
  stats_read_buffers_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F RB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_read_buffers_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void dec_stats_read_buffers_allocated(char *path, unsigned long size, unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "decreasing buffers");
  stats_read_buffers_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F RB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_read_buffers_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall inc_stats_size_list(__int64 a1, unsigned int a2)
{
__int64 v3; // rax
int v4; // eax
char v5[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_list_allocated += a2;
if ( trace_file_fd > 0 )
{
v3 = get_current_time_millis();
v4 = snprintf(v5, 0x50uLL, "%lu A SL %u %lu\n", v3 - stats_main_start, a2, stats_size_list_allocated);
write(trace_file_fd, v5, v4);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func6(__int64 a1, unsigned int a2)
{
__int64 v3; // rax
int v4; // eax
char v5[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_list_allocated += a2;
if ( trace_file_fd > 0 )
{
v3 = get_current_time_millis();
v4 = snprintf(v5, 0x50uLL, "%lu A SL %u %lu\n", v3 - stats_main_start, a2, stats_size_list_allocated);
write(trace_file_fd, v5, v4);
}
return func1(&stats_lock);
}

original_code:
void inc_stats_size_list(uint64_t size, uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_list_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A SL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_list_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void inc_stats_size_list(unsigned long size, unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_list_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A SL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_list_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall dec_stats_size_list(__int64 a1, unsigned int a2)
{
__int64 v3; // rax
int v4; // eax
char v5[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "decreasing buffers");
stats_size_list_allocated -= a2;
if ( trace_file_fd > 0 )
{
v3 = get_current_time_millis();
v4 = snprintf(v5, 0x50uLL, "%lu F SL %u %lu\n", v3 - stats_main_start, a2, stats_size_list_allocated);
write(trace_file_fd, v5, v4);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func7(__int64 a1, unsigned int a2)
{
__int64 v3; // rax
int v4; // eax
char v5[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "decreasing buffers");
stats_size_list_allocated -= a2;
if ( trace_file_fd > 0 )
{
v3 = get_current_time_millis();
v4 = snprintf(v5, 0x50uLL, "%lu F SL %u %lu\n", v3 - stats_main_start, a2, stats_size_list_allocated);
write(trace_file_fd, v5, v4);
}
return func1(&stats_lock);
}

original_code:
void dec_stats_size_list(uint64_t size, uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "decreasing buffers");
  stats_size_list_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F SL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_list_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void dec_stats_size_list(unsigned long size, unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "decreasing buffers");
  stats_size_list_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F SL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_list_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall inc_stats_hashtable(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_hashtable_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A HT %u %lu\n", v2 - stats_main_start, a1, stats_size_hashtable_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func8(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_hashtable_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A HT %u %lu\n", v2 - stats_main_start, a1, stats_size_hashtable_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void inc_stats_hashtable(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_hashtable_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A HT %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_hashtable_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void inc_stats_hashtable(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_hashtable_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A HT %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_hashtable_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall dec_stats_hashtable(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_hashtable_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F HT %u %lu\n", v2 - stats_main_start, a1, stats_size_hashtable_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func9(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_hashtable_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F HT %u %lu\n", v2 - stats_main_start, a1, stats_size_hashtable_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void dec_stats_hashtable(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_hashtable_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F HT %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_hashtable_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void dec_stats_hashtable(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_hashtable_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F HT %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_hashtable_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall inc_stats_readlist(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_readlist_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A RL %u %lu\n", v2 - stats_main_start, a1, stats_size_readlist_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func10(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_readlist_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A RL %u %lu\n", v2 - stats_main_start, a1, stats_size_readlist_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void inc_stats_readlist(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_readlist_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A RL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_readlist_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void inc_stats_readlist(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_readlist_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A RL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_readlist_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall dec_stats_readlist(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_readlist_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F RL %u %lu\n", v2 - stats_main_start, a1, stats_size_readlist_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func11(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_readlist_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F RL %u %lu\n", v2 - stats_main_start, a1, stats_size_readlist_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void dec_stats_readlist(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_readlist_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F RL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_readlist_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void dec_stats_readlist(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_readlist_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F RL %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_readlist_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall inc_stats_dirbuf(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_dirbuf_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A DB %u %lu\n", v2 - stats_main_start, a1, stats_size_dirbuf_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func12(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_dirbuf_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A DB %u %lu\n", v2 - stats_main_start, a1, stats_size_dirbuf_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void inc_stats_dirbuf(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_dirbuf_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A DB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_dirbuf_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void inc_stats_dirbuf(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_dirbuf_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A DB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_dirbuf_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall dec_stats_dirbuf(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_dirbuf_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F DB %u %lu\n", v2 - stats_main_start, a1, stats_size_dirbuf_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func13(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_dirbuf_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F DB %u %lu\n", v2 - stats_main_start, a1, stats_size_dirbuf_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void dec_stats_dirbuf(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_dirbuf_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F DB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_dirbuf_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void dec_stats_dirbuf(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_dirbuf_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F DB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_dirbuf_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall inc_stats_pblocks(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_pblocks_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A PB %u %lu\n", v2 - stats_main_start, a1, stats_size_pblocks_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func14(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_pblocks_allocated += a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu A PB %u %lu\n", v2 - stats_main_start, a1, stats_size_pblocks_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void inc_stats_pblocks(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_pblocks_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A PB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_pblocks_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void inc_stats_pblocks(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_pblocks_allocated += bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " A PB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_pblocks_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall dec_stats_pblocks(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

d_mutex_lock(&stats_lock, "increasing buffers");
stats_size_pblocks_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F PB %u %lu\n", v2 - stats_main_start, a1, stats_size_pblocks_allocated);
write(trace_file_fd, v4, v3);
}
return d_mutex_unlock(&stats_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func15(unsigned int a1)
{
__int64 v2; // rax
int v3; // eax
char v4[88]; // [rsp+0h] [rbp-58h] BYREF

func0(&stats_lock, "increasing buffers");
stats_size_pblocks_allocated -= a1;
if ( trace_file_fd > 0 )
{
v2 = get_current_time_millis();
v3 = snprintf(v4, 0x50uLL, "%lu F PB %u %lu\n", v2 - stats_main_start, a1, stats_size_pblocks_allocated);
write(trace_file_fd, v4, v3);
}
return func1(&stats_lock);
}

original_code:
void dec_stats_pblocks(uint32_t bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_pblocks_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    uint64_t t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F PB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_pblocks_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}

canonical_original_code:
void dec_stats_pblocks(unsigned int bytes)
{
  d_mutex_lock(&stats_lock, "increasing buffers");
  stats_size_pblocks_allocated -= bytes;
  ;
  if (trace_file_fd > 0) {
    char line[80];
    int n;
    unsigned long t = get_current_time_millis() - stats_main_start;
    n = snprintf(line, 80, "%" "l" "u" " F PB %" "u" " %" "l" "u" "\n",
                 t, bytes, stats_size_pblocks_allocated);
    write(trace_file_fd, line, n);
  }
  d_mutex_unlock(&stats_lock);
}


decompiled_code:
unsigned int __fastcall increase_unique_counter(int a1)
{
d_mutex_lock(&counters_lock, "counters");
s_files_completed_unique += a1;
return d_mutex_unlock(&counters_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func16(int a1)
{
func0(&counters_lock, "counters");
s_files_completed_unique += a1;
return func1(&counters_lock);
}

original_code:
void increase_unique_counter(int n)
{
  d_mutex_lock(&counters_lock, "counters");
  s_files_completed_unique += n;
  d_mutex_unlock(&counters_lock);
}


decompiled_code:
unsigned int __fastcall increase_dup_counter(int a1)
{
d_mutex_lock(&counters_lock, "counters");
s_files_completed_dups += a1;
return d_mutex_unlock(&counters_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func17(int a1)
{
func0(&counters_lock, "counters");
s_files_completed_dups += a1;
return func1(&counters_lock);
}

original_code:
void increase_dup_counter(int n)
{
  d_mutex_lock(&counters_lock, "counters");
  s_files_completed_dups += n;
  d_mutex_unlock(&counters_lock);
}


decompiled_code:
unsigned int increase_sets_first_read()
{
d_mutex_lock(&counters_lock, "counters");
++count_sets_first_read;
return d_mutex_unlock(&counters_lock);
}

canonical_decompiled_code:
unsigned int func18()
{
func0(&counters_lock, "counters");
++count_sets_first_read;
return func1(&counters_lock);
}

original_code:
void increase_sets_first_read()
{
  d_mutex_lock(&counters_lock, "counters");
  count_sets_first_read++;
  d_mutex_unlock(&counters_lock);
}


decompiled_code:
unsigned int increase_sets_first_read_completed()
{
d_mutex_lock(&counters_lock, "counters");
++stats_sets_first_read_completed;
return d_mutex_unlock(&counters_lock);
}

canonical_decompiled_code:
unsigned int func19()
{
func0(&counters_lock, "counters");
++stats_sets_first_read_completed;
return func1(&counters_lock);
}

original_code:
void increase_sets_first_read_completed()
{
  d_mutex_lock(&counters_lock, "counters");
  stats_sets_first_read_completed++;
  d_mutex_unlock(&counters_lock);
}


decompiled_code:
unsigned int __fastcall update_open_files(int a1)
{
d_mutex_lock(&counters_lock, "counters");
current_open_files += a1;
return d_mutex_unlock(&counters_lock);
}

canonical_decompiled_code:
unsigned int __fastcall func20(int a1)
{
func0(&counters_lock, "counters");
current_open_files += a1;
return func1(&counters_lock);
}

original_code:
void update_open_files(int n)
{
  d_mutex_lock(&counters_lock, "counters");
  current_open_files += n;
  d_mutex_unlock(&counters_lock);
}


decompiled_code:
void __fastcall show_extents(const char *a1)
{
void *v1; // rbp
__int64 v2; // rax
_QWORD v3[21]; // [rsp+0h] [rbp-A8h] BYREF

if ( (unsigned int)get_file_info(a1, v3) )
{
printf("error: unable to stat %s\n", a1);
}
else
{
v1 = (void *)fiemap_alloc();
v2 = get_block_info_from_path(a1, v3[1], v3[6], v1);
dump_block_list(&unk_A4, v2);
free(v1);
}
}

canonical_decompiled_code:
void __fastcall func0(const char *a1)
{
void *v1; // rbp
__int64 v2; // rax
_QWORD v3[21]; // [rsp+0h] [rbp-A8h] BYREF

if ( (unsigned int)get_file_info(a1, v3) )
{
printf("error: unable to stat %s\n", a1);
}
else
{
v1 = (void *)fiemap_alloc();
v2 = get_block_info_from_path(a1, v3[1], v3[6], v1);
dump_block_list(&unk_A4, v2);
free(v1);
}
}

original_code:
void show_extents(char * path)
{
  struct block_list * bl;
  struct stat finfo;
  if (get_file_info(path, &finfo)) {
    printf("error: unable to stat %s\n", path);
    return;
  }
  void * fmap = fiemap_alloc();
  bl = get_block_info_from_path(path, finfo.st_ino, finfo.st_size, fmap);
  dump_block_list("", bl);
  free(fmap);
}

canonical_original_code:
void show_extents(char *path)
{
  struct block_list *bl;
  struct stat finfo;
  if (get_file_info(path, &finfo)) {
    printf("error: unable to stat %s\n", path);
    return;
  }
  void *fmap = fiemap_alloc();
  bl = get_block_info_from_path(path, finfo.st_ino, finfo.st_size, fmap);
  dump_block_list("", bl);
  free(fmap);
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types:
fmap
void *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

user_defined_types: struct block_list_entry { unsigned long start_pos; unsigned long len; unsigned long block; }


decompiled_code:
void operation_info()
{
if ( info_extents_path )
show_extents(info_extents_path);
}

canonical_decompiled_code:
void func1()
{
if ( info_extents_path )
func0(info_extents_path);
}

original_code:
void operation_info()
{
  if (info_extents_path != ((void *)0)) {
    show_extents(info_extents_path);
  }
}


decompiled_code:
__int64 __fastcall pb_get_filename(__int64 a1)
{
__int64 result; // rax

result = a1 + 80;
if ( !a1 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax

result = a1 + 80;
if ( !a1 )
result = 0LL;
return result;
}

original_code:
static inline char * pb_get_filename(struct path_list_entry * entry)
{
  if (entry == ((void *)0)) { return ((void *)0); }
  return (char *)((char *)entry + sizeof(struct path_list_entry));
}

canonical_original_code:
static inline char *pb_get_filename(struct path_list_entry *entry)
{
  if (entry == ((void *)0)) { return ((void *)0); }
  return (char *)((char *)entry + sizeof(struct path_list_entry));
}

variable_types: struct path_list_entry { struct path_list_entry *next; struct block_list { unsigned char count; struct block_list_entry { unsigned long start_pos; unsigned long len; unsigned long block; } entry[]; } *blocks; struct direntry { struct direntry *parent; char *name; unsigned short total_size; unsigned char name_size; } *dir; char *buffer; void *hash_ctx; unsigned long file_pos; unsigned long next_read_byte; unsigned int next_buffer_pos; unsigned int bufsize; unsigned int data_in_buffer; int fd; unsigned char state; unsigned char filename_size; unsigned char next_read_block; } *

return_type: char *

user_defined_types: struct path_list_entry { struct path_list_entry *next; struct block_list *blocks; struct direntry *dir; char *buffer; void *hash_ctx; unsigned long file_pos; unsigned long next_read_byte; unsigned int next_buffer_pos; unsigned int bufsize; unsigned int data_in_buffer; int fd; unsigned char state; unsigned char filename_size; unsigned char next_read_block; }


decompiled_code:
__int64 __fastcall dirbuf_alloc(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 v3; // rcx
unsigned int v5; // er13
_QWORD *v6; // rbp
void *v7; // rax

v1 = last_dirbuf;
if ( *(_DWORD *)(last_dirbuf + 20) < a1 )
{
v5 = 2 * *(_DWORD *)(last_dirbuf + 16);
v6 = malloc(0x20uLL);
*(_QWORD *)(v1 + 24) = v6;
last_dirbuf = (__int64)v6;
v7 = malloc(v5);
*v6 = v7;
v6[1] = v7;
*((_DWORD *)v6 + 4) = v5;
*((_DWORD *)v6 + 5) = v5;
v6[3] = 0LL;
inc_stats_dirbuf(v5);
}
v2 = last_dirbuf;
v3 = *(_QWORD *)(last_dirbuf + 8);
*(_QWORD *)(last_dirbuf + 8) = v3 + a1;
*(_DWORD *)(v2 + 20) -= a1;
total_dirbufs += a1;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 v3; // rcx
unsigned int v5; // er13
_QWORD *v6; // rbp
void *v7; // rax

v1 = last_dirbuf;
if ( *(_DWORD *)(last_dirbuf + 20) < a1 )
{
v5 = 2 * *(_DWORD *)(last_dirbuf + 16);
v6 = malloc(0x20uLL);
*(_QWORD *)(v1 + 24) = v6;
last_dirbuf = (__int64)v6;
v7 = malloc(v5);
*v6 = v7;
v6[1] = v7;
*((_DWORD *)v6 + 4) = v5;
*((_DWORD *)v6 + 5) = v5;
v6[3] = 0LL;
inc_stats_dirbuf(v5);
}
v2 = last_dirbuf;
v3 = *(_QWORD *)(last_dirbuf + 8);
*(_QWORD *)(last_dirbuf + 8) = v3 + a1;
*(_DWORD *)(v2 + 20) -= a1;
total_dirbufs += a1;
return v3;
}

original_code:
static inline char * dirbuf_alloc(uint32_t size)
{
  if (last_dirbuf->free < size) {
    uint32_t nextsize = last_dirbuf->size * 2;
    struct dirbuf_list * n;
    n = (struct dirbuf_list *)malloc(sizeof(struct dirbuf_list));
    last_dirbuf->next = n;
    last_dirbuf = n;
    last_dirbuf->ptr = (char *)malloc(nextsize);
    last_dirbuf->pos = last_dirbuf->ptr;
    last_dirbuf->size = nextsize;
    last_dirbuf->free = nextsize;
    last_dirbuf->next = ((void *)0);
    inc_stats_dirbuf(nextsize);
  }
  char * p = last_dirbuf->pos;
  last_dirbuf->pos += size;
  last_dirbuf->free -= size;
  total_dirbufs += size;
  return p;
}

canonical_original_code:
static inline char *dirbuf_alloc(unsigned int size)
{
  if (last_dirbuf->free < size) {
    unsigned int nextsize = last_dirbuf->size * 2;
    struct dirbuf_list *n;
    n = (struct dirbuf_list *)malloc(sizeof(struct dirbuf_list));
    last_dirbuf->next = n;
    last_dirbuf = n;
    last_dirbuf->ptr = (char *)malloc(nextsize);
    last_dirbuf->pos = last_dirbuf->ptr;
    last_dirbuf->size = nextsize;
    last_dirbuf->free = nextsize;
    last_dirbuf->next = ((void *)0);
    inc_stats_dirbuf(nextsize);
  }
  char *p = last_dirbuf->pos;
  last_dirbuf->pos += size;
  last_dirbuf->free -= size;
  total_dirbufs += size;
  return p;
}

variable_types:
size
unsigned int

variable_types:
nextsize
unsigned int

variable_types: struct dirbuf_list { char *ptr; char *pos; unsigned int size; unsigned int free; struct dirbuf_list *next; } *

variable_types:
p
char *


decompiled_code:
_DWORD *init_dirtree()
{
unsigned int v0; // ebx
_DWORD *result; // rax

v0 = x_small_buffers == 0 ? 4096 : 128;
first_dirbuf = malloc(0x20uLL);
*(_QWORD *)first_dirbuf = malloc(v0);
inc_stats_dirbuf(v0);
result = first_dirbuf;
last_dirbuf = (__int64)first_dirbuf;
*((_QWORD *)first_dirbuf + 1) = *(_QWORD *)first_dirbuf;
result[4] = v0;
result[5] = v0;
*((_QWORD *)result + 3) = 0LL;
return result;
}

canonical_decompiled_code:
_DWORD *func3()
{
unsigned int v0; // ebx
_DWORD *result; // rax

v0 = x_small_buffers == 0 ? 4096 : 128;
first_dirbuf = malloc(0x20uLL);
*(_QWORD *)first_dirbuf = malloc(v0);
inc_stats_dirbuf(v0);
result = first_dirbuf;
last_dirbuf = (__int64)first_dirbuf;
*((_QWORD *)first_dirbuf + 1) = *(_QWORD *)first_dirbuf;
result[4] = v0;
result[5] = v0;
*((_QWORD *)result + 3) = 0LL;
return result;
}

original_code:
void init_dirtree()
{
  uint32_t init_size = (1024 * 4);
  if (x_small_buffers) { init_size = 128; }
  first_dirbuf = (struct dirbuf_list *)malloc(sizeof(struct dirbuf_list));
  first_dirbuf->ptr = (char *)malloc(init_size);
  inc_stats_dirbuf(init_size);
  last_dirbuf = first_dirbuf;
  last_dirbuf->pos = last_dirbuf->ptr;
  last_dirbuf->size = init_size;
  last_dirbuf->free = init_size;
  last_dirbuf->next = ((void *)0);
}

canonical_original_code:
void init_dirtree()
{
  unsigned int init_size = (1024 * 4);
  if (x_small_buffers) { init_size = 128; }
  first_dirbuf = (struct dirbuf_list *)malloc(sizeof(struct dirbuf_list));
  first_dirbuf->ptr = (char *)malloc(init_size);
  inc_stats_dirbuf(init_size);
  last_dirbuf = first_dirbuf;
  last_dirbuf->pos = last_dirbuf->ptr;
  last_dirbuf->size = init_size;
  last_dirbuf->free = init_size;
  last_dirbuf->next = ((void *)0);
}

user_defined_types: struct dirbuf_list { char *ptr; char *pos; unsigned int size; unsigned int free; struct dirbuf_list *next; }


decompiled_code:
__int64 free_dirtree()
{
void **v0; // rbx
unsigned int v1; // ebp
void **v2; // rdi

v0 = (void **)first_dirbuf;
if ( first_dirbuf )
{
v1 = 0;
do
{
free(*v0);
v1 += *((_DWORD *)v0 + 4);
v2 = v0;
v0 = (void **)v0[3];
free(v2);
}
while ( v0 );
}
else
{
v1 = 0;
}
first_dirbuf = 0LL;
last_dirbuf = 0LL;
return dec_stats_dirbuf(v1);
}

canonical_decompiled_code:
__int64 func4()
{
void **v0; // rbx
unsigned int v1; // ebp
void **v2; // rdi

v0 = (void **)first_dirbuf;
if ( first_dirbuf )
{
v1 = 0;
do
{
free(*v0);
v1 += *((_DWORD *)v0 + 4);
v2 = v0;
v0 = (void **)v0[3];
free(v2);
}
while ( v0 );
}
else
{
v1 = 0;
}
first_dirbuf = 0LL;
last_dirbuf = 0LL;
return dec_stats_dirbuf(v1);
}

original_code:
void free_dirtree()
{
  struct dirbuf_list * p;
  struct dirbuf_list * prev;
  uint64_t total = 0;
  p = first_dirbuf;
  while(p != ((void *)0)) {
    free(p->ptr);
    total += p->size;
    prev = p;
    p = p->next;
    free(prev);
  }
  first_dirbuf = ((void *)0);
  last_dirbuf = ((void *)0);
  dec_stats_dirbuf(total);
}

canonical_original_code:
void free_dirtree()
{
  struct dirbuf_list *p;
  struct dirbuf_list *prev;
  unsigned long total = 0;
  p = first_dirbuf;
  while(p != ((void *)0)) {
    free(p->ptr);
    total += p->size;
    prev = p;
    p = p->next;
    free(prev);
  }
  first_dirbuf = ((void *)0);
  last_dirbuf = ((void *)0);
  dec_stats_dirbuf(total);
}

variable_types:
total
unsigned long


original_code:
struct direntry * new_child_dir(char * name, struct direntry * parent)
{
  struct direntry * entry = (struct direntry *)dirbuf_alloc(direntry_size);
  uint8_t len = (uint8_t)strlen(name);
  if (len == 1 && name[0] == '/') {
    if (parent != ((void *)0)) {
      printf("error: new_child_dir: / has non-null parent\n");
      exit(1);
    }
    len = 0;
    entry->name_size = 0;
    entry->name = ((void *)0);
  } else {
    entry->name_size = len;
    entry->name = dirbuf_alloc(len);
    memcpy(entry->name, name, len);
  }
  entry->parent = parent;
  if (parent == ((void *)0)) {
    entry->total_size = len;
  } else {
    entry->total_size = len + 1 + parent->total_size;
  }
  return entry;
}

canonical_original_code:
struct direntry *new_child_dir(char *name, struct direntry *parent)
{
  struct direntry *entry = (struct direntry *)dirbuf_alloc(direntry_size);
  unsigned char len = (uint8_t)strlen(name);
  if (len == 1 && name[0] == '/') {
    if (parent != ((void *)0)) {
      printf("error: new_child_dir: / has non-null parent\n");
      exit(1);
    }
    len = 0;
    entry->name_size = 0;
    entry->name = ((void *)0);
  } else {
    entry->name_size = len;
    entry->name = dirbuf_alloc(len);
    memcpy(entry->name, name, len);
  }
  entry->parent = parent;
  if (parent == ((void *)0)) {
    entry->total_size = len;
  } else {
    entry->total_size = len + 1 + parent->total_size;
  }
  return entry;
}

variable_types:
name
char *

variable_types:
parent
struct direntry *

variable_types: struct direntry { struct direntry *parent; char *name; unsigned short total_size; unsigned char name_size; } *

variable_types:
len
unsigned char


decompiled_code:
__int64 test_dirtree()
{
__int64 v0; // rax
bool v1; // cf
bool v2; // zf
const char *v3; // rsi
__int64 v4; // rcx
const char *v5; // rdi
const char *v7; // rax
_BYTE v8[1032]; // [rsp+0h] [rbp-408h] BYREF

if ( log_level > 2 )
{
pthread_mutex_lock(&logger_lock);
v7 = (const char *)get_thread_name();
printf("%s", v7);
puts("=== dirtree ===");
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
}
init_path_block();
init_dirtree();
v0 = new_child_dir("/", 0LL);
build_path_from_string("something", v0, v8);
v3 = "/something";
v4 = 11LL;
v5 = v8;
do
{
if ( !v4 )
break;
v1 = *v3 < (unsigned int)*v5;
v2 = *v3++ == *v5++;
--v4;
}
while ( v2 );
if ( (!v1 && !v2) != v1 )
_assert_fail("!strcmp(\"/something\", buffer)", "src/testing.c", 0x2Du, "test_dirtree");
return free_dirtree(v5, v3);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
bool v1; // cf
bool v2; // zf
const char *v3; // rsi
__int64 v4; // rcx
const char *v5; // rdi
const char *v7; // rax
_BYTE v8[1032]; // [rsp+0h] [rbp-408h] BYREF

if ( log_level > 2 )
{
pthread_mutex_lock(&logger_lock);
v7 = (const char *)get_thread_name();
printf("%s", v7);
puts("=== dirtree ===");
fflush(stdout);
pthread_mutex_unlock(&logger_lock);
}
init_path_block();
init_dirtree();
v0 = new_child_dir("/", 0LL);
build_path_from_string("something", v0, v8);
v3 = "/something";
v4 = 11LL;
v5 = v8;
do
{
if ( !v4 )
break;
v1 = *v3 < (unsigned int)*v5;
v2 = *v3++ == *v5++;
--v4;
}
while ( v2 );
if ( (!v1 && !v2) != v1 )
_assert_fail("!strcmp(\"/something\", buffer)", "src/testing.c", 0x2Du, "test_dirtree");
return free_dirtree(v5, v3);
}

original_code:
static void test_dirtree()
{
  char buffer[1024];
  if (3 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("=== dirtree ===\n"); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
  init_path_block();
  init_dirtree();
  struct direntry * root = new_child_dir("/", ((void *)0));
  build_path_from_string("something", root, buffer);
  ((void) sizeof ((!strcmp("/something", buffer)) ? 1 : 0), __extension__ ({ if (!strcmp("/something", buffer)) ; else __assert_fail ("!strcmp(\"/something\", buffer)", "src/testing.c", 45, __extension__ __PRETTY_FUNCTION__); }));
  free_dirtree();
}

canonical_original_code:
static void test_dirtree()
{
  char buffer[1024];
  if (3 <= log_level) { pthread_mutex_lock(&logger_lock); printf("%s", get_thread_name()); printf("=== dirtree ===\n"); fflush(stdout); pthread_mutex_unlock(&logger_lock); };
  init_path_block();
  init_dirtree();
  struct direntry *root = new_child_dir("/", ((void *)0));
  build_path_from_string("something", root, buffer);
  ((void) sizeof ((!strcmp("/something", buffer)) ? 1 : 0), __extension__ ({ if (!strcmp("/something", buffer)) ; else __assert_fail ("!strcmp(\"/something\", buffer)", "src/testing.c", 45, __extension__ __PRETTY_FUNCTION__); }));
  free_dirtree();
}

variable_types:
buffer
char [1024]

user_defined_types: struct direntry { struct direntry *parent; char *name; unsigned short total_size; unsigned char name_size; }


testing

decompiled_code:
__int64 testing()
{
test_hash_table();
return test_dirtree();
}

canonical_decompiled_code:
__int64 func1()
{
test_hash_table();
return func0();
}

original_code:
void testing()
{
  test_hash_table();
  test_dirtree();
}


decompiled_code:
void *init_filecompare()
{
void *result; // rax

ptr = malloc(filecmp_block_size);
result = malloc(filecmp_block_size);
s2 = result;
return result;
}

canonical_decompiled_code:
void *func2()
{
void *result; // rax

ptr = malloc(filecmp_block_size);
result = malloc(filecmp_block_size);
s2 = result;
return result;
}

original_code:
void init_filecompare()
{
  buffers[1] = (char *)malloc(filecmp_block_size);
  buffers[2] = (char *)malloc(filecmp_block_size);
}


decompiled_code:
void free_filecompare()
{
free(ptr);
free(s2);
}

canonical_decompiled_code:
void func3()
{
free(ptr);
free(s2);
}

original_code:
void free_filecompare()
{
  free(buffers[1]);
  free(buffers[2]);
}


repo: jvirkki/libbloom

decompiled_code:
__int64 __fastcall test_bit_set_bit(__int64 a1, unsigned __int64 a2, unsigned int a3)
{
_BYTE *v3; // rdi
int v4; // eax
unsigned int v5; // ecx

v3 = (_BYTE *)((a2 >> 3) + a1);
v4 = 1 << (a2 & 7);
v5 = 1;
if ( ((unsigned __int8)v4 & *v3) == 0 )
{
v5 = a3;
if ( a3 )
{
*v3 |= v4;
v5 = 0;
}
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned __int64 a2, unsigned int a3)
{
_BYTE *v3; // rdi
int v4; // eax
unsigned int v5; // ecx

v3 = (_BYTE *)((a2 >> 3) + a1);
v4 = 1 << (a2 & 7);
v5 = 1;
if ( ((unsigned __int8)v4 & *v3) == 0 )
{
v5 = a3;
if ( a3 )
{
*v3 |= v4;
v5 = 0;
}
}
return v5;
}

original_code:
inline static int test_bit_set_bit(unsigned char * buf,
                                   unsigned long int bit, int set_bit)
{
  unsigned long int byte = bit >> 3;
  unsigned char c = buf[byte];
  unsigned char mask = 1 << (bit % 8ul);
  if (c & mask) {
    return 1;
  } else {
    if (set_bit) {
      buf[byte] = c | mask;
    }
    return 0;
  }
}

canonical_original_code:
inline static int test_bit_set_bit(unsigned char *buf, unsigned long bit, int set_bit)
{
  unsigned long byte = bit >> 3;
  unsigned char c = buf[byte];
  unsigned char mask = 1 << (bit % 8ul);
  if (c & mask) {
    return 1;
  } else {
    if (set_bit) {
      buf[byte] = c | mask;
    }
    return 0;
  }
}

variable_types:
buf
unsigned char *

variable_types:
bit
unsigned long

variable_types:
byte
unsigned long

variable_types:
c
unsigned char

variable_types:
mask
unsigned char


decompiled_code:
__int64 __fastcall bloom_check_add(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4)
{
unsigned __int64 v6; // rbp
unsigned int v7; // eax
unsigned __int8 v8; // dl
__int64 v9; // r14
unsigned __int64 v10; // r12
unsigned __int8 v11; // r15

if ( !*(_BYTE *)(a1 + 40) )
{
printf("bloom at %p not initialized!\n", (const void *)a1);
return 0xFFFFFFFFLL;
}
v6 = (unsigned int)murmurhash2(a2, a3, 2538058380LL);
v7 = murmurhash2(a2, a3, v6);
v8 = *(_BYTE *)(a1 + 24);
if ( v8 )
{
v9 = v7;
v6 = (unsigned int)v6;
v10 = 0LL;
v11 = 0;
while ( 1 )
{
if ( (unsigned int)test_bit_set_bit(*(_QWORD *)(a1 + 56), v6 % *(_QWORD *)(a1 + 8), a4) )
{
++v11;
}
else if ( !a4 )
{
return 0LL;
}
++v10;
v8 = *(_BYTE *)(a1 + 24);
v6 += v9;
if ( v8 <= v10 )
return v8 == v11;
}
}
v11 = 0;
return v8 == v11;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4)
{
unsigned __int64 v6; // rbp
unsigned int v7; // eax
unsigned __int8 v8; // dl
__int64 v9; // r14
unsigned __int64 v10; // r12
unsigned __int8 v11; // r15

if ( !*(_BYTE *)(a1 + 40) )
{
printf("bloom at %p not initialized!\n", (const void *)a1);
return 0xFFFFFFFFLL;
}
v6 = (unsigned int)func19(a2, a3, 2538058380LL);
v7 = func19(a2, a3, v6);
v8 = *(_BYTE *)(a1 + 24);
if ( v8 )
{
v9 = v7;
v6 = (unsigned int)v6;
v10 = 0LL;
v11 = 0;
while ( 1 )
{
if ( (unsigned int)func6(*(_QWORD *)(a1 + 56), v6 % *(_QWORD *)(a1 + 8), a4) )
{
++v11;
}
else if ( !a4 )
{
return 0LL;
}
++v10;
v8 = *(_BYTE *)(a1 + 24);
v6 += v9;
if ( v8 <= v10 )
return v8 == v11;
}
}
v11 = 0;
return v8 == v11;
}

original_code:
static int bloom_check_add(struct bloom * bloom,
                           const void * buffer, int len, int add)
{
  if (bloom->ready == 0) {
    printf("bloom at %p not initialized!\n", (void *)bloom);
    return -1;
  }
  unsigned char hits = 0;
  unsigned int a = murmurhash2(buffer, len, 0x9747b28c);
  unsigned int b = murmurhash2(buffer, len, a);
  unsigned long int x;
  unsigned long int i;
  for (i = 0; i < bloom->hashes; i++) {
    x = (a + b*i) % bloom->bits;
    if (test_bit_set_bit(bloom->bf, x, add)) {
      hits++;
    } else if (!add) {
      return 0;
    }
  }
  if (hits == bloom->hashes) {
    return 1;
  }
  return 0;
}

canonical_original_code:
static int bloom_check_add(struct bloom *bloom, void *buffer, int len, int add)
{
  if (bloom->ready == 0) {
    printf("bloom at %p not initialized!\n", (void *)bloom);
    return -1;
  }
  unsigned char hits = 0;
  unsigned int a = murmurhash2(buffer, len, 0x9747b28c);
  unsigned int b = murmurhash2(buffer, len, a);
  unsigned long x;
  unsigned long i;
  for (i = 0; i < bloom->hashes; i++) {
    x = (a + b*i) % bloom->bits;
    if (test_bit_set_bit(bloom->bf, x, add)) {
      hits++;
    } else if (!add) {
      return 0;
    }
  }
  if (hits == bloom->hashes) {
    return 1;
  }
  return 0;
}

variable_types: struct bloom { unsigned int entries; unsigned long bits; unsigned long bytes; unsigned char hashes; double error; unsigned char ready; unsigned char major; unsigned char minor; double bpe; unsigned char *bf; } *

variable_types:
buffer
void *

variable_types: len int

variable_types: add int

variable_types:
hits
unsigned char

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
x
unsigned long

variable_types:
i
unsigned long


original_code:
int bloom_init2(struct bloom * bloom, unsigned int entries, double error)
{
  if (sizeof(unsigned long int) < 8) {
    printf("error: libbloom will not function correctly because\n");
    printf("sizeof(unsigned long int) == %ld\n", sizeof(unsigned long int));
    exit(1);
  }
  memset(bloom, 0, sizeof(struct bloom));
  if (entries < 1000 || error <= 0 || error >= 1) {
    return 1;
  }
  bloom->entries = entries;
  bloom->error = error;
  double num = -log(bloom->error);
  double denom = 0.480453013918201;
  bloom->bpe = (num / denom);
  long double dentries = (long double)entries;
  long double allbits = dentries * bloom->bpe;
  bloom->bits = (unsigned long int)allbits;
  if (bloom->bits % 8) {
    bloom->bytes = (bloom->bits / 8) + 1;
  } else {
    bloom->bytes = bloom->bits / 8;
  }
  bloom->hashes = (unsigned char)ceil(0.693147180559945 * bloom->bpe);
  bloom->bf = (unsigned char *)calloc(bloom->bytes, sizeof(unsigned char));
  if (bloom->bf == ((void *)0)) {
    return 1;
  }
  bloom->ready = 1;
  bloom->major = 2;
  bloom->minor = 0;
  return 0;
}

canonical_original_code:
int bloom_init2(struct bloom *bloom, unsigned int entries, double error)
{
  if (sizeof(unsigned long) < 8) {
    printf("error: libbloom will not function correctly because\n");
    printf("sizeof(unsigned long int) == %ld\n", sizeof(unsigned long));
    exit(1);
  }
  memset(bloom, 0, sizeof(struct bloom));
  if (entries < 1000 || error <= 0 || error >= 1) {
    return 1;
  }
  bloom->entries = entries;
  bloom->error = error;
  double num = -log(bloom->error);
  double denom = 0.480453013918201;
  bloom->bpe = (num / denom);
  long double dentries = (long double)entries;
  long double allbits = dentries * bloom->bpe;
  bloom->bits = (unsigned long)allbits;
  if (bloom->bits % 8) {
    bloom->bytes = (bloom->bits / 8) + 1;
  } else {
    bloom->bytes = bloom->bits / 8;
  }
  bloom->hashes = (unsigned char)ceil(0.693147180559945 * bloom->bpe);
  bloom->bf = (unsigned char *)calloc(bloom->bytes, sizeof(unsigned char));
  if (bloom->bf == ((void *)0)) {
    return 1;
  }
  bloom->ready = 1;
  bloom->major = 2;
  bloom->minor = 0;
  return 0;
}

variable_types:
entries
unsigned int

variable_types: error double

variable_types: num double

variable_types: denom double

variable_types:
dentries
long double

variable_types:
allbits
long double

user_defined_types: struct bloom { unsigned int entries; unsigned long bits; unsigned long bytes; unsigned char hashes; double error; unsigned char ready; unsigned char major; unsigned char minor; double bpe; unsigned char *bf; }


decompiled_code:
__int64 bloom_init()
{
return bloom_init2();
}

canonical_decompiled_code:
__int64 func9()
{
return func8();
}

original_code:
int bloom_init(struct bloom * bloom, int entries, double error)
{
  return bloom_init2(bloom, (unsigned int)entries, error);
}

canonical_original_code:
int bloom_init(struct bloom *bloom, int entries, double error)
{
  return bloom_init2(bloom, (unsigned int)entries, error);
}

variable_types: entries int


decompiled_code:
__int64 __fastcall bloom_check(__int64 a1, __int64 a2, unsigned int a3)
{
return bloom_check_add(a1, a2, a3, 0);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, unsigned int a3)
{
return func7(a1, a2, a3, 0);
}

original_code:
int bloom_check(struct bloom * bloom, const void * buffer, int len)
{
  return bloom_check_add(bloom, buffer, len, 0);
}

canonical_original_code:
int bloom_check(struct bloom *bloom, void *buffer, int len)
{
  return bloom_check_add(bloom, buffer, len, 0);
}


decompiled_code:
__int64 __fastcall bloom_add(__int64 a1, __int64 a2, unsigned int a3)
{
return bloom_check_add(a1, a2, a3, 1u);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, unsigned int a3)
{
return func7(a1, a2, a3, 1u);
}

original_code:
int bloom_add(struct bloom * bloom, const void * buffer, int len)
{
  return bloom_check_add(bloom, buffer, len, 1);
}

canonical_original_code:
int bloom_add(struct bloom *bloom, void *buffer, int len)
{
  return bloom_check_add(bloom, buffer, len, 1);
}


decompiled_code:
int __fastcall bloom_print(unsigned int *a1)
{
printf("bloom at %p\n", a1);
if ( !*((_BYTE *)a1 + 40) )
puts(" *** NOT READY ***");
printf(" ->version = %d.%d\n", *((unsigned __int8 *)a1 + 41), *((unsigned __int8 *)a1 + 42));
printf(" ->entries = %u\n", *a1);
printf(" ->error = %f\n", *((double *)a1 + 4));
printf(" ->bits = %lu\n", *((_QWORD *)a1 + 1));
printf(" ->bits per elem = %f\n", *((double *)a1 + 6));
printf(" ->bytes = %lu", *((_QWORD *)a1 + 2));
printf(" (%u KB, %u MB)\n", *((_QWORD *)a1 + 2) >> 10, (unsigned int)(*((_QWORD *)a1 + 2) >> 10) >> 10);
return printf(" ->hash functions = %d\n", *((unsigned __int8 *)a1 + 24));
}

canonical_decompiled_code:
int __fastcall func12(unsigned int *a1)
{
printf("bloom at %p\n", a1);
if ( !*((_BYTE *)a1 + 40) )
puts(" *** NOT READY ***");
printf(" ->version = %d.%d\n", *((unsigned __int8 *)a1 + 41), *((unsigned __int8 *)a1 + 42));
printf(" ->entries = %u\n", *a1);
printf(" ->error = %f\n", *((double *)a1 + 4));
printf(" ->bits = %lu\n", *((_QWORD *)a1 + 1));
printf(" ->bits per elem = %f\n", *((double *)a1 + 6));
printf(" ->bytes = %lu", *((_QWORD *)a1 + 2));
printf(" (%u KB, %u MB)\n", *((_QWORD *)a1 + 2) >> 10, (unsigned int)(*((_QWORD *)a1 + 2) >> 10) >> 10);
return printf(" ->hash functions = %d\n", *((unsigned __int8 *)a1 + 24));
}

original_code:
void bloom_print(struct bloom * bloom)
{
  printf("bloom at %p\n", (void *)bloom);
  if (!bloom->ready) { printf(" *** NOT READY ***\n"); }
  printf(" ->version = %d.%d\n", bloom->major, bloom->minor);
  printf(" ->entries = %u\n", bloom->entries);
  printf(" ->error = %f\n", bloom->error);
  printf(" ->bits = %lu\n", bloom->bits);
  printf(" ->bits per elem = %f\n", bloom->bpe);
  printf(" ->bytes = %lu", bloom->bytes);
  unsigned int KB = bloom->bytes / 1024;
  unsigned int MB = KB / 1024;
  printf(" (%u KB, %u MB)\n", KB, MB);
  printf(" ->hash functions = %d\n", bloom->hashes);
}

canonical_original_code:
void bloom_print(struct bloom *bloom)
{
  printf("bloom at %p\n", (void *)bloom);
  if (!bloom->ready) { printf(" *** NOT READY ***\n"); }
  printf(" ->version = %d.%d\n", bloom->major, bloom->minor);
  printf(" ->entries = %u\n", bloom->entries);
  printf(" ->error = %f\n", bloom->error);
  printf(" ->bits = %lu\n", bloom->bits);
  printf(" ->bits per elem = %f\n", bloom->bpe);
  printf(" ->bytes = %lu", bloom->bytes);
  unsigned int KB = bloom->bytes / 1024;
  unsigned int MB = KB / 1024;
  printf(" (%u KB, %u MB)\n", KB, MB);
  printf(" ->hash functions = %d\n", bloom->hashes);
}

variable_types:
KB
unsigned int

variable_types:
MB
unsigned int


original_code:
void bloom_free(struct bloom * bloom)
{
  if (bloom->ready) {
    free(bloom->bf);
  }
  bloom->ready = 0;
}

canonical_original_code:
void bloom_free(struct bloom *bloom)
{
  if (bloom->ready) {
    free(bloom->bf);
  }
  bloom->ready = 0;
}

variable_types: struct bloom { unsigned int entries; unsigned long bits; unsigned long bytes; unsigned char hashes; double error; unsigned char ready; unsigned char major; unsigned char minor; double bpe; unsigned char *bf; } *


decompiled_code:
__int64 __fastcall bloom_reset(__int64 a1)
{
__int64 result; // rax

result = 1LL;
if ( *(_BYTE *)(a1 + 40) )
{
memset(*(void **)(a1 + 56), 0, *(_QWORD *)(a1 + 16));
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
__int64 result; // rax

result = 1LL;
if ( *(_BYTE *)(a1 + 40) )
{
memset(*(void **)(a1 + 56), 0, *(_QWORD *)(a1 + 16));
result = 0LL;
}
return result;
}

original_code:
int bloom_reset(struct bloom * bloom)
{
  if (!bloom->ready) return 1;
  memset(bloom->bf, 0, bloom->bytes);
  return 0;
}

canonical_original_code:
int bloom_reset(struct bloom *bloom)
{
  if (!bloom->ready) return 1;
  memset(bloom->bf, 0, bloom->bytes);
  return 0;
}


decompiled_code:
__int64 __fastcall bloom_save(void *buf, char *file)
{
__int64 result; // rax
int v3; // ebx
__int16 bufa[13]; // [rsp+0h] [rbp-1Ah] BYREF

if ( !file )
return 1LL;
result = 1LL;
if ( *file )
{
v3 = open(file, 65, 420LL);
result = 1LL;
if ( v3 >= 0 )
{
if ( write(v3, "libbloom2", 9uLL) == 9
&& (bufa[0] = 64, write(v3, bufa, 2uLL) == 2)
&& write(v3, buf, 0x40uLL) == 64
&& *((_QWORD *)buf + 2) == write(v3, *((const void **)buf + 7), *((_QWORD *)buf + 2)) )
{
close(v3);
result = 0LL;
}
else
{
close(v3);
result = 1LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(void *buf, char *file)
{
__int64 result; // rax
int v3; // ebx
__int16 bufa[13]; // [rsp+0h] [rbp-1Ah] BYREF

if ( !file )
return 1LL;
result = 1LL;
if ( *file )
{
v3 = open(file, 65, 420LL);
result = 1LL;
if ( v3 >= 0 )
{
if ( write(v3, "libbloom2", 9uLL) == 9
&& (bufa[0] = 64, write(v3, bufa, 2uLL) == 2)
&& write(v3, buf, 0x40uLL) == 64
&& *((_QWORD *)buf + 2) == write(v3, *((const void **)buf + 7), *((_QWORD *)buf + 2)) )
{
close(v3);
result = 0LL;
}
else
{
close(v3);
result = 1LL;
}
}
}
return result;
}

original_code:
int bloom_save(struct bloom * bloom, char * filename)
{
  if (filename == ((void *)0) || filename[0] == 0) {
    return 1;
  }
  int fd = open(filename, 01 | 0100, 0644);
  if (fd < 0) {
    return 1;
  }
  ssize_t out = write(fd, "libbloom2", strlen("libbloom2"));
  if (out != strlen("libbloom2")) { goto save_error; }
  uint16_t size = sizeof(struct bloom);
  out = write(fd, &size, sizeof(uint16_t));
  if (out != sizeof(uint16_t)) { goto save_error; }
  out = write(fd, bloom, sizeof(struct bloom));
  if (out != sizeof(struct bloom)) { goto save_error; }
  out = write(fd, bloom->bf, bloom->bytes);
  if (out != bloom->bytes) { goto save_error; }
  close(fd);
  return 0;
 save_error:
  close(fd);
  return 1;
}

canonical_original_code:
int bloom_save(struct bloom *bloom, char *filename)
{
  if (filename == ((void *)0) || filename[0] == 0) {
    return 1;
  }
  int fd = open(filename, 01 | 0100, 0644);
  if (fd < 0) {
    return 1;
  }
  long out = write(fd, "libbloom2", strlen("libbloom2"));
  if (out != strlen("libbloom2")) { goto save_error; }
  unsigned short size = sizeof(struct bloom);
  out = write(fd, &size, sizeof(unsigned short));
  if (out != sizeof(unsigned short)) { goto save_error; }
  out = write(fd, bloom, sizeof(struct bloom));
  if (out != sizeof(struct bloom)) { goto save_error; }
  out = write(fd, bloom->bf, bloom->bytes);
  if (out != bloom->bytes) { goto save_error; }
  close(fd);
  return 0;
 save_error:
  close(fd);
  return 1;
}

variable_types:
filename
char *

variable_types: fd int

variable_types: out long

variable_types:
size
unsigned short


decompiled_code:
__int64 __fastcall bloom_load(void *buf, char *file)
{
unsigned int v3; // ebp
int v4; // eax
int v5; // er12
bool v6; // zf
size_t v7; // r13
void *v8; // rsi
__int16 v10; // [rsp+Eh] [rbp-4Ah] BYREF
__int64 bufa[3]; // [rsp+10h] [rbp-48h] BYREF
int v12; // [rsp+28h] [rbp-30h]
__int16 v13; // [rsp+2Ch] [rbp-2Ch]

if ( !file )
return 1;
v3 = 1;
if ( *file )
{
if ( !buf )
return 2;
*(_QWORD *)buf = 0LL;
*((_QWORD *)buf + 1) = 0LL;
*((_QWORD *)buf + 2) = 0LL;
*((_QWORD *)buf + 3) = 0LL;
*((_QWORD *)buf + 4) = 0LL;
*((_QWORD *)buf + 5) = 0LL;
*((_QWORD *)buf + 6) = 0LL;
*((_QWORD *)buf + 7) = 0LL;
v4 = open(file, 0);
v5 = v4;
v3 = 3;
if ( v4 >= 0 )
{
bufa[0] = 0LL;
bufa[1] = 0LL;
bufa[2] = 0LL;
v12 = 0;
v13 = 0;
if ( read(v4, bufa, 9uLL) != 9 )
{
v3 = 4;
goto LABEL_19;
}
v6 = memcmp(bufa, "libbloom2", 9uLL) == 0;
v3 = !v6;
if ( !v6 )
{
v3 = 5;
LABEL_19:
close(v5);
*((_BYTE *)buf + 40) = 0;
return v3;
}
if ( read(v5, &v10, 2uLL) != 2 )
{
v3 = 6;
goto LABEL_19;
}
if ( v10 != 64 )
{
v3 = 7;
goto LABEL_19;
}
if ( read(v5, buf, 0x40uLL) != 64 )
{
v3 = 8;
goto LABEL_19;
}
*((_QWORD *)buf + 7) = 0LL;
if ( *((_BYTE *)buf + 41) != 2 )
{
v3 = 9;
goto LABEL_19;
}
v7 = *((_QWORD *)buf + 2);
v8 = malloc(v7);
*((_QWORD *)buf + 7) = v8;
if ( !v8 )
{
v3 = 10;
goto LABEL_19;
}
if ( *((_QWORD *)buf + 2) != read(v5, v8, v7) )
{
free(*((void **)buf + 7));
*((_QWORD *)buf + 7) = 0LL;
v3 = 11;
goto LABEL_19;
}
close(v5);
}
}
return v3;
}

original_code:
int bloom_load(struct bloom * bloom, char * filename)
{
  int rv = 0;
  if (filename == ((void *)0) || filename[0] == 0) { return 1; }
  if (bloom == ((void *)0)) { return 2; }
  memset(bloom, 0, sizeof(struct bloom));
  int fd = open(filename, 00);
  if (fd < 0) { return 3; }
  char line[30];
  memset(line, 0, 30);
  ssize_t in = read(fd, line, strlen("libbloom2"));
  if (in != strlen("libbloom2")) {
    rv = 4;
    goto load_error;
  }
  if (strncmp(line, "libbloom2", strlen("libbloom2"))) {
    rv = 5;
    goto load_error;
  }
  uint16_t size;
  in = read(fd, &size, sizeof(uint16_t));
  if (in != sizeof(uint16_t)) {
    rv = 6;
    goto load_error;
  }
  if (size != sizeof(struct bloom)) {
    rv = 7;
    goto load_error;
  }
  in = read(fd, bloom, sizeof(struct bloom));
  if (in != sizeof(struct bloom)) {
    rv = 8;
    goto load_error;
  }
  bloom->bf = ((void *)0);
  if (bloom->major != 2) {
    rv = 9;
    goto load_error;
  }
  bloom->bf = (unsigned char *)malloc(bloom->bytes);
  if (bloom->bf == ((void *)0)) { rv = 10; goto load_error; }
  in = read(fd, bloom->bf, bloom->bytes);
  if (in != bloom->bytes) {
    rv = 11;
    free(bloom->bf);
    bloom->bf = ((void *)0);
    goto load_error;
  }
  close(fd);
  return rv;
 load_error:
  close(fd);
  bloom->ready = 0;
  return rv;
}

canonical_original_code:
int bloom_load(struct bloom *bloom, char *filename)
{
  int rv = 0;
  if (filename == ((void *)0) || filename[0] == 0) { return 1; }
  if (bloom == ((void *)0)) { return 2; }
  memset(bloom, 0, sizeof(struct bloom));
  int fd = open(filename, 00);
  if (fd < 0) { return 3; }
  char line[30];
  memset(line, 0, 30);
  long in = read(fd, line, strlen("libbloom2"));
  if (in != strlen("libbloom2")) {
    rv = 4;
    goto load_error;
  }
  if (strncmp(line, "libbloom2", strlen("libbloom2"))) {
    rv = 5;
    goto load_error;
  }
  unsigned short size;
  in = read(fd, &size, sizeof(unsigned short));
  if (in != sizeof(unsigned short)) {
    rv = 6;
    goto load_error;
  }
  if (size != sizeof(struct bloom)) {
    rv = 7;
    goto load_error;
  }
  in = read(fd, bloom, sizeof(struct bloom));
  if (in != sizeof(struct bloom)) {
    rv = 8;
    goto load_error;
  }
  bloom->bf = ((void *)0);
  if (bloom->major != 2) {
    rv = 9;
    goto load_error;
  }
  bloom->bf = (unsigned char *)malloc(bloom->bytes);
  if (bloom->bf == ((void *)0)) { rv = 10; goto load_error; }
  in = read(fd, bloom->bf, bloom->bytes);
  if (in != bloom->bytes) {
    rv = 11;
    free(bloom->bf);
    bloom->bf = ((void *)0);
    goto load_error;
  }
  close(fd);
  return rv;
 load_error:
  close(fd);
  bloom->ready = 0;
  return rv;
}

variable_types: rv int

variable_types:
line
char [30]

variable_types: in long


decompiled_code:
__int64 __fastcall bloom_merge(_BYTE *a1, _BYTE *a2)
{
__int64 result; // rax
__int64 v3; // rdx
unsigned __int64 v4; // rax

if ( a1[40] )
{
if ( a2[40] )
{
result = 1LL;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( *((double *)a1 + 4) == *((double *)a2 + 4) )
{
if ( a1[41] == a2[41] && a1[42] == a2[42] )
{
v3 = *((_QWORD *)a1 + 2);
if ( v3 == *((_QWORD *)a2 + 2) )
{
if ( v3 )
{
v4 = 0LL;
do
{
*(_BYTE *)(*((_QWORD *)a1 + 7) + v4) |= *(_BYTE *)(*((_QWORD *)a2 + 7) + v4);
++v4;
}
while ( *((_QWORD *)a1 + 2) > v4 );
result = 0LL;
}
else
{
result = 0LL;
}
}
}
}
else
{
result = 1LL;
}
}
}
else
{
printf("bloom at %p not initialized!\n", a2);
result = 0xFFFFFFFFLL;
}
}
else
{
printf("bloom at %p not initialized!\n", a1);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(_BYTE *a1, _BYTE *a2)
{
__int64 result; // rax
__int64 v3; // rdx
unsigned __int64 v4; // rax

if ( a1[40] )
{
if ( a2[40] )
{
result = 1LL;
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
{
if ( *((double *)a1 + 4) == *((double *)a2 + 4) )
{
if ( a1[41] == a2[41] && a1[42] == a2[42] )
{
v3 = *((_QWORD *)a1 + 2);
if ( v3 == *((_QWORD *)a2 + 2) )
{
if ( v3 )
{
v4 = 0LL;
do
{
*(_BYTE *)(*((_QWORD *)a1 + 7) + v4) |= *(_BYTE *)(*((_QWORD *)a2 + 7) + v4);
++v4;
}
while ( *((_QWORD *)a1 + 2) > v4 );
result = 0LL;
}
else
{
result = 0LL;
}
}
}
}
else
{
result = 1LL;
}
}
}
else
{
printf("bloom at %p not initialized!\n", a2);
result = 0xFFFFFFFFLL;
}
}
else
{
printf("bloom at %p not initialized!\n", a1);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int bloom_merge(struct bloom * bloom_dest, struct bloom * bloom_src)
{
  if (bloom_dest->ready == 0) {
    printf("bloom at %p not initialized!\n", (void *)bloom_dest);
    return -1;
  }
  if (bloom_src->ready == 0) {
    printf("bloom at %p not initialized!\n", (void *)bloom_src);
    return -1;
  }
  if (bloom_dest->entries != bloom_src->entries) {
    return 1;
  }
  if (bloom_dest->error != bloom_src->error) {
    return 1;
  }
  if (bloom_dest->major != bloom_src->major) {
    return 1;
  }
  if (bloom_dest->minor != bloom_src->minor) {
    return 1;
  }
  if (bloom_dest->bytes != bloom_src->bytes) {
    return 1;
  }
  unsigned long int p;
  for (p = 0; p < bloom_dest->bytes; p++) {
    bloom_dest->bf[p] |= bloom_src->bf[p];
  }
  return 0;
}

canonical_original_code:
int bloom_merge(struct bloom *bloom_dest, struct bloom *bloom_src)
{
  if (bloom_dest->ready == 0) {
    printf("bloom at %p not initialized!\n", (void *)bloom_dest);
    return -1;
  }
  if (bloom_src->ready == 0) {
    printf("bloom at %p not initialized!\n", (void *)bloom_src);
    return -1;
  }
  if (bloom_dest->entries != bloom_src->entries) {
    return 1;
  }
  if (bloom_dest->error != bloom_src->error) {
    return 1;
  }
  if (bloom_dest->major != bloom_src->major) {
    return 1;
  }
  if (bloom_dest->minor != bloom_src->minor) {
    return 1;
  }
  if (bloom_dest->bytes != bloom_src->bytes) {
    return 1;
  }
  unsigned long p;
  for (p = 0; p < bloom_dest->bytes; p++) {
    bloom_dest->bf[p] |= bloom_src->bf[p];
  }
  return 0;
}

variable_types:
p
unsigned long


decompiled_code:
const char *bloom_version()
{
return "2.0";
}

canonical_decompiled_code:
const char *func18()
{
return "2.0";
}

original_code:
const char * bloom_version()
{
  return "2.0";
}

canonical_original_code:
char *bloom_version()
{
  return "2.0";
}


printtimedif

repo: jvonmitchell/AptProfile

decompiled_code:
int printtimedif()
{
__int64 v0; // rdx
__suseconds_t v1; // rsi

v0 = tim_temp.tv_sec - tim;
v1 = tim_temp.tv_usec - *((_QWORD *)&tim + 1);
if ( tim_temp.tv_usec < *((__int64 *)&tim + 1) )
{
--v0;
v1 += 1000000LL;
}
return fprintf(_bss_start, "%ds:%du\n", v0, v1);
}

canonical_decompiled_code:
int func7()
{
__int64 v0; // rdx
__suseconds_t v1; // rsi

v0 = tim_temp.tv_sec - tim;
v1 = tim_temp.tv_usec - *((_QWORD *)&tim + 1);
if ( tim_temp.tv_usec < *((__int64 *)&tim + 1) )
{
--v0;
v1 += 1000000LL;
}
return fprintf(_bss_start, "%ds:%du\n", v0, v1);
}

original_code:
void printtimedif() {
 suseconds_t usecdif;
 time_t secdif=tim_temp.tv_sec-tim.tv_sec;
 if(tim_temp.tv_usec<tim.tv_usec) {
  --secdif;
  usecdif=tim.tv_usec-tim_temp.tv_usec;
  usecdif=1000000-usecdif;
 }
 else {
  usecdif=tim_temp.tv_usec-tim.tv_usec;
 }
 fprintf(stdout,"%ds:%du\n",secdif,usecdif);
}

canonical_original_code:
void printtimedif() {
 long usecdif;
 long secdif = tim_temp.tv_sec-tim.tv_sec;
 if(tim_temp.tv_usec<tim.tv_usec) {
  --secdif;
  usecdif=tim.tv_usec-tim_temp.tv_usec;
  usecdif=1000000-usecdif;
 }
 else {
  usecdif=tim_temp.tv_usec-tim.tv_usec;
 }
 fprintf(stdout,"%ds:%du\n",secdif,usecdif);
}

variable_types: usecdif long

variable_types: secdif long


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
size_t v4; // rax

v3 = 0;
while ( !feof(stdin) && fgets(buff, 1024, stdin) )
{
gettimeofday(&tim_temp, 0LL);
if ( v3 )
printtimedif();
tim = (__int128)_mm_load_si128((const __m128i *)&tim_temp);
v4 = strlen(buff);
fwrite(buff, 1uLL, v4 - 1, _bss_start);
fputc(9, _bss_start);
v3 = 1;
}
printtimedif();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
size_t v4; // rax

v3 = 0;
while ( !feof(stdin) && fgets(buff, 1024, stdin) )
{
gettimeofday(&tim_temp, 0LL);
if ( v3 )
func7();
tim = (__int128)_mm_load_si128((const __m128i *)&tim_temp);
v4 = strlen(buff);
fwrite(buff, 1uLL, v4 - 1, _bss_start);
fputc(9, _bss_start);
v3 = 1;
}
func7();
return 0;
}

original_code:
int main(int argc,char **argv) {
 int should_out=0;
 while(!feof(stdin) && fgets(buff,sizeof(buff),stdin)) {
  gettimeofday(&tim_temp,((void *)0));
  if(should_out) {
   printtimedif();
  }
  should_out=1;
  tim=tim_temp;
  fwrite(buff,1,strlen(buff)-1,stdout);
  fputc('\t',stdout);
 }
 printtimedif();
}

canonical_original_code:
int main(int argc, char **argv) {
 int should_out = 0;
 while(!feof(stdin) && fgets(buff,sizeof(buff),stdin)) {
  gettimeofday(&tim_temp,((void *)0));
  if(should_out) {
   printtimedif();
  }
  should_out=1;
  tim=tim_temp;
  fwrite(buff,1,strlen(buff)-1,stdout);
  fputc('\t',stdout);
 }
 printtimedif();
}

variable_types: argc int

variable_types:
argv
char **


spawn

decompiled_code:
__pid_t __fastcall spawn(__int64 a1)
{
__pid_t result; // eax
int v2; // eax

result = fork();
if ( !result )
{
v2 = xcb_get_file_descriptor(dpy);
close(v2);
if ( *(_BYTE *)(a1 + 52) )
putenv((char *)(a1 + 52));
if ( termprog )
{
execl(shell, shell, &unk_A00, termprog, 0LL);
fprintf(stderr, "9wm: exec %s", shell);
perror(" failed");
}
execlp("9term", "9term", "-9wm", 0LL);
execlp("xterm", "xterm", "-ut", 0LL);
perror("9wm: exec 9term/xterm failed");
exit(0);
}
return result;
}

canonical_decompiled_code:
__pid_t __fastcall func0(__int64 a1)
{
__pid_t result; // eax
int v2; // eax

result = fork();
if ( !result )
{
v2 = xcb_get_file_descriptor(dpy);
close(v2);
if ( *(_BYTE *)(a1 + 52) )
putenv((char *)(a1 + 52));
if ( termprog )
{
execl(shell, shell, &unk_A00, termprog, 0LL);
fprintf(stderr, "9wm: exec %s", shell);
perror(" failed");
}
execlp("9term", "9term", "-9wm", 0LL);
execlp("xterm", "xterm", "-ut", 0LL);
perror("9wm: exec 9term/xterm failed");
exit(0);
}
return result;
}

original_code:
void spawn(ScreenInfo *s)
{
    ;
    if (fork() == 0) {
        close(xcb_get_file_descriptor(dpy));
        if (s->display[0] != '\0')
            putenv(s->display);
        if (termprog != ((void *)0)) {
            execl(shell, shell, "-c", termprog, 0);
            fprintf(stderr, "9wm: exec %s", shell);
            perror(" failed");
        }
        execlp("9term", "9term", "-9wm", 0);
        execlp("xterm", "xterm", "-ut", 0);
        perror("9wm: exec 9term/xterm failed");
        exit(0);
    }
}

canonical_original_code:
void spawn(struct ScreenInfo *s)
{
    ;
    if (fork() == 0) {
        close(xcb_get_file_descriptor(dpy));
        if (s->display[0] != '\0')
            putenv(s->display);
        if (termprog != ((void *)0)) {
            execl(shell, shell, "-c", termprog, 0);
            fprintf(stderr, "9wm: exec %s", shell);
            perror(" failed");
        }
        execlp("9term", "9term", "-9wm", 0);
        execlp("xterm", "xterm", "-ut", 0);
        perror("9wm: exec 9term/xterm failed");
        exit(0);
    }
}

variable_types: struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; } *


reshape

decompiled_code:
void __fastcall reshape(unsigned int *a1)
{
unsigned int v1; // ebp
unsigned int v2; // er12

if ( a1 )
{
v1 = a1[10];
v2 = a1[11];
if ( (unsigned int)sweep() )
{
active(a1);
top(a1);
xraisewindow(dpy, a1[1]);
xmoveresizewindow(
dpy,
a1[1],
a1[8] - (unsigned int)border,
a1[9] - (unsigned int)border,
a1[10] + 2 * (_DWORD)border - 2,
a1[11] + 2 * (_DWORD)border - 2);
if ( *((_QWORD *)a1 + 5) == __PAIR64__(v2, v1) )
sendconfig(a1);
else
xmoveresizewindow(
dpy,
*a1,
(unsigned int)((_DWORD)border - 1),
(unsigned int)((_DWORD)border - 1),
a1[10],
a1[11]);
}
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned int *a1)
{
unsigned int v1; // ebp
unsigned int v2; // er12

if ( a1 )
{
v1 = a1[10];
v2 = a1[11];
if ( (unsigned int)sweep() )
{
active(a1);
top(a1);
xraisewindow(dpy, a1[1]);
xmoveresizewindow(
dpy,
a1[1],
a1[8] - (unsigned int)border,
a1[9] - (unsigned int)border,
a1[10] + 2 * (_DWORD)border - 2,
a1[11] + 2 * (_DWORD)border - 2);
if ( *((_QWORD *)a1 + 5) == __PAIR64__(v2, v1) )
sendconfig(a1);
else
xmoveresizewindow(
dpy,
*a1,
(unsigned int)((_DWORD)border - 1),
(unsigned int)((_DWORD)border - 1),
a1[10],
a1[11]);
}
}
}

original_code:
void reshape(Client *c)
{
    int odx, ody;
    uint32_t values[2];
    if (c == 0)
        return;
    odx = c->dx;
    ody = c->dy;
    if (sweep(c) == 0)
        return;
    active(c);
    top(c);
    xraisewindow(dpy, c->parent);
    xmoveresizewindow(dpy, c->parent, c->x-_border, c->y-_border,
                    c->dx+2*(_border-1), c->dy+2*(_border-1));
    if (c->dx == odx && c->dy == ody)
        sendconfig(c);
    else
        xmoveresizewindow(dpy, c->window, _border-1, _border-1, c->dx, c->dy);
}

canonical_original_code:
void reshape(struct Client *c)
{
    int odx; int ody;
    unsigned int values[2];
    if (c == 0)
        return;
    odx = c->dx;
    ody = c->dy;
    if (sweep(c) == 0)
        return;
    active(c);
    top(c);
    xraisewindow(dpy, c->parent);
    xmoveresizewindow(dpy, c->parent, c->x-_border, c->y-_border,
                    c->dx+2*(_border-1), c->dy+2*(_border-1));
    if (c->dx == odx && c->dy == ody)
        sendconfig(c);
    else
        xmoveresizewindow(dpy, c->window, _border-1, _border-1, c->dx, c->dy);
}

variable_types: struct Client { unsigned int window; unsigned int parent; unsigned int trans; struct Client *next; struct Client *revert; int x; int y; int dx; int dy; int border; struct xcb_size_hints_t { unsigned int flags; int x; int width; int min_width; int max_width; int width_inc; int min_aspect_num; int max_aspect_num; int base_width; unsigned int win_gravity; } size; int min_dx; int min_dy; int state; int init; int reparenting; int is9term; int hold; int proto; char *label; char *instance; char *class; char *name; char *iconname; unsigned int cmap; int ncmapwins; unsigned int *cmapwins; unsigned int *wmcmaps; struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; } *screen; } *

variable_types: odx int

variable_types: ody int

variable_types:
values
unsigned int [2]

user_defined_types: struct Client { unsigned int window; unsigned int parent; unsigned int trans; struct Client *next; struct Client *revert; int x; int y; int dx; int dy; int border; struct xcb_size_hints_t size; int min_dx; int min_dy; int state; int init; int reparenting; int is9term; int hold; int proto; char *label; char *instance; char *class; char *name; char *iconname; unsigned int cmap; int ncmapwins; unsigned int *cmapwins; unsigned int *wmcmaps; struct ScreenInfo *screen; }


move

decompiled_code:
void __fastcall move(unsigned int *a1)
{
if ( a1 )
{
if ( (unsigned int)drag() )
{
active(a1);
top(a1);
xraisewindow(dpy, a1[1]);
xmovewindow(dpy, a1[1], a1[8] - (unsigned int)border, a1[9] - (unsigned int)border);
sendconfig(a1);
}
}
}

canonical_decompiled_code:
void __fastcall func2(unsigned int *a1)
{
if ( a1 )
{
if ( (unsigned int)drag() )
{
active(a1);
top(a1);
xraisewindow(dpy, a1[1]);
xmovewindow(dpy, a1[1], a1[8] - (unsigned int)border, a1[9] - (unsigned int)border);
sendconfig(a1);
}
}
}

original_code:
void move(Client *c)
{
    uint32_t values[2];
    if (c == 0)
        return;
    if (drag(c) == 0)
        return;
    active(c);
    top(c);
    xraisewindow(dpy, c->parent);
    xmovewindow(dpy, c->parent, c->x - _border, c->y - _border);
    sendconfig(c);
}

canonical_original_code:
void move(struct Client *c)
{
    unsigned int values[2];
    if (c == 0)
        return;
    if (drag(c) == 0)
        return;
    active(c);
    top(c);
    xraisewindow(dpy, c->parent);
    xmovewindow(dpy, c->parent, c->x - _border, c->y - _border);
    sendconfig(c);
}

user_defined_types: struct xcb_size_hints_t { unsigned int flags; int x; int width; int min_width; int max_width; int width_inc; int min_aspect_num; int max_aspect_num; int base_width; unsigned int win_gravity; }

user_defined_types: struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; }