decompiled_code:
int __fastcall print_superblock(const char *a1)
{
puts("+------------------------------------------------------------------------------+");
puts("\t\t\t\tEXT3_SUPER_BLOCK");
puts("+------------------------------------------------------------------------------+");
printf("Total inode count = %u\n", *(unsigned int *)a1);
printf("Block count = %u\n", *((unsigned int *)a1 + 1));
printf("Reserved block count = %u\n", *((unsigned int *)a1 + 2));
printf("Free block count = %u\n", *((unsigned int *)a1 + 3));
printf("Free inode count = %u\n", *((unsigned int *)a1 + 4));
printf("First data block = %u\n", *((unsigned int *)a1 + 5));
printf("Block size = 1024 * 2^%u octets\n", *((unsigned int *)a1 + 6));
printf("Fragment size =%u\n", *((unsigned int *)a1 + 7));
printf("Blocks per group count =%u\n", *((unsigned int *)a1 + 8));
printf("Fragments per group count =%u\n", *((unsigned int *)a1 + 9));
printf("Inode per group count =%u\n", *((unsigned int *)a1 + 10));
puts("+------------------------------------------------------------------------------+");
printf("Last mounting operation timestamp =%u\n", *((unsigned int *)a1 + 11));
print_time(*((unsigned int *)a1 + 11));
printf("Last writing operation timestamp =%u\n", *((unsigned int *)a1 + 12));
print_time(*((unsigned int *)a1 + 12));
printf("Counter (times mounted)=%hu\n", *((unsigned __int16 *)a1 + 26));
printf("Authorized mount count before integrity checking =%hu\n", *((unsigned __int16 *)a1 + 27));
printf("Magic Number =%#.4hx\n", *((unsigned __int16 *)a1 + 28));
printf("Status flag =%hx\n", *((unsigned __int16 *)a1 + 29));
print_state(*((unsigned __int16 *)a1 + 29));
printf("Behaviour when detecting errors =%hu\n", *((unsigned __int16 *)a1 + 30));
print_errorbehavior(*((unsigned __int16 *)a1 + 30));
printf("Minimum compatible revision level (version)=%hu\n", *((unsigned __int16 *)a1 + 31));
print_revlev(*((unsigned __int16 *)a1 + 31));
printf("Last check timestamp =%u\n", *((unsigned int *)a1 + 16));
print_time(*((unsigned int *)a1 + 16));
printf("Maximum interval between checks = %u secondes\n", *((unsigned int *)a1 + 17));
printf("Creator OS =%u\n", *((unsigned int *)a1 + 18));
print_creatorOS(*((unsigned int *)a1 + 18));
printf("Current revision level (version)=%u\n", *((unsigned int *)a1 + 19));
print_revlev(*((unsigned int *)a1 + 19));
puts("+------------------------------------------------------------------------------+");
printf("Default UID for reserved blocks =%hu\n", *((unsigned __int16 *)a1 + 40));
printf("Default GID for reserved blocks =%hu\n", *((unsigned __int16 *)a1 + 41));
printf("First non-reserved inode number =%u\n", *((unsigned int *)a1 + 21));
printf("Inode size = %hu\n", *((unsigned __int16 *)a1 + 44));
printf("Superblock block number (being read)= %hu\n", *((unsigned __int16 *)a1 + 45));
puts("+------------------------------------------------------------------------------+");
printf("Compatible features set = %#.4x\n", *((unsigned int *)a1 + 23));
print_featcompat(*((unsigned int *)a1 + 23));
printf("Incompatible features set = %#.4x\n", *((unsigned int *)a1 + 24));
print_featincompat(*((unsigned int *)a1 + 24));
printf("Read-Only Compatible features set = %#.4x\n", *((unsigned int *)a1 + 25));
print_featROcompat(*((unsigned int *)a1 + 25));
puts("+------------------------------------------------------------------------------+");
print_UUID(a1 + 104);
printf("Volume name = \"%s\"\n", a1 + 120);
printf("Last mounted in directory \"%s\"\n", a1 + 136);
printf("Compression usage bitmap = %u\n", *((unsigned int *)a1 + 50));
printf("Number of blocks to try to preallocate = %hu\n", *((unsigned __int8 *)a1 + 204));
printf("Number of blocks to preallocate for directories = %hu\n", *((unsigned __int8 *)a1 + 205));
puts("+------------------------------------------------------------------------------+");
printf("Journal ");
print_UUID(a1 + 208);
printf("Journal Inode number = %u\n", *((unsigned int *)a1 + 56));
printf("Journal device number = %u\n", *((unsigned int *)a1 + 57));
printf("Start of list of orphaned inodes to delete = %u\n", *((unsigned int *)a1 + 58));
printf(
"HTREE default hash seed = %x|%x|%x|%x\n",
*((unsigned int *)a1 + 59),
*((unsigned int *)a1 + 60),
*((unsigned int *)a1 + 61),
*((unsigned int *)a1 + 62));
printf("Hash default version = %hd\n", *((unsigned __int8 *)a1 + 252));
printf("Default mount options = %u\n", *((unsigned int *)a1 + 64));
print_mountoptions(*((unsigned int *)a1 + 64));
return printf("First metablock block group = %u\n", *((unsigned int *)a1 + 65));
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
puts("+------------------------------------------------------------------------------+");
puts("\t\t\t\tEXT3_SUPER_BLOCK");
puts("+------------------------------------------------------------------------------+");
printf("Total inode count = %u\n", *(unsigned int *)a1);
printf("Block count = %u\n", *((unsigned int *)a1 + 1));
printf("Reserved block count = %u\n", *((unsigned int *)a1 + 2));
printf("Free block count = %u\n", *((unsigned int *)a1 + 3));
printf("Free inode count = %u\n", *((unsigned int *)a1 + 4));
printf("First data block = %u\n", *((unsigned int *)a1 + 5));
printf("Block size = 1024 * 2^%u octets\n", *((unsigned int *)a1 + 6));
printf("Fragment size =%u\n", *((unsigned int *)a1 + 7));
printf("Blocks per group count =%u\n", *((unsigned int *)a1 + 8));
printf("Fragments per group count =%u\n", *((unsigned int *)a1 + 9));
printf("Inode per group count =%u\n", *((unsigned int *)a1 + 10));
puts("+------------------------------------------------------------------------------+");
printf("Last mounting operation timestamp =%u\n", *((unsigned int *)a1 + 11));
print_time(*((unsigned int *)a1 + 11));
printf("Last writing operation timestamp =%u\n", *((unsigned int *)a1 + 12));
print_time(*((unsigned int *)a1 + 12));
printf("Counter (times mounted)=%hu\n", *((unsigned __int16 *)a1 + 26));
printf("Authorized mount count before integrity checking =%hu\n", *((unsigned __int16 *)a1 + 27));
printf("Magic Number =%#.4hx\n", *((unsigned __int16 *)a1 + 28));
printf("Status flag =%hx\n", *((unsigned __int16 *)a1 + 29));
print_state(*((unsigned __int16 *)a1 + 29));
printf("Behaviour when detecting errors =%hu\n", *((unsigned __int16 *)a1 + 30));
print_errorbehavior(*((unsigned __int16 *)a1 + 30));
printf("Minimum compatible revision level (version)=%hu\n", *((unsigned __int16 *)a1 + 31));
print_revlev(*((unsigned __int16 *)a1 + 31));
printf("Last check timestamp =%u\n", *((unsigned int *)a1 + 16));
print_time(*((unsigned int *)a1 + 16));
printf("Maximum interval between checks = %u secondes\n", *((unsigned int *)a1 + 17));
printf("Creator OS =%u\n", *((unsigned int *)a1 + 18));
print_creatorOS(*((unsigned int *)a1 + 18));
printf("Current revision level (version)=%u\n", *((unsigned int *)a1 + 19));
print_revlev(*((unsigned int *)a1 + 19));
puts("+------------------------------------------------------------------------------+");
printf("Default UID for reserved blocks =%hu\n", *((unsigned __int16 *)a1 + 40));
printf("Default GID for reserved blocks =%hu\n", *((unsigned __int16 *)a1 + 41));
printf("First non-reserved inode number =%u\n", *((unsigned int *)a1 + 21));
printf("Inode size = %hu\n", *((unsigned __int16 *)a1 + 44));
printf("Superblock block number (being read)= %hu\n", *((unsigned __int16 *)a1 + 45));
puts("+------------------------------------------------------------------------------+");
printf("Compatible features set = %#.4x\n", *((unsigned int *)a1 + 23));
print_featcompat(*((unsigned int *)a1 + 23));
printf("Incompatible features set = %#.4x\n", *((unsigned int *)a1 + 24));
print_featincompat(*((unsigned int *)a1 + 24));
printf("Read-Only Compatible features set = %#.4x\n", *((unsigned int *)a1 + 25));
print_featROcompat(*((unsigned int *)a1 + 25));
puts("+------------------------------------------------------------------------------+");
print_UUID(a1 + 104);
printf("Volume name = \"%s\"\n", a1 + 120);
printf("Last mounted in directory \"%s\"\n", a1 + 136);
printf("Compression usage bitmap = %u\n", *((unsigned int *)a1 + 50));
printf("Number of blocks to try to preallocate = %hu\n", *((unsigned __int8 *)a1 + 204));
printf("Number of blocks to preallocate for directories = %hu\n", *((unsigned __int8 *)a1 + 205));
puts("+------------------------------------------------------------------------------+");
printf("Journal ");
print_UUID(a1 + 208);
printf("Journal Inode number = %u\n", *((unsigned int *)a1 + 56));
printf("Journal device number = %u\n", *((unsigned int *)a1 + 57));
printf("Start of list of orphaned inodes to delete = %u\n", *((unsigned int *)a1 + 58));
printf(
"HTREE default hash seed = %x|%x|%x|%x\n",
*((unsigned int *)a1 + 59),
*((unsigned int *)a1 + 60),
*((unsigned int *)a1 + 61),
*((unsigned int *)a1 + 62));
printf("Hash default version = %hd\n", *((unsigned __int8 *)a1 + 252));
printf("Default mount options = %u\n", *((unsigned int *)a1 + 64));
print_mountoptions(*((unsigned int *)a1 + 64));
return printf("First metablock block group = %u\n", *((unsigned int *)a1 + 65));
}

original_code:
void print_superblock ( const struct ext3_super_block *sb ) {
  printf("+------------------------------------------------------------------------------+\n");
  printf("\t\t\t\tEXT3_SUPER_BLOCK\n");
  printf("+------------------------------------------------------------------------------+\n");
  printf("Total inode count    = %u\n", sb->s_inodes_count);
  printf("Block count    = %u\n", sb->s_blocks_count);
  printf("Reserved block count  = %u\n", sb->s_r_blocks_count);
  printf("Free block count = %u\n", sb->s_free_blocks_count);
  printf("Free inode count = %u\n", sb->s_free_inodes_count);
  printf("First data block = %u\n", sb->s_first_data_block);
  printf("Block size = 1024 * 2^%u octets\n", sb->s_log_block_size);
  printf("Fragment size =%u\n", sb->s_log_frag_size);
  printf("Blocks per group count =%u\n", sb->s_blocks_per_group);
  printf("Fragments per group count =%u\n", sb->s_frags_per_group);
  printf("Inode per group count =%u\n", sb->s_inodes_per_group);
  printf("+------------------------------------------------------------------------------+\n");
  printf("Last mounting operation timestamp =%u\n", sb->s_mtime);
  print_time(sb->s_mtime);
  printf("Last writing operation timestamp =%u\n", sb->s_wtime);
  print_time(sb->s_wtime);
  printf("Counter (times mounted)=%hu\n", sb->s_mnt_count);
  printf("Authorized mount count before integrity checking =%hu\n", sb->s_max_mnt_count);
  printf("Magic Number =%#.4hx\n", sb->s_magic);
  printf("Status flag =%hx\n", sb->s_state);
  print_state(sb->s_state);
  printf("Behaviour when detecting errors =%hu\n", sb->s_errors);
  print_errorbehavior(sb->s_errors);
  printf("Minimum compatible revision level (version)=%hu\n", sb->s_minor_rev_level);
  print_revlev(sb->s_minor_rev_level);
  printf("Last check timestamp =%u\n", sb->s_lastcheck);
  print_time(sb->s_lastcheck);
  printf("Maximum interval between checks = %u secondes\n", sb->s_checkinterval);
  printf("Creator OS =%u\n", sb->s_creator_os);
  print_creatorOS(sb->s_creator_os);
  printf("Current revision level (version)=%u\n", sb->s_rev_level);
  print_revlev(sb->s_rev_level);
  printf("%s", "+------------------------------------------------------------------------------+\n");
  printf("Default UID for reserved blocks =%hu\n", sb->s_def_resuid);
  printf("Default GID for reserved blocks =%hu\n", sb->s_def_resgid);
  printf("First non-reserved inode number =%u\n", sb->s_first_ino);
  printf("Inode size = %hu\n", sb->s_inode_size);
  printf("Superblock block number (being read)= %hu\n", sb->s_block_group_nr);
  printf("+------------------------------------------------------------------------------+\n");
  printf("Compatible features set = %#.4x\n", sb->s_feature_compat);
  print_featcompat(sb->s_feature_compat);
  printf("Incompatible features set = %#.4x\n", sb->s_feature_incompat);
  print_featincompat(sb->s_feature_incompat);
  printf("Read-Only Compatible features set = %#.4x\n", sb->s_feature_ro_compat);
  print_featROcompat(sb->s_feature_ro_compat);
  printf("%s", "+------------------------------------------------------------------------------+\n");
  print_UUID( sb->s_uuid );
  printf("Volume name = \"%s\"\n", sb->s_volume_name);
  printf("Last mounted in directory \"%s\"\n", sb->s_last_mounted);
  printf("Compression usage bitmap = %u\n", sb->s_algorithm_usage_bitmap);
  printf("Number of blocks to try to preallocate = %hu\n", sb->s_prealloc_blocks);
  printf("Number of blocks to preallocate for directories = %hu\n", sb->s_prealloc_dir_blocks);
  printf("+------------------------------------------------------------------------------+\n");
  printf("Journal ");
  print_UUID( sb->s_journal_uuid );
  printf("Journal Inode number = %u\n", sb->s_journal_inum);
  printf("Journal device number = %u\n", sb->s_journal_dev);
  printf("Start of list of orphaned inodes to delete = %u\n", sb->s_last_orphan);
  printf("HTREE default hash seed = %x|%x|%x|%x\n", sb->s_hash_seed[0], sb->s_hash_seed[1], sb->s_hash_seed[2], sb->s_hash_seed[3]);
  printf("Hash default version = %hd\n", sb->s_def_hash_version);
  printf("Default mount options = %u\n", sb->s_default_mount_opts);
  print_mountoptions(sb->s_default_mount_opts);
  printf("First metablock block group = %u\n", sb->s_first_meta_bg);
}

