decompiled_code:
__int64 __fastcall fax_send_page(char *file, _DWORD *a2, __int64 a3, unsigned int a4, unsigned int a5)
{
__int64 v6; // rbx
int v7; // er15
char v8; // r12
int v9; // ebx
int v10; // er14
unsigned int v11; // er15
const char *v12; // rdx
const char *v13; // r9
__int64 v14; // r12
size_t v15; // r13
__int64 v16; // rdx
int v17; // eax
unsigned int v18; // ecx
__int64 i; // rax
char v20; // dl
unsigned __int8 v21; // al
unsigned int v22; // er12
int fd; // [rsp+4h] [rbp-364h]
unsigned int v26; // [rsp+18h] [rbp-350h]
char v28; // [rsp+2Fh] [rbp-339h] BYREF
unsigned __int8 buf; // [rsp+30h] [rbp-338h] BYREF
__int64 v30; // [rsp+31h] [rbp-337h]
__int64 v31; // [rsp+39h] [rbp-32Fh]
char v32; // [rsp+41h] [rbp-327h]
char v33; // [rsp+4Dh] [rbp-31Bh]
unsigned __int8 v34; // [rsp+70h] [rbp-2F8h]
char v35[96]; // [rsp+130h] [rbp-238h] BYREF
int v36; // [rsp+190h] [rbp-1D8h]

v6 = a3;
lprintf(5LL, "fax_send_page(\"%s\") started...", file);
tio_set_flow_control(a5, v6, 1LL);
tio_set(a5, v6);
if ( (unsigned int)fax_command("AT+FDT", "CONNECT", a5) == -1 || fax_hangup )
{
v22 = -1;
lprintf(3LL, "AT+FDT -> some error (%d), abort fax send!", fax_hangup_code);
}
else
{
signal(14, (__sighandler_t)fax_send_timeout);
if ( modem_type == 4 && (modem_quirks & 8) == 0 )
{
lprintf(5LL, "waiting for XON, got:");
alarm(0x14u);
do
{
if ( (unsigned int)mdm_read_byte(a5, &v28) != 1 )
{
lprintf(1LL, "timeout waiting for XON");
fwrite("error waiting for XON!\n", 1uLL, 0x17uLL, stderr);
close(a5);
exit(11);
}
lputc(5LL, (unsigned int)v28);
}
while ( v28 != 17 );
alarm(0);
}
tio_set_flow_control(a5, a3, 5LL);
tio_set(a5, a3);
lprintf(4LL, "sending %s...", file);
v7 = open(file, 0);
if ( v7 != -1 )
{
if ( (modem_quirks & 0x10) != 0 )
{
lprintf(4LL, "send %d 0-bytes (pad before first EOL)...", 100LL);
memset(v35, 0, sizeof(v35));
v36 = 0;
write(a5, v35, 0x64uLL);
}
v8 = 1;
v9 = 0;
alarm(0x28u);
v26 = 0;
fd = v7;
while ( 1 )
{
LABEL_9:
v10 = read(fd, &buf, 0x40uLL);
if ( v10 <= 0 )
{
close(fd);
goto LABEL_53;
}
if ( v9 > 1000 )
{
v9 -= 1000;
alarm(0x1Eu);
}
if ( !v8 )
{
v16 = buf;
goto LABEL_33;
}
if ( v10 <= 63 )
break;
if ( v30 ^ 0x6165736552204350LL | v31 ^ 0x636E49202C686372LL || v32 )
{
v21 = buf;
LABEL_43:
v16 = v21;
if ( v21 == 73 )
{
if ( (_BYTE)v30 != 73 )
goto LABEL_41;
}
else
{
if ( v21 != 77 )
{
if ( v10 <= 9 || v21 )
goto LABEL_41;
goto LABEL_33;
}
if ( (_BYTE)v30 != 77 )
goto LABEL_41;
}
lprintf(3LL, "file may be 'tiffg3' - TIFF is *not* a valid input format", v21);
fwrite("WARNING: file may be 'tiffg3' - TIFF file format is *not* supported!\n", 1uLL, 0x45uLL, stderr);
fwrite(" Thus, fax transmission will most propably fail\n", 1uLL, 0x38uLL, stderr);
v16 = buf;
goto LABEL_33;
}
v11 = 0;
lprintf(4LL, "skipping over GhostScript header");
if ( (fax_par_d != 0) != (v33 != 0) )
{
v12 = "normal";
v13 = "normal";
if ( v33 )
v13 = "fine";
if ( fax_par_d )
v12 = "fine";
fprintf(stderr, "WARNING: sending in %s mode, fax data is %s mode\n", v12, v13);
lprintf(3LL, "resolution mismatch");
}
if ( v10 != 64 )
{
v16 = v34;
v17 = 64;
LABEL_34:
v18 = 0;
for ( i = v17 + 1; ; ++i )
{
v20 = *((_BYTE *)&fax_send_swaptable + v16);
v11 = v18 + 1;
v35[v18] = v20;
if ( v20 == 16 )
{
v35[v11] = 16;
v11 = v18 + 2;
}
if ( v10 <= (int)i )
break;
v16 = *(&buf + i);
v18 = v11;
}
v15 = (int)v11;
v14 = (int)v11;
goto LABEL_24;
}
v14 = 0LL;
v15 = 0LL;
LABEL_24:
lprintf(6LL, "read %d, write %d", (unsigned int)v10, v11);
if ( write(a5, v35, v15) != v14 )
lprintf(1LL, "could not write all %d bytes", v11);
v8 = fax_sendpg_timeout;
if ( fax_sendpg_timeout )
fax_send_panic_exit(a5);
v26 += v11;
v9 += v11;
if ( (unsigned __int8)check_for_input(a5) )
{
lprintf(5LL, "input: got ");
while ( read(a5, &v28, 1uLL) == 1 )
{
lputc(5LL, (unsigned int)v28);
if ( !(unsigned __int8)check_for_input(a5) )
goto LABEL_9;
}
lprintf(1LL, "read failed");
}
}
v21 = buf;
if ( v10 != 1 )
goto LABEL_43;
LABEL_41:
lprintf(
3LL,
"file looks 'suspicious', buf=%02x %02x %02x %02x...",
v21,
(unsigned __int8)v30,
BYTE1(v30),
BYTE2(v30));
fwrite("WARNING: are you sure that this is a G3 fax file? Doesn't seem to be...\n", 1uLL, 0x48uLL, stderr);
v16 = buf;
LABEL_33:
v17 = 0;
goto LABEL_34;
}
lprintf(1LL, "cannot open %s", file);
lprintf(3LL, "have to send empty page instead");
v26 = 0;
LABEL_53:
lprintf(4LL, "page complete, %d bytes sent", v26);
if ( a2 )
*a2 += v26;
v22 = fax_send_ppm(a5, a3, a4);
alarm(0);
}
return v22;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *file, _DWORD *a2, __int64 a3, unsigned int a4, unsigned int a5)
{
__int64 v6; // rbx
int v7; // er15
char v8; // r12
int v9; // ebx
int v10; // er14
unsigned int v11; // er15
const char *v12; // rdx
const char *v13; // r9
__int64 v14; // r12
size_t v15; // r13
__int64 v16; // rdx
int v17; // eax
unsigned int v18; // ecx
__int64 i; // rax
char v20; // dl
unsigned __int8 v21; // al
unsigned int v22; // er12
int fd; // [rsp+4h] [rbp-364h]
unsigned int v26; // [rsp+18h] [rbp-350h]
char v28; // [rsp+2Fh] [rbp-339h] BYREF
unsigned __int8 buf; // [rsp+30h] [rbp-338h] BYREF
__int64 v30; // [rsp+31h] [rbp-337h]
__int64 v31; // [rsp+39h] [rbp-32Fh]
char v32; // [rsp+41h] [rbp-327h]
char v33; // [rsp+4Dh] [rbp-31Bh]
unsigned __int8 v34; // [rsp+70h] [rbp-2F8h]
char v35[96]; // [rsp+130h] [rbp-238h] BYREF
int v36; // [rsp+190h] [rbp-1D8h]

v6 = a3;
lprintf(5LL, "fax_send_page(\"%s\") started...", file);
tio_set_flow_control(a5, v6, 1LL);
tio_set(a5, v6);
if ( (unsigned int)fax_command("AT+FDT", "CONNECT", a5) == -1 || fax_hangup )
{
v22 = -1;
lprintf(3LL, "AT+FDT -> some error (%d), abort fax send!", fax_hangup_code);
}
else
{
signal(14, (__sighandler_t)fax_send_timeout);
if ( modem_type == 4 && (modem_quirks & 8) == 0 )
{
lprintf(5LL, "waiting for XON, got:");
alarm(0x14u);
do
{
if ( (unsigned int)mdm_read_byte(a5, &v28) != 1 )
{
lprintf(1LL, "timeout waiting for XON");
fwrite("error waiting for XON!\n", 1uLL, 0x17uLL, stderr);
close(a5);
exit(11);
}
lputc(5LL, (unsigned int)v28);
}
while ( v28 != 17 );
alarm(0);
}
tio_set_flow_control(a5, a3, 5LL);
tio_set(a5, a3);
lprintf(4LL, "sending %s...", file);
v7 = open(file, 0);
if ( v7 != -1 )
{
if ( (modem_quirks & 0x10) != 0 )
{
lprintf(4LL, "send %d 0-bytes (pad before first EOL)...", 100LL);
memset(v35, 0, sizeof(v35));
v36 = 0;
write(a5, v35, 0x64uLL);
}
v8 = 1;
v9 = 0;
alarm(0x28u);
v26 = 0;
fd = v7;
while ( 1 )
{
LABEL_9:
v10 = read(fd, &buf, 0x40uLL);
if ( v10 <= 0 )
{
close(fd);
goto LABEL_53;
}
if ( v9 > 1000 )
{
v9 -= 1000;
alarm(0x1Eu);
}
if ( !v8 )
{
v16 = buf;
goto LABEL_33;
}
if ( v10 <= 63 )
break;
if ( v30 ^ 0x6165736552204350LL | v31 ^ 0x636E49202C686372LL || v32 )
{
v21 = buf;
LABEL_43:
v16 = v21;
if ( v21 == 73 )
{
if ( (_BYTE)v30 != 73 )
goto LABEL_41;
}
else
{
if ( v21 != 77 )
{
if ( v10 <= 9 || v21 )
goto LABEL_41;
goto LABEL_33;
}
if ( (_BYTE)v30 != 77 )
goto LABEL_41;
}
lprintf(3LL, "file may be 'tiffg3' - TIFF is *not* a valid input format", v21);
fwrite("WARNING: file may be 'tiffg3' - TIFF file format is *not* supported!\n", 1uLL, 0x45uLL, stderr);
fwrite(" Thus, fax transmission will most propably fail\n", 1uLL, 0x38uLL, stderr);
v16 = buf;
goto LABEL_33;
}
v11 = 0;
lprintf(4LL, "skipping over GhostScript header");
if ( (fax_par_d != 0) != (v33 != 0) )
{
v12 = "normal";
v13 = "normal";
if ( v33 )
v13 = "fine";
if ( fax_par_d )
v12 = "fine";
fprintf(stderr, "WARNING: sending in %s mode, fax data is %s mode\n", v12, v13);
lprintf(3LL, "resolution mismatch");
}
if ( v10 != 64 )
{
v16 = v34;
v17 = 64;
LABEL_34:
v18 = 0;
for ( i = v17 + 1; ; ++i )
{
v20 = *((_BYTE *)&fax_send_swaptable + v16);
v11 = v18 + 1;
v35[v18] = v20;
if ( v20 == 16 )
{
v35[v11] = 16;
v11 = v18 + 2;
}
if ( v10 <= (int)i )
break;
v16 = *(&buf + i);
v18 = v11;
}
v15 = (int)v11;
v14 = (int)v11;
goto LABEL_24;
}
v14 = 0LL;
v15 = 0LL;
LABEL_24:
lprintf(6LL, "read %d, write %d", (unsigned int)v10, v11);
if ( write(a5, v35, v15) != v14 )
lprintf(1LL, "could not write all %d bytes", v11);
v8 = fax_sendpg_timeout;
if ( fax_sendpg_timeout )
func1(a5);
v26 += v11;
v9 += v11;
if ( (unsigned __int8)check_for_input(a5) )
{
lprintf(5LL, "input: got ");
while ( read(a5, &v28, 1uLL) == 1 )
{
lputc(5LL, (unsigned int)v28);
if ( !(unsigned __int8)check_for_input(a5) )
goto LABEL_9;
}
lprintf(1LL, "read failed");
}
}
v21 = buf;
if ( v10 != 1 )
goto LABEL_43;
LABEL_41:
lprintf(
3LL,
"file looks 'suspicious', buf=%02x %02x %02x %02x...",
v21,
(unsigned __int8)v30,
BYTE1(v30),
BYTE2(v30));
fwrite("WARNING: are you sure that this is a G3 fax file? Doesn't seem to be...\n", 1uLL, 0x48uLL, stderr);
v16 = buf;
LABEL_33:
v17 = 0;
goto LABEL_34;
}
lprintf(1LL, "cannot open %s", file);
lprintf(3LL, "have to send empty page instead");
v26 = 0;
LABEL_53:
lprintf(4LL, "page complete, %d bytes sent", v26);
if ( a2 )
*a2 += v26;
v22 = func2(a5, a3, a4);
alarm(0);
}
return v22;
}

