decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er14
void *v4; // r13
__int64 *v5; // r15
__int128 *v6; // rbx
unsigned int i; // ebp
unsigned int v8; // ebx
int v9; // eax
int v10; // eax
__int64 v11; // rbp
unsigned int v12; // er12
pthread_t v13; // rdi
int *v15; // rax
char *v16; // rax
int *v17; // rax
char *v18; // rax
int *v19; // rax
char *v20; // rax
__int128 v21; // [rsp+0h] [rbp-2048h] BYREF
__int64 v22; // [rsp+10h] [rbp-2038h]
__int64 v23; // [rsp+60h] [rbp-1FE8h] BYREF
int v24; // [rsp+68h] [rbp-1FE0h]
int v25; // [rsp+6Ch] [rbp-1FDCh]
_DWORD v26[2000]; // [rsp+70h] [rbp-1FD8h] BYREF
pthread_mutex_t mutex; // [rsp+1FB0h] [rbp-98h] BYREF
pthread_cond_t cond; // [rsp+1FD8h] [rbp-70h] BYREF

memset(&zero_buf, 0, 0xA00uLL);
v21 = 0LL;
v22 = 0LL;
if ( argc != 2 )
{
printf("%s: <disk_name>\n", *argv);
return -1;
}
v25 = 0;
v26[1998] = 0;
memset(v26, 0, 0x1F38uLL);
v23 = 0LL;
v24 = 0;
pthread_mutex_init(&mutex, 0LL);
pthread_cond_init(&cond, 0LL);
v3 = open64(argv[1], 0, 0.0);
if ( v3 < 0 )
{
v19 = _errno_location();
v20 = strerror(*v19);
printf("%s: open error. %s\n", argv[1], v20);
return -1;
}
v4 = calloc(0x400000uLL, 1uLL);
if ( !v4 )
{
puts("malloc error");
return -1;
}
v5 = (__int64 *)&v21;
v6 = &v21;
for ( i = 0; i != 4; ++i )
{
*((_DWORD *)v6 + 2) = i;
*((_DWORD *)v6 + 3) = v3;
*((_QWORD *)v6 + 2) = &v23;
if ( pthread_create((pthread_t *)v6, 0LL, dump_file_thread, v6) < 0 )
{
v17 = _errno_location();
v18 = strerror(*v17);
printf("create thread %d error, %s\n", i, v18);
return -1;
}
v6 = (__int128 *)((char *)v6 + 24);
}
v8 = 850;
do
{
LABEL_8:
v9 = get_block_data(v3, v4, v8);
if ( v9 < 0 )
{
v15 = _errno_location();
v16 = strerror(*v15);
printf("%s read error, %s\n", "main", v16);
return -1;
}
v10 = v9 >> 12;
v11 = (__int64)v4;
v12 = v10 + v8;
}
while ( !v10 );
while ( 1 )
{
if ( !guess_dind_data(v11) )
{
printf("find a DIND %u\n", v8);
pthread_mutex_lock(&mutex);
if ( queue_full_isra_0(v24) )
pthread_cond_wait(&cond, &mutex);
enqueue_isra_0((__int64)&v23, v8);
pthread_mutex_unlock(&mutex);
}
++v8;
if ( __ROR4__(197912093 * v8, 5) <= 0xA7C5u )
break;
if ( v8 > 0x747097F )
goto LABEL_19;
LABEL_13:
v11 += 4096LL;
if ( v8 == v12 )
goto LABEL_8;
}
printf("Now Scan Block %u\n", v8);
if ( v8 <= 0x747097F )
goto LABEL_13;
LABEL_19:
is_finish = 1;
puts("\nScan IND_DATA Finish!!");
do
{
v13 = *v5;
v5 += 3;
pthread_join(v13, 0LL);
}
while ( v5 != &v23 );
close(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er14
void *v4; // r13
__int64 *v5; // r15
__int128 *v6; // rbx
unsigned int i; // ebp
unsigned int v8; // ebx
int v9; // eax
int v10; // eax
__int64 v11; // rbp
unsigned int v12; // er12
pthread_t v13; // rdi
int *v15; // rax
char *v16; // rax
int *v17; // rax
char *v18; // rax
int *v19; // rax
char *v20; // rax
__int128 v21; // [rsp+0h] [rbp-2048h] BYREF
__int64 v22; // [rsp+10h] [rbp-2038h]
__int64 v23; // [rsp+60h] [rbp-1FE8h] BYREF
int v24; // [rsp+68h] [rbp-1FE0h]
int v25; // [rsp+6Ch] [rbp-1FDCh]
_DWORD v26[2000]; // [rsp+70h] [rbp-1FD8h] BYREF
pthread_mutex_t mutex; // [rsp+1FB0h] [rbp-98h] BYREF
pthread_cond_t cond; // [rsp+1FD8h] [rbp-70h] BYREF

memset(&zero_buf, 0, 0xA00uLL);
v21 = 0LL;
v22 = 0LL;
if ( argc != 2 )
{
printf("%s: <disk_name>\n", *argv);
return -1;
}
v25 = 0;
v26[1998] = 0;
memset(v26, 0, 0x1F38uLL);
v23 = 0LL;
v24 = 0;
pthread_mutex_init(&mutex, 0LL);
pthread_cond_init(&cond, 0LL);
v3 = open64(argv[1], 0, 0.0);
if ( v3 < 0 )
{
v19 = _errno_location();
v20 = strerror(*v19);
printf("%s: open error. %s\n", argv[1], v20);
return -1;
}
v4 = calloc(0x400000uLL, 1uLL);
if ( !v4 )
{
puts("malloc error");
return -1;
}
v5 = (__int64 *)&v21;
v6 = &v21;
for ( i = 0; i != 4; ++i )
{
*((_DWORD *)v6 + 2) = i;
*((_DWORD *)v6 + 3) = v3;
*((_QWORD *)v6 + 2) = &v23;
if ( pthread_create((pthread_t *)v6, 0LL, dump_file_thread, v6) < 0 )
{
v17 = _errno_location();
v18 = strerror(*v17);
printf("create thread %d error, %s\n", i, v18);
return -1;
}
v6 = (__int128 *)((char *)v6 + 24);
}
v8 = 850;
do
{
LABEL_8:
v9 = func9(v3, v4, v8);
if ( v9 < 0 )
{
v15 = _errno_location();
v16 = strerror(*v15);
printf("%s read error, %s\n", "main", v16);
return -1;
}
v10 = v9 >> 12;
v11 = (__int64)v4;
v12 = v10 + v8;
}
while ( !v10 );
while ( 1 )
{
if ( !func6(v11) )
{
printf("find a DIND %u\n", v8);
pthread_mutex_lock(&mutex);
if ( func5(v24) )
pthread_cond_wait(&cond, &mutex);
func3((__int64)&v23, v8);
pthread_mutex_unlock(&mutex);
}
++v8;
if ( __ROR4__(197912093 * v8, 5) <= 0xA7C5u )
break;
if ( v8 > 0x747097F )
goto LABEL_19;
LABEL_13:
v11 += 4096LL;
if ( v8 == v12 )
goto LABEL_8;
}
printf("Now Scan Block %u\n", v8);
if ( v8 <= 0x747097F )
goto LABEL_13;
LABEL_19:
is_finish = 1;
puts("\nScan IND_DATA Finish!!");
do
{
v13 = *v5;
v5 += 3;
pthread_join(v13, 0LL);
}
while ( v5 != &v23 );
close(v3);
return 0;
}

