decompiled_code:
__int64 __fastcall ZyXEL_Omni56K_answer_phone(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
size_t v4; // r13
int v5; // er12
unsigned __int8 v6; // bp
const unsigned __int16 **v7; // rsi
char *v8; // rdx
bool v9; // cf
bool v10; // zf
char *v11; // rsi
const char *v12; // rdi
__int64 v13; // rcx
char v14[32]; // [rsp+0h] [rbp-148h] BYREF
char s1[296]; // [rsp+20h] [rbp-128h] BYREF

strcpy(v14, "CALLER'S NUMBER: ");
v2 = 8195;
if ( (unsigned int)IS_101_answer_phone(a1, a2, 0x3A5245424D554E20LL) == 8202 )
{
v2 = 8202;
if ( !strcmp(CallerId, "none") && !(unsigned int)voice_command("AT*T", &unk_81E) && !(unsigned int)voice_read(s1) )
{
v4 = (int)strlen(v14);
v5 = strncmp(s1, v14, v4);
if ( v5 )
{
voice_flush(3LL);
}
else
{
v6 = s1[v4];
if ( v6 )
{
v7 = _ctype_b_loc();
v8 = &s1[v4];
do
{
if ( ((*v7)[v6] & 0x4000) != 0 )
number[v5++] = v6;
v6 = *++v8;
}
while ( v5 <= 14 && v6 );
}
number[v5] = 0;
lprintf(5LL, "Got caller ID: \"%s\"", number);
if ( (unsigned int)voice_command("AT&I0", &unk_81E) )
voice_flush(3LL);
v9 = 0;
v10 = number[0] == 0;
if ( number[0] )
{
v11 = number;
v12 = "?";
v13 = 2LL;
do
{
if ( !v13 )
break;
v9 = (unsigned __int8)*v11 < (unsigned int)*v12;
v10 = *v11++ == *v12++;
--v13;
}
while ( v10 );
if ( (!v9 && !v10) != v9 )
{
CallerId = number;
setup_environment(v12, v11);
}
}
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
size_t v4; // r13
int v5; // er12
unsigned __int8 v6; // bp
const unsigned __int16 **v7; // rsi
char *v8; // rdx
bool v9; // cf
bool v10; // zf
char *v11; // rsi
const char *v12; // rdi
__int64 v13; // rcx
char v14[32]; // [rsp+0h] [rbp-148h] BYREF
char s1[296]; // [rsp+20h] [rbp-128h] BYREF

strcpy(v14, "CALLER'S NUMBER: ");
v2 = 8195;
if ( (unsigned int)IS_101_answer_phone(a1, a2, 0x3A5245424D554E20LL) == 8202 )
{
v2 = 8202;
if ( !strcmp(CallerId, "none") && !(unsigned int)voice_command("AT*T", &unk_81E) && !(unsigned int)voice_read(s1) )
{
v4 = (int)strlen(v14);
v5 = strncmp(s1, v14, v4);
if ( v5 )
{
voice_flush(3LL);
}
else
{
v6 = s1[v4];
if ( v6 )
{
v7 = _ctype_b_loc();
v8 = &s1[v4];
do
{
if ( ((*v7)[v6] & 0x4000) != 0 )
number[v5++] = v6;
v6 = *++v8;
}
while ( v5 <= 14 && v6 );
}
number[v5] = 0;
lprintf(5LL, "Got caller ID: \"%s\"", number);
if ( (unsigned int)voice_command("AT&I0", &unk_81E) )
voice_flush(3LL);
v9 = 0;
v10 = number[0] == 0;
if ( number[0] )
{
v11 = number;
v12 = "?";
v13 = 2LL;
do
{
if ( !v13 )
break;
v9 = (unsigned __int8)*v11 < (unsigned int)*v12;
v10 = *v11++ == *v12++;
--v13;
}
while ( v10 );
if ( (!v9 && !v10) != v9 )
{
CallerId = number;
setup_environment(v12, v11);
}
}
}
}
}
return v2;
}

original_code:
static int ZyXEL_Omni56K_answer_phone (void)
{
  char buffer[(256)];
  char resp[] = "CALLER'S NUMBER: ";
  int i, j, len;
  if (IS_101_answer_phone() != (0x200a))
    return (0x2003);
  if (strcmp(CallerId, "none") != 0)
    return (0x200a);
  if (voice_command("AT*T", "") == (0) && voice_read(buffer) == (0)) {
    len = strlen(resp);
    if (strncmp(buffer, resp, len) == 0) {
      for (i = len, j = 0; buffer[i] && j < 15; i++) {
        if (((*__ctype_b_loc ())[(int) ((buffer[i] & 0xFF))] & (unsigned short int) _ISprint))
          number[j++] = buffer[i];
      }
      number[j++] = '\0';
      lprintf(5, "Got caller ID: \"%s\"", number);
      if (voice_command("AT&I0", ""))
        voice_flush(3);
      if (number[0] && strcmp(number, "?")) {
        CallerId = number;
        setup_environment();
      }
    } else {
      voice_flush(3);
    }
  }
  return (0x200a);
}

canonical_original_code:
static int ZyXEL_Omni56K_answer_phone()
{
  char buffer[-1];
  char resp[] = "CALLER'S NUMBER: ";
  int i; int j; int len;
  if (IS_101_answer_phone() != (0x200a))
    return (0x2003);
  if (strcmp(CallerId, "none") != 0)
    return (0x200a);
  if (voice_command("AT*T", "") == (0) && voice_read(buffer) == (0)) {
    len = strlen(resp);
    if (strncmp(buffer, resp, len) == 0) {
      for (i = len, j = 0; buffer[i] && j < 15; i++) {
        if (((*__ctype_b_loc ())[(int) ((buffer[i] & 0xFF))] & (unsigned short) _ISprint))
          number[j++] = buffer[i];
      }
      number[j++] = '\0';
      lprintf(5, "Got caller ID: \"%s\"", number);
      if (voice_command("AT&I0", ""))
        voice_flush(3);
      if (number[0] && strcmp(number, "?")) {
        CallerId = number;
        setup_environment();
      }
    } else {
      voice_flush(3);
    }
  }
  return (0x200a);
}

variable_types:
resp
char []

variable_types: i int

variable_types: j int

variable_types: len int


repo: Distrotech/mgetty

decompiled_code:
__int64 __fastcall sendfax_parse_args(int argc, char **argv)
{
char *v4; // rax
int v5; // eax
int v6; // eax

v4 = (char *)malloc(0xDuLL);
if ( v4 )
{
strcpy(v4, "tty4c:tty4d");
*(&c + 1) = v4;
*((_DWORD *)&c + 5) = 3;
}
else
{
*((_DWORD *)&c + 5) = 0;
}
while ( 2 )
{
v5 = getopt(argc, argv, "d:vx:ph:l:nm:SC:I:rA:D:M:R:V");
if ( v5 != -1 )
{
switch ( v5 )
{
case '?':
return 0xFFFFFFFFLL;
case 'A':
*(&c + 82) = optarg;
*((_DWORD *)&c + 167) = 2;
continue;
case 'C':
*(&c + 13) = optarg;
*((_DWORD *)&c + 29) = 2;
continue;
case 'D':
*(&c + 46) = optarg;
*((_DWORD *)&c + 95) = 2;
continue;
case 'I':
*(&c + 49) = optarg;
*((_DWORD *)&c + 101) = 2;
continue;
case 'M':
*(&c + 61) = (char *)atoi(optarg);
*((_DWORD *)&c + 125) = 2;
continue;
case 'R':
*(&c + 28) = (char *)atoi(optarg);
*((_DWORD *)&c + 59) = 2;
continue;
case 'S':
*(&c + 76) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 155) = 2;
continue;
case 'V':
printf("\nmgetty+sendfax by Gert Doering\n%s\n\n", mgetty_version);
printf("log file written to '%s'\n", "/var/log/sendfax.log");
printf("config file read from '%s'\n\n", "/etc/mgetty+sendfax/sendfax.config");
exit(0);
case 'd':
*(&c + 52) = optarg;
*((_DWORD *)&c + 107) = 2;
continue;
case 'h':
*(&c + 73) = optarg;
*((_DWORD *)&c + 149) = 2;
continue;
case 'l':
if ( *optarg == 47 )
{
if ( memcmp(optarg, "/dev/", 5uLL) )
{
fprintf(stderr, "%s: -l: device must be located in /dev!\n", *argv);
exit(1);
}
}
*(&c + 1) = optarg;
*((_DWORD *)&c + 5) = 2;
continue;
case 'm':
*(&c + 7) = optarg;
*((_DWORD *)&c + 17) = 2;
continue;
case 'n':
*(&c + 55) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 113) = 2;
continue;
case 'p':
*(&c + 70) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 143) = 2;
continue;
case 'r':
*(&c + 79) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 161) = 2;
continue;
case 'v':
*(&c + 67) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 137) = 2;
continue;
case 'x':
v6 = atoi(optarg);
*(&c + 64) = (char *)v6;
*((_DWORD *)&c + 131) = 2;
log_set_llevel((unsigned int)v6);
continue;
default:
continue;
}
}
break;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int argc, char **argv)
{
char *v4; // rax
int v5; // eax
int v6; // eax

v4 = (char *)malloc(0xDuLL);
if ( v4 )
{
strcpy(v4, "tty4c:tty4d");
*(&c + 1) = v4;
*((_DWORD *)&c + 5) = 3;
}
else
{
*((_DWORD *)&c + 5) = 0;
}
while ( 2 )
{
v5 = getopt(argc, argv, "d:vx:ph:l:nm:SC:I:rA:D:M:R:V");
if ( v5 != -1 )
{
switch ( v5 )
{
case '?':
return 0xFFFFFFFFLL;
case 'A':
*(&c + 82) = optarg;
*((_DWORD *)&c + 167) = 2;
continue;
case 'C':
*(&c + 13) = optarg;
*((_DWORD *)&c + 29) = 2;
continue;
case 'D':
*(&c + 46) = optarg;
*((_DWORD *)&c + 95) = 2;
continue;
case 'I':
*(&c + 49) = optarg;
*((_DWORD *)&c + 101) = 2;
continue;
case 'M':
*(&c + 61) = (char *)atoi(optarg);
*((_DWORD *)&c + 125) = 2;
continue;
case 'R':
*(&c + 28) = (char *)atoi(optarg);
*((_DWORD *)&c + 59) = 2;
continue;
case 'S':
*(&c + 76) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 155) = 2;
continue;
case 'V':
printf("\nmgetty+sendfax by Gert Doering\n%s\n\n", mgetty_version);
printf("log file written to '%s'\n", "/var/log/sendfax.log");
printf("config file read from '%s'\n\n", "/etc/mgetty+sendfax/sendfax.config");
exit(0);
case 'd':
*(&c + 52) = optarg;
*((_DWORD *)&c + 107) = 2;
continue;
case 'h':
*(&c + 73) = optarg;
*((_DWORD *)&c + 149) = 2;
continue;
case 'l':
if ( *optarg == 47 )
{
if ( memcmp(optarg, "/dev/", 5uLL) )
{
fprintf(stderr, "%s: -l: device must be located in /dev!\n", *argv);
exit(1);
}
}
*(&c + 1) = optarg;
*((_DWORD *)&c + 5) = 2;
continue;
case 'm':
*(&c + 7) = optarg;
*((_DWORD *)&c + 17) = 2;
continue;
case 'n':
*(&c + 55) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 113) = 2;
continue;
case 'p':
*(&c + 70) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 143) = 2;
continue;
case 'r':
*(&c + 79) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 161) = 2;
continue;
case 'v':
*(&c + 67) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 137) = 2;
continue;
case 'x':
v6 = atoi(optarg);
*(&c + 64) = (char *)v6;
*((_DWORD *)&c + 131) = 2;
log_set_llevel((unsigned int)v6);
continue;
default:
continue;
}
}
break;
}
return 0LL;
}

original_code:
int sendfax_parse_args (int argc,char ** argv)
{
int opt;
char * p;
conf_data c_a[2];
    if ( ( (char *)&c_a[1] - (char *)&c_a[0] ) !=
  ( (char *)&c.ttys_0 - (char *)&c.ttys ) )
    {
 fprintf( stderr, "ERROR: config table size mixup. contact author\n" );
 exit(99);
    }
    p = malloc( sizeof( "tty4c:tty4d" )+1 );
    if ( p == ((void *)0) )
 c.ttys.flags = C_EMPTY;
    else
    {
 strcpy( p, "tty4c:tty4d" );
 c.ttys.d.p = p;
 c.ttys.flags = C_CONF;
    }
    while ((opt = getopt(argc, argv, "d:vx:ph:l:nm:SC:I:rA:D:M:R:V")) != (-1))
    {
 switch (opt) {
   case 'd':
     { (&c.poll_dir)->d.p = (optarg); (&c.poll_dir)->flags = C_OVERRIDE; };
     break;
   case 'v':
     { (&c.verbose)->d.i = ((1==1)); (&c.verbose)->flags = C_OVERRIDE; };
     break;
   case 'x':
     { (&c.debug)->d.i = (atoi(optarg)); (&c.debug)->flags = C_OVERRIDE; };
     log_set_llevel( ((int) c.debug.d.i) );
     break;
   case 'p':
     { (&c.fax_poll_wanted)->d.i = ((1==1)); (&c.fax_poll_wanted)->flags = C_OVERRIDE; };
     break;
   case 'h':
     { (&c.fax_page_header)->d.p = (optarg); (&c.fax_page_header)->flags = C_OVERRIDE; };
     break;
   case 'l':
     if ( optarg[0] == '/' &&
   strncmp( optarg, "/dev/", 5 ) != 0 )
     {
  fprintf( stderr, "%s: -l: device must be located in /dev!\n",
                   argv[0]);
  exit(1);
     }
     { (&c.ttys)->d.p = (optarg); (&c.ttys)->flags = C_OVERRIDE; };
     break;
   case 'n':
     { (&c.normal_res)->d.i = ((1==1)); (&c.normal_res)->flags = C_OVERRIDE; };
     break;
   case 'm':
     { (&c.modem_init)->d.p = (optarg); (&c.modem_init)->flags = C_OVERRIDE; };
     break;
   case 'S':
     { (&c.use_stdin)->d.i = ((1==1)); (&c.use_stdin)->flags = C_OVERRIDE; };
     break;
   case 'C':
     { (&c.modem_type)->d.p = (optarg); (&c.modem_type)->flags = C_OVERRIDE; };
     break;
   case 'I':
     { (&c.station_id)->d.p = (optarg); (&c.station_id)->flags = C_OVERRIDE; };
     break;
   case 'r':
     { (&c.rename_files)->d.i = ((1==1)); (&c.rename_files)->flags = C_OVERRIDE; };
     break;
   case 'A':
     { (&c.acct_handle)->d.p = (optarg); (&c.acct_handle)->flags = C_OVERRIDE; };
     break;
   case 'D':
     { (&c.dial_prefix)->d.p = (optarg); (&c.dial_prefix)->flags = C_OVERRIDE; };
     break;
   case 'M':
     { (&c.fax_max_speed)->d.i = (atoi(optarg)); (&c.fax_max_speed)->flags = C_OVERRIDE; };
     break;
   case 'R':
     { (&c.max_tries)->d.i = (atoi(optarg)); (&c.max_tries)->flags = C_OVERRIDE; };
     break;
   case 'V':
     printf("\nmgetty+sendfax by Gert Doering\n%s\n\n",
      mgetty_version);
     printf("log file written to '%s'\n", "/var/log/sendfax.log" );
            printf("config file read from '%s'\n\n",
   (("sendfax.config")[0] == '/'? ("sendfax.config") : ("/etc/mgetty+sendfax""/""sendfax.config")));
     exit(0);
   case '?':
     return -1;
     break;
 }
    }
    return 0;
}