original_code:
int fax_send_page (char * g3_file,int * bytes_sent,TIO * tio,Post_page_messages ppm,int fd)
{
    int g3fd;
    char ch;
    char buf[256];
    char wbuf[ sizeof(buf) * 2 ];
    int w_total = 0;
    int rc;
    lprintf( 5, "fax_send_page(\"%s\") started...", g3_file );
    tio_set_flow_control( fd, tio, (0x01 | (0x02 | 0x04)) & 0x01 );
    tio_set( fd, tio );
    if ( fax_command( "AT+FDT", "CONNECT", fd ) == -1 ||
  fax_hangup != 0 )
    {
 lprintf( 3, "AT+FDT -> some error (%d), abort fax send!",
   fax_hangup_code );
 return -1;
    }
    signal( 14, fax_send_timeout );
    if ( modem_type == Mt_class2 &&
  ( modem_quirks & 0x08 ) == 0 )
    {
 lprintf( 5, "waiting for XON, got:" );
 alarm( 20 );
 do
 {
     if ( mdm_read_byte( fd, &ch ) != 1 )
     {
  lprintf( 1, "timeout waiting for XON" );
  fprintf( stderr, "error waiting for XON!\n" );
  close( fd );
  exit(11);
     }
     lputc( 5, ch );
 }
 while ( ch != 021 );
 alarm(0);
    }
    tio_set_flow_control( fd, tio, (0x01 | (0x02 | 0x04)) & (0x01|0x04));
    tio_set( fd, tio );
    lprintf( 4, "sending %s...", g3_file );
    g3fd = open( g3_file, 00 );
    if ( g3fd == -1 )
    {
 lprintf( 1, "cannot open %s", g3_file );
 lprintf( 3, "have to send empty page instead" );
    }
    else
    {
 int r, i, w;
 int w_refresh = 0;
 boolean first = (1==1);
 if ( modem_quirks & 0x10 )
 {
     char nbuf[100];
     lprintf( 4, "send %d 0-bytes (pad before first EOL)...", sizeof(nbuf) );
     bzero( nbuf, sizeof(nbuf) );
     write( fd, nbuf, sizeof(nbuf) );
 }
 alarm( 40 );
 while ( ( r = read( g3fd, buf, 64 ) ) > 0 )
 {
     if ( w_refresh > 1000 )
     {
  w_refresh -= 1000;
  alarm( 30 );
     }
     i = 0;
     if ( first )
     {
  first = (1==0);
  if ( r >= 64 && strcmp( buf+1,
     "PC Research, Inc" ) == 0 )
  {
      lprintf( 4, "skipping over GhostScript header" );
      i = 64;
      if ( ( fax_par_d.vr != 0 ) != ( buf[29] != 0 ) )
      {
   fprintf( stderr, "WARNING: sending in %s mode, fax data is %s mode\n",
     fax_par_d.vr? "fine" : "normal",
     buf[29] ? "fine" : "normal" );
   lprintf( 3, "resolution mismatch" );
      }
  }
                else
                if ( r >= 2 && ( ( buf[0] == 0x49 && buf[1] == 0x49 ) ||
                                 ( buf[0] == 0x4d && buf[1] == 0x4d ) ) )
  {
      lprintf( 3, "file may be 'tiffg3' - TIFF is *not* a valid input format" );
      fprintf( stderr, "WARNING: file may be 'tiffg3' - TIFF file format is *not* supported!\n" );
      fprintf( stderr, "         Thus, fax transmission will most propably fail\n" );
  }
                else
                if ( r < 10 || buf[0] != 0 )
  {
      lprintf( 3, "file looks 'suspicious', buf=%02x %02x %02x %02x...", buf[0] &0xff, buf[1] &0xff, buf[2] &0xff, buf[3] &0xff );
                    fprintf( stderr, "WARNING: are you sure that this is a G3 fax file? Doesn't seem to be...\n" );
  }
     }
     for ( w = 0; i < r; i++ )
     {
  wbuf[ w ] = fax_send_swaptable[ (unsigned char) buf[i] ];
  if ( wbuf[ w++ ] == 020 ) wbuf[ w++ ] = 020;
     }
     lprintf( 6, "read %d, write %d", r, w );
     if ( write( fd, wbuf, w ) != w )
     {
  lprintf( 1, "could not write all %d bytes", w );
     }
     if ( fax_sendpg_timeout )
     {
  fax_send_panic_exit( fd );
     }
     w_total += w;
     w_refresh += w;
     if ( check_for_input( fd ) )
     {
  lprintf( 5, "input: got " );
  do
  {
      if ( read( fd, &ch, 1 ) != 1 )
      {
   lprintf( 1, "read failed" );
   break;
      }
      else
   lputc( 5, ch );
  }
  while ( check_for_input( fd ) );
     }
 }
 close(g3fd);
    }
    lprintf( 4, "page complete, %d bytes sent", w_total );
    if ( bytes_sent != ((void *)0) )
            *bytes_sent += w_total;
    rc = fax_send_ppm( fd, tio, ppm );
    alarm(0);
    return rc;
}