original_code:
int main(int argc, char **argv)
{
 int fd = 0, ret, i;
 char *buf = ((void *)0), *p = ((void *)0);
 uint32_t next_block = 850;
 struct dump_thread_info dti[4];
 struct dumpdind_queue dindqueue;
 memset(zero_buf, 0, sizeof(zero_buf));
 memset(&dti, 0, sizeof(struct dump_thread_info));
 if (argc != 2) {
  printf("%s: <disk_name>\n", argv[0]);
  return -1;
 }
 memset(dindqueue.block_no, 0, sizeof(dindqueue.block_no));
 dindqueue.head = 0;
 dindqueue.tail = 0;
 dindqueue.size = 0;
 pthread_mutex_init(&dindqueue.mutex, ((void *)0));
 pthread_cond_init(&dindqueue.cond, ((void *)0));
 fd = open(argv[1], 00 | 0);
 if (fd < 0) {
  printf("%s: open error. %s\n", argv[1], strerror((*__errno_location ())));
  return -1;
 }
 buf = malloc((1024 * 1024 * 4));
 if (((void *)0) == buf) {
  printf("malloc error\n");
  return -1;
 }
 memset(buf, 0, (1024 * 1024 * 4));
 for (i = 0; i < 4; i ++) {
  dti[i].thread_num = i;
  dti[i].disk_fd = fd;
  dti[i].queue = &dindqueue;
  ret = pthread_create(&dti[i].thread_id, ((void *)0), dump_file_thread, &dti[i]);
  if (ret < 0) {
   printf("create thread %d error, %s\n", i, strerror((*__errno_location ())));
   return -1;
  }
 }
 while (1) {
  ret = get_block_data(fd, buf, next_block);
  if (ret < 0) {
   printf("%s read error, %s\n", __func__, strerror((*__errno_location ())));
   return -1;
  }
  for (i = 0; i < (ret / 4096); i ++) {
   p = buf + i * 4096;
   if (0 == guess_dind_data(p)) {
    printf("find a DIND %u\n", next_block);
    pthread_mutex_lock(&dindqueue.mutex);
    if (queue_full(&dindqueue)) {
     pthread_cond_wait(&dindqueue.cond, &dindqueue.mutex);
     enqueue(&dindqueue, next_block);
    } else {
     enqueue(&dindqueue, next_block);
    }
    pthread_mutex_unlock(&dindqueue.mutex);
   }
   next_block ++;
   if (! (next_block % 100000)) {
    printf("Now Scan Block %u\n", next_block);
   }
   if (next_block > 122095999)
    break;
  }
  if (next_block > 122095999) {
   is_finish = 1;
   printf("\nScan IND_DATA Finish!!\n");
   break;
  }
 }
 for (i = 0; i < 4; i ++) {
  pthread_join(dti[i].thread_id, ((void *)0));
 }
 close(fd);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 int fd = 0; int ret; int i;
 char *buf = ((void *)0); char *p = ((void *)0);
 unsigned int next_block = 850;
 struct dump_thread_info dti[4];
 struct dumpdind_queue dindqueue;
 memset(zero_buf, 0, sizeof(zero_buf));
 memset(&dti, 0, sizeof(struct dump_thread_info));
 if (argc != 2) {
  printf("%s: <disk_name>\n", argv[0]);
  return -1;
 }
 memset(dindqueue.block_no, 0, sizeof(dindqueue.block_no));
 dindqueue.head = 0;
 dindqueue.tail = 0;
 dindqueue.size = 0;
 pthread_mutex_init(&dindqueue.mutex, ((void *)0));
 pthread_cond_init(&dindqueue.cond, ((void *)0));
 fd = open(argv[1], 00 | 0);
 if (fd < 0) {
  printf("%s: open error. %s\n", argv[1], strerror((*__errno_location ())));
  return -1;
 }
 buf = malloc((1024 * 1024 * 4));
 if (((void *)0) == buf) {
  printf("malloc error\n");
  return -1;
 }
 memset(buf, 0, (1024 * 1024 * 4));
 for (i = 0; i < 4; i ++) {
  dti[i].thread_num = i;
  dti[i].disk_fd = fd;
  dti[i].queue = &dindqueue;
  ret = pthread_create(&dti[i].thread_id, ((void *)0), dump_file_thread, &dti[i]);
  if (ret < 0) {
   printf("create thread %d error, %s\n", i, strerror((*__errno_location ())));
   return -1;
  }
 }
 while (1) {
  ret = get_block_data(fd, buf, next_block);
  if (ret < 0) {
   printf("%s read error, %s\n", __func__, strerror((*__errno_location ())));
   return -1;
  }
  for (i = 0; i < (ret / 4096); i ++) {
   p = buf + i * 4096;
   if (0 == guess_dind_data(p)) {
    printf("find a DIND %u\n", next_block);
    pthread_mutex_lock(&dindqueue.mutex);
    if (queue_full(&dindqueue)) {
     pthread_cond_wait(&dindqueue.cond, &dindqueue.mutex);
     enqueue(&dindqueue, next_block);
    } else {
     enqueue(&dindqueue, next_block);
    }
    pthread_mutex_unlock(&dindqueue.mutex);
   }
   next_block ++;
   if (! (next_block % 100000)) {
    printf("Now Scan Block %u\n", next_block);
   }
   if (next_block > 122095999)
    break;
  }
  if (next_block > 122095999) {
   is_finish = 1;
   printf("\nScan IND_DATA Finish!!\n");
   break;
  }
 }
 for (i = 0; i < 4; i ++) {
  pthread_join(dti[i].thread_id, ((void *)0));
 }
 close(fd);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
buf
char *

variable_types: struct dump_thread_info { unsigned long thread_id; int thread_num; int disk_fd; struct dumpdind_queue { int head; int tail; int size; unsigned int block_no[2000]; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; } *queue; } [4]

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

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


decompiled_code:
__int64 __fastcall PTR_ERR(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code:
static inline long PTR_ERR(const void *ptr)
{
 return (long) ptr;
}

canonical_original_code:
static inline long PTR_ERR(void *ptr)
{
 return (long) ptr;
}

variable_types:
ptr
void *

return_type: long


decompiled_code:
_BOOL8 __fastcall IS_ERR(unsigned __int64 a1)
{
return a1 > 0xFFFFFFFFFFFFF000LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int64 a1)
{
return a1 > 0xFFFFFFFFFFFFF000LL;
}

original_code:
static inline long IS_ERR(const void *ptr)
{
 return (((unsigned long)ptr) >= (unsigned long)-4095);
}

canonical_original_code:
static inline long IS_ERR(void *ptr)
{
 return (((unsigned long)ptr) >= (unsigned long)-4095);
}


decompiled_code:
__int64 __fastcall vbfs_create_obj(char *s, unsigned int a2)
{
char *v2; // rax
char *v3; // rbp
char *v4; // rdi
__int64 v5; // r12
unsigned int v6; // er13
char v8[464]; // [rsp+0h] [rbp-208h] BYREF
__int16 v9; // [rsp+1D0h] [rbp-38h]

memset(v8, 0, sizeof(v8));
v9 = 0;
v2 = strdup(s);
if ( !v2 )
return (unsigned int)-12;
v3 = v2;
v4 = v2;
if ( (unsigned int)get_lastname(v2, v8, 47LL) )
{
free(v4);
v6 = -22;
}
else if ( v8[0] )
{
v5 = pathname_to_inode(v4);
free(v3);
if ( IS_ERR(v5) )
{
v6 = PTR_ERR(v5);
}
else
{
v6 = vbfs_create(v5, v8, a2);
if ( !v6 )
vbfs_update_times(v5, 3LL);
vbfs_inode_close(v5);
}
}
else
{
free(v4);
v6 = -17;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *s, unsigned int a2)
{
char *v2; // rax
char *v3; // rbp
char *v4; // rdi
__int64 v5; // r12
unsigned int v6; // er13
char v8[464]; // [rsp+0h] [rbp-208h] BYREF
__int16 v9; // [rsp+1D0h] [rbp-38h]

memset(v8, 0, sizeof(v8));
v9 = 0;
v2 = strdup(s);
if ( !v2 )
return (unsigned int)-12;
v3 = v2;
v4 = v2;
if ( (unsigned int)get_lastname(v2, v8, 47LL) )
{
free(v4);
v6 = -22;
}
else if ( v8[0] )
{
v5 = pathname_to_inode(v4);
free(v3);
if ( func1(v5) )
{
v6 = func0(v5);
}
else
{
v6 = vbfs_create(v5, v8, a2);
if ( !v6 )
vbfs_update_times(v5, 3LL);
vbfs_inode_close(v5);
}
}
else
{
free(v4);
v6 = -17;
}
return v6;
}

original_code:
static int vbfs_create_obj(const char *path, uint32_t mode)
{
 int ret;
 struct inode_info *inode;
 char last_name[466];
 char *name = ((void *)0);
 char *pos = ((void *)0);
 memset(last_name, 0, sizeof(last_name));
 name = strdup(path);
 if (((void *)0) == name)
  return -12;
 pos = name;
 ret = get_lastname(pos, last_name, '/');
 if (ret) {
  free(name);
  return -22;
 }
 if (strlen(last_name) == 0) {
  free(name);
  return -17;
 }
 inode = pathname_to_inode(pos);
 free(name);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_create(inode, last_name, mode);
 if (ret) {
  vbfs_inode_close(inode);
  return ret;
 }
 vbfs_update_times(inode, UPDATE_ATIME | UPDATE_MTIME);
 vbfs_inode_close(inode);
 return 0;
}

canonical_original_code:
static int vbfs_create_obj(char *path, unsigned int mode)
{
 int ret;
 struct inode_info *inode;
 char last_name[466];
 char *name = ((void *)0);
 char *pos = ((void *)0);
 memset(last_name, 0, sizeof(last_name));
 name = strdup(path);
 if (((void *)0) == name)
  return -12;
 pos = name;
 ret = get_lastname(pos, last_name, '/');
 if (ret) {
  free(name);
  return -22;
 }
 if (strlen(last_name) == 0) {
  free(name);
  return -17;
 }
 inode = pathname_to_inode(pos);
 free(name);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_create(inode, last_name, mode);
 if (ret) {
  vbfs_inode_close(inode);
  return ret;
 }
 vbfs_update_times(inode, UPDATE_ATIME | UPDATE_MTIME);
 vbfs_inode_close(inode);
 return 0;
}

variable_types:
path
char *

variable_types:
mode
unsigned int

variable_types: ret int

variable_types: struct inode_info { struct vbfs_dirent { unsigned int i_ino; unsigned int i_pino; unsigned int i_mode; unsigned long i_size; unsigned int i_atime; unsigned int i_ctime; unsigned int i_mtime; char name[466]; } *dirent; unsigned int data_no; unsigned int position; int status; unsigned int flags; int ref; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; struct hlist_node { struct hlist_node *next; } hash_list; struct list_head { struct list_head *next; } active_list; struct list_head extend_list; } *

variable_types:
name
char *

variable_types:
pos
char *

return_type: int

user_defined_types: struct inode_info { struct vbfs_dirent *dirent; unsigned int data_no; unsigned int position; int status; unsigned int flags; int ref; union pthread_mutex_t lock; struct hlist_node hash_list; struct list_head active_list; struct list_head extend_list; }


decompiled_code:
__int64 __fastcall vbfs_fuse_unlink(const char *a1)
{
__int64 v1; // rdi
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_unlink %s\n", "vbfs_fuse_unlink", 242LL, a1);
v1 = pathname_to_inode(a1);
if ( IS_ERR(v1) )
result = PTR_ERR(v1);
else
result = vbfs_unlink();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(const char *a1)
{
__int64 v1; // rdi
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_unlink %s\n", "vbfs_fuse_unlink", 242LL, a1);
v1 = pathname_to_inode(a1);
if ( func1(v1) )
result = func0(v1);
else
result = vbfs_unlink();
return result;
}

original_code:
static int vbfs_fuse_unlink(const char *path)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_unlink %s\n", __FUNCTION__, 242, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_unlink(inode);
 return ret;
}

canonical_original_code:
static int vbfs_fuse_unlink(char *path)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_unlink %s\n", __FUNCTION__, 242, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_unlink(inode);
 return ret;
}

user_defined_types: struct hlist_node { struct hlist_node *next; }

user_defined_types: struct list_head { struct list_head *next; }

user_defined_types: struct vbfs_dirent { unsigned int i_ino; unsigned int i_pino; unsigned int i_mode; unsigned long i_size; unsigned int i_atime; unsigned int i_ctime; unsigned int i_mtime; char name[466]; }

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


decompiled_code:
__int64 vbfs_fuse_access()
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_access\n", "vbfs_fuse_access", 106LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_access\n", "vbfs_fuse_access", 106LL);
return 0LL;
}

original_code:
static int vbfs_fuse_access(const char *path, int mode)
{
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_access\n", __FUNCTION__, 106); } while(0);
 return 0;
}

canonical_original_code:
static int vbfs_fuse_access(char *path, int mode)
{
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_access\n", __FUNCTION__, 106); } while(0);
 return 0;
}

variable_types: mode int


decompiled_code:
__int64 __fastcall vbfs_fuse_statfs(const char *a1)
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_statfs %s\n", "vbfs_fuse_statfs", 394LL, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_statfs %s\n", "vbfs_fuse_statfs", 394LL, a1);
return 0LL;
}

original_code:
static int vbfs_fuse_statfs(const char *path, struct statvfs *stbuf)
{
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_statfs %s\n", __FUNCTION__, 394, path); } while(0);
 return 0;
}

canonical_original_code:
static int vbfs_fuse_statfs(char *path, struct statvfs *stbuf)
{
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_statfs %s\n", __FUNCTION__, 394, path); } while(0);
 return 0;
}

variable_types: struct statvfs { unsigned long f_bsize; unsigned long f_frsize; unsigned long f_blocks; unsigned long f_bfree; unsigned long f_bavail; unsigned long f_files; unsigned long f_ffree; unsigned long f_favail; unsigned long f_fsid; unsigned long f_flag; unsigned long f_namemax; int __f_spare[6]; } *


decompiled_code:
__int64 __fastcall vbfs_fuse_fgetattr(const char *a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rax

if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_fgetattr %s\n", "vbfs_fuse_fgetattr", 94LL, a1);
v4 = *(_QWORD **)(a3 + 24);
if ( !v4 )
return 0LL;
}
else
{
v4 = *(_QWORD **)(a3 + 24);
if ( !v4 )
return 0LL;
}
fill_stbuf_by_dirent(a2, *v4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rax

if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_fgetattr %s\n", "vbfs_fuse_fgetattr", 94LL, a1);
v4 = *(_QWORD **)(a3 + 24);
if ( !v4 )
return 0LL;
}
else
{
v4 = *(_QWORD **)(a3 + 24);
if ( !v4 )
return 0LL;
}
fill_stbuf_by_dirent(a2, *v4);
return 0LL;
}

original_code:
static int vbfs_fuse_fgetattr(const char *path, struct stat *stbuf,
    struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_fgetattr %s\n", __FUNCTION__, 94, path); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  fill_stbuf_by_dirent(stbuf, inode->dirent);
 }
 return ret;
}

canonical_original_code:
static int vbfs_fuse_fgetattr(char *path, struct stat *stbuf, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_fgetattr %s\n", __FUNCTION__, 94, path); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  fill_stbuf_by_dirent(stbuf, inode->dirent);
 }
 return ret;
}

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

variable_types: struct fuse_file_info { int flags; unsigned long fh_old; int writepage; unsigned int direct_io; unsigned int keep_cache; unsigned int flush; unsigned int nonseekable; unsigned int flock_release; unsigned int padding; unsigned long fh; unsigned long lock_owner; } *

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


decompiled_code:
__int64 __fastcall vbfs_fuse_ftruncate(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdi
__int64 result; // rax

if ( !is_debug )
{
v4 = *(_QWORD *)(a3 + 24);
result = 0LL;
if ( !v4 )
return result;
return (unsigned int)-((unsigned int)vbfs_truncate(v4, a2) != 0);
}
log_debug("%s(%d) vbfs_fuse_ftruncate\n", "vbfs_fuse_ftruncate", 296LL);
v4 = *(_QWORD *)(a3 + 24);
result = 0LL;
if ( v4 )
return (unsigned int)-((unsigned int)vbfs_truncate(v4, a2) != 0);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdi
__int64 result; // rax

if ( !is_debug )
{
v4 = *(_QWORD *)(a3 + 24);
result = 0LL;
if ( !v4 )
return result;
return (unsigned int)-((unsigned int)vbfs_truncate(v4, a2) != 0);
}
log_debug("%s(%d) vbfs_fuse_ftruncate\n", "vbfs_fuse_ftruncate", 296LL);
v4 = *(_QWORD *)(a3 + 24);
result = 0LL;
if ( v4 )
return (unsigned int)-((unsigned int)vbfs_truncate(v4, a2) != 0);
return result;
}

original_code:
static int vbfs_fuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_ftruncate\n", __FUNCTION__, 296); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_truncate(inode, size);
  if (ret)
   return -1;
 }
 return 0;
}

canonical_original_code:
static int vbfs_fuse_ftruncate(char *path, long size, struct fuse_file_info *fi)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_ftruncate\n", __FUNCTION__, 296); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_truncate(inode, size);
  if (ret)
   return -1;
 }
 return 0;
}

variable_types: size long

user_defined_types: struct fuse_file_info { int flags; unsigned long fh_old; int writepage; unsigned int direct_io; unsigned int keep_cache; unsigned int flush; unsigned int nonseekable; unsigned int flock_release; unsigned int padding; unsigned long fh; unsigned long lock_owner; }


decompiled_code:
__int64 __fastcall vbfs_fuse_opendir(const char *a1, __int64 a2)
{
__int64 v2; // rdi

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_opendir %s\n", "vbfs_fuse_opendir", 115LL, a1);
v2 = pathname_to_inode(a1);
if ( IS_ERR(v2) )
return PTR_ERR(v2);
*(_QWORD *)(a2 + 24) = v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1, __int64 a2)
{
__int64 v2; // rdi

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_opendir %s\n", "vbfs_fuse_opendir", 115LL, a1);
v2 = pathname_to_inode(a1);
if ( func1(v2) )
return func0(v2);
*(_QWORD *)(a2 + 24) = v2;
return 0LL;
}

original_code:
static int vbfs_fuse_opendir(const char *path, struct fuse_file_info *fi)
{
 struct inode_info *inode = ((void *)0);
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_opendir %s\n", __FUNCTION__, 115, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 fi->fh = (uint64_t) inode;
 return 0;
}