canonical_original_code:
int sendfax_parse_args(int argc, char **argv)
{
int opt;
char *p;
struct conf_data c_a[2];
    if ( ( (char *)&c_a[1] - (char *)&c_a[0] ) !=
  ( (char *)&c.ttys_0 - (char *)&c.ttys ) )
    {
 fprintf( stderr, "ERROR: config table size mixup. contact author\n" );
 exit(99);
    }
    p = malloc( sizeof( "tty4c:tty4d" )+1 );
    if ( p == ((void *)0) )
 c.ttys.flags = C_EMPTY;
    else
    {
 strcpy( p, "tty4c:tty4d" );
 c.ttys.d.p = p;
 c.ttys.flags = C_CONF;
    }
    while ((opt = getopt(argc, argv, "d:vx:ph:l:nm:SC:I:rA:D:M:R:V")) != (-1))
    {
 switch (opt) {
   case 'd':
     { (&c.poll_dir)->d.p = (optarg); (&c.poll_dir)->flags = C_OVERRIDE; };
     break;
   case 'v':
     { (&c.verbose)->d.i = ((1==1)); (&c.verbose)->flags = C_OVERRIDE; };
     break;
   case 'x':
     { (&c.debug)->d.i = (atoi(optarg)); (&c.debug)->flags = C_OVERRIDE; };
     log_set_llevel( ((int) c.debug.d.i) );
     break;
   case 'p':
     { (&c.fax_poll_wanted)->d.i = ((1==1)); (&c.fax_poll_wanted)->flags = C_OVERRIDE; };
     break;
   case 'h':
     { (&c.fax_page_header)->d.p = (optarg); (&c.fax_page_header)->flags = C_OVERRIDE; };
     break;
   case 'l':
     if ( optarg[0] == '/' &&
   strncmp( optarg, "/dev/", 5 ) != 0 )
     {
  fprintf( stderr, "%s: -l: device must be located in /dev!\n",
                   argv[0]);
  exit(1);
     }
     { (&c.ttys)->d.p = (optarg); (&c.ttys)->flags = C_OVERRIDE; };
     break;
   case 'n':
     { (&c.normal_res)->d.i = ((1==1)); (&c.normal_res)->flags = C_OVERRIDE; };
     break;
   case 'm':
     { (&c.modem_init)->d.p = (optarg); (&c.modem_init)->flags = C_OVERRIDE; };
     break;
   case 'S':
     { (&c.use_stdin)->d.i = ((1==1)); (&c.use_stdin)->flags = C_OVERRIDE; };
     break;
   case 'C':
     { (&c.modem_type)->d.p = (optarg); (&c.modem_type)->flags = C_OVERRIDE; };
     break;
   case 'I':
     { (&c.station_id)->d.p = (optarg); (&c.station_id)->flags = C_OVERRIDE; };
     break;
   case 'r':
     { (&c.rename_files)->d.i = ((1==1)); (&c.rename_files)->flags = C_OVERRIDE; };
     break;
   case 'A':
     { (&c.acct_handle)->d.p = (optarg); (&c.acct_handle)->flags = C_OVERRIDE; };
     break;
   case 'D':
     { (&c.dial_prefix)->d.p = (optarg); (&c.dial_prefix)->flags = C_OVERRIDE; };
     break;
   case 'M':
     { (&c.fax_max_speed)->d.i = (atoi(optarg)); (&c.fax_max_speed)->flags = C_OVERRIDE; };
     break;
   case 'R':
     { (&c.max_tries)->d.i = (atoi(optarg)); (&c.max_tries)->flags = C_OVERRIDE; };
     break;
   case 'V':
     printf("\nmgetty+sendfax by Gert Doering\n%s\n\n",
      mgetty_version);
     printf("log file written to '%s'\n", "/var/log/sendfax.log" );
            printf("config file read from '%s'\n\n",
   (("sendfax.config")[0] == '/'? ("sendfax.config") : ("/etc/mgetty+sendfax""/""sendfax.config")));
     exit(0);
   case '?':
     return -1;
     break;
 }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int

variable_types:
p
char *

variable_types: struct conf_data { char *key; union { long i; void *p; } d; enum { CT_INT=0, CT_STRING=1, CT_CHAT=2, CT_BOOL=3, CT_FLOWL=4, CT_ACTION=5, CT_KEYWORD=6 } type; enum { C_EMPTY=0, C_PRESET=1, C_OVERRIDE=2, C_CONF=3, C_IGNORE=4 } flags; } [2]

return_type: int


decompiled_code:
__int64 __fastcall sendfax_get_config(const char *a1)
{
__int64 result; // rax

if ( a1 )
{
lprintf(5LL, "reading specific data for port '%s'", a1);
get_config("/etc/mgetty+sendfax/sendfax.config", (unsigned int)((_DWORD)&c + 24), "port", a1);
}
else
{
lprintf(5LL, "reading default configuration");
get_config("/etc/mgetty+sendfax/sendfax.config", &c, "port", 0LL);
}
result = log_set_llevel(*((unsigned int *)&c + 128));
if ( *((_DWORD *)&c + 35) )
{
lprintf(5LL, "set modem_quirks: 0x%04x", *((unsigned int *)&c + 32));
result = (__int64)*(&c + 16);
modem_quirks = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
__int64 result; // rax

if ( a1 )
{
lprintf(5LL, "reading specific data for port '%s'", a1);
get_config("/etc/mgetty+sendfax/sendfax.config", (unsigned int)((_DWORD)&c + 24), "port", a1);
}
else
{
lprintf(5LL, "reading default configuration");
get_config("/etc/mgetty+sendfax/sendfax.config", &c, "port", 0LL);
}
result = log_set_llevel(*((unsigned int *)&c + 128));
if ( *((_DWORD *)&c + 35) )
{
lprintf(5LL, "set modem_quirks: 0x%04x", *((unsigned int *)&c + 32));
result = (__int64)*(&c + 16);
modem_quirks = result;
}
return result;
}

original_code:
void sendfax_get_config (char * port)
{
    if ( port == ((void *)0) )
    {
 lprintf( 5, "reading default configuration" );
 get_config( (("sendfax.config")[0] == '/'? ("sendfax.config") : ("/etc/mgetty+sendfax""/""sendfax.config")),
      (conf_data *)&c, "port", ((void *)0) );
    }
    else
    {
 lprintf( 5, "reading specific data for port '%s'", port );
 get_config( (("sendfax.config")[0] == '/'? ("sendfax.config") : ("/etc/mgetty+sendfax""/""sendfax.config")),
      ((conf_data *)&c)+1, "port", port );
    }
    log_set_llevel( ((int) c.debug.d.i) );
    if ( ( c.modem_quirks.flags != C_EMPTY ) )
    {
        lprintf( 5, "set modem_quirks: 0x%04x", ((int) c.modem_quirks.d.i));
 modem_quirks = ((int) c.modem_quirks.d.i);
    }
}

canonical_original_code:
void sendfax_get_config(char *port)
{
    if ( port == ((void *)0) )
    {
 lprintf( 5, "reading default configuration" );
 get_config( (("sendfax.config")[0] == '/'? ("sendfax.config") : ("/etc/mgetty+sendfax""/""sendfax.config")),
      (struct conf_data *)&c, "port", ((void *)0) );
    }
    else
    {
 lprintf( 5, "reading specific data for port '%s'", port );
 get_config( (("sendfax.config")[0] == '/'? ("sendfax.config") : ("/etc/mgetty+sendfax""/""sendfax.config")),
      ((struct conf_data *)&c)+1, "port", port );
    }
    log_set_llevel( ((int) c.debug.d.i) );
    if ( ( c.modem_quirks.flags != C_EMPTY ) )
    {
        lprintf( 5, "set modem_quirks: 0x%04x", ((int) c.modem_quirks.d.i));
 modem_quirks = ((int) c.modem_quirks.d.i);
    }
}

variable_types:
port
char *

return_type: void

user_defined_types: struct conf_data { char *key; union { long i; void *p; } d; enum { CT_INT=0, CT_STRING=1, CT_CHAT=2, CT_BOOL=3, CT_FLOWL=4, CT_ACTION=5, CT_KEYWORD=6 } type; enum { C_EMPTY=0, C_PRESET=1, C_OVERRIDE=2, C_CONF=3, C_IGNORE=4 } flags; }


fft

original_code:
static void fft (float *real, float *imag, int n)
     {
     float a;
     float tr;
     float ti;
     float wr;
     float wi;
     int mr = 0;
     int l;
     int istep;
     int m;
     int i;
     int j;
     for (m = 1; m <= (n - 1); m++)
          {
          l = n / 2;
          while ((mr + l) > (n - 1))
               l /= 2;
          mr = (mr % l) + l;
          if (mr > m)
               {
               tr = real[m];
               real[m] = real[mr];
               real[mr] = tr;
               ti = imag[m];
               imag[m] = imag[mr];
               imag[mr] = ti;
               }
          }
     for (l = 1; l < n; l = istep)
          {
          istep = 2 * l;
          for (m = 1; m <= l; m++)
               {
               a = -3.14159265358979323846 * (m - 1.0) / l;
               wr = cos(a);
               wi = sin(a);
               i = m - 1;
               do
                    {
                    j = i + l;
                    tr = wr * real[j] - wi * imag[j];
                    ti = wr * imag[j] + wi * real[j];
                    real[j] = real[i] - tr;
                    imag[j] = imag[i] - ti;
                    real[i] += tr;
                    imag[i] += ti;
                    i += istep;
                    }
               while (i < n);
               }
          }
     }

canonical_original_code:
static void fft(float *real, float *imag, int n)
     {
     float a;
     float tr;
     float ti;
     float wr;
     float wi;
     int mr = 0;
     int l;
     int istep;
     int m;
     int i;
     int j;
     for (m = 1; m <= (n - 1); m++)
          {
          l = n / 2;
          while ((mr + l) > (n - 1))
               l /= 2;
          mr = (mr % l) + l;
          if (mr > m)
               {
               tr = real[m];
               real[m] = real[mr];
               real[mr] = tr;
               ti = imag[m];
               imag[m] = imag[mr];
               imag[mr] = ti;
               }
          }
     for (l = 1; l < n; l = istep)
          {
          istep = 2 * l;
          for (m = 1; m <= l; m++)
               {
               a = -3.14159265358979323846 * (m - 1.0) / l;
               wr = cos(a);
               wi = sin(a);
               i = m - 1;
               do
                    {
                    j = i + l;
                    tr = wr * real[j] - wi * imag[j];
                    ti = wr * imag[j] + wi * real[j];
                    real[j] = real[i] - tr;
                    imag[j] = imag[i] - ti;
                    real[i] += tr;
                    imag[i] += ti;
                    i += istep;
                    }
               while (i < n);
               }
          }
     }

variable_types:
real
float *

variable_types:
imag
float *

variable_types: n int

variable_types: a float

variable_types: tr float

variable_types: ti float

variable_types: wr float

variable_types: wi float

variable_types: mr int

variable_types: l int

variable_types: istep int

variable_types: m int


decompiled_code:
_WORD *gsm_create()
{
_WORD *v0; // rdx

v0 = malloc(0x290uLL);
if ( v0 )
{
memset(v0, 0, 0x290uLL);
v0[316] = 40;
}
return v0;
}

original_code:
gsm gsm_create (void)
{
     gsm r;
     r = (gsm)malloc(sizeof(struct gsm_state));
     if (!r) return r;
     memset((char *)r, 0, sizeof(*r));
     r->nrp = 40;
     return r;
}

canonical_original_code:
struct gsm_state *gsm_create()
{
     struct gsm_state *r;
     r = (struct gsm_state *)malloc(sizeof(struct gsm_state));
     if (!r) return r;
     memset((char *)r, 0, sizeof(*r));
     r->nrp = 40;
     return r;
}

variable_types: struct gsm_state { short dp0[280]; short z1; long L_z2; int mp; short u[8]; short LARpp[2][8]; short j; short ltp_cut; short nrp; short v[9]; short msr; char verbose; char fast; } *


decompiled_code:
__int64 voice_impersonify()
{
unsigned int v0; // ebx
__int64 v1; // rdi
int *v2; // rax
char *v3; // rax
int *v5; // rax
char *v6; // rax
__gid_t gid; // [rsp+8h] [rbp-10h] BYREF
__uid_t uid[3]; // [rsp+Ch] [rbp-Ch] BYREF

get_ugid((unsigned int)((_DWORD)cvd + 1104), (unsigned int)((_DWORD)cvd + 1128), uid, &gid);
if ( setegid(gid) )
{
v2 = _errno_location();
v3 = strerror(*v2);
lprintf(3LL, "%s: cannot set effective GID to %d: %s", program_name, gid, v3);
v0 = 0;
}
else
{
v0 = 0;
if ( seteuid(uid[0]) )
{
v5 = _errno_location();
v6 = strerror(*v5);
lprintf(3LL, "%s: cannot set effective UID to %d: %s", program_name, uid[0], v6);
}
else
{
v1 = cvd[145];
v0 = 1;
if ( v1 != -1 )
old_umask = umask(~(_WORD)v1 & 0x1B6);
}
}
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // ebx
__int64 v1; // rdi
int *v2; // rax
char *v3; // rax
int *v5; // rax
char *v6; // rax
__gid_t gid; // [rsp+8h] [rbp-10h] BYREF
__uid_t uid[3]; // [rsp+Ch] [rbp-Ch] BYREF

get_ugid((unsigned int)((_DWORD)cvd + 1104), (unsigned int)((_DWORD)cvd + 1128), uid, &gid);
if ( setegid(gid) )
{
v2 = _errno_location();
v3 = strerror(*v2);
lprintf(3LL, "%s: cannot set effective GID to %d: %s", program_name, gid, v3);
v0 = 0;
}
else
{
v0 = 0;
if ( seteuid(uid[0]) )
{
v5 = _errno_location();
v6 = strerror(*v5);
lprintf(3LL, "%s: cannot set effective UID to %d: %s", program_name, uid[0], v6);
}
else
{
v1 = cvd[145];
v0 = 1;
if ( v1 != -1 )
old_umask = umask(~(_WORD)v1 & 0x1B6);
}
}
return v0;
}

original_code:
int voice_impersonify(void) {
   uid_t uid;
   gid_t gid;
   get_ugid((char *) &cvd.phone_owner,
     (char *) &cvd.phone_group,
     &uid,
     &gid);
   if (setegid(gid)) {
      lprintf(3, "%s: cannot set effective GID to %d: %s",
       program_name, gid, strerror((*__errno_location ())));
      return 0;
   }
   if (seteuid(uid)) {
      lprintf(3, "%s: cannot set effective UID to %d: %s",
       program_name, uid, strerror((*__errno_location ())));
      return 0;
   }
   if (cvd.phone_mode.d.i != -1) {
      old_umask = umask(0666 & ~(cvd.phone_mode.d.i));
   }
   return 1;
}

canonical_original_code:
int voice_impersonify() {
   unsigned int uid;
   unsigned int gid;
   get_ugid((char *) &cvd.phone_owner,
     (char *) &cvd.phone_group,
     &uid,
     &gid);
   if (setegid(gid)) {
      lprintf(3, "%s: cannot set effective GID to %d: %s",
       program_name, gid, strerror((*__errno_location ())));
      return 0;
   }
   if (seteuid(uid)) {
      lprintf(3, "%s: cannot set effective UID to %d: %s",
       program_name, uid, strerror((*__errno_location ())));
      return 0;
   }
   if (cvd.phone_mode.d.i != -1) {
      old_umask = umask(0666 & ~(cvd.phone_mode.d.i));
   }
   return 1;
}

variable_types:
uid
unsigned int

variable_types:
gid
unsigned int


decompiled_code:
__int64 voice_desimpersonify()
{
__uid_t v0; // eax
unsigned int v1; // ebx
__gid_t v2; // eax
int *v3; // rax
char *v4; // rbx
__uid_t v5; // eax
int *v7; // rax
char *v8; // rbp
__gid_t v9; // eax

v0 = getuid();
if ( seteuid(v0) )
{
v3 = _errno_location();
v4 = strerror(*v3);
v5 = getuid();
lprintf(3LL, "%s: cannot switch back to effective UID %d: %s", program_name, v5, v4);
v1 = 0;
}
else
{
v1 = 0;
v2 = getgid();
if ( setegid(v2) )
{
v7 = _errno_location();
v8 = strerror(*v7);
v9 = getgid();
lprintf(3LL, "%s: cannot switch back to effective GID %d: %s", program_name, v9, v8);
}
else
{
v1 = 1;
if ( cvd[145] != -1LL )
umask(old_umask);
}
}
return v1;
}

canonical_decompiled_code:
__int64 func1()
{
__uid_t v0; // eax
unsigned int v1; // ebx
__gid_t v2; // eax
int *v3; // rax
char *v4; // rbx
__uid_t v5; // eax
int *v7; // rax
char *v8; // rbp
__gid_t v9; // eax

v0 = getuid();
if ( seteuid(v0) )
{
v3 = _errno_location();
v4 = strerror(*v3);
v5 = getuid();
lprintf(3LL, "%s: cannot switch back to effective UID %d: %s", program_name, v5, v4);
v1 = 0;
}
else
{
v1 = 0;
v2 = getgid();
if ( setegid(v2) )
{
v7 = _errno_location();
v8 = strerror(*v7);
v9 = getgid();
lprintf(3LL, "%s: cannot switch back to effective GID %d: %s", program_name, v9, v8);
}
else
{
v1 = 1;
if ( cvd[145] != -1LL )
umask(old_umask);
}
}
return v1;
}

original_code:
int voice_desimpersonify(void) {
   if (seteuid(getuid())) {
      lprintf(3, "%s: cannot switch back to effective UID %d: %s",
       program_name, getuid(), strerror((*__errno_location ())));
      return 0;
   }
   if (setegid(getgid())) {
      lprintf(3, "%s: cannot switch back to effective GID %d: %s",
       program_name, getgid(), strerror((*__errno_location ())));
      return 0;
   }
   if (cvd.phone_mode.d.i != -1) {
      umask(old_umask);
   }
   return 1;
}

canonical_original_code:
int voice_desimpersonify() {
   if (seteuid(getuid())) {
      lprintf(3, "%s: cannot switch back to effective UID %d: %s",
       program_name, getuid(), strerror((*__errno_location ())));
      return 0;
   }
   if (setegid(getgid())) {
      lprintf(3, "%s: cannot switch back to effective GID %d: %s",
       program_name, getgid(), strerror((*__errno_location ())));
      return 0;
   }
   if (cvd.phone_mode.d.i != -1) {
      umask(old_umask);
   }
   return 1;
}


decompiled_code:
__int64 __fastcall mgetty_parse_args(int argc, char **argv)
{
int v2; // eax
int v3; // eax

*(&c + 43) = (char *)&def_init_chat_seq;
*((_DWORD *)&c + 89) = 1;
*(&c + 46) = (char *)&def_force_init_chat_seq;
*((_DWORD *)&c + 95) = 1;
*(&c + 76) = (char *)&def_answer_chat_seq;
*((_DWORD *)&c + 155) = 1;
if ( !strcmp((const char *)get_basename(*argv), "getty") )
{
*(&c + 10) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 23) = 2;
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
}
while ( 1 )
{
v2 = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV");
if ( v2 == -1 )
return 0LL;
switch ( v2 )
{
case '?':
exit_usage(2);
case 'C':
*(&c + 37) = optarg;
*((_DWORD *)&c + 77) = 2;
break;
case 'D':
*(&c + 31) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 65) = 2;
break;
case 'F':
*(&c + 34) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 71) = 2;
break;
case 'I':
*(&c + 115) = optarg;
*((_DWORD *)&c + 233) = 2;
break;
case 'R':
*(&c + 85) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 173) = 2;
*(&c + 88) = (char *)atoi(optarg);
*((_DWORD *)&c + 179) = 2;
break;
case 'S':
*(&c + 124) = optarg;
*((_DWORD *)&c + 251) = 2;
break;
case 'V':
printf("\nmgetty+sendfax by Gert Doering\n%s\n\n", mgetty_version);
printf("log file written to '");
printf("/var/log/mgetty.%s", "<ttyX>");
printf("'\nconfig file read from '%s", "/etc/mgetty+sendfax/mgetty.config");
puts("'\n");
exit(0);
case 'a':
*(&c + 82) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 167) = 2;
break;
case 'b':
*(&c + 10) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 23) = 2;
break;
case 'c':
lprintf(0LL, "gettydefs not supported\n");
exit_usage(2);
case 'i':
*(&c + 94) = optarg;
*((_DWORD *)&c + 191) = 2;
break;
case 'k':
*(&c + 127) = (char *)atol(optarg);
*((_DWORD *)&c + 257) = 2;
break;
case 'm':
*((_DWORD *)&c + 89) = 2;
*(&c + 43) = (char *)conf_get_chat(optarg);
break;
case 'n':
*(&c + 64) = (char *)atoi(optarg);
*((_DWORD *)&c + 131) = 2;
break;
case 'p':
*(&c + 100) = optarg;
*((_DWORD *)&c + 203) = 2;
break;
case 'r':
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
break;
case 's':
*(&c + 1) = (char *)atoi(optarg);
*((_DWORD *)&c + 5) = 2;
break;
case 'x':
v3 = atoi(optarg);
*(&c + 145) = (char *)v3;
*((_DWORD *)&c + 293) = 2;
log_set_llevel((unsigned int)v3);
break;
default:
continue;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func1(int argc, char **argv)
{
int v2; // eax
int v3; // eax

*(&c + 43) = (char *)&def_init_chat_seq;
*((_DWORD *)&c + 89) = 1;
*(&c + 46) = (char *)&def_force_init_chat_seq;
*((_DWORD *)&c + 95) = 1;
*(&c + 76) = (char *)&def_answer_chat_seq;
*((_DWORD *)&c + 155) = 1;
if ( !strcmp((const char *)get_basename(*argv), "getty") )
{
*(&c + 10) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 23) = 2;
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
}
while ( 1 )
{
v2 = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV");
if ( v2 == -1 )
return 0LL;
switch ( v2 )
{
case '?':
func0(2);
case 'C':
*(&c + 37) = optarg;
*((_DWORD *)&c + 77) = 2;
break;
case 'D':
*(&c + 31) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 65) = 2;
break;
case 'F':
*(&c + 34) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 71) = 2;
break;
case 'I':
*(&c + 115) = optarg;
*((_DWORD *)&c + 233) = 2;
break;
case 'R':
*(&c + 85) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 173) = 2;
*(&c + 88) = (char *)atoi(optarg);
*((_DWORD *)&c + 179) = 2;
break;
case 'S':
*(&c + 124) = optarg;
*((_DWORD *)&c + 251) = 2;
break;
case 'V':
printf("\nmgetty+sendfax by Gert Doering\n%s\n\n", mgetty_version);
printf("log file written to '");
printf("/var/log/mgetty.%s", "<ttyX>");
printf("'\nconfig file read from '%s", "/etc/mgetty+sendfax/mgetty.config");
puts("'\n");
exit(0);
case 'a':
*(&c + 82) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 167) = 2;
break;
case 'b':
*(&c + 10) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 23) = 2;
break;
case 'c':
lprintf(0LL, "gettydefs not supported\n");
func0(2);
case 'i':
*(&c + 94) = optarg;
*((_DWORD *)&c + 191) = 2;
break;
case 'k':
*(&c + 127) = (char *)atol(optarg);
*((_DWORD *)&c + 257) = 2;
break;
case 'm':
*((_DWORD *)&c + 89) = 2;
*(&c + 43) = (char *)conf_get_chat(optarg);
break;
case 'n':
*(&c + 64) = (char *)atoi(optarg);
*((_DWORD *)&c + 131) = 2;
break;
case 'p':
*(&c + 100) = optarg;
*((_DWORD *)&c + 203) = 2;
break;
case 'r':
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
break;
case 's':
*(&c + 1) = (char *)atoi(optarg);
*((_DWORD *)&c + 5) = 2;
break;
case 'x':
v3 = atoi(optarg);
*(&c + 145) = (char *)v3;
*((_DWORD *)&c + 293) = 2;
log_set_llevel((unsigned int)v3);
break;
default:
continue;
}
}
}