canonical_original_code:
int fax_send_page(char *g3_file, int *bytes_sent, struct termios *tio, enum Post_page_messages ppm, int fd)
{
    int g3fd;
    char ch;
    char buf[256];
    char wbuf[-1];
    int w_total = 0;
    int rc;
    lprintf( 5, "fax_send_page(\"%s\") started...", g3_file );
    tio_set_flow_control( fd, tio, (0x01 | (0x02 | 0x04)) & 0x01 );
    tio_set( fd, tio );
    if ( fax_command( "AT+FDT", "CONNECT", fd ) == -1 ||
  fax_hangup != 0 )
    {
 lprintf( 3, "AT+FDT -> some error (%d), abort fax send!",
   fax_hangup_code );
 return -1;
    }
    signal( 14, fax_send_timeout );
    if ( modem_type == Mt_class2 &&
  ( modem_quirks & 0x08 ) == 0 )
    {
 lprintf( 5, "waiting for XON, got:" );
 alarm( 20 );
 do
 {
     if ( mdm_read_byte( fd, &ch ) != 1 )
     {
  lprintf( 1, "timeout waiting for XON" );
  fprintf( stderr, "error waiting for XON!\n" );
  close( fd );
  exit(11);
     }
     lputc( 5, ch );
 }
 while ( ch != 021 );
 alarm(0);
    }
    tio_set_flow_control( fd, tio, (0x01 | (0x02 | 0x04)) & (0x01|0x04));
    tio_set( fd, tio );
    lprintf( 4, "sending %s...", g3_file );
    g3fd = open( g3_file, 00 );
    if ( g3fd == -1 )
    {
 lprintf( 1, "cannot open %s", g3_file );
 lprintf( 3, "have to send empty page instead" );
    }
    else
    {
 int r; int i; int w;
 int w_refresh = 0;
 char first = (1==1);
 if ( modem_quirks & 0x10 )
 {
     char nbuf[100];
     lprintf( 4, "send %d 0-bytes (pad before first EOL)...", sizeof(nbuf) );
     bzero( nbuf, sizeof(nbuf) );
     write( fd, nbuf, sizeof(nbuf) );
 }
 alarm( 40 );
 while ( ( r = read( g3fd, buf, 64 ) ) > 0 )
 {
     if ( w_refresh > 1000 )
     {
  w_refresh -= 1000;
  alarm( 30 );
     }
     i = 0;
     if ( first )
     {
  first = (1==0);
  if ( r >= 64 && strcmp( buf+1,
     "PC Research, Inc" ) == 0 )
  {
      lprintf( 4, "skipping over GhostScript header" );
      i = 64;
      if ( ( fax_par_d.vr != 0 ) != ( buf[29] != 0 ) )
      {
   fprintf( stderr, "WARNING: sending in %s mode, fax data is %s mode\n",
     fax_par_d.vr? "fine" : "normal",
     buf[29] ? "fine" : "normal" );
   lprintf( 3, "resolution mismatch" );
      }
  }
                else
                if ( r >= 2 && ( ( buf[0] == 0x49 && buf[1] == 0x49 ) ||
                                 ( buf[0] == 0x4d && buf[1] == 0x4d ) ) )
  {
      lprintf( 3, "file may be 'tiffg3' - TIFF is *not* a valid input format" );
      fprintf( stderr, "WARNING: file may be 'tiffg3' - TIFF file format is *not* supported!\n" );
      fprintf( stderr, "         Thus, fax transmission will most propably fail\n" );
  }
                else
                if ( r < 10 || buf[0] != 0 )
  {
      lprintf( 3, "file looks 'suspicious', buf=%02x %02x %02x %02x...", buf[0] &0xff, buf[1] &0xff, buf[2] &0xff, buf[3] &0xff );
                    fprintf( stderr, "WARNING: are you sure that this is a G3 fax file? Doesn't seem to be...\n" );
  }
     }
     for ( w = 0; i < r; i++ )
     {
  wbuf[ w ] = fax_send_swaptable[ (unsigned char) buf[i] ];
  if ( wbuf[ w++ ] == 020 ) wbuf[ w++ ] = 020;
     }
     lprintf( 6, "read %d, write %d", r, w );
     if ( write( fd, wbuf, w ) != w )
     {
  lprintf( 1, "could not write all %d bytes", w );
     }
     if ( fax_sendpg_timeout )
     {
  fax_send_panic_exit( fd );
     }
     w_total += w;
     w_refresh += w;
     if ( check_for_input( fd ) )
     {
  lprintf( 5, "input: got " );
  do
  {
      if ( read( fd, &ch, 1 ) != 1 )
      {
   lprintf( 1, "read failed" );
   break;
      }
      else
   lputc( 5, ch );
  }
  while ( check_for_input( fd ) );
     }
 }
 close(g3fd);
    }
    lprintf( 4, "page complete, %d bytes sent", w_total );
    if ( bytes_sent != ((void *)0) )
            *bytes_sent += w_total;
    rc = fax_send_ppm( fd, tio, ppm );
    alarm(0);
    return rc;
}

variable_types: ch char

variable_types:
buf
char [256]

variable_types:
wbuf
char [-1]

variable_types: r int

variable_types: i int

variable_types: w int

variable_types: first char

variable_types:
nbuf
char [100]

user_defined_types: enum Post_page_messages { pp_mps=0, pp_eom=1, pp_eop=2, pp_pri_mps=3, pp_pri_eom=4, pp_pri_eop=5 }


repo: Distrotech/mgetty

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

reset_watchdog();
if ( current_device_1 == a1 || current_device_1 < 0 )
{
current_device_1 = a1;
}
else
{
voice_command("ATH0", "VCON|OK");
current_device_1 = a1;
if ( a1 > 7 )
{
LABEL_6:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, a1);
return 0xFFFFFFFFLL;
}
}
switch ( a1 )
{
case 1u:
voice_command("AT#VLS=0", "OK");
result = 0LL;
break;
case 2u:
voice_command("AT#VLS=4", "OK");
result = 0LL;
break;
case 3u:
voice_command("AT#VLS=3", "VCON");
result = 0LL;
break;
case 6u:
voice_command("AT#VLS=2", "VCON");
result = 0LL;
break;
case 7u:
voice_command("AT#VLS=1", "VCON");
result = 0LL;
break;
default:
goto LABEL_6;
}
return result;
}

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

reset_watchdog();
if ( current_device_1 == a1 || current_device_1 < 0 )
{
current_device_1 = a1;
}
else
{
voice_command("ATH0", "VCON|OK");
current_device_1 = a1;
if ( a1 > 7 )
{
LABEL_6:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, a1);
return 0xFFFFFFFFLL;
}
}
switch ( a1 )
{
case 1u:
voice_command("AT#VLS=0", "OK");
result = 0LL;
break;
case 2u:
voice_command("AT#VLS=4", "OK");
result = 0LL;
break;
case 3u:
voice_command("AT#VLS=3", "VCON");
result = 0LL;
break;
case 6u:
voice_command("AT#VLS=2", "VCON");
result = 0LL;
break;
case 7u:
voice_command("AT#VLS=1", "VCON");
result = 0LL;
break;
default:
goto LABEL_6;
}
return result;
}

original_code:
static int
Multitech_5600ZDXv_set_device (int device)
{
  static int current_device = -1;
  reset_watchdog();
  if ((current_device != device) && (current_device >= 0)) {
    voice_command("ATH0","VCON|OK");
  }
  current_device=device;
  switch (device) {
    case (0x0001):
      voice_command("AT#VLS=0", "OK");
      break;
    case (0x0002):
      voice_command("AT#VLS=4", "OK");
      break;
    case (0x0003):
      voice_command("AT#VLS=3", "VCON");
      break;
    case (0x0006):
      voice_command("AT#VLS=2", "VCON");
      break;
    case (0x0007):
      voice_command("AT#VLS=1","VCON");
      break;
    default:
      lprintf(3, "%s: Unknown output device (%d)",
              voice_modem->name, device);
      return((-1));
  }
  return((0));
}

canonical_original_code:
static int Multitech_5600ZDXv_set_device(int device)
{
  static int current_device = -1;
  reset_watchdog();
  if ((current_device != device) && (current_device >= 0)) {
    voice_command("ATH0","VCON|OK");
  }
  current_device=device;
  switch (device) {
    case (0x0001):
      voice_command("AT#VLS=0", "OK");
      break;
    case (0x0002):
      voice_command("AT#VLS=4", "OK");
      break;
    case (0x0003):
      voice_command("AT#VLS=3", "VCON");
      break;
    case (0x0006):
      voice_command("AT#VLS=2", "VCON");
      break;
    case (0x0007):
      voice_command("AT#VLS=1","VCON");
      break;
    default:
      lprintf(3, "%s: Unknown output device (%d)",
              voice_modem->name, device);
      return((-1));
  }
  return((0));
}

variable_types: device int

return_type: int


decompiled_code:
__int64 __fastcall Multitech_5600ZDXv_set_compression(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 v6; // rdx
__int64 v7; // rdx
char v8[280]; // [rsp+0h] [rbp-118h] BYREF

reset_watchdog();
v4 = *a2;
if ( *a2 == 7200 || v4 == 11025 )
{
v6 = (unsigned int)v4;
}
else
{
if ( v4 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
*a2 = 7200LL;
v6 = 7200LL;
}
sprintf(v8, "AT#VSR=%d", v6);
if ( (unsigned int)voice_command(v8, "OK") != 4096 )
return 0xFFFFFFFFLL;
v7 = *a1;
if ( *a1 == 2 )
{
LABEL_11:
*a3 = v7;
sprintf(v8, "AT#VBS=%d", v7);
return (unsigned int)-((unsigned int)voice_command(v8, "OK") != 4096);
}
if ( *a1 > 2 )
{
if ( ((v7 - 4) & 0xFFFFFFFFFFFFFFFBLL) == 0 )
goto LABEL_11;
}
else if ( !v7 )
{
*a1 = 2LL;
v7 = 2LL;
goto LABEL_11;
}
lprintf(3LL, "ROCKWELL handle event: Illegal voice compression method (%d)", v7);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 v6; // rdx
__int64 v7; // rdx
char v8[280]; // [rsp+0h] [rbp-118h] BYREF

reset_watchdog();
v4 = *a2;
if ( *a2 == 7200 || v4 == 11025 )
{
v6 = (unsigned int)v4;
}
else
{
if ( v4 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
*a2 = 7200LL;
v6 = 7200LL;
}
sprintf(v8, "AT#VSR=%d", v6);
if ( (unsigned int)voice_command(v8, "OK") != 4096 )
return 0xFFFFFFFFLL;
v7 = *a1;
if ( *a1 == 2 )
{
LABEL_11:
*a3 = v7;
sprintf(v8, "AT#VBS=%d", v7);
return (unsigned int)-((unsigned int)voice_command(v8, "OK") != 4096);
}
if ( *a1 > 2 )
{
if ( ((v7 - 4) & 0xFFFFFFFFFFFFFFFBLL) == 0 )
goto LABEL_11;
}
else if ( !v7 )
{
*a1 = 2LL;
v7 = 2LL;
goto LABEL_11;
}
lprintf(3LL, "ROCKWELL handle event: Illegal voice compression method (%d)", v7);
return 0xFFFFFFFFLL;
}

original_code:
static int
Multitech_5600ZDXv_set_compression (p_int *compression, p_int *speed, int *bits)
{
  char buf[(256)];
  reset_watchdog();
  switch (*speed) {
    case 0:
      *speed = 7200;
    case 7200:
    case 11025:
      break;
    default:
      lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name, (int)*speed);
      return((-1));
  }
  if (sprintf(buf, "AT#VSR=%d", (int)*speed) == -1) {
    lprintf(1, "%s: Command too long", __FUNCTION__);
  }
  if (voice_command(buf, "OK") != (0x1000)) {
    return((-1));
  }
  switch (*compression) {
    case 0:
      *compression = 2;
    case 2:
    case 4:
    case 8:
      *bits = *compression;
      break;
    default:
      lprintf(3,
              "ROCKWELL handle event: Illegal voice compression method (%d)",
              *compression);
      return((-1));
  }
  if (sprintf(buf, "AT#VBS=%d", *bits) == -1) {
    lprintf(1, "%s: Command too long", __FUNCTION__);
  }
  if (voice_command(buf, "OK") != (0x1000)) {
    return((-1));
  }
  return ((0));
}

canonical_original_code:
static int Multitech_5600ZDXv_set_compression(long *compression, long *speed, int *bits)
{
  char buf[-1];
  reset_watchdog();
  switch (*speed) {
    case 0:
      *speed = 7200;
    case 7200:
    case 11025:
      break;
    default:
      lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name, (int)*speed);
      return((-1));
  }
  if (sprintf(buf, "AT#VSR=%d", (int)*speed) == -1) {
    lprintf(1, "%s: Command too long", __FUNCTION__);
  }
  if (voice_command(buf, "OK") != (0x1000)) {
    return((-1));
  }
  switch (*compression) {
    case 0:
      *compression = 2;
    case 2:
    case 4:
    case 8:
      *bits = *compression;
      break;
    default:
      lprintf(3,
              "ROCKWELL handle event: Illegal voice compression method (%d)",
              *compression);
      return((-1));
  }
  if (sprintf(buf, "AT#VBS=%d", *bits) == -1) {
    lprintf(1, "%s: Command too long", __FUNCTION__);
  }
  if (voice_command(buf, "OK") != (0x1000)) {
    return((-1));
  }
  return ((0));
}