canonical_original_code:
static int vbfs_fuse_opendir(char *path, struct fuse_file_info *fi)
{
 struct inode_info *inode = ((void *)0);
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_opendir %s\n", __FUNCTION__, 115, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 fi->fh = (unsigned long) inode;
 return 0;
}


decompiled_code:
__int64 __fastcall vbfs_fuse_releasedir(const char *a1, __int64 a2)
{
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_releasedir %s\n", "vbfs_fuse_releasedir", 149LL, a1);
if ( *(_QWORD *)(a2 + 24) )
{
vbfs_inode_close();
result = 0LL;
}
else
{
log_error("%s(%d) BUG", "vbfs_fuse_releasedir", 152LL);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, __int64 a2)
{
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_releasedir %s\n", "vbfs_fuse_releasedir", 149LL, a1);
if ( *(_QWORD *)(a2 + 24) )
{
vbfs_inode_close();
result = 0LL;
}
else
{
log_error("%s(%d) BUG", "vbfs_fuse_releasedir", 152LL);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int vbfs_fuse_releasedir(const char *path, struct fuse_file_info *fi)
{
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_releasedir %s\n", __FUNCTION__, 149, path); } while(0);
 if (! fi->fh) {
  do { log_error("%s(%d) " "BUG", __FUNCTION__, 152); } while(0);
  return -1;
 }
 inode = (struct inode_info *) fi->fh;
 vbfs_inode_close(inode);
 return 0;
}

canonical_original_code:
static int vbfs_fuse_releasedir(char *path, struct fuse_file_info *fi)
{
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_releasedir %s\n", __FUNCTION__, 149, path); } while(0);
 if (! fi->fh) {
  do { log_error("%s(%d) " "BUG", __FUNCTION__, 152); } while(0);
  return -1;
 }
 inode = (struct inode_info *) fi->fh;
 vbfs_inode_close(inode);
 return 0;
}


decompiled_code:
__int64 __fastcall vbfs_fuse_release(const char *a1, __int64 a2)
{
if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_release %s\n", "vbfs_fuse_release", 420LL, a1);
if ( !*(_QWORD *)(a2 + 24) )
return 0LL;
}
else if ( !*(_QWORD *)(a2 + 24) )
{
return 0LL;
}
return vbfs_inode_close();
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1, __int64 a2)
{
if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_release %s\n", "vbfs_fuse_release", 420LL, a1);
if ( !*(_QWORD *)(a2 + 24) )
return 0LL;
}
else if ( !*(_QWORD *)(a2 + 24) )
{
return 0LL;
}
return vbfs_inode_close();
}

original_code:
static int vbfs_fuse_release(const char *path, struct fuse_file_info *fi)
{
 struct inode_info *inode;
 int ret = 0;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_release %s\n", __FUNCTION__, 420, path); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_inode_close(inode);
  if (ret)
   return ret;
 }
 return 0;
}

canonical_original_code:
static int vbfs_fuse_release(char *path, struct fuse_file_info *fi)
{
 struct inode_info *inode;
 int ret = 0;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_release %s\n", __FUNCTION__, 420, path); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_inode_close(inode);
  if (ret)
   return ret;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall vbfs_fuse_truncate(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
int v4; // er12

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_truncate\n", "vbfs_fuse_truncate", 277LL);
v2 = pathname_to_inode(a1);
if ( IS_ERR(v2) )
return PTR_ERR(v2);
v4 = vbfs_truncate(v2, a2);
vbfs_inode_close(v2);
return (unsigned int)-(v4 != 0);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
int v4; // er12

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_truncate\n", "vbfs_fuse_truncate", 277LL);
v2 = pathname_to_inode(a1);
if ( func1(v2) )
return func0(v2);
v4 = vbfs_truncate(v2, a2);
vbfs_inode_close(v2);
return (unsigned int)-(v4 != 0);
}

original_code:
static int vbfs_fuse_truncate(const char *path, off_t size)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_truncate\n", __FUNCTION__, 277); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_truncate(inode, size);
 vbfs_inode_close(inode);
 if (ret)
  return -1;
 return 0;
}

canonical_original_code:
static int vbfs_fuse_truncate(char *path, long size)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_truncate\n", __FUNCTION__, 277); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_truncate(inode, size);
 vbfs_inode_close(inode);
 if (ret)
  return -1;
 return 0;
}


decompiled_code:
__int64 __fastcall vbfs_fuse_getattr(const char *a1, __int64 a2)
{
_QWORD *v2; // rdi

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_getattr %s\n", "vbfs_fuse_getattr", 75LL, a1);
v2 = (_QWORD *)pathname_to_inode(a1);
if ( IS_ERR((unsigned __int64)v2) )
return PTR_ERR((__int64)v2);
fill_stbuf_by_dirent(a2, *v2);
vbfs_inode_close(v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(const char *a1, __int64 a2)
{
_QWORD *v2; // rdi

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_getattr %s\n", "vbfs_fuse_getattr", 75LL, a1);
v2 = (_QWORD *)pathname_to_inode(a1);
if ( func1((unsigned __int64)v2) )
return func0((__int64)v2);
fill_stbuf_by_dirent(a2, *v2);
vbfs_inode_close(v2);
return 0LL;
}

original_code:
static int vbfs_fuse_getattr(const char *path, struct stat *stbuf)
{
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_getattr %s\n", __FUNCTION__, 75, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 fill_stbuf_by_dirent(stbuf, inode->dirent);
 vbfs_inode_close(inode);
 return 0;
}

canonical_original_code:
static int vbfs_fuse_getattr(char *path, struct stat *stbuf)
{
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_getattr %s\n", __FUNCTION__, 75, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 fill_stbuf_by_dirent(stbuf, inode->dirent);
 vbfs_inode_close(inode);
 return 0;
}

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
__int64 __fastcall vbfs_fuse_create(char *s, __int64 a2, __int64 a3)
{
unsigned int v4; // er12
__int64 result; // rax
__int64 v6; // rdi

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_create %s\n", "vbfs_fuse_create", 345LL, s);
v4 = vbfs_create_obj(s, 1u);
if ( v4 )
return v4;
v6 = pathname_to_inode(s);
if ( IS_ERR(v6) )
return (unsigned int)PTR_ERR(v6);
result = 0LL;
*(_QWORD *)(a3 + 24) = v6;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(char *s, __int64 a2, __int64 a3)
{
unsigned int v4; // er12
__int64 result; // rax
__int64 v6; // rdi

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_create %s\n", "vbfs_fuse_create", 345LL, s);
v4 = func11(s, 1u);
if ( v4 )
return v4;
v6 = pathname_to_inode(s);
if ( func1(v6) )
return (unsigned int)func0(v6);
result = 0LL;
*(_QWORD *)(a3 + 24) = v6;
return result;
}

original_code:
static int vbfs_fuse_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_create %s\n", __FUNCTION__, 345, path); } while(0);
 ret = vbfs_create_obj(path, VBFS_FT_REG_FILE);
 if (ret)
  return ret;
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 fi->fh = (uint64_t) inode;
 return 0;
}

canonical_original_code:
static int vbfs_fuse_create(char *path, unsigned int mode, struct fuse_file_info *fi)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_create %s\n", __FUNCTION__, 345, path); } while(0);
 ret = vbfs_create_obj(path, VBFS_FT_REG_FILE);
 if (ret)
  return ret;
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 fi->fh = (unsigned long) inode;
 return 0;
}


decompiled_code:
__int64 __fastcall vbfs_fuse_open(char *s, __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_open %s\n", "vbfs_fuse_open", 315LL, s);
v3 = pathname_to_inode(s);
if ( !IS_ERR(v3) || (result = PTR_ERR(v3), (_DWORD)result != -2) )
{
LABEL_5:
*(_QWORD *)(a2 + 24) = v3;
return 0LL;
}
if ( (*(_BYTE *)a2 & 0x40) != 0 )
{
result = vbfs_create_obj(s, 1u);
if ( !(_DWORD)result )
{
v3 = pathname_to_inode(s);
if ( IS_ERR(v3) )
return PTR_ERR(v3);
goto LABEL_5;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(char *s, __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_open %s\n", "vbfs_fuse_open", 315LL, s);
v3 = pathname_to_inode(s);
if ( !func1(v3) || (result = func0(v3), (_DWORD)result != -2) )
{
LABEL_5:
*(_QWORD *)(a2 + 24) = v3;
return 0LL;
}
if ( (*(_BYTE *)a2 & 0x40) != 0 )
{
result = func11(s, 1u);
if ( !(_DWORD)result )
{
v3 = pathname_to_inode(s);
if ( func1(v3) )
return func0(v3);
goto LABEL_5;
}
}
return result;
}

original_code:
static int vbfs_fuse_open(const char *path, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_open %s\n", __FUNCTION__, 315, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  ret = PTR_ERR(inode);
 if (-2 == ret) {
  if (fi->flags & 0100) {
   ret = vbfs_create_obj(path, VBFS_FT_REG_FILE);
   if (ret)
    return ret;
   inode = pathname_to_inode(path);
   if (IS_ERR(inode))
    return PTR_ERR(inode);
  } else
   return ret;
 }
 fi->fh = (uint64_t) inode;
 return 0;
}

canonical_original_code:
static int vbfs_fuse_open(char *path, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_open %s\n", __FUNCTION__, 315, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  ret = PTR_ERR(inode);
 if (-2 == ret) {
  if (fi->flags & 0100) {
   ret = vbfs_create_obj(path, VBFS_FT_REG_FILE);
   if (ret)
    return ret;
   inode = pathname_to_inode(path);
   if (IS_ERR(inode))
    return PTR_ERR(inode);
  } else
   return ret;
 }
 fi->fh = (unsigned long) inode;
 return 0;
}


decompiled_code:
__int64 __fastcall vbfs_fuse_mkdir(char *s)
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_mkdir %s\n", "vbfs_fuse_mkdir", 208LL, s);
return vbfs_create_obj(s, 2u);
}

canonical_decompiled_code:
__int64 __fastcall func14(char *s)
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_mkdir %s\n", "vbfs_fuse_mkdir", 208LL, s);
return func11(s, 2u);
}

original_code:
static int vbfs_fuse_mkdir(const char *path, mode_t mode)
{
 int ret;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_mkdir %s\n", __FUNCTION__, 208, path); } while(0);
 ret = vbfs_create_obj(path, VBFS_FT_DIR);
 return ret;
}

canonical_original_code:
static int vbfs_fuse_mkdir(char *path, unsigned int mode)
{
 int ret;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_mkdir %s\n", __FUNCTION__, 208, path); } while(0);
 ret = vbfs_create_obj(path, VBFS_FT_DIR);
 return ret;
}


decompiled_code:
__int64 vbfs_fuse_destroy()
{
__int64 v0; // rax
__int64 v1; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_destroy\n", "vbfs_fuse_destroy", 451LL);
v0 = get_meta_queue();
queue_destroy(v0);
v1 = get_data_queue();
queue_destroy(v1);
(*(void (**)(void))(ioengine + 16LL))();
super_umount_clean();
return log_close();
}

canonical_decompiled_code:
__int64 func15()
{
__int64 v0; // rax
__int64 v1; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_destroy\n", "vbfs_fuse_destroy", 451LL);
v0 = get_meta_queue();
queue_destroy(v0);
v1 = get_data_queue();
queue_destroy(v1);
(*(void (**)(void))(ioengine + 16LL))();
super_umount_clean();
return log_close();
}

original_code:
static void vbfs_fuse_destroy(void *data)
{
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_destroy\n", __FUNCTION__, 451); } while(0);
 queue_destroy(get_meta_queue());
 queue_destroy(get_data_queue());
 ioengine->io_exit();
 super_umount_clean();
 log_close();
}

variable_types:
data
void *

return_type: void


decompiled_code:
__int64 vbfs_fuse_init()
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_init\n", "vbfs_fuse_init", 466LL);
if ( (unsigned int)meta_queue_create() )
{
log_error("%s(%d) meta queue create error\n", "vbfs_fuse_init", 470LL);
exit(1);
}
if ( (unsigned int)data_queue_create() )
{
log_error("%s(%d) data queue create error\n", "vbfs_fuse_init", 476LL);
exit(1);
}
if ( (*(unsigned int (**)(void))(ioengine + 8LL))() )
{
log_error("%s(%d) io thread init error\n", "vbfs_fuse_init", 482LL);
exit(1);
}
if ( (int)init_root_inode() < 0 )
{
log_error("%s(%d) root inode init error\n", "vbfs_fuse_init", 488LL);
exit(1);
}
sync_super();
return 0LL;
}

canonical_decompiled_code:
__int64 func16()
{
if ( is_debug )
log_debug("%s(%d) vbfs_fuse_init\n", "vbfs_fuse_init", 466LL);
if ( (unsigned int)meta_queue_create() )
{
log_error("%s(%d) meta queue create error\n", "vbfs_fuse_init", 470LL);
exit(1);
}
if ( (unsigned int)data_queue_create() )
{
log_error("%s(%d) data queue create error\n", "vbfs_fuse_init", 476LL);
exit(1);
}
if ( (*(unsigned int (**)(void))(ioengine + 8LL))() )
{
log_error("%s(%d) io thread init error\n", "vbfs_fuse_init", 482LL);
exit(1);
}
if ( (int)init_root_inode() < 0 )
{
log_error("%s(%d) root inode init error\n", "vbfs_fuse_init", 488LL);
exit(1);
}
sync_super();
return 0LL;
}

original_code:
static void *vbfs_fuse_init(struct fuse_conn_info *conn)
{
 int ret;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_init\n", __FUNCTION__, 466); } while(0);
 ret = meta_queue_create();
 if (ret) {
  do { log_error("%s(%d) " "meta queue create error\n", __FUNCTION__, 470); } while(0);
  exit(1);
 }
 ret = data_queue_create();
 if (ret) {
  do { log_error("%s(%d) " "data queue create error\n", __FUNCTION__, 476); } while(0);
  exit(1);
 }
 ret = ioengine->io_init();
 if (ret) {
  do { log_error("%s(%d) " "io thread init error\n", __FUNCTION__, 482); } while(0);
  exit(1);
 }
 ret = init_root_inode();
 if (ret < 0) {
  do { log_error("%s(%d) " "root inode init error\n", __FUNCTION__, 488); } while(0);
  exit(1);
 }
 sync_super();
 return ((void *)0);
}

variable_types: struct fuse_conn_info { unsigned int proto_major; unsigned int proto_minor; unsigned int async_read; unsigned int max_write; unsigned int max_readahead; unsigned int capable; unsigned int want; unsigned int max_background; unsigned int congestion_threshold; unsigned int reserved[23]; } *

return_type: void *


decompiled_code:
__int64 __fastcall vbfs_fuse_readdir(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v8; // r14
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_readdir %s\n", "vbfs_fuse_readdir", 131LL, a1);
v8 = *(_QWORD *)(a5 + 24);
if ( v8 )
{
vbfs_readdir(*(_QWORD *)(a5 + 24), a4, a3, a2);
vbfs_update_times(v8, 1LL);
result = 0LL;
}
else
{
log_error("%s(%d) BUG", "vbfs_fuse_readdir", 134LL);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v8; // r14
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_readdir %s\n", "vbfs_fuse_readdir", 131LL, a1);
v8 = *(_QWORD *)(a5 + 24);
if ( v8 )
{
vbfs_readdir(*(_QWORD *)(a5 + 24), a4, a3, a2);
vbfs_update_times(v8, 1LL);
result = 0LL;
}
else
{
log_error("%s(%d) BUG", "vbfs_fuse_readdir", 134LL);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int vbfs_fuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
    off_t offset, struct fuse_file_info *fi)
{
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_readdir %s\n", __FUNCTION__, 131, path); } while(0);
 if (! fi->fh) {
  do { log_error("%s(%d) " "BUG", __FUNCTION__, 134); } while(0);
  return -1;
 }
 inode = (struct inode_info *) fi->fh;
 vbfs_readdir(inode, offset, filler, buf);
 vbfs_update_times(inode, UPDATE_ATIME);
 return 0;
}

canonical_original_code:
static int vbfs_fuse_readdir(char *path, void *buf, int (*filler)(void *buf, char *name, struct stat *stbuf, long off), long offset, struct fuse_file_info *fi)
{
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_readdir %s\n", __FUNCTION__, 131, path); } while(0);
 if (! fi->fh) {
  do { log_error("%s(%d) " "BUG", __FUNCTION__, 134); } while(0);
  return -1;
 }
 inode = (struct inode_info *) fi->fh;
 vbfs_readdir(inode, offset, filler, buf);
 vbfs_update_times(inode, UPDATE_ATIME);
 return 0;
}

variable_types:
buf
void *

variable_types: int (*)(void *buf, char *name, struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; } *stbuf, long off)

variable_types: offset long


decompiled_code:
__int64 __fastcall vbfs_fuse_fsync(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp

if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_fsync\n", "vbfs_fuse_fsync", 438LL);
v4 = *(_QWORD *)(a3 + 24);
if ( !v4 )
return 0LL;
}
else
{
v4 = *(_QWORD *)(a3 + 24);
if ( !v4 )
return 0LL;
}
vbfs_update_times(v4, 3LL);
return sync_file(v4);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp

if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_fsync\n", "vbfs_fuse_fsync", 438LL);
v4 = *(_QWORD *)(a3 + 24);
if ( !v4 )
return 0LL;
}
else
{
v4 = *(_QWORD *)(a3 + 24);
if ( !v4 )
return 0LL;
}
vbfs_update_times(v4, 3LL);
return sync_file(v4);
}

