decompiled_code:
void __fastcall cmd_list_nlst(__int64 a1, __int64 a2, char a3)
{
unsigned int v3; // er13
const char *v5; // rax
char *v6; // r12

v3 = *(_DWORD *)a1;
if ( *(_BYTE *)(a1 + 4168) )
{
if ( (unsigned __int8)check_dir_exist(a1 + 8) )
{
send_all(v3, "150 Here comes the directory listing.\n", 38LL);
if ( *(_DWORD *)(a1 + 4) )
{
v5 = (const char *)merge_paths(a1 + 8, a2, 0LL);
v6 = (char *)v5;
if ( v5 )
{
list_directory((unsigned int *)a1, v5, a3);
free(v6);
}
else
{
send_mesg_451(v3);
close(*(_DWORD *)(a1 + 4));
*(_DWORD *)(a1 + 4) = 0;
}
}
else
{
send_mesg_425(v3);
}
}
else
{
send_mesg_553(v3);
}
}
else
{
send_mesg_530(v3, 114LL);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, char a3)
{
unsigned int v3; // er13
const char *v5; // rax
char *v6; // r12

v3 = *(_DWORD *)a1;
if ( *(_BYTE *)(a1 + 4168) )
{
if ( (unsigned __int8)check_dir_exist(a1 + 8) )
{
send_all(v3, "150 Here comes the directory listing.\n", 38LL);
if ( *(_DWORD *)(a1 + 4) )
{
v5 = (const char *)merge_paths(a1 + 8, a2, 0LL);
v6 = (char *)v5;
if ( v5 )
{
func1((unsigned int *)a1, v5, a3);
free(v6);
}
else
{
send_mesg_451(v3);
close(*(_DWORD *)(a1 + 4));
*(_DWORD *)(a1 + 4) = 0;
}
}
else
{
send_mesg_425(v3);
}
}
else
{
send_mesg_553(v3);
}
}
else
{
send_mesg_530(v3, 114LL);
}
}

original_code:
void cmd_list_nlst (session_info_t *si, char *arg, _Bool detail)
{
  char *fullpath;
  char *transferStart;
  int csfd = si->csfd;
  if (!si->loggedin) {
    send_mesg_530 (csfd, 'r');
    return;
  }
  if (!check_dir_exist (si->cwd, arg)) {
    send_mesg_553 (csfd);
    return;
  }
  transferStart = "150 Here comes the directory listing.\n";
  send_all (csfd, (uint8_t*)transferStart, strlen (transferStart));
  if (si->dsfd == 0) {
    send_mesg_425 (csfd);
    return;
  }
  if ((fullpath = merge_paths (si->cwd, arg, ((void *)0))) == ((void *)0)) {
    send_mesg_451 (csfd);
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  list_directory (si, fullpath, detail);
  free (fullpath);
  return;
}

canonical_original_code:
void cmd_list_nlst(struct session_info_t *si, char *arg, _Bool detail)
{
  char *fullpath;
  char *transferStart;
  int csfd = si->csfd;
  if (!si->loggedin) {
    send_mesg_530 (csfd, 'r');
    return;
  }
  if (!check_dir_exist (si->cwd, arg)) {
    send_mesg_553 (csfd);
    return;
  }
  transferStart = "150 Here comes the directory listing.\n";
  send_all (csfd, (unsigned char *)transferStart, strlen (transferStart));
  if (si->dsfd == 0) {
    send_mesg_425 (csfd);
    return;
  }
  if ((fullpath = merge_paths (si->cwd, arg, ((void *)0))) == ((void *)0)) {
    send_mesg_451 (csfd);
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  list_directory (si, fullpath, detail);
  free (fullpath);
  return;
}

variable_types:
fullpath
char *

variable_types:
transferStart
char *


decompiled_code:
void __fastcall cmd_mkd(int *a1, __int64 a2)
{
unsigned int v2; // er12
const char *v3; // rax
char *v4; // rbp
const char *v5; // r13
char *v6; // rbx
size_t v7; // rax
int *v8; // rax
char *v9; // rax

v2 = *a1;
if ( *((_BYTE *)a1 + 4168) && strcmp((const char *)a1 + 4104, "anonymous") )
{
v3 = (const char *)merge_paths(a1 + 2, a2, 0LL);
v4 = (char *)v3;
if ( v3 )
{
if ( mkdir(v3, 0x1C0u) == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
fprintf(stderr, "%s: mkdir: %s\n", "cmd_mkd", v9);
send_mesg_550_process_error(v2);
close(a1[1]);
a1[1] = 0;
}
else
{
v5 = rootdir;
v6 = strstr(v4, rootdir);
v7 = strlen(v5);
send_mesg_257(v2, &v6[v7]);
}
free(v4);
}
else
{
fprintf(stderr, "%s: merge_paths: filepath merge error\n", "cmd_mkd");
close(a1[1]);
a1[1] = 0;
}
}
else
{
send_mesg_530(v2, 114LL);
close(a1[1]);
a1[1] = 0;
}
}

canonical_decompiled_code:
void __fastcall func3(int *a1, __int64 a2)
{
unsigned int v2; // er12
const char *v3; // rax
char *v4; // rbp
const char *v5; // r13
char *v6; // rbx
size_t v7; // rax
int *v8; // rax
char *v9; // rax

v2 = *a1;
if ( *((_BYTE *)a1 + 4168) && strcmp((const char *)a1 + 4104, "anonymous") )
{
v3 = (const char *)merge_paths(a1 + 2, a2, 0LL);
v4 = (char *)v3;
if ( v3 )
{
if ( mkdir(v3, 0x1C0u) == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
fprintf(stderr, "%s: mkdir: %s\n", "cmd_mkd", v9);
send_mesg_550_process_error(v2);
close(a1[1]);
a1[1] = 0;
}
else
{
v5 = rootdir;
v6 = strstr(v4, rootdir);
v7 = strlen(v5);
send_mesg_257(v2, &v6[v7]);
}
free(v4);
}
else
{
fprintf(stderr, "%s: merge_paths: filepath merge error\n", "cmd_mkd");
close(a1[1]);
a1[1] = 0;
}
}
else
{
send_mesg_530(v2, 114LL);
close(a1[1]);
a1[1] = 0;
}
}

original_code:
void cmd_mkd (session_info_t *si, char * filepath)
{
  mode_t permissions;
  char *outpath;
  int csfd = si->csfd;
  permissions = 0;
  permissions = permissions | 0400;
  permissions = permissions | 0200;
  permissions = permissions | 0100;
  if (si->loggedin == 0 || strcmp (si->user, "anonymous") == 0) {
    send_mesg_530 (csfd, 'r');
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  if ((filepath = merge_paths (si->cwd, filepath, ((void *)0))) == ((void *)0)) {
    fprintf (stderr, "%s: merge_paths: filepath merge error\n", __FUNCTION__);
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  if (mkdir (filepath, permissions) == -1) {
    fprintf (stderr, "%s: mkdir: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
    send_mesg_550_process_error (csfd);
    close (si->dsfd);
    si->dsfd = 0;
    free (filepath);
    return;
  }
  outpath = strstr (filepath, rootdir);
  outpath += strlen (rootdir);
  send_mesg_257 (csfd, outpath);
  free (filepath);
  return;
}

canonical_original_code:
void cmd_mkd(struct session_info_t *si, char *filepath)
{
  unsigned int permissions;
  char *outpath;
  int csfd = si->csfd;
  permissions = 0;
  permissions = permissions | 0400;
  permissions = permissions | 0200;
  permissions = permissions | 0100;
  if (si->loggedin == 0 || strcmp (si->user, "anonymous") == 0) {
    send_mesg_530 (csfd, 'r');
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  if ((filepath = merge_paths (si->cwd, filepath, ((void *)0))) == ((void *)0)) {
    fprintf (stderr, "%s: merge_paths: filepath merge error\n", __FUNCTION__);
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  if (mkdir (filepath, permissions) == -1) {
    fprintf (stderr, "%s: mkdir: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
    send_mesg_550_process_error (csfd);
    close (si->dsfd);
    si->dsfd = 0;
    free (filepath);
    return;
  }
  outpath = strstr (filepath, rootdir);
  outpath += strlen (rootdir);
  send_mesg_257 (csfd, outpath);
  free (filepath);
  return;
}

variable_types: struct session_info_t { int csfd; int dsfd; char cwd[4096]; char user[64]; _Bool loggedin; _Bool cmdComplete; _Bool cmdAbort; _Bool cmdQuit; char cmdString[4096]; char type; } *

variable_types:
filepath
char *

variable_types:
permissions
unsigned int

variable_types:
outpath
char *

variable_types: csfd int

return_type: void


decompiled_code:
void __fastcall cmd_cwd(int *a1, __int64 a2)
{
unsigned int v2; // er13
char *v3; // r12
const char *v4; // rax
char *v5; // rbp
char *v6; // r14
const char *v7; // rsi

v2 = *a1;
if ( *((_BYTE *)a1 + 4168) )
{
v3 = (char *)(a1 + 2);
if ( (unsigned __int8)check_dir_exist(a1 + 2) )
{
v4 = (const char *)merge_paths(v3, a2, 0LL);
v5 = (char *)v4;
if ( v4 )
{
v6 = canonicalize_file_name(v4);
if ( v6 )
{
*((_BYTE *)a1 + 8) = 0;
v7 = &v6[strlen(rootdir)];
strcat(v3, v7);
*(_WORD *)&v3[strlen(v3)] = 47;
send_mesg_250(v2);
free(v5);
free(v6);
}
else
{
send_mesg_550_process_error(v2);
free(v5);
}
}
else
{
send_mesg_550_process_error(v2);
}
}
else
{
send_mesg_550_no_dir(v2);
}
}
else
{
send_mesg_530(v2, 114LL);
}
}

canonical_decompiled_code:
void __fastcall func4(int *a1, __int64 a2)
{
unsigned int v2; // er13
char *v3; // r12
const char *v4; // rax
char *v5; // rbp
char *v6; // r14
const char *v7; // rsi

v2 = *a1;
if ( *((_BYTE *)a1 + 4168) )
{
v3 = (char *)(a1 + 2);
if ( (unsigned __int8)check_dir_exist(a1 + 2) )
{
v4 = (const char *)merge_paths(v3, a2, 0LL);
v5 = (char *)v4;
if ( v4 )
{
v6 = canonicalize_file_name(v4);
if ( v6 )
{
*((_BYTE *)a1 + 8) = 0;
v7 = &v6[strlen(rootdir)];
strcat(v3, v7);
*(_WORD *)&v3[strlen(v3)] = 47;
send_mesg_250(v2);
free(v5);
free(v6);
}
else
{
send_mesg_550_process_error(v2);
free(v5);
}
}
else
{
send_mesg_550_process_error(v2);
}
}
else
{
send_mesg_550_no_dir(v2);
}
}
else
{
send_mesg_530(v2, 114LL);
}
}

original_code:
void cmd_cwd (session_info_t *si, char *arg)
{
  char *fullpath;
  char *canon;
  int csfd = si->csfd;
  if (si->loggedin == 0) {
    send_mesg_530 (csfd, 'r');
    return;
  }
  if (!check_dir_exist (si->cwd, arg)) {
    send_mesg_550_no_dir (csfd);
    return;
  }
  if ((fullpath = merge_paths (si->cwd, arg, ((void *)0))) == ((void *)0)) {
    send_mesg_550_process_error (csfd);
    return;
  }
  if ((canon = canonicalize_file_name (fullpath)) == ((void *)0)) {
    send_mesg_550_process_error (csfd);
    free (fullpath);
    return;
  }
  si->cwd[0] = '\0';
  strcat (si->cwd, canon + strlen (rootdir));
  strcat (si->cwd, "/");
  send_mesg_250 (csfd);
  free (fullpath);
  free (canon);
}

canonical_original_code:
void cmd_cwd(struct session_info_t *si, char *arg)
{
  char *fullpath;
  char *canon;
  int csfd = si->csfd;
  if (si->loggedin == 0) {
    send_mesg_530 (csfd, 'r');
    return;
  }
  if (!check_dir_exist (si->cwd, arg)) {
    send_mesg_550_no_dir (csfd);
    return;
  }
  if ((fullpath = merge_paths (si->cwd, arg, ((void *)0))) == ((void *)0)) {
    send_mesg_550_process_error (csfd);
    return;
  }
  if ((canon = canonicalize_file_name (fullpath)) == ((void *)0)) {
    send_mesg_550_process_error (csfd);
    free (fullpath);
    return;
  }
  si->cwd[0] = '\0';
  strcat (si->cwd, canon + strlen (rootdir));
  strcat (si->cwd, "/");
  send_mesg_250 (csfd);
  free (fullpath);
  free (canon);
}

variable_types:
arg
char *

variable_types:
canon
char *

user_defined_types: struct session_info_t { int csfd; int dsfd; char cwd[4096]; char user[64]; _Bool loggedin; _Bool cmdComplete; _Bool cmdAbort; _Bool cmdQuit; char cmdString[4096]; char type; }


decompiled_code:
void __fastcall cmd_cdup(__int64 a1, __int64 a2)
{
unsigned int v2; // er8
char v3[18]; // [rsp+0h] [rbp-12h] BYREF

v2 = *(_DWORD *)a1;
if ( *(_BYTE *)(a1 + 4168) )
{
if ( a2 )
{
send_mesg_550_no_argument(v2);
}
else
{
strcpy(v3, "..");
cmd_cwd((int *)a1, (__int64)v3);
}
}
else
{
send_mesg_530(v2, 114LL);
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2)
{
unsigned int v2; // er8
char v3[18]; // [rsp+0h] [rbp-12h] BYREF

v2 = *(_DWORD *)a1;
if ( *(_BYTE *)(a1 + 4168) )
{
if ( a2 )
{
send_mesg_550_no_argument(v2);
}
else
{
strcpy(v3, "..");
func4((int *)a1, (__int64)v3);
}
}
else
{
send_mesg_530(v2, 114LL);
}
}

original_code:
void cmd_cdup (session_info_t *si, char *arg)
{
  char up[10];
  int csfd = si->csfd;
  if (si->loggedin == 0) {
    send_mesg_530 (csfd, 'r');
    return;
  }
  if (arg != ((void *)0)) {
    send_mesg_550_no_argument (csfd);
    return;
  }
  up[0] = '\0';
  strcpy (up, "..");
  cmd_cwd (si, up);
  return;
}

canonical_original_code:
void cmd_cdup(struct session_info_t *si, char *arg)
{
  char up[10];
  int csfd = si->csfd;
  if (si->loggedin == 0) {
    send_mesg_530 (csfd, 'r');
    return;
  }
  if (arg != ((void *)0)) {
    send_mesg_550_no_argument (csfd);
    return;
  }
  up[0] = '\0';
  strcpy (up, "..");
  cmd_cwd (si, up);
  return;
}

variable_types:
up
char [10]


decompiled_code:
__int64 __fastcall cmd_pwd(unsigned int *a1)
{
return send_mesg_257(*a1, a1 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1)
{
return send_mesg_257(*a1, a1 + 2);
}

original_code:
void cmd_pwd (session_info_t *si)
{
  send_mesg_257 (si->csfd, si->cwd);
}

canonical_original_code:
void cmd_pwd(struct session_info_t *si)
{
  send_mesg_257 (si->csfd, si->cwd);
}


decompiled_code:
int __fastcall get_md5(char *src, const char *a2, char *a3)
{
char *v4; // rbx
size_t v5; // rax
__int64 v6; // rdx
char *v7; // rdi
int result; // eax
_BYTE v9[16]; // [rsp+0h] [rbp-288h] BYREF
char v10[96]; // [rsp+10h] [rbp-278h] BYREF
char dest[536]; // [rsp+70h] [rbp-218h] BYREF

v4 = v9;
strcpy(dest, a2);
strcat(dest, src);
md5Start(v10);
v5 = strlen(dest);
md5Add(v10, dest, v5);
md5End(v10, v9);
do
{
v6 = (unsigned __int8)*v4;
v7 = a3;
++v4;
a3 += 2;
result = sprintf(v7, "%02x", v6);
}
while ( v4 != v10 );
return result;
}

canonical_decompiled_code:
int __fastcall func0(char *src, const char *a2, char *a3)
{
char *v4; // rbx
size_t v5; // rax
__int64 v6; // rdx
char *v7; // rdi
int result; // eax
_BYTE v9[16]; // [rsp+0h] [rbp-288h] BYREF
char v10[96]; // [rsp+10h] [rbp-278h] BYREF
char dest[536]; // [rsp+70h] [rbp-218h] BYREF

v4 = v9;
strcpy(dest, a2);
strcat(dest, src);
md5Start(v10);
v5 = strlen(dest);
md5Add(v10, dest, v5);
md5End(v10, v9);
do
{
v6 = (unsigned __int8)*v4;
v7 = a3;
++v4;
a3 += 2;
result = sprintf(v7, "%02x", v6);
}
while ( v4 != v10 );
return result;
}

original_code:
static void get_md5 (char *user, char *pass, char *md5str)
{
  char data[500];
  byte_t md5checksum[16];
  struct md5CTX md5struct;
  strcpy (data, pass);
  strcat (data, user);
  md5Start (&md5struct);
  md5Add (&md5struct, (byte_t*)data, strlen (data));
  md5End (&md5struct, md5checksum);
  for(int i = 0; i < 16; ++i)
    sprintf (&md5str[i*2], "%02x", (unsigned int)md5checksum[i]);
}

canonical_original_code:
static void get_md5(char *user, char *pass, char *md5str)
{
  char data[500];
  unsigned char md5checksum[16];
  struct md5CTX md5struct;
  strcpy (data, pass);
  strcat (data, user);
  md5Start (&md5struct);
  md5Add (&md5struct, (unsigned char *)data, strlen (data));
  md5End (&md5struct, md5checksum);
  for(int i = 0; i < 16; ++i)
    sprintf (&md5str[i*2], "%02x", (unsigned int)md5checksum[i]);
}

variable_types:
user
char *

variable_types:
pass
char *

variable_types:
data
char [500]

variable_types: struct md5CTX { unsigned int h[4]; unsigned long bytesProcessed; unsigned char block[-1]; unsigned char bytesInBlock; }

variable_types: i int


decompiled_code:
char *__fastcall cmd_user(int *a1, const char *a2)
{
unsigned int v2; // er12

v2 = *a1;
if ( !a2 )
return (char *)send_mesg_501(v2);
*((_BYTE *)a1 + 4168) = 0;
*((_BYTE *)a1 + 4104) = 0;
if ( !strcasecmp(a2, "anonymous") )
{
*((_BYTE *)a1 + 4168) = 1;
send_mesg_230(v2, 115LL);
}
else
{
send_mesg_331(v2);
}
return strcpy((char *)a1 + 4104, a2);
}

canonical_decompiled_code:
char *__fastcall func1(int *a1, const char *a2)
{
unsigned int v2; // er12

v2 = *a1;
if ( !a2 )
return (char *)send_mesg_501(v2);
*((_BYTE *)a1 + 4168) = 0;
*((_BYTE *)a1 + 4104) = 0;
if ( !strcasecmp(a2, "anonymous") )
{
*((_BYTE *)a1 + 4168) = 1;
send_mesg_230(v2, 115LL);
}
else
{
send_mesg_331(v2);
}
return strcpy((char *)a1 + 4104, a2);
}

original_code:
void cmd_user (session_info_t *si, char *arg)
{
  int csfd = si->csfd;
  if (arg == ((void *)0)) {
    send_mesg_501 (csfd);
    return;
  }
  si->loggedin = 0;
  si->user[0] = '\0';
  if (strcasecmp (arg, "anonymous") == 0) {
    si->loggedin = 1;
    send_mesg_230 (csfd, 's');
  } else if (arg != ((void *)0)) {
    send_mesg_331 (csfd);
  }
  strcpy (si->user, arg);
  return;
}

canonical_original_code:
void cmd_user(struct session_info_t *si, char *arg)
{
  int csfd = si->csfd;
  if (arg == ((void *)0)) {
    send_mesg_501 (csfd);
    return;
  }
  si->loggedin = 0;
  si->user[0] = '\0';
  if (strcasecmp (arg, "anonymous") == 0) {
    si->loggedin = 1;
    send_mesg_230 (csfd, 's');
  } else if (arg != ((void *)0)) {
    send_mesg_331 (csfd);
  }
  strcpy (si->user, arg);
  return;
}


original_code:
void cmd_pass (session_info_t *si, char *arg)
{
  char *pass = ((void *)0);
  char md5string[33];
  int csfd = si->csfd;
  if (si->loggedin) {
    send_mesg_230 (csfd, 'n');
    return;
  }
  if (strlen (si->user) == 0) {
    send_mesg_503 (csfd);
    return;
  }
  if (strlen (arg) == 0) {
    send_mesg_501 (csfd);
    return;
  }
  if ((pass = get_config_value (si->user, "../conf/user.conf")) == ((void *)0)) {
    send_mesg_530 (csfd, 'f');
    return;
  }
  get_md5 (si->user, arg, md5string);
  if (strcmp (md5string, pass) == 0) {
    send_mesg_230 (csfd, 's');
    si->loggedin = 1;
  } else {
    send_mesg_530 (csfd, 'f');
  }
  free (pass);
  return;
}

canonical_original_code:
void cmd_pass(struct session_info_t *si, char *arg)
{
  char *pass = ((void *)0);
  char md5string[33];
  int csfd = si->csfd;
  if (si->loggedin) {
    send_mesg_230 (csfd, 'n');
    return;
  }
  if (strlen (si->user) == 0) {
    send_mesg_503 (csfd);
    return;
  }
  if (strlen (arg) == 0) {
    send_mesg_501 (csfd);
    return;
  }
  if ((pass = get_config_value (si->user, "../conf/user.conf")) == ((void *)0)) {
    send_mesg_530 (csfd, 'f');
    return;
  }
  get_md5 (si->user, arg, md5string);
  if (strcmp (md5string, pass) == 0) {
    send_mesg_230 (csfd, 's');
    si->loggedin = 1;
  } else {
    send_mesg_530 (csfd, 'f');
  }
  free (pass);
  return;
}


decompiled_code:
int __fastcall log_received_cmd(const char *a1, const char *a2, const char *a3, int a4)
{
struct tm *v6; // rax
char *v7; // rax
int result; // eax
time_t timer; // [rsp+8h] [rbp-30h] BYREF

time(&timer);
v6 = localtime(&timer);
v7 = asctime(v6);
fprintf(stderr, "%s\tUser <%s>\n", v7, a1);
if ( a2 )
result = fprintf(stderr, "\tEntered Command <%s> with (%d) Argument(s) \"%s\"\n\n", a2, (unsigned int)(a4 - 1), a3);
else
result = fwrite("\tERROR: Missing Command\n", 1uLL, 0x18uLL, stderr);
return result;
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, const char *a2, const char *a3, int a4)
{
struct tm *v6; // rax
char *v7; // rax
int result; // eax
time_t timer; // [rsp+8h] [rbp-30h] BYREF

time(&timer);
v6 = localtime(&timer);
v7 = asctime(v6);
fprintf(stderr, "%s\tUser <%s>\n", v7, a1);
if ( a2 )
result = fprintf(stderr, "\tEntered Command <%s> with (%d) Argument(s) \"%s\"\n\n", a2, (unsigned int)(a4 - 1), a3);
else
result = fwrite("\tERROR: Missing Command\n", 1uLL, 0x18uLL, stderr);
return result;
}

original_code:
void log_received_cmd (char *user, char *cmd, char *arg, int numArgs)
{
  struct tm *timeInfo;
  time_t rawTime;
  time (&rawTime);
  timeInfo = localtime (&rawTime);
  fprintf (stderr, "%s\tUser <%s>\n", asctime (timeInfo), user);
  if (cmd == ((void *)0)) {
    fprintf (stderr, "\tERROR: Missing Command\n");
    return;
  }
  fprintf (stderr, "\tEntered Command <%s> with (%d) Argument(s) \"%s\"\n\n",
    cmd, (numArgs - 1), arg);
}

canonical_original_code:
void log_received_cmd(char *user, char *cmd, char *arg, int numArgs)
{
  struct tm *timeInfo;
  long rawTime;
  time (&rawTime);
  timeInfo = localtime (&rawTime);
  fprintf (stderr, "%s\tUser <%s>\n", asctime (timeInfo), user);
  if (cmd == ((void *)0)) {
    fprintf (stderr, "\tERROR: Missing Command\n");
    return;
  }
  fprintf (stderr, "\tEntered Command <%s> with (%d) Argument(s) \"%s\"\n\n",
    cmd, (numArgs - 1), arg);
}

variable_types:
cmd
char *

variable_types: numArgs int

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types: rawTime long


decompiled_code:
int print_help()
{
puts("The current commands are:");
puts("\tclients");
puts("\thelp");
puts("\tserverinfo");
return puts("\tshutdown");
}

canonical_decompiled_code:
int func0()
{
puts("The current commands are:");
puts("\tclients");
puts("\thelp");
puts("\tserverinfo");
return puts("\tshutdown");
}

original_code:
static void print_help (void)
{
  printf ("The current commands are:\n");
  printf ("\tclients\n");
  printf ("\thelp\n");
  printf ("\tserverinfo\n");
  printf ("\tshutdown\n");
  return;
}

canonical_original_code:
static void print_help()
{
  printf ("The current commands are:\n");
  printf ("\tclients\n");
  printf ("\thelp\n");
  printf ("\tserverinfo\n");
  printf ("\tshutdown\n");
  return;
}


decompiled_code:
__int64 server_info()
{
__int64 v0; // rax
void *v1; // rbp
char *v2; // rbp
char v4[24]; // [rsp+10h] [rbp-18h] BYREF

v0 = get_config_value("INTERFACE_CONFIG", "../conf/ftp.conf");
if ( !v0 )
return 0xFFFFFFFFLL;
v1 = (void *)v0;
if ( (unsigned int)get_interface_address(v0, v4) != -1 )
{
free(v1);
v2 = (char *)get_config_value("DEFAULT_PORT_CONFIG", "../conf/ftp.conf");
if ( v2 )
{
puts("The server can be reached at:");
printf("\tIP address: %s\n", v4);
printf("\ton port : %s\n", v2);
free(v2);
return 0LL;
}
return 0xFFFFFFFFLL;
}
free(v1);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax
void *v1; // rbp
char *v2; // rbp
char v4[24]; // [rsp+10h] [rbp-18h] BYREF

v0 = get_config_value("INTERFACE_CONFIG", "../conf/ftp.conf");
if ( !v0 )
return 0xFFFFFFFFLL;
v1 = (void *)v0;
if ( (unsigned int)get_interface_address(v0, v4) != -1 )
{
free(v1);
v2 = (char *)get_config_value("DEFAULT_PORT_CONFIG", "../conf/ftp.conf");
if ( v2 )
{
puts("The server can be reached at:");
printf("\tIP address: %s\n", v4);
printf("\ton port : %s\n", v2);
free(v2);
return 0LL;
}
return 0xFFFFFFFFLL;
}
free(v1);
return 0xFFFFFFFFLL;
}

original_code:
static int server_info (void)
{
  char *interface;
  char address[16];
  char *port;
  if ((interface = get_config_value ("INTERFACE_CONFIG",
         "../conf/ftp.conf")) == ((void *)0))
    return -1;
  if (get_interface_address (interface, &address) == -1) {
    free (interface);
    return -1;
  }
  free (interface);
  if ((port = get_config_value ("DEFAULT_PORT_CONFIG",
    "../conf/ftp.conf")) == ((void *)0))
    return -1;
  printf ("The server can be reached at:\n");
  printf ("\tIP address: %s\n", address);
  printf ("\ton port   : %s\n", port);
  free (port);
  return 0;
}

canonical_original_code:
static int server_info()
{
  char *interface;
  char address[16];
  char *port;
  if ((interface = get_config_value ("INTERFACE_CONFIG",
         "../conf/ftp.conf")) == ((void *)0))
    return -1;
  if (get_interface_address (interface, &address) == -1) {
    free (interface);
    return -1;
  }
  free (interface);
  if ((port = get_config_value ("DEFAULT_PORT_CONFIG",
    "../conf/ftp.conf")) == ((void *)0))
    return -1;
  printf ("The server can be reached at:\n");
  printf ("\tIP address: %s\n", address);
  printf ("\ton port   : %s\n", port);
  free (port);
  return 0;
}

variable_types:
interface
char *

variable_types:
address
char [16]

variable_types:
port
char *

return_type: int


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

puts("The server is now ready to accept client connections.\n");
result = server_info();
if ( (_DWORD)result != -1 )
{
printf("\nYou may enter commands to this console. ");
puts("Enter \"help\" for a list of commands.");
result = 0LL;
}
return result;
}

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

puts("The server is now ready to accept client connections.\n");
result = func1();
if ( (_DWORD)result != -1 )
{
printf("\nYou may enter commands to this console. ");
puts("Enter \"help\" for a list of commands.");
result = 0LL;
}
return result;
}

original_code:
int welcome_message (void)
{
  printf ("The server is now ready to accept client connections.\n\n");
  if (server_info () == -1)
    return -1;
  printf ("\nYou may enter commands to this console. ");
  printf ("Enter \"help\" for a list of commands.\n");
  return 0;
}

canonical_original_code:
int welcome_message()
{
  printf ("The server is now ready to accept client connections.\n\n");
  if (server_info () == -1)
    return -1;
  printf ("\nYou may enter commands to this console. ");
  printf ("Enter \"help\" for a list of commands.\n");
  return 0;
}


decompiled_code:
__int64 read_server_cmd()
{
unsigned int v0; // er12
unsigned int v2; // eax
__int64 v3; // [rsp+0h] [rbp-58h] BYREF
int v4; // [rsp+8h] [rbp-50h]

if ( !fgets((char *)&v3, 79, stdin) )
return (unsigned int)-1;
if ( (_DWORD)v3 != 1886152040 || WORD2(v3) != 10 )
{
if ( v3 == 0x6E69726576726573LL && v4 == 683878 )
return (unsigned int)-((unsigned int)server_info() == -1);
if ( v3 == 0x6E776F6474756873LL )
{
v0 = -999;
if ( (_WORD)v4 == 10 )
return v0;
}
else if ( v3 == 0xA73746E65696C63LL && !(_BYTE)v4 )
{
v2 = get_cthread_count();
v0 = 0;
printf("Current number of clients: %d\n", v2);
return v0;
}
v0 = 0;
puts("Command not recognized, enter \"help\" for a list of commands.");
return v0;
}
print_help();
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
unsigned int v0; // er12
unsigned int v2; // eax
__int64 v3; // [rsp+0h] [rbp-58h] BYREF
int v4; // [rsp+8h] [rbp-50h]

if ( !fgets((char *)&v3, 79, stdin) )
return (unsigned int)-1;
if ( (_DWORD)v3 != 1886152040 || WORD2(v3) != 10 )
{
if ( v3 == 0x6E69726576726573LL && v4 == 683878 )
return (unsigned int)-((unsigned int)func1() == -1);
if ( v3 == 0x6E776F6474756873LL )
{
v0 = -999;
if ( (_WORD)v4 == 10 )
return v0;
}
else if ( v3 == 0xA73746E65696C63LL && !(_BYTE)v4 )
{
v2 = get_cthread_count();
v0 = 0;
printf("Current number of clients: %d\n", v2);
return v0;
}
v0 = 0;
puts("Command not recognized, enter \"help\" for a list of commands.");
return v0;
}
func0();
return 0LL;
}

original_code:
int read_server_cmd (void)
{
  char cmd[80];
  if (fgets (cmd, 80 - 1, stdin) == ((void *)0))
    return -1;
  if (strcmp (cmd, "help\n") == 0) {
    print_help ();
    return 0;
  } else if (strcmp (cmd, "serverinfo\n") == 0) {
    if (server_info () == -1)
      return -1;
    return 0;
  } else if (strcmp (cmd, "shutdown\n") == 0) {
    return -999;
  } else if (strcmp (cmd, "clients\n") == 0) {
    printf ("Current number of clients: %d\n", get_cthread_count());
  } else {
    printf ("Command not recognized, enter \"help\" for a list of commands.\n");
  }
  return 0;
}

canonical_original_code:
int read_server_cmd()
{
  char cmd[80];
  if (fgets (cmd, 80 - 1, stdin) == ((void *)0))
    return -1;
  if (strcmp (cmd, "help\n") == 0) {
    print_help ();
    return 0;
  } else if (strcmp (cmd, "serverinfo\n") == 0) {
    if (server_info () == -1)
      return -1;
    return 0;
  } else if (strcmp (cmd, "shutdown\n") == 0) {
    return -999;
  } else if (strcmp (cmd, "clients\n") == 0) {
    printf ("Current number of clients: %d\n", get_cthread_count());
  } else {
    printf ("Command not recognized, enter \"help\" for a list of commands.\n");
  }
  return 0;
}

variable_types:
cmd
char [80]


decompiled_code:
__int64 __fastcall cmd_help(unsigned int *a1, const char *a2)
{
unsigned int v2; // er12
const char *v4; // rdx
bool v5; // zf
const char *v6; // rsi

v2 = *a1;
if ( !a2 )
return send_mesg_214_general(v2);
v4 = "\tSend new user information\n";
v5 = strcmp(a2, "USER") == 0;
v6 = "To use: USER <SP> <username> <CRLF>\n";
if ( v5 )
return send_mesg_214_specific(v2, v6, v4);
if ( !strcmp(a2, "PASS") )
return send_mesg_214_specific(v2, "To use: PASS <SP> <password> <CRLF>\n", "\tSend a user password\n");
v4 = "\tTerminate the FTP session and exit\n";
v6 = "To use: QUIT <CRLF>\n";
if ( !strcmp(a2, "QUIT") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tOpen a specified data port\n";
v6 = "To use: PORT <SP> <host-port> <CRLF>\n";
if ( !strcmp(a2, "PORT") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tEnter passive transfer mode\n";
v6 = "To use: PASV <CRLF>\n";
if ( !strcmp(a2, "PASV") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tSet file transfer type\n";
v6 = "To use: TYPE <SP> <type-code> <CRLF>\n";
if ( !strcmp(a2, "TYPE") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tSet file transfer structure\n";
v6 = "To use: STRU <SP> <structure-code> <CRLF>\n";
if ( !strcmp(a2, "STRU") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tSet file transfer mode\n";
v6 = "To use: MODE <SP> <mode-code> <CRLF>\n";
if ( !strcmp(a2, "MODE") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tRetrieve a file from the remote host\n";
v6 = "To use: RETR <SP> <pathname> <CRLF>\n";
if ( !strcmp(a2, "RETR") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tStore a file on the remote host\n";
v6 = "To use: STOR <SP> <pathname> <CRLF>\n";
if ( !strcmp(a2, "STOR") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tStore a file uniquely\n";
v6 = "To use: STOU <CRLF>\n";
if ( !strcmp(a2, "STOU") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tAppend to a remote file\n";
v6 = "To use: APPE <SP> <pathname> <CRLF>\n";
if ( !strcmp(a2, "APPE") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tAbort a file transfer\n";
v6 = "To use: ABOR <CRLF>\n";
if ( !strcmp(a2, "ABOR") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tList contents of remote path\n";
v6 = "To use: LIST [<SP> <pathname>] <CRLF>\n";
if ( !strcmp(a2, "LIST") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tName list of remote directory\n";
v6 = "To use: NLST [<SP> <pathname>] <CRLF>\n";
if ( !strcmp(a2, "NLST") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tReturn remote system type\n";
v6 = "To use: SYST <CRLF>\n";
if ( !strcmp(a2, "SYST") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tPrint local help information on using the server\n";
v6 = "To use: HELP [<SP> <string>] <CRLF>\n";
if ( !strcmp(a2, "HELP") )
return send_mesg_214_specific(v2, v6, v4);
if ( !strcmp(a2, "NOOP") )
{
v4 = "\tDo nothing; server sends an OK reply\n";
v6 = "To use: NOOP <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "ACCT") )
{
v4 = "\tSend account command to the remote server\n";
v6 = "To use: ACCT <SP> <account-information> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "CDUP") )
{
v4 = "\tChange remote working directory to parent directory\n";
v6 = "To use: CDUP <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "SMNT") )
{
v4 = "\tMount a different file system data structure withoutaltering their login\n\tor accounting information\n";
v6 = "To use: SMNT <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "REIN") )
{
v4 = "\tReinitialize the connection\n";
v6 = "To use: REIN <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "ALLO") )
{
v4 = "\tAllocate sufficient storage space to receive a file\n";
v6 = "To use: ALLO <SP> <decimal-integer> [<SP> R <SP> <decimal-integer>] <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "REST") )
{
v4 = "\tRestart transfer at bytecount marker\n";
v6 = "To use: REST <SP> <marker> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "RNFR") )
{
v4 = "\tUsed when renaming a file; rename from\n";
v6 = "To use: RNFR <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "RNTO") )
{
v4 = "\tUsed when renaming a file; rename to\n";
v6 = "To use: RNTO <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "DELE") )
{
v4 = "\tDelete a remote file\n";
v6 = "To use: DELE <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "SITE") )
{
v4 = "\tSend site specific command to the remote server\n";
v6 = "To use: SITE <SP> <string> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "STAT") )
{
v4 = "\tReturn current server status\n";
v6 = "To use: STAT [<SP> <pathname>] <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "CWD") )
{
v4 = "\tChange the current working directory on the remote machine\n";
v6 = "To use: CWD <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "RMD") )
{
v4 = "\tRemove a directory on the remote machine\n";
v6 = "To use: RMD <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "MKD") )
{
v4 = "\tCreate a directory on the remote machine\n";
v6 = "To use: MKD <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "PWD") )
{
v4 = "\tPrint the current working directory on the remote machine\n";
v6 = "To use: PWD <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
return send_mesg_501(v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1, const char *a2)
{
unsigned int v2; // er12
const char *v4; // rdx
bool v5; // zf
const char *v6; // rsi

v2 = *a1;
if ( !a2 )
return send_mesg_214_general(v2);
v4 = "\tSend new user information\n";
v5 = strcmp(a2, "USER") == 0;
v6 = "To use: USER <SP> <username> <CRLF>\n";
if ( v5 )
return send_mesg_214_specific(v2, v6, v4);
if ( !strcmp(a2, "PASS") )
return send_mesg_214_specific(v2, "To use: PASS <SP> <password> <CRLF>\n", "\tSend a user password\n");
v4 = "\tTerminate the FTP session and exit\n";
v6 = "To use: QUIT <CRLF>\n";
if ( !strcmp(a2, "QUIT") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tOpen a specified data port\n";
v6 = "To use: PORT <SP> <host-port> <CRLF>\n";
if ( !strcmp(a2, "PORT") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tEnter passive transfer mode\n";
v6 = "To use: PASV <CRLF>\n";
if ( !strcmp(a2, "PASV") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tSet file transfer type\n";
v6 = "To use: TYPE <SP> <type-code> <CRLF>\n";
if ( !strcmp(a2, "TYPE") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tSet file transfer structure\n";
v6 = "To use: STRU <SP> <structure-code> <CRLF>\n";
if ( !strcmp(a2, "STRU") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tSet file transfer mode\n";
v6 = "To use: MODE <SP> <mode-code> <CRLF>\n";
if ( !strcmp(a2, "MODE") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tRetrieve a file from the remote host\n";
v6 = "To use: RETR <SP> <pathname> <CRLF>\n";
if ( !strcmp(a2, "RETR") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tStore a file on the remote host\n";
v6 = "To use: STOR <SP> <pathname> <CRLF>\n";
if ( !strcmp(a2, "STOR") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tStore a file uniquely\n";
v6 = "To use: STOU <CRLF>\n";
if ( !strcmp(a2, "STOU") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tAppend to a remote file\n";
v6 = "To use: APPE <SP> <pathname> <CRLF>\n";
if ( !strcmp(a2, "APPE") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tAbort a file transfer\n";
v6 = "To use: ABOR <CRLF>\n";
if ( !strcmp(a2, "ABOR") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tList contents of remote path\n";
v6 = "To use: LIST [<SP> <pathname>] <CRLF>\n";
if ( !strcmp(a2, "LIST") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tName list of remote directory\n";
v6 = "To use: NLST [<SP> <pathname>] <CRLF>\n";
if ( !strcmp(a2, "NLST") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tReturn remote system type\n";
v6 = "To use: SYST <CRLF>\n";
if ( !strcmp(a2, "SYST") )
return send_mesg_214_specific(v2, v6, v4);
v4 = "\tPrint local help information on using the server\n";
v6 = "To use: HELP [<SP> <string>] <CRLF>\n";
if ( !strcmp(a2, "HELP") )
return send_mesg_214_specific(v2, v6, v4);
if ( !strcmp(a2, "NOOP") )
{
v4 = "\tDo nothing; server sends an OK reply\n";
v6 = "To use: NOOP <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "ACCT") )
{
v4 = "\tSend account command to the remote server\n";
v6 = "To use: ACCT <SP> <account-information> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "CDUP") )
{
v4 = "\tChange remote working directory to parent directory\n";
v6 = "To use: CDUP <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "SMNT") )
{
v4 = "\tMount a different file system data structure withoutaltering their login\n\tor accounting information\n";
v6 = "To use: SMNT <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "REIN") )
{
v4 = "\tReinitialize the connection\n";
v6 = "To use: REIN <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "ALLO") )
{
v4 = "\tAllocate sufficient storage space to receive a file\n";
v6 = "To use: ALLO <SP> <decimal-integer> [<SP> R <SP> <decimal-integer>] <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "REST") )
{
v4 = "\tRestart transfer at bytecount marker\n";
v6 = "To use: REST <SP> <marker> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "RNFR") )
{
v4 = "\tUsed when renaming a file; rename from\n";
v6 = "To use: RNFR <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "RNTO") )
{
v4 = "\tUsed when renaming a file; rename to\n";
v6 = "To use: RNTO <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "DELE") )
{
v4 = "\tDelete a remote file\n";
v6 = "To use: DELE <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "SITE") )
{
v4 = "\tSend site specific command to the remote server\n";
v6 = "To use: SITE <SP> <string> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "STAT") )
{
v4 = "\tReturn current server status\n";
v6 = "To use: STAT [<SP> <pathname>] <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "CWD") )
{
v4 = "\tChange the current working directory on the remote machine\n";
v6 = "To use: CWD <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "RMD") )
{
v4 = "\tRemove a directory on the remote machine\n";
v6 = "To use: RMD <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "MKD") )
{
v4 = "\tCreate a directory on the remote machine\n";
v6 = "To use: MKD <SP> <pathname> <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
if ( !strcmp(a2, "PWD") )
{
v4 = "\tPrint the current working directory on the remote machine\n";
v6 = "To use: PWD <CRLF>\n";
return send_mesg_214_specific(v2, v6, v4);
}
return send_mesg_501(v2);
}

original_code:
void cmd_help (session_info_t *si, char *arg)
{
  int csfd = si->csfd;
  if (arg == ((void *)0)) {
    send_mesg_214_general (csfd);
    return;
  }
  if (strcmp (arg, "USER") == 0) {
    send_mesg_214_specific (csfd, "To use: USER <SP> <username> <CRLF>\n",
       "\tSend new user information\n");
  } else if (strcmp (arg, "PASS") == 0) {
    send_mesg_214_specific (csfd, "To use: PASS <SP> <password> <CRLF>\n",
       "\tSend a user password\n");
  } else if (strcmp (arg, "QUIT") == 0) {
    send_mesg_214_specific (csfd, "To use: QUIT <CRLF>\n",
       "\tTerminate the FTP session and exit\n");
  } else if (strcmp (arg, "PORT") == 0) {
    send_mesg_214_specific (csfd, "To use: PORT <SP> <host-port> <CRLF>\n",
       "\tOpen a specified data port\n");
  } else if (strcmp (arg, "PASV") == 0) {
    send_mesg_214_specific (csfd, "To use: PASV <CRLF>\n",
       "\tEnter passive transfer mode\n");
  } else if (strcmp (arg, "TYPE") == 0) {
    send_mesg_214_specific (csfd, "To use: TYPE <SP> <type-code> <CRLF>\n",
       "\tSet file transfer type\n");
  } else if (strcmp (arg, "STRU") == 0) {
    send_mesg_214_specific (csfd, "To use: STRU <SP> <structure-code> <CRLF>\n",
       "\tSet file transfer structure\n");
  } else if (strcmp (arg, "MODE") == 0) {
    send_mesg_214_specific (csfd, "To use: MODE <SP> <mode-code> <CRLF>\n",
       "\tSet file transfer mode\n");
  } else if (strcmp (arg, "RETR") == 0) {
    send_mesg_214_specific (csfd, "To use: RETR <SP> <pathname> <CRLF>\n",
       "\tRetrieve a file from the remote host\n");
  } else if (strcmp (arg, "STOR") == 0) {
    send_mesg_214_specific (csfd, "To use: STOR <SP> <pathname> <CRLF>\n",
       "\tStore a file on the remote host\n");
  } else if (strcmp (arg, "STOU") == 0) {
    send_mesg_214_specific (csfd, "To use: STOU <CRLF>\n",
       "\tStore a file uniquely\n");
  } else if (strcmp (arg, "APPE") == 0) {
    send_mesg_214_specific (csfd, "To use: APPE <SP> <pathname> <CRLF>\n",
       "\tAppend to a remote file\n");
  } else if (strcmp (arg, "ABOR") == 0) {
    send_mesg_214_specific (csfd, "To use: ABOR <CRLF>\n",
       "\tAbort a file transfer\n");
  } else if (strcmp (arg, "LIST") == 0) {
    send_mesg_214_specific (csfd, "To use: LIST [<SP> <pathname>] <CRLF>\n",
       "\tList contents of remote path\n");
  } else if (strcmp (arg, "NLST") == 0) {
    send_mesg_214_specific (csfd, "To use: NLST [<SP> <pathname>] <CRLF>\n",
       "\tName list of remote directory\n");
  } else if (strcmp (arg, "SYST") == 0) {
    send_mesg_214_specific (csfd, "To use: SYST <CRLF>\n",
       "\tReturn remote system type\n");
  } else if (strcmp (arg, "HELP") == 0) {
    send_mesg_214_specific (csfd, "To use: HELP [<SP> <string>] <CRLF>\n",
       "\tPrint local help information on using the server\n");
  } else if (strcmp (arg, "NOOP") == 0) {
    send_mesg_214_specific (csfd, "To use: NOOP <CRLF>\n",
       "\tDo nothing; server sends an OK reply\n");
  } else if (strcmp (arg, "ACCT") == 0) {
    send_mesg_214_specific (csfd, "To use: ACCT <SP> <account-information> <CRLF>\n",
       "\tSend account command to the remote server\n");
  } else if (strcmp (arg, "CDUP") == 0) {
    send_mesg_214_specific (csfd, "To use: CDUP <CRLF>\n",
       "\tChange remote working directory to parent directory\n");
  } else if (strcmp (arg, "SMNT") == 0) {
    send_mesg_214_specific (csfd, "To use: SMNT <SP> <pathname> <CRLF>\n",
       "\tMount a different file system data structure without"
       "altering their login\n\tor accounting information\n");
  } else if (strcmp (arg, "REIN") == 0) {
    send_mesg_214_specific (csfd, "To use: REIN <CRLF>\n",
       "\tReinitialize the connection\n");
  } else if (strcmp (arg, "ALLO") == 0) {
    send_mesg_214_specific (csfd, "To use: ALLO <SP> <decimal-integer> "
       "[<SP> R <SP> <decimal-integer>] <CRLF>\n",
       "\tAllocate sufficient storage space to receive a file\n");
  } else if (strcmp (arg, "REST") == 0) {
    send_mesg_214_specific (csfd, "To use: REST <SP> <marker> <CRLF>\n",
       "\tRestart transfer at bytecount marker\n");
  } else if (strcmp (arg, "RNFR") == 0) {
    send_mesg_214_specific (csfd, "To use: RNFR <SP> <pathname> <CRLF>\n",
       "\tUsed when renaming a file; rename from\n");
  } else if (strcmp (arg, "RNTO") == 0) {
    send_mesg_214_specific (csfd, "To use: RNTO <SP> <pathname> <CRLF>\n",
       "\tUsed when renaming a file; rename to\n");
  } else if (strcmp (arg, "DELE") == 0) {
    send_mesg_214_specific (csfd, "To use: DELE <SP> <pathname> <CRLF>\n",
       "\tDelete a remote file\n");
  } else if (strcmp (arg, "SITE") == 0) {
    send_mesg_214_specific (csfd, "To use: SITE <SP> <string> <CRLF>\n",
       "\tSend site specific command to the remote server\n");
  } else if (strcmp (arg, "STAT") == 0) {
    send_mesg_214_specific (csfd, "To use: STAT [<SP> <pathname>] <CRLF>\n",
       "\tReturn current server status\n");
  }else if (strcmp (arg, "CWD") == 0) {
    send_mesg_214_specific (csfd, "To use: CWD <SP> <pathname> <CRLF>\n",
       "\tChange the current working directory on the remote machine\n");
  } else if (strcmp (arg, "RMD") == 0) {
    send_mesg_214_specific (csfd, "To use: RMD <SP> <pathname> <CRLF>\n",
       "\tRemove a directory on the remote machine\n");
  } else if (strcmp (arg, "MKD") == 0) {
    send_mesg_214_specific (csfd, "To use: MKD <SP> <pathname> <CRLF>\n",
       "\tCreate a directory on the remote machine\n");
  } else if (strcmp (arg, "PWD") == 0) {
    send_mesg_214_specific (csfd, "To use: PWD <CRLF>\n",
       "\tPrint the current working directory on the remote machine\n");
  } else {
    send_mesg_501 (csfd);
  }
}

canonical_original_code:
void cmd_help(struct session_info_t *si, char *arg)
{
  int csfd = si->csfd;
  if (arg == ((void *)0)) {
    send_mesg_214_general (csfd);
    return;
  }
  if (strcmp (arg, "USER") == 0) {
    send_mesg_214_specific (csfd, "To use: USER <SP> <username> <CRLF>\n",
       "\tSend new user information\n");
  } else if (strcmp (arg, "PASS") == 0) {
    send_mesg_214_specific (csfd, "To use: PASS <SP> <password> <CRLF>\n",
       "\tSend a user password\n");
  } else if (strcmp (arg, "QUIT") == 0) {
    send_mesg_214_specific (csfd, "To use: QUIT <CRLF>\n",
       "\tTerminate the FTP session and exit\n");
  } else if (strcmp (arg, "PORT") == 0) {
    send_mesg_214_specific (csfd, "To use: PORT <SP> <host-port> <CRLF>\n",
       "\tOpen a specified data port\n");
  } else if (strcmp (arg, "PASV") == 0) {
    send_mesg_214_specific (csfd, "To use: PASV <CRLF>\n",
       "\tEnter passive transfer mode\n");
  } else if (strcmp (arg, "TYPE") == 0) {
    send_mesg_214_specific (csfd, "To use: TYPE <SP> <type-code> <CRLF>\n",
       "\tSet file transfer type\n");
  } else if (strcmp (arg, "STRU") == 0) {
    send_mesg_214_specific (csfd, "To use: STRU <SP> <structure-code> <CRLF>\n",
       "\tSet file transfer structure\n");
  } else if (strcmp (arg, "MODE") == 0) {
    send_mesg_214_specific (csfd, "To use: MODE <SP> <mode-code> <CRLF>\n",
       "\tSet file transfer mode\n");
  } else if (strcmp (arg, "RETR") == 0) {
    send_mesg_214_specific (csfd, "To use: RETR <SP> <pathname> <CRLF>\n",
       "\tRetrieve a file from the remote host\n");
  } else if (strcmp (arg, "STOR") == 0) {
    send_mesg_214_specific (csfd, "To use: STOR <SP> <pathname> <CRLF>\n",
       "\tStore a file on the remote host\n");
  } else if (strcmp (arg, "STOU") == 0) {
    send_mesg_214_specific (csfd, "To use: STOU <CRLF>\n",
       "\tStore a file uniquely\n");
  } else if (strcmp (arg, "APPE") == 0) {
    send_mesg_214_specific (csfd, "To use: APPE <SP> <pathname> <CRLF>\n",
       "\tAppend to a remote file\n");
  } else if (strcmp (arg, "ABOR") == 0) {
    send_mesg_214_specific (csfd, "To use: ABOR <CRLF>\n",
       "\tAbort a file transfer\n");
  } else if (strcmp (arg, "LIST") == 0) {
    send_mesg_214_specific (csfd, "To use: LIST [<SP> <pathname>] <CRLF>\n",
       "\tList contents of remote path\n");
  } else if (strcmp (arg, "NLST") == 0) {
    send_mesg_214_specific (csfd, "To use: NLST [<SP> <pathname>] <CRLF>\n",
       "\tName list of remote directory\n");
  } else if (strcmp (arg, "SYST") == 0) {
    send_mesg_214_specific (csfd, "To use: SYST <CRLF>\n",
       "\tReturn remote system type\n");
  } else if (strcmp (arg, "HELP") == 0) {
    send_mesg_214_specific (csfd, "To use: HELP [<SP> <string>] <CRLF>\n",
       "\tPrint local help information on using the server\n");
  } else if (strcmp (arg, "NOOP") == 0) {
    send_mesg_214_specific (csfd, "To use: NOOP <CRLF>\n",
       "\tDo nothing; server sends an OK reply\n");
  } else if (strcmp (arg, "ACCT") == 0) {
    send_mesg_214_specific (csfd, "To use: ACCT <SP> <account-information> <CRLF>\n",
       "\tSend account command to the remote server\n");
  } else if (strcmp (arg, "CDUP") == 0) {
    send_mesg_214_specific (csfd, "To use: CDUP <CRLF>\n",
       "\tChange remote working directory to parent directory\n");
  } else if (strcmp (arg, "SMNT") == 0) {
    send_mesg_214_specific (csfd, "To use: SMNT <SP> <pathname> <CRLF>\n",
       "\tMount a different file system data structure without"
       "altering their login\n\tor accounting information\n");
  } else if (strcmp (arg, "REIN") == 0) {
    send_mesg_214_specific (csfd, "To use: REIN <CRLF>\n",
       "\tReinitialize the connection\n");
  } else if (strcmp (arg, "ALLO") == 0) {
    send_mesg_214_specific (csfd, "To use: ALLO <SP> <decimal-integer> "
       "[<SP> R <SP> <decimal-integer>] <CRLF>\n",
       "\tAllocate sufficient storage space to receive a file\n");
  } else if (strcmp (arg, "REST") == 0) {
    send_mesg_214_specific (csfd, "To use: REST <SP> <marker> <CRLF>\n",
       "\tRestart transfer at bytecount marker\n");
  } else if (strcmp (arg, "RNFR") == 0) {
    send_mesg_214_specific (csfd, "To use: RNFR <SP> <pathname> <CRLF>\n",
       "\tUsed when renaming a file; rename from\n");
  } else if (strcmp (arg, "RNTO") == 0) {
    send_mesg_214_specific (csfd, "To use: RNTO <SP> <pathname> <CRLF>\n",
       "\tUsed when renaming a file; rename to\n");
  } else if (strcmp (arg, "DELE") == 0) {
    send_mesg_214_specific (csfd, "To use: DELE <SP> <pathname> <CRLF>\n",
       "\tDelete a remote file\n");
  } else if (strcmp (arg, "SITE") == 0) {
    send_mesg_214_specific (csfd, "To use: SITE <SP> <string> <CRLF>\n",
       "\tSend site specific command to the remote server\n");
  } else if (strcmp (arg, "STAT") == 0) {
    send_mesg_214_specific (csfd, "To use: STAT [<SP> <pathname>] <CRLF>\n",
       "\tReturn current server status\n");
  }else if (strcmp (arg, "CWD") == 0) {
    send_mesg_214_specific (csfd, "To use: CWD <SP> <pathname> <CRLF>\n",
       "\tChange the current working directory on the remote machine\n");
  } else if (strcmp (arg, "RMD") == 0) {
    send_mesg_214_specific (csfd, "To use: RMD <SP> <pathname> <CRLF>\n",
       "\tRemove a directory on the remote machine\n");
  } else if (strcmp (arg, "MKD") == 0) {
    send_mesg_214_specific (csfd, "To use: MKD <SP> <pathname> <CRLF>\n",
       "\tCreate a directory on the remote machine\n");
  } else if (strcmp (arg, "PWD") == 0) {
    send_mesg_214_specific (csfd, "To use: PWD <CRLF>\n",
       "\tPrint the current working directory on the remote machine\n");
  } else {
    send_mesg_501 (csfd);
  }
}

variable_types: struct session_info_t { int csfd; int dsfd; char cwd[4096]; char user[64]; _Bool loggedin; _Bool cmdComplete; _Bool cmdAbort; _Bool cmdQuit; char cmdString[4096]; char type; } *

variable_types: csfd int


decompiled_code:
__int64 __fastcall modify_cthread_count(int a1)
{
__int64 result; // rax
int v2; // eax

if ( !a1 )
return 0LL;
if ( pthread_mutex_lock(&ctrlCountMutex) )
{
fprintf(stderr, "%s: pthread_mutex_lock error\n", "modify_cthread_count");
result = 0xFFFFFFFFLL;
}
else
{
v2 = activeControlThreads - 1;
if ( a1 > 0 )
v2 = activeControlThreads + 1;
activeControlThreads = v2;
if ( pthread_mutex_unlock(&ctrlCountMutex) )
{
fprintf(stderr, "%s: pthread_mutex_unlock error\n", "modify_cthread_count");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

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

if ( !a1 )
return 0LL;
if ( pthread_mutex_lock(&ctrlCountMutex) )
{
fprintf(stderr, "%s: pthread_mutex_lock error\n", "modify_cthread_count");
result = 0xFFFFFFFFLL;
}
else
{
v2 = activeControlThreads - 1;
if ( a1 > 0 )
v2 = activeControlThreads + 1;
activeControlThreads = v2;
if ( pthread_mutex_unlock(&ctrlCountMutex) )
{
fprintf(stderr, "%s: pthread_mutex_unlock error\n", "modify_cthread_count");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int modify_cthread_count (int value)
{
  if (value == 0)
    return 0;
  if (pthread_mutex_lock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_lock error\n", __FUNCTION__);
    return -1;
  }
  if (value > 0)
    activeControlThreads++;
  else
    activeControlThreads--;
  if (pthread_mutex_unlock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_unlock error\n", __FUNCTION__);
    return -1;
  }
  return 0;
}

canonical_original_code:
int modify_cthread_count(int value)
{
  if (value == 0)
    return 0;
  if (pthread_mutex_lock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_lock error\n", __FUNCTION__);
    return -1;
  }
  if (value > 0)
    activeControlThreads++;
  else
    activeControlThreads--;
  if (pthread_mutex_unlock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_unlock error\n", __FUNCTION__);
    return -1;
  }
  return 0;
}

variable_types: value int


decompiled_code:
__int64 __fastcall control_thread(void *ptr)
{
while ( (unsigned int)send_mesg_220(*(unsigned int *)ptr) )
;
session(*(unsigned int *)ptr);
close(*(_DWORD *)ptr);
free(ptr);
modify_cthread_count(-1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *ptr)
{
while ( (unsigned int)send_mesg_220(*(unsigned int *)ptr) )
;
session(*(unsigned int *)ptr);
close(*(_DWORD *)ptr);
free(ptr);
func0(-1);
return 0LL;
}

original_code:
void *control_thread (void *arg) {
  int *csfd = arg;
  while (send_mesg_220 (*csfd) != 0);
  session (*csfd);
  close (*csfd);
  free (csfd);
  modify_cthread_count (-1);
  return ((void *)0);
}

canonical_original_code:
void *control_thread(void *arg) {
  int *csfd = arg;
  while (send_mesg_220 (*csfd) != 0);
  session (*csfd);
  close (*csfd);
  free (csfd);
  modify_cthread_count (-1);
  return ((void *)0);
}

variable_types:
arg
void *

variable_types:
csfd
int *

return_type: void *


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

if ( pthread_mutex_lock(&ctrlCountMutex) )
{
v0 = -1;
fprintf(stderr, "%s: pthread_mutex_lock error\n", "get_cthread_count");
}
else
{
v0 = activeControlThreads;
if ( pthread_mutex_unlock(&ctrlCountMutex) )
{
v0 = -1;
fprintf(stderr, "%s: pthread_mutex_unlock error\n", "get_cthread_count");
}
}
return v0;
}

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

if ( pthread_mutex_lock(&ctrlCountMutex) )
{
v0 = -1;
fprintf(stderr, "%s: pthread_mutex_lock error\n", "get_cthread_count");
}
else
{
v0 = activeControlThreads;
if ( pthread_mutex_unlock(&ctrlCountMutex) )
{
v0 = -1;
fprintf(stderr, "%s: pthread_mutex_unlock error\n", "get_cthread_count");
}
}
return v0;
}

original_code:
int get_cthread_count (void)
{
  int count;
  if (pthread_mutex_lock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_lock error\n", __FUNCTION__);
    return -1;
  }
  count = activeControlThreads;
  if (pthread_mutex_unlock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_unlock error\n", __FUNCTION__);
    return -1;
  }
  return count;
}

canonical_original_code:
int get_cthread_count()
{
  int count;
  if (pthread_mutex_lock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_lock error\n", __FUNCTION__);
    return -1;
  }
  count = activeControlThreads;
  if (pthread_mutex_unlock (&ctrlCountMutex) != 0) {
    fprintf (stderr, "%s: pthread_mutex_unlock error\n", __FUNCTION__);
    return -1;
  }
  return count;
}

variable_types: count int


decompiled_code:
int __fastcall cmd_stou(unsigned int *a1)
{
void *v1; // rbp
int *v2; // rax
unsigned int v3; // eax
unsigned int v4; // eax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

if ( *((_BYTE *)a1 + 4168) && strcmp((const char *)a1 + 4104, "anonymous") )
{
v3 = time(0LL);
srand(v3);
do
{
free(v1);
v4 = rand();
sprintf(v6, "%d", v4);
v1 = (void *)merge_paths(a1 + 2, v6, 0LL);
}
while ( access((const char *)v1, 0) != -1 );
v2 = _errno_location();
if ( *v2 == 2 )
{
free(v1);
LODWORD(v2) = store((__int64)a1, (__int64)v6, "w");
}
}
else
{
send_mesg_530(*a1, 114LL);
LODWORD(v2) = close(a1[1]);
a1[1] = 0;
}
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int *a1)
{
void *v1; // rbp
int *v2; // rax
unsigned int v3; // eax
unsigned int v4; // eax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

if ( *((_BYTE *)a1 + 4168) && strcmp((const char *)a1 + 4104, "anonymous") )
{
v3 = time(0LL);
srand(v3);
do
{
free(v1);
v4 = rand();
sprintf(v6, "%d", v4);
v1 = (void *)merge_paths(a1 + 2, v6, 0LL);
}
while ( access((const char *)v1, 0) != -1 );
v2 = _errno_location();
if ( *v2 == 2 )
{
free(v1);
LODWORD(v2) = func2((__int64)a1, (__int64)v6, "w");
}
}
else
{
send_mesg_530(*a1, 114LL);
LODWORD(v2) = close(a1[1]);
a1[1] = 0;
}
return (int)v2;
}

original_code:
void cmd_stou (session_info_t *si, char *arg)
{
  int rt;
  char tempname[256];
  char *fullpath;
  int csfd = si->csfd;
  if (si->loggedin == 0 || strcmp (si->user, "anonymous") == 0) {
    send_mesg_530 (csfd, 'r');
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  srand (time (((void *)0)));
  do {
    if (fullpath)
      free (fullpath);
    sprintf (tempname, "%d", rand());
    fullpath = merge_paths (si->cwd, tempname, ((void *)0));
    if ((rt = access (fullpath, 0)) == -1) {
      if ((*__errno_location ()) == 2)
 continue;
      else
 return;
    }
  } while (rt != -1);
  free (fullpath);
  store (si, tempname, "w");
  return;
}

canonical_original_code:
void cmd_stou(struct session_info_t *si, char *arg)
{
  int rt;
  char tempname[256];
  char *fullpath;
  int csfd = si->csfd;
  if (si->loggedin == 0 || strcmp (si->user, "anonymous") == 0) {
    send_mesg_530 (csfd, 'r');
    close (si->dsfd);
    si->dsfd = 0;
    return;
  }
  srand (time (((void *)0)));
  do {
    if (fullpath)
      free (fullpath);
    sprintf (tempname, "%d", rand());
    fullpath = merge_paths (si->cwd, tempname, ((void *)0));
    if ((rt = access (fullpath, 0)) == -1) {
      if ((*__errno_location ()) == 2)
 continue;
      else
 return;
    }
  } while (rt != -1);
  free (fullpath);
  store (si, tempname, "w");
  return;
}

variable_types:
arg
char *

variable_types: rt int

variable_types:
tempname
char [256]

variable_types:
fullpath
char *


decompiled_code:
__int64 __fastcall perm_neg_check(unsigned int *a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax

if ( !*((_BYTE *)a1 + 4168) || !strcmp((const char *)a1 + 4104, "anonymous") )
{
send_mesg_530(*a1, 114LL);
close(a1[1]);
a1[1] = 0;
result = 0xFFFFFFFFLL;
}
else
{
v2 = check_future_file(a1 + 2, a2, 0LL);
if ( v2 == -1 )
{
cleanup_stor_recv(a1, 0LL, 450);
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)(v2 + 3) <= 1 )
{
cleanup_stor_recv(a1, 0LL, 553);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax

if ( !*((_BYTE *)a1 + 4168) || !strcmp((const char *)a1 + 4104, "anonymous") )
{
send_mesg_530(*a1, 114LL);
close(a1[1]);
a1[1] = 0;
result = 0xFFFFFFFFLL;
}
else
{
v2 = check_future_file(a1 + 2, a2, 0LL);
if ( v2 == -1 )
{
func1(a1, 0LL, 450);
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)(v2 + 3) <= 1 )
{
func1(a1, 0LL, 553);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
static int perm_neg_check (session_info_t *si, char *arg)
{
  int pathCheck;
  if (si->loggedin == 0 || strcmp (si->user, "anonymous") == 0) {
    send_mesg_530 (si->csfd, 'r');
    close (si->dsfd);
    si->dsfd = 0;
    return -1;
  }
  if ((pathCheck = check_future_file (si->cwd, arg, 0)) == -1) {
    cleanup_stor_recv (si, ((void *)0), 450);
    return -1;
  } else if (pathCheck == -2) {
    cleanup_stor_recv (si, ((void *)0), 553);
    return -1;
  } else if (pathCheck == -3) {
    cleanup_stor_recv (si, ((void *)0), 553);
    return -1;
  }
  return 0;
}

canonical_original_code:
static int perm_neg_check(struct session_info_t *si, char *arg)
{
  int pathCheck;
  if (si->loggedin == 0 || strcmp (si->user, "anonymous") == 0) {
    send_mesg_530 (si->csfd, 'r');
    close (si->dsfd);
    si->dsfd = 0;
    return -1;
  }
  if ((pathCheck = check_future_file (si->cwd, arg, 0)) == -1) {
    cleanup_stor_recv (si, ((void *)0), 450);
    return -1;
  } else if (pathCheck == -2) {
    cleanup_stor_recv (si, ((void *)0), 553);
    return -1;
  } else if (pathCheck == -3) {
    cleanup_stor_recv (si, ((void *)0), 553);
    return -1;
  }
  return 0;
}

variable_types: pathCheck int


decompiled_code:
int __fastcall cmd_stor(unsigned int *a1, __int64 a2)
{
int result; // eax

result = perm_neg_check(a1, a2);
if ( result != -1 )
result = store((__int64)a1, a2, "w");
return result;
}

canonical_decompiled_code:
int __fastcall func5(unsigned int *a1, __int64 a2)
{
int result; // eax

result = func4(a1, a2);
if ( result != -1 )
result = func2((__int64)a1, a2, "w");
return result;
}

original_code:
void cmd_stor (session_info_t *si, char *cmd)
{
  if (perm_neg_check (si, cmd) == -1)
    return;
  store (si, cmd, "w");
  return;
}

canonical_original_code:
void cmd_stor(struct session_info_t *si, char *cmd)
{
  if (perm_neg_check (si, cmd) == -1)
    return;
  store (si, cmd, "w");
  return;
}

variable_types:
cmd
char *


decompiled_code:
int __fastcall cmd_appe(unsigned int *a1, __int64 a2)
{
int result; // eax

result = perm_neg_check(a1, a2);
if ( result != -1 )
result = store((__int64)a1, a2, "a");
return result;
}

canonical_decompiled_code:
int __fastcall func6(unsigned int *a1, __int64 a2)
{
int result; // eax

result = func4(a1, a2);
if ( result != -1 )
result = func2((__int64)a1, a2, "a");
return result;
}

original_code:
void cmd_appe (session_info_t *si, char *cmd)
{
  if (perm_neg_check (si, cmd) == -1)
    return;
  store (si, cmd, "a");
  return;
}

canonical_original_code:
void cmd_appe(struct session_info_t *si, char *cmd)
{
  if (perm_neg_check (si, cmd) == -1)
    return;
  store (si, cmd, "a");
  return;
}


decompiled_code:
__int64 __fastcall read_cmd(__int64 a1, int a2, __int64 a3)
{
unsigned int v4; // er12
__int64 v6; // rbx
int v7; // eax
_BYTE *v8; // rax
int v10; // edi
char *v11; // rax

v4 = 0;
v6 = 0LL;
do
{
while ( 1 )
{
while ( 1 )
{
v7 = recv(a2, (void *)(a1 + v6), 1uLL, 0);
if ( v7 != -1 )
break;
v10 = *_errno_location();
if ( v10 != 4 )
{
v11 = strerror(v10);
fprintf(stderr, "%s: recv: %s\n", "read_cmd", v11);
return 0xFFFFFFFFLL;
}
}
if ( v7 <= 0 )
break;
v4 += v7;
v6 = (int)v4;
v8 = (_BYTE *)(a1 + (int)v4 - 1);
if ( *v8 == 10 )
{
*v8 = 0;
return v4;
}
}
}
while ( v7 );
*(_WORD *)(a3 + 4170) = 257;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, __int64 a3)
{
unsigned int v4; // er12
__int64 v6; // rbx
int v7; // eax
_BYTE *v8; // rax
int v10; // edi
char *v11; // rax

v4 = 0;
v6 = 0LL;
do
{
while ( 1 )
{
while ( 1 )
{
v7 = recv(a2, (void *)(a1 + v6), 1uLL, 0);
if ( v7 != -1 )
break;
v10 = *_errno_location();
if ( v10 != 4 )
{
v11 = strerror(v10);
fprintf(stderr, "%s: recv: %s\n", "read_cmd", v11);
return 0xFFFFFFFFLL;
}
}
if ( v7 <= 0 )
break;
v4 += v7;
v6 = (int)v4;
v8 = (_BYTE *)(a1 + (int)v4 - 1);
if ( *v8 == 10 )
{
*v8 = 0;
return v4;
}
}
}
while ( v7 );
*(_WORD *)(a3 + 4170) = 257;
return v4;
}

original_code:
int read_cmd (char *str, int sock, session_info_t *si)
{
  int rt = 0;
  int len = 0;
  while (1) {
    if ((rt = recv (sock, str+len, 1, 0)) == -1) {
      if ((*__errno_location ()) == 4)
 continue;
      fprintf (stderr, "%s: recv: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
      return -1;
    }
    if (rt > 0) {
      len += rt;
      if (str[len-1] == '\n') {
 str[len-1] = '\0';
 break;
      }
    } else if (rt == 0) {
      si->cmdAbort = 1;
      si->cmdQuit = 1;
      break;
    }
  }
  return len;
}

canonical_original_code:
int read_cmd(char *str, int sock, struct session_info_t *si)
{
  int rt = 0;
  int len = 0;
  while (1) {
    if ((rt = recv (sock, str+len, 1, 0)) == -1) {
      if ((*__errno_location ()) == 4)
 continue;
      fprintf (stderr, "%s: recv: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
      return -1;
    }
    if (rt > 0) {
      len += rt;
      if (str[len-1] == '\n') {
 str[len-1] = '\0';
 break;
      }
    } else if (rt == 0) {
      si->cmdAbort = 1;
      si->cmdQuit = 1;
      break;
    }
  }
  return len;
}

variable_types:
str
char *

variable_types: sock int

variable_types: len int


session

decompiled_code:
__int64 __fastcall session(int a1)
{
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // r13
int v5; // edi
char *v6; // rax
int v8; // er8
int *v10; // rax
char *v11; // rax
int *v12; // rax
char *v13; // rax
int *v14; // rax
char *v15; // rax
unsigned int v16; // [rsp+Ch] [rbp-316Ch]
pthread_t newthread; // [rsp+18h] [rbp-3160h] BYREF
struct timeval timeout; // [rsp+20h] [rbp-3158h] BYREF
pthread_attr_t attr; // [rsp+30h] [rbp-3148h] BYREF
fd_set readfds; // [rsp+70h] [rbp-3108h] BYREF
char s1[4096]; // [rsp+F0h] [rbp-3088h] BYREF
int arg; // [rsp+10F0h] [rbp-2088h] BYREF
int fd; // [rsp+10F4h] [rbp-2084h]
__int16 v24; // [rsp+10F8h] [rbp-2080h]
char v25; // [rsp+20F8h] [rbp-1080h]
int v26; // [rsp+2138h] [rbp-1040h]
char dest[4156]; // [rsp+213Ch] [rbp-103Ch] BYREF

newthread = 0LL;
pthread_attr_init(&attr);
arg = a1;
fd = 0;
v25 = 0;
v26 = 0;
dest[0] = 0;
dest[4096] = 97;
v24 = 47;
s1[0] = 0;
if ( !shutdownServer )
{
v2 = 0LL;
v3 = a1 / 64;
v4 = 1LL << (a1 % 64);
while ( 1 )
{
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[v3] |= v4;
timeout.tv_sec = 0LL;
timeout.tv_usec = 100000LL;
if ( select(a1 + 1, &readfds, 0LL, 0LL, &timeout) == -1 )
break;
if ( (readfds.fds_bits[v3] & v4) != 0 )
{
if ( (unsigned int)read_cmd((__int64)s1, a1, (__int64)&arg) == -1 )
{
free_queue(v2);
return (unsigned int)-1;
}
v2 = add_to_queue(s1, v2);
}
if ( !strncasecmp(s1, "ABOR", 4uLL) )
{
BYTE2(v26) = 1;
s1[0] = 0;
send_mesg_226((unsigned int)a1, 97LL);
LABEL_8:
if ( shutdownServer )
goto LABEL_17;
goto LABEL_9;
}
if ( !newthread && v2 )
{
v2 = pull_from_queue(s1, v2);
strcpy(dest, s1);
s1[0] = 0;
if ( pthread_create(&newthread, &attr, (void *(*)(void *))&command_switch, &arg) == -1 )
{
v16 = -1;
v14 = _errno_location();
v15 = strerror(*v14);
fprintf(stderr, "%s: pthread_create: %s\n", "session", v15);
LABEL_13:
free_queue(v2);
return v16;
}
goto LABEL_8;
}
if ( !BYTE1(v26) )
goto LABEL_8;
v8 = pthread_join(newthread, 0LL);
if ( v8 == -1 )
goto LABEL_27;
dest[0] = 0;
newthread = 0LL;
BYTE1(v26) = 0;
if ( shutdownServer )
goto LABEL_17;
LABEL_9:
if ( HIBYTE(v26) )
goto LABEL_17;
}
v16 = -1;
v5 = *_errno_location();
if ( v5 != 4 )
{
v6 = strerror(v5);
fprintf(stderr, "%s: select: %s\n", "session", v6);
goto LABEL_13;
}
goto LABEL_8;
}
v2 = 0LL;
LABEL_17:
BYTE2(v26) = 1;
if ( newthread )
{
v8 = pthread_join(newthread, 0LL);
if ( v8 == -1 )
{
LABEL_27:
v16 = v8;
v12 = _errno_location();
v13 = strerror(*v12);
fprintf(stderr, "%s: pthread_join: %s\n", "session", v13);
goto LABEL_13;
}
}
if ( fd > 0 && close(fd) == -1 )
{
v10 = _errno_location();
v11 = strerror(*v10);
fprintf(stderr, "%s: close: %s\n", "session", v11);
}
free_queue(v2);
pthread_attr_destroy(&attr);
return 0;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // r13
int v5; // edi
char *v6; // rax
int v8; // er8
int *v10; // rax
char *v11; // rax
int *v12; // rax
char *v13; // rax
int *v14; // rax
char *v15; // rax
unsigned int v16; // [rsp+Ch] [rbp-316Ch]
pthread_t newthread; // [rsp+18h] [rbp-3160h] BYREF
struct timeval timeout; // [rsp+20h] [rbp-3158h] BYREF
pthread_attr_t attr; // [rsp+30h] [rbp-3148h] BYREF
fd_set readfds; // [rsp+70h] [rbp-3108h] BYREF
char s1[4096]; // [rsp+F0h] [rbp-3088h] BYREF
int arg; // [rsp+10F0h] [rbp-2088h] BYREF
int fd; // [rsp+10F4h] [rbp-2084h]
__int16 v24; // [rsp+10F8h] [rbp-2080h]
char v25; // [rsp+20F8h] [rbp-1080h]
int v26; // [rsp+2138h] [rbp-1040h]
char dest[4156]; // [rsp+213Ch] [rbp-103Ch] BYREF

newthread = 0LL;
pthread_attr_init(&attr);
arg = a1;
fd = 0;
v25 = 0;
v26 = 0;
dest[0] = 0;
dest[4096] = 97;
v24 = 47;
s1[0] = 0;
if ( !shutdownServer )
{
v2 = 0LL;
v3 = a1 / 64;
v4 = 1LL << (a1 % 64);
while ( 1 )
{
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[v3] |= v4;
timeout.tv_sec = 0LL;
timeout.tv_usec = 100000LL;
if ( select(a1 + 1, &readfds, 0LL, 0LL, &timeout) == -1 )
break;
if ( (readfds.fds_bits[v3] & v4) != 0 )
{
if ( (unsigned int)func0((__int64)s1, a1, (__int64)&arg) == -1 )
{
free_queue(v2);
return (unsigned int)-1;
}
v2 = add_to_queue(s1, v2);
}
if ( !strncasecmp(s1, "ABOR", 4uLL) )
{
BYTE2(v26) = 1;
s1[0] = 0;
send_mesg_226((unsigned int)a1, 97LL);
LABEL_8:
if ( shutdownServer )
goto LABEL_17;
goto LABEL_9;
}
if ( !newthread && v2 )
{
v2 = pull_from_queue(s1, v2);
strcpy(dest, s1);
s1[0] = 0;
if ( pthread_create(&newthread, &attr, (void *(*)(void *))&command_switch, &arg) == -1 )
{
v16 = -1;
v14 = _errno_location();
v15 = strerror(*v14);
fprintf(stderr, "%s: pthread_create: %s\n", "session", v15);
LABEL_13:
free_queue(v2);
return v16;
}
goto LABEL_8;
}
if ( !BYTE1(v26) )
goto LABEL_8;
v8 = pthread_join(newthread, 0LL);
if ( v8 == -1 )
goto LABEL_27;
dest[0] = 0;
newthread = 0LL;
BYTE1(v26) = 0;
if ( shutdownServer )
goto LABEL_17;
LABEL_9:
if ( HIBYTE(v26) )
goto LABEL_17;
}
v16 = -1;
v5 = *_errno_location();
if ( v5 != 4 )
{
v6 = strerror(v5);
fprintf(stderr, "%s: select: %s\n", "session", v6);
goto LABEL_13;
}
goto LABEL_8;
}
v2 = 0LL;
LABEL_17:
BYTE2(v26) = 1;
if ( newthread )
{
v8 = pthread_join(newthread, 0LL);
if ( v8 == -1 )
{
LABEL_27:
v16 = v8;
v12 = _errno_location();
v13 = strerror(*v12);
fprintf(stderr, "%s: pthread_join: %s\n", "session", v13);
goto LABEL_13;
}
}
if ( fd > 0 && close(fd) == -1 )
{
v10 = _errno_location();
v11 = strerror(*v10);
fprintf(stderr, "%s: close: %s\n", "session", v11);
}
free_queue(v2);
pthread_attr_destroy(&attr);
return 0;
}

original_code:
int session (int csfd)
{
  queue *cmdQueuePtr = ((void *)0);
  pthread_t commandThread = 0;
  session_info_t sessioninfo;
  pthread_attr_t attr;
  char commandstr[4096];
  struct timeval timeout;
  fd_set rfds;
  pthread_attr_init (&attr);
  sessioninfo.csfd = csfd;
  sessioninfo.dsfd = 0;
  sessioninfo.cmdAbort = 0;
  sessioninfo.cmdQuit = 0;
  sessioninfo.loggedin = 0;
  sessioninfo.cmdComplete = 0;
  sessioninfo.user[0] = '\0';
  sessioninfo.cmdString[0] = '\0';
  sessioninfo.type = 'a';
  strcpy (sessioninfo.cwd, "/");
  commandstr[0] = '\0';
  while (!shutdownServer && !sessioninfo.cmdQuit) {
    do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&rfds)->fds_bits)[0]) : "memory"); } while (0);
    ((void) (((&rfds)->fds_bits)[((csfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((csfd) % (8 * (int) sizeof (__fd_mask)))))));
    timeout.tv_sec = 0;
    timeout.tv_usec = 100000;
    if (select (csfd+1, &rfds, ((void *)0), ((void *)0), &timeout) == -1) {
      if ((*__errno_location ()) == 4)
 continue;
      fprintf (stderr, "%s: select: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
      free_queue (cmdQueuePtr);
      return -1;
    }
    if (((((&rfds)->fds_bits)[((csfd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((csfd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
      if (read_cmd (commandstr, csfd, &sessioninfo) == -1) {
 free_queue (cmdQueuePtr);
 return -1;
      }
      cmdQueuePtr = add_to_queue (commandstr, cmdQueuePtr);
    }
    if (strncasecmp (commandstr, "ABOR", 4) == 0) {
      sessioninfo.cmdAbort = 1;
      commandstr[0] = '\0';
      send_mesg_226 (csfd, 'a');
    }
    else if (commandThread == 0 && cmdQueuePtr) {
      if (cmdQueuePtr) {
 cmdQueuePtr = pull_from_queue (commandstr, cmdQueuePtr);
      }
      strcpy (sessioninfo.cmdString, commandstr);
      commandstr[0] = '\0';
      if (pthread_create (&commandThread, &attr, &command_switch, (void*) &sessioninfo) == -1) {
 fprintf (stderr, "%s: pthread_create: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
 free_queue (cmdQueuePtr);
 return -1;
      }
    } else if (sessioninfo.cmdComplete) {
      if (pthread_join (commandThread, ((void *)0)) == -1) {
 fprintf (stderr, "%s: pthread_join: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
 free_queue (cmdQueuePtr);
 return -1;
      }
      commandThread = 0;
      sessioninfo.cmdString[0] = '\0';
      sessioninfo.cmdComplete = 0;
    }
  }
  sessioninfo.cmdAbort = 1;
  if (commandThread) {
    if (pthread_join (commandThread, ((void *)0)) == -1) {
      fprintf (stderr, "%s: pthread_join: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
      free_queue (cmdQueuePtr);
      return -1;
    }
  }
  if (sessioninfo.dsfd > 0) {
    if (close (sessioninfo.dsfd) == -1)
      fprintf (stderr, "%s: close: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
  }
  free_queue (cmdQueuePtr);
  pthread_attr_destroy (&attr);
  return 0;
}

canonical_original_code:
int session(int csfd)
{
  struct node *cmdQueuePtr = ((void *)0);
  unsigned long commandThread = 0;
  struct session_info_t sessioninfo;
  union pthread_attr_t attr;
  char commandstr[4096];
  struct timeval timeout;
  struct fd_set rfds;
  pthread_attr_init (&attr);
  sessioninfo.csfd = csfd;
  sessioninfo.dsfd = 0;
  sessioninfo.cmdAbort = 0;
  sessioninfo.cmdQuit = 0;
  sessioninfo.loggedin = 0;
  sessioninfo.cmdComplete = 0;
  sessioninfo.user[0] = '\0';
  sessioninfo.cmdString[0] = '\0';
  sessioninfo.type = 'a';
  strcpy (sessioninfo.cwd, "/");
  commandstr[0] = '\0';
  while (!shutdownServer && !sessioninfo.cmdQuit) {
    do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&rfds)->fds_bits)[0]) : "memory"); } while (0);
    ((void) (((&rfds)->fds_bits)[((csfd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((csfd) % (8 * (int) sizeof (__fd_mask)))))));
    timeout.tv_sec = 0;
    timeout.tv_usec = 100000;
    if (select (csfd+1, &rfds, ((void *)0), ((void *)0), &timeout) == -1) {
      if ((*__errno_location ()) == 4)
 continue;
      fprintf (stderr, "%s: select: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
      free_queue (cmdQueuePtr);
      return -1;
    }
    if (((((&rfds)->fds_bits)[((csfd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((csfd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
      if (read_cmd (commandstr, csfd, &sessioninfo) == -1) {
 free_queue (cmdQueuePtr);
 return -1;
      }
      cmdQueuePtr = add_to_queue (commandstr, cmdQueuePtr);
    }
    if (strncasecmp (commandstr, "ABOR", 4) == 0) {
      sessioninfo.cmdAbort = 1;
      commandstr[0] = '\0';
      send_mesg_226 (csfd, 'a');
    }
    else if (commandThread == 0 && cmdQueuePtr) {
      if (cmdQueuePtr) {
 cmdQueuePtr = pull_from_queue (commandstr, cmdQueuePtr);
      }
      strcpy (sessioninfo.cmdString, commandstr);
      commandstr[0] = '\0';
      if (pthread_create (&commandThread, &attr, &command_switch, (void *) &sessioninfo) == -1) {
 fprintf (stderr, "%s: pthread_create: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
 free_queue (cmdQueuePtr);
 return -1;
      }
    } else if (sessioninfo.cmdComplete) {
      if (pthread_join (commandThread, ((void *)0)) == -1) {
 fprintf (stderr, "%s: pthread_join: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
 free_queue (cmdQueuePtr);
 return -1;
      }
      commandThread = 0;
      sessioninfo.cmdString[0] = '\0';
      sessioninfo.cmdComplete = 0;
    }
  }
  sessioninfo.cmdAbort = 1;
  if (commandThread) {
    if (pthread_join (commandThread, ((void *)0)) == -1) {
      fprintf (stderr, "%s: pthread_join: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
      free_queue (cmdQueuePtr);
      return -1;
    }
  }
  if (sessioninfo.dsfd > 0) {
    if (close (sessioninfo.dsfd) == -1)
      fprintf (stderr, "%s: close: %s\n", __FUNCTION__, strerror ((*__errno_location ())));
  }
  free_queue (cmdQueuePtr);
  pthread_attr_destroy (&attr);
  return 0;
}

variable_types: struct node { char cmd[4096]; struct node *next; } *

variable_types:
commandThread
unsigned long

variable_types: struct session_info_t { int csfd; int dsfd; char cwd[4096]; char user[64]; _Bool loggedin; _Bool cmdComplete; _Bool cmdAbort; _Bool cmdQuit; char cmdString[4096]; char type; }

variable_types: union pthread_attr_t { char __size[56]; long __align; }

variable_types:
commandstr
char [4096]

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types:
rfds
struct fd_set { long fds_bits[-1]; }


decompiled_code:
void __fastcall putLittleEnd32(_DWORD *a1, int a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func0(_DWORD *a1, int a2)
{
*a1 = a2;
}

original_code:
static inline void putLittleEnd32(byte_t *location, uint32_t value)
{
  location[0] = (byte_t)((value ) & 0xFF);
  location[1] = (byte_t)((value >> 8) & 0xFF);
  location[2] = (byte_t)((value >> 16) & 0xFF);
  location[3] = (byte_t)((value >> 24) & 0xFF);
}

canonical_original_code:
static inline void putLittleEnd32(unsigned char *location, unsigned int value)
{
  location[0] = (byte_t)((value ) & 0xFF);
  location[1] = (byte_t)((value >> 8) & 0xFF);
  location[2] = (byte_t)((value >> 16) & 0xFF);
  location[3] = (byte_t)((value >> 24) & 0xFF);
}

variable_types:
location
unsigned char *

variable_types:
value
unsigned int


decompiled_code:
void __fastcall putLittleEnd64(_QWORD *a1, __int64 a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1, __int64 a2)
{
*a1 = a2;
}

original_code:
static inline void putLittleEnd64(byte_t *location, uint64_t value)
{
  location[0] = (byte_t)((value ) & 0xFF);
  location[1] = (byte_t)((value >> 8) & 0xFF);
  location[2] = (byte_t)((value >> 16) & 0xFF);
  location[3] = (byte_t)((value >> 24) & 0xFF);
  location[4] = (byte_t)((value >> 32) & 0xFF);
  location[5] = (byte_t)((value >> 40) & 0xFF);
  location[6] = (byte_t)((value >> 48) & 0xFF);
  location[7] = (byte_t)((value >> 56) & 0xFF);
}

canonical_original_code:
static inline void putLittleEnd64(unsigned char *location, unsigned long value)
{
  location[0] = (byte_t)((value ) & 0xFF);
  location[1] = (byte_t)((value >> 8) & 0xFF);
  location[2] = (byte_t)((value >> 16) & 0xFF);
  location[3] = (byte_t)((value >> 24) & 0xFF);
  location[4] = (byte_t)((value >> 32) & 0xFF);
  location[5] = (byte_t)((value >> 40) & 0xFF);
  location[6] = (byte_t)((value >> 48) & 0xFF);
  location[7] = (byte_t)((value >> 56) & 0xFF);
}

variable_types:
value
unsigned long


decompiled_code:
__int64 __fastcall getLittleEnd32(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1)
{
return *a1;
}

original_code:
static inline uint32_t getLittleEnd32(const byte_t *location)
{
  return
    (((uint32_t)(location[0])) ) |
    (((uint32_t)(location[1])) << 8) |
    (((uint32_t)(location[2])) << 16) |
    (((uint32_t)(location[3])) << 24);
}

canonical_original_code:
static inline unsigned int getLittleEnd32(unsigned char *location)
{
  return
    (((unsigned int)(location[0])) ) |
    (((unsigned int)(location[1])) << 8) |
    (((unsigned int)(location[2])) << 16) |
    (((unsigned int)(location[3])) << 24);
}

return_type: unsigned int


decompiled_code:
__int64 __fastcall circShiftLeft32(int a1, char a2)
{
return (unsigned int)__ROL4__(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, char a2)
{
return (unsigned int)__ROL4__(a1, a2);
}

original_code:
static inline uint32_t circShiftLeft32(uint32_t value, int amount)
{
  if ((amount &= 31) == 0)
    return value;
  return (value << amount) | (value >> (32 - amount));
}

canonical_original_code:
static inline unsigned int circShiftLeft32(unsigned int value, int amount)
{
  if ((amount &= 31) == 0)
    return value;
  return (value << amount) | (value >> (32 - amount));
}

variable_types: amount int


canonical_original_code:
static void md5ProcessBlock(struct md5CTX *ctx, unsigned char *block)
{
  unsigned int a = ctx->h[0];
  unsigned int b = ctx->h[1];
  unsigned int c = ctx->h[2];
  unsigned int d = ctx->h[3];
  unsigned int w[16];
  unsigned int f; unsigned int k; unsigned int temp;
  int i;
  for (i = 0; i < 16; i++)
    w[i] = getLittleEnd32(block + i*4);
  for (i = 0; i < 64; i++) {
    if (i < 16) {
      f = (b & c) | ((~b) & d);
      k = i;
    }
    else if (i < 32) {
      f = (d & b) | ((~d) & c);
      k = ((i << 2) + i + 1) & (0x0F);
    }
    else if (i < 48) {
      f = b ^ c ^ d;
      k = ((i << 1) + i + 5) & (0x0F);
    }
    else {
      f = c ^ (b | (~d));
      k = ((i << 3) - i) & (0x0F);
    }
    temp = d;
    d = c;
    c = b;
    b = b + circShiftLeft32((a + f + SINE[i] + w[k]), ROTATION[i]);
    a = temp;
  }
  ctx->h[0] += a;
  ctx->h[1] += b;
  ctx->h[2] += c;
  ctx->h[3] += d;
}

variable_types: struct md5CTX { unsigned int h[4]; unsigned long bytesProcessed; unsigned char block[-1]; unsigned char bytesInBlock; } *

variable_types:
block
unsigned char *

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
c
unsigned int

variable_types:
d
unsigned int

variable_types:
w
unsigned int [16]

variable_types:
f
unsigned int

variable_types:
k
unsigned int

variable_types:
temp
unsigned int

variable_types: i int


original_code:
void md5Start(void *c)
{
  struct md5CTX *ctx = (struct md5CTX *)c;
  ctx->h[0] = (uint32_t)0x67452301;
  ctx->h[1] = (uint32_t)0xEFCDAB89;
  ctx->h[2] = (uint32_t)0x98BADCFE;
  ctx->h[3] = (uint32_t)0x10325476;
  ctx->bytesProcessed = 0;
  ctx->bytesInBlock = 0;
}

canonical_original_code:
void md5Start(void *c)
{
  struct md5CTX *ctx = (struct md5CTX *)c;
  ctx->h[0] = (unsigned int)0x67452301;
  ctx->h[1] = (unsigned int)0xEFCDAB89;
  ctx->h[2] = (unsigned int)0x98BADCFE;
  ctx->h[3] = (unsigned int)0x10325476;
  ctx->bytesProcessed = 0;
  ctx->bytesInBlock = 0;
}

variable_types:
c
void *

user_defined_types: struct md5CTX { unsigned int h[4]; unsigned long bytesProcessed; unsigned char block[-1]; unsigned char bytesInBlock; }


decompiled_code:
__int64 __fastcall md5Add(__int64 a1, unsigned int *a2)
{
unsigned __int64 v2; // rdx
unsigned __int64 v3; // rax
unsigned __int64 v4; // r13
unsigned __int64 v6; // rax
__int64 v8; // rdi
unsigned int *v9; // rsi
size_t v10; // rbx
unsigned int *v12; // rsi
unsigned int v13; // [rsp+Ch] [rbp-3Ch]

v13 = sizeIsLargerThan64_constprop_0();
if ( v13 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a1 + 16);
v4 = v2;
if ( ~v2 < v3 )
return (unsigned int)-1;
v6 = v2 + v3;
*(_QWORD *)(a1 + 16) = v6;
if ( v6 > 0x1FFFFFFFFFFFFFFFLL )
return (unsigned int)-1;
LABEL_4:
while ( v4 )
{
while ( 1 )
{
v8 = *(unsigned __int8 *)(a1 + 88);
if ( !(_BYTE)v8 && v4 > 0x3F )
{
v12 = a2;
a2 += 16;
v4 -= 64LL;
md5ProcessBlock((int *)a1, v12);
goto LABEL_4;
}
v9 = a2;
v10 = 64 - (unsigned __int8)v8;
if ( v10 > v4 )
v10 = v4;
a2 = (unsigned int *)((char *)a2 + v10);
v4 -= v10;
memcpy((void *)(a1 + 24 + v8), v9, v10);
if ( (_BYTE)v10 + *(_BYTE *)(a1 + 88) == 64 )
break;
*(_BYTE *)(a1 + 88) += v10;
if ( !v4 )
return v13;
}
*(_BYTE *)(a1 + 88) = 0;
md5ProcessBlock((int *)a1, (unsigned int *)(a1 + 24));
}
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int *a2)
{
unsigned __int64 v2; // rdx
unsigned __int64 v3; // rax
unsigned __int64 v4; // r13
unsigned __int64 v6; // rax
__int64 v8; // rdi
unsigned int *v9; // rsi
size_t v10; // rbx
unsigned int *v12; // rsi
unsigned int v13; // [rsp+Ch] [rbp-3Ch]

v13 = func5();
if ( v13 )
return (unsigned int)-1;
v3 = *(_QWORD *)(a1 + 16);
v4 = v2;
if ( ~v2 < v3 )
return (unsigned int)-1;
v6 = v2 + v3;
*(_QWORD *)(a1 + 16) = v6;
if ( v6 > 0x1FFFFFFFFFFFFFFFLL )
return (unsigned int)-1;
LABEL_4:
while ( v4 )
{
while ( 1 )
{
v8 = *(unsigned __int8 *)(a1 + 88);
if ( !(_BYTE)v8 && v4 > 0x3F )
{
v12 = a2;
a2 += 16;
v4 -= 64LL;
func4((int *)a1, v12);
goto LABEL_4;
}
v9 = a2;
v10 = 64 - (unsigned __int8)v8;
if ( v10 > v4 )
v10 = v4;
a2 = (unsigned int *)((char *)a2 + v10);
v4 -= v10;
memcpy((void *)(a1 + 24 + v8), v9, v10);
if ( (_BYTE)v10 + *(_BYTE *)(a1 + 88) == 64 )
break;
*(_BYTE *)(a1 + 88) += v10;
if ( !v4 )
return v13;
}
*(_BYTE *)(a1 + 88) = 0;
func4((int *)a1, (unsigned int *)(a1 + 24));
}
return v13;
}

original_code:
int md5Add(void *c, const byte_t *bytes, size_t numBytes)
{
  struct md5CTX *ctx = (struct md5CTX *)c;
  size_t toFillBlock, addToCtx;
  if (sizeIsLargerThan64(numBytes) ||
      (18446744073709551615UL) - (uint64_t)numBytes < ctx->bytesProcessed)
    return -1;
  ctx->bytesProcessed = (uint64_t)numBytes + ctx->bytesProcessed;
  if (ctx->bytesProcessed > ((uint64_t)(0x1FFFFFFFFFFFFFFFLLU)))
    return -1;
  while (numBytes > 0) {
    if (ctx->bytesInBlock == 0 && numBytes >= (64)) {
      md5ProcessBlock(ctx, bytes);
      bytes += (64);
      numBytes -= (64);
    }
    else {
      toFillBlock = (64) - ctx->bytesInBlock;
      addToCtx = (toFillBlock < numBytes ? toFillBlock : numBytes);
      memcpy(ctx->block + ctx->bytesInBlock, bytes, addToCtx);
      ctx->bytesInBlock += addToCtx;
      bytes += addToCtx;
      numBytes -= addToCtx;
      if (ctx->bytesInBlock == (64)) {
 ctx->bytesInBlock = 0;
 md5ProcessBlock(ctx, ctx->block);
      }
    }
  }
  return 0;
}

canonical_original_code:
int md5Add(void *c, unsigned char *bytes, unsigned long numBytes)
{
  struct md5CTX *ctx = (struct md5CTX *)c;
  unsigned long toFillBlock; unsigned long addToCtx;
  if (sizeIsLargerThan64(numBytes) ||
      (18446744073709551615UL) - (unsigned long)numBytes < ctx->bytesProcessed)
    return -1;
  ctx->bytesProcessed = (unsigned long)numBytes + ctx->bytesProcessed;
  if (ctx->bytesProcessed > ((unsigned long)(0x1FFFFFFFFFFFFFFFLLU)))
    return -1;
  while (numBytes > 0) {
    if (ctx->bytesInBlock == 0 && numBytes >= (64)) {
      md5ProcessBlock(ctx, bytes);
      bytes += (64);
      numBytes -= (64);
    }
    else {
      toFillBlock = (64) - ctx->bytesInBlock;
      addToCtx = (toFillBlock < numBytes ? toFillBlock : numBytes);
      memcpy(ctx->block + ctx->bytesInBlock, bytes, addToCtx);
      ctx->bytesInBlock += addToCtx;
      bytes += addToCtx;
      numBytes -= addToCtx;
      if (ctx->bytesInBlock == (64)) {
 ctx->bytesInBlock = 0;
 md5ProcessBlock(ctx, ctx->block);
      }
    }
  }
  return 0;
}

variable_types:
bytes
unsigned char *

variable_types:
numBytes
unsigned long

variable_types:
toFillBlock
unsigned long

variable_types:
addToCtx
unsigned long


original_code:
void md5End(void *c, byte_t *digest)
{
  struct md5CTX *ctx = (struct md5CTX *)c;
  byte_t toAppend[(64)+8];
  uint64_t totalBits;
  size_t numToAppend;
  int i;
  totalBits = ctx->bytesProcessed * 8;
  if (ctx->bytesInBlock < 56)
    numToAppend = 56 - ctx->bytesInBlock;
  else
    numToAppend = (64) - (ctx->bytesInBlock - 56);
  toAppend[0] = (byte_t)(0x80);
  memset(toAppend+1, 0, numToAppend-1);
  putLittleEnd64(toAppend + numToAppend, totalBits);
  md5Add(ctx, toAppend, numToAppend + 8);
  for (i = 0; i < 4; i++)
    putLittleEnd32(digest + i*4, ctx->h[i]);
}

canonical_original_code:
void md5End(void *c, unsigned char *digest)
{
  struct md5CTX *ctx = (struct md5CTX *)c;
  unsigned char toAppend[-1];
  unsigned long totalBits;
  unsigned long numToAppend;
  int i;
  totalBits = ctx->bytesProcessed * 8;
  if (ctx->bytesInBlock < 56)
    numToAppend = 56 - ctx->bytesInBlock;
  else
    numToAppend = (64) - (ctx->bytesInBlock - 56);
  toAppend[0] = (byte_t)(0x80);
  memset(toAppend+1, 0, numToAppend-1);
  putLittleEnd64(toAppend + numToAppend, totalBits);
  md5Add(ctx, toAppend, numToAppend + 8);
  for (i = 0; i < 4; i++)
    putLittleEnd32(digest + i*4, ctx->h[i]);
}

variable_types:
digest
unsigned char *

variable_types:
toAppend
unsigned char [-1]

variable_types:
totalBits
unsigned long

variable_types:
numToAppend
unsigned long


decompiled_code:
__int64 __fastcall trim_whitespace(const char *a1)
{
char *v1; // r12
const char *v2; // rbx
__int64 v3; // r13
const char *v4; // rbp
const unsigned __int16 *v5; // rax
__int64 v6; // rdx
__int64 v7; // rdx
unsigned __int8 *v8; // rbp
__int64 v9; // rdx
__int64 result; // rax

v1 = (char *)a1;
v2 = a1 - 1;
v3 = (int)strlen(a1);
v4 = &a1[v3];
v5 = *_ctype_b_loc();
do
v6 = *++v2;
while ( (v5[v6] & 0x2000) != 0 );
v7 = *(v4 - 1);
v8 = (unsigned __int8 *)(v4 - 1);
if ( (v5[v7] & 0x2000) != 0 )
{
do
{
if ( v2 == (const char *)v8 )
break;
v9 = (char)*--v8;
}
while ( (v5[v9] & 0x2000) != 0 );
}
result = (__int64)&a1[v3 - 1];
if ( v8 != (unsigned __int8 *)result )
{
v8[1] = 0;
LABEL_8:
if ( a1 == v2 )
return result;
goto LABEL_11;
}
if ( a1 == v2 )
return result;
if ( v2 != (const char *)v8 )
goto LABEL_8;
*a1 = 0;
LABEL_11:
while ( 1 )
{
result = *(unsigned __int8 *)v2;
if ( !(_BYTE)result )
break;
*v1++ = result;
++v2;
}
*v1 = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
char *v1; // r12
const char *v2; // rbx
__int64 v3; // r13
const char *v4; // rbp
const unsigned __int16 *v5; // rax
__int64 v6; // rdx
__int64 v7; // rdx
unsigned __int8 *v8; // rbp
__int64 v9; // rdx
__int64 result; // rax

v1 = (char *)a1;
v2 = a1 - 1;
v3 = (int)strlen(a1);
v4 = &a1[v3];
v5 = *_ctype_b_loc();
do
v6 = *++v2;
while ( (v5[v6] & 0x2000) != 0 );
v7 = *(v4 - 1);
v8 = (unsigned __int8 *)(v4 - 1);
if ( (v5[v7] & 0x2000) != 0 )
{
do
{
if ( v2 == (const char *)v8 )
break;
v9 = (char)*--v8;
}
while ( (v5[v9] & 0x2000) != 0 );
}
result = (__int64)&a1[v3 - 1];
if ( v8 != (unsigned __int8 *)result )
{
v8[1] = 0;
LABEL_8:
if ( a1 == v2 )
return result;
goto LABEL_11;
}
if ( a1 == v2 )
return result;
if ( v2 != (const char *)v8 )
goto LABEL_8;
*a1 = 0;
LABEL_11:
while ( 1 )
{
result = *(unsigned __int8 *)v2;
if ( !(_BYTE)result )
break;
*v1++ = result;
++v2;
}
*v1 = 0;
return result;
}

original_code:
static void trim_whitespace (char *string)
{
  int length;
  char *head;
  char *tail;
  length = strlen (string);
  head = string - 1;
  tail = string + length;
  while (((*__ctype_b_loc ())[(int) ((*(++head)))] & (unsigned short int) _ISspace));
  while (((*__ctype_b_loc ())[(int) ((*(--tail)))] & (unsigned short int) _ISspace) && (tail != head));
  if ((string + length - 1) != tail) {
    *(tail + 1) = '\0';
  } else if ((head != string) && (tail == head)) {
    *string = '\0';
  }
  tail = string;
  if (head != string) {
    while (*head) *tail++ = *head++;
    *tail = '\0';
  }
}

canonical_original_code:
static void trim_whitespace(char *string)
{
  int length;
  char *head;
  char *tail;
  length = strlen (string);
  head = string - 1;
  tail = string + length;
  while (((*__ctype_b_loc ())[(int) ((*(++head)))] & (unsigned short) _ISspace));
  while (((*__ctype_b_loc ())[(int) ((*(--tail)))] & (unsigned short) _ISspace) && (tail != head));
  if ((string + length - 1) != tail) {
    *(tail + 1) = '\0';
  } else if ((head != string) && (tail == head)) {
    *string = '\0';
  }
  tail = string;
  if (head != string) {
    while (*head) *tail++ = *head++;
    *tail = '\0';
  }
}

variable_types:
string
char *

variable_types: length int

variable_types:
head
char *

variable_types:
tail
char *


decompiled_code:
__int64 __fastcall get_arg_count(const char *a1)
{
unsigned int v1; // er12
int v2; // ebx
size_t v3; // rbp
const unsigned __int16 **v4; // rax
const unsigned __int16 *v5; // rsi
size_t v6; // rdx
unsigned __int8 v7; // al
bool v8; // cl

v1 = 0;
v2 = 0;
v3 = strlen(a1);
while ( v2 < v3 )
{
v4 = _ctype_b_loc();
v5 = *v4;
if ( ((*v4)[a1[v2]] & 0x2000) == 0 )
{
v6 = v2 + 1;
do
{
v2 = v6;
v7 = (v5[a1[v6]] >> 13) ^ 1;
v8 = v3 > v6++;
}
while ( (v7 & v8) != 0 );
++v1;
}
++v2;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
unsigned int v1; // er12
int v2; // ebx
size_t v3; // rbp
const unsigned __int16 **v4; // rax
const unsigned __int16 *v5; // rsi
size_t v6; // rdx
unsigned __int8 v7; // al
bool v8; // cl

v1 = 0;
v2 = 0;
v3 = strlen(a1);
while ( v2 < v3 )
{
v4 = _ctype_b_loc();
v5 = *v4;
if ( ((*v4)[a1[v2]] & 0x2000) == 0 )
{
v6 = v2 + 1;
do
{
v2 = v6;
v7 = (v5[a1[v6]] >> 13) ^ 1;
v8 = v3 > v6++;
}
while ( (v7 & v8) != 0 );
++v1;
}
++v2;
}
return v1;
}

original_code:
int get_arg_count (const char *cmdString)
{
  int argCount = 0;
  for (int i = 0; i < strlen (cmdString); i++) {
    if (!((*__ctype_b_loc ())[(int) ((cmdString[i]))] & (unsigned short int) _ISspace)) {
      while (!((*__ctype_b_loc ())[(int) ((cmdString[i]))] & (unsigned short int) _ISspace) && (i < strlen (cmdString))) {
 i++;
      }
      argCount++;
    }
  }
  return argCount;
}

canonical_original_code:
int get_arg_count(char *cmdString)
{
  int argCount = 0;
  for (int i = 0; i < strlen (cmdString); i++) {
    if (!((*__ctype_b_loc ())[(int) ((cmdString[i]))] & (unsigned short) _ISspace)) {
      while (!((*__ctype_b_loc ())[(int) ((cmdString[i]))] & (unsigned short) _ISspace) && (i < strlen (cmdString))) {
 i++;
      }
      argCount++;
    }
  }
  return argCount;
}

variable_types:
cmdString
char *

variable_types: argCount int


decompiled_code:
size_t __fastcall convert_to_upper(char *s)
{
unsigned __int64 i; // rbx
size_t result; // rax

for ( i = 0LL; ; ++i )
{
result = strlen(s);
if ( result <= i )
break;
s[i] = (*_ctype_toupper_loc())[s[i]];
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func2(char *s)
{
unsigned __int64 i; // rbx
size_t result; // rax

for ( i = 0LL; ; ++i )
{
result = strlen(s);
if ( result <= i )
break;
s[i] = (*_ctype_toupper_loc())[s[i]];
}
return result;
}

original_code:
void convert_to_upper (char *string)
{
  int i;
  for (i = 0; i < strlen (string); i++) {
    string[i] = toupper (string[i]);
  }
}

canonical_original_code:
void convert_to_upper(char *string)
{
  int i;
  for (i = 0; i < strlen (string); i++) {
    string[i] = toupper (string[i]);
  }
}


decompiled_code:
const char *__fastcall separate_cmd_from_args(const char **a1, int a2)
{
const unsigned __int16 **v2; // rax
const char *v3; // r12
const unsigned __int16 *v4; // rcx
const char *v5; // rdx
__int64 v6; // rax

trim_whitespace(*a1);
if ( a2 == 1 )
{
v3 = 0LL;
convert_to_upper((char *)*a1);
}
else
{
v2 = _ctype_b_loc();
v3 = *a1;
v4 = *v2;
do
{
v5 = v3;
v6 = *v3++;
}
while ( (v4[v6] & 0x2000) == 0 );
*v5 = 0;
convert_to_upper((char *)*a1);
}
return v3;
}

canonical_decompiled_code:
const char *__fastcall func3(const char **a1, int a2)
{
const unsigned __int16 **v2; // rax
const char *v3; // r12
const unsigned __int16 *v4; // rcx
const char *v5; // rdx
__int64 v6; // rax

func0(*a1);
if ( a2 == 1 )
{
v3 = 0LL;
func2((char *)*a1);
}
else
{
v2 = _ctype_b_loc();
v3 = *a1;
v4 = *v2;
do
{
v5 = v3;
v6 = *v3++;
}
while ( (v4[v6] & 0x2000) == 0 );
*v5 = 0;
func2((char *)*a1);
}
return v3;
}

original_code:
char *separate_cmd_from_args (char **cmdLineStr, int numArgs)
{
  char *args;
  trim_whitespace (*cmdLineStr);
  if (numArgs == 1) {
    convert_to_upper (*cmdLineStr);
    return ((void *)0);
  }
  args = *cmdLineStr;
  while (!((*__ctype_b_loc ())[(int) ((*(args++)))] & (unsigned short int) _ISspace));
  *(args - 1) = '\0';
  convert_to_upper (*cmdLineStr);
  return args;
}

canonical_original_code:
char *separate_cmd_from_args(char **cmdLineStr, int numArgs)
{
  char *args;
  trim_whitespace (*cmdLineStr);
  if (numArgs == 1) {
    convert_to_upper (*cmdLineStr);
    return ((void *)0);
  }
  args = *cmdLineStr;
  while (!((*__ctype_b_loc ())[(int) ((*(args++)))] & (unsigned short) _ISspace));
  *(args - 1) = '\0';
  convert_to_upper (*cmdLineStr);
  return args;
}

variable_types:
cmdLineStr
char **

variable_types: numArgs int

variable_types:
args
char *

return_type: char *