canonical_original_code:
void print_superblock(struct ext3_super_block *sb) {
  printf("+------------------------------------------------------------------------------+\n");
  printf("\t\t\t\tEXT3_SUPER_BLOCK\n");
  printf("+------------------------------------------------------------------------------+\n");
  printf("Total inode count    = %u\n", sb->s_inodes_count);
  printf("Block count    = %u\n", sb->s_blocks_count);
  printf("Reserved block count  = %u\n", sb->s_r_blocks_count);
  printf("Free block count = %u\n", sb->s_free_blocks_count);
  printf("Free inode count = %u\n", sb->s_free_inodes_count);
  printf("First data block = %u\n", sb->s_first_data_block);
  printf("Block size = 1024 * 2^%u octets\n", sb->s_log_block_size);
  printf("Fragment size =%u\n", sb->s_log_frag_size);
  printf("Blocks per group count =%u\n", sb->s_blocks_per_group);
  printf("Fragments per group count =%u\n", sb->s_frags_per_group);
  printf("Inode per group count =%u\n", sb->s_inodes_per_group);
  printf("+------------------------------------------------------------------------------+\n");
  printf("Last mounting operation timestamp =%u\n", sb->s_mtime);
  print_time(sb->s_mtime);
  printf("Last writing operation timestamp =%u\n", sb->s_wtime);
  print_time(sb->s_wtime);
  printf("Counter (times mounted)=%hu\n", sb->s_mnt_count);
  printf("Authorized mount count before integrity checking =%hu\n", sb->s_max_mnt_count);
  printf("Magic Number =%#.4hx\n", sb->s_magic);
  printf("Status flag =%hx\n", sb->s_state);
  print_state(sb->s_state);
  printf("Behaviour when detecting errors =%hu\n", sb->s_errors);
  print_errorbehavior(sb->s_errors);
  printf("Minimum compatible revision level (version)=%hu\n", sb->s_minor_rev_level);
  print_revlev(sb->s_minor_rev_level);
  printf("Last check timestamp =%u\n", sb->s_lastcheck);
  print_time(sb->s_lastcheck);
  printf("Maximum interval between checks = %u secondes\n", sb->s_checkinterval);
  printf("Creator OS =%u\n", sb->s_creator_os);
  print_creatorOS(sb->s_creator_os);
  printf("Current revision level (version)=%u\n", sb->s_rev_level);
  print_revlev(sb->s_rev_level);
  printf("%s", "+------------------------------------------------------------------------------+\n");
  printf("Default UID for reserved blocks =%hu\n", sb->s_def_resuid);
  printf("Default GID for reserved blocks =%hu\n", sb->s_def_resgid);
  printf("First non-reserved inode number =%u\n", sb->s_first_ino);
  printf("Inode size = %hu\n", sb->s_inode_size);
  printf("Superblock block number (being read)= %hu\n", sb->s_block_group_nr);
  printf("+------------------------------------------------------------------------------+\n");
  printf("Compatible features set = %#.4x\n", sb->s_feature_compat);
  print_featcompat(sb->s_feature_compat);
  printf("Incompatible features set = %#.4x\n", sb->s_feature_incompat);
  print_featincompat(sb->s_feature_incompat);
  printf("Read-Only Compatible features set = %#.4x\n", sb->s_feature_ro_compat);
  print_featROcompat(sb->s_feature_ro_compat);
  printf("%s", "+------------------------------------------------------------------------------+\n");
  print_UUID( sb->s_uuid );
  printf("Volume name = \"%s\"\n", sb->s_volume_name);
  printf("Last mounted in directory \"%s\"\n", sb->s_last_mounted);
  printf("Compression usage bitmap = %u\n", sb->s_algorithm_usage_bitmap);
  printf("Number of blocks to try to preallocate = %hu\n", sb->s_prealloc_blocks);
  printf("Number of blocks to preallocate for directories = %hu\n", sb->s_prealloc_dir_blocks);
  printf("+------------------------------------------------------------------------------+\n");
  printf("Journal ");
  print_UUID( sb->s_journal_uuid );
  printf("Journal Inode number = %u\n", sb->s_journal_inum);
  printf("Journal device number = %u\n", sb->s_journal_dev);
  printf("Start of list of orphaned inodes to delete = %u\n", sb->s_last_orphan);
  printf("HTREE default hash seed = %x|%x|%x|%x\n", sb->s_hash_seed[0], sb->s_hash_seed[1], sb->s_hash_seed[2], sb->s_hash_seed[3]);
  printf("Hash default version = %hd\n", sb->s_def_hash_version);
  printf("Default mount options = %u\n", sb->s_default_mount_opts);
  print_mountoptions(sb->s_default_mount_opts);
  printf("First metablock block group = %u\n", sb->s_first_meta_bg);
}


decompiled_code:
int __fastcall print_sb_copy(_DWORD *a1)
{
int v1; // er12
unsigned int v2; // ebx
int result; // eax
__int64 v4; // rsi
__int64 v5; // rdx
unsigned int i; // ebx

v1 = a1[1] / a1[8];
printf("The superblock contains very important datas, ext3 maintains several copies of \nit. ");
if ( !(unsigned int)mask((unsigned int)a1[25], 1LL) )
{
puts("a copy exists at the start of every block group");
if ( v1 > 0 )
{
v2 = 3;
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", 1LL, (unsigned int)a1[8]);
if ( v1 > 3 )
{
do
{
v4 = v2;
v5 = v2 * a1[8];
++v2;
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", v4, v5);
}
while ( v1 != v2 );
}
return result;
}
return puts("There is no copy of the superblock");
}
puts("Your filesystem uses the sparse superblock feature :\n");
if ( v1 <= 0 )
return puts("There is no copy of the superblock");
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", 1LL, (unsigned int)a1[8]);
if ( v1 > 3 )
{
for ( i = 3; i != v1; ++i )
{
if ( !(unsigned int)is_pow_of(i, 3LL) && !(unsigned int)is_pow_of(i, 5LL) )
{
result = is_pow_of(i, 7LL);
if ( !result )
continue;
}
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", i, i * a1[8]);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(_DWORD *a1)
{
int v1; // er12
unsigned int v2; // ebx
int result; // eax
__int64 v4; // rsi
__int64 v5; // rdx
unsigned int i; // ebx

v1 = a1[1] / a1[8];
printf("The superblock contains very important datas, ext3 maintains several copies of \nit. ");
if ( !(unsigned int)mask((unsigned int)a1[25], 1LL) )
{
puts("a copy exists at the start of every block group");
if ( v1 > 0 )
{
v2 = 3;
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", 1LL, (unsigned int)a1[8]);
if ( v1 > 3 )
{
do
{
v4 = v2;
v5 = v2 * a1[8];
++v2;
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", v4, v5);
}
while ( v1 != v2 );
}
return result;
}
return puts("There is no copy of the superblock");
}
puts("Your filesystem uses the sparse superblock feature :\n");
if ( v1 <= 0 )
return puts("There is no copy of the superblock");
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", 1LL, (unsigned int)a1[8]);
if ( v1 > 3 )
{
for ( i = 3; i != v1; ++i )
{
if ( !(unsigned int)is_pow_of(i, 3LL) && !(unsigned int)is_pow_of(i, 5LL) )
{
result = is_pow_of(i, 7LL);
if ( !result )
continue;
}
result = printf("\tThere is a copy of the superblock at group #%d block #%d\n\n", i, i * a1[8]);
}
}
return result;
}

original_code:
void print_sb_copy ( const struct ext3_super_block *sb ) {
  int group_count = sb->s_blocks_count/((sb)->s_blocks_per_group);
  int i = 1;
  printf("The superblock contains very important datas, ext3 maintains "
      "several copies of \nit. ");
  if (! mask( sb->s_feature_ro_compat, 0x0001)) {
    printf("a copy exists at the start of every block group\n");
    if ( group_count > 0 ) {
      printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
          i, i*((sb)->s_blocks_per_group) );
      for ( i = 3 ; i < group_count || i == 0; i++ )
        printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
            i, i == 0?(1024 << (sb)->s_log_block_size):i*((sb)->s_blocks_per_group) );
    }
    else {
      printf("There is no copy of the superblock\n");
    }
  }
  else {
    printf("Your filesystem uses the sparse superblock feature :\n\n");
    if ( group_count > 0 ) {
      printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
          1, i*((sb)->s_blocks_per_group) );
      for ( i = 3 ; i < group_count ; i++ ) {
        if ( is_pow_of( i, 3 ) || is_pow_of( i, 5 ) || is_pow_of( i, 7 ) ) {
          printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
              i, i*((sb)->s_blocks_per_group) );
        }
      }
    }
    else {
      printf("There is no copy of the superblock\n");
    }
  }
}

canonical_original_code:
void print_sb_copy(struct ext3_super_block *sb) {
  int group_count = sb->s_blocks_count/((sb)->s_blocks_per_group);
  int i = 1;
  printf("The superblock contains very important datas, ext3 maintains "
      "several copies of \nit. ");
  if (! mask( sb->s_feature_ro_compat, 0x0001)) {
    printf("a copy exists at the start of every block group\n");
    if ( group_count > 0 ) {
      printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
          i, i*((sb)->s_blocks_per_group) );
      for ( i = 3 ; i < group_count || i == 0; i++ )
        printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
            i, i == 0?(1024 << (sb)->s_log_block_size):i*((sb)->s_blocks_per_group) );
    }
    else {
      printf("There is no copy of the superblock\n");
    }
  }
  else {
    printf("Your filesystem uses the sparse superblock feature :\n\n");
    if ( group_count > 0 ) {
      printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
          1, i*((sb)->s_blocks_per_group) );
      for ( i = 3 ; i < group_count ; i++ ) {
        if ( is_pow_of( i, 3 ) || is_pow_of( i, 5 ) || is_pow_of( i, 7 ) ) {
          printf("\tThere is a copy of the superblock at group #%d block #%d\n\n",
              i, i*((sb)->s_blocks_per_group) );
        }
      }
    }
    else {
      printf("There is no copy of the superblock\n");
    }
  }
}

variable_types: struct ext3_super_block { unsigned int s_inodes_count; unsigned int s_blocks_count; unsigned int s_r_blocks_count; unsigned int s_free_blocks_count; unsigned int s_free_inodes_count; unsigned int s_first_data_block; unsigned int s_log_block_size; unsigned int s_log_frag_size; unsigned int s_blocks_per_group; unsigned int s_frags_per_group; unsigned int s_inodes_per_group; unsigned int s_mtime; unsigned int s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_errors; unsigned short s_minor_rev_level; unsigned int s_lastcheck; unsigned int s_checkinterval; unsigned int s_creator_os; unsigned int s_rev_level; unsigned short s_def_resuid; unsigned short s_def_resgid; unsigned int s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned int s_feature_compat; unsigned int s_feature_incompat; unsigned int s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned int s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_reserved_gdt_blocks; unsigned char s_journal_uuid[16]; unsigned int s_journal_inum; unsigned int s_journal_dev; unsigned int s_last_orphan; unsigned int s_hash_seed[4]; unsigned char s_def_hash_version; unsigned char s_reserved_char_pad; unsigned short s_reserved_word_pad; unsigned int s_default_mount_opts; unsigned int s_first_meta_bg; unsigned int s_mkfs_time; unsigned int s_jnl_blocks[17]; unsigned int s_blocks_count_hi; unsigned int s_r_blocks_count_hi; unsigned int s_free_blocks_count_hi; unsigned short s_min_extra_isize; unsigned short s_want_extra_isize; unsigned int s_flags; unsigned short s_raid_stride; unsigned short s_mmp_interval; unsigned long long s_mmp_block; unsigned int s_raid_stripe_width; unsigned char s_log_groups_per_flex; unsigned char s_reserved_char_pad2; unsigned short s_reserved_pad; unsigned int s_reserved[162]; } *