original_code:
static int vbfs_fuse_fsync(const char *path, int isdatasync, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_fsync\n", __FUNCTION__, 438); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  vbfs_update_times(inode, UPDATE_ATIME | UPDATE_MTIME);
  ret = sync_file(inode);
 }
 return ret;
}

canonical_original_code:
static int vbfs_fuse_fsync(char *path, int isdatasync, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_fsync\n", __FUNCTION__, 438); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  vbfs_update_times(inode, UPDATE_ATIME | UPDATE_MTIME);
  ret = sync_file(inode);
 }
 return ret;
}

variable_types: isdatasync int


decompiled_code:
__int64 __fastcall vbfs_fuse_flush(const char *a1, __int64 a2)
{
__int64 v2; // rbp

if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_flush %s\n", "vbfs_fuse_flush", 404LL, a1);
v2 = *(_QWORD *)(a2 + 24);
if ( !v2 )
return 0LL;
}
else
{
v2 = *(_QWORD *)(a2 + 24);
if ( !v2 )
return 0LL;
}
vbfs_update_times(v2, 3LL);
return sync_file(v2);
}

canonical_decompiled_code:
__int64 __fastcall func19(const char *a1, __int64 a2)
{
__int64 v2; // rbp

if ( is_debug )
{
log_debug("%s(%d) vbfs_fuse_flush %s\n", "vbfs_fuse_flush", 404LL, a1);
v2 = *(_QWORD *)(a2 + 24);
if ( !v2 )
return 0LL;
}
else
{
v2 = *(_QWORD *)(a2 + 24);
if ( !v2 )
return 0LL;
}
vbfs_update_times(v2, 3LL);
return sync_file(v2);
}

original_code:
static int vbfs_fuse_flush(const char *path, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_flush %s\n", __FUNCTION__, 404, path); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  vbfs_update_times(inode, UPDATE_ATIME | UPDATE_MTIME);
  ret = sync_file(inode);
 }
 return ret;
}

canonical_original_code:
static int vbfs_fuse_flush(char *path, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_flush %s\n", __FUNCTION__, 404, path); } while(0);
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  vbfs_update_times(inode, UPDATE_ATIME | UPDATE_MTIME);
  ret = sync_file(inode);
 }
 return ret;
}

variable_types:
path
char *


decompiled_code:
__int64 __fastcall vbfs_fuse_write(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( *(_QWORD *)(a5 + 24) )
result = vbfs_write_buf();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( *(_QWORD *)(a5 + 24) )
result = vbfs_write_buf();
else
result = 0LL;
return result;
}

original_code:
static int vbfs_fuse_write(const char *path, const char *buf, size_t size, off_t offset,
    struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_write_buf(inode, buf, size, offset);
 }
 return ret;
}

canonical_original_code:
static int vbfs_fuse_write(char *path, char *buf, unsigned long size, long offset, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_write_buf(inode, buf, size, offset);
 }
 return ret;
}

variable_types:
buf
char *

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall vbfs_fuse_read(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( *(_QWORD *)(a5 + 24) )
result = vbfs_read_buf();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( *(_QWORD *)(a5 + 24) )
result = vbfs_read_buf();
else
result = 0LL;
return result;
}

original_code:
static int vbfs_fuse_read(const char *path, char *buf, size_t size, off_t offset,
    struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_read_buf(inode, buf, size, offset);
 }
 return ret;
}

canonical_original_code:
static int vbfs_fuse_read(char *path, char *buf, unsigned long size, long offset, struct fuse_file_info *fi)
{
 int ret = 0;
 struct inode_info *inode;
 if (fi->fh) {
  inode = (struct inode_info *) fi->fh;
  ret = vbfs_read_buf(inode, buf, size, offset);
 }
 return ret;
}

variable_types: ret int

variable_types: struct inode_info { struct vbfs_dirent { unsigned int i_ino; unsigned int i_pino; unsigned int i_mode; unsigned long i_size; unsigned int i_atime; unsigned int i_ctime; unsigned int i_mtime; char name[466]; } *dirent; unsigned int data_no; unsigned int position; int status; unsigned int flags; int ref; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; struct hlist_node { struct hlist_node *next; } hash_list; struct list_head { struct list_head *next; } active_list; struct list_head extend_list; } *


decompiled_code:
__int64 __fastcall vbfs_fuse_rename(const char *a1, const char *a2)
{
__int64 v2; // rdi
unsigned int v4; // er12

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_rename from %s, to %s\n", "vbfs_fuse_rename", 258LL, a1, a2);
v2 = pathname_to_inode(a1);
if ( IS_ERR(v2) )
return (unsigned int)PTR_ERR(v2);
v4 = vbfs_rename(v2, a2);
vbfs_inode_close(v2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func22(const char *a1, const char *a2)
{
__int64 v2; // rdi
unsigned int v4; // er12

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_rename from %s, to %s\n", "vbfs_fuse_rename", 258LL, a1, a2);
v2 = pathname_to_inode(a1);
if ( func1(v2) )
return (unsigned int)func0(v2);
v4 = vbfs_rename(v2, a2);
vbfs_inode_close(v2);
return v4;
}

original_code:
static int vbfs_fuse_rename(const char *from, const char *to)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_rename from %s, to %s\n", __FUNCTION__, 258, from, to); } while(0);
 inode = pathname_to_inode(from);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_rename(inode, to);
 vbfs_inode_close(inode);
 if (ret)
  return ret;
 return 0;
}

canonical_original_code:
static int vbfs_fuse_rename(char *from, char *to)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_rename from %s, to %s\n", __FUNCTION__, 258, from, to); } while(0);
 inode = pathname_to_inode(from);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_rename(inode, to);
 vbfs_inode_close(inode);
 if (ret)
  return ret;
 return 0;
}

variable_types:
from
char *

variable_types:
to
char *


decompiled_code:
__int64 __fastcall vbfs_fuse_rmdir(const char *a1)
{
__int64 v1; // rdi
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_rmdir %s\n", "vbfs_fuse_rmdir", 226LL, a1);
v1 = pathname_to_inode(a1);
if ( IS_ERR(v1) )
result = PTR_ERR(v1);
else
result = vbfs_rmdir();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(const char *a1)
{
__int64 v1; // rdi
__int64 result; // rax

if ( is_debug )
log_debug("%s(%d) vbfs_fuse_rmdir %s\n", "vbfs_fuse_rmdir", 226LL, a1);
v1 = pathname_to_inode(a1);
if ( func1(v1) )
result = func0(v1);
else
result = vbfs_rmdir();
return result;
}

original_code:
static int vbfs_fuse_rmdir(const char *path)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_rmdir %s\n", __FUNCTION__, 226, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_rmdir(inode);
 return ret;
}

canonical_original_code:
static int vbfs_fuse_rmdir(char *path)
{
 int ret;
 struct inode_info *inode;
 do { if (is_debug) log_debug("%s(%d) " "vbfs_fuse_rmdir %s\n", __FUNCTION__, 226, path); } while(0);
 inode = pathname_to_inode(path);
 if (IS_ERR(inode))
  return PTR_ERR(inode);
 ret = vbfs_rmdir(inode);
 return ret;
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // r12
int v4; // er12

if ( argc <= 2 )
{
fprintf(stderr, "argument error: %s <mountpoint> [options] <device>\n", *argv);
exit(1);
}
log_init(argc, argv, envp);
rdwr_register();
v3 = &argv[argc - 1];
if ( (int)init_super(*v3) < 0 )
{
fwrite("Invalidate filesystem\n", 1uLL, 0x16uLL, stderr);
exit(1);
}
*v3 = 0LL;
v4 = fuse_main_real((unsigned int)(argc - 1), argv, vbfs_op, 360LL, 0LL);
log_error("%s(%d) fuse_main end\n", "main", 522LL);
return v4;
}

original_code:
int main(int argc, char **argv)
{
 int ret = 0;
 int i_argc;
 char **s_argv;
 if (argc < 3) {
  fprintf(stderr, "argument error: %s <mountpoint> [options] <device>\n", argv[0]);
  exit(1);
 }
 log_init();
 rdwr_register();
 ret = init_super(argv[argc - 1]);
 if (ret < 0) {
  fprintf(stderr, "Invalidate filesystem\n");
  exit(1);
 }
 i_argc = argc - 1;
 s_argv = argv;
 s_argv[argc - 1] = ((void *)0);
 ret = fuse_main_real(i_argc, s_argv, &vbfs_op, sizeof(*(&vbfs_op)), ((void *)0));
 do { log_error("%s(%d) " "fuse_main end\n", __FUNCTION__, 522); } while(0);
 return ret;
}