original_code:
int mgetty_parse_args (int argc,char ** argv)
{
int opt;
conf_data c_a[2];
    if ( ( (char *)&c_a[1] - (char *)&c_a[0] ) !=
  ( (char *)&c.switchbd - (char *)&c.speed ) )
    {
 fprintf( stderr, "ERROR: config table size mixup. contact author\n" );
 exit(99);
    }
    c.init_chat.d.p = (void *) def_init_chat_seq;
    c.init_chat.flags = C_PRESET;
    c.force_init_chat.d.p = (void *) def_force_init_chat_seq;
    c.force_init_chat.flags = C_PRESET;
    c.answer_chat.d.p = (void *) def_answer_chat_seq;
    c.answer_chat.flags = C_PRESET;
    if ( strcmp( get_basename( argv[0] ), "getty" ) == 0 )
    {
 { (&c.blocking)->d.i = ((1==1)); (&c.blocking)->flags = C_OVERRIDE; };
 { (&c.direct_line)->d.i = ((1==1)); (&c.direct_line)->flags = C_OVERRIDE; };
    }
    while ((opt = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV")) != (-1))
    {
 switch (opt)
 {
   case 'c':
     lprintf( 0, "gettydefs not supported\n");
     exit_usage(2);
   case 'k':
     { (&c.diskspace)->d.i = (atol(optarg)); (&c.diskspace)->flags = C_OVERRIDE; };
     break;
   case 'x':
     { (&c.debug)->d.i = (atoi(optarg)); (&c.debug)->flags = C_OVERRIDE; };
     log_set_llevel( ((int) c.debug.d.i) );
     break;
   case 's':
     { (&c.speed)->d.i = (atoi(optarg)); (&c.speed)->flags = C_OVERRIDE; };
     break;
   case 'r':
     { (&c.direct_line)->d.i = ((1==1)); (&c.direct_line)->flags = C_OVERRIDE; };
     break;
   case 'p':
     { (&c.login_prompt)->d.p = (optarg); (&c.login_prompt)->flags = C_OVERRIDE; };
     break;
   case 'n':
     { (&c.rings_wanted)->d.i = (atoi(optarg)); (&c.rings_wanted)->flags = C_OVERRIDE; };
     break;
   case 'R':
     { (&c.ringback)->d.i = ((1==1)); (&c.ringback)->flags = C_OVERRIDE; };
     { (&c.ringback_time)->d.i = (atoi(optarg)); (&c.ringback_time)->flags = C_OVERRIDE; };
     break;
   case 'i':
     { (&c.issue_file)->d.p = (optarg); (&c.issue_file)->flags = C_OVERRIDE; };
     break;
   case 'D':
     { (&c.data_only)->d.i = ((1==1)); (&c.data_only)->flags = C_OVERRIDE; };
     break;
   case 'F':
     { (&c.fax_only)->d.i = ((1==1)); (&c.fax_only)->flags = C_OVERRIDE; };
     break;
   case 'C':
     { (&c.modem_type)->d.p = (optarg); (&c.modem_type)->flags = C_OVERRIDE; };
     break;
   case 'S':
     { (&c.fax_server_file)->d.p = (optarg); (&c.fax_server_file)->flags = C_OVERRIDE; };
     break;
   case 'I':
     { (&c.station_id)->d.p = (optarg); (&c.station_id)->flags = C_OVERRIDE; };
     break;
   case 'b':
     { (&c.blocking)->d.i = ((1==1)); (&c.blocking)->flags = C_OVERRIDE; };
     break;
   case 'a':
     { (&c.autobauding)->d.i = ((1==1)); (&c.autobauding)->flags = C_OVERRIDE; };
     break;
   case 'm':
     c.init_chat.flags = C_OVERRIDE;
     c.init_chat.d.p = conf_get_chat( optarg );
     break;
   case 'V':
     printf("\nmgetty+sendfax by Gert Doering\n%s\n\n",
      mgetty_version);
     printf("log file written to '");
     printf("/var/log/mgetty.%s", "<ttyX>");
            printf("'\nconfig file read from '%s",
   (("mgetty.config")[0] == '/'? ("mgetty.config") : ("/etc/mgetty+sendfax""/""mgetty.config")));
     printf("'\n\n");
     exit(0);
   case '?':
     exit_usage(2);
     break;
 }
    }
    return 0;
}

canonical_original_code:
int mgetty_parse_args(int argc, char **argv)
{
int opt;
struct conf_data c_a[2];
    if ( ( (char *)&c_a[1] - (char *)&c_a[0] ) !=
  ( (char *)&c.switchbd - (char *)&c.speed ) )
    {
 fprintf( stderr, "ERROR: config table size mixup. contact author\n" );
 exit(99);
    }
    c.init_chat.d.p = (void *) def_init_chat_seq;
    c.init_chat.flags = C_PRESET;
    c.force_init_chat.d.p = (void *) def_force_init_chat_seq;
    c.force_init_chat.flags = C_PRESET;
    c.answer_chat.d.p = (void *) def_answer_chat_seq;
    c.answer_chat.flags = C_PRESET;
    if ( strcmp( get_basename( argv[0] ), "getty" ) == 0 )
    {
 { (&c.blocking)->d.i = ((1==1)); (&c.blocking)->flags = C_OVERRIDE; };
 { (&c.direct_line)->d.i = ((1==1)); (&c.direct_line)->flags = C_OVERRIDE; };
    }
    while ((opt = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV")) != (-1))
    {
 switch (opt)
 {
   case 'c':
     lprintf( 0, "gettydefs not supported\n");
     exit_usage(2);
   case 'k':
     { (&c.diskspace)->d.i = (atol(optarg)); (&c.diskspace)->flags = C_OVERRIDE; };
     break;
   case 'x':
     { (&c.debug)->d.i = (atoi(optarg)); (&c.debug)->flags = C_OVERRIDE; };
     log_set_llevel( ((int) c.debug.d.i) );
     break;
   case 's':
     { (&c.speed)->d.i = (atoi(optarg)); (&c.speed)->flags = C_OVERRIDE; };
     break;
   case 'r':
     { (&c.direct_line)->d.i = ((1==1)); (&c.direct_line)->flags = C_OVERRIDE; };
     break;
   case 'p':
     { (&c.login_prompt)->d.p = (optarg); (&c.login_prompt)->flags = C_OVERRIDE; };
     break;
   case 'n':
     { (&c.rings_wanted)->d.i = (atoi(optarg)); (&c.rings_wanted)->flags = C_OVERRIDE; };
     break;
   case 'R':
     { (&c.ringback)->d.i = ((1==1)); (&c.ringback)->flags = C_OVERRIDE; };
     { (&c.ringback_time)->d.i = (atoi(optarg)); (&c.ringback_time)->flags = C_OVERRIDE; };
     break;
   case 'i':
     { (&c.issue_file)->d.p = (optarg); (&c.issue_file)->flags = C_OVERRIDE; };
     break;
   case 'D':
     { (&c.data_only)->d.i = ((1==1)); (&c.data_only)->flags = C_OVERRIDE; };
     break;
   case 'F':
     { (&c.fax_only)->d.i = ((1==1)); (&c.fax_only)->flags = C_OVERRIDE; };
     break;
   case 'C':
     { (&c.modem_type)->d.p = (optarg); (&c.modem_type)->flags = C_OVERRIDE; };
     break;
   case 'S':
     { (&c.fax_server_file)->d.p = (optarg); (&c.fax_server_file)->flags = C_OVERRIDE; };
     break;
   case 'I':
     { (&c.station_id)->d.p = (optarg); (&c.station_id)->flags = C_OVERRIDE; };
     break;
   case 'b':
     { (&c.blocking)->d.i = ((1==1)); (&c.blocking)->flags = C_OVERRIDE; };
     break;
   case 'a':
     { (&c.autobauding)->d.i = ((1==1)); (&c.autobauding)->flags = C_OVERRIDE; };
     break;
   case 'm':
     c.init_chat.flags = C_OVERRIDE;
     c.init_chat.d.p = conf_get_chat( optarg );
     break;
   case 'V':
     printf("\nmgetty+sendfax by Gert Doering\n%s\n\n",
      mgetty_version);
     printf("log file written to '");
     printf("/var/log/mgetty.%s", "<ttyX>");
            printf("'\nconfig file read from '%s",
   (("mgetty.config")[0] == '/'? ("mgetty.config") : ("/etc/mgetty+sendfax""/""mgetty.config")));
     printf("'\n\n");
     exit(0);
   case '?':
     exit_usage(2);
     break;
 }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int

variable_types: struct conf_data { char *key; union { long i; void *p; } d; enum { CT_INT=0, CT_STRING=1, CT_CHAT=2, CT_BOOL=3, CT_FLOWL=4, CT_ACTION=5, CT_KEYWORD=6 } type; enum { C_EMPTY=0, C_PRESET=1, C_OVERRIDE=2, C_CONF=3, C_IGNORE=4 } flags; } [2]


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

lprintf(5LL, "reading configuration data for port '%s'", a1);
get_config("/etc/mgetty+sendfax/mgetty.config", &c, "port", a1);
log_set_llevel(*((unsigned int *)&c + 290));
minfreespace = *((int *)&c + 254);
result = tio_check_speed(*((unsigned int *)&c + 2));
if ( (int)result < 0 )
{
lprintf(0LL, "invalid port speed: %d", *((unsigned int *)&c + 2));
exit_usage(2);
}
if ( *((_DWORD *)&c + 11) )
{
v2 = (__int64)*(&c + 4);
if ( (_DWORD)v2 )
{
if ( !*((_BYTE *)&c + 248) )
{
result = tio_check_speed(v2);
if ( (int)result < 0 )
{
lprintf(0LL, "invalid fax reception switch speed: %d", *((unsigned int *)&c + 8));
exit_usage(2);
}
}
}
}
if ( !*((_DWORD *)&c + 128) )
{
*(&c + 64) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 131) = 2;
}
if ( *((int *)&c + 176) <= 29 )
{
*(&c + 88) = (_BYTE *)mgetty_parse_args;
*((_DWORD *)&c + 179) = 2;
}
if ( *((_DWORD *)&c + 122) <= 0x383u )
{
result = lprintf(5LL, "increasing modem_check_time to 900 sec.");
*(&c + 61) = (_BYTE *)(&loc_380 + 4);
*((_DWORD *)&c + 125) = 2;
}
if ( *((_DWORD *)&c + 83) )
{
lprintf(5LL, "set modem_quirks: 0x%04x", *((unsigned int *)&c + 80));
result = (__int64)*(&c + 40);
modem_quirks = result;
}
return result;
}

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

lprintf(5LL, "reading configuration data for port '%s'", a1);
get_config("/etc/mgetty+sendfax/mgetty.config", &c, "port", a1);
log_set_llevel(*((unsigned int *)&c + 290));
minfreespace = *((int *)&c + 254);
result = tio_check_speed(*((unsigned int *)&c + 2));
if ( (int)result < 0 )
{
lprintf(0LL, "invalid port speed: %d", *((unsigned int *)&c + 2));
func0(2);
}
if ( *((_DWORD *)&c + 11) )
{
v2 = (__int64)*(&c + 4);
if ( (_DWORD)v2 )
{
if ( !*((_BYTE *)&c + 248) )
{
result = tio_check_speed(v2);
if ( (int)result < 0 )
{
lprintf(0LL, "invalid fax reception switch speed: %d", *((unsigned int *)&c + 8));
func0(2);
}
}
}
}
if ( !*((_DWORD *)&c + 128) )
{
*(&c + 64) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 131) = 2;
}
if ( *((int *)&c + 176) <= 29 )
{
*(&c + 88) = (_BYTE *)mgetty_parse_args;
*((_DWORD *)&c + 179) = 2;
}
if ( *((_DWORD *)&c + 122) <= 0x383u )
{
result = lprintf(5LL, "increasing modem_check_time to 900 sec.");
*(&c + 61) = (_BYTE *)(&loc_380 + 4);
*((_DWORD *)&c + 125) = 2;
}
if ( *((_DWORD *)&c + 83) )
{
lprintf(5LL, "set modem_quirks: 0x%04x", *((unsigned int *)&c + 80));
result = (__int64)*(&c + 40);
modem_quirks = result;
}
return result;
}

original_code:
void mgetty_get_config (char * port)
{
    lprintf( 5, "reading configuration data for port '%s'", port );
    get_config( (("mgetty.config")[0] == '/'? ("mgetty.config") : ("/etc/mgetty+sendfax""/""mgetty.config")),
  (conf_data *)&c, "port", port );
    log_set_llevel( ((int) c.debug.d.i) );
    minfreespace = ((int) c.diskspace.d.i);
    if ( tio_check_speed( ((int) c.speed.d.i) ) < 0 )
    {
 lprintf( 0, "invalid port speed: %d", ((int) c.speed.d.i));
 exit_usage(2);
    }
    if ( ( c.switchbd.flags != C_EMPTY ) && ((int) c.switchbd.d.i) != 0 && !((boolean) c.data_only.d.i) &&
  tio_check_speed( ((int) c.switchbd.d.i) ) < 0 )
    {
 lprintf( 0, "invalid fax reception switch speed: %d",
   ((int) c.switchbd.d.i) );
 exit_usage(2);
    }
    if ( ((int) c.rings_wanted.d.i) == 0 ) { (&c.rings_wanted)->d.i = (1); (&c.rings_wanted)->flags = C_OVERRIDE; };
    if ( ((int) c.ringback_time.d.i) < 30 ) { (&c.ringback_time)->d.i = (30); (&c.ringback_time)->flags = C_OVERRIDE; };
    if ( ((int) c.modem_check_time.d.i) >= 0 &&
  ((int) c.modem_check_time.d.i) < 900 )
    {
 lprintf( 5, "increasing modem_check_time to 900 sec." );
 { (&c.modem_check_time)->d.i = (900); (&c.modem_check_time)->flags = C_OVERRIDE; };
    }
    if ( ( c.modem_quirks.flags != C_EMPTY ) )
    {
        lprintf( 5, "set modem_quirks: 0x%04x", ((int) c.modem_quirks.d.i));
 modem_quirks = ((int) c.modem_quirks.d.i);
    }
}

canonical_original_code:
void mgetty_get_config(char *port)
{
    lprintf( 5, "reading configuration data for port '%s'", port );
    get_config( (("mgetty.config")[0] == '/'? ("mgetty.config") : ("/etc/mgetty+sendfax""/""mgetty.config")),
  (struct conf_data *)&c, "port", port );
    log_set_llevel( ((int) c.debug.d.i) );
    minfreespace = ((int) c.diskspace.d.i);
    if ( tio_check_speed( ((int) c.speed.d.i) ) < 0 )
    {
 lprintf( 0, "invalid port speed: %d", ((int) c.speed.d.i));
 exit_usage(2);
    }
    if ( ( c.switchbd.flags != C_EMPTY ) && ((int) c.switchbd.d.i) != 0 && !((char) c.data_only.d.i) &&
  tio_check_speed( ((int) c.switchbd.d.i) ) < 0 )
    {
 lprintf( 0, "invalid fax reception switch speed: %d",
   ((int) c.switchbd.d.i) );
 exit_usage(2);
    }
    if ( ((int) c.rings_wanted.d.i) == 0 ) { (&c.rings_wanted)->d.i = (1); (&c.rings_wanted)->flags = C_OVERRIDE; };
    if ( ((int) c.ringback_time.d.i) < 30 ) { (&c.ringback_time)->d.i = (30); (&c.ringback_time)->flags = C_OVERRIDE; };
    if ( ((int) c.modem_check_time.d.i) >= 0 &&
  ((int) c.modem_check_time.d.i) < 900 )
    {
 lprintf( 5, "increasing modem_check_time to 900 sec." );
 { (&c.modem_check_time)->d.i = (900); (&c.modem_check_time)->flags = C_OVERRIDE; };
    }
    if ( ( c.modem_quirks.flags != C_EMPTY ) )
    {
        lprintf( 5, "set modem_quirks: 0x%04x", ((int) c.modem_quirks.d.i));
 modem_quirks = ((int) c.modem_quirks.d.i);
    }
}

variable_types:
port
char *


decompiled_code:
void __fastcall __noreturn exit_usage(int status)
{
lprintf(0LL, "Usage: mgetty [-x debug] [-s speed] [-r] line");
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(int status)
{
lprintf(0LL, "Usage: mgetty [-x debug] [-s speed] [-r] line");
exit(status);
}

original_code:
void exit_usage (int code)
{
    lprintf( 0, "Usage: mgetty [-x debug] [-s speed] [-r] line" );
    exit(code);
}

canonical_original_code:
void exit_usage(int code)
{
    lprintf( 0, "Usage: mgetty [-x debug] [-s speed] [-r] line" );
    exit(code);
}

variable_types: code int


decompiled_code:
void __fastcall vgetty_button(int a1)
{
_BYTE v1[264]; // [rsp-108h] [rbp-108h] BYREF

if ( !a1 )
{
if ( **((_BYTE **)&cvd + 163) )
{
make_path(v1, *((_QWORD *)&cvd + 136));
voice_mode_on();
voice_execute_shell_script(v1, 0LL);
voice_mode_off();
exit(0);
}
}
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
_BYTE v1[264]; // [rsp-108h] [rbp-108h] BYREF

if ( !a1 )
{
if ( **((_BYTE **)&cvd + 163) )
{
make_path(v1, *((_QWORD *)&cvd + 136));
voice_mode_on();
voice_execute_shell_script(v1, 0LL);
voice_mode_off();
exit(0);
}
}
}

original_code:
void vgetty_button(int rings)
     {
     if ((rings == 0) && (strlen(cvd.button_program.d.p) != 0))
          {
          char file_name[(256)];
          make_path(file_name, cvd.voice_dir.d.p,
           cvd.button_program.d.p);
          voice_mode_on();
          voice_execute_shell_script(file_name, ((void *)0));
          voice_mode_off();
          exit(0);
          };
     }

canonical_original_code:
void vgetty_button(int rings)
     {
     if ((rings == 0) && (strlen(cvd.button_program.d.p) != 0))
          {
          char file_name[-1];
          make_path(file_name, cvd.voice_dir.d.p,
           cvd.button_program.d.p);
          voice_mode_on();
          voice_execute_shell_script(file_name, ((void *)0));
          voice_mode_off();
          exit(0);
          };
     }

variable_types: rings int


getdiskstats

decompiled_code:
__int64 __fastcall getdiskstats(const char *a1, __fsword_t *a2)
{
int v2; // edx
__int64 result; // rax
struct statfs v4; // [rsp+0h] [rbp-88h] BYREF

v2 = statfs(a1, &v4);
result = 1LL;
if ( v2 >= 0 )
{
*a2 = v4.f_bsize;
a2[1] = v4.f_blocks;
a2[4] = v4.f_files;
a2[2] = v4.f_bfree;
a2[3] = v4.f_bavail;
a2[5] = v4.f_ffree;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, __fsword_t *a2)
{
int v2; // edx
__int64 result; // rax
struct statfs v4; // [rsp+0h] [rbp-88h] BYREF

v2 = statfs(a1, &v4);
result = 1LL;
if ( v2 >= 0 )
{
*a2 = v4.f_bsize;
a2[1] = v4.f_blocks;
a2[4] = v4.f_files;
a2[2] = v4.f_bfree;
a2[3] = v4.f_bavail;
a2[5] = v4.f_ffree;
result = 0LL;
}
return result;
}

original_code:
int
getdiskstats (char *path,mntinf *mi)
{
    struct statfs info;
    if (statfs(path,&info) < 0) {
 return(1);
    }
    mi->mi_bsize = info.f_bsize;
    mi->mi_blocks = info.f_blocks;
    mi->mi_files = info.f_files;
    mi->mi_bfree = info.f_bfree;
    mi->mi_bavail = info.f_bavail;
    mi->mi_ffree = info.f_ffree;
    return(0);
}

canonical_original_code:
int getdiskstats(char *path, struct mountinfo *mi)
{
    struct statfs info;
    if (statfs(path,&info) < 0) {
 return(1);
    }
    mi->mi_bsize = info.f_bsize;
    mi->mi_blocks = info.f_blocks;
    mi->mi_files = info.f_files;
    mi->mi_bfree = info.f_bfree;
    mi->mi_bavail = info.f_bavail;
    mi->mi_ffree = info.f_ffree;
    return(0);
}

variable_types:
path
char *

variable_types: struct mountinfo { long mi_bsize; long mi_blocks; long mi_bfree; long mi_bavail; long mi_files; long mi_ffree; } *

variable_types: struct statfs { long f_type; long f_bsize; unsigned long f_blocks; unsigned long f_bfree; unsigned long f_bavail; unsigned long f_files; unsigned long f_ffree; struct __fsid_t { int __val[2]; } f_fsid; long f_namelen; long f_frsize; long f_flags; long f_spare[4]; }

user_defined_types: struct statfs { long f_type; long f_bsize; unsigned long f_blocks; unsigned long f_bfree; unsigned long f_bavail; unsigned long f_files; unsigned long f_ffree; struct __fsid_t f_fsid; long f_namelen; long f_frsize; long f_flags; long f_spare[4]; }


checkspace

decompiled_code:
__int64 __fastcall checkspace(const char *a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // ebx
__fsword_t v4[9]; // [rsp+0h] [rbp-48h] BYREF

v1 = getdiskstats(a1, v4);
result = 1LL;
if ( !v1 )
{
v3 = *(_DWORD *)((char *)v4 + 1) * (v4[3] >> 2);
lprintf(5LL, "%d Mb free on %s", v3 >> 10, a1);
result = v3 / minfreespace;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // ebx
__fsword_t v4[9]; // [rsp+0h] [rbp-48h] BYREF

v1 = func0(a1, v4);
result = 1LL;
if ( !v1 )
{
v3 = *(_DWORD *)((char *)v4 + 1) * (v4[3] >> 2);
lprintf(5LL, "%d Mb free on %s", v3 >> 10, a1);
result = v3 / minfreespace;
}
return result;
}

original_code:
int checkspace (char *path)
{
    struct mountinfo mi;
    unsigned int kbytes;
    if (getdiskstats(path, &mi))
 return(1);
    kbytes = (mi.mi_bavail>>2) * (mi.mi_bsize>>8);
    lprintf( 5, "%d Mb free on %s", kbytes/1024, path );
    return( kbytes / minfreespace);
}

canonical_original_code:
int checkspace(char *path)
{
    struct mountinfo mi;
    unsigned int kbytes;
    if (getdiskstats(path, &mi))
 return(1);
    kbytes = (mi.mi_bavail>>2) * (mi.mi_bsize>>8);
    lprintf( 5, "%d Mb free on %s", kbytes/1024, path );
    return( kbytes / minfreespace);
}

variable_types: struct mountinfo { long mi_bsize; long mi_blocks; long mi_bfree; long mi_bavail; long mi_files; long mi_ffree; }

variable_types:
kbytes
unsigned int


decompiled_code:
__int64 __fastcall callback_parse_args(int argc, char **argv)
{
int v4; // eax
int v5; // eax
char *v6; // rax

c[19] = (char *)&def_init_chat_seq;
HIDWORD(c[20]) = 1;
while ( 1 )
{
v4 = getopt(argc, argv, "x:s:am:l:SdV");
if ( v4 == -1 )
return 0LL;
switch ( v4 )
{
case '?':
exit_usage(2);
case 'S':
v6 = ttyname(0);
c[1] = v6;
HIDWORD(c[2]) = 2;
lprintf(4LL, "using stdin for dial out, tty=%s", v6);
break;
case 'V':
printf("\nmgetty+sendfax by Gert Doering\n%s\n\n", mgetty_version);
printf("log file written to '");
printf("/var/log/mgetty.%s", "callback");
puts("'\n");
exit(0);
case 'a':
c[28] = (_BYTE *)&loc_1;
HIDWORD(c[29]) = 2;
break;
case 'd':
c[34] = (_BYTE *)&loc_1;
HIDWORD(c[35]) = 2;
lprintf(4LL, "debug mode active");
break;
case 'l':
if ( *optarg == 47 )
{
if ( memcmp(optarg, "/dev/", 5uLL) )
{
fprintf(stderr, "%s: -l: device must be located in /dev!\n", *argv);
exit(1);
}
}
c[1] = optarg;
HIDWORD(c[2]) = 2;
break;
case 'm':
HIDWORD(c[20]) = 2;
c[19] = (char *)conf_get_chat(optarg);
break;
case 's':
c[22] = (char *)atoi(optarg);
HIDWORD(c[23]) = 2;
break;
case 'x':
v5 = atoi(optarg);
c[37] = (char *)v5;
HIDWORD(c[38]) = 2;
log_set_llevel((unsigned int)v5);
break;
default:
continue;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func1(int argc, char **argv)
{
int v4; // eax
int v5; // eax
char *v6; // rax

c[19] = (char *)&def_init_chat_seq;
HIDWORD(c[20]) = 1;
while ( 1 )
{
v4 = getopt(argc, argv, "x:s:am:l:SdV");
if ( v4 == -1 )
return 0LL;
switch ( v4 )
{
case '?':
func0(2);
case 'S':
v6 = ttyname(0);
c[1] = v6;
HIDWORD(c[2]) = 2;
lprintf(4LL, "using stdin for dial out, tty=%s", v6);
break;
case 'V':
printf("\nmgetty+sendfax by Gert Doering\n%s\n\n", mgetty_version);
printf("log file written to '");
printf("/var/log/mgetty.%s", "callback");
puts("'\n");
exit(0);
case 'a':
c[28] = (_BYTE *)&loc_1;
HIDWORD(c[29]) = 2;
break;
case 'd':
c[34] = (_BYTE *)&loc_1;
HIDWORD(c[35]) = 2;
lprintf(4LL, "debug mode active");
break;
case 'l':
if ( *optarg == 47 )
{
if ( memcmp(optarg, "/dev/", 5uLL) )
{
fprintf(stderr, "%s: -l: device must be located in /dev!\n", *argv);
exit(1);
}
}
c[1] = optarg;
HIDWORD(c[2]) = 2;
break;
case 'm':
HIDWORD(c[20]) = 2;
c[19] = (char *)conf_get_chat(optarg);
break;
case 's':
c[22] = (char *)atoi(optarg);
HIDWORD(c[23]) = 2;
break;
case 'x':
v5 = atoi(optarg);
c[37] = (char *)v5;
HIDWORD(c[38]) = 2;
log_set_llevel((unsigned int)v5);
break;
default:
continue;
}
}
}

original_code:
int callback_parse_args (int argc,char ** argv)
{
int opt;
conf_data c_a[2];
    if ( ( (char *)&c_a[1] - (char *)&c_a[0] ) !=
  ( (char *)&c.ttys_0 - (char *)&c.ttys ) )
    {
 fprintf( stderr, "ERROR: config table size mixup. contact author\n" );
 exit(99);
    }
    c.modem_init.d.p = (void *) def_init_chat_seq;
    c.modem_init.flags = C_PRESET;
    while ((opt = getopt(argc, argv, "x:s:am:l:SdV")) != (-1))
    {
 switch (opt)
 {
   case 'x':
     { (&c.debug)->d.i = (atoi(optarg)); (&c.debug)->flags = C_OVERRIDE; };
     log_set_llevel( ((int) c.debug.d.i) );
     break;
   case 's':
     { (&c.speed)->d.i = (atoi(optarg)); (&c.speed)->flags = C_OVERRIDE; };
     break;
   case 'a':
     { (&c.autobauding)->d.i = ((1==1)); (&c.autobauding)->flags = C_OVERRIDE; };
     break;
   case 'm':
     c.modem_init.flags = C_OVERRIDE;
     c.modem_init.d.p = conf_get_chat( optarg );
     break;
   case 'l':
     if ( optarg[0] == '/' &&
   strncmp( optarg, "/dev/", 5 ) != 0 )
     {
  fprintf( stderr, "%s: -l: device must be located in /dev!\n",
                   argv[0]);
  exit(1);
     }
     { (&c.ttys)->d.p = (optarg); (&c.ttys)->flags = C_OVERRIDE; };
     break;
   case 'S':
     { (&c.ttys)->d.p = (ttyname(0)); (&c.ttys)->flags = C_OVERRIDE; };
     lprintf( 4, "using stdin for dial out, tty=%s", ((char *) c.ttys.d.p));
     break;
   case 'd':
     { (&c.nodetach)->d.i = ((1==1)); (&c.nodetach)->flags = C_OVERRIDE; };
     lprintf( 4, "debug mode active" );
     break;
   case 'V':
     printf("\nmgetty+sendfax by Gert Doering\n%s\n\n",
      mgetty_version);
     printf("log file written to '");
     printf("/var/log/mgetty.%s", "callback" );
     printf("'\n\n");
     exit(0);
   case '?':
     exit_usage(2);
     break;
 }
    }
    return 0;
}

canonical_original_code:
int callback_parse_args(int argc, char **argv)
{
int opt;
struct conf_data c_a[2];
    if ( ( (char *)&c_a[1] - (char *)&c_a[0] ) !=
  ( (char *)&c.ttys_0 - (char *)&c.ttys ) )
    {
 fprintf( stderr, "ERROR: config table size mixup. contact author\n" );
 exit(99);
    }
    c.modem_init.d.p = (void *) def_init_chat_seq;
    c.modem_init.flags = C_PRESET;
    while ((opt = getopt(argc, argv, "x:s:am:l:SdV")) != (-1))
    {
 switch (opt)
 {
   case 'x':
     { (&c.debug)->d.i = (atoi(optarg)); (&c.debug)->flags = C_OVERRIDE; };
     log_set_llevel( ((int) c.debug.d.i) );
     break;
   case 's':
     { (&c.speed)->d.i = (atoi(optarg)); (&c.speed)->flags = C_OVERRIDE; };
     break;
   case 'a':
     { (&c.autobauding)->d.i = ((1==1)); (&c.autobauding)->flags = C_OVERRIDE; };
     break;
   case 'm':
     c.modem_init.flags = C_OVERRIDE;
     c.modem_init.d.p = conf_get_chat( optarg );
     break;
   case 'l':
     if ( optarg[0] == '/' &&
   strncmp( optarg, "/dev/", 5 ) != 0 )
     {
  fprintf( stderr, "%s: -l: device must be located in /dev!\n",
                   argv[0]);
  exit(1);
     }
     { (&c.ttys)->d.p = (optarg); (&c.ttys)->flags = C_OVERRIDE; };
     break;
   case 'S':
     { (&c.ttys)->d.p = (ttyname(0)); (&c.ttys)->flags = C_OVERRIDE; };
     lprintf( 4, "using stdin for dial out, tty=%s", ((char *) c.ttys.d.p));
     break;
   case 'd':
     { (&c.nodetach)->d.i = ((1==1)); (&c.nodetach)->flags = C_OVERRIDE; };
     lprintf( 4, "debug mode active" );
     break;
   case 'V':
     printf("\nmgetty+sendfax by Gert Doering\n%s\n\n",
      mgetty_version);
     printf("log file written to '");
     printf("/var/log/mgetty.%s", "callback" );
     printf("'\n\n");
     exit(0);
   case '?':
     exit_usage(2);
     break;
 }
    }
    return 0;
}


decompiled_code:
__int64 __fastcall callback_get_config(const char *a1)
{
__int64 result; // rax

if ( a1 )
{
lprintf(5LL, "reading specific data for port '%s'", a1);
get_config("/etc/mgetty+sendfax/callback.config", (unsigned int)((_DWORD)c + 24), "port", a1);
}
else
{
lprintf(5LL, "reading default configuration");
get_config("/etc/mgetty+sendfax/callback.config", c, "port", 0LL);
}
log_set_llevel(LODWORD(c[37]));
result = tio_check_speed(LODWORD(c[22]));
if ( (int)result < 0 )
{
lprintf(0LL, "invalid port speed: %d", LODWORD(c[22]));
exit_usage(2);
}
return result;
}

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

if ( a1 )
{
lprintf(5LL, "reading specific data for port '%s'", a1);
get_config("/etc/mgetty+sendfax/callback.config", (unsigned int)((_DWORD)c + 24), "port", a1);
}
else
{
lprintf(5LL, "reading default configuration");
get_config("/etc/mgetty+sendfax/callback.config", c, "port", 0LL);
}
log_set_llevel(LODWORD(c[37]));
result = tio_check_speed(LODWORD(c[22]));
if ( (int)result < 0 )
{
lprintf(0LL, "invalid port speed: %d", LODWORD(c[22]));
func0(2);
}
return result;
}

original_code:
void callback_get_config (char * port)
{
    if ( port == ((void *)0) )
    {
 lprintf( 5, "reading default configuration" );
 get_config( (("callback.config")[0] == '/'? ("callback.config") : ("/etc/mgetty+sendfax""/""callback.config")),
      (conf_data *)&c, "port", ((void *)0) );
    }
    else
    {
 lprintf( 5, "reading specific data for port '%s'", port );
 get_config( (("callback.config")[0] == '/'? ("callback.config") : ("/etc/mgetty+sendfax""/""callback.config")),
      ((conf_data *)&c)+1, "port", port );
    }
    log_set_llevel( ((int) c.debug.d.i) );
    if ( tio_check_speed( ((int) c.speed.d.i) ) < 0 )
    {
 lprintf( 0, "invalid port speed: %d", ((int) c.speed.d.i));
 exit_usage(2);
    }
}

canonical_original_code:
void callback_get_config(char *port)
{
    if ( port == ((void *)0) )
    {
 lprintf( 5, "reading default configuration" );
 get_config( (("callback.config")[0] == '/'? ("callback.config") : ("/etc/mgetty+sendfax""/""callback.config")),
      (struct conf_data *)&c, "port", ((void *)0) );
    }
    else
    {
 lprintf( 5, "reading specific data for port '%s'", port );
 get_config( (("callback.config")[0] == '/'? ("callback.config") : ("/etc/mgetty+sendfax""/""callback.config")),
      ((struct conf_data *)&c)+1, "port", port );
    }
    log_set_llevel( ((int) c.debug.d.i) );
    if ( tio_check_speed( ((int) c.speed.d.i) ) < 0 )
    {
 lprintf( 0, "invalid port speed: %d", ((int) c.speed.d.i));
 exit_usage(2);
    }
}


decompiled_code:
void __fastcall __noreturn exit_usage(int status)
{
fwrite(
"Usage: callback [-x <debug level>] [-V] [-l <modem lines>] [-m <initstring>]\n"
" [-s <speed>] [-d] [-S] [phone number(s)...]\n",
1uLL,
0x80uLL,
stderr);
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(int status)
{
fwrite(
"Usage: callback [-x <debug level>] [-V] [-l <modem lines>] [-m <initstring>]\n"
" [-s <speed>] [-d] [-S] [phone number(s)...]\n",
1uLL,
0x80uLL,
stderr);
exit(status);
}

original_code:
void exit_usage (int code)
{
    fprintf( stderr, "Usage: callback [-x <debug level>] [-V] [-l <modem lines>] [-m <initstring>]\n       [-s <speed>] [-d] [-S] [phone number(s)...]\n");
    exit(code);
}

canonical_original_code:
void exit_usage(int code)
{
    fprintf( stderr, "Usage: callback [-x <debug level>] [-V] [-l <modem lines>] [-m <initstring>]\n       [-s <speed>] [-d] [-S] [phone number(s)...]\n");
    exit(code);
}


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

if ( !have_warned )
{
result = fprintf(stderr, "WARNING: G3 file \"%s\" has incorrect line width, fixed\n", a1);
++have_warned;
}
return result;
}

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

if ( !have_warned )
{
result = fprintf(stderr, "WARNING: G3 file \"%s\" has incorrect line width, fixed\n", a1);
++have_warned;
}
return result;
}

original_code:
void warn_g3 (char * file)
{
    if ( have_warned ) return;
    fprintf( stderr, "WARNING: G3 file \"%s\" has incorrect line width, fixed\n",
             file );
    have_warned++;
}

canonical_original_code:
void warn_g3(char *file)
{
    if ( have_warned ) return;
    fprintf( stderr, "WARNING: G3 file \"%s\" has incorrect line width, fixed\n",
             file );
    have_warned++;
}

variable_types:
file
char *


decompiled_code:
void __fastcall __noreturn exit_usage(const char *a1)
{
fprintf(stderr, "usage: %s [-h <lines>] [-a] [-l] [-p <n>] [-w <n>] g3-file ...\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
fprintf(stderr, "usage: %s [-h <lines>] [-a] [-l] [-p <n>] [-w <n>] g3-file ...\n", a1);
exit(1);
}

original_code:
void exit_usage (char * program)
{
    fprintf( stderr, "usage: %s [-h <lines>] [-a] [-l] [-p <n>] [-w <n>] g3-file ...\n",
     program );
    exit(1);
}

canonical_original_code:
void exit_usage(char *program)
{
    fprintf( stderr, "usage: %s [-h <lines>] [-a] [-l] [-p <n>] [-w <n>] g3-file ...\n",
     program );
    exit(1);
}

variable_types:
program
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
unsigned __int64 v6; // rdi
int v7; // eax
__int64 v8; // rdx
__int64 v9; // rcx
unsigned __int64 v10; // rsi
int v11; // ebx
bool v12; // cf
bool v13; // zf
char v14; // al
bool v15; // cf
bool v16; // zf
const char *v17; // rdi
__int64 v18; // rcx
const char *v19; // rsi
unsigned int v20; // er12
int v21; // eax
bool v22; // cf
bool v23; // zf
__int64 v24; // rcx
_BOOL4 v25; // er14
int v26; // ebx
unsigned int v27; // ebp
int v28; // ebx
int v29; // ebp
unsigned int *v30; // rax
__off_t v31; // rax
int v32; // eax
int v33; // eax
int v34; // eax
int v35; // eax
int v36; // eax
int v37; // eax
unsigned int v38; // er15
__int64 v39; // rdx
__int64 v40; // rcx
__int64 v41; // rdx
__int64 v42; // rcx
__int64 v43; // rdx
__int64 v44; // rcx
__int64 v45; // rdx
__int64 v46; // rcx
__int64 v47; // rdx
__int64 v48; // rcx
int v50; // er13
int v51; // [rsp+8h] [rbp-80h]
unsigned int v52; // [rsp+Ch] [rbp-7Ch]
unsigned int v53; // [rsp+10h] [rbp-78h]
int v54; // [rsp+14h] [rbp-74h]
const char **v55; // [rsp+18h] [rbp-70h]
int v58; // [rsp+38h] [rbp-50h]
int v59; // [rsp+3Ch] [rbp-4Ch]
unsigned int v60; // [rsp+40h] [rbp-48h]
int v61; // [rsp+48h] [rbp-40h]
int v62; // [rsp+4Ch] [rbp-3Ch]

build_tree(&white, &t_white, envp);
build_tree(&white, &m_white, v3);
build_tree(&black, &t_black, v4);
build_tree(&black, &m_black, v5);
init_byte_tab(0LL, byte_tab);
init_byte_tab(0LL, &out_byte_tab);
v59 = 0;
v62 = 0;
v52 = 1728;
v61 = 0;
while ( 1 )
{
v6 = (unsigned int)argc;
v7 = getopt(argc, (char *const *)argv, "lah:p:w:RL:");
if ( v7 == -1 )
break;
switch ( v7 )
{
case '?':
exit_usage(*argv);
case 'L':
v59 = atoi(optarg);
break;
case 'R':
v62 = 1;
break;
case 'a':
byte_align = 1;
break;
case 'h':
v61 = atoi(optarg);
break;
case 'l':
putblackline = 1;
break;
case 'p':
padding = atoi(optarg);
break;
case 'w':
v52 = atoi(optarg);
break;
default:
continue;
}
}
if ( (int)v52 <= 99 )
{
fprintf(stderr, "%s: line width must be >= 100 PELs\n", *argv);
exit(1);
}
v53 = optind;
v10 = (unsigned int)argc;
if ( argc <= optind )
{
v11 = 1;
LABEL_104:
if ( !v62 )
goto LABEL_105;
goto LABEL_106;
}
v55 = &argv[optind];
v58 = 0;
v11 = 1;
v12 = __CFADD__(v52, 1);
v13 = v52 == -1;
while ( 2 )
{
v8 = (__int64)*v55;
v6 = (unsigned __int64)"-l";
v9 = 3LL;
v10 = (unsigned __int64)*v55;
do
{
if ( !v9 )
break;
v12 = *(_BYTE *)v10 < *(_BYTE *)v6;
v13 = *(_BYTE *)v10++ == *(_BYTE *)v6++;
--v9;
}
while ( v13 );
v14 = (!v12 && !v13) - v12;
v15 = 0;
v16 = v14 == 0;
if ( !v14 )
{
putblackline = 1;
goto LABEL_17;
}
v17 = "-";
v18 = 2LL;
v19 = *v55;
do
{
if ( !v18 )
break;
v15 = *v19 < (unsigned int)*v17;
v16 = *v19++ == *v17++;
--v18;
}
while ( v16 );
v20 = (char)((!v15 && !v16) - v15);
if ( (!v15 && !v16) != v15 )
{
v10 = 0LL;
v20 = open(*v55, 0);
if ( v20 == -1 )
{
v6 = (unsigned __int64)*v55;
perror(*v55);
goto LABEL_17;
}
}
if ( v11 )
{
if ( byte_align || padding > 0 )
putcode(0LL, 4LL, v8, v18);
putcode(2048LL, 12LL, v8, v18);
v28 = v61 - 1;
if ( v61 <= 0 )
{
--v61;
}
else
{
v29 = v61 - 1;
do
{
putwhitespan(v52);
((void (*)(void))puteol)();
--v29;
}
while ( v29 != -1 );
v61 = -1;
v58 += v28 + 1;
}
}
have_warned = 0;
v10 = (unsigned __int64)rbuf;
v6 = v20;
v21 = read(v20, rbuf, 0x2000uLL);
rs = v21;
if ( v21 < 0 )
{
perror("read");
close(rs);
exit(8);
}
v22 = (unsigned int)v21 < 0x3F;
v23 = v21 == 63;
if ( v21 <= 63 )
{
rp = 0;
if ( v21 <= 0 )
{
LABEL_61:
if ( v20 )
goto LABEL_102;
goto LABEL_62;
}
}
else
{
v10 = (unsigned __int64)&unk_881;
v6 = (unsigned __int64)"PC Research, Inc";
v24 = 17LL;
do
{
if ( !v24 )
break;
v22 = *(_BYTE *)v10 < *(_BYTE *)v6;
v23 = *(_BYTE *)v10++ == *(_BYTE *)v6++;
--v24;
}
while ( v23 );
rp = ((!v22 && !v23) == v22) << 6;
}
v51 = 0;
v60 = 0;
v25 = 0;
v54 = 0;
v26 = 0;
v27 = 0;
while ( 1 )
{
while ( v26 <= 19 )
{
v32 = rp++;
v27 |= byte_tab[(unsigned __int8)rbuf[v32]] << v26;
v26 += 8;
if ( rp >= rs )
{
v10 = (unsigned __int64)rbuf;
v6 = v20;
v33 = read(v20, rbuf, 0x2000uLL);
rs = v33;
if ( v33 < 0 )
{
v6 = (unsigned __int64)"read2";
perror("read2");
break;
}
rp = 0;
if ( !v33 )
goto LABEL_61;
}
}
if ( v25 )
{
v8 = black;
v30 = *(unsigned int **)(black + 8LL * (unsigned __int8)v27 + 8);
}
else
{
v8 = white;
v30 = *(unsigned int **)(white + 8LL * (unsigned __int8)v27 + 8);
}
if ( v30 )
{
while ( 1 )
{
v9 = *v30;
if ( (_DWORD)v9 )
break;
v27 >>= 8;
v26 -= 8;
v8 = (unsigned __int8)v27;
v30 = *(unsigned int **)&v30[2 * (unsigned __int8)v27 + 2];
if ( !v30 )
goto LABEL_53;
}
v27 >>= v9;
v26 -= v9;
v50 = v30[1];
if ( v50 != -1 )
{
v10 = (unsigned int)v51;
if ( v50 + v51 > (int)v52 )
{
v38 = v52 - v51;
v6 = (unsigned __int64)*v55;
warn_g3(*v55);
if ( (int)(v52 - v51) > 0 )
{
v6 = v38;
if ( v25 )
putblackspan(v38);
else
putwhitespan(v38);
}
v51 = v52 + 1;
}
else
{
v10 = v30[3];
v6 = v30[2];
putcode(v6, v10, v8, v9);
v51 += v50;
}
if ( v50 <= 63 )
v25 = !v25;
goto LABEL_115;
}
}
else
{
LABEL_53:
v31 = lseek(0, 0LL, 1);
v10 = (unsigned __int64)"invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n";
v6 = (unsigned __int64)stderr;
fprintf(
stderr,
"invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n",
v60,
(unsigned int)v51,
rp - (__int64)rs + v31);
while ( (v27 & 0x3F) != 0 )
{
v27 >>= 1;
v9 = (unsigned int)(v26 - 1);
if ( (int)v9 <= 19 )
{
v34 = rp;
v8 = (unsigned int)(rp + 1);
rp = v8;
v27 |= byte_tab[(unsigned __int8)rbuf[v34]] << (v26 - 1);
v26 += 7;
if ( (int)v8 >= rs )
{
v10 = (unsigned __int64)rbuf;
v6 = v20;
v35 = read(v20, rbuf, 0x2000uLL);
rs = v35;
if ( v35 < 0 )
{
v6 = (unsigned __int64)"read4";
perror("read4");
break;
}
rp = 0;
if ( !v35 )
goto LABEL_61;
}
}
else
{
--v26;
}
}
}
if ( v51 > 0 && (int)v52 > v51 )
{
warn_g3(*v55);
if ( v25 )
putblackspan(0LL);
v6 = v52 - v51;
putwhitespan(v6);
}
while ( (v27 & 1) == 0 )
{
if ( (v27 & 0xF) != 0 )
{
--v26;
v27 >>= 1;
}
else
{
v26 -= 4;
v27 >>= 4;
}
if ( v26 <= 19 )
{
v36 = rp;
v8 = (unsigned int)(rp + 1);
rp = v8;
v9 = (unsigned int)v26;
v27 |= byte_tab[(unsigned __int8)rbuf[v36]] << v26;
v26 += 8;
if ( (int)v8 >= rs )
{
v10 = (unsigned __int64)rbuf;
v6 = v20;
v37 = read(v20, rbuf, 0x2000uLL);
rs = v37;
if ( v37 < 0 )
{
v6 = (unsigned __int64)"read3";
perror("read3");
break;
}
rp = 0;
if ( !v37 )
goto LABEL_61;
}
}
}
--v26;
v27 >>= 1;
v25 = v51;
if ( !v51 )
{
++v54;
goto LABEL_115;
}
++v60;
((void (*)(void))puteol)();
++v58;
v10 = (unsigned int)v59;
if ( v59 > 0 && v59 <= v58 )
break;
v51 = 0;
v25 = 0;
v54 = 0;
LABEL_115:
if ( rs <= 0 || v54 > 3 )
goto LABEL_61;
}
if ( !v20 )
break;
LABEL_102:
v6 = v20;
close(v20);
LABEL_62:
if ( v59 <= 0 || v58 < v59 )
{
v11 = 0;
v6 = v53;
if ( argc - 1 != v53 )
{
putwhitespan(v52);
((void (*)(void))puteol)();
if ( putblackline )
{
putwhitespan(0LL);
putblackspan(v52);
((void (*)(void))puteol)();
}
v6 = v52;
putwhitespan(v52);
((void (*)(void))puteol)();
v11 = 0;
}
LABEL_17:
++v53;
++v55;
v12 = argc < v53;
v13 = argc == v53;
if ( argc == v53 )
goto LABEL_104;
continue;
}
break;
}
if ( v62 )
{
write(1, &buf, buflen);
return 0;
}
v11 = 0;
LABEL_105:
puteol(v6, v10, v8, v9);
puteol(v6, v10, v39, v40);
puteol(v6, v10, v41, v42);
puteol(v6, v10, v43, v44);
puteol(v6, v10, v45, v46);
puteol(v6, v10, v47, v48);
LABEL_106:
write(1, &buf, buflen);
if ( v11 )
fprintf(stderr, "%s: warning: no input file specified, empty g3 file created\n", *argv);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
unsigned __int64 v6; // rdi
int v7; // eax
__int64 v8; // rdx
__int64 v9; // rcx
unsigned __int64 v10; // rsi
int v11; // ebx
bool v12; // cf
bool v13; // zf
char v14; // al
bool v15; // cf
bool v16; // zf
const char *v17; // rdi
__int64 v18; // rcx
const char *v19; // rsi
unsigned int v20; // er12
int v21; // eax
bool v22; // cf
bool v23; // zf
__int64 v24; // rcx
_BOOL4 v25; // er14
int v26; // ebx
unsigned int v27; // ebp
int v28; // ebx
int v29; // ebp
unsigned int *v30; // rax
__off_t v31; // rax
int v32; // eax
int v33; // eax
int v34; // eax
int v35; // eax
int v36; // eax
int v37; // eax
unsigned int v38; // er15
__int64 v39; // rdx
__int64 v40; // rcx
__int64 v41; // rdx
__int64 v42; // rcx
__int64 v43; // rdx
__int64 v44; // rcx
__int64 v45; // rdx
__int64 v46; // rcx
__int64 v47; // rdx
__int64 v48; // rcx
int v50; // er13
int v51; // [rsp+8h] [rbp-80h]
unsigned int v52; // [rsp+Ch] [rbp-7Ch]
unsigned int v53; // [rsp+10h] [rbp-78h]
int v54; // [rsp+14h] [rbp-74h]
const char **v55; // [rsp+18h] [rbp-70h]
int v58; // [rsp+38h] [rbp-50h]
int v59; // [rsp+3Ch] [rbp-4Ch]
unsigned int v60; // [rsp+40h] [rbp-48h]
int v61; // [rsp+48h] [rbp-40h]
int v62; // [rsp+4Ch] [rbp-3Ch]

build_tree(&white, &t_white, envp);
build_tree(&white, &m_white, v3);
build_tree(&black, &t_black, v4);
build_tree(&black, &m_black, v5);
init_byte_tab(0LL, byte_tab);
init_byte_tab(0LL, &out_byte_tab);
v59 = 0;
v62 = 0;
v52 = 1728;
v61 = 0;
while ( 1 )
{
v6 = (unsigned int)argc;
v7 = getopt(argc, (char *const *)argv, "lah:p:w:RL:");
if ( v7 == -1 )
break;
switch ( v7 )
{
case '?':
func0(*argv);
case 'L':
v59 = atoi(optarg);
break;
case 'R':
v62 = 1;
break;
case 'a':
byte_align = 1;
break;
case 'h':
v61 = atoi(optarg);
break;
case 'l':
putblackline = 1;
break;
case 'p':
padding = atoi(optarg);
break;
case 'w':
v52 = atoi(optarg);
break;
default:
continue;
}
}
if ( (int)v52 <= 99 )
{
fprintf(stderr, "%s: line width must be >= 100 PELs\n", *argv);
exit(1);
}
v53 = optind;
v10 = (unsigned int)argc;
if ( argc <= optind )
{
v11 = 1;
LABEL_104:
if ( !v62 )
goto LABEL_105;
goto LABEL_106;
}
v55 = &argv[optind];
v58 = 0;
v11 = 1;
v12 = __CFADD__(v52, 1);
v13 = v52 == -1;
while ( 2 )
{
v8 = (__int64)*v55;
v6 = (unsigned __int64)"-l";
v9 = 3LL;
v10 = (unsigned __int64)*v55;
do
{
if ( !v9 )
break;
v12 = *(_BYTE *)v10 < *(_BYTE *)v6;
v13 = *(_BYTE *)v10++ == *(_BYTE *)v6++;
--v9;
}
while ( v13 );
v14 = (!v12 && !v13) - v12;
v15 = 0;
v16 = v14 == 0;
if ( !v14 )
{
putblackline = 1;
goto LABEL_17;
}
v17 = "-";
v18 = 2LL;
v19 = *v55;
do
{
if ( !v18 )
break;
v15 = *v19 < (unsigned int)*v17;
v16 = *v19++ == *v17++;
--v18;
}
while ( v16 );
v20 = (char)((!v15 && !v16) - v15);
if ( (!v15 && !v16) != v15 )
{
v10 = 0LL;
v20 = open(*v55, 0);
if ( v20 == -1 )
{
v6 = (unsigned __int64)*v55;
perror(*v55);
goto LABEL_17;
}
}
if ( v11 )
{
if ( byte_align || padding > 0 )
putcode(0LL, 4LL, v8, v18);
putcode(2048LL, 12LL, v8, v18);
v28 = v61 - 1;
if ( v61 <= 0 )
{
--v61;
}
else
{
v29 = v61 - 1;
do
{
putwhitespan(v52);
((void (*)(void))puteol)();
--v29;
}
while ( v29 != -1 );
v61 = -1;
v58 += v28 + 1;
}
}
have_warned = 0;
v10 = (unsigned __int64)rbuf;
v6 = v20;
v21 = read(v20, rbuf, 0x2000uLL);
rs = v21;
if ( v21 < 0 )
{
perror("read");
close(rs);
exit(8);
}
v22 = (unsigned int)v21 < 0x3F;
v23 = v21 == 63;
if ( v21 <= 63 )
{
rp = 0;
if ( v21 <= 0 )
{
LABEL_61:
if ( v20 )
goto LABEL_102;
goto LABEL_62;
}
}
else
{
v10 = (unsigned __int64)&unk_881;
v6 = (unsigned __int64)"PC Research, Inc";
v24 = 17LL;
do
{
if ( !v24 )
break;
v22 = *(_BYTE *)v10 < *(_BYTE *)v6;
v23 = *(_BYTE *)v10++ == *(_BYTE *)v6++;
--v24;
}
while ( v23 );
rp = ((!v22 && !v23) == v22) << 6;
}
v51 = 0;
v60 = 0;
v25 = 0;
v54 = 0;
v26 = 0;
v27 = 0;
while ( 1 )
{
while ( v26 <= 19 )
{
v32 = rp++;
v27 |= byte_tab[(unsigned __int8)rbuf[v32]] << v26;
v26 += 8;
if ( rp >= rs )
{
v10 = (unsigned __int64)rbuf;
v6 = v20;
v33 = read(v20, rbuf, 0x2000uLL);
rs = v33;
if ( v33 < 0 )
{
v6 = (unsigned __int64)"read2";
perror("read2");
break;
}
rp = 0;
if ( !v33 )
goto LABEL_61;
}
}
if ( v25 )
{
v8 = black;
v30 = *(unsigned int **)(black + 8LL * (unsigned __int8)v27 + 8);
}
else
{
v8 = white;
v30 = *(unsigned int **)(white + 8LL * (unsigned __int8)v27 + 8);
}
if ( v30 )
{
while ( 1 )
{
v9 = *v30;
if ( (_DWORD)v9 )
break;
v27 >>= 8;
v26 -= 8;
v8 = (unsigned __int8)v27;
v30 = *(unsigned int **)&v30[2 * (unsigned __int8)v27 + 2];
if ( !v30 )
goto LABEL_53;
}
v27 >>= v9;
v26 -= v9;
v50 = v30[1];
if ( v50 != -1 )
{
v10 = (unsigned int)v51;
if ( v50 + v51 > (int)v52 )
{
v38 = v52 - v51;
v6 = (unsigned __int64)*v55;
func1(*v55);
if ( (int)(v52 - v51) > 0 )
{
v6 = v38;
if ( v25 )
putblackspan(v38);
else
putwhitespan(v38);
}
v51 = v52 + 1;
}
else
{
v10 = v30[3];
v6 = v30[2];
putcode(v6, v10, v8, v9);
v51 += v50;
}
if ( v50 <= 63 )
v25 = !v25;
goto LABEL_115;
}
}
else
{
LABEL_53:
v31 = lseek(0, 0LL, 1);
v10 = (unsigned __int64)"invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n";
v6 = (unsigned __int64)stderr;
fprintf(
stderr,
"invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n",
v60,
(unsigned int)v51,
rp - (__int64)rs + v31);
while ( (v27 & 0x3F) != 0 )
{
v27 >>= 1;
v9 = (unsigned int)(v26 - 1);
if ( (int)v9 <= 19 )
{
v34 = rp;
v8 = (unsigned int)(rp + 1);
rp = v8;
v27 |= byte_tab[(unsigned __int8)rbuf[v34]] << (v26 - 1);
v26 += 7;
if ( (int)v8 >= rs )
{
v10 = (unsigned __int64)rbuf;
v6 = v20;
v35 = read(v20, rbuf, 0x2000uLL);
rs = v35;
if ( v35 < 0 )
{
v6 = (unsigned __int64)"read4";
perror("read4");
break;
}
rp = 0;
if ( !v35 )
goto LABEL_61;
}
}
else
{
--v26;
}
}
}
if ( v51 > 0 && (int)v52 > v51 )
{
func1(*v55);
if ( v25 )
putblackspan(0LL);
v6 = v52 - v51;
putwhitespan(v6);
}
while ( (v27 & 1) == 0 )
{
if ( (v27 & 0xF) != 0 )
{
--v26;
v27 >>= 1;
}
else
{
v26 -= 4;
v27 >>= 4;
}
if ( v26 <= 19 )
{
v36 = rp;
v8 = (unsigned int)(rp + 1);
rp = v8;
v9 = (unsigned int)v26;
v27 |= byte_tab[(unsigned __int8)rbuf[v36]] << v26;
v26 += 8;
if ( (int)v8 >= rs )
{
v10 = (unsigned __int64)rbuf;
v6 = v20;
v37 = read(v20, rbuf, 0x2000uLL);
rs = v37;
if ( v37 < 0 )
{
v6 = (unsigned __int64)"read3";
perror("read3");
break;
}
rp = 0;
if ( !v37 )
goto LABEL_61;
}
}
}
--v26;
v27 >>= 1;
v25 = v51;
if ( !v51 )
{
++v54;
goto LABEL_115;
}
++v60;
((void (*)(void))puteol)();
++v58;
v10 = (unsigned int)v59;
if ( v59 > 0 && v59 <= v58 )
break;
v51 = 0;
v25 = 0;
v54 = 0;
LABEL_115:
if ( rs <= 0 || v54 > 3 )
goto LABEL_61;
}
if ( !v20 )
break;
LABEL_102:
v6 = v20;
close(v20);
LABEL_62:
if ( v59 <= 0 || v58 < v59 )
{
v11 = 0;
v6 = v53;
if ( argc - 1 != v53 )
{
putwhitespan(v52);
((void (*)(void))puteol)();
if ( putblackline )
{
putwhitespan(0LL);
putblackspan(v52);
((void (*)(void))puteol)();
}
v6 = v52;
putwhitespan(v52);
((void (*)(void))puteol)();
v11 = 0;
}
LABEL_17:
++v53;
++v55;
v12 = argc < v53;
v13 = argc == v53;
if ( argc == v53 )
goto LABEL_104;
continue;
}
break;
}
if ( v62 )
{
write(1, &buf, buflen);
return 0;
}
v11 = 0;
LABEL_105:
puteol(v6, v10, v8, v9);
puteol(v6, v10, v39, v40);
puteol(v6, v10, v41, v42);
puteol(v6, v10, v43, v44);
puteol(v6, v10, v45, v46);
puteol(v6, v10, v47, v48);
LABEL_106:
write(1, &buf, buflen);
if ( v11 )
fprintf(stderr, "%s: warning: no input file specified, empty g3 file created\n", *argv);
return 0;
}

original_code:
int main (int argc,char ** argv)
{
    int i;
    int fd;
    unsigned int data;
    int hibit;
    int cons_eol;
    int color;
    int row, col;
    struct g3_tree * p;
    int nr_pels;
    int first_file = 1;
    int empty_lines = 0;
    int line_width = 1728;
    int opt_R = 0;
    int max_length = 0;
    int lines_out = 0;
    build_tree( &white, t_white );
    build_tree( &white, m_white );
    build_tree( &black, t_black );
    build_tree( &black, m_black );
    init_byte_tab( 0, byte_tab );
    init_byte_tab( 0, out_byte_tab );
    while ( (i = getopt(argc, argv, "lah:p:w:RL:")) != (-1) )
    {
 switch (i)
 {
   case 'l': putblackline = 1; break;
   case 'a': byte_align = 1; break;
   case 'h': empty_lines = atoi( optarg ); break;
   case 'p': padding = atoi( optarg ); break;
   case 'w': line_width = atoi( optarg ); break;
   case 'R': opt_R = 1; break;
   case 'L': max_length = atoi( optarg ); break;
   case '?': exit_usage(argv[0]); break;
 }
    }
    if ( line_width < 100 )
    {
        fprintf( stderr, "%s: line width must be >= 100 PELs\n", argv[0] );
        exit(1);
    }
    for ( i=optind; i<argc; i++ )
    {
        if ( strcmp( argv[i], "-l" ) == 0)
        {
     putblackline = 1; continue;
        }
 if ( strcmp( argv[i], "-" ) == 0 )
  fd = 0;
 else
  fd = open( argv[i], 00 );
 if ( fd == -1 ) { perror( argv[i] ); continue; }
 if ( first_file )
 {
     if ( byte_align || padding > 0 ) putcode( 0, 4 );
     putcode( 0x800, 12 );
     first_file = 0;
     while ( empty_lines-- > 0 )
     {
  putwhitespan( line_width );
  puteol();
  lines_out++;
     }
 }
 hibit = 0;
 data = 0;
 cons_eol = 0;
 color = 0;
 have_warned = 0;
 rs = read( fd, rbuf, sizeof(rbuf) );
 if ( rs < 0 ) { perror( "read" ); close( rs ); exit(8); }
 rp = ( rs >= 64 && strcmp( rbuf+1, "PC Research, Inc" ) == 0 ) ? 64 : 0;
 row = col = 0;
 while ( rs > 0 && cons_eol < 4 )
 {
     while ( hibit < 20 )
     {
  data |= ( byte_tab[ (int) (unsigned char) rbuf[ rp++] ] << hibit );
  hibit += 8;
  if ( rp >= rs )
  {
      rs = read( fd, rbuf, sizeof( rbuf ) );
      if ( rs < 0 ) { perror( "read2"); break; }
      rp = 0;
      if ( rs == 0 ) {
   goto do_write;}
  }
     }
     if ( color == 0 )
  p = white->nextb[ data & 0xff ];
     else
  p = black->nextb[ data & 0xff ];
     while ( p != ((void *)0) && ! ( p->nr_bits ) )
     {
  data >>= 8;
  hibit -= 8;
  p = p->nextb[ data & 0xff ];
     }
     if ( p == ((void *)0) )
     {
  fprintf( stderr, "invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n",
    row, col, (unsigned long)lseek( 0, 0, 1 ) - rs + rp );
  while ( ( data & 0x03f ) != 0 )
  {
      data >>= 1; hibit--;
      if ( hibit < 20 )
      {
   data |= ( byte_tab[ (int) (unsigned char) rbuf[ rp++] ] << hibit );
   hibit += 8;
   if ( rp >= rs )
   { rs = read( fd, rbuf, sizeof( rbuf ) );
       if ( rs < 0 ) { perror( "read4"); break; }
       rp = 0;
       if ( rs == 0 ) goto do_write;
   }
      }
  }
  nr_pels = -1;
     }
     else
     {
  data >>= p->nr_bits;
  hibit -= p->nr_bits;
  nr_pels = ( (struct g3code *) p ) ->nr_pels;
     }
     if ( nr_pels == -1 )
     {
  if ( col>0 && col < line_width )
  {
      warn_g3( argv[i] );
      if ( color != 0 )
   { putblackspan(0); }
      putwhitespan( line_width - col );
  }
  while ( ( data & 0x01 ) != 1 )
  {
      if ( ( data & 0xf ) == 0 )
      {
   hibit-= 4; data >>= 4;
      }
      else
      {
   hibit--; data >>= 1;
      }
      if ( hibit < 20 )
      {
   data |= ( byte_tab[ (int) (unsigned char) rbuf[ rp++] ] << hibit );
   hibit += 8;
   if ( rp >= rs )
   { rs = read( fd, rbuf, sizeof( rbuf ) );
       if ( rs < 0 ) { perror( "read3"); break; }
       rp = 0;
       if ( rs == 0 ) goto do_write;
   }
      }
  }
  hibit--; data >>=1;
  color=0;
  if ( col == 0 )
      cons_eol++;
  else
  {
      row++; col=0;
      cons_eol = 0;
      puteol();
      lines_out++;
      if ( max_length > 0 &&
    lines_out >= max_length ) { goto do_write; }
  }
     }
     else
     {
      if ( col + nr_pels <= line_width )
      {
      putcode( ( (struct g3code *) p ) ->bit_code,
        ( (struct g3code *) p ) ->bit_length );
      col += nr_pels;
  }
  else
  {
      int put_pels = (line_width - col);
      warn_g3( argv[i] );
      if ( put_pels > 0 )
      {
          if ( color == 0 )
              putwhitespan( put_pels );
   else
       putblackspan( put_pels );
      }
      col = line_width+1;
  }
  if ( nr_pels < 64 ) color = !color;
     }
 }
do_write:
 if( fd != 0 ) close(fd);
 if ( max_length > 0 &&
      lines_out >= max_length ) { break; }
 if ( i != argc -1 )
 {
     putwhitespan( line_width );
     puteol();
            if ( putblackline )
  { putwhitespan( 0 );
    putblackspan( line_width );
    puteol(); }
     putwhitespan( line_width );
     puteol();
 }
    }
    if ( ! opt_R )
    {
 for ( i=0; i<6; i++ ) puteol();
    }
    if ( out_hibit != 0 )
        buf[buflen++] = out_byte_tab[out_data & 0xff];
    write( 1, buf, buflen );
    if ( first_file )
    {
 fprintf( stderr, "%s: warning: no input file specified, empty g3 file created\n", argv[0] );
    }
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    int i;
    int fd;
    unsigned int data;
    int hibit;
    int cons_eol;
    int color;
    int row; int col;
    struct g3_tree *p;
    int nr_pels;
    int first_file = 1;
    int empty_lines = 0;
    int line_width = 1728;
    int opt_R = 0;
    int max_length = 0;
    int lines_out = 0;
    build_tree( &white, t_white );
    build_tree( &white, m_white );
    build_tree( &black, t_black );
    build_tree( &black, m_black );
    init_byte_tab( 0, byte_tab );
    init_byte_tab( 0, out_byte_tab );
    while ( (i = getopt(argc, argv, "lah:p:w:RL:")) != (-1) )
    {
 switch (i)
 {
   case 'l': putblackline = 1; break;
   case 'a': byte_align = 1; break;
   case 'h': empty_lines = atoi( optarg ); break;
   case 'p': padding = atoi( optarg ); break;
   case 'w': line_width = atoi( optarg ); break;
   case 'R': opt_R = 1; break;
   case 'L': max_length = atoi( optarg ); break;
   case '?': exit_usage(argv[0]); break;
 }
    }
    if ( line_width < 100 )
    {
        fprintf( stderr, "%s: line width must be >= 100 PELs\n", argv[0] );
        exit(1);
    }
    for ( i=optind; i<argc; i++ )
    {
        if ( strcmp( argv[i], "-l" ) == 0)
        {
     putblackline = 1; continue;
        }
 if ( strcmp( argv[i], "-" ) == 0 )
  fd = 0;
 else
  fd = open( argv[i], 00 );
 if ( fd == -1 ) { perror( argv[i] ); continue; }
 if ( first_file )
 {
     if ( byte_align || padding > 0 ) putcode( 0, 4 );
     putcode( 0x800, 12 );
     first_file = 0;
     while ( empty_lines-- > 0 )
     {
  putwhitespan( line_width );
  puteol();
  lines_out++;
     }
 }
 hibit = 0;
 data = 0;
 cons_eol = 0;
 color = 0;
 have_warned = 0;
 rs = read( fd, rbuf, sizeof(rbuf) );
 if ( rs < 0 ) { perror( "read" ); close( rs ); exit(8); }
 rp = ( rs >= 64 && strcmp( rbuf+1, "PC Research, Inc" ) == 0 ) ? 64 : 0;
 row = col = 0;
 while ( rs > 0 && cons_eol < 4 )
 {
     while ( hibit < 20 )
     {
  data |= ( byte_tab[ (int) (unsigned char) rbuf[ rp++] ] << hibit );
  hibit += 8;
  if ( rp >= rs )
  {
      rs = read( fd, rbuf, sizeof( rbuf ) );
      if ( rs < 0 ) { perror( "read2"); break; }
      rp = 0;
      if ( rs == 0 ) {
   goto do_write;}
  }
     }
     if ( color == 0 )
  p = white->nextb[ data & 0xff ];
     else
  p = black->nextb[ data & 0xff ];
     while ( p != ((void *)0) && ! ( p->nr_bits ) )
     {
  data >>= 8;
  hibit -= 8;
  p = p->nextb[ data & 0xff ];
     }
     if ( p == ((void *)0) )
     {
  fprintf( stderr, "invalid code, row=%d, col=%d, file offset=%lx, skip to eol\n",
    row, col, (unsigned long)lseek( 0, 0, 1 ) - rs + rp );
  while ( ( data & 0x03f ) != 0 )
  {
      data >>= 1; hibit--;
      if ( hibit < 20 )
      {
   data |= ( byte_tab[ (int) (unsigned char) rbuf[ rp++] ] << hibit );
   hibit += 8;
   if ( rp >= rs )
   { rs = read( fd, rbuf, sizeof( rbuf ) );
       if ( rs < 0 ) { perror( "read4"); break; }
       rp = 0;
       if ( rs == 0 ) goto do_write;
   }
      }
  }
  nr_pels = -1;
     }
     else
     {
  data >>= p->nr_bits;
  hibit -= p->nr_bits;
  nr_pels = ( (struct g3code *) p ) ->nr_pels;
     }
     if ( nr_pels == -1 )
     {
  if ( col>0 && col < line_width )
  {
      warn_g3( argv[i] );
      if ( color != 0 )
   { putblackspan(0); }
      putwhitespan( line_width - col );
  }
  while ( ( data & 0x01 ) != 1 )
  {
      if ( ( data & 0xf ) == 0 )
      {
   hibit-= 4; data >>= 4;
      }
      else
      {
   hibit--; data >>= 1;
      }
      if ( hibit < 20 )
      {
   data |= ( byte_tab[ (int) (unsigned char) rbuf[ rp++] ] << hibit );
   hibit += 8;
   if ( rp >= rs )
   { rs = read( fd, rbuf, sizeof( rbuf ) );
       if ( rs < 0 ) { perror( "read3"); break; }
       rp = 0;
       if ( rs == 0 ) goto do_write;
   }
      }
  }
  hibit--; data >>=1;
  color=0;
  if ( col == 0 )
      cons_eol++;
  else
  {
      row++; col=0;
      cons_eol = 0;
      puteol();
      lines_out++;
      if ( max_length > 0 &&
    lines_out >= max_length ) { goto do_write; }
  }
     }
     else
     {
      if ( col + nr_pels <= line_width )
      {
      putcode( ( (struct g3code *) p ) ->bit_code,
        ( (struct g3code *) p ) ->bit_length );
      col += nr_pels;
  }
  else
  {
      int put_pels = (line_width - col);
      warn_g3( argv[i] );
      if ( put_pels > 0 )
      {
          if ( color == 0 )
              putwhitespan( put_pels );
   else
       putblackspan( put_pels );
      }
      col = line_width+1;
  }
  if ( nr_pels < 64 ) color = !color;
     }
 }
do_write:
 if( fd != 0 ) close(fd);
 if ( max_length > 0 &&
      lines_out >= max_length ) { break; }
 if ( i != argc -1 )
 {
     putwhitespan( line_width );
     puteol();
            if ( putblackline )
  { putwhitespan( 0 );
    putblackspan( line_width );
    puteol(); }
     putwhitespan( line_width );
     puteol();
 }
    }
    if ( ! opt_R )
    {
 for ( i=0; i<6; i++ ) puteol();
    }
    if ( out_hibit != 0 )
        buf[buflen++] = out_byte_tab[out_data & 0xff];
    write( 1, buf, buflen );
    if ( first_file )
    {
 fprintf( stderr, "%s: warning: no input file specified, empty g3 file created\n", argv[0] );
    }
    return 0;
}

variable_types: i int

variable_types: fd int

variable_types:
data
unsigned int

variable_types: hibit int

variable_types: color int

variable_types: row int

variable_types: col int

variable_types: struct g3_tree { int nr_bits; struct g3_tree *nextb[-1]; } *


variable_types: struct gsm_state { short dp0[280]; short z1; long L_z2; int mp; short u[8]; short LARpp[2][8]; short j; short ltp_cut; short nrp; short v[9]; short msr; char verbose; char fast; } *

variable_types:
c
unsigned char *

variable_types:
target
short *

variable_types:
LARc
short [8]

variable_types:
Nc
short [4]

variable_types:
Mc
short [4]

variable_types:
bc
short [4]

variable_types:
xmaxc
short [4]

variable_types:
xmc
short [-1]


decompiled_code:
__int64 __fastcall Multitech_5634ZPX_ISA_set_device(unsigned int a1)
{
__int64 result; // rax

reset_watchdog();
switch ( a1 )
{
case 1u:
voice_command("AT+VLS=0", &unk_363);
result = 0LL;
break;
case 2u:
voice_command("AT+VLS=1", &unk_363);
result = 0LL;
break;
case 3u:
voice_command("AT+VLS=6", &unk_363);
result = 0LL;
break;
case 6u:
voice_command("AT+VLS=4", &unk_363);
result = 0LL;
break;
case 7u:
voice_command("AT+VLS=2", &unk_363);
result = 0LL;
break;
default:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

reset_watchdog();
switch ( a1 )
{
case 1u:
voice_command("AT+VLS=0", &unk_363);
result = 0LL;
break;
case 2u:
voice_command("AT+VLS=1", &unk_363);
result = 0LL;
break;
case 3u:
voice_command("AT+VLS=6", &unk_363);
result = 0LL;
break;
case 6u:
voice_command("AT+VLS=4", &unk_363);
result = 0LL;
break;
case 7u:
voice_command("AT+VLS=2", &unk_363);
result = 0LL;
break;
default:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
static int Multitech_5634ZPX_ISA_set_device(int device)
     {
     reset_watchdog();
     switch (device)
          {
          case (0x0001):
               voice_command("AT+VLS=0", "OK");
               return((0));
          case (0x0007):
               voice_command("AT+VLS=2", "OK");
               return((0));
          case (0x0002):
               voice_command("AT+VLS=1", "OK");
               return((0));
          case (0x0006):
               voice_command("AT+VLS=4", "OK");
               return((0));
          case (0x0003):
               voice_command("AT+VLS=6", "OK");
               return((0));
          };
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }

variable_types: device int


decompiled_code:
__int64 __fastcall Multitech_5634ZPX_ISA_beep(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
unsigned int v3; // er12
int v4; // edi
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

v2 = (unsigned int)((int)a2 >> 31);
LODWORD(v2) = (int)a2 % *(_DWORD *)(voice_modem + 48LL);
v3 = (int)a2 / *(_DWORD *)(voice_modem + 48LL);
reset_watchdog(a1, a2, v2);
sprintf(v6, *(const char **)(voice_modem + 32LL), (unsigned int)a1, (unsigned int)a1, v3);
if ( (unsigned int)voice_command(v6, &unk_393) )
return 0xFFFFFFFFLL;
v4 = 1000;
if ( (int)a2 >= 1000 )
v4 = a2;
delay((unsigned int)(v4 - 1000));
return (unsigned int)-((voice_command(&unk_393, *(_QWORD *)(voice_modem + 40LL)) & 0x1000) == 0);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
unsigned int v3; // er12
int v4; // edi
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

v2 = (unsigned int)((int)a2 >> 31);
LODWORD(v2) = (int)a2 % *(_DWORD *)(voice_modem + 48LL);
v3 = (int)a2 / *(_DWORD *)(voice_modem + 48LL);
reset_watchdog(a1, a2, v2);
sprintf(v6, *(const char **)(voice_modem + 32LL), (unsigned int)a1, (unsigned int)a1, v3);
if ( (unsigned int)voice_command(v6, &unk_393) )
return 0xFFFFFFFFLL;
v4 = 1000;
if ( (int)a2 >= 1000 )
v4 = a2;
delay((unsigned int)(v4 - 1000));
return (unsigned int)-((voice_command(&unk_393, *(_QWORD *)(voice_modem + 40LL)) & 0x1000) == 0);
}

original_code:
int Multitech_5634ZPX_ISA_beep(int frequency, int length)
     {
     char buffer[(256)];
     int true_length = length / voice_modem->beep_timeunit;
     reset_watchdog();
     sprintf(buffer, voice_modem->beep_cmnd, frequency, frequency, true_length);
     if (voice_command(buffer, "") != (0))
          return((-1));
     delay(((length - 1000) > 0) ? (length - 1000) : 0);
     if ((voice_command("", voice_modem->beep_answr) & (0x1000)) != (0x1000))
          return((-1));
     return((0));
     }

canonical_original_code:
int Multitech_5634ZPX_ISA_beep(int frequency, int length)
     {
     char buffer[-1];
     int true_length = length / voice_modem->beep_timeunit;
     reset_watchdog();
     sprintf(buffer, voice_modem->beep_cmnd, frequency, frequency, true_length);
     if (voice_command(buffer, "") != (0))
          return((-1));
     delay(((length - 1000) > 0) ? (length - 1000) : 0);
     if ((voice_command("", voice_modem->beep_answr) & (0x1000)) != (0x1000))
          return((-1));
     return((0));
     }

variable_types: frequency int

variable_types: length int

variable_types:
buffer
char [-1]


decompiled_code:
void vgetty_create_message_flag_file()
{
int v0; // eax
char v1[264]; // [rsp-108h] [rbp-108h] BYREF

if ( **((_BYTE **)&cvd + 148) )
{
make_path(v1, *((_QWORD *)&cvd + 136));
lprintf(6LL, "%s: creating message flag file %s", program_name, v1);
v0 = creat(v1, 0x1B6u);
if ( v0 < 0 )
lprintf(3LL, "%s: could not creat message flag file %s", program_name, v1);
else
close(v0);
}
}

canonical_decompiled_code:
void func1()
{
int v0; // eax
char v1[264]; // [rsp-108h] [rbp-108h] BYREF

if ( **((_BYTE **)&cvd + 148) )
{
make_path(v1, *((_QWORD *)&cvd + 136));
lprintf(6LL, "%s: creating message flag file %s", program_name, v1);
v0 = creat(v1, 0x1B6u);
if ( v0 < 0 )
lprintf(3LL, "%s: could not creat message flag file %s", program_name, v1);
else
close(v0);
}
}

original_code:
void vgetty_create_message_flag_file(void)
     {
     if (strlen(cvd.message_flag_file.d.p) != 0)
          {
          char flag_file_name[(256)];
          int flag_file;
          make_path(flag_file_name, cvd.voice_dir.d.p,
           cvd.message_flag_file.d.p);
          lprintf(6, "%s: creating message flag file %s",
           program_name, flag_file_name);
          flag_file = creat(flag_file_name, 0666);
          if (flag_file < 0)
               lprintf(3, "%s: could not creat message flag file %s",
                program_name, flag_file_name);
          else
               close(flag_file);
          };
     }

canonical_original_code:
void vgetty_create_message_flag_file()
     {
     if (strlen(cvd.message_flag_file.d.p) != 0)
          {
          char flag_file_name[-1];
          int flag_file;
          make_path(flag_file_name, cvd.voice_dir.d.p,
           cvd.message_flag_file.d.p);
          lprintf(6, "%s: creating message flag file %s",
           program_name, flag_file_name);
          flag_file = creat(flag_file_name, 0666);
          if (flag_file < 0)
               lprintf(3, "%s: could not creat message flag file %s",
                program_name, flag_file_name);
          else
               close(flag_file);
          };
     }