variable_types: i int

return_type: void


decompiled_code:
__int64 __fastcall read_block(int fd, __int64 a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a3 * (__int64)(1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek read_block");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, 1024 << *(_DWORD *)(a2 + 24)) )
{
result = 0LL;
}
else
{
perror("ext3Viewer error - read read_block");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, __int64 a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a3 * (__int64)(1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek read_block");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, 1024 << *(_DWORD *)(a2 + 24)) )
{
result = 0LL;
}
else
{
perror("ext3Viewer error - read read_block");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int read_block ( int fd, struct ext3_super_block *sb,
    __u32 num, char *block ) {
  off_t lret;
  size_t sret;
  lret = lseek( fd, ((off_t) num)*(1024 << (sb)->s_log_block_size), 0);
  if ( lret <= 0 ) {
    perror("ext3Viewer error - lseek read_block");
    return -1;
  }
  sret = read ( fd, block, (1024 << (sb)->s_log_block_size) );
  if ( sret <= 0 ) {
    perror("ext3Viewer error - read read_block");
    return -1;
  }
  return 0;
}

canonical_original_code:
int read_block(int fd, struct ext3_super_block *sb, unsigned int num, char *block) {
  long lret;
  unsigned long sret;
  lret = lseek( fd, ((long) num)*(1024 << (sb)->s_log_block_size), 0);
  if ( lret <= 0 ) {
    perror("ext3Viewer error - lseek read_block");
    return -1;
  }
  sret = read ( fd, block, (1024 << (sb)->s_log_block_size) );
  if ( sret <= 0 ) {
    perror("ext3Viewer error - read read_block");
    return -1;
  }
  return 0;
}

variable_types: fd int

variable_types:
num
unsigned int

variable_types:
block
char *

variable_types: lret long

variable_types:
sret
unsigned long

return_type: int

user_defined_types: struct ext3_super_block { unsigned int s_inodes_count; unsigned int s_blocks_count; unsigned int s_r_blocks_count; unsigned int s_free_blocks_count; unsigned int s_free_inodes_count; unsigned int s_first_data_block; unsigned int s_log_block_size; unsigned int s_log_frag_size; unsigned int s_blocks_per_group; unsigned int s_frags_per_group; unsigned int s_inodes_per_group; unsigned int s_mtime; unsigned int s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_errors; unsigned short s_minor_rev_level; unsigned int s_lastcheck; unsigned int s_checkinterval; unsigned int s_creator_os; unsigned int s_rev_level; unsigned short s_def_resuid; unsigned short s_def_resgid; unsigned int s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned int s_feature_compat; unsigned int s_feature_incompat; unsigned int s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned int s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_reserved_gdt_blocks; unsigned char s_journal_uuid[16]; unsigned int s_journal_inum; unsigned int s_journal_dev; unsigned int s_last_orphan; unsigned int s_hash_seed[4]; unsigned char s_def_hash_version; unsigned char s_reserved_char_pad; unsigned short s_reserved_word_pad; unsigned int s_default_mount_opts; unsigned int s_first_meta_bg; unsigned int s_mkfs_time; unsigned int s_jnl_blocks[17]; unsigned int s_blocks_count_hi; unsigned int s_r_blocks_count_hi; unsigned int s_free_blocks_count_hi; unsigned short s_min_extra_isize; unsigned short s_want_extra_isize; unsigned int s_flags; unsigned short s_raid_stride; unsigned short s_mmp_interval; unsigned long long s_mmp_block; unsigned int s_raid_stripe_width; unsigned char s_log_groups_per_flex; unsigned char s_reserved_char_pad2; unsigned short s_reserved_pad; unsigned int s_reserved[162]; }


decompiled_code:
__int64 __fastcall read_block_pointer(int fd, int a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a2 * (unsigned __int64)a3, 0) <= 0 )
{
perror("ext3Viewer error - lseek read_block");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, a2) )
{
result = 0LL;
}
else
{
perror("ext3Viewer error - read read_block");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int fd, int a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a2 * (unsigned __int64)a3, 0) <= 0 )
{
perror("ext3Viewer error - lseek read_block");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, a2) )
{
result = 0LL;
}
else
{
perror("ext3Viewer error - read read_block");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int read_block_pointer ( int fd, int block_size,
    __u32 num, __u32 *block ) {
  off_t lret;
  size_t sret;
  lret = lseek( fd, ((off_t) num)*block_size, 0);
  if ( lret <= 0 ) {
    perror("ext3Viewer error - lseek read_block");
    return -1;
  }
  sret = read ( fd, block, block_size );
  if ( sret <= 0 ) {
    perror("ext3Viewer error - read read_block");
    return -1;
  }
  return 0;
}

canonical_original_code:
int read_block_pointer(int fd, int block_size, unsigned int num, unsigned int *block) {
  long lret;
  unsigned long sret;
  lret = lseek( fd, ((long) num)*block_size, 0);
  if ( lret <= 0 ) {
    perror("ext3Viewer error - lseek read_block");
    return -1;
  }
  sret = read ( fd, block, block_size );
  if ( sret <= 0 ) {
    perror("ext3Viewer error - read read_block");
    return -1;
  }
  return 0;
}

variable_types:
block
unsigned int *


variable_types: max int

variable_types:
block
unsigned int [-1]

variable_types: ret int


decompiled_code:
void __fastcall print_block_hexa(int fd, __int64 a2, unsigned int a3)
{
int v4; // er14
int v5; // er13
unsigned __int8 *v6; // r12
unsigned __int8 *v7; // rbx
unsigned __int8 *v8; // rbp
unsigned __int8 *v9; // r15
__int64 v10; // rsi
unsigned __int8 *v11; // r15
__int64 v12; // rsi
unsigned __int8 *v13; // r15
int v14; // edi
unsigned __int8 *ptr; // [rsp+8h] [rbp-40h]

v4 = 1024 << *(_DWORD *)(a2 + 24);
ptr = (unsigned __int8 *)malloc(v4);
if ( (unsigned int)read_block(fd, a2, a3, ptr) == -1 )
exit(1);
if ( v4 > 0 )
{
v5 = 0;
v6 = ptr;
v7 = ptr + 16;
v8 = ptr + 8;
do
{
v9 = v6;
printf(" %.8x ", (unsigned int)v5);
do
{
v10 = *v9++;
printf("%.2x ", v10);
}
while ( v9 != v8 );
v11 = v6;
putchar(32);
do
{
v12 = v11[8];
++v11;
printf("%.2x ", v12);
}
while ( v11 != v8 );
v13 = v6;
printf(" |");
do
{
v14 = (char)*v13;
if ( (unsigned __int8)(*v13 - 32) > 0x5Eu )
v14 = 46;
putchar(v14);
++v13;
}
while ( v13 != v7 );
v5 += 16;
v7 += 16;
v6 += 16;
v8 += 16;
puts("|");
}
while ( v4 > v5 );
}
free(ptr);
}

original_code:
void print_block_hexa ( int fd, struct ext3_super_block *sb, __u32 block_num ) {
  int cc, c;
  int blocksize = (1024 << (sb)->s_log_block_size);
  char *block;
  int ret;
  block = malloc ( blocksize );
  ret = read_block( fd, sb, block_num, block );
  if ( ret == -1 )
    exit(1);
  for ( cc = 0 ; cc < blocksize ; cc+= 16) {
    printf(" %.8x  ", cc);
    for ( c = 0 ; c < 8 ; c++ )
      printf("%.2x ", (__u8) block[cc+c]);
    printf(" ");
    for ( ; c < 16 ; c++ )
      printf("%.2x ", (__u8)block[cc+c]);
    printf(" |");
    for ( c = 0 ; c < 16 ; c++ )
      if ( block[c+cc] >= 32 && block[c+cc] <= 126 )
        putchar(block[c+cc]);
      else
        putchar('.');
    printf("|\n");
  }
  free ( block );
}

canonical_original_code:
void print_block_hexa(int fd, struct ext3_super_block *sb, unsigned int block_num) {
  int cc; int c;
  int blocksize = (1024 << (sb)->s_log_block_size);
  char *block;
  int ret;
  block = malloc ( blocksize );
  ret = read_block( fd, sb, block_num, block );
  if ( ret == -1 )
    exit(1);
  for ( cc = 0 ; cc < blocksize ; cc+= 16) {
    printf(" %.8x  ", cc);
    for ( c = 0 ; c < 8 ; c++ )
      printf("%.2x ", (unsigned char) block[cc+c]);
    printf(" ");
    for ( ; c < 16 ; c++ )
      printf("%.2x ", (unsigned char)block[cc+c]);
    printf(" |");
    for ( c = 0 ; c < 16 ; c++ )
      if ( block[c+cc] >= 32 && block[c+cc] <= 126 )
        putchar(block[c+cc]);
      else
        putchar('.');
    printf("|\n");
  }
  free ( block );
}

variable_types: cc int

variable_types: c int

variable_types: blocksize int


decompiled_code:
void __fastcall print_block_hexa_noline(int fd, __int64 a2, unsigned int a3)
{
int v4; // er14
int v5; // er13
unsigned __int8 *v6; // r12
unsigned __int8 *v7; // rbx
unsigned __int8 *v8; // rbp
unsigned __int8 *v9; // r15
__int64 v10; // rsi
unsigned __int8 *v11; // r15
__int64 v12; // rsi
unsigned __int8 *v13; // r15
int v14; // edi
unsigned __int8 *ptr; // [rsp+8h] [rbp-40h]

v4 = 1024 << *(_DWORD *)(a2 + 24);
ptr = (unsigned __int8 *)malloc(v4);
if ( (unsigned int)read_block(fd, a2, a3, ptr) == -1 )
exit(1);
if ( v4 > 0 )
{
v5 = 0;
v6 = ptr;
v7 = ptr + 16;
v8 = ptr + 8;
do
{
v9 = v6;
printf(" ");
do
{
v10 = *v9++;
printf("%.2x ", v10);
}
while ( v9 != v8 );
v11 = v6;
putchar(32);
do
{
v12 = v11[8];
++v11;
printf("%.2x ", v12);
}
while ( v11 != v8 );
v13 = v6;
printf(" |");
do
{
v14 = (char)*v13;
if ( (unsigned __int8)(*v13 - 32) > 0x5Eu )
v14 = 46;
putchar(v14);
++v13;
}
while ( v13 != v7 );
v5 += 16;
v7 += 16;
v6 += 16;
v8 += 16;
puts("|");
}
while ( v4 > v5 );
}
free(ptr);
}

original_code:
void print_block_hexa_noline ( int fd, struct ext3_super_block *sb,
    __u32 block_num ) {
  int cc, c;
  int blocksize = (1024 << (sb)->s_log_block_size);
  char *block;
  int ret;
  block = malloc ( blocksize );
  ret = read_block( fd, sb, block_num, block );
  if ( ret == -1 )
    exit(1);
  for ( cc = 0 ; cc < blocksize ; cc+= 16) {
    printf("     ");
    for ( c = 0 ; c < 8 ; c++ )
      printf("%.2x ", (__u8) block[cc+c]);
    printf(" ");
    for ( ; c < 16 ; c++ )
      printf("%.2x ", (__u8)block[cc+c]);
    printf(" |");
    for ( c = 0 ; c < 16 ; c++ )
      if ( block[c+cc] >= 32 && block[c+cc] <= 126 )
        putchar(block[c+cc]);
      else
        putchar('.');
    printf("|\n");
  }
  free ( block );
}

canonical_original_code:
void print_block_hexa_noline(int fd, struct ext3_super_block *sb, unsigned int block_num) {
  int cc; int c;
  int blocksize = (1024 << (sb)->s_log_block_size);
  char *block;
  int ret;
  block = malloc ( blocksize );
  ret = read_block( fd, sb, block_num, block );
  if ( ret == -1 )
    exit(1);
  for ( cc = 0 ; cc < blocksize ; cc+= 16) {
    printf("     ");
    for ( c = 0 ; c < 8 ; c++ )
      printf("%.2x ", (unsigned char) block[cc+c]);
    printf(" ");
    for ( ; c < 16 ; c++ )
      printf("%.2x ", (unsigned char)block[cc+c]);
    printf(" |");
    for ( c = 0 ; c < 16 ; c++ )
      if ( block[c+cc] >= 32 && block[c+cc] <= 126 )
        putchar(block[c+cc]);
      else
        putchar('.');
    printf("|\n");
  }
  free ( block );
}


decompiled_code:
void __fastcall print_blocks(int fd, __int64 a2, unsigned int a3, __int16 a4, int a5)
{
unsigned int v7; // ebx
unsigned int v8; // ebx
__int64 v9; // [rsp+0h] [rbp-58h]
int buf[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

if ( a4 )
{
if ( a3 )
{
v9 = a3;
if ( lseek64(fd, a3 * (__int64)(1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek 2 print_blocks");
exit(-1);
}
if ( !read(fd, buf, 4uLL) )
{
perror("ext3Viewer error - read 2 print_blocks");
exit(-1);
}
v7 = 0;
while ( buf[0] && (1024 << *(_DWORD *)(a2 + 24)) / 4 > v7 )
{
++v7;
print_blocks(fd);
if ( lseek64(fd, 4 * v7 + v9 * (1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek 3 print_blocks");
exit(-1);
}
if ( !read(fd, buf, 4uLL) )
{
perror("ext3Viewer error - read 3 print_blocks");
exit(-1);
}
}
}
}
else
{
if ( lseek64(fd, a3 * (__int64)(1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek block print_blocks");
exit(-1);
}
if ( a5 )
{
if ( a5 == 1 && 1024 << *(_DWORD *)(a2 + 24) )
{
v8 = 0;
do
{
if ( !read(fd, buf, 1uLL) )
{
perror("ext3Viewer error - read octet print_blocks");
exit(-1);
}
++v8;
putchar(SLOBYTE(buf[0]));
}
while ( 1024 << *(_DWORD *)(a2 + 24) > v8 );
}
}
else
{
print_block_hexa_noline(fd, a2, a3);
}
}
}

canonical_decompiled_code:
void __fastcall func5(int fd, __int64 a2, unsigned int a3, __int16 a4, int a5)
{
unsigned int v7; // ebx
unsigned int v8; // ebx
__int64 v9; // [rsp+0h] [rbp-58h]
int buf[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

if ( a4 )
{
if ( a3 )
{
v9 = a3;
if ( lseek64(fd, a3 * (__int64)(1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek 2 print_blocks");
exit(-1);
}
if ( !read(fd, buf, 4uLL) )
{
perror("ext3Viewer error - read 2 print_blocks");
exit(-1);
}
v7 = 0;
while ( buf[0] && (1024 << *(_DWORD *)(a2 + 24)) / 4 > v7 )
{
++v7;
func5(fd);
if ( lseek64(fd, 4 * v7 + v9 * (1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek 3 print_blocks");
exit(-1);
}
if ( !read(fd, buf, 4uLL) )
{
perror("ext3Viewer error - read 3 print_blocks");
exit(-1);
}
}
}
}
else
{
if ( lseek64(fd, a3 * (__int64)(1024 << *(_DWORD *)(a2 + 24)), 0) <= 0 )
{
perror("ext3Viewer error - lseek block print_blocks");
exit(-1);
}
if ( a5 )
{
if ( a5 == 1 && 1024 << *(_DWORD *)(a2 + 24) )
{
v8 = 0;
do
{
if ( !read(fd, buf, 1uLL) )
{
perror("ext3Viewer error - read octet print_blocks");
exit(-1);
}
++v8;
putchar(SLOBYTE(buf[0]));
}
while ( 1024 << *(_DWORD *)(a2 + 24) > v8 );
}
}
else
{
func4(fd, a2, a3);
}
}
}

original_code:
void print_blocks ( int fd, struct ext3_super_block *sb,
    __u32 block_num, short rec_level, int mode ) {
  unsigned int c = 0;
  char octet;
  __u32 iblock_num;
  off_t lret;
  size_t sret;
  if ( rec_level == 0 ) {
    ;
    lret = lseek( fd, ((off_t) block_num)*(1024 << (sb)->s_log_block_size), 0);
    if ( lret <= 0 ) {
      perror("ext3Viewer error - lseek block print_blocks");
      exit (-1);
    }
    if ( mode == 0 ) {
      print_block_hexa_noline ( fd, sb, block_num );
    }
    else if ( mode == 1 ) {
      for ( c = 0 ; c < (1024 << (sb)->s_log_block_size) ; c++ )
      {
        sret = read ( fd, &octet, sizeof(char) );
        if ( sret <= 0 ) {
          perror("ext3Viewer error - read octet print_blocks");
          exit (-1);
        }
        putchar(octet);
      }
    }
  }
  else {
    if ( block_num > 0 ) {
      ;
      lret = lseek( fd, ((off_t) block_num)*(1024 << (sb)->s_log_block_size), 0);
      if ( lret <= 0 ) {
        perror("ext3Viewer error - lseek 2 print_blocks");
        exit (-1);
      }
      sret = read ( fd, &iblock_num, 4 );
      if ( sret <= 0 ) {
        perror("ext3Viewer error - read 2 print_blocks");
        exit (-1);
      }
      while ( iblock_num != 0 && c < ((1024 << (sb)->s_log_block_size)/4) )
      {
        print_blocks ( fd, sb, iblock_num, rec_level-1, mode );
        c++;
        lret = lseek( fd, ((off_t) block_num)*(1024 << (sb)->s_log_block_size)+(c*4),
            0);
        if ( lret <= 0 ) {
          perror("ext3Viewer error - lseek 3 print_blocks");
          exit (-1);
        }
        sret = read ( fd, &iblock_num, 4 );
        if ( sret <= 0 ) {
          perror("ext3Viewer error - read 3 print_blocks");
          exit (-1);
        }
      }
    }
  }
}

canonical_original_code:
void print_blocks(int fd, struct ext3_super_block *sb, unsigned int block_num, short rec_level, int mode) {
  unsigned int c = 0;
  char octet;
  unsigned int iblock_num;
  long lret;
  unsigned long sret;
  if ( rec_level == 0 ) {
    ;
    lret = lseek( fd, ((long) block_num)*(1024 << (sb)->s_log_block_size), 0);
    if ( lret <= 0 ) {
      perror("ext3Viewer error - lseek block print_blocks");
      exit (-1);
    }
    if ( mode == 0 ) {
      print_block_hexa_noline ( fd, sb, block_num );
    }
    else if ( mode == 1 ) {
      for ( c = 0 ; c < (1024 << (sb)->s_log_block_size) ; c++ )
      {
        sret = read ( fd, &octet, sizeof(char) );
        if ( sret <= 0 ) {
          perror("ext3Viewer error - read octet print_blocks");
          exit (-1);
        }
        putchar(octet);
      }
    }
  }
  else {
    if ( block_num > 0 ) {
      ;
      lret = lseek( fd, ((long) block_num)*(1024 << (sb)->s_log_block_size), 0);
      if ( lret <= 0 ) {
        perror("ext3Viewer error - lseek 2 print_blocks");
        exit (-1);
      }
      sret = read ( fd, &iblock_num, 4 );
      if ( sret <= 0 ) {
        perror("ext3Viewer error - read 2 print_blocks");
        exit (-1);
      }
      while ( iblock_num != 0 && c < ((1024 << (sb)->s_log_block_size)/4) )
      {
        print_blocks ( fd, sb, iblock_num, rec_level-1, mode );
        c++;
        lret = lseek( fd, ((long) block_num)*(1024 << (sb)->s_log_block_size)+(c*4),
            0);
        if ( lret <= 0 ) {
          perror("ext3Viewer error - lseek 3 print_blocks");
          exit (-1);
        }
        sret = read ( fd, &iblock_num, 4 );
        if ( sret <= 0 ) {
          perror("ext3Viewer error - read 3 print_blocks");
          exit (-1);
        }
      }
    }
  }
}

variable_types: mode int

variable_types:
c
unsigned int

variable_types: octet char


original_code:
void print_t_bin(char content)
{
  printf("%d", content&1);
  printf("%d",(content&2)>>1);
  printf("%d",(content&4)>>2);
  printf("%d",(content&8)>>3);
  printf("%d",(content&16)>>4);
  printf("%d",(content&32)>>5);
  printf("%d",(content&64)>>6);
  printf("%d",(content&128)>>7);
}

variable_types: content char


decompiled_code:
int __fastcall open_fs(const char *a1)
{
int result; // eax

result = open64(a1, 0);
if ( result == -1 )
{
perror("Could not open the filesystem ");
result = -1;
}
return result;
}

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

result = open64(a1, 0);
if ( result == -1 )
{
perror("Could not open the filesystem ");
result = -1;
}
return result;
}

original_code:
int open_fs ( char * path ) {
  int fd;
  ;
  if ( ( fd = open ( path, 00 ) )== -1) {
    perror("Could not open the filesystem ");
    return -1;
  }
  else return fd;
}

canonical_original_code:
int open_fs(char *path) {
  int fd;
  ;
  if ( ( fd = open ( path, 00 ) )== -1) {
    perror("Could not open the filesystem ");
    return -1;
  }
  else return fd;
}

variable_types:
path
char *


decompiled_code:
__int64 __fastcall close_fs(int a1)
{
if ( close(a1) != -1 )
return 0LL;
perror("close_fs error");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
if ( close(a1) != -1 )
return 0LL;
perror("close_fs error");
return 0xFFFFFFFFLL;
}

original_code:
int close_fs ( int fd ) {
  ;
  if ( close( fd ) == -1 ) {
    perror("close_fs error");
    return -1;
  }
  return 0;
}

canonical_original_code:
int close_fs(int fd) {
  ;
  if ( close( fd ) == -1 ) {
    perror("close_fs error");
    return -1;
  }
  return 0;
}

variable_types: fd int


decompiled_code:
__int64 __fastcall read_journal_superblock(int fd, int a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a2 * (unsigned __int64)a3, 0) == -1 )
{
perror("ext3Viewer - lseek error: journal superblock");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, 0x400uLL) == -1 )
{
perror("ext3Viewer - read error: journal superblock");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd, int a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a2 * (unsigned __int64)a3, 0) == -1 )
{
perror("ext3Viewer - lseek error: journal superblock");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, 0x400uLL) == -1 )
{
perror("ext3Viewer - read error: journal superblock");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int read_journal_superblock(int fd, int block_size, __u32 jsb_block_num, struct journal_superblock_s *jsb ) {
  off_t lret;
  ssize_t sret;
  __u64 jsb_pos =(__u64)(jsb_block_num) * block_size;
  lret = lseek( fd, jsb_pos, 0);
  if ( lret == -1 ) {
    perror("ext3Viewer - lseek error: journal superblock");
    return -1;
  }
  sret = read( fd, jsb, sizeof(struct journal_superblock_s) );
  if ( sret == -1 ) {
    perror("ext3Viewer - read error: journal superblock");
    return -1;
  }
  return 0;
}

canonical_original_code:
int read_journal_superblock(int fd, int block_size, unsigned int jsb_block_num, struct journal_superblock_s *jsb) {
  long lret;
  long sret;
  unsigned long long jsb_pos = (__u64)(jsb_block_num) * block_size;
  lret = lseek( fd, jsb_pos, 0);
  if ( lret == -1 ) {
    perror("ext3Viewer - lseek error: journal superblock");
    return -1;
  }
  sret = read( fd, jsb, sizeof(struct journal_superblock_s) );
  if ( sret == -1 ) {
    perror("ext3Viewer - read error: journal superblock");
    return -1;
  }
  return 0;
}

variable_types: struct journal_superblock_s { struct journal_header_s { unsigned int h_magic; unsigned int h_blocktype; unsigned int h_sequence; } s_header; unsigned int s_blocksize; unsigned int s_maxlen; unsigned int s_first; unsigned int s_sequence; unsigned int s_start; unsigned int s_errno; unsigned int s_feature_compat; unsigned int s_feature_incompat; unsigned int s_feature_ro_compat; unsigned char s_uuid[16]; unsigned int s_nr_users; unsigned int s_dynsuper; unsigned int s_max_transaction; unsigned int s_max_trans_data; unsigned int s_padding[44]; unsigned char s_users[-1]; } *

variable_types: sret long

user_defined_types: struct journal_superblock_s { struct journal_header_s s_header; unsigned int s_blocksize; unsigned int s_maxlen; unsigned int s_first; unsigned int s_sequence; unsigned int s_start; unsigned int s_errno; unsigned int s_feature_compat; unsigned int s_feature_incompat; unsigned int s_feature_ro_compat; unsigned char s_uuid[16]; unsigned int s_nr_users; unsigned int s_dynsuper; unsigned int s_max_transaction; unsigned int s_max_trans_data; unsigned int s_padding[44]; unsigned char s_users[-1]; }


decompiled_code:
__int64 __fastcall read_journal_header(int fd, int a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a2 * (unsigned __int64)a3, 0) == -1 )
{
perror("ext3Viewer - lseek error: journal header");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, 0xCuLL) == -1 )
{
perror("ext3Viewer - read error: journal header");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int fd, int a2, unsigned int a3, void *a4)
{
__int64 result; // rax

if ( lseek64(fd, a2 * (unsigned __int64)a3, 0) == -1 )
{
perror("ext3Viewer - lseek error: journal header");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a4, 0xCuLL) == -1 )
{
perror("ext3Viewer - read error: journal header");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int read_journal_header( int fd, int block_size,
    __u32 journal_block_num, struct journal_header_s *header ) {
  off_t lret;
  ssize_t sret;
  __u64 journal_offset = (__u64)(journal_block_num) * block_size;
  lret = lseek( fd, journal_offset, 0 );
  if ( lret == -1 ) {
    perror("ext3Viewer - lseek error: journal header");
    return -1;
  }
  sret = read( fd, header, sizeof(struct journal_header_s) );
  if ( sret == -1 ) {
    perror("ext3Viewer - read error: journal header");
    return -1;
  }
  return 0;
}

canonical_original_code:
int read_journal_header(int fd, int block_size, unsigned int journal_block_num, struct journal_header_s *header) {
  long lret;
  long sret;
  unsigned long long journal_offset = (__u64)(journal_block_num) * block_size;
  lret = lseek( fd, journal_offset, 0 );
  if ( lret == -1 ) {
    perror("ext3Viewer - lseek error: journal header");
    return -1;
  }
  sret = read( fd, header, sizeof(struct journal_header_s) );
  if ( sret == -1 ) {
    perror("ext3Viewer - read error: journal header");
    return -1;
  }
  return 0;
}

variable_types: struct journal_header_s { unsigned int h_magic; unsigned int h_blocktype; unsigned int h_sequence; } *

variable_types: lret long


decompiled_code:
__int64 __fastcall read_journal_revoke_header(int fd, int a2, unsigned int a3, int a4, void *a5)
{
__int64 result; // rax

if ( lseek64(fd, a3 * (__int64)a2 + a4, 0) == -1 )
{
perror("ext3Viewer - lseek error: journal header");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a5, 0x10uLL) == -1 )
{
perror("ext3Viewer - read error: journal header");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd, int a2, unsigned int a3, int a4, void *a5)
{
__int64 result; // rax

if ( lseek64(fd, a3 * (__int64)a2 + a4, 0) == -1 )
{
perror("ext3Viewer - lseek error: journal header");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, a5, 0x10uLL) == -1 )
{
perror("ext3Viewer - read error: journal header");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int read_journal_revoke_header(int fd, int block_size,
    __u32 journal_block, int offset, struct journal_revoke_header_s *header ) {
  off_t lret;
  ssize_t sret;
  __u64 journal_offset = (__u64)(journal_block) * block_size;
  lret = lseek( fd, journal_offset + offset , 0 );
  if ( lret == -1 ) {
    perror("ext3Viewer - lseek error: journal header");
    return -1;
  }
  sret = read( fd, header, sizeof(struct journal_revoke_header_s) );
  if ( sret == -1 ) {
    perror("ext3Viewer - read error: journal header");
    return -1;
  }
  return 0;
}

canonical_original_code:
int read_journal_revoke_header(int fd, int block_size, unsigned int journal_block, int offset, struct journal_revoke_header_s *header) {
  long lret;
  long sret;
  unsigned long long journal_offset = (__u64)(journal_block) * block_size;
  lret = lseek( fd, journal_offset + offset , 0 );
  if ( lret == -1 ) {
    perror("ext3Viewer - lseek error: journal header");
    return -1;
  }
  sret = read( fd, header, sizeof(struct journal_revoke_header_s) );
  if ( sret == -1 ) {
    perror("ext3Viewer - read error: journal header");
    return -1;
  }
  return 0;
}

variable_types: offset int

variable_types: struct journal_revoke_header_s { struct journal_header_s { unsigned int h_magic; unsigned int h_blocktype; unsigned int h_sequence; } r_header; unsigned int r_count; } *

user_defined_types: struct journal_revoke_header_s { struct journal_header_s r_header; unsigned int r_count; }


decompiled_code:
int __fastcall print_journal_header(unsigned int *a1)
{
unsigned int v1; // eax
__int64 v2; // rdx
unsigned int v3; // eax
unsigned int v4; // eax
int result; // eax

if ( (unsigned int)_fswab32(*a1) != -1069860456 )
puts("ERROR ---------------------");
puts("Journal superblock header:");
v1 = _fswab32(*a1);
printf("Journal magic number:%#x, should be %#x \n", v1, v2);
v3 = _fswab32(a1[1]);
printf("Journal block type:%u ", v3);
switch ( (unsigned int)_fswab32(a1[1]) )
{
case 1u:
puts("JFS_DESCRIPTOR_BLOCK");
goto LABEL_5;
case 2u:
puts("JFS_COMMIT_BLOCK");
goto LABEL_5;
case 3u:
puts("JFS_SUPERBLOCK_V1");
goto LABEL_5;
case 4u:
puts("JFS_SUPERBLOCK_V2");
goto LABEL_5;
case 5u:
puts("JFS_REVOKE_BLOCK");
LABEL_5:
v4 = _fswab32(a1[2]);
result = printf("Journal sequence:%u \n\n", v4);
break;
default:
result = puts("Unexpected block type");
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(unsigned int *a1)
{
unsigned int v1; // eax
__int64 v2; // rdx
unsigned int v3; // eax
unsigned int v4; // eax
int result; // eax

if ( (unsigned int)func1(*a1) != -1069860456 )
puts("ERROR ---------------------");
puts("Journal superblock header:");
v1 = func1(*a1);
printf("Journal magic number:%#x, should be %#x \n", v1, v2);
v3 = func1(a1[1]);
printf("Journal block type:%u ", v3);
switch ( (unsigned int)func1(a1[1]) )
{
case 1u:
puts("JFS_DESCRIPTOR_BLOCK");
goto LABEL_5;
case 2u:
puts("JFS_COMMIT_BLOCK");
goto LABEL_5;
case 3u:
puts("JFS_SUPERBLOCK_V1");
goto LABEL_5;
case 4u:
puts("JFS_SUPERBLOCK_V2");
goto LABEL_5;
case 5u:
puts("JFS_REVOKE_BLOCK");
LABEL_5:
v4 = func1(a1[2]);
result = printf("Journal sequence:%u \n\n", v4);
break;
default:
result = puts("Unexpected block type");
break;
}
return result;
}

user_defined_types: struct journal_header_s { unsigned int h_magic; unsigned int h_blocktype; unsigned int h_sequence; }


decompiled_code:
int __fastcall print_journal_revoke_header(unsigned int *a1)
{
int result; // eax
unsigned int v2; // eax

print_journal_header(a1);
result = _fswab32(a1[1]);
if ( result == 5 )
{
v2 = _fswab32(a1[3]);
result = printf("Count of bytes used in the block: %u\n", v2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(unsigned int *a1)
{
int result; // eax
unsigned int v2; // eax

func5(a1);
result = func1(a1[1]);
if ( result == 5 )
{
v2 = func1(a1[3]);
result = printf("Count of bytes used in the block: %u\n", v2);
}
return result;
}

canonical_original_code:
void print_journal_revoke_header(struct journal_revoke_header_s *header) {
  print_journal_header( &header->r_header );
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(header->r_header.h_blocktype))) ? ((__u32)( (((__u32)((__u32)(__be32)(header->r_header.h_blocktype)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(header->r_header.h_blocktype)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(header->r_header.h_blocktype)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(header->r_header.h_blocktype)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(header->r_header.h_blocktype))) == 5 )
    printf("Count of bytes used in the block: %u\n", (__builtin_constant_p((__u32)((__u32)(__be32)(header->r_count))) ? ((__u32)( (((__u32)((__u32)(__be32)(header->r_count)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(header->r_count)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(header->r_count)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(header->r_count)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(header->r_count))));
}


decompiled_code:
__int64 __fastcall dump_journal_block(int fd, int a2, unsigned int a3)
{
__int64 v3; // r12
int v5; // ebx
__int64 v6; // r12
unsigned int v7; // eax
unsigned int v8; // eax
char v9; // al
int v10; // eax
unsigned int buf; // [rsp+8h] [rbp-40h] BYREF
unsigned int v12; // [rsp+Ch] [rbp-3Ch]
unsigned int v13[14]; // [rsp+10h] [rbp-38h] BYREF

v3 = a3;
read_journal_revoke_header(fd, a2, a3, 0, v13);
if ( (unsigned int)_fswab32(v13[0]) != -1069860456 )
return 0LL;
print_journal_revoke_header(v13);
if ( (unsigned int)_fswab32(v13[1]) != 1 )
{
LABEL_16:
puts("+------------------------------------------------------------------------------+");
return 0LL;
}
v5 = 12;
v6 = a2 * v3;
while ( 1 )
{
if ( lseek64(fd, v6 + v5, 0) == -1 )
{
perror("lseek dump journal block");
return 0xFFFFFFFFLL;
}
if ( read(fd, &buf, 8uLL) == -1 )
break;
v7 = _fswab32(buf);
printf("Concerned block number : %u\n", v7);
v8 = _fswab32(v12);
printf("flag: %u\n", v8);
v9 = _fswab32(v12);
if ( (v9 & 1) != 0 )
{
puts("JFS_FLAG_ESPACE: on-disk block is escaped");
v9 = _fswab32(v12);
if ( (v9 & 2) != 0 )
{
LABEL_18:
puts("JFS_FLAG_SAME_UUID: block has same uuid as previous");
v9 = _fswab32(v12);
goto LABEL_10;
}
}
else if ( (v9 & 2) != 0 )
{
goto LABEL_18;
}
v5 += 16;
LABEL_10:
if ( (v9 & 4) != 0 )
{
puts("JFS_FLAG_DELETED: block deleted by this transaction");
v9 = _fswab32(v12);
}
v10 = v9 & 8;
if ( v10 )
{
puts("JFS_FLAG_LAST_TAG: last tag in this descriptor block");
v10 = _fswab32(v12) & 8;
}
v5 += 8;
if ( a2 <= v5 || v10 )
goto LABEL_16;
}
perror("read dump journal block");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int fd, int a2, unsigned int a3)
{
__int64 v3; // r12
int v5; // ebx
__int64 v6; // r12
unsigned int v7; // eax
unsigned int v8; // eax
char v9; // al
int v10; // eax
unsigned int buf; // [rsp+8h] [rbp-40h] BYREF
unsigned int v12; // [rsp+Ch] [rbp-3Ch]
unsigned int v13[14]; // [rsp+10h] [rbp-38h] BYREF

v3 = a3;
func4(fd, a2, a3, 0, v13);
if ( (unsigned int)func1(v13[0]) != -1069860456 )
return 0LL;
func6(v13);
if ( (unsigned int)func1(v13[1]) != 1 )
{
LABEL_16:
puts("+------------------------------------------------------------------------------+");
return 0LL;
}
v5 = 12;
v6 = a2 * v3;
while ( 1 )
{
if ( lseek64(fd, v6 + v5, 0) == -1 )
{
perror("lseek dump journal block");
return 0xFFFFFFFFLL;
}
if ( read(fd, &buf, 8uLL) == -1 )
break;
v7 = func1(buf);
printf("Concerned block number : %u\n", v7);
v8 = func1(v12);
printf("flag: %u\n", v8);
v9 = func1(v12);
if ( (v9 & 1) != 0 )
{
puts("JFS_FLAG_ESPACE: on-disk block is escaped");
v9 = func1(v12);
if ( (v9 & 2) != 0 )
{
LABEL_18:
puts("JFS_FLAG_SAME_UUID: block has same uuid as previous");
v9 = func1(v12);
goto LABEL_10;
}
}
else if ( (v9 & 2) != 0 )
{
goto LABEL_18;
}
v5 += 16;
LABEL_10:
if ( (v9 & 4) != 0 )
{
puts("JFS_FLAG_DELETED: block deleted by this transaction");
v9 = func1(v12);
}
v10 = v9 & 8;
if ( v10 )
{
puts("JFS_FLAG_LAST_TAG: last tag in this descriptor block");
v10 = func1(v12) & 8;
}
v5 += 8;
if ( a2 <= v5 || v10 )
goto LABEL_16;
}
perror("read dump journal block");
return 0xFFFFFFFFLL;
}

original_code:
int dump_journal_block ( int fd, int block_size, __u32 block_num ) {
  int offset = 0;
  struct journal_block_tag_s jb_tag;
  struct journal_revoke_header_s j_rheader;
  off_t lret;
  ssize_t sret;
  read_journal_revoke_header( fd, block_size, block_num, 0, &j_rheader );
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic)))) ? ((__u32)( (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)((j_rheader.r_header.h_magic)))) == 0xc03b3998U ) {
    print_journal_revoke_header(&j_rheader);
    if ( (__builtin_constant_p((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype))) ? ((__u32)( (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(j_rheader.r_header.h_blocktype))) ==
  1 ) {
      offset = sizeof( struct journal_header_s );
      do {
  lret = lseek( fd, (__u64)(block_num)*block_size + offset, 0 );
  if ( lret == -1 ) {
    perror("lseek dump journal block");
    return -1;
  }
  sret = read( fd, &jb_tag, sizeof(struct journal_block_tag_s ) );
  if ( sret == -1 ) {
    perror("read dump journal block");
    return -1;
  }
  printf("Concerned block number : %u\n", (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_blocknr))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_blocknr))));
  printf("flag: %u\n", (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))));
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 1 ) {
    printf("JFS_FLAG_ESPACE: on-disk block is escaped\n");
  }
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 2 ) {
    printf("JFS_FLAG_SAME_UUID: block has same uuid as previous\n");
  }
  else
    offset += 16;
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 4) {
    printf("JFS_FLAG_DELETED: block deleted by this transaction\n");
        }
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 8 ) {
    printf("JFS_FLAG_LAST_TAG: last tag in this descriptor block\n");
  }
  offset += sizeof( struct journal_block_tag_s );
      }
      while ( !(((__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (__u32)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 8)) &&
    offset < block_size );
    }
  printf("+------------------------------------------------------------------------------+\n");
  }
  return 0;
}

canonical_original_code:
int dump_journal_block(int fd, int block_size, unsigned int block_num) {
  int offset = 0;
  struct journal_block_tag_s jb_tag;
  struct journal_revoke_header_s j_rheader;
  long lret;
  long sret;
  read_journal_revoke_header( fd, block_size, block_num, 0, &j_rheader );
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic)))) ? ((__u32)( (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)((j_rheader.r_header.h_magic))) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)((j_rheader.r_header.h_magic)))) == 0xc03b3998U ) {
    print_journal_revoke_header(&j_rheader);
    if ( (__builtin_constant_p((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype))) ? ((__u32)( (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(j_rheader.r_header.h_blocktype)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(j_rheader.r_header.h_blocktype))) ==
  1 ) {
      offset = sizeof( struct journal_header_s );
      do {
  lret = lseek( fd, (__u64)(block_num)*block_size + offset, 0 );
  if ( lret == -1 ) {
    perror("lseek dump journal block");
    return -1;
  }
  sret = read( fd, &jb_tag, sizeof(struct journal_block_tag_s ) );
  if ( sret == -1 ) {
    perror("read dump journal block");
    return -1;
  }
  printf("Concerned block number : %u\n", (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_blocknr))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_blocknr)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_blocknr))));
  printf("flag: %u\n", (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))));
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 1 ) {
    printf("JFS_FLAG_ESPACE: on-disk block is escaped\n");
  }
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 2 ) {
    printf("JFS_FLAG_SAME_UUID: block has same uuid as previous\n");
  }
  else
    offset += 16;
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 4) {
    printf("JFS_FLAG_DELETED: block deleted by this transaction\n");
        }
  if ( (__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 8 ) {
    printf("JFS_FLAG_LAST_TAG: last tag in this descriptor block\n");
  }
  offset += sizeof( struct journal_block_tag_s );
      }
      while ( !(((__builtin_constant_p((__u32)((__u32)(__be32)(jb_tag.t_flags))) ? ((__u32)( (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x000000ffUL) << 24) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x0000ff00UL) << 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0x00ff0000UL) >> 8) | (((__u32)((__u32)(__be32)(jb_tag.t_flags)) & (unsigned int)0xff000000UL) >> 24))) : __fswab32((__u32)(__be32)(jb_tag.t_flags))) & 8)) &&
    offset < block_size );
    }
  printf("+------------------------------------------------------------------------------+\n");
  }
  return 0;
}