variable_types: argc int

variable_types:
argv
char **


dolog

decompiled_code:
// attributes: thunk
void dolog(int pri, const char *fmt, __gnuc_va_list ap)
{
vsyslog(pri, fmt, ap);
}

canonical_decompiled_code:
void func0(int pri, const char *fmt, __gnuc_va_list ap)
{
vsyslog(pri, fmt, ap);
}

original_code:
static void dolog(int prio, const char *fmt, va_list ap)
{
 vsyslog(prio, fmt, ap);
}

canonical_original_code:
static void dolog(int prio, char *fmt, __builtin_va_list ap)
{
 vsyslog(prio, fmt, ap);
}

variable_types: prio int

variable_types:
fmt
char *


decompiled_code:
__int64 log_init()
{
__int64 result; // rax

openlog("vbfs-fuse", 0, 24);
setlogmask(255);
result = 0LL;
is_debug = 1;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

openlog("vbfs-fuse", 0, 24);
setlogmask(255);
result = 0LL;
is_debug = 1;
return result;
}

original_code:
int log_init(void)
{
 openlog("vbfs-fuse", 0, (3<<3));
 setlogmask(((1 << ((7)+1)) - 1));
 is_debug = 1;
 return 0;
}

canonical_original_code:
int log_init()
{
 openlog("vbfs-fuse", 0, (3<<3));
 setlogmask(((1 << ((7)+1)) - 1));
 is_debug = 1;
 return 0;
}


decompiled_code:
void log_warning(char *fmt, ...)
{
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, fmt);
dolog(4, fmt, ap);
}

canonical_decompiled_code:
void func2(char *fmt, ...)
{
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, fmt);
func0(4, fmt, ap);
}

original_code:
void log_warning(const char *fmt, ...)
{
 va_list ap;
 __builtin_va_start(ap,fmt);
 dolog(4, fmt, ap);
 __builtin_va_end(ap);
}

canonical_original_code:
void log_warning(char *fmt, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 dolog(4, fmt, ap);
 __builtin_va_end(ap);
}


decompiled_code:
void log_error(char *fmt, ...)
{
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, fmt);
dolog(3, fmt, ap);
}

canonical_decompiled_code:
void func3(char *fmt, ...)
{
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, fmt);
func0(3, fmt, ap);
}

original_code:
void log_error(const char *fmt, ...)
{
 va_list ap;
 __builtin_va_start(ap,fmt);
 dolog(3, fmt, ap);
 __builtin_va_end(ap);
}

canonical_original_code:
void log_error(char *fmt, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 dolog(3, fmt, ap);
 __builtin_va_end(ap);
}


decompiled_code:
void log_debug(char *fmt, ...)
{
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, fmt);
dolog(7, fmt, ap);
}

canonical_decompiled_code:
void func4(char *fmt, ...)
{
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, fmt);
func0(7, fmt, ap);
}

original_code:
void log_debug(const char *fmt, ...)
{
 va_list ap;
 __builtin_va_start(ap,fmt);
 dolog(7, fmt, ap);
 __builtin_va_end(ap);
}

canonical_original_code:
void log_debug(char *fmt, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 dolog(7, fmt, ap);
 __builtin_va_end(ap);
}


decompiled_code:
// attributes: thunk
void log_close(void)
{
closelog();
}

canonical_decompiled_code:
void func5(void)
{
closelog();
}

original_code:
void log_close(void)
{
 closelog();
}

canonical_original_code:
void log_close()
{
 closelog();
}


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

result = *(unsigned int *)(a1 + 48);
if ( (_DWORD)result == 1 )
{
result = write_extend(*(unsigned int *)(a1 + 36), *(_QWORD *)(a1 + 40));
}
else
{
if ( (_DWORD)result )
{
*(_DWORD *)(a1 + 52) = -22;
return result;
}
result = read_extend(*(unsigned int *)(a1 + 36), *(_QWORD *)(a1 + 40));
}
if ( (int)result < 0 )
{
result = (unsigned int)-*_errno_location();
*(_DWORD *)(a1 + 52) = result;
}
return result;
}

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

result = *(unsigned int *)(a1 + 48);
if ( (_DWORD)result == 1 )
{
result = write_extend(*(unsigned int *)(a1 + 36), *(_QWORD *)(a1 + 40));
}
else
{
if ( (_DWORD)result )
{
*(_DWORD *)(a1 + 52) = -22;
return result;
}
result = read_extend(*(unsigned int *)(a1 + 36), *(_QWORD *)(a1 + 40));
}
if ( (int)result < 0 )
{
result = (unsigned int)-*_errno_location();
*(_DWORD *)(a1 + 52) = result;
}
return result;
}

original_code:
static void extend_bufio(struct extend_buf *b)
{
 int ret = 0;
 if (WRITE == b->rw) {
  ret = write_extend(b->real_eno, b->data);
 } else if (READ == b->rw) {
  ret = read_extend(b->real_eno, b->data);
 } else {
  b->error = -22;
 }
 if (ret < 0)
  b->error = -(*__errno_location ());
}

variable_types: struct extend_buf { struct hlist_node { struct hlist_node *next; } hash_list; struct list_head { struct list_head *next; } lru_list; unsigned int eno; unsigned int real_eno; char *data; int rw; int error; unsigned int list_mode; unsigned int hold_cnt; unsigned int state; unsigned long last_accessed; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; void (*end_io_fn)(void *args); void *args; struct list_head data_list; struct queue { struct list_head lru[2]; unsigned long n_buffers[2]; struct hlist_head { struct hlist_node *first; } *cache_hash; int hash_bits; struct list_head reserved_buffers; unsigned int need_reserved_buffers; unsigned long clean_tid; int clean_stop; union pthread_mutex_t clean_lock; union pthread_cond_t free_buffer_cond; union pthread_mutex_t free_buffer_lock; union pthread_mutex_t lock; unsigned int eno_prefix; } *q; struct list_head inode_list; } *