variable_types:
compression
long *

variable_types:
speed
long *

variable_types:
bits
int *

variable_types:
buf
char [-1]


decompiled_code:
__int64 Multitech_5600ZDXv_init()
{
__int64 v0; // rdx
unsigned __int64 v1; // rax
__int64 result; // rax
_BYTE v3[64]; // [rsp+0h] [rbp-148h] BYREF
char s[264]; // [rsp+40h] [rbp-108h] BYREF

reset_watchdog();
lprintf(4LL, "initializing Multitech MT5600ZDXv voice modem");
v0 = *((unsigned int *)&cvd + 110);
voice_modem_state = 2;
sprintf(s, "AT#VSP=%1u", v0);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence period");
if ( (unsigned int)voice_command("AT#VSD=0", "OK") != 4096 )
lprintf(3LL, "can't disable silence deletion");
if ( (unsigned int)voice_command("AT#VTD=3F,3F,3F", "OK") != 4096 )
lprintf(3LL, "can't set DLE responses");
v1 = *((_QWORD *)&cvd + 58);
if ( v1 > 0x64 )
{
lprintf(3LL, "Invalid threshold value.");
result = 0xFFFFFFFFLL;
}
else
{
sprintf(s, "AT#VSS=%1u", (unsigned int)(3 * v1) / 0x64uLL);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence threshold");
if ( (unsigned int)voice_command("AT&K3", "OK") == 4096 )
{
tio_get(voice_fd, v3);
tio_set_flow_control(voice_fd, v3, 1LL);
tio_set(voice_fd, v3);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rdx
unsigned __int64 v1; // rax
__int64 result; // rax
_BYTE v3[64]; // [rsp+0h] [rbp-148h] BYREF
char s[264]; // [rsp+40h] [rbp-108h] BYREF

reset_watchdog();
lprintf(4LL, "initializing Multitech MT5600ZDXv voice modem");
v0 = *((unsigned int *)&cvd + 110);
voice_modem_state = 2;
sprintf(s, "AT#VSP=%1u", v0);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence period");
if ( (unsigned int)voice_command("AT#VSD=0", "OK") != 4096 )
lprintf(3LL, "can't disable silence deletion");
if ( (unsigned int)voice_command("AT#VTD=3F,3F,3F", "OK") != 4096 )
lprintf(3LL, "can't set DLE responses");
v1 = *((_QWORD *)&cvd + 58);
if ( v1 > 0x64 )
{
lprintf(3LL, "Invalid threshold value.");
result = 0xFFFFFFFFLL;
}
else
{
sprintf(s, "AT#VSS=%1u", (unsigned int)(3 * v1) / 0x64uLL);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence threshold");
if ( (unsigned int)voice_command("AT&K3", "OK") == 4096 )
{
tio_get(voice_fd, v3);
tio_set_flow_control(voice_fd, v3, 1LL);
tio_set(voice_fd, v3);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
result = 0LL;
}
return result;
}

original_code:
static int
Multitech_5600ZDXv_init(void)
{
  char buffer[(256)];
  reset_watchdog();
  lprintf(4, "initializing Multitech MT5600ZDXv voice modem");
  voice_modem_state = (0x0002);
  sprintf(buffer, "AT#VSP=%1u", (int)cvd.rec_silence_len.d.i);
  if (voice_command(buffer, "OK") != (0x1000))
    lprintf(3, "can't set silence period");
  if (voice_command("AT#VSD=0", "OK") != (0x1000))
    lprintf(3, "can't disable silence deletion");
  if (voice_command("AT#VTD=3F,3F,3F", "OK") != (0x1000))
    lprintf(3, "can't set DLE responses");
  if ((cvd.rec_silence_threshold.d.i > 100) ||
      (cvd.rec_silence_threshold.d.i < 0)) {
    lprintf(3, "Invalid threshold value.");
    return(-1);
  }
  sprintf(buffer, "AT#VSS=%1u", (int)cvd.rec_silence_threshold.d.i * 3 / 100);
  if (voice_command(buffer, "OK") != (0x1000))
    lprintf(3, "can't set silence threshold");
  if (voice_command("AT&K3", "OK") == (0x1000)) {
    TIO tio;
    tio_get(voice_fd, &tio);
    tio_set_flow_control(voice_fd, &tio, 0x01);
    tio_set(voice_fd, &tio);
  } else {
    lprintf(3, "can't turn on hardware flow control");
  }
  voice_modem_state = (0x0001);
  return((0));
}

canonical_original_code:
static int Multitech_5600ZDXv_init()
{
  char buffer[-1];
  reset_watchdog();
  lprintf(4, "initializing Multitech MT5600ZDXv voice modem");
  voice_modem_state = (0x0002);
  sprintf(buffer, "AT#VSP=%1u", (int)cvd.rec_silence_len.d.i);
  if (voice_command(buffer, "OK") != (0x1000))
    lprintf(3, "can't set silence period");
  if (voice_command("AT#VSD=0", "OK") != (0x1000))
    lprintf(3, "can't disable silence deletion");
  if (voice_command("AT#VTD=3F,3F,3F", "OK") != (0x1000))
    lprintf(3, "can't set DLE responses");
  if ((cvd.rec_silence_threshold.d.i > 100) ||
      (cvd.rec_silence_threshold.d.i < 0)) {
    lprintf(3, "Invalid threshold value.");
    return(-1);
  }
  sprintf(buffer, "AT#VSS=%1u", (int)cvd.rec_silence_threshold.d.i * 3 / 100);
  if (voice_command(buffer, "OK") != (0x1000))
    lprintf(3, "can't set silence threshold");
  if (voice_command("AT&K3", "OK") == (0x1000)) {
    struct termios tio;
    tio_get(voice_fd, &tio);
    tio_set_flow_control(voice_fd, &tio, 0x01);
    tio_set(voice_fd, &tio);
  } else {
    lprintf(3, "can't turn on hardware flow control");
  }
  voice_modem_state = (0x0001);
  return((0));
}

variable_types:
buffer
char [-1]

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
__int64 __fastcall Multitech_5600ZDXv_handle_dle(char a1)
{
__int64 v2; // rax

if ( a1 != 116 )
return IS_101_handle_dle((unsigned int)a1);
v2 = create_event(8200LL);
return queue_event(v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(char a1)
{
__int64 v2; // rax

if ( a1 != 116 )
return IS_101_handle_dle((unsigned int)a1);
v2 = create_event(8200LL);
return queue_event(v2);
}

original_code:
static int
Multitech_5600ZDXv_handle_dle(char data)
{
  switch (data) {
    case 't':
      return(queue_event(create_event((0x2008))));
  }
  return(IS_101_handle_dle(data));
}

variable_types: data char


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

if ( *a3 != 47 )
{
v4 = stpcpy(a1, a2);
*v4 = 47;
a1 = v4 + 1;
}
return strcpy(a1, a3);
}

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

if ( *a3 != 47 )
{
v4 = stpcpy(a1, a2);
*v4 = 47;
a1 = v4 + 1;
}
return strcpy(a1, a3);
}

original_code:
void make_path(char *result, char *path, char *name)
     {
     if (name[0] == '/')
          {
          strcpy(result, name);
          }
     else
          {
          strcpy(result, path);
          strcat(result, "/");
          strcat(result, name);
          };
     }

variable_types:
result
char *

variable_types:
path
char *

variable_types:
name
char *

return_type: void


decompiled_code:
__int64 __fastcall vgetty_handle_event(int a1, char a2)
{
unsigned int v2; // er12
size_t v4; // rax

if ( a1 <= 8210 )
{
if ( a1 > 0x2000 )
{
switch ( a1 )
{
case 8193:
case 8195:
case 8200:
goto LABEL_9;
case 8196:
voice_stop_current_action();
answer_mode = answer_mode & 1;
switch_to_data_fax_mode = 1;
return 0LL;
case 8198:
voice_stop_current_action();
answer_mode = answer_mode & 2;
switch_to_data_fax_mode = 1;
return 0LL;
case 8199:
return 0;
case 8206:
voice_stop_current_action();
answer_mode = answer_mode & 3;
switch_to_data_fax_mode = 1;
return 0LL;
case 8209:
if ( a2 == 42 )
{
v2 = 0;
first_dtmf = 0;
dtmf_code = 0;
if ( voice_modem_state == 5 )
(*(void (**)(void))(voice_modem + 392LL))();
return v2;
}
if ( a2 != 35 )
{
if ( first_dtmf && voice_modem_state == 5 )
{
v2 = 0;
first_dtmf = 0;
(*(void (**)(void))(voice_modem + 392LL))();
answer_mode = answer_mode & 3;
switch_to_data_fax_mode = 1;
return v2;
}
first_dtmf = 0;
v4 = strlen(&dtmf_code);
if ( v4 != 255 )
{
execute_dtmf_script = 1;
v2 = 0;
*(&dtmf_code + (int)v4 + 1) = 0;
*(&dtmf_code + (int)v4) = a2;
return v2;
}
goto LABEL_9;
}
first_dtmf = 0;
voice_stop_current_action();
if ( !dtmf_code )
goto LABEL_10;
execute_dtmf_script = 1;
v2 = 0;
break;
case 8210:
voice_stop_current_action();
return 0LL;
default:
return (unsigned int)-2;
}
return v2;
}
return (unsigned int)-2;
}
if ( a1 > 16387 )
{
v2 = -2;
if ( (unsigned int)(a1 - 16389) > 1 )
return v2;
}
else if ( a1 <= 16385 )
{
return (unsigned int)-2;
}
LABEL_9:
voice_stop_current_action();
LABEL_10:
hangup_requested = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, char a2)
{
unsigned int v2; // er12
size_t v4; // rax

if ( a1 <= 8210 )
{
if ( a1 > 0x2000 )
{
switch ( a1 )
{
case 8193:
case 8195:
case 8200:
goto LABEL_9;
case 8196:
voice_stop_current_action();
answer_mode = answer_mode & 1;
switch_to_data_fax_mode = 1;
return 0LL;
case 8198:
voice_stop_current_action();
answer_mode = answer_mode & 2;
switch_to_data_fax_mode = 1;
return 0LL;
case 8199:
return 0;
case 8206:
voice_stop_current_action();
answer_mode = answer_mode & 3;
switch_to_data_fax_mode = 1;
return 0LL;
case 8209:
if ( a2 == 42 )
{
v2 = 0;
first_dtmf = 0;
dtmf_code = 0;
if ( voice_modem_state == 5 )
(*(void (**)(void))(voice_modem + 392LL))();
return v2;
}
if ( a2 != 35 )
{
if ( first_dtmf && voice_modem_state == 5 )
{
v2 = 0;
first_dtmf = 0;
(*(void (**)(void))(voice_modem + 392LL))();
answer_mode = answer_mode & 3;
switch_to_data_fax_mode = 1;
return v2;
}
first_dtmf = 0;
v4 = strlen(&dtmf_code);
if ( v4 != 255 )
{
execute_dtmf_script = 1;
v2 = 0;
*(&dtmf_code + (int)v4 + 1) = 0;
*(&dtmf_code + (int)v4) = a2;
return v2;
}
goto LABEL_9;
}
first_dtmf = 0;
voice_stop_current_action();
if ( !dtmf_code )
goto LABEL_10;
execute_dtmf_script = 1;
v2 = 0;
break;
case 8210:
voice_stop_current_action();
return 0LL;
default:
return (unsigned int)-2;
}
return v2;
}
return (unsigned int)-2;
}
if ( a1 > 16387 )
{
v2 = -2;
if ( (unsigned int)(a1 - 16389) > 1 )
return v2;
}
else if ( a1 <= 16385 )
{
return (unsigned int)-2;
}
LABEL_9:
voice_stop_current_action();
LABEL_10:
hangup_requested = 1;
return 0LL;
}

original_code:
int vgetty_handle_event(int event, event_data data)
     {
     switch (event)
          {
          case (0x2007):
               return((0));
          case (0x2001):
          case (0x2003):
          case (0x2008):
          case (0x4002):
          case (0x4003):
          case (0x4005):
          case (0x4006):
               voice_stop_current_action();
               hangup_requested = (0==0);
               return((0));
          case (0x2004):
               voice_stop_current_action();
               answer_mode = answer_mode & (1);
               switch_to_data_fax_mode = (0==0);
               return((0));
          case (0x2006):
               voice_stop_current_action();
               answer_mode = answer_mode & (2);
               switch_to_data_fax_mode = (0==0);
               return((0));
          case (0x200e):
               voice_stop_current_action();
               answer_mode = answer_mode & ((1) | (2));
               switch_to_data_fax_mode = (0==0);
               return((0));
          case (0x2011):
               {
               int length;
               if (data.c == '*')
                    {
                    first_dtmf = (0==1);
                    dtmf_code[0] = 0x00;
                    if (voice_modem_state == (0x0005))
                         voice_modem->stop_playing();
                    return((0));
                    };
               if (data.c == '#')
                    {
                    first_dtmf = (0==1);
                    voice_stop_current_action();
                    if (strlen(dtmf_code) == 0)
                         hangup_requested = (0==0);
                    else
                         execute_dtmf_script = (0==0);
                    return((0));
                    };
               if ((first_dtmf) && (voice_modem_state == (0x0005)))
                    {
                    first_dtmf = (0==1);
                    voice_modem->stop_playing();
                    answer_mode = answer_mode & ((1) | (2));
                    switch_to_data_fax_mode = (0==0);
                    return((0));
                    };
               first_dtmf = (0==1);
               length = strlen(dtmf_code);
               if (length >= ((256) - 1)) {
                    voice_stop_current_action();
                    hangup_requested = (0==0);
                    return((0));
               }
               execute_dtmf_script = (0==0);
               dtmf_code[length + 1] = 0x00;
               dtmf_code[length] = data.c;
               return((0));
               };
          case (0x2012):
               voice_stop_current_action();
               return((0));
          };
     return((-2));
     }

canonical_original_code:
int vgetty_handle_event(int event, union event_data data)
     {
     switch (event)
          {
          case (0x2007):
               return((0));
          case (0x2001):
          case (0x2003):
          case (0x2008):
          case (0x4002):
          case (0x4003):
          case (0x4005):
          case (0x4006):
               voice_stop_current_action();
               hangup_requested = (0==0);
               return((0));
          case (0x2004):
               voice_stop_current_action();
               answer_mode = answer_mode & (1);
               switch_to_data_fax_mode = (0==0);
               return((0));
          case (0x2006):
               voice_stop_current_action();
               answer_mode = answer_mode & (2);
               switch_to_data_fax_mode = (0==0);
               return((0));
          case (0x200e):
               voice_stop_current_action();
               answer_mode = answer_mode & ((1) | (2));
               switch_to_data_fax_mode = (0==0);
               return((0));
          case (0x2011):
               {
               int length;
               if (data.c == '*')
                    {
                    first_dtmf = (0==1);
                    dtmf_code[0] = 0x00;
                    if (voice_modem_state == (0x0005))
                         voice_modem->stop_playing();
                    return((0));
                    };
               if (data.c == '#')
                    {
                    first_dtmf = (0==1);
                    voice_stop_current_action();
                    if (strlen(dtmf_code) == 0)
                         hangup_requested = (0==0);
                    else
                         execute_dtmf_script = (0==0);
                    return((0));
                    };
               if ((first_dtmf) && (voice_modem_state == (0x0005)))
                    {
                    first_dtmf = (0==1);
                    voice_modem->stop_playing();
                    answer_mode = answer_mode & ((1) | (2));
                    switch_to_data_fax_mode = (0==0);
                    return((0));
                    };
               first_dtmf = (0==1);
               length = strlen(dtmf_code);
               if (length >= ((256) - 1)) {
                    voice_stop_current_action();
                    hangup_requested = (0==0);
                    return((0));
               }
               execute_dtmf_script = (0==0);
               dtmf_code[length + 1] = 0x00;
               dtmf_code[length] = data.c;
               return((0));
               };
          case (0x2012):
               voice_stop_current_action();
               return((0));
          };
     return((-2));
     }

variable_types: event int

variable_types: union event_data { char c; int i; void *p; struct { int frequency; int length; } beep; }

variable_types: length int


decompiled_code:
__int64 __fastcall voice_analyze(char *s1, char *s, int a3)
{
__int64 result; // rax
char *v4; // rbp
int v5; // er13
char *v7; // rbx
__int64 v8; // rdx
const char *v9; // rbp
__int64 v10; // rbx
size_t v11; // rax

result = 8194LL;
if ( *s1 )
{
v4 = s;
if ( s )
{
v5 = 0;
if ( *s )
{
while ( 1 )
{
v7 = strchr(v4, 124);
v8 = (unsigned int)((_DWORD)v7 - (_DWORD)v4);
if ( !v7 )
v8 = (unsigned int)strlen(v4);
if ( a3 )
{
if ( !strncmp(s1, v4, (int)v8) )
return (unsigned int)(v5 + 4096);
}
else if ( (unsigned int)wildmat(s1, v4, v8) )
{
return (unsigned int)(v5 + 4096);
}
if ( v7 )
{
v4 = v7 + 1;
++v5;
if ( v7[1] )
continue;
}
break;
}
}
}
v9 = modem_answers;
v10 = 0LL;
if ( modem_answers )
{
while ( 1 )
{
v11 = strlen(v9);
if ( !strncmp(s1, v9, v11) )
break;
++v10;
v9 = (&modem_answers)[2 * v10];
if ( !v9 )
goto LABEL_17;
}
result = LODWORD((&modem_answers)[2 * (int)v10 + 1]);
}
else
{
LABEL_17:
result = 0x4000LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, char *s, int a3)
{
__int64 result; // rax
char *v4; // rbp
int v5; // er13
char *v7; // rbx
__int64 v8; // rdx
const char *v9; // rbp
__int64 v10; // rbx
size_t v11; // rax

result = 8194LL;
if ( *s1 )
{
v4 = s;
if ( s )
{
v5 = 0;
if ( *s )
{
while ( 1 )
{
v7 = strchr(v4, 124);
v8 = (unsigned int)((_DWORD)v7 - (_DWORD)v4);
if ( !v7 )
v8 = (unsigned int)strlen(v4);
if ( a3 )
{
if ( !strncmp(s1, v4, (int)v8) )
return (unsigned int)(v5 + 4096);
}
else if ( (unsigned int)wildmat(s1, v4, v8) )
{
return (unsigned int)(v5 + 4096);
}
if ( v7 )
{
v4 = v7 + 1;
++v5;
if ( v7[1] )
continue;
}
break;
}
}
}
v9 = modem_answers;
v10 = 0LL;
if ( modem_answers )
{
while ( 1 )
{
v11 = strlen(v9);
if ( !strncmp(s1, v9, v11) )
break;
++v10;
v9 = (&modem_answers)[2 * v10];
if ( !v9 )
goto LABEL_17;
}
result = LODWORD((&modem_answers)[2 * (int)v10 + 1]);
}
else
{
LABEL_17:
result = 0x4000LL;
}
}
return result;
}

original_code:
int voice_analyze(char *buffer, char *expected_answers, int exact_match)
     {
     int current;
     char *user_answer;
     char *new_user_answer;
     int user_answer_length;
     user_answer = expected_answers;
     if (strlen(buffer) == 0)
          return((0x2002));
     for(current = 0; ((user_answer != ((void *)0)) && (strlen(user_answer) > 0));
      current++)
          {
          new_user_answer = strstr(user_answer, "|");
          if (new_user_answer == ((void *)0))
               user_answer_length = strlen(user_answer);
          else
               user_answer_length = (int) (new_user_answer - user_answer);
          if (exact_match)
               {
               if (strncmp(buffer, user_answer, user_answer_length) == 0)
                    return(current + (0x1000));
               }
          else
               {
               if (wildmat(buffer, user_answer, user_answer_length) != 0)
                    return(current + (0x1000));
               }
          if (new_user_answer == ((void *)0))
               user_answer = ((void *)0);
          else
               user_answer = new_user_answer + 1;
          };
     for(current = 0; modem_answers[current].answer != ((void *)0); current++)
          if (strncmp(buffer, modem_answers[current].answer,
           strlen(modem_answers[current].answer)) == 0)
               return(modem_answers[current].value);
     return((0x4000));
     }

variable_types:
buffer
char *

variable_types: current int


decompiled_code:
const char *__fastcall wav_format_str(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "Microsoft Official Unknown";
break;
case 1:
result = "Microsoft PCM";
break;
case 2:
result = "Microsoft ADPCM";
break;
case 3:
case 4:
case 5:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 17:
case 18:
case 19:
case 20:
result = "Unknown";
break;
case 6:
result = "Microsoft A-law";
break;
case 7:
result = "Microsoft U-law";
break;
case 16:
result = "OKI ADPCM format.";
break;
case 21:
result = "Digistd format.";
break;
case 22:
result = "Digifix format.";
break;
default:
result = "IBM A-law";
if ( a1 != 258 )
{
if ( a1 == 259 )
{
result = "IBM ADPCM";
}
else
{
result = "Unknown";
if ( a1 == 257 )
result = "IBM U-law format.";
}
}
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "Microsoft Official Unknown";
break;
case 1:
result = "Microsoft PCM";
break;
case 2:
result = "Microsoft ADPCM";
break;
case 3:
case 4:
case 5:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 17:
case 18:
case 19:
case 20:
result = "Unknown";
break;
case 6:
result = "Microsoft A-law";
break;
case 7:
result = "Microsoft U-law";
break;
case 16:
result = "OKI ADPCM format.";
break;
case 21:
result = "Digistd format.";
break;
case 22:
result = "Digifix format.";
break;
default:
result = "IBM A-law";
if ( a1 != 258 )
{
if ( a1 == 259 )
{
result = "IBM ADPCM";
}
else
{
result = "Unknown";
if ( a1 == 257 )
result = "IBM U-law format.";
}
}
break;
}
return result;
}

original_code:
static char * wav_format_str(unsigned wFormatTag)
     {
     switch (wFormatTag)
          {
          case (0x0000):
               return "Microsoft Official Unknown";
          case (0x0001):
               return "Microsoft PCM";
          case (0x0002):
               return "Microsoft ADPCM";
          case (0x0006):
               return "Microsoft A-law";
          case (0x0007):
               return "Microsoft U-law";
          case (0x0010):
               return "OKI ADPCM format.";
          case (0x0015):
               return "Digistd format.";
          case (0x0016):
               return "Digifix format.";
          case (0x0101):
               return "IBM U-law format.";
          case (0x0102):
               return "IBM A-law";
          case (0x0103):
               return "IBM ADPCM";
          default:
               return "Unknown";
          }
     }

canonical_original_code:
static char *wav_format_str(unsigned int wFormatTag)
     {
     switch (wFormatTag)
          {
          case (0x0000):
               return "Microsoft Official Unknown";
          case (0x0001):
               return "Microsoft PCM";
          case (0x0002):
               return "Microsoft ADPCM";
          case (0x0006):
               return "Microsoft A-law";
          case (0x0007):
               return "Microsoft U-law";
          case (0x0010):
               return "OKI ADPCM format.";
          case (0x0015):
               return "Digistd format.";
          case (0x0016):
               return "Digifix format.";
          case (0x0101):
               return "IBM U-law format.";
          case (0x0102):
               return "IBM A-law";
          case (0x0103):
               return "IBM ADPCM";
          default:
               return "Unknown";
          }
     }

variable_types:
wFormatTag
unsigned int

return_type: char *


decompiled_code:
__int64 ZyXEL_Omni56K_voice_mode_on()
{
unsigned int v0; // er12
__int64 v1; // rax
__int64 v2; // rdx
__int64 v3; // rax
__int64 v4; // rdx
char v6[264]; // [rsp+0h] [rbp-108h] BYREF

if ( (unsigned int)IS_101_voice_mode_on() )
return (unsigned int)-1;
v0 = 0;
if ( (unsigned int)voice_command("AT+VIT=100", &unk_730) != 4096 )
lprintf(3LL, "voice init failed, continuing");
sprintf(v6, "AT+VSD=%d,%d", (unsigned int)((int)(31 * *((_QWORD *)&cvd + 58)) / 100), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v1 = *((_QWORD *)&cvd + 82);
if ( v1 == -1 )
{
*((_QWORD *)&cvd + 82) = 50LL;
v2 = 128LL;
}
else
{
v2 = (unsigned int)(144 * (int)v1 / 100 + 56);
}
sprintf(v6, "AT+VGT=%d", v2);
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v3 = *((_QWORD *)&cvd + 79);
if ( v3 == -1 )
{
*((_QWORD *)&cvd + 79) = 50LL;
v4 = 128LL;
}
else
{
v4 = (unsigned int)(144 * (int)v3 / 100 + 56);
}
sprintf(v6, "AT+VGR=%d", v4);
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting receive gain didn't work");
sprintf(v6, "AT+VRA=%d+VRN=%d", *((unsigned int *)&cvd + 398), *((unsigned int *)&cvd + 404));
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting ringback delay didn't work");
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // er12
__int64 v1; // rax
__int64 v2; // rdx
__int64 v3; // rax
__int64 v4; // rdx
char v6[264]; // [rsp+0h] [rbp-108h] BYREF

if ( (unsigned int)IS_101_voice_mode_on() )
return (unsigned int)-1;
v0 = 0;
if ( (unsigned int)voice_command("AT+VIT=100", &unk_730) != 4096 )
lprintf(3LL, "voice init failed, continuing");
sprintf(v6, "AT+VSD=%d,%d", (unsigned int)((int)(31 * *((_QWORD *)&cvd + 58)) / 100), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v1 = *((_QWORD *)&cvd + 82);
if ( v1 == -1 )
{
*((_QWORD *)&cvd + 82) = 50LL;
v2 = 128LL;
}
else
{
v2 = (unsigned int)(144 * (int)v1 / 100 + 56);
}
sprintf(v6, "AT+VGT=%d", v2);
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v3 = *((_QWORD *)&cvd + 79);
if ( v3 == -1 )
{
*((_QWORD *)&cvd + 79) = 50LL;
v4 = 128LL;
}
else
{
v4 = (unsigned int)(144 * (int)v3 / 100 + 56);
}
sprintf(v6, "AT+VGR=%d", v4);
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting receive gain didn't work");
sprintf(v6, "AT+VRA=%d+VRN=%d", *((unsigned int *)&cvd + 398), *((unsigned int *)&cvd + 404));
if ( (unsigned int)voice_command(v6, &unk_730) != 4096 )
lprintf(3LL, "setting ringback delay didn't work");
return v0;
}

original_code:
static int ZyXEL_Omni56K_voice_mode_on (void)
     {
     char buffer[(256)];
     if (IS_101_voice_mode_on())
          return((-1));
     if (voice_command("AT+VIT=100", "OK") != (0x1000))
          lprintf(3, "voice init failed, continuing");
     sprintf(buffer, "AT+VSD=%d,%d", (int)cvd.rec_silence_threshold.d.i *
      31 / 100, (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting recording preferences didn't work");
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = 50;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 144 / 100 + 56);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting transmit gain didn't work");
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = 50;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 144 / 100 + 56);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting receive gain didn't work");
     sprintf(buffer, "AT+VRA=%d+VRN=%d",
      (int)cvd.ringback_goes_away.d.i, (int)cvd.ringback_never_came.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3,"setting ringback delay didn't work");
     return((0));
     }

canonical_original_code:
static int ZyXEL_Omni56K_voice_mode_on()
     {
     char buffer[-1];
     if (IS_101_voice_mode_on())
          return((-1));
     if (voice_command("AT+VIT=100", "OK") != (0x1000))
          lprintf(3, "voice init failed, continuing");
     sprintf(buffer, "AT+VSD=%d,%d", (int)cvd.rec_silence_threshold.d.i *
      31 / 100, (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting recording preferences didn't work");
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = 50;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 144 / 100 + 56);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting transmit gain didn't work");
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = 50;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 144 / 100 + 56);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting receive gain didn't work");
     sprintf(buffer, "AT+VRA=%d+VRN=%d",
      (int)cvd.ringback_goes_away.d.i, (int)cvd.ringback_never_came.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3,"setting ringback delay didn't work");
     return((0));
     }


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

reset_watchdog();
switch ( a1 )
{
case 2u:
voice_command("AT+VLS=2", "VCON");
result = 0LL;
break;
case 7u:
voice_command("AT+VLS=1", "VCON");
result = 0LL;
break;
case 1u:
voice_command("AT+VLS=0", &unk_730);
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 func1(unsigned int a1)
{
__int64 result; // rax

reset_watchdog();
switch ( a1 )
{
case 2u:
voice_command("AT+VLS=2", "VCON");
result = 0LL;
break;
case 7u:
voice_command("AT+VLS=1", "VCON");
result = 0LL;
break;
case 1u:
voice_command("AT+VLS=0", &unk_730);
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 ZyXEL_Omni56K_set_device (int device)
     {
     reset_watchdog();
     switch (device)
          {
          case (0x0001):
               voice_command("AT+VLS=0", "OK");
               return((0));
          case (0x0007):
               voice_command("AT+VLS=1", "VCON");
               return((0));
          case (0x0002):
               voice_command("AT+VLS=2", "VCON");
               return((0));
          };
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }

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

variable_types: device int


decompiled_code:
__int64 __fastcall ZyXEL_Omni56K_set_compression(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 v5; // rcx

reset_watchdog();
v4 = *a2;
if ( *a2 )
{
if ( v4 != 9600 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 9600LL;
}
v5 = *a1;
if ( !*a1 )
{
*a1 = 4LL;
goto LABEL_5;
}
if ( v5 == 4 )
{
LABEL_5:
*a3 = 4;
return (unsigned int)-((unsigned int)voice_command("AT+VSM=4,9600", &unk_730) != 4096);
}
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v5);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 v5; // rcx

reset_watchdog();
v4 = *a2;
if ( *a2 )
{
if ( v4 != 9600 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 9600LL;
}
v5 = *a1;
if ( !*a1 )
{
*a1 = 4LL;
goto LABEL_5;
}
if ( v5 == 4 )
{
LABEL_5:
*a3 = 4;
return (unsigned int)-((unsigned int)voice_command("AT+VSM=4,9600", &unk_730) != 4096);
}
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v5);
return 0xFFFFFFFFLL;
}

original_code:
static int ZyXEL_Omni56K_set_compression (p_int *compression, p_int *speed, int *bits)
     {
     reset_watchdog();
     if (*speed == 0)
          *speed = 9600;
     if (*speed != 9600)
          {
          lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name,
           (int)*speed);
          return((-1));
          };
     if (*compression == 0)
          *compression = 4;
     if (*compression != 4)
          {
          lprintf(3, "%s: Illegal voice compression method (%d)",
           voice_modem->name, (int)*compression);
          return((-1));
          };
     *bits = 4;
     if (voice_command("AT+VSM=4,9600", "OK") != (0x1000))
          return((-1));
     return((0));
     }

canonical_original_code:
static int ZyXEL_Omni56K_set_compression(long *compression, long *speed, int *bits)
     {
     reset_watchdog();
     if (*speed == 0)
          *speed = 9600;
     if (*speed != 9600)
          {
          lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name,
           (int)*speed);
          return((-1));
          };
     if (*compression == 0)
          *compression = 4;
     if (*compression != 4)
          {
          lprintf(3, "%s: Illegal voice compression method (%d)",
           voice_modem->name, (int)*compression);
          return((-1));
          };
     *bits = 4;
     if (voice_command("AT+VSM=4,9600", "OK") != (0x1000))
          return((-1));
     return((0));
     }

variable_types:
compression
long *


decompiled_code:
__int64 ZyXEL_Omni56K_init()
{
reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing ZyXEL Omni 56K voice modem");
if ( (unsigned int)voice_command("ATS40.3=1S40.4=1S40.5=1S40.6=1", &unk_730) != 4096 )
lprintf(3LL, "couldn't initialize distinctive RING");
voice_modem_state = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing ZyXEL Omni 56K voice modem");
if ( (unsigned int)voice_command("ATS40.3=1S40.4=1S40.5=1S40.6=1", &unk_730) != 4096 )
lprintf(3LL, "couldn't initialize distinctive RING");
voice_modem_state = 1;
return 0LL;
}

original_code:
static int ZyXEL_Omni56K_init (void)
     {
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing ZyXEL Omni 56K voice modem");
     if (voice_command("ATS40.3=1S40.4=1S40.5=1S40.6=1", "OK") !=
      (0x1000))
          lprintf(3, "couldn't initialize distinctive RING");
     voice_modem_state = (0x0001);
     return((0));
     }

canonical_original_code:
static int ZyXEL_Omni56K_init()
     {
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing ZyXEL Omni 56K voice modem");
     if (voice_command("ATS40.3=1S40.4=1S40.5=1S40.6=1", "OK") !=
      (0x1000))
          lprintf(3, "couldn't initialize distinctive RING");
     voice_modem_state = (0x0001);
     return((0));
     }


decompiled_code:
__int64 __fastcall ZyXEL_Omni56K_answer_phone(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // er12
int v5; // ebp
unsigned __int8 v6; // bl
const unsigned __int16 **v7; // rax
char *v8; // rdx
const unsigned __int16 **v9; // rsi
__int64 v10; // rax
__m128i v11; // [rsp+0h] [rbp-138h] BYREF
__int16 v12; // [rsp+10h] [rbp-128h]
char s1[17]; // [rsp+20h] [rbp-118h] BYREF
unsigned __int8 v14; // [rsp+31h] [rbp-107h] BYREF

v3 = 8195;
v12 = 32;
v11 = _mm_load_si128((const __m128i *)&LC28);
if ( (unsigned int)IS_101_answer_phone(a1, a2, a3) == 8202 )
{
v3 = 8202;
if ( !strcmp(CallerId, "none") && !(unsigned int)voice_command("AT*T", &unk_7DE) && !(unsigned int)voice_read(s1) )
{
v5 = strncmp(s1, v11.m128i_i8, 0x11uLL);
if ( v5 )
{
voice_flush(3LL);
}
else
{
v6 = v14;
if ( v14 )
{
v7 = _ctype_b_loc();
v8 = (char *)&v14;
v9 = v7;
do
{
if ( ((*v9)[v6] & 0x4000) != 0 )
{
v10 = v5++;
*((_BYTE *)&number + v10) = v6;
}
v6 = *++v8;
}
while ( v5 <= 14 && v6 );
}
*((_BYTE *)&number + v5) = 0;
lprintf(5LL, "Got caller ID: \"%s\"", (const char *)&number);
if ( (unsigned int)voice_command("AT&I0", &unk_7DE) )
voice_flush(3LL);
if ( (_BYTE)number && number != 63 )
{
CallerId = &number;
setup_environment();
}
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // er12
int v5; // ebp
unsigned __int8 v6; // bl
const unsigned __int16 **v7; // rax
char *v8; // rdx
const unsigned __int16 **v9; // rsi
__int64 v10; // rax
__m128i v11; // [rsp+0h] [rbp-138h] BYREF
__int16 v12; // [rsp+10h] [rbp-128h]
char s1[17]; // [rsp+20h] [rbp-118h] BYREF
unsigned __int8 v14; // [rsp+31h] [rbp-107h] BYREF

v3 = 8195;
v12 = 32;
v11 = _mm_load_si128((const __m128i *)&LC28);
if ( (unsigned int)IS_101_answer_phone(a1, a2, a3) == 8202 )
{
v3 = 8202;
if ( !strcmp(CallerId, "none") && !(unsigned int)voice_command("AT*T", &unk_7DE) && !(unsigned int)voice_read(s1) )
{
v5 = strncmp(s1, v11.m128i_i8, 0x11uLL);
if ( v5 )
{
voice_flush(3LL);
}
else
{
v6 = v14;
if ( v14 )
{
v7 = _ctype_b_loc();
v8 = (char *)&v14;
v9 = v7;
do
{
if ( ((*v9)[v6] & 0x4000) != 0 )
{
v10 = v5++;
*((_BYTE *)&number + v10) = v6;
}
v6 = *++v8;
}
while ( v5 <= 14 && v6 );
}
*((_BYTE *)&number + v5) = 0;
lprintf(5LL, "Got caller ID: \"%s\"", (const char *)&number);
if ( (unsigned int)voice_command("AT&I0", &unk_7DE) )
voice_flush(3LL);
if ( (_BYTE)number && number != 63 )
{
CallerId = &number;
setup_environment();
}
}
}
}
return v3;
}

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


decompiled_code:
__int64 __fastcall sendfax_parse_args(int argc, char **argv)
{
char *v4; // rax
int v5; // eax
int v6; // eax
char *v7; // rax
char *v8; // rax
char *v9; // rax
int v10; // eax
int v11; // eax
char *v12; // rax
char *v13; // rax
char *v14; // rax
char *v15; // rax

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':
v15 = optarg;
*((_DWORD *)&c + 167) = 2;
*(&c + 82) = v15;
continue;
case 'C':
v14 = optarg;
*((_DWORD *)&c + 29) = 2;
*(&c + 13) = v14;
continue;
case 'D':
v13 = optarg;
*((_DWORD *)&c + 95) = 2;
*(&c + 46) = v13;
continue;
case 'I':
v12 = optarg;
*((_DWORD *)&c + 101) = 2;
*(&c + 49) = v12;
continue;
case 'M':
v11 = atoi(optarg);
*((_DWORD *)&c + 125) = 2;
*(&c + 61) = (char *)v11;
continue;
case 'R':
v10 = atoi(optarg);
*((_DWORD *)&c + 59) = 2;
*(&c + 28) = (char *)v10;
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':
v9 = optarg;
*((_DWORD *)&c + 107) = 2;
*(&c + 52) = v9;
continue;
case 'h':
v8 = optarg;
*((_DWORD *)&c + 149) = 2;
*(&c + 73) = v8;
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':
v7 = optarg;
*((_DWORD *)&c + 17) = 2;
*(&c + 7) = v7;
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);
*((_DWORD *)&c + 131) = 2;
*(&c + 64) = (char *)v6;
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
char *v7; // rax
char *v8; // rax
char *v9; // rax
int v10; // eax
int v11; // eax
char *v12; // rax
char *v13; // rax
char *v14; // rax
char *v15; // rax

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':
v15 = optarg;
*((_DWORD *)&c + 167) = 2;
*(&c + 82) = v15;
continue;
case 'C':
v14 = optarg;
*((_DWORD *)&c + 29) = 2;
*(&c + 13) = v14;
continue;
case 'D':
v13 = optarg;
*((_DWORD *)&c + 95) = 2;
*(&c + 46) = v13;
continue;
case 'I':
v12 = optarg;
*((_DWORD *)&c + 101) = 2;
*(&c + 49) = v12;
continue;
case 'M':
v11 = atoi(optarg);
*((_DWORD *)&c + 125) = 2;
*(&c + 61) = (char *)v11;
continue;
case 'R':
v10 = atoi(optarg);
*((_DWORD *)&c + 59) = 2;
*(&c + 28) = (char *)v10;
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':
v9 = optarg;
*((_DWORD *)&c + 107) = 2;
*(&c + 52) = v9;
continue;
case 'h':
v8 = optarg;
*((_DWORD *)&c + 149) = 2;
*(&c + 73) = v8;
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':
v7 = optarg;
*((_DWORD *)&c + 17) = 2;
*(&c + 7) = v7;
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);
*((_DWORD *)&c + 131) = 2;
*(&c + 64) = (char *)v6;
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]


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);
}
log_set_llevel(*((unsigned int *)&c + 128));
result = *((unsigned int *)&c + 35);
if ( (_DWORD)result )
{
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);
}
log_set_llevel(*((unsigned int *)&c + 128));
result = *((unsigned int *)&c + 35);
if ( (_DWORD)result )
{
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 *

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 *result; // rax

result = calloc(0x290uLL, 1uLL);
if ( result )
result[316] = 40;
return result;
}

canonical_decompiled_code:
_WORD *func0()
{
_WORD *result; // rax

result = calloc(0x290uLL, 1uLL);
if ( result )
result[316] = 40;
return result;
}

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()
{
__int64 v0; // rdi
__int64 result; // rax
int *v2; // rax
char *v3; // rax
int *v4; // rax
char *v5; // rax
__uid_t uid; // [rsp+8h] [rbp-10h] BYREF
__gid_t gid[3]; // [rsp+Ch] [rbp-Ch] BYREF

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

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

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

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
__gid_t v1; // eax
__int64 result; // rax
int *v3; // rax
char *v4; // r12
__uid_t v5; // eax
int *v6; // rax
char *v7; // rbx
__gid_t v8; // 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);
result = 0LL;
}
else
{
v1 = getgid();
if ( setegid(v1) )
{
v6 = _errno_location();
v7 = strerror(*v6);
v8 = getgid();
lprintf(3LL, "%s: cannot switch back to effective GID %d: %s", program_name, v8, v7);
result = 0LL;
}
else
{
if ( cvd[145] != -1LL )
umask(old_umask);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__uid_t v0; // eax
__gid_t v1; // eax
__int64 result; // rax
int *v3; // rax
char *v4; // r12
__uid_t v5; // eax
int *v6; // rax
char *v7; // rbx
__gid_t v8; // 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);
result = 0LL;
}
else
{
v1 = getgid();
if ( setegid(v1) )
{
v6 = _errno_location();
v7 = strerror(*v6);
v8 = getgid();
lprintf(3LL, "%s: cannot switch back to effective GID %d: %s", program_name, v8, v7);
result = 0LL;
}
else
{
if ( cvd[145] != -1LL )
umask(old_umask);
result = 1LL;
}
}
return result;
}

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)
{
char *v3; // rdi
int v4; // eax
int v5; // eax
int v6; // eax
char *v7; // rax
int v8; // eax
char *v9; // rdi
char *v10; // rax
char *v11; // rax
char *v12; // rax
char *v13; // rdi
int v14; // eax
char *v15; // rax
char *v16; // rax

*(&c + 43) = (char *)&def_init_chat_seq;
*(&c + 46) = (char *)&def_force_init_chat_seq;
*(&c + 76) = (char *)&def_answer_chat_seq;
v3 = *argv;
*((_DWORD *)&c + 89) = 1;
*((_DWORD *)&c + 95) = 1;
*((_DWORD *)&c + 155) = 1;
if ( !strcmp((const char *)get_basename(v3), "getty") )
{
*(&c + 10) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 23) = 2;
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
}
while ( 1 )
{
v4 = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV");
if ( v4 == -1 )
return 0LL;
switch ( v4 )
{
case '?':
exit_usage(2);
case 'C':
v16 = optarg;
*((_DWORD *)&c + 77) = 2;
*(&c + 37) = v16;
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':
v15 = optarg;
*((_DWORD *)&c + 233) = 2;
*(&c + 115) = v15;
break;
case 'R':
v13 = optarg;
*(&c + 85) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 173) = 2;
v14 = atoi(v13);
*((_DWORD *)&c + 179) = 2;
*(&c + 88) = (char *)v14;
break;
case 'S':
v12 = optarg;
*((_DWORD *)&c + 251) = 2;
*(&c + 124) = v12;
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':
v11 = optarg;
*((_DWORD *)&c + 191) = 2;
*(&c + 94) = v11;
break;
case 'k':
v10 = (char *)atol(optarg);
*((_DWORD *)&c + 257) = 2;
*(&c + 127) = v10;
break;
case 'm':
v9 = optarg;
*((_DWORD *)&c + 89) = 2;
*(&c + 43) = (char *)conf_get_chat(v9);
break;
case 'n':
v8 = atoi(optarg);
*((_DWORD *)&c + 131) = 2;
*(&c + 64) = (char *)v8;
break;
case 'p':
v7 = optarg;
*((_DWORD *)&c + 203) = 2;
*(&c + 100) = v7;
break;
case 'r':
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
break;
case 's':
v6 = atoi(optarg);
*((_DWORD *)&c + 5) = 2;
*(&c + 1) = (char *)v6;
break;
case 'x':
v5 = atoi(optarg);
*((_DWORD *)&c + 293) = 2;
*(&c + 145) = (char *)v5;
log_set_llevel((unsigned int)v5);
break;
default:
continue;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func1(int argc, char **argv)
{
char *v3; // rdi
int v4; // eax
int v5; // eax
int v6; // eax
char *v7; // rax
int v8; // eax
char *v9; // rdi
char *v10; // rax
char *v11; // rax
char *v12; // rax
char *v13; // rdi
int v14; // eax
char *v15; // rax
char *v16; // rax

*(&c + 43) = (char *)&def_init_chat_seq;
*(&c + 46) = (char *)&def_force_init_chat_seq;
*(&c + 76) = (char *)&def_answer_chat_seq;
v3 = *argv;
*((_DWORD *)&c + 89) = 1;
*((_DWORD *)&c + 95) = 1;
*((_DWORD *)&c + 155) = 1;
if ( !strcmp((const char *)get_basename(v3), "getty") )
{
*(&c + 10) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 23) = 2;
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
}
while ( 1 )
{
v4 = getopt(argc, argv, "c:x:s:rp:n:R:i:DC:FS:k:m:I:baV");
if ( v4 == -1 )
return 0LL;
switch ( v4 )
{
case '?':
func0(2);
case 'C':
v16 = optarg;
*((_DWORD *)&c + 77) = 2;
*(&c + 37) = v16;
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':
v15 = optarg;
*((_DWORD *)&c + 233) = 2;
*(&c + 115) = v15;
break;
case 'R':
v13 = optarg;
*(&c + 85) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 173) = 2;
v14 = atoi(v13);
*((_DWORD *)&c + 179) = 2;
*(&c + 88) = (char *)v14;
break;
case 'S':
v12 = optarg;
*((_DWORD *)&c + 251) = 2;
*(&c + 124) = v12;
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':
v11 = optarg;
*((_DWORD *)&c + 191) = 2;
*(&c + 94) = v11;
break;
case 'k':
v10 = (char *)atol(optarg);
*((_DWORD *)&c + 257) = 2;
*(&c + 127) = v10;
break;
case 'm':
v9 = optarg;
*((_DWORD *)&c + 89) = 2;
*(&c + 43) = (char *)conf_get_chat(v9);
break;
case 'n':
v8 = atoi(optarg);
*((_DWORD *)&c + 131) = 2;
*(&c + 64) = (char *)v8;
break;
case 'p':
v7 = optarg;
*((_DWORD *)&c + 203) = 2;
*(&c + 100) = v7;
break;
case 'r':
*(&c + 7) = (_BYTE *)&loc_1;
*((_DWORD *)&c + 17) = 2;
break;
case 's':
v6 = atoi(optarg);
*((_DWORD *)&c + 5) = 2;
*(&c + 1) = (char *)v6;
break;
case 'x':
v5 = atoi(optarg);
*((_DWORD *)&c + 293) = 2;
*(&c + 145) = (char *)v5;
log_set_llevel((unsigned int)v5);
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]