variable_types: struct journal_block_tag_s { unsigned int t_blocknr; unsigned int t_flags; }

variable_types: struct journal_revoke_header_s { struct journal_header_s { unsigned int h_magic; unsigned int h_blocktype; unsigned int h_sequence; } r_header; unsigned int r_count; }


decompiled_code:
__int64 __fastcall dump_journal_block_rec(unsigned int a1, int a2, unsigned int a3, int a4)
{
unsigned int v5; // er12
__int64 v8; // rbx
unsigned int v9; // ebp
__int64 v10; // rdx
unsigned int *ptr; // [rsp+8h] [rbp-40h]

if ( a4 )
{
ptr = (unsigned int *)malloc(a2);
if ( (unsigned int)read_block_pointer(a1, (unsigned int)a2, a3, ptr) == -1 )
exit(1);
v8 = 0LL;
v9 = a4 - 1;
if ( a2 > 3 )
{
do
{
v10 = ptr[v8];
if ( !(_DWORD)v10 )
break;
v5 = dump_journal_block_rec(a1, (unsigned int)a2, v10, v9);
if ( v5 == -1 )
return v5;
++v8;
}
while ( a2 / 4 > (int)v8 );
}
v5 = 0;
free(ptr);
}
else
{
v5 = dump_journal_block(a1, a2, a3);
if ( v5 == -1 )
fwrite("!!error dumping the journal!!\n", 1uLL, 0x1EuLL, stderr);
else
v5 = 0;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, int a2, unsigned int a3, int a4)
{
unsigned int v5; // er12
__int64 v8; // rbx
unsigned int v9; // ebp
__int64 v10; // rdx
unsigned int *ptr; // [rsp+8h] [rbp-40h]

if ( a4 )
{
ptr = (unsigned int *)malloc(a2);
if ( (unsigned int)read_block_pointer(a1, (unsigned int)a2, a3, ptr) == -1 )
exit(1);
v8 = 0LL;
v9 = a4 - 1;
if ( a2 > 3 )
{
do
{
v10 = ptr[v8];
if ( !(_DWORD)v10 )
break;
v5 = func8(a1, (unsigned int)a2, v10, v9);
if ( v5 == -1 )
return v5;
++v8;
}
while ( a2 / 4 > (int)v8 );
}
v5 = 0;
free(ptr);
}
else
{
v5 = func7(a1, a2, a3);
if ( v5 == -1 )
fwrite("!!error dumping the journal!!\n", 1uLL, 0x1EuLL, stderr);
else
v5 = 0;
}
return v5;
}

original_code:
int dump_journal_block_rec ( int fd, int block_size, __u32 block_num,
    int rec_level ) {
  __u32 *block;
  int i;
  int ret;
  if ( rec_level == 0 ) {
    ret = dump_journal_block( fd, block_size, block_num);
    if ( ret == -1 ) {
      fprintf( stderr, "!!error dumping the journal!!\n" );
      return -1;
    }
  }
  else {
    block = malloc( block_size );
    ret = read_block_pointer ( fd, block_size, block_num, block );
    if ( ret == -1 )
      exit(1);
    i = 0;
    while ( i < block_size/4 && block[i] != 0 ) {
      ret = dump_journal_block_rec( fd, block_size, block[i], rec_level-1 );
      if ( ret == -1 ) {
  return -1;
      }
      i++;
    }
    free( block );
  }
  return 0;
}

canonical_original_code:
int dump_journal_block_rec(int fd, int block_size, unsigned int block_num, int rec_level) {
  unsigned int *block;
  int i;
  int ret;
  if ( rec_level == 0 ) {
    ret = dump_journal_block( fd, block_size, block_num);
    if ( ret == -1 ) {
      fprintf( stderr, "!!error dumping the journal!!\n" );
      return -1;
    }
  }
  else {
    block = malloc( block_size );
    ret = read_block_pointer ( fd, block_size, block_num, block );
    if ( ret == -1 )
      exit(1);
    i = 0;
    while ( i < block_size/4 && block[i] != 0 ) {
      ret = dump_journal_block_rec( fd, block_size, block[i], rec_level-1 );
      if ( ret == -1 ) {
  return -1;
      }
      i++;
    }
    free( block );
  }
  return 0;
}

variable_types:
block
unsigned int *

variable_types: i int

variable_types: ret int


decompiled_code:
__int64 __fastcall dump_journal(unsigned int a1, int a2, _DWORD *a3)
{
unsigned int v4; // edx
__int64 v5; // rbx
bool v6; // al
unsigned int v7; // edx
unsigned int v8; // edx
unsigned int v9; // edx

v4 = a3[10];
if ( v4 )
{
v5 = 1LL;
do
{
dump_journal_block_rec(a1, a2, v4, 0);
v4 = a3[v5 + 10];
v6 = (_DWORD)v5++ != 12;
}
while ( v6 && v4 != 0 );
}
v7 = a3[22];
if ( !v7 )
{
v8 = a3[23];
if ( !v8 )
goto LABEL_6;
LABEL_9:
dump_journal_block_rec(a1, a2, v8, 2);
v9 = a3[24];
if ( !v9 )
return 0LL;
goto LABEL_10;
}
dump_journal_block_rec(a1, a2, v7, 1);
v8 = a3[23];
if ( v8 )
goto LABEL_9;
LABEL_6:
v9 = a3[24];
if ( !v9 )
return 0LL;
LABEL_10:
dump_journal_block_rec(a1, a2, v9, 3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, int a2, _DWORD *a3)
{
unsigned int v4; // edx
__int64 v5; // rbx
bool v6; // al
unsigned int v7; // edx
unsigned int v8; // edx
unsigned int v9; // edx

v4 = a3[10];
if ( v4 )
{
v5 = 1LL;
do
{
func8(a1, a2, v4, 0);
v4 = a3[v5 + 10];
v6 = (_DWORD)v5++ != 12;
}
while ( v6 && v4 != 0 );
}
v7 = a3[22];
if ( !v7 )
{
v8 = a3[23];
if ( !v8 )
goto LABEL_6;
LABEL_9:
func8(a1, a2, v8, 2);
v9 = a3[24];
if ( !v9 )
return 0LL;
goto LABEL_10;
}
func8(a1, a2, v7, 1);
v8 = a3[23];
if ( v8 )
goto LABEL_9;
LABEL_6:
v9 = a3[24];
if ( !v9 )
return 0LL;
LABEL_10:
func8(a1, a2, v9, 3);
return 0LL;
}

original_code:
int dump_journal ( int fd, int block_size, struct ext3_inode *i ) {
  int cc = 0;
  while( i->i_block[cc] != 0 && cc < 12) {
    dump_journal_block_rec( fd, block_size, i->i_block[cc], 0 );
    cc++;
  }
  if ( i->i_block[12] != 0 )
    dump_journal_block_rec( fd, block_size, i->i_block[12], 1 );
  if ( i->i_block[(12 + 1)] != 0 )
    dump_journal_block_rec( fd, block_size, i->i_block[(12 + 1)], 2 );
  if ( i->i_block[((12 + 1) + 1)] != 0 )
    dump_journal_block_rec( fd, block_size, i->i_block[((12 + 1) + 1)], 3 );
  return 0;
}

canonical_original_code:
int dump_journal(int fd, int block_size, struct ext3_inode *i) {
  int cc = 0;
  while( i->i_block[cc] != 0 && cc < 12) {
    dump_journal_block_rec( fd, block_size, i->i_block[cc], 0 );
    cc++;
  }
  if ( i->i_block[12] != 0 )
    dump_journal_block_rec( fd, block_size, i->i_block[12], 1 );
  if ( i->i_block[(12 + 1)] != 0 )
    dump_journal_block_rec( fd, block_size, i->i_block[(12 + 1)], 2 );
  if ( i->i_block[((12 + 1) + 1)] != 0 )
    dump_journal_block_rec( fd, block_size, i->i_block[((12 + 1) + 1)], 3 );
  return 0;
}

variable_types: struct ext3_inode { unsigned short i_mode; unsigned short i_uid; unsigned int i_size; unsigned int i_atime; unsigned int i_ctime; unsigned int i_mtime; unsigned int i_dtime; unsigned short i_gid; unsigned short i_links_count; unsigned int i_blocks; unsigned int i_flags; union { struct { unsigned int l_i_reserved1; } linux1; struct { unsigned int h_i_translator; } hurd1; struct { unsigned int m_i_reserved1; } masix1; } osd1; unsigned int i_block[-1]; unsigned int i_generation; unsigned int i_file_acl; unsigned int i_dir_acl; unsigned int i_faddr; union { struct { unsigned char l_i_frag; unsigned char l_i_fsize; unsigned short i_pad1; unsigned short l_i_uid_high; unsigned short l_i_gid_high; unsigned int l_i_reserved2; } linux2; struct { unsigned char h_i_frag; unsigned char h_i_fsize; unsigned short h_i_mode_high; unsigned short h_i_uid_high; unsigned short h_i_gid_high; unsigned int h_i_author; } hurd2; struct { unsigned char m_i_frag; unsigned char m_i_fsize; unsigned short m_pad1; unsigned int m_i_reserved2[2]; } masix2; } osd2; unsigned short i_extra_isize; unsigned short i_pad1; } *

variable_types: cc int


decompiled_code:
__int64 __fastcall is_pow_of(int a1, int a2)
{
__int64 result; // rax
float v3; // xmm0_4

result = 1LL;
v3 = (float)a1;
if ( a1 != a2 )
{
do
{
if ( v3 <= 1.0 )
return 1LL;
v3 = v3 / (float)a2;
}
while ( v3 == (float)(int)v3 );
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
__int64 result; // rax
float v3; // xmm0_4

result = 1LL;
v3 = (float)a1;
if ( a1 != a2 )
{
do
{
if ( v3 <= 1.0 )
return 1LL;
v3 = v3 / (float)a2;
}
while ( v3 == (float)(int)v3 );
result = 0LL;
}
return result;
}

original_code:
int is_pow_of ( int num, int pow ) {
  float nb = (float)num;
  float nb2 = 0;
  if ( num == pow )
    return 1;
  else {
    while ( nb > 1.0f ) {
      nb = nb/pow;
      nb2 = (int)nb;
      if ( nb2 != nb )
  return 0;
    }
    return 1;
  }
}

canonical_original_code:
int is_pow_of(int num, int pow) {
  float nb = (float)num;
  float nb2 = 0;
  if ( num == pow )
    return 1;
  else {
    while ( nb > 1.0f ) {
      nb = nb/pow;
      nb2 = (int)nb;
      if ( nb2 != nb )
  return 0;
    }
    return 1;
  }
}

variable_types: num int

variable_types: pow int

variable_types: nb float


decompiled_code:
int __fastcall print_journal_superblock(unsigned int *a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
unsigned int v13; // eax

print_journal_header(a1);
v1 = _fswab32(a1[3]);
printf("Journal device blocksize:%u \n", v1);
v2 = _fswab32(a1[4]);
printf("Total blocks in journal size:%u \n", v2);
v3 = _fswab32(a1[5]);
printf("First block of log information:%u\n", v3);
v4 = _fswab32(a1[6]);
printf("First commit ID expected in the log:%u\n", v4);
v5 = _fswab32(a1[7]);
printf("Block number of the log start:%u \n", v5);
v6 = _fswab32(a1[8]);
printf("Error value (if any):%u\n", v6);
puts("The following fields are only valid in a version 2 superblock.");
v7 = _fswab32(a1[9]);
printf("Compatible features set:%#x\n", v7);
v8 = _fswab32(a1[10]);
printf("Incompatible features set:%#x\n", v8);
v9 = _fswab32(a1[11]);
printf("Read-only compatible feature set:%#x\n", v9);
print_UUID(a1 + 12);
v10 = _fswab32(a1[16]);
printf("Number of filesystem sharing log:%u\n", v10);
v11 = _fswab32(a1[17]);
printf("Block number of dynamic superblock copy:%u\n", v11);
v12 = _fswab32(a1[18]);
printf("Limit of journal blocks per transaction:%u\n", v12);
v13 = _fswab32(a1[19]);
printf("Limit of data blocks per transaction:%u\n", v13);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func11(unsigned int *a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
unsigned int v13; // eax

func5(a1);
v1 = func1(a1[3]);
printf("Journal device blocksize:%u \n", v1);
v2 = func1(a1[4]);
printf("Total blocks in journal size:%u \n", v2);
v3 = func1(a1[5]);
printf("First block of log information:%u\n", v3);
v4 = func1(a1[6]);
printf("First commit ID expected in the log:%u\n", v4);
v5 = func1(a1[7]);
printf("Block number of the log start:%u \n", v5);
v6 = func1(a1[8]);
printf("Error value (if any):%u\n", v6);
puts("The following fields are only valid in a version 2 superblock.");
v7 = func1(a1[9]);
printf("Compatible features set:%#x\n", v7);
v8 = func1(a1[10]);
printf("Incompatible features set:%#x\n", v8);
v9 = func1(a1[11]);
printf("Read-only compatible feature set:%#x\n", v9);
print_UUID(a1 + 12);
v10 = func1(a1[16]);
printf("Number of filesystem sharing log:%u\n", v10);
v11 = func1(a1[17]);
printf("Block number of dynamic superblock copy:%u\n", v11);
v12 = func1(a1[18]);
printf("Limit of journal blocks per transaction:%u\n", v12);
v13 = func1(a1[19]);
printf("Limit of data blocks per transaction:%u\n", v13);
return putchar(10);
}


decompiled_code:
__int64 __fastcall read_inodebitmap(int fd, __int64 a2, __int64 a3, _QWORD *a4)
{
__int64 v5; // rdx
unsigned int v6; // er13

v5 = *(unsigned int *)(a3 + 4);
*a4 = 0LL;
if ( (unsigned int)lseek64(fd, v5 * (1024 << *(_DWORD *)(a2 + 24)), 0) == -1 )
{
v6 = -1;
perror("ext3Viewer - lseek error: Inode Bitmap");
}
else
{
v6 = read(fd, a4, *(_DWORD *)(a2 + 40) >> 3);
if ( v6 == -1 )
perror("ext3Viewer - read error: Inode Bitmap");
else
v6 = 0;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, __int64 a2, __int64 a3, _QWORD *a4)
{
__int64 v5; // rdx
unsigned int v6; // er13

v5 = *(unsigned int *)(a3 + 4);
*a4 = 0LL;
if ( (unsigned int)lseek64(fd, v5 * (1024 << *(_DWORD *)(a2 + 24)), 0) == -1 )
{
v6 = -1;
perror("ext3Viewer - lseek error: Inode Bitmap");
}
else
{
v6 = read(fd, a4, *(_DWORD *)(a2 + 40) >> 3);
if ( v6 == -1 )
perror("ext3Viewer - read error: Inode Bitmap");
else
v6 = 0;
}
return v6;
}

original_code:
int read_inodebitmap( int fd, const struct ext3_super_block *sb,
    const struct ext3_group_desc *gd, char * inodebitmap) {
  __u64 block_num = gd->bg_inode_bitmap;
  int ret;
  bzero(inodebitmap, sizeof(inodebitmap));
  ret = lseek( fd, block_num * (1024 << (sb)->s_log_block_size), 0);
  if ( ret == -1 ) {
    perror("ext3Viewer - lseek error: Inode Bitmap");
    return -1;
  }
  ret = read( fd, inodebitmap, (((sb)->s_inodes_per_group)/8) );
  if ( ret == -1 ) {
    perror("ext3Viewer - read error: Inode Bitmap");
    return -1;
  }
  return 0;
}

canonical_original_code:
int read_inodebitmap(int fd, struct ext3_super_block *sb, struct ext3_group_desc *gd, char *inodebitmap) {
  unsigned long long block_num = gd->bg_inode_bitmap;
  int ret;
  bzero(inodebitmap, sizeof(inodebitmap));
  ret = lseek( fd, block_num * (1024 << (sb)->s_log_block_size), 0);
  if ( ret == -1 ) {
    perror("ext3Viewer - lseek error: Inode Bitmap");
    return -1;
  }
  ret = read( fd, inodebitmap, (((sb)->s_inodes_per_group)/8) );
  if ( ret == -1 ) {
    perror("ext3Viewer - read error: Inode Bitmap");
    return -1;
  }
  return 0;
}

variable_types: fd int

variable_types: struct ext3_super_block { unsigned int s_inodes_count; unsigned int s_blocks_count; unsigned int s_r_blocks_count; unsigned int s_free_blocks_count; unsigned int s_free_inodes_count; unsigned int s_first_data_block; unsigned int s_log_block_size; unsigned int s_log_frag_size; unsigned int s_blocks_per_group; unsigned int s_frags_per_group; unsigned int s_inodes_per_group; unsigned int s_mtime; unsigned int s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_errors; unsigned short s_minor_rev_level; unsigned int s_lastcheck; unsigned int s_checkinterval; unsigned int s_creator_os; unsigned int s_rev_level; unsigned short s_def_resuid; unsigned short s_def_resgid; unsigned int s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned int s_feature_compat; unsigned int s_feature_incompat; unsigned int s_feature_ro_compat; unsigned char s_uuid[16]; char s_volume_name[16]; char s_last_mounted[64]; unsigned int s_algorithm_usage_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned short s_reserved_gdt_blocks; unsigned char s_journal_uuid[16]; unsigned int s_journal_inum; unsigned int s_journal_dev; unsigned int s_last_orphan; unsigned int s_hash_seed[4]; unsigned char s_def_hash_version; unsigned char s_reserved_char_pad; unsigned short s_reserved_word_pad; unsigned int s_default_mount_opts; unsigned int s_first_meta_bg; unsigned int s_mkfs_time; unsigned int s_jnl_blocks[17]; unsigned int s_blocks_count_hi; unsigned int s_r_blocks_count_hi; unsigned int s_free_blocks_count_hi; unsigned short s_min_extra_isize; unsigned short s_want_extra_isize; unsigned int s_flags; unsigned short s_raid_stride; unsigned short s_mmp_interval; unsigned long long s_mmp_block; unsigned int s_raid_stripe_width; unsigned char s_log_groups_per_flex; unsigned char s_reserved_char_pad2; unsigned short s_reserved_pad; unsigned int s_reserved[162]; } *

variable_types: struct ext3_group_desc { unsigned int bg_block_bitmap; unsigned int bg_inode_bitmap; unsigned int bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned int bg_reserved[3]; } *

variable_types:
inodebitmap
char *


decompiled_code:
__int64 __fastcall read_datablockbitmap(int fd, _DWORD *a2, unsigned int *a3, int a4, _QWORD *a5)
{
__int64 v8; // rdi
int v9; // eax
int v10; // ebp
unsigned int v11; // edx
size_t v12; // rdx
unsigned int v13; // er15

v8 = *a3;
v9 = a2[1] / a2[8];
*a5 = 0LL;
v10 = v9;
if ( (unsigned int)lseek64(fd, v8 * (1024 << a2[6]), 0) == -1 )
{
v13 = -1;
perror("ext3Viewer - lseek error: Data Block Bitmap");
}
else
{
v11 = a2[8];
if ( v10 == a4 )
v12 = (a2[1] - v10 * v11) >> 3;
else
v12 = v11 >> 3;
if ( (unsigned int)read(fd, a5, v12) == -1 )
{
v13 = -1;
perror("ext3Viewer - read error: Data Block Bitmap");
}
else
{
v13 = 0;
}
}
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func1(int fd, _DWORD *a2, unsigned int *a3, int a4, _QWORD *a5)
{
__int64 v8; // rdi
int v9; // eax
int v10; // ebp
unsigned int v11; // edx
size_t v12; // rdx
unsigned int v13; // er15

v8 = *a3;
v9 = a2[1] / a2[8];
*a5 = 0LL;
v10 = v9;
if ( (unsigned int)lseek64(fd, v8 * (1024 << a2[6]), 0) == -1 )
{
v13 = -1;
perror("ext3Viewer - lseek error: Data Block Bitmap");
}
else
{
v11 = a2[8];
if ( v10 == a4 )
v12 = (a2[1] - v10 * v11) >> 3;
else
v12 = v11 >> 3;
if ( (unsigned int)read(fd, a5, v12) == -1 )
{
v13 = -1;
perror("ext3Viewer - read error: Data Block Bitmap");
}
else
{
v13 = 0;
}
}
return v13;
}

original_code:
int read_datablockbitmap( int fd, const struct ext3_super_block *sb,
    const struct ext3_group_desc *gd,
    const __u32 group_num, char *datablockbitmap)
{
  __u64 block_num = gd->bg_block_bitmap;
  int ret;
  int group_count = sb->s_blocks_count/((sb)->s_blocks_per_group);
  int otherblockscount;
  memset(datablockbitmap, 0, sizeof(datablockbitmap));
  ret = lseek( fd, block_num * (1024 << (sb)->s_log_block_size), 0);
  if ( ret == -1 ) {
    perror("ext3Viewer - lseek error: Data Block Bitmap");
    return -1;
  }
  if( group_num == group_count )
    {
      otherblockscount =(group_count * ((sb)->s_blocks_per_group));
      ret = read( fd, datablockbitmap,(sb->s_blocks_count
            - otherblockscount )/8 );
      if ( ret == -1 ) {
        perror("ext3Viewer - read error: Data Block Bitmap");
        return -1;
      }
    }
  else
  {
    ret = read( fd, datablockbitmap, (((sb)->s_blocks_per_group)/8) );
    if ( ret == -1 ) {
      perror("ext3Viewer - read error: Data Block Bitmap");
      return -1;
    }
  }
  return 0;
}

canonical_original_code:
int read_datablockbitmap(int fd, struct ext3_super_block *sb, struct ext3_group_desc *gd, unsigned int group_num, char *datablockbitmap)
{
  unsigned long long block_num = gd->bg_block_bitmap;
  int ret;
  int group_count = sb->s_blocks_count/((sb)->s_blocks_per_group);
  int otherblockscount;
  memset(datablockbitmap, 0, sizeof(datablockbitmap));
  ret = lseek( fd, block_num * (1024 << (sb)->s_log_block_size), 0);
  if ( ret == -1 ) {
    perror("ext3Viewer - lseek error: Data Block Bitmap");
    return -1;
  }
  if( group_num == group_count )
    {
      otherblockscount =(group_count * ((sb)->s_blocks_per_group));
      ret = read( fd, datablockbitmap,(sb->s_blocks_count
            - otherblockscount )/8 );
      if ( ret == -1 ) {
        perror("ext3Viewer - read error: Data Block Bitmap");
        return -1;
      }
    }
  else
  {
    ret = read( fd, datablockbitmap, (((sb)->s_blocks_per_group)/8) );
    if ( ret == -1 ) {
      perror("ext3Viewer - read error: Data Block Bitmap");
      return -1;
    }
  }
  return 0;
}

variable_types:
datablockbitmap
char *

variable_types: otherblockscount int

user_defined_types: struct ext3_group_desc { unsigned int bg_block_bitmap; unsigned int bg_inode_bitmap; unsigned int bg_inode_table; unsigned short bg_free_blocks_count; unsigned short bg_free_inodes_count; unsigned short bg_used_dirs_count; unsigned short bg_pad; unsigned int bg_reserved[3]; }


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

result = 1LL;
if ( (a1 & 1) != 0 )
{
result = 2LL;
if ( (a1 & 2) != 0 )
{
result = 3LL;
if ( (a1 & 4) != 0 )
{
result = 4LL;
if ( (a1 & 8) != 0 )
{
result = 5LL;
if ( (a1 & 0x10) != 0 )
{
result = 6LL;
if ( (a1 & 0x20) != 0 )
{
result = 7LL;
if ( (a1 & 0x40) != 0 )
result = 8 * (unsigned int)(a1 >= 0);
}
}
}
}
}
}
return result;
}

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

result = 1LL;
if ( (a1 & 1) != 0 )
{
result = 2LL;
if ( (a1 & 2) != 0 )
{
result = 3LL;
if ( (a1 & 4) != 0 )
{
result = 4LL;
if ( (a1 & 8) != 0 )
{
result = 5LL;
if ( (a1 & 0x10) != 0 )
{
result = 6LL;
if ( (a1 & 0x20) != 0 )
{
result = 7LL;
if ( (a1 & 0x40) != 0 )
result = 8 * (unsigned int)(a1 >= 0);
}
}
}
}
}
}
return result;
}

original_code:
int bitmap_test_free(char content )
{
  if(!(content&1)){return 1;}
  if(!((content&2)>>1)){return 2;}
  if(!((content&4)>>2)){return 3;}
  if(!((content&8)>>3)){return 4;}
  if(!((content&16)>>4)){return 5;}
  if(!((content&32)>>5)){return 6;}
  if(!((content&64)>>6)){return 7;}
  if(!((content&128)>>7)){return 8;}
  return 0;
}

canonical_original_code:
int bitmap_test_free(char content)
{
  if(!(content&1)){return 1;}
  if(!((content&2)>>1)){return 2;}
  if(!((content&4)>>2)){return 3;}
  if(!((content&8)>>3)){return 4;}
  if(!((content&16)>>4)){return 5;}
  if(!((content&32)>>5)){return 6;}
  if(!((content&64)>>6)){return 7;}
  if(!((content&128)>>7)){return 8;}
  return 0;
}

variable_types: content char


decompiled_code:
ssize_t __fastcall read_group_desc(int fd, __int64 a2, unsigned __int16 a3, void *a4)
{
ssize_t result; // rax

if ( lseek64(fd, 32LL * a3 + (unsigned int)((1024 << *(_DWORD *)(a2 + 24)) * (*(_DWORD *)(a2 + 20) + 1)), 0) <= 0 )
{
perror("ext3Viewer error - lseek error group_desc");
exit(1);
}
result = read(fd, a4, 0x20uLL);
if ( !result )
{
perror("ext3Viewer error - error reading group_desc");
exit(1);
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func3(int fd, __int64 a2, unsigned __int16 a3, void *a4)
{
ssize_t result; // rax

if ( lseek64(fd, 32LL * a3 + (unsigned int)((1024 << *(_DWORD *)(a2 + 24)) * (*(_DWORD *)(a2 + 20) + 1)), 0) <= 0 )
{
perror("ext3Viewer error - lseek error group_desc");
exit(1);
}
result = read(fd, a4, 0x20uLL);
if ( !result )
{
perror("ext3Viewer error - error reading group_desc");
exit(1);
}
return result;
}

original_code:
void read_group_desc(int fd, const struct ext3_super_block *sb,
    __u16 group_num, struct ext3_group_desc *gd) {
  off_t lret;
  size_t sret;
  lret = lseek ( fd, (sb->s_first_data_block+1) * (1024 << (sb)->s_log_block_size) +
      sizeof(struct ext3_group_desc) * group_num, 0 );
  if ( lret <= 0) {
    perror("ext3Viewer error - lseek error group_desc");
    exit(1);
  }
  ;
  ;
  ;
  ;
  ;
  sret = read ( fd, gd, sizeof(struct ext3_group_desc) );
  if( sret <= 0 ) {
    perror("ext3Viewer error - error reading group_desc");
    exit(1);
  }
  ;
  ;
  ;
  ;
  ;
  ;
  ;
  ;
}

canonical_original_code:
void read_group_desc(int fd, struct ext3_super_block *sb, unsigned short group_num, struct ext3_group_desc *gd) {
  long lret;
  unsigned long sret;
  lret = lseek ( fd, (sb->s_first_data_block+1) * (1024 << (sb)->s_log_block_size) +
      sizeof(struct ext3_group_desc) * group_num, 0 );
  if ( lret <= 0) {
    perror("ext3Viewer error - lseek error group_desc");
    exit(1);
  }
  ;
  ;
  ;
  ;
  ;
  sret = read ( fd, gd, sizeof(struct ext3_group_desc) );
  if( sret <= 0 ) {
    perror("ext3Viewer error - error reading group_desc");
    exit(1);
  }
  ;
  ;
  ;
  ;
  ;
  ;
  ;
  ;
}

variable_types: lret long

variable_types:
sret
unsigned long


decompiled_code:
int __fastcall print_groupdesc(unsigned int *a1)
{
printf("Block bitmap block (number)= %u\n", *a1);
printf("Inode bitmap block number = %u\n", a1[1]);
printf("First Inode table block number = %u\n", a1[2]);
printf("Free blocks count (in this group) = %hd\n", *((unsigned __int16 *)a1 + 6));
printf("Free inodes count (in this group) = %hd\n", *((unsigned __int16 *)a1 + 7));
return printf("Directories count (in this group) = %hd\n", *((unsigned __int16 *)a1 + 8));
}

canonical_decompiled_code:
int __fastcall func4(unsigned int *a1)
{
printf("Block bitmap block (number)= %u\n", *a1);
printf("Inode bitmap block number = %u\n", a1[1]);
printf("First Inode table block number = %u\n", a1[2]);
printf("Free blocks count (in this group) = %hd\n", *((unsigned __int16 *)a1 + 6));
printf("Free inodes count (in this group) = %hd\n", *((unsigned __int16 *)a1 + 7));
return printf("Directories count (in this group) = %hd\n", *((unsigned __int16 *)a1 + 8));
}

original_code:
void print_groupdesc ( const struct ext3_group_desc *gd)
{
  printf("Block bitmap block (number)= %u\n", gd->bg_block_bitmap);
  printf("Inode bitmap block number =  %u\n", gd->bg_inode_bitmap);
  printf("First Inode table block number = %u\n", gd->bg_inode_table);
  printf("Free blocks count (in this group) = %hd\n", gd->bg_free_blocks_count);
  printf("Free inodes count (in this group) = %hd\n", gd->bg_free_inodes_count);
  printf("Directories count (in this group) = %hd\n", gd->bg_used_dirs_count);
}

canonical_original_code:
void print_groupdesc(struct ext3_group_desc *gd)
{
  printf("Block bitmap block (number)= %u\n", gd->bg_block_bitmap);
  printf("Inode bitmap block number =  %u\n", gd->bg_inode_bitmap);
  printf("First Inode table block number = %u\n", gd->bg_inode_table);
  printf("Free blocks count (in this group) = %hd\n", gd->bg_free_blocks_count);
  printf("Free inodes count (in this group) = %hd\n", gd->bg_free_inodes_count);
  printf("Directories count (in this group) = %hd\n", gd->bg_used_dirs_count);
}


decompiled_code:
int __fastcall print_inodeblocknumber(__int64 a1, int a2, unsigned __int16 a3)
{
return printf("0x%08x", *(_DWORD *)(a1 + 40) * (unsigned int)a3 + a2 + 1);
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, int a2, unsigned __int16 a3)
{
return printf("0x%08x", *(_DWORD *)(a1 + 40) * (unsigned int)a3 + a2 + 1);
}

original_code:
void print_inodeblocknumber(const struct ext3_super_block *sb,
    __u32 inode_num_g, __u16 gb_num)
{
  __u32 i_num;
  i_num = inode_num_g+(((sb)->s_inodes_per_group)*gb_num);
  printf("0x%08x", i_num+1);
}

canonical_original_code:
void print_inodeblocknumber(struct ext3_super_block *sb, unsigned int inode_num_g, unsigned short gb_num)
{
  unsigned int i_num;
  i_num = inode_num_g+(((sb)->s_inodes_per_group)*gb_num);
  printf("0x%08x", i_num+1);
}


variable_types:
i
unsigned long long

variable_types: charcount int

variable_types:
imax
unsigned int


decompiled_code:
int __fastcall print_datablock_blocknumber(__int64 a1, int a2, unsigned __int16 a3)
{
return printf("0x%08x", *(_DWORD *)(a1 + 32) * (unsigned int)a3 + *(_DWORD *)(a1 + 20) + a2);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, int a2, unsigned __int16 a3)
{
return printf("0x%08x", *(_DWORD *)(a1 + 32) * (unsigned int)a3 + *(_DWORD *)(a1 + 20) + a2);
}

original_code:
void print_datablock_blocknumber(const struct ext3_super_block* sb,
    __u32 block_num_g, __u16 gb_num)
{
  __u32 b_num;
  b_num = block_num_g+(((sb)->s_blocks_per_group)*gb_num);
  printf("0x%08x", b_num+sb->s_first_data_block);
}

canonical_original_code:
void print_datablock_blocknumber(struct ext3_super_block *sb, unsigned int block_num_g, unsigned short gb_num)
{
  unsigned int b_num;
  b_num = block_num_g+(((sb)->s_blocks_per_group)*gb_num);
  printf("0x%08x", b_num+sb->s_first_data_block);
}


original_code:
void print_datablockbitmap(const struct ext3_super_block *sb,
    char *datablockbitmap, __u16 gb_num)
{
  unsigned long long int b = 0;
  int charcount = 0;
  __u32 bmax;
  int group_count = sb->s_blocks_count/((sb)->s_blocks_per_group);
  if(gb_num == group_count)
  {
    bmax = ((__u32)
        (sb->s_blocks_count - (group_count * ((sb)->s_blocks_per_group)))/8);
  }
  else
  {
    bmax = ((__u32)
        ((sb)->s_blocks_per_group)) / 8;
  }
  printf("Data blocks Bitmap: 0 means free Data Block, 1 means Data Block in use\n");
  printf("%s", "+------------------------------------------------------------------------------+\n");
  printf("|Databl. n.|    Bits values\n");
  printf("%s", "+------------------------------------------------------------------------------+\n");
  while ( b < bmax )
  {
    if(b%6 == 0)
    {
      if(b == 0) {
        printf("|");
      }
      else {
        printf("\n|");
      }
      print_datablock_blocknumber(sb, b*8, gb_num);
    }
    if( charcount%8 == 0)
    {
      printf("|");
    }
    print_t_bin(datablockbitmap[b]);
    b++;
    charcount = charcount+8;
  }
  printf("\n%s", "+------------------------------------------------------------------------------+\n");
}

canonical_original_code:
void print_datablockbitmap(struct ext3_super_block *sb, char *datablockbitmap, unsigned short gb_num)
{
  unsigned long long b = 0;
  int charcount = 0;
  unsigned int bmax;
  int group_count = sb->s_blocks_count/((sb)->s_blocks_per_group);
  if(gb_num == group_count)
  {
    bmax = ((__u32)
        (sb->s_blocks_count - (group_count * ((sb)->s_blocks_per_group)))/8);
  }
  else
  {
    bmax = ((__u32)
        ((sb)->s_blocks_per_group)) / 8;
  }
  printf("Data blocks Bitmap: 0 means free Data Block, 1 means Data Block in use\n");
  printf("%s", "+------------------------------------------------------------------------------+\n");
  printf("|Databl. n.|    Bits values\n");
  printf("%s", "+------------------------------------------------------------------------------+\n");
  while ( b < bmax )
  {
    if(b%6 == 0)
    {
      if(b == 0) {
        printf("|");
      }
      else {
        printf("\n|");
      }
      print_datablock_blocknumber(sb, b*8, gb_num);
    }
    if( charcount%8 == 0)
    {
      printf("|");
    }
    print_t_bin(datablockbitmap[b]);
    b++;
    charcount = charcount+8;
  }
  printf("\n%s", "+------------------------------------------------------------------------------+\n");
}

variable_types:
b
unsigned long long

variable_types:
bmax
unsigned int