user_defined_types: struct extend_buf { struct hlist_node hash_list; struct list_head lru_list; unsigned int eno; unsigned int real_eno; char *data; int rw; int error; unsigned int list_mode; unsigned int hold_cnt; unsigned int state; unsigned long last_accessed; union pthread_mutex_t lock; union pthread_cond_t cond; void (*end_io_fn)(void *args); void *args; struct list_head data_list; struct queue *q; struct list_head inode_list; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct queue { struct list_head lru[2]; unsigned long n_buffers[2]; struct hlist_head *cache_hash; int hash_bits; struct list_head reserved_buffers; unsigned int need_reserved_buffers; unsigned long clean_tid; int clean_stop; union pthread_mutex_t clean_lock; union pthread_cond_t free_buffer_cond; union pthread_mutex_t free_buffer_lock; union pthread_mutex_t lock; unsigned int eno_prefix; }


decompiled_code:
__int64 rdwr_exit()
{
__int64 v0; // rbx
pthread_t i; // rdi
__int64 result; // rax

v0 = 0LL;
log_error("%s(%d) close io threads\n", "rdwr_exit", 112LL);
dword_4C0 = 1;
pthread_cond_broadcast(&cond);
for ( i = *(_QWORD *)info; i; i = *((_QWORD *)info + v0) )
{
if ( dword_428 <= (int)v0 )
break;
++v0;
pthread_join(i, 0LL);
}
pthread_cond_destroy(&cond);
pthread_mutex_destroy(&mutex);
pthread_mutex_destroy(&stru_498);
free(info);
result = 0LL;
dword_4C0 = 0;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
pthread_t i; // rdi
__int64 result; // rax

v0 = 0LL;
log_error("%s(%d) close io threads\n", "rdwr_exit", 112LL);
dword_4C0 = 1;
pthread_cond_broadcast(&cond);
for ( i = *(_QWORD *)info; i; i = *((_QWORD *)info + v0) )
{
if ( dword_428 <= (int)v0 )
break;
++v0;
pthread_join(i, 0LL);
}
pthread_cond_destroy(&cond);
pthread_mutex_destroy(&mutex);
pthread_mutex_destroy(&stru_498);
free(info);
result = 0LL;
dword_4C0 = 0;
return result;
}

original_code:
static int rdwr_exit()
{
 int i = 0;
 do { log_error("%s(%d) " "close io threads\n", __FUNCTION__, 112); } while(0);
 info.stop = 1;
 pthread_cond_broadcast(&info.pending_cond);
 for (i = 0; info.worker_thread[i] && i < info.nr_threads; i ++)
  pthread_join(info.worker_thread[i], ((void *)0));
 pthread_cond_destroy(&info.pending_cond);
 pthread_mutex_destroy(&info.pending_lock);
 pthread_mutex_destroy(&info.startup_lock);
 free(info.worker_thread);
 info.stop = 0;
 return 0;
}

variable_types: i int


decompiled_code:
__int64 __fastcall rdwr_submit(__int64 a1)
{
pthread_mutex_lock(&mutex);
list_add_tail_constprop_0((_QWORD *)(a1 + 184));
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
pthread_mutex_lock(&mutex);
func7((_QWORD *)(a1 + 184));
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
return 0LL;
}

original_code:
int rdwr_submit(struct extend_buf *b)
{
 pthread_mutex_lock(&info.pending_lock);
 list_add_tail(&b->data_list, &info.pending_list);
 pthread_cond_signal(&info.pending_cond);
 pthread_mutex_unlock(&info.pending_lock);
 return 0;
}

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct hlist_head { struct hlist_node *first; }


decompiled_code:
__int64 __fastcall rdwr_thread_open(int a1)
{
__int64 v1; // rbx
int v2; // er12
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rbp
pthread_t v6; // rdi
__int64 result; // rax

info = calloc(8LL * a1, 1uLL);
INIT_LIST_HEAD_constprop_0();
pthread_cond_init(&cond, 0LL);
pthread_mutex_init(&mutex, 0LL);
pthread_mutex_init(&stru_498, 0LL);
pthread_mutex_lock(&stru_498);
if ( a1 <= 0 )
{
LABEL_9:
pthread_mutex_unlock(&stru_498);
dword_428 = a1;
result = 0LL;
}
else
{
v1 = 0LL;
while ( 1 )
{
v2 = v1;
if ( pthread_create((pthread_t *)info + v1, 0LL, (void *(*)(void *))extend_worker_fn, 0LL) )
break;
if ( ++v1 == a1 )
goto LABEL_9;
}
puts("pthread_create failed");
dword_4C0 = 1;
pthread_mutex_unlock(&stru_498);
if ( (_DWORD)v1 )
{
v3 = (int)v1;
v4 = 8LL * (int)v1 - 8;
v5 = 8 * (v3 - (unsigned int)(v2 - 1)) - 16;
do
{
v6 = *(_QWORD *)((char *)info + v4);
v4 -= 8LL;
pthread_join(v6, 0LL);
}
while ( v5 != v4 );
}
pthread_cond_destroy(&cond);
pthread_mutex_destroy(&mutex);
pthread_mutex_destroy(&stru_498);
free(info);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1)
{
__int64 v1; // rbx
int v2; // er12
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rbp
pthread_t v6; // rdi
__int64 result; // rax

info = calloc(8LL * a1, 1uLL);
func9();
pthread_cond_init(&cond, 0LL);
pthread_mutex_init(&mutex, 0LL);
pthread_mutex_init(&stru_498, 0LL);
pthread_mutex_lock(&stru_498);
if ( a1 <= 0 )
{
LABEL_9:
pthread_mutex_unlock(&stru_498);
dword_428 = a1;
result = 0LL;
}
else
{
v1 = 0LL;
while ( 1 )
{
v2 = v1;
if ( pthread_create((pthread_t *)info + v1, 0LL, (void *(*)(void *))extend_worker_fn, 0LL) )
break;
if ( ++v1 == a1 )
goto LABEL_9;
}
puts("pthread_create failed");
dword_4C0 = 1;
pthread_mutex_unlock(&stru_498);
if ( (_DWORD)v1 )
{
v3 = (int)v1;
v4 = 8LL * (int)v1 - 8;
v5 = 8 * (v3 - (unsigned int)(v2 - 1)) - 16;
do
{
v6 = *(_QWORD *)((char *)info + v4);
v4 -= 8LL;
pthread_join(v6, 0LL);
}
while ( v5 != v4 );
}
pthread_cond_destroy(&cond);
pthread_mutex_destroy(&mutex);
pthread_mutex_destroy(&stru_498);
free(info);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int rdwr_thread_open(int nr_threads)
{
 int i = 0, ret = 0;
 info.worker_thread = malloc(sizeof(pthread_t) * nr_threads);
 memset(info.worker_thread, 0, sizeof(pthread_t) * nr_threads);
 INIT_LIST_HEAD(&info.pending_list);
 pthread_cond_init(&info.pending_cond, ((void *)0));
 pthread_mutex_init(&info.pending_lock, ((void *)0));
 pthread_mutex_init(&info.startup_lock, ((void *)0));
 pthread_mutex_lock(&info.startup_lock);
 for (i = 0; i < nr_threads; i++) {
  ret = pthread_create(&info.worker_thread[i], ((void *)0),
    extend_worker_fn, ((void *)0));
  if (ret) {
   printf("pthread_create failed\n");
   goto destroy_threads;
  }
 }
 pthread_mutex_unlock(&info.startup_lock);
 info.nr_threads = nr_threads;
 return 0;
destroy_threads:
 info.stop = 1;
 pthread_mutex_unlock(&info.startup_lock);
 for (; i > 0; i--) {
  pthread_join(info.worker_thread[i - 1], ((void *)0));
 }
 pthread_cond_destroy(&info.pending_cond);
 pthread_mutex_destroy(&info.pending_lock);
 pthread_mutex_destroy(&info.startup_lock);
 free(info.worker_thread);
 return -1;
}

canonical_original_code:
int rdwr_thread_open(int nr_threads)
{
 int i = 0; int ret = 0;
 info.worker_thread = malloc(sizeof(pthread_t) * nr_threads);
 memset(info.worker_thread, 0, sizeof(pthread_t) * nr_threads);
 INIT_LIST_HEAD(&info.pending_list);
 pthread_cond_init(&info.pending_cond, ((void *)0));
 pthread_mutex_init(&info.pending_lock, ((void *)0));
 pthread_mutex_init(&info.startup_lock, ((void *)0));
 pthread_mutex_lock(&info.startup_lock);
 for (i = 0; i < nr_threads; i++) {
  ret = pthread_create(&info.worker_thread[i], ((void *)0),
    extend_worker_fn, ((void *)0));
  if (ret) {
   printf("pthread_create failed\n");
   goto destroy_threads;
  }
 }
 pthread_mutex_unlock(&info.startup_lock);
 info.nr_threads = nr_threads;
 return 0;
destroy_threads:
 info.stop = 1;
 pthread_mutex_unlock(&info.startup_lock);
 for (; i > 0; i--) {
  pthread_join(info.worker_thread[i - 1], ((void *)0));
 }
 pthread_cond_destroy(&info.pending_cond);
 pthread_mutex_destroy(&info.pending_lock);
 pthread_mutex_destroy(&info.startup_lock);
 free(info.worker_thread);
 return -1;
}


decompiled_code:
__int64 rdwr_init()
{
memset(&info, 0, 0xA8uLL);
return rdwr_thread_open(4);
}

canonical_decompiled_code:
__int64 func11()
{
memset(&info, 0, 0xA8uLL);
return func10(4);
}

original_code:
static int rdwr_init()
{
 int ret;
 memset(&info, 0, sizeof(struct thread_info));
 ret = rdwr_thread_open(4);
 return ret;
}

user_defined_types: struct thread_info { unsigned long *worker_thread; int nr_threads; union pthread_cond_t pending_cond; union pthread_mutex_t pending_lock; struct list_head pending_list; union pthread_mutex_t startup_lock; int stop; }


decompiled_code:
__int64 rdwr_register()
{
return register_ioengine(&rdwr_engine);
}

canonical_decompiled_code:
__int64 func12()
{
return register_ioengine(&rdwr_engine);
}

original_code:
void rdwr_register()
{
 register_ioengine(&rdwr_engine);
}


decompiled_code:
__int64 __fastcall PTR_ERR(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code:
static inline long PTR_ERR(const void *ptr)
{
 return (long) ptr;
}

canonical_original_code:
static inline long PTR_ERR(void *ptr)
{
 return (long) ptr;
}

variable_types:
ptr
void *


decompiled_code:
_BOOL8 __fastcall IS_ERR(unsigned __int64 a1)
{
return a1 > 0xFFFFFFFFFFFFF000LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned __int64 a1)
{
return a1 > 0xFFFFFFFFFFFFF000LL;
}

original_code:
static inline long IS_ERR(const void *ptr)
{
 return (((unsigned long)ptr) >= (unsigned long)-4095);
}

canonical_original_code:
static inline long IS_ERR(void *ptr)
{
 return (((unsigned long)ptr) >= (unsigned long)-4095);
}


decompiled_code:
__int64 init_bad_extend()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
static int init_bad_extend(void)
{
 return 0;
}

canonical_original_code:
static int init_bad_extend()
{
 return 0;
}


decompiled_code:
__int64 super_umount_clean()
{
unsigned int v0; // er12

pthread_mutex_lock(&stru_5D8);
dword_5BC = 0;
v0 = sync_super_unlocked();
pthread_mutex_unlock(&stru_5D8);
return v0;
}

canonical_decompiled_code:
__int64 func9()
{
unsigned int v0; // er12

pthread_mutex_lock(&stru_5D8);
dword_5BC = 0;
v0 = func4();
pthread_mutex_unlock(&stru_5D8);
return v0;
}

original_code:
int super_umount_clean(void)
{
 int ret;
 pthread_mutex_lock(&vbfs_ctx.super.lock);
 vbfs_ctx.super.s_state = CLEAN;
 ret = sync_super_unlocked();
 pthread_mutex_unlock(&vbfs_ctx.super.lock);
 return ret;
}

canonical_original_code:
int super_umount_clean()
{
 int ret;
 pthread_mutex_lock(&vbfs_ctx.super.lock);
 vbfs_ctx.super.s_state = CLEAN;
 ret = sync_super_unlocked();
 pthread_mutex_unlock(&vbfs_ctx.super.lock);
 return ret;
}


decompiled_code:
__int64 get_bitmap_curr()
{
unsigned int v0; // er12

pthread_mutex_lock(&stru_5D8);
v0 = dword_5B0 + dword_5AC;
pthread_mutex_unlock(&stru_5D8);
return v0;
}

canonical_decompiled_code:
__int64 func10()
{
unsigned int v0; // er12

pthread_mutex_lock(&stru_5D8);
v0 = dword_5B0 + dword_5AC;
pthread_mutex_unlock(&stru_5D8);
return v0;
}

original_code:
uint32_t get_bitmap_curr(void)
{
 uint32_t bm_offset = 0;
 pthread_mutex_lock(&vbfs_ctx.super.lock);
 bm_offset = vbfs_ctx.super.bitmap_current
   + vbfs_ctx.super.bitmap_offset;
 pthread_mutex_unlock(&vbfs_ctx.super.lock);
 return bm_offset;
}

canonical_original_code:
unsigned int get_bitmap_curr()
{
 unsigned int bm_offset = 0;
 pthread_mutex_lock(&vbfs_ctx.super.lock);
 bm_offset = vbfs_ctx.super.bitmap_current
   + vbfs_ctx.super.bitmap_offset;
 pthread_mutex_unlock(&vbfs_ctx.super.lock);
 return bm_offset;
}

return_type: unsigned int


decompiled_code:
__int64 add_bitmap_curr()
{
unsigned int v0; // er12

pthread_mutex_lock(&stru_5D8);
dword_5D0 = 1;
dword_5B0 = (dword_5B0 + 1) % (unsigned int)dword_5A8;
v0 = dword_5AC + dword_5B0;
pthread_mutex_unlock(&stru_5D8);
return v0;
}

canonical_decompiled_code:
__int64 func11()
{
unsigned int v0; // er12

pthread_mutex_lock(&stru_5D8);
dword_5D0 = 1;
dword_5B0 = (dword_5B0 + 1) % (unsigned int)dword_5A8;
v0 = dword_5AC + dword_5B0;
pthread_mutex_unlock(&stru_5D8);
return v0;
}

original_code:
uint32_t add_bitmap_curr(void)
{
 uint32_t bm_offset = 0;
 pthread_mutex_lock(&vbfs_ctx.super.lock);
 ++ vbfs_ctx.super.bitmap_current;
 vbfs_ctx.super.bitmap_current %= vbfs_ctx.super.bitmap_count;
 bm_offset = vbfs_ctx.super.bitmap_current + vbfs_ctx.super.bitmap_offset;
 vbfs_ctx.super.super_vbfs_dirty = DIRTY;
 pthread_mutex_unlock(&vbfs_ctx.super.lock);
 return bm_offset;
}

canonical_original_code:
unsigned int add_bitmap_curr()
{
 unsigned int bm_offset = 0;
 pthread_mutex_lock(&vbfs_ctx.super.lock);
 ++ vbfs_ctx.super.bitmap_current;
 vbfs_ctx.super.bitmap_current %= vbfs_ctx.super.bitmap_count;
 bm_offset = vbfs_ctx.super.bitmap_current + vbfs_ctx.super.bitmap_offset;
 vbfs_ctx.super.super_vbfs_dirty = DIRTY;
 pthread_mutex_unlock(&vbfs_ctx.super.lock);
 return bm_offset;
}


decompiled_code:
__int64 meta_queue_create()
{
__int64 v0; // rdi
__int64 v1; // rdi
_BOOL8 v2; // r8
__int64 result; // rax

v0 = (unsigned int)dword_5A8;
if ( (unsigned int)dword_5A8 >= 0x10 )
v0 = 16LL;
v1 = queue_create(v0, 4LL, 0LL);
qword_610 = v1;
v2 = IS_ERR(v1);
result = 0LL;
if ( v2 )
result = PTR_ERR(v1);
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__int64 v0; // rdi
__int64 v1; // rdi
_BOOL8 v2; // r8
__int64 result; // rax

v0 = (unsigned int)dword_5A8;
if ( (unsigned int)dword_5A8 >= 0x10 )
v0 = 16LL;
v1 = queue_create(v0, 4LL, 0LL);
qword_610 = v1;
v2 = func1(v1);
result = 0LL;
if ( v2 )
result = func0(v1);
return result;
}

original_code:
int meta_queue_create(void)
{
 int ret = 0, reserved_bufs, hash_bits;
 if (vbfs_ctx.super.bitmap_count < 16)
  reserved_bufs = vbfs_ctx.super.bitmap_count;
 else
  reserved_bufs = 16;
 hash_bits = 4;
 vbfs_ctx.meta_queue = queue_create(reserved_bufs, hash_bits, 0);
 if (IS_ERR(vbfs_ctx.meta_queue))
  ret = PTR_ERR(vbfs_ctx.meta_queue);
 return ret;
}

canonical_original_code:
int meta_queue_create()
{
 int ret = 0; int reserved_bufs; int hash_bits;
 if (vbfs_ctx.super.bitmap_count < 16)
  reserved_bufs = vbfs_ctx.super.bitmap_count;
 else
  reserved_bufs = 16;
 hash_bits = 4;
 vbfs_ctx.meta_queue = queue_create(reserved_bufs, hash_bits, 0);
 if (IS_ERR(vbfs_ctx.meta_queue))
  ret = PTR_ERR(vbfs_ctx.meta_queue);
 return ret;
}


decompiled_code:
__int64 data_queue_create()
{
__int64 v0; // rdi
__int64 v1; // rdi
_BOOL8 v2; // r8
__int64 result; // rax

v0 = (unsigned int)dword_590;
if ( (unsigned int)dword_590 >= 0x100 )
v0 = 256LL;
v1 = queue_create(v0, 10LL, (unsigned int)(dword_5A8 + dword_5AC));
qword_618 = v1;
v2 = IS_ERR(v1);
result = 0LL;
if ( v2 )
result = PTR_ERR(v1);
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 v0; // rdi
__int64 v1; // rdi
_BOOL8 v2; // r8
__int64 result; // rax

v0 = (unsigned int)dword_590;
if ( (unsigned int)dword_590 >= 0x100 )
v0 = 256LL;
v1 = queue_create(v0, 10LL, (unsigned int)(dword_5A8 + dword_5AC));
qword_618 = v1;
v2 = func1(v1);
result = 0LL;
if ( v2 )
result = func0(v1);
return result;
}

original_code:
int data_queue_create(void)
{
 int ret = 0, reserved_bufs, hash_bits;
 uint32_t data_offset;
 if (vbfs_ctx.super.s_extend_count < 256)
  reserved_bufs = vbfs_ctx.super.s_extend_count;
 else
  reserved_bufs = 256;
 hash_bits = 10;
 data_offset = vbfs_ctx.super.bitmap_count + vbfs_ctx.super.bitmap_offset;
 vbfs_ctx.data_queue = queue_create(reserved_bufs, hash_bits, data_offset);
 if (IS_ERR(vbfs_ctx.data_queue)) {
  ret = PTR_ERR(vbfs_ctx.data_queue);
 }
 return ret;
}

canonical_original_code:
int data_queue_create()
{
 int ret = 0; int reserved_bufs; int hash_bits;
 unsigned int data_offset;
 if (vbfs_ctx.super.s_extend_count < 256)
  reserved_bufs = vbfs_ctx.super.s_extend_count;
 else
  reserved_bufs = 256;
 hash_bits = 10;
 data_offset = vbfs_ctx.super.bitmap_count + vbfs_ctx.super.bitmap_offset;
 vbfs_ctx.data_queue = queue_create(reserved_bufs, hash_bits, data_offset);
 if (IS_ERR(vbfs_ctx.data_queue)) {
  ret = PTR_ERR(vbfs_ctx.data_queue);
 }
 return ret;
}


decompiled_code:
void __fastcall init_dir_bm_size(int a1)
{
dword_600 = a1;
}

canonical_decompiled_code:
void __fastcall func14(int a1)
{
dword_600 = a1;
}

original_code:
void init_dir_bm_size(uint32_t dir_bm_size)
{
 vbfs_ctx.super.dir_bm_size = dir_bm_size;
}

canonical_original_code:
void init_dir_bm_size(unsigned int dir_bm_size)
{
 vbfs_ctx.super.dir_bm_size = dir_bm_size;
}


decompiled_code:
void __fastcall init_dir_capacity(int a1)
{
dword_604 = a1;
}

canonical_decompiled_code:
void __fastcall func15(int a1)
{
dword_604 = a1;
}

original_code:
void init_dir_capacity(uint32_t dir_capacity)
{
 vbfs_ctx.super.dir_capacity = dir_capacity;
}

canonical_original_code:
void init_dir_capacity(unsigned int dir_capacity)
{
 vbfs_ctx.super.dir_capacity = dir_capacity;
}


decompiled_code:
__int64 __fastcall free_extend_bitmap_async(unsigned int a1)
{
unsigned int v1; // er12

pthread_mutex_lock(&bitmap_lock);
v1 = _free_extend_bitmap(a1, 0LL);
pthread_mutex_unlock(&bitmap_lock);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1)
{
unsigned int v1; // er12

pthread_mutex_lock(&bitmap_lock);
v1 = func9(a1, 0LL);
pthread_mutex_unlock(&bitmap_lock);
return v1;
}

original_code:
int free_extend_bitmap_async(const uint32_t extend_no)
{
 int ret;
 pthread_mutex_lock(&bitmap_lock);
 ret = __free_extend_bitmap(extend_no, 0);
 pthread_mutex_unlock(&bitmap_lock);
 return ret;
}

canonical_original_code:
int free_extend_bitmap_async(unsigned int extend_no)
{
 int ret;
 pthread_mutex_lock(&bitmap_lock);
 ret = __free_extend_bitmap(extend_no, 0);
 pthread_mutex_unlock(&bitmap_lock);
 return ret;
}


decompiled_code:
__int64 __fastcall alloc_extend_bitmap(_DWORD *a1)
{
unsigned int v1; // er12

pthread_mutex_lock(&bitmap_lock);
v1 = _alloc_extend_bitmap(a1);
pthread_mutex_unlock(&bitmap_lock);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(_DWORD *a1)
{
unsigned int v1; // er12

pthread_mutex_lock(&bitmap_lock);
v1 = func7(a1);
pthread_mutex_unlock(&bitmap_lock);
return v1;
}

original_code:
int alloc_extend_bitmap(uint32_t *extend_no)
{
 int ret;
 pthread_mutex_lock(&bitmap_lock);
 ret = __alloc_extend_bitmap(extend_no);
 pthread_mutex_unlock(&bitmap_lock);
 return ret;
}

canonical_original_code:
int alloc_extend_bitmap(unsigned int *extend_no)
{
 int ret;
 pthread_mutex_lock(&bitmap_lock);
 ret = __alloc_extend_bitmap(extend_no);
 pthread_mutex_unlock(&bitmap_lock);
 return ret;
}


decompiled_code:
__int64 __fastcall free_extend_bitmap(unsigned int a1)
{
unsigned int v1; // er12

pthread_mutex_lock(&bitmap_lock);
v1 = _free_extend_bitmap(a1, 1LL);
pthread_mutex_unlock(&bitmap_lock);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1)
{
unsigned int v1; // er12

pthread_mutex_lock(&bitmap_lock);
v1 = func9(a1, 1LL);
pthread_mutex_unlock(&bitmap_lock);
return v1;
}

original_code:
int free_extend_bitmap(const uint32_t extend_no)
{
 int ret;
 pthread_mutex_lock(&bitmap_lock);
 ret = __free_extend_bitmap(extend_no, 1);
 pthread_mutex_unlock(&bitmap_lock);
 return ret;
}

canonical_original_code:
int free_extend_bitmap(unsigned int extend_no)
{
 int ret;
 pthread_mutex_lock(&bitmap_lock);
 ret = __free_extend_bitmap(extend_no, 1);
 pthread_mutex_unlock(&bitmap_lock);
 return ret;
}


decompiled_code:
_BOOL8 __fastcall is_need_alloc(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rdx
_BOOL8 result; // rax

v2 = a2 - (unsigned int)get_file_idx_size();
result = 0LL;
if ( v2 >= a1 )
result = a2 % get_extend_size() == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rdx
_BOOL8 result; // rax

v2 = a2 - (unsigned int)get_file_idx_size();
result = 0LL;
if ( v2 >= a1 )
result = a2 % get_extend_size() == 0;
return result;
}

original_code:
static int is_need_alloc(uint64_t size, off_t buf_off)
{
 if (size > (buf_off - get_file_idx_size()))
  return 0;
 if (buf_off % get_extend_size())
  return 0;
 return 1;
}

canonical_original_code:
static int is_need_alloc(unsigned long size, long buf_off)
{
 if (size > (buf_off - get_file_idx_size()))
  return 0;
 if (buf_off % get_extend_size())
  return 0;
 return 1;
}


decompiled_code:
__int64 __fastcall sync_file(_DWORD *a1)
{
unsigned int v2; // ebp
__int64 v3; // rax
__int64 v4; // rdi
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

vbfs_inode_sync();
if ( *(_DWORD *)(*(_QWORD *)a1 + 8LL) != 1 || a1[5] )
return 0LL;
v2 = **(_DWORD **)a1;
v3 = get_data_queue();
v4 = extend_get(v3, v2, v5);
if ( !IS_ERR(v4) )
{
if ( v4 )
{
extend_write_dirty(v5[0]);
extend_put(v5[0]);
}
return 0LL;
}
return PTR_ERR(v4);
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
unsigned int v2; // ebp
__int64 v3; // rax
__int64 v4; // rdi
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

vbfs_inode_sync();
if ( *(_DWORD *)(*(_QWORD *)a1 + 8LL) != 1 || a1[5] )
return 0LL;
v2 = **(_DWORD **)a1;
v3 = get_data_queue();
v4 = extend_get(v3, v2, v5);
if ( !func1(v4) )
{
if ( v4 )
{
extend_write_dirty(v5[0]);
extend_put(v5[0]);
}
return 0LL;
}
return func0(v4);
}

original_code:
int sync_file(struct inode_info *inode)
{
 char *data;
 struct extend_buf *b;
 vbfs_inode_sync(inode);
 if (inode->dirent->i_mode == VBFS_FT_REG_FILE &&
   (! inode->flags & INODE_REMOVE)) {
  data = extend_get(get_data_queue(), inode->dirent->i_ino, &b);
  if (IS_ERR(data))
   return PTR_ERR(data);
  if (!data)
   return 0;
  extend_write_dirty(b);
  extend_put(b);
 }
 return 0;
}

variable_types:
data
char *


decompiled_code:
__int64 __fastcall vbfs_read_buf(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4)
{
unsigned int v6; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
v6 = _vbfs_read_buf((unsigned int **)a1, a2, a3, a4);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4)
{
unsigned int v6; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
v6 = func6((unsigned int **)a1, a2, a3, a4);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v6;
}

original_code:
int vbfs_read_buf(struct inode_info *inode, char *buf, size_t size, off_t offset)
{
 int ret;
 pthread_mutex_lock(&inode->lock);
 ret = __vbfs_read_buf(inode, buf, size, offset);
 pthread_mutex_unlock(&inode->lock);
 return ret;
}

canonical_original_code:
int vbfs_read_buf(struct inode_info *inode, char *buf, unsigned long size, long offset)
{
 int ret;
 pthread_mutex_lock(&inode->lock);
 ret = __vbfs_read_buf(inode, buf, size, offset);
 pthread_mutex_unlock(&inode->lock);
 return ret;
}

variable_types: offset long


decompiled_code:
__int64 __fastcall vbfs_write_buf(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4)
{
unsigned int v6; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
v6 = _vbfs_write_buf(a1, a2, a3, a4);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, __int64 a3, unsigned __int64 a4)
{
unsigned int v6; // er12

pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
v6 = func8(a1, a2, a3, a4);
pthread_mutex_unlock((pthread_mutex_t *)(a1 + 32));
return v6;
}

original_code:
int vbfs_write_buf(struct inode_info *inode, const char *buf, size_t size, off_t offset)
{
 int ret;
 pthread_mutex_lock(&inode->lock);
 ret = __vbfs_write_buf(inode, buf, size, offset);
 pthread_mutex_unlock(&inode->lock);
 return ret;
}

canonical_original_code:
int vbfs_write_buf(struct inode_info *inode, char *buf, unsigned long size, long offset)
{
 int ret;
 pthread_mutex_lock(&inode->lock);
 ret = __vbfs_write_buf(inode, buf, size, offset);
 pthread_mutex_unlock(&inode->lock);
 return ret;
}


decompiled_code:
__int64 __fastcall close_edata(void *ptr)
{
pthread_mutex_t *v1; // r13
pthread_mutex_t *v2; // r12
int v3; // eax
unsigned int v4; // er14
__int64 result; // rax

v1 = (pthread_mutex_t *)((char *)ptr + 32);
v2 = (pthread_mutex_t *)(*((_QWORD *)ptr + 13) + 16LL);
pthread_mutex_lock(v2);
pthread_mutex_lock((pthread_mutex_t *)((char *)ptr + 32));
v3 = *((_DWORD *)ptr + 5) - 1;
*((_DWORD *)ptr + 5) = v3;
if ( v3 > 0 )
{
pthread_mutex_unlock(v1);
pthread_mutex_unlock(v2);
result = 0LL;
}
else
{
list_del((__int64)ptr + 88);
if ( *((_DWORD *)ptr + 4) != 2 )
goto LABEL_3;
if ( is_debug )
log_debug("%s(%d) write extend %u", "close_edata", 131LL, *(unsigned int *)ptr);
v4 = -5;
if ( !(unsigned int)write_extend(*(_DWORD *)ptr, *((void **)ptr + 1)) )
LABEL_3:
v4 = 0;
pthread_mutex_unlock(v1);
pthread_mutex_unlock(v2);
pthread_mutex_destroy(v1);
if ( *((_DWORD *)ptr + 4) )
free(*((void **)ptr + 1));
free(ptr);
result = v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *ptr)
{
pthread_mutex_t *v1; // r13
pthread_mutex_t *v2; // r12
int v3; // eax
unsigned int v4; // er14
__int64 result; // rax

v1 = (pthread_mutex_t *)((char *)ptr + 32);
v2 = (pthread_mutex_t *)(*((_QWORD *)ptr + 13) + 16LL);
pthread_mutex_lock(v2);
pthread_mutex_lock((pthread_mutex_t *)((char *)ptr + 32));
v3 = *((_DWORD *)ptr + 5) - 1;
*((_DWORD *)ptr + 5) = v3;
if ( v3 > 0 )
{
pthread_mutex_unlock(v1);
pthread_mutex_unlock(v2);
result = 0LL;
}
else
{
func4((__int64)ptr + 88);
if ( *((_DWORD *)ptr + 4) != 2 )
goto LABEL_3;
if ( is_debug )
log_debug("%s(%d) write extend %u", "close_edata", 131LL, *(unsigned int *)ptr);
v4 = -5;
if ( !(unsigned int)func6(*(_DWORD *)ptr, *((void **)ptr + 1)) )
LABEL_3:
v4 = 0;
pthread_mutex_unlock(v1);
pthread_mutex_unlock(v2);
pthread_mutex_destroy(v1);
if ( *((_DWORD *)ptr + 4) )
free(*((void **)ptr + 1));
free(ptr);
result = v4;
}
return result;
}

original_code:
int close_edata(struct extend_data *edata)
{
 struct extend_queue *equeue = ((void *)0);
 int ret = 0;
 equeue = edata->equeue;
 pthread_mutex_lock(&equeue->all_ed_lock);
 pthread_mutex_lock(&edata->ed_lock);
 if (--edata->ref > 0) {
  pthread_mutex_unlock(&edata->ed_lock);
  pthread_mutex_unlock(&equeue->all_ed_lock);
  return 0;
 }
 list_del(&edata->rq_list);
 if (BUFFER_DIRTY == edata->status) {
  do { if (is_debug) log_debug("%s(%d) " "write extend %u", __FUNCTION__, 131, edata->extend_no); } while(0);
  if(write_extend(edata->extend_no, edata->buf))
   ret = -5;
 }
 pthread_mutex_unlock(&edata->ed_lock);
 pthread_mutex_unlock(&equeue->all_ed_lock);
 pthread_mutex_destroy(&edata->ed_lock);
 if (BUFFER_NOT_READY != edata->status)
  free(edata->buf);
 free(edata);
 return ret;
}

variable_types: struct extend_data { unsigned int extend_no; char *buf; int status; int ref; int inode_ref; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } ed_lock; struct list_head { struct list_head *next; } data_list; struct list_head rq_list; struct extend_queue { struct list_head all_ed_list; union pthread_mutex_t all_ed_lock; struct list_head cache_list; union pthread_mutex_t cache_lock; void *q_private; } *equeue; } *

variable_types: struct extend_queue { struct list_head { struct list_head *next; } all_ed_list; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } all_ed_lock; struct list_head cache_list; union pthread_mutex_t cache_lock; void *q_private; } *

user_defined_types: struct extend_data { unsigned int extend_no; char *buf; int status; int ref; int inode_ref; union pthread_mutex_t ed_lock; struct list_head data_list; struct list_head rq_list; struct extend_queue *equeue; }


decompiled_code:
__int64 __fastcall read_edata(__int64 a1)
{
unsigned int v1; // er12
pthread_mutex_t *v2; // rbp
void *v3; // rax
unsigned int v4; // er12

v1 = vbfs_ctx[2];
v2 = (pthread_mutex_t *)(a1 + 32);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
if ( *(_DWORD *)(a1 + 16) )
{
v4 = 0;
}
else
{
v3 = (void *)mp_valloc(v1);
*(_QWORD *)(a1 + 8) = v3;
if ( !v3 )
{
v4 = -12;
pthread_mutex_unlock(v2);
return v4;
}
v4 = read_extend(*(_DWORD *)a1, v3);
if ( v4 )
{
v4 = -5;
mp_free(*(_QWORD *)(a1 + 8));
*(_QWORD *)(a1 + 8) = 0LL;
}
else
{
*(_DWORD *)(a1 + 16) = 1;
}
}
pthread_mutex_unlock(v2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
unsigned int v1; // er12
pthread_mutex_t *v2; // rbp
void *v3; // rax
unsigned int v4; // er12

v1 = vbfs_ctx[2];
v2 = (pthread_mutex_t *)(a1 + 32);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
if ( *(_DWORD *)(a1 + 16) )
{
v4 = 0;
}
else
{
v3 = (void *)mp_valloc(v1);
*(_QWORD *)(a1 + 8) = v3;
if ( !v3 )
{
v4 = -12;
pthread_mutex_unlock(v2);
return v4;
}
v4 = func8(*(_DWORD *)a1, v3);
if ( v4 )
{
v4 = -5;
mp_free(*(_QWORD *)(a1 + 8));
*(_QWORD *)(a1 + 8) = 0LL;
}
else
{
*(_DWORD *)(a1 + 16) = 1;
}
}
pthread_mutex_unlock(v2);
return v4;
}

original_code:
int read_edata(struct extend_data *edata)
{
 int ret = 0;
 size_t len = vbfs_ctx.super.s_extend_size;
 pthread_mutex_lock(&edata->ed_lock);
 if (BUFFER_NOT_READY == edata->status) {
  edata->buf = mp_valloc(len);
  if (((void *)0) == edata->buf) {
   pthread_mutex_unlock(&edata->ed_lock);
   return -12;
  }
  ret = read_extend(edata->extend_no, edata->buf);
  if (0 == ret) {
   edata->status = BUFFER_CLEAN;
  } else {
   mp_free(edata->buf);
   edata->buf = ((void *)0);
   ret = -5;
  }
 }
 pthread_mutex_unlock(&edata->ed_lock);
 return ret;
}

canonical_original_code:
int read_edata(struct extend_data *edata)
{
 int ret = 0;
 unsigned long len = vbfs_ctx.super.s_extend_size;
 pthread_mutex_lock(&edata->ed_lock);
 if (BUFFER_NOT_READY == edata->status) {
  edata->buf = mp_valloc(len);
  if (((void *)0) == edata->buf) {
   pthread_mutex_unlock(&edata->ed_lock);
   return -12;
  }
  ret = read_extend(edata->extend_no, edata->buf);
  if (0 == ret) {
   edata->status = BUFFER_CLEAN;
  } else {
   mp_free(edata->buf);
   edata->buf = ((void *)0);
   ret = -5;
  }
 }
 pthread_mutex_unlock(&edata->ed_lock);
 return ret;
}

variable_types:
len
unsigned long

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

user_defined_types: struct extend_queue { struct list_head all_ed_list; union pthread_mutex_t all_ed_lock; struct list_head cache_list; union pthread_mutex_t cache_lock; void *q_private; }


decompiled_code:
__int64 __fastcall sync_edata(__int64 a1)
{
unsigned int v1; // er12
pthread_mutex_t *v2; // rbp

v1 = 0;
v2 = (pthread_mutex_t *)(a1 + 32);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
if ( *(_DWORD *)(a1 + 16) != 2 )
goto LABEL_2;
if ( (unsigned int)write_extend(*(_DWORD *)a1, *(void **)(a1 + 8)) )
{
v1 = -5;
LABEL_2:
pthread_mutex_unlock(v2);
return v1;
}
*(_DWORD *)(a1 + 16) = 1;
pthread_mutex_unlock(v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
unsigned int v1; // er12
pthread_mutex_t *v2; // rbp

v1 = 0;
v2 = (pthread_mutex_t *)(a1 + 32);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 32));
if ( *(_DWORD *)(a1 + 16) != 2 )
goto LABEL_2;
if ( (unsigned int)func6(*(_DWORD *)a1, *(void **)(a1 + 8)) )
{
v1 = -5;
LABEL_2:
pthread_mutex_unlock(v2);
return v1;
}
*(_DWORD *)(a1 + 16) = 1;
pthread_mutex_unlock(v2);
return 0LL;
}

original_code:
int sync_edata(struct extend_data *edata)
{
 int ret = 0;
 pthread_mutex_lock(&edata->ed_lock);
 if (BUFFER_DIRTY == edata->status) {
  ret = write_extend(edata->extend_no, edata->buf);
  if (0 == ret) {
   edata->status = BUFFER_CLEAN;
  } else
   ret = -5;
 }
 pthread_mutex_unlock(&edata->ed_lock);
 return ret;
}

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


decompiled_code:
__int64 __fastcall write_to_disk(int fd, void *buf, __off64_t offset, size_t n)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "write_to_disk", 10LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( write(fd, buf, n) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) write error %s\n", "write_to_disk", 14LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int fd, void *buf, __off64_t offset, size_t n)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "write_to_disk", 10LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( write(fd, buf, n) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) write error %s\n", "write_to_disk", 14LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int write_to_disk(int fd, void *buf, __u64 offset, size_t len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 10, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (write(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "write error %s\n", __FUNCTION__, 14, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int write_to_disk(int fd, void *buf, unsigned long long offset, unsigned long len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 10, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (write(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "write error %s\n", __FUNCTION__, 14, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

variable_types: fd int

variable_types:
buf
void *

variable_types:
offset
unsigned long long


decompiled_code:
__int64 __fastcall write_extend(unsigned int a1, void *a2)
{
return (unsigned int)-((unsigned int)write_to_disk(
vbfs_ctx[0],
a2,
(unsigned int)vbfs_ctx[2] * (unsigned __int64)a1,
(unsigned int)vbfs_ctx[2]) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, void *a2)
{
return (unsigned int)-((unsigned int)func5(
vbfs_ctx[0],
a2,
(unsigned int)vbfs_ctx[2] * (unsigned __int64)a1,
(unsigned int)vbfs_ctx[2]) != 0);
}

original_code:
static int write_extend(__u32 extend_no, void *buf)
{
 size_t len = vbfs_ctx.super.s_extend_size;
 int fd = vbfs_ctx.fd;
 off64_t offset = (__u64)extend_no * len;
 if (write_to_disk(fd, buf, offset, len))
  return -1;
 return 0;
}

canonical_original_code:
static int write_extend(unsigned int extend_no, void *buf)
{
 unsigned long len = vbfs_ctx.super.s_extend_size;
 int fd = vbfs_ctx.fd;
 long offset = (__u64)extend_no * len;
 if (write_to_disk(fd, buf, offset, len))
  return -1;
 return 0;
}


decompiled_code:
__int64 __fastcall read_from_disk(int fd, void *buf, __off64_t offset, size_t nbytes)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "read_from_disk", 24LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( read(fd, buf, nbytes) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) read error %s\n", "read_from_disk", 28LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int fd, void *buf, __off64_t offset, size_t nbytes)
{
__int64 result; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax

if ( lseek64(fd, offset, 0) < 0 )
{
v6 = _errno_location();
v7 = strerror(*v6);
log_error("%s(%d) lseek error %s\n", "read_from_disk", 24LL, v7);
result = 0xFFFFFFFFLL;
}
else if ( read(fd, buf, nbytes) < 0 )
{
v8 = _errno_location();
v9 = strerror(*v8);
log_error("%s(%d) read error %s\n", "read_from_disk", 28LL, v9);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int read_from_disk(int fd, void *buf, __u64 offset, size_t len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 24, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (read(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "read error %s\n", __FUNCTION__, 28, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}

canonical_original_code:
int read_from_disk(int fd, void *buf, unsigned long long offset, unsigned long len)
{
 if (lseek64(fd, offset, 0) < 0) {
  do { log_error("%s(%d) " "lseek error %s\n", __FUNCTION__, 24, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 if (read(fd, buf, len) < 0) {
  do { log_error("%s(%d) " "read error %s\n", __FUNCTION__, 28, strerror((*__errno_location ()))); } while(0);
  return -1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall read_extend(unsigned int a1, void *a2)
{
return (unsigned int)-((unsigned int)read_from_disk(
vbfs_ctx[0],
a2,
(unsigned int)vbfs_ctx[2] * (unsigned __int64)a1,
(unsigned int)vbfs_ctx[2]) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, void *a2)
{
return (unsigned int)-((unsigned int)func7(
vbfs_ctx[0],
a2,
(unsigned int)vbfs_ctx[2] * (unsigned __int64)a1,
(unsigned int)vbfs_ctx[2]) != 0);
}

original_code:
static int read_extend(__u32 extend_no, void *buf)
{
 size_t len = vbfs_ctx.super.s_extend_size;
 int fd = vbfs_ctx.fd;
 off64_t offset = (__u64)extend_no * len;
 if (read_from_disk(fd, buf, offset, len))
  return -1;
 return 0;
}

canonical_original_code:
static int read_extend(unsigned int extend_no, void *buf)
{
 unsigned long len = vbfs_ctx.super.s_extend_size;
 int fd = vbfs_ctx.fd;
 long offset = (__u64)extend_no * len;
 if (read_from_disk(fd, buf, offset, len))
  return -1;
 return 0;
}


decompiled_code:
__int64 __fastcall alloc_edata_by_inode(unsigned int a1, __int64 a2, _DWORD *a3)
{
__int64 v4; // r12

pthread_mutex_lock((pthread_mutex_t *)(a2 + 64));
v4 = alloc_edata_by_inode_unlocked(a1, a2, a3);
pthread_mutex_unlock((pthread_mutex_t *)(a2 + 64));
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, __int64 a2, _DWORD *a3)
{
__int64 v4; // r12

pthread_mutex_lock((pthread_mutex_t *)(a2 + 64));
v4 = func4(a1, a2, a3);
pthread_mutex_unlock((pthread_mutex_t *)(a2 + 64));
return v4;
}

original_code:
struct extend_data *alloc_edata_by_inode(const __u32 extend_no,
    struct inode_vbfs *inode_v, int *err_no)
{
 struct extend_data *edata = ((void *)0);
 pthread_mutex_lock(&inode_v->inode_lock);
 edata = alloc_edata_by_inode_unlocked(extend_no, inode_v, err_no);
 pthread_mutex_unlock(&inode_v->inode_lock);
 return edata;
}

canonical_original_code:
struct extend_data *alloc_edata_by_inode(unsigned int extend_no, struct inode_vbfs *inode_v, int *err_no)
{
 struct extend_data *edata = ((void *)0);
 pthread_mutex_lock(&inode_v->inode_lock);
 edata = alloc_edata_by_inode_unlocked(extend_no, inode_v, err_no);
 pthread_mutex_unlock(&inode_v->inode_lock);
 return edata;
}

variable_types: struct inode_vbfs { unsigned int i_ino; unsigned int i_pino; unsigned int i_mode; unsigned long long i_size; unsigned int i_ctime; unsigned int i_atime; unsigned int i_mtime; unsigned int i_extend; int inode_dirty; int ref; struct list_head active_list; union pthread_mutex_t inode_lock; struct inode_dirents { int ref; int dir_cnt; int status; struct list_head dir_list; } dirent; struct list_head data_buf_list; } *

return_type: struct extend_data { unsigned int extend_no; char *buf; int status; int ref; int inode_ref; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } ed_lock; struct list_head { struct list_head *next; } data_list; struct list_head rq_list; struct extend_queue { struct list_head all_ed_list; union pthread_mutex_t all_ed_lock; struct list_head cache_list; union pthread_mutex_t cache_lock; void *q_private; } *equeue; } *

user_defined_types: struct inode_vbfs { unsigned int i_ino; unsigned int i_pino; unsigned int i_mode; unsigned long long i_size; unsigned int i_ctime; unsigned int i_atime; unsigned int i_mtime; unsigned int i_extend; int inode_dirty; int ref; struct list_head active_list; union pthread_mutex_t inode_lock; struct inode_dirents dirent; struct list_head data_buf_list; }