decompiled_code:
char *__fastcall mdm_get_idstring(char *s2, int a2, int a3)
{
int v4; // er8
char *result; // rax
int v6; // ebx
char *v7; // rax
char *v8; // rbp

v4 = mdm_send(s2, a3);
result = "<ERROR>";
if ( v4 != -1 )
{
v6 = 0;
signal(14, (__sighandler_t)fwf_sig_alarm);
alarm(0xAu);
rbuf_0 = 0;
LABEL_3:
while ( 1 )
{
v7 = mdm_get_line(a3);
v8 = v7;
if ( !v7 )
break;
while ( strcmp(v7, s2) )
{
if ( *v8 == 79 && v8[1] == 75 && !v8[2] || !strcmp(v8, "ERROR") )
{
alarm(0);
signal(14, 0LL);
return &rbuf_0;
}
lprintf(5LL, "mdm_gis: string %d: '%s'", (unsigned int)++v6, v8);
if ( v6 != a2 )
goto LABEL_3;
strncpy(&rbuf_0, v8, 0x77uLL);
byte_4F7 = 0;
v7 = mdm_get_line(a3);
v8 = v7;
if ( !v7 )
goto LABEL_11;
}
}
LABEL_11:
alarm(0);
signal(14, 0LL);
result = "<ERROR>";
}
return result;
}

canonical_decompiled_code:
char *__fastcall func5(char *s2, int a2, int a3)
{
int v4; // er8
char *result; // rax
int v6; // ebx
char *v7; // rax
char *v8; // rbp

v4 = func1(s2, a3);
result = "<ERROR>";
if ( v4 != -1 )
{
v6 = 0;
signal(14, (__sighandler_t)fwf_sig_alarm);
alarm(0xAu);
rbuf_0 = 0;
LABEL_3:
while ( 1 )
{
v7 = func3(a3);
v8 = v7;
if ( !v7 )
break;
while ( strcmp(v7, s2) )
{
if ( *v8 == 79 && v8[1] == 75 && !v8[2] || !strcmp(v8, "ERROR") )
{
alarm(0);
signal(14, 0LL);
return &rbuf_0;
}
lprintf(5LL, "mdm_gis: string %d: '%s'", (unsigned int)++v6, v8);
if ( v6 != a2 )
goto LABEL_3;
strncpy(&rbuf_0, v8, 0x77uLL);
byte_4F7 = 0;
v7 = func3(a3);
v8 = v7;
if ( !v7 )
goto LABEL_11;
}
}
LABEL_11:
alarm(0);
signal(14, 0LL);
result = "<ERROR>";
}
return result;
}

original_code:
char * mdm_get_idstring (char * send,int n,int fd)
{
    char * l; int i;
    static char rbuf[120];
    if ( mdm_send( send, fd ) == -1 ) return "<ERROR>";
    signal( 14, fwf_sig_alarm ); alarm(10); fwf_timeout = (1==0);
    i=0;
    rbuf[0] = '\0';
    while(1)
    {
 l = mdm_get_line( fd );
 if ( l == ((void *)0) ) break;
 if ( strcmp( l, send ) == 0 ) continue;
        if ( strcmp( l, "OK" ) == 0 ||
      strcmp( l, "ERROR" ) == 0 ) break;
        i++;
 lprintf( 5, "mdm_gis: string %d: '%s'", i, l );
 if ( i==-1 || i==n )
     { strncpy( rbuf, l, sizeof(rbuf)-1); rbuf[sizeof(rbuf)-1]='\0'; }
    }
    alarm(0); signal( 14, ((__sighandler_t) 0) );
    if ( l == ((void *)0) ) return "<ERROR>";
    return rbuf;
}

canonical_original_code:
char *mdm_get_idstring(char *send, int n, int fd)
{
    char *l; int i;
    static char rbuf[120];
    if ( mdm_send( send, fd ) == -1 ) return "<ERROR>";
    signal( 14, fwf_sig_alarm ); alarm(10); fwf_timeout = (1==0);
    i=0;
    rbuf[0] = '\0';
    while(1)
    {
 l = mdm_get_line( fd );
 if ( l == ((void *)0) ) break;
 if ( strcmp( l, send ) == 0 ) continue;
        if ( strcmp( l, "OK" ) == 0 ||
      strcmp( l, "ERROR" ) == 0 ) break;
        i++;
 lprintf( 5, "mdm_gis: string %d: '%s'", i, l );
 if ( i==-1 || i==n )
     { strncpy( rbuf, l, sizeof(rbuf)-1); rbuf[sizeof(rbuf)-1]='\0'; }
    }
    alarm(0); signal( 14, ((void (*)(int)) 0) );
    if ( l == ((void *)0) ) return "<ERROR>";
    return rbuf;
}

variable_types: n int

variable_types: i int

variable_types:
rbuf
char [120]


repo: Distrotech/mgetty

decompiled_code:
__int64 __fastcall mdm_read_byte(int a1, char *a2)
{
__int64 v2; // rax
int v3; // ecx
char v4; // al
__int64 result; // rax
int v6; // eax
int v7; // ebp

v2 = frb_rp_3;
v3 = frb_rp_3 + 1;
if ( frb_rp_3 < frb_len_2 || (v6 = read(a1, frb_buf_1, 0x200uLL), v3 = 1, v7 = v6, frb_len_2 = v6, v2 = 0LL, v7 > 0) )
{
v4 = frb_buf_1[v2];
frb_rp_3 = v3;
*a2 = v4;
result = 1LL;
}
else
{
if ( !v7 )
*_errno_location() = 0;
lprintf(1LL, "mdm_read_byte: read returned %d", (unsigned int)v7);
result = (unsigned int)frb_len_2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, char *a2)
{
__int64 v2; // rax
int v3; // ecx
char v4; // al
__int64 result; // rax
int v6; // eax
int v7; // ebp

v2 = frb_rp_3;
v3 = frb_rp_3 + 1;
if ( frb_rp_3 < frb_len_2 || (v6 = read(a1, frb_buf_1, 0x200uLL), v3 = 1, v7 = v6, frb_len_2 = v6, v2 = 0LL, v7 > 0) )
{
v4 = frb_buf_1[v2];
frb_rp_3 = v3;
*a2 = v4;
result = 1LL;
}
else
{
if ( !v7 )
*_errno_location() = 0;
lprintf(1LL, "mdm_read_byte: read returned %d", (unsigned int)v7);
result = (unsigned int)frb_len_2;
}
return result;
}

original_code:
int mdm_read_byte (int fd,char * c)
{
static char frb_buf[512];
static int frb_rp = 0;
static int frb_len = 0;
    if ( frb_rp >= frb_len )
    {
 frb_len = read( fd, frb_buf, sizeof( frb_buf ) );
 if ( frb_len <= 0 )
 {
     if ( frb_len == 0 ) (*__errno_location ()) = 0;
     lprintf( 1, "mdm_read_byte: read returned %d", frb_len );
     return frb_len;
 }
 frb_rp = 0;
    }
    *c = frb_buf[ frb_rp++ ];
    return 1;
}

canonical_original_code:
int mdm_read_byte(int fd, char *c)
{
static char frb_buf[512];
static int frb_rp = 0;
static int frb_len = 0;
    if ( frb_rp >= frb_len )
    {
 frb_len = read( fd, frb_buf, sizeof( frb_buf ) );
 if ( frb_len <= 0 )
 {
     if ( frb_len == 0 ) (*__errno_location ()) = 0;
     lprintf( 1, "mdm_read_byte: read returned %d", frb_len );
     return frb_len;
 }
 frb_rp = 0;
    }
    *c = frb_buf[ frb_rp++ ];
    return 1;
}

variable_types: fd int

variable_types:
c
char *

return_type: int


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

reset_watchdog();
if ( current_device_0 == a1 || current_device_0 < 0 )
{
current_device_0 = a1;
}
else
{
voice_command("ATH0", "VCON|OK");
voice_command("AT#CLS=8", "OK");
current_device_0 = 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_0 == a1 || current_device_0 < 0 )
{
current_device_0 = a1;
}
else
{
voice_command("ATH0", "VCON|OK");
voice_command("AT#CLS=8", "OK");
current_device_0 = 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 Rockwell_set_device (int device)
     {
     static int current_device = -1;
     reset_watchdog();
     if ((current_device != device) && (current_device >= 0)) {
          voice_command("ATH0","VCON|OK");
   voice_command("AT#CLS=8", "OK");
     }
     current_device=device;
     switch (device)
          {
          case (0x0001):
               voice_command("AT#VLS=0", "OK");
               return((0));
          case (0x0002):
               voice_command("AT#VLS=4", "OK");
               return((0));
          case (0x0003):
               voice_command("AT#VLS=3", "VCON");
               return((0));
          case (0x0006):
               voice_command("AT#VLS=2", "VCON");
               return((0));
          case (0x0007):
               voice_command("AT#VLS=1","VCON");
               return((0));
          }
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }

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

variable_types: device int


decompiled_code:
__int64 __fastcall Rockwell_set_compression(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 v5; // rdx
const char *v6; // rdi

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 v5; // rdx
const char *v6; // rdi

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

original_code:
static int Rockwell_set_compression (p_int *compression, p_int *speed, int *bits)
     {
     reset_watchdog();
     if (*compression == 0)
          *compression = 2;
     if (*speed == 0)
          *speed = 7200;
     if (*speed != 7200)
          {
          lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name,
           *speed);
          return((-1));
          };
     switch (*compression)
          {
          case 2:
               *bits=2;
               if (voice_command("AT#VBS=2", "OK") != (0x1000))
                    return((-1));
               return ((0));
          case 4:
               *bits=4;
               if (voice_command("AT#VBS=4", "OK") != (0x1000))
                    return((-1));
               return ((0));
          case 8:
               *bits=8;
               if (voice_command("AT#VBS=8", "OK") != (0x1000))
                    return((-1));
               return ((0));
          case 16:
               *bits=16;
               if (voice_command("AT#VBS=16", "OK") != (0x1000))
                    return((-1));
               return ((0));
          }
     lprintf(3,
      "ROCKWELL handle event: Illegal voice compression method (%d)",
      *compression);
     return((-1));
     }

canonical_original_code:
static int Rockwell_set_compression(long *compression, long *speed, int *bits)
     {
     reset_watchdog();
     if (*compression == 0)
          *compression = 2;
     if (*speed == 0)
          *speed = 7200;
     if (*speed != 7200)
          {
          lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name,
           *speed);
          return((-1));
          };
     switch (*compression)
          {
          case 2:
               *bits=2;
               if (voice_command("AT#VBS=2", "OK") != (0x1000))
                    return((-1));
               return ((0));
          case 4:
               *bits=4;
               if (voice_command("AT#VBS=4", "OK") != (0x1000))
                    return((-1));
               return ((0));
          case 8:
               *bits=8;
               if (voice_command("AT#VBS=8", "OK") != (0x1000))
                    return((-1));
               return ((0));
          case 16:
               *bits=16;
               if (voice_command("AT#VBS=16", "OK") != (0x1000))
                    return((-1));
               return ((0));
          }
     lprintf(3,
      "ROCKWELL handle event: Illegal voice compression method (%d)",
      *compression);
     return((-1));
     }

variable_types:
compression
long *

variable_types:
speed
long *

variable_types:
bits
int *


decompiled_code:
__int64 Rockwell_init()
{
__int64 v0; // rdx
__int64 v1; // rcx
unsigned int v2; // eax
__int64 v3; // rcx
unsigned int v4; // eax
unsigned __int64 v5; // rax
__int64 result; // rax
_BYTE v7[64]; // [rsp+0h] [rbp-148h] BYREF
char s[264]; // [rsp+40h] [rbp-108h] BYREF

reset_watchdog();
lprintf(4LL, "initializing ROCKWELL 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");
v1 = *((_QWORD *)&cvd + 82);
if ( v1 )
{
if ( v1 == -1 )
{
*((_QWORD *)&cvd + 82) = 50LL;
v2 = 0x8000;
}
else
{
v2 = 0x10000 / (100 / (int)v1);
}
sprintf(s, "AT#TL=%X", v2);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set transmit gain");
}
v3 = *((_QWORD *)&cvd + 79);
if ( v3 )
{
if ( v3 == -1 )
{
*((_QWORD *)&cvd + 79) = 50LL;
v4 = 0x8000;
}
else
{
v4 = 0x10000 / (100 / (int)v3);
}
sprintf(s, "AT#RG=%X", v4);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set record gain");
}
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");
v5 = *((_QWORD *)&cvd + 58);
if ( v5 > 0x64 )
{
lprintf(3LL, "Invalid threshold value.");
result = 0xFFFFFFFFLL;
}
else
{
sprintf(s, "AT#VSS=%1u", (unsigned int)(3 * v5) / 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, v7);
tio_set_flow_control(voice_fd, v7, 1LL);
tio_set(voice_fd, v7);
}
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
__int64 v1; // rcx
unsigned int v2; // eax
__int64 v3; // rcx
unsigned int v4; // eax
unsigned __int64 v5; // rax
__int64 result; // rax
_BYTE v7[64]; // [rsp+0h] [rbp-148h] BYREF
char s[264]; // [rsp+40h] [rbp-108h] BYREF

reset_watchdog();
lprintf(4LL, "initializing ROCKWELL 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");
v1 = *((_QWORD *)&cvd + 82);
if ( v1 )
{
if ( v1 == -1 )
{
*((_QWORD *)&cvd + 82) = 50LL;
v2 = 0x8000;
}
else
{
v2 = 0x10000 / (100 / (int)v1);
}
sprintf(s, "AT#TL=%X", v2);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set transmit gain");
}
v3 = *((_QWORD *)&cvd + 79);
if ( v3 )
{
if ( v3 == -1 )
{
*((_QWORD *)&cvd + 79) = 50LL;
v4 = 0x8000;
}
else
{
v4 = 0x10000 / (100 / (int)v3);
}
sprintf(s, "AT#RG=%X", v4);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set record gain");
}
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");
v5 = *((_QWORD *)&cvd + 58);
if ( v5 > 0x64 )
{
lprintf(3LL, "Invalid threshold value.");
result = 0xFFFFFFFFLL;
}
else
{
sprintf(s, "AT#VSS=%1u", (unsigned int)(3 * v5) / 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, v7);
tio_set_flow_control(voice_fd, v7, 1LL);
tio_set(voice_fd, v7);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
result = 0LL;
}
return result;
}

original_code:
static int Rockwell_init(void)
     {
     char buffer[(256)];
     reset_watchdog();
     lprintf(4, "initializing ROCKWELL 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 (cvd.transmit_gain.d.i) {
 if (cvd.transmit_gain.d.i == -1) {
    cvd.transmit_gain.d.i = 50;
 }
        sprintf(buffer, "AT#TL=%X", (65536 / (100 / (int)cvd.transmit_gain.d.i)));
 if (voice_command(buffer, "OK") != (0x1000)) {
          lprintf(3, "can't set transmit gain");
        }
     }
     if (cvd.receive_gain.d.i) {
 if (cvd.receive_gain.d.i == -1) {
    cvd.receive_gain.d.i = 50;
 }
        sprintf(buffer, "AT#RG=%X", (65536 / (100 / (int)cvd.receive_gain.d.i)));
 if (voice_command(buffer, "OK") != (0x1000)) {
      lprintf(3, "can't set record gain");
        }
     }
     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 Rockwell_init()
     {
     char buffer[-1];
     reset_watchdog();
     lprintf(4, "initializing ROCKWELL 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 (cvd.transmit_gain.d.i) {
 if (cvd.transmit_gain.d.i == -1) {
    cvd.transmit_gain.d.i = 50;
 }
        sprintf(buffer, "AT#TL=%X", (65536 / (100 / (int)cvd.transmit_gain.d.i)));
 if (voice_command(buffer, "OK") != (0x1000)) {
          lprintf(3, "can't set transmit gain");
        }
     }
     if (cvd.receive_gain.d.i) {
 if (cvd.receive_gain.d.i == -1) {
    cvd.receive_gain.d.i = 50;
 }
        sprintf(buffer, "AT#RG=%X", (65536 / (100 / (int)cvd.receive_gain.d.i)));
 if (voice_command(buffer, "OK") != (0x1000)) {
      lprintf(3, "can't set record gain");
        }
     }
     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 Rockwell_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 Rockwell_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:
__int64 __fastcall Lucent_beep(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
unsigned int v3; // er13
int v4; // edi
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

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

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

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

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

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

variable_types: frequency int

variable_types: length int


decompiled_code:
__int64 __fastcall Lucent_set_device(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

reset_watchdog(a1, a2, a3);
switch ( (int)a1 )
{
case 1:
case 10:
voice_command("AT+VLS=0", &unk_76A);
result = 0LL;
break;
case 2:
voice_command("AT+VLS=1", &unk_76A);
result = 0LL;
break;
case 4:
voice_command("AT+VLS=6", &unk_76A);
result = 0LL;
break;
case 6:
voice_command("AT+VLS=4", &unk_76A);
result = 0LL;
break;
case 7:
voice_command("AT+VLS=2", &unk_76A);
result = 0LL;
break;
case 9:
voice_command("AT+VLS=5", &unk_76A);
result = 0LL;
break;
case 12:
voice_command("AT+VLS=7", &unk_76A);
result = 0LL;
break;
default:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, (unsigned int)a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

reset_watchdog(a1, a2, a3);
switch ( (int)a1 )
{
case 1:
case 10:
voice_command("AT+VLS=0", &unk_76A);
result = 0LL;
break;
case 2:
voice_command("AT+VLS=1", &unk_76A);
result = 0LL;
break;
case 4:
voice_command("AT+VLS=6", &unk_76A);
result = 0LL;
break;
case 6:
voice_command("AT+VLS=4", &unk_76A);
result = 0LL;
break;
case 7:
voice_command("AT+VLS=2", &unk_76A);
result = 0LL;
break;
case 9:
voice_command("AT+VLS=5", &unk_76A);
result = 0LL;
break;
case 12:
voice_command("AT+VLS=7", &unk_76A);
result = 0LL;
break;
default:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, (unsigned int)a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

canonical_original_code:
static int Lucent_set_device(int device)
     {
     reset_watchdog();
     switch (device)
          {
   case (0x000A):
          case (0x0001):
               voice_command("AT+VLS=0", "OK");
               return((0));
          case (0x0002):
               voice_command("AT+VLS=1", "OK");
               return((0));
   case (0x0007):
     voice_command("AT+VLS=2", "OK");
     return((0));
          case (0x0006):
               voice_command("AT+VLS=4", "OK");
               return((0));
          case (0x0004):
               voice_command("AT+VLS=6", "OK");
               return((0));
   case (0x0009):
     voice_command("AT+VLS=5", "OK");
     return((0));
   case (0x000C):
     voice_command("AT+VLS=7", "OK");
     return((0));
          };
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }


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

reset_watchdog(a1, a2, a3);
v4 = *a1;
if ( *a1 )
{
if ( *a2 )
{
LABEL_4:
switch ( v4 )
{
case 1LL:
v6 = *a2;
*a3 = 8;
if ( v6 != 8000 && v6 != 7200 && v6 != 11025 )
goto LABEL_23;
sprintf(v8, "AT+VSM=128,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
case 2LL:
v6 = *a2;
*a3 = 16;
if ( v6 != 8000 && v6 != 7200 && v6 != 11025 )
goto LABEL_23;
sprintf(v8, "AT+VSM=129,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
case 3LL:
v5 = *a2;
*a3 = 8;
if ( v5 != 8000 )
goto LABEL_24;
sprintf(v8, "AT+VSM=130,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
case 4LL:
v5 = *a2;
goto LABEL_12;
case 5LL:
v6 = *a2;
*a3 = 4;
if ( v6 == 7200 || v6 == 8000 || v6 == 11025 )
{
sprintf(v8, "AT+VSM=132,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
}
LABEL_23:
v5 = v6;
break;
default:
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
goto LABEL_24;
}
LABEL_3:
*a2 = 8000LL;
v4 = *a1;
goto LABEL_4;
}
*a1 = 4LL;
v5 = *a2;
if ( !*a2 )
goto LABEL_3;
LABEL_12:
*a3 = 8;
if ( v5 != 8000 )
{
LABEL_24:
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v5);
return 0xFFFFFFFFLL;
}
sprintf(v8, "AT+VSM=131,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
}

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

reset_watchdog(a1, a2, a3);
v4 = *a1;
if ( *a1 )
{
if ( *a2 )
{
LABEL_4:
switch ( v4 )
{
case 1LL:
v6 = *a2;
*a3 = 8;
if ( v6 != 8000 && v6 != 7200 && v6 != 11025 )
goto LABEL_23;
sprintf(v8, "AT+VSM=128,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
case 2LL:
v6 = *a2;
*a3 = 16;
if ( v6 != 8000 && v6 != 7200 && v6 != 11025 )
goto LABEL_23;
sprintf(v8, "AT+VSM=129,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
case 3LL:
v5 = *a2;
*a3 = 8;
if ( v5 != 8000 )
goto LABEL_24;
sprintf(v8, "AT+VSM=130,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
case 4LL:
v5 = *a2;
goto LABEL_12;
case 5LL:
v6 = *a2;
*a3 = 4;
if ( v6 == 7200 || v6 == 8000 || v6 == 11025 )
{
sprintf(v8, "AT+VSM=132,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
}
LABEL_23:
v5 = v6;
break;
default:
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
goto LABEL_24;
}
LABEL_3:
*a2 = 8000LL;
v4 = *a1;
goto LABEL_4;
}
*a1 = 4LL;
v5 = *a2;
if ( !*a2 )
goto LABEL_3;
LABEL_12:
*a3 = 8;
if ( v5 != 8000 )
{
LABEL_24:
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v5);
return 0xFFFFFFFFLL;
}
sprintf(v8, "AT+VSM=131,%d");
return (unsigned int)-((unsigned int)voice_command(v8, &unk_76A) != 4096);
}

original_code:
static int Lucent_set_compression (p_int *compression, p_int *speed, int *bits)
     {
     char buffer[(256)];
     reset_watchdog();
     if (*compression == 0)
       *compression = 4;
     if (*speed == 0)
       *speed = 8000;
     switch (*compression)
          {
          case 1:
               *bits = 8;
        if ( (*speed != 7200) && (*speed != 8000) && (*speed != 11025) )
   {
            lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
     return((-1));
   }
        sprintf(buffer, "AT+VSM=128,%d", (int)*speed);
               if (voice_command(buffer, "OK") != (0x1000))
                    return((-1));
               break;
          case 2:
               *bits = 16;
        if ( (*speed != 7200) && (*speed != 8000) && (*speed != 11025) )
   {
            lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
     return((-1));
   }
        sprintf(buffer, "AT+VSM=129,%d", (int)*speed);
               if (voice_command(buffer, "OK") != (0x1000))
                    return((-1));
               break;
          case 3:
               *bits = 8;
        if ( *speed != 8000 )
   {
     lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
     return((-1));
   }
        sprintf(buffer, "AT+VSM=130,%d", (int)*speed);
               if (voice_command(buffer, "OK") != (0x1000))
                    return((-1));
               break;
   case 4:
     *bits = 8;
     if ( *speed != 8000 )
       {
  lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
  return((-1));
       }
     sprintf(buffer, "AT+VSM=131,%d", (int)*speed);
     if (voice_command(buffer, "OK") != (0x1000))
       return((-1));
     break;
   case 5:
     *bits = 4;
     if ((*speed != 8000) && (*speed != 7200) && (*speed != 11025))
       {
  lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
  return((-1));
       }
     sprintf(buffer, "AT+VSM=132,%d", (int)*speed);
     if (voice_command(buffer, "OK") != (0x1000))
       return((-1));
     break;
          default:
               lprintf(3, "%s: Illegal voice compression method (%d)",
                voice_modem->name, *compression);
               return((-1));
          };
     return((0));
     }

canonical_original_code:
static int Lucent_set_compression(long *compression, long *speed, int *bits)
     {
     char buffer[-1];
     reset_watchdog();
     if (*compression == 0)
       *compression = 4;
     if (*speed == 0)
       *speed = 8000;
     switch (*compression)
          {
          case 1:
               *bits = 8;
        if ( (*speed != 7200) && (*speed != 8000) && (*speed != 11025) )
   {
            lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
     return((-1));
   }
        sprintf(buffer, "AT+VSM=128,%d", (int)*speed);
               if (voice_command(buffer, "OK") != (0x1000))
                    return((-1));
               break;
          case 2:
               *bits = 16;
        if ( (*speed != 7200) && (*speed != 8000) && (*speed != 11025) )
   {
            lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
     return((-1));
   }
        sprintf(buffer, "AT+VSM=129,%d", (int)*speed);
               if (voice_command(buffer, "OK") != (0x1000))
                    return((-1));
               break;
          case 3:
               *bits = 8;
        if ( *speed != 8000 )
   {
     lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
     return((-1));
   }
        sprintf(buffer, "AT+VSM=130,%d", (int)*speed);
               if (voice_command(buffer, "OK") != (0x1000))
                    return((-1));
               break;
   case 4:
     *bits = 8;
     if ( *speed != 8000 )
       {
  lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
  return((-1));
       }
     sprintf(buffer, "AT+VSM=131,%d", (int)*speed);
     if (voice_command(buffer, "OK") != (0x1000))
       return((-1));
     break;
   case 5:
     *bits = 4;
     if ((*speed != 8000) && (*speed != 7200) && (*speed != 11025))
       {
  lprintf(3, "%s: Illegal sample rate (%d)",
      voice_modem->name, *speed);
  return((-1));
       }
     sprintf(buffer, "AT+VSM=132,%d", (int)*speed);
     if (voice_command(buffer, "OK") != (0x1000))
       return((-1));
     break;
          default:
               lprintf(3, "%s: Illegal voice compression method (%d)",
                voice_modem->name, *compression);
               return((-1));
          };
     return((0));
     }


decompiled_code:
__int64 __fastcall Lucent_init(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rdx
__int64 v4; // rdx
char v6[264]; // [rsp+0h] [rbp-108h] BYREF

reset_watchdog(a1, a2, a3);
voice_modem_state = 2;
lprintf(4LL, "initializing Lucent voice modem");
sprintf(v6, "AT+VSD=%d,%d", (unsigned int)((int)*((_QWORD *)&cvd + 58) / 10 + 123), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v6, &unk_76A) != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v3 = *((_QWORD *)&cvd + 82);
if ( v3 == -1 )
{
*((_QWORD *)&cvd + 82) = 128LL;
v3 = 128LL;
}
sprintf(v6, "AT+VGT=%d", v3);
if ( (unsigned int)voice_command(v6, &unk_76A) != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v4 = *((_QWORD *)&cvd + 79);
if ( v4 == -1 )
{
*((_QWORD *)&cvd + 79) = 128LL;
v4 = 128LL;
}
sprintf(v6, "AT+VGR=%d", v4);
if ( (unsigned int)voice_command(v6, &unk_76A) != 4096 )
lprintf(3LL, "setting receive gain didn't work");
if ( (unsigned int)voice_command("AT+VIT=0", &unk_76A) != 4096 )
lprintf(3LL, "can't deactivate inactivity timer");
if ( (unsigned int)voice_command("AT+VPR=0", &unk_76A) != 4096 )
lprintf(3LL, "can't select autobauding");
if ( (unsigned int)voice_command("AT+VLS=0", &unk_76A) != 4096 )
lprintf(3LL, "can't deselect all input/output devices");
voice_modem_state = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rdx
__int64 v4; // rdx
char v6[264]; // [rsp+0h] [rbp-108h] BYREF

reset_watchdog(a1, a2, a3);
voice_modem_state = 2;
lprintf(4LL, "initializing Lucent voice modem");
sprintf(v6, "AT+VSD=%d,%d", (unsigned int)((int)*((_QWORD *)&cvd + 58) / 10 + 123), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v6, &unk_76A) != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v3 = *((_QWORD *)&cvd + 82);
if ( v3 == -1 )
{
*((_QWORD *)&cvd + 82) = 128LL;
v3 = 128LL;
}
sprintf(v6, "AT+VGT=%d", v3);
if ( (unsigned int)voice_command(v6, &unk_76A) != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v4 = *((_QWORD *)&cvd + 79);
if ( v4 == -1 )
{
*((_QWORD *)&cvd + 79) = 128LL;
v4 = 128LL;
}
sprintf(v6, "AT+VGR=%d", v4);
if ( (unsigned int)voice_command(v6, &unk_76A) != 4096 )
lprintf(3LL, "setting receive gain didn't work");
if ( (unsigned int)voice_command("AT+VIT=0", &unk_76A) != 4096 )
lprintf(3LL, "can't deactivate inactivity timer");
if ( (unsigned int)voice_command("AT+VPR=0", &unk_76A) != 4096 )
lprintf(3LL, "can't select autobauding");
if ( (unsigned int)voice_command("AT+VLS=0", &unk_76A) != 4096 )
lprintf(3LL, "can't deselect all input/output devices");
voice_modem_state = 1;
return 0LL;
}

original_code:
static int Lucent_init (void)
     {
     char buffer[(256)];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing Lucent voice modem");
     sprintf(buffer, "AT+VSD=%d,%d", (int)cvd.rec_silence_threshold.d.i *
      10 / 100 + 123, (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 = 128;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i);
     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 = 128;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting receive gain didn't work");
     if (voice_command("AT+VIT=0", "OK") != (0x1000))
          lprintf(3, "can't deactivate inactivity timer");
     if (voice_command("AT+VPR=0", "OK") != (0x1000))
          lprintf(3, "can't select autobauding");
     if (voice_command("AT+VLS=0", "OK") != (0x1000))
          lprintf(3, "can't deselect all input/output devices");
     voice_modem_state = (0x0001);
     return((0));
     }

canonical_original_code:
static int Lucent_init()
     {
     char buffer[-1];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing Lucent voice modem");
     sprintf(buffer, "AT+VSD=%d,%d", (int)cvd.rec_silence_threshold.d.i *
      10 / 100 + 123, (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 = 128;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i);
     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 = 128;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting receive gain didn't work");
     if (voice_command("AT+VIT=0", "OK") != (0x1000))
          lprintf(3, "can't deactivate inactivity timer");
     if (voice_command("AT+VPR=0", "OK") != (0x1000))
          lprintf(3, "can't select autobauding");
     if (voice_command("AT+VLS=0", "OK") != (0x1000))
          lprintf(3, "can't deselect all input/output devices");
     voice_modem_state = (0x0001);
     return((0));
     }


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

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

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

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

original_code:
static int Lucent_handle_dle(char data)
     {
     switch (data)
          {
          case 's':
               return(queue_event(create_event((0x2012))));
          }
     return(IS_101_handle_dle(data));
     }


decompiled_code:
void __fastcall hylafax_nsf_decode(void *s2, unsigned int a2)
{
size_t v2; // rdx
const void *v4; // rdi
void **v5; // rbx
const char *v6; // r8
const void **v7; // r13
const void *v8; // rdi
__int64 v9; // rax
size_t v10; // r14
const char *v11; // r15
unsigned int v12; // ebx
char *v13; // r12
int v14; // eax
const char *v15; // [rsp+8h] [rbp-40h]

v2 = 3LL;
v4 = &unk_140;
v5 = &KnownNSF;
while ( a2 < (unsigned int)v2 || memcmp(v4, s2, v2) )
{
v4 = v5[6];
v5 += 6;
if ( !v4 )
return;
v2 = *((unsigned int *)v5 + 2);
}
v6 = (const char *)v5[2];
v7 = (const void **)v5[5];
if ( v6 )
{
if ( !v7 || (v8 = *v7) == 0LL )
{
v11 = "<unknown>";
LABEL_20:
lprintf(4LL, "NSF: vendor=%s, model=%s", v6, v11);
return;
}
}
else
{
if ( !v7 )
return;
v8 = *v7;
if ( !*v7 )
return;
}
v9 = *((unsigned int *)v5 + 7);
v10 = *((unsigned int *)v5 + 8);
v11 = 0LL;
v12 = v9 + v10;
v13 = (char *)s2 + v9;
do
{
if ( v12 <= a2 )
{
v15 = v6;
v14 = memcmp(v8, v13, v10);
v6 = v15;
if ( !v14 )
v11 = (const char *)v7[1];
}
v8 = v7[2];
v7 += 2;
}
while ( v8 );
if ( (unsigned __int64)v6 | (unsigned __int64)v11 )
{
if ( !v11 )
v11 = "<unknown>";
if ( !v6 )
v6 = "<unknown>";
goto LABEL_20;
}
}

canonical_decompiled_code:
void __fastcall func0(void *s2, unsigned int a2)
{
size_t v2; // rdx
const void *v4; // rdi
void **v5; // rbx
const char *v6; // r8
const void **v7; // r13
const void *v8; // rdi
__int64 v9; // rax
size_t v10; // r14
const char *v11; // r15
unsigned int v12; // ebx
char *v13; // r12
int v14; // eax
const char *v15; // [rsp+8h] [rbp-40h]

v2 = 3LL;
v4 = &unk_140;
v5 = &KnownNSF;
while ( a2 < (unsigned int)v2 || memcmp(v4, s2, v2) )
{
v4 = v5[6];
v5 += 6;
if ( !v4 )
return;
v2 = *((unsigned int *)v5 + 2);
}
v6 = (const char *)v5[2];
v7 = (const void **)v5[5];
if ( v6 )
{
if ( !v7 || (v8 = *v7) == 0LL )
{
v11 = "<unknown>";
LABEL_20:
lprintf(4LL, "NSF: vendor=%s, model=%s", v6, v11);
return;
}
}
else
{
if ( !v7 )
return;
v8 = *v7;
if ( !*v7 )
return;
}
v9 = *((unsigned int *)v5 + 7);
v10 = *((unsigned int *)v5 + 8);
v11 = 0LL;
v12 = v9 + v10;
v13 = (char *)s2 + v9;
do
{
if ( v12 <= a2 )
{
v15 = v6;
v14 = memcmp(v8, v13, v10);
v6 = v15;
if ( !v14 )
v11 = (const char *)v7[1];
}
v8 = v7[2];
v7 += 2;
}
while ( v8 );
if ( (unsigned __int64)v6 | (unsigned __int64)v11 )
{
if ( !v11 )
v11 = "<unknown>";
if ( !v6 )
v6 = "<unknown>";
goto LABEL_20;
}
}

original_code:
void hylafax_nsf_decode (unsigned char * nsf,int nsfSize)
{
const char * vendor = ((void *)0);
const char * model = ((void *)0);
const NSFData * p;
const ModelData * pp;
    for( p = KnownNSF; p->vendorId; p++ ){
        if( nsfSize >= p->vendorIdSize &&
            memcmp( p->vendorId, &nsf[0], p->vendorIdSize )==0 ){
     if( p->vendorName )
                vendor = p->vendorName;
            if( p->knownModels ){
                for( pp = p->knownModels; pp->modelId; pp++ )
                    if( nsfSize >= p->modelIdPos + p->modelIdSize &&
                        memcmp( pp->modelId, &nsf[p->modelIdPos], p->modelIdSize )==0 )
                        model = pp->modelName;
            }
     break;
        }
    }
    if ( vendor != ((void *)0) || model != ((void *)0) )
 lprintf( 4, "NSF: vendor=%s, model=%s",
   vendor != ((void *)0)? vendor: "<unknown>",
   model != ((void *)0)? model : "<unknown>" );
}

canonical_original_code:
void hylafax_nsf_decode(unsigned char *nsf, int nsfSize)
{
char *vendor = ((void *)0);
char *model = ((void *)0);
struct NSFData *p;
struct ModelData *pp;
    for( p = KnownNSF; p->vendorId; p++ ){
        if( nsfSize >= p->vendorIdSize &&
            memcmp( p->vendorId, &nsf[0], p->vendorIdSize )==0 ){
     if( p->vendorName )
                vendor = p->vendorName;
            if( p->knownModels ){
                for( pp = p->knownModels; pp->modelId; pp++ )
                    if( nsfSize >= p->modelIdPos + p->modelIdSize &&
                        memcmp( pp->modelId, &nsf[p->modelIdPos], p->modelIdSize )==0 )
                        model = pp->modelName;
            }
     break;
        }
    }
    if ( vendor != ((void *)0) || model != ((void *)0) )
 lprintf( 4, "NSF: vendor=%s, model=%s",
   vendor != ((void *)0)? vendor: "<unknown>",
   model != ((void *)0)? model : "<unknown>" );
}

variable_types:
nsf
unsigned char *

variable_types: nsfSize int

variable_types:
vendor
char *

variable_types:
model
char *

variable_types: struct NSFData { char *vendorId; unsigned int vendorIdSize; char *vendorName; char inverseStationIdOrder; unsigned int modelIdPos; unsigned int modelIdSize; struct ModelData { char *modelId; char *modelName; } *knownModels; } *

return_type: void

user_defined_types: struct NSFData { char *vendorId; unsigned int vendorIdSize; char *vendorName; char inverseStationIdOrder; unsigned int modelIdPos; unsigned int modelIdSize; struct ModelData *knownModels; }


decompiled_code:
_BOOL8 __fastcall ZyXEL_1496_check_rmd_adequation(const char *a1)
{
_BOOL4 v1; // er8

v1 = 1;
if ( strcmp(a1, "ZyXEL 1496") )
v1 = strcmp(a1, "ZyXEL 2864") == 0;
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(const char *a1)
{
_BOOL4 v1; // er8

v1 = 1;
if ( strcmp(a1, "ZyXEL 1496") )
v1 = strcmp(a1, "ZyXEL 2864") == 0;
return v1;
}

original_code:
int ZyXEL_1496_check_rmd_adequation(char *rmd_name) {
   return !strncmp(rmd_name,
                   "ZyXEL 1496",
                   sizeof("ZyXEL 1496"))
          || !strncmp(rmd_name,
                      "ZyXEL 2864",
                      sizeof("ZyXEL 2864"));
}


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

if ( a1 == 3 )
{
voice_command("AT+VLS=8", "VCON");
return 0LL;
}
if ( a1 > 3 )
{
if ( a1 == 6 )
{
voice_command("AT+VLS=16", "VCON");
return 0LL;
}
goto LABEL_10;
}
if ( a1 != 1 )
{
if ( a1 == 2 )
{
v1 = 0;
voice_command("AT+VLS=2", "VCON");
return v1;
}
LABEL_10:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, (unsigned int)a1);
return 0xFFFFFFFFLL;
}
v3 = voice_write("AT+VLS=0");
if ( v3 )
return (unsigned int)-1;
if ( (unsigned int)voice_command(&unk_7CB, "AT+VLS=0|OK") == 4096 )
voice_command(&unk_7CB, "OK");
voice_command("AT+VNH=0", "OK");
return v3;
}

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

if ( a1 == 3 )
{
voice_command("AT+VLS=8", "VCON");
return 0LL;
}
if ( a1 > 3 )
{
if ( a1 == 6 )
{
voice_command("AT+VLS=16", "VCON");
return 0LL;
}
goto LABEL_10;
}
if ( a1 != 1 )
{
if ( a1 == 2 )
{
v1 = 0;
voice_command("AT+VLS=2", "VCON");
return v1;
}
LABEL_10:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, (unsigned int)a1);
return 0xFFFFFFFFLL;
}
v3 = voice_write("AT+VLS=0");
if ( v3 )
return (unsigned int)-1;
if ( (unsigned int)voice_command(&unk_7CB, "AT+VLS=0|OK") == 4096 )
voice_command(&unk_7CB, "OK");
voice_command("AT+VNH=0", "OK");
return v3;
}

original_code:
static int ZyXEL_1496_set_device (int device)
     {
     switch (device)
          {
          case (0x0001):
               if (voice_write("AT+VLS=0") != (0))
                    return((-1));
               if (voice_command("", "AT+VLS=0|OK") == (0x1000))
                    voice_command("", "OK");
               voice_command("AT+VNH=0", "OK");
               return((0));
          case (0x0002):
               voice_command("AT+VLS=2", "VCON");
               return((0));
          case (0x0003):
               voice_command("AT+VLS=8", "VCON");
               return((0));
          case (0x0006):
               voice_command("AT+VLS=16", "VCON");
               return((0));
          };
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }

canonical_original_code:
static int ZyXEL_1496_set_device(int device)
     {
     switch (device)
          {
          case (0x0001):
               if (voice_write("AT+VLS=0") != (0))
                    return((-1));
               if (voice_command("", "AT+VLS=0|OK") == (0x1000))
                    voice_command("", "OK");
               voice_command("AT+VNH=0", "OK");
               return((0));
          case (0x0002):
               voice_command("AT+VLS=2", "VCON");
               return((0));
          case (0x0003):
               voice_command("AT+VLS=8", "VCON");
               return((0));
          case (0x0006):
               voice_command("AT+VLS=16", "VCON");
               return((0));
          };
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }


decompiled_code:
__int64 __fastcall ZyXEL_1496_set_compression(_QWORD *a1, __int64 *a2, _DWORD *a3)
{
__int64 v3; // rcx
__int64 result; // rax
const char *v5; // rdi

if ( !*a1 )
*a1 = 2LL;
v3 = *a2;
if ( *a2 )
{
if ( v3 != 9600 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v3);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 9600LL;
}
switch ( *a1 )
{
case 1LL:
*a3 = 1;
v5 = "AT+VSM=1";
goto LABEL_10;
case 2LL:
*a3 = 2;
v5 = "AT+VSM=2";
goto LABEL_10;
case 3LL:
*a3 = 3;
v5 = "AT+VSM=3";
goto LABEL_10;
case 4LL:
*a3 = 4;
v5 = "AT+VSM=4";
goto LABEL_10;
case 0x1ELL:
*a3 = 3;
v5 = "AT+VSM=30";
LABEL_10:
result = (unsigned int)-((unsigned int)voice_command(v5, "OK") != 4096);
break;
default:
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, *a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 *a2, _DWORD *a3)
{
__int64 v3; // rcx
__int64 result; // rax
const char *v5; // rdi

if ( !*a1 )
*a1 = 2LL;
v3 = *a2;
if ( *a2 )
{
if ( v3 != 9600 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v3);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 9600LL;
}
switch ( *a1 )
{
case 1LL:
*a3 = 1;
v5 = "AT+VSM=1";
goto LABEL_10;
case 2LL:
*a3 = 2;
v5 = "AT+VSM=2";
goto LABEL_10;
case 3LL:
*a3 = 3;
v5 = "AT+VSM=3";
goto LABEL_10;
case 4LL:
*a3 = 4;
v5 = "AT+VSM=4";
goto LABEL_10;
case 0x1ELL:
*a3 = 3;
v5 = "AT+VSM=30";
LABEL_10:
result = (unsigned int)-((unsigned int)voice_command(v5, "OK") != 4096);
break;
default:
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, *a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

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


decompiled_code:
__int64 ZyXEL_1496_init()
{
__int64 v0; // rdx
__int64 v1; // rdx
__int64 v2; // rdx
__int64 v3; // rdx
char v5[264]; // [rsp+0h] [rbp-108h] BYREF

reset_watchdog();
voice_modem_state = 2;
voice_command("ATI1", &unk_7CB);
voice_read(v5);
voice_read(v5);
voice_command(&unk_7CB, "OK");
rom_release = 100 * (v5[10] - 48) + 2 * (5 * v5[12] - 240) + v5[13] - 48;
lprintf(4LL, "ROM release %4.2f detected", (double)rom_release / 100.0);
lprintf(4LL, "initializing ZyXEL 1496 voice modem");
if ( (unsigned int)voice_command("ATS40.3=1 S40.4=1 S40.5=1 S40.6=1", "OK") != 4096 )
lprintf(3LL, "couldn't initialize distinctive RING");
if ( (unsigned int)voice_command("ATS39.6=1 S39.7=0 +VIT=60", "OK") != 4096 )
lprintf(3LL, "voice init failed, continuing");
sprintf(
v5,
"AT+VDH=%d +VDD=%d",
(unsigned int)((int)(31 * *((_QWORD *)&cvd + 37)) / 100),
(unsigned int)((int)*((_QWORD *)&cvd + 34) / 5));
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting DTMF preferences didn't work");
sprintf(v5, "AT+VSD=%d,%d", (unsigned int)((int)(31 * *((_QWORD *)&cvd + 58)) / 100), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v0 = *((_QWORD *)&cvd + 82);
if ( v0 == -1 )
{
*((_QWORD *)&cvd + 82) = 75LL;
v1 = 191LL;
}
else
{
v1 = (unsigned int)(255 * (int)v0 / 100);
}
sprintf(v5, "AT+VGT=%d", v1);
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v2 = *((_QWORD *)&cvd + 79);
if ( v2 == -1 )
{
*((_QWORD *)&cvd + 79) = 75LL;
v3 = 191LL;
}
else
{
v3 = (unsigned int)(255 * (int)v2 / 100);
}
sprintf(v5, "AT+VGR=%d", v3);
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting receive gain didn't work");
if ( (unsigned int)voice_command("AT+VNH=1", "OK") != 4096 )
lprintf(3LL, "can't disable autohangup");
sprintf(v5, "AT+VRA=%d+VRN=%d", *((unsigned int *)&cvd + 398), *((unsigned int *)&cvd + 404));
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting ringback delay didn't work");
voice_modem_state = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rdx
__int64 v1; // rdx
__int64 v2; // rdx
__int64 v3; // rdx
char v5[264]; // [rsp+0h] [rbp-108h] BYREF

reset_watchdog();
voice_modem_state = 2;
voice_command("ATI1", &unk_7CB);
voice_read(v5);
voice_read(v5);
voice_command(&unk_7CB, "OK");
rom_release = 100 * (v5[10] - 48) + 2 * (5 * v5[12] - 240) + v5[13] - 48;
lprintf(4LL, "ROM release %4.2f detected", (double)rom_release / 100.0);
lprintf(4LL, "initializing ZyXEL 1496 voice modem");
if ( (unsigned int)voice_command("ATS40.3=1 S40.4=1 S40.5=1 S40.6=1", "OK") != 4096 )
lprintf(3LL, "couldn't initialize distinctive RING");
if ( (unsigned int)voice_command("ATS39.6=1 S39.7=0 +VIT=60", "OK") != 4096 )
lprintf(3LL, "voice init failed, continuing");
sprintf(
v5,
"AT+VDH=%d +VDD=%d",
(unsigned int)((int)(31 * *((_QWORD *)&cvd + 37)) / 100),
(unsigned int)((int)*((_QWORD *)&cvd + 34) / 5));
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting DTMF preferences didn't work");
sprintf(v5, "AT+VSD=%d,%d", (unsigned int)((int)(31 * *((_QWORD *)&cvd + 58)) / 100), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v0 = *((_QWORD *)&cvd + 82);
if ( v0 == -1 )
{
*((_QWORD *)&cvd + 82) = 75LL;
v1 = 191LL;
}
else
{
v1 = (unsigned int)(255 * (int)v0 / 100);
}
sprintf(v5, "AT+VGT=%d", v1);
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v2 = *((_QWORD *)&cvd + 79);
if ( v2 == -1 )
{
*((_QWORD *)&cvd + 79) = 75LL;
v3 = 191LL;
}
else
{
v3 = (unsigned int)(255 * (int)v2 / 100);
}
sprintf(v5, "AT+VGR=%d", v3);
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting receive gain didn't work");
if ( (unsigned int)voice_command("AT+VNH=1", "OK") != 4096 )
lprintf(3LL, "can't disable autohangup");
sprintf(v5, "AT+VRA=%d+VRN=%d", *((unsigned int *)&cvd + 398), *((unsigned int *)&cvd + 404));
if ( (unsigned int)voice_command(v5, "OK") != 4096 )
lprintf(3LL, "setting ringback delay didn't work");
voice_modem_state = 1;
return 0LL;
}

original_code:
static int ZyXEL_1496_init (void)
     {
     char buffer[(256)];
     reset_watchdog();
     voice_modem_state = (0x0002);
     voice_command("ATI1", "");
     voice_read(buffer);
     voice_read(buffer);
     voice_command("", "OK");
     rom_release = 100 * (buffer[10] - '0') + 10 *
      (buffer[12] - '0') + (buffer[13] - '0');
     lprintf(4, "ROM release %4.2f detected", rom_release / 100.0);
     lprintf(4, "initializing ZyXEL 1496 voice modem");
     if (voice_command("ATS40.3=1 S40.4=1 S40.5=1 S40.6=1", "OK") !=
      (0x1000))
          lprintf(3, "couldn't initialize distinctive RING");
     if (voice_command("ATS39.6=1 S39.7=0 +VIT=60", "OK") != (0x1000))
          lprintf(3, "voice init failed, continuing");
     sprintf(buffer, "AT+VDH=%d +VDD=%d", (int)cvd.dtmf_threshold.d.i *
      31 / 100, (int)cvd.dtmf_len.d.i / 5);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting DTMF preferences didn't work");
     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 = 75;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 255 / 100);
     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 = 75;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 255 / 100);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting receive gain didn't work");
     if (voice_command("AT+VNH=1", "OK") != (0x1000))
          lprintf(3, "can't disable autohangup");
     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");
     voice_modem_state = (0x0001);
     return((0));
     }

canonical_original_code:
static int ZyXEL_1496_init()
     {
     char buffer[-1];
     reset_watchdog();
     voice_modem_state = (0x0002);
     voice_command("ATI1", "");
     voice_read(buffer);
     voice_read(buffer);
     voice_command("", "OK");
     rom_release = 100 * (buffer[10] - '0') + 10 *
      (buffer[12] - '0') + (buffer[13] - '0');
     lprintf(4, "ROM release %4.2f detected", rom_release / 100.0);
     lprintf(4, "initializing ZyXEL 1496 voice modem");
     if (voice_command("ATS40.3=1 S40.4=1 S40.5=1 S40.6=1", "OK") !=
      (0x1000))
          lprintf(3, "couldn't initialize distinctive RING");
     if (voice_command("ATS39.6=1 S39.7=0 +VIT=60", "OK") != (0x1000))
          lprintf(3, "voice init failed, continuing");
     sprintf(buffer, "AT+VDH=%d +VDD=%d", (int)cvd.dtmf_threshold.d.i *
      31 / 100, (int)cvd.dtmf_len.d.i / 5);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting DTMF preferences didn't work");
     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 = 75;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 255 / 100);
     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 = 75;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 255 / 100);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting receive gain didn't work");
     if (voice_command("AT+VNH=1", "OK") != (0x1000))
          lprintf(3, "can't disable autohangup");
     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");
     voice_modem_state = (0x0001);
     return((0));
     }


original_code:
void Gsm_Coder (struct gsm_state * S, word * s, word * LARc, word * Nc, word * bc, word * Mc, word * xmaxc, word * xMc)
{
     int k;
     word * dp = S->dp0 + 120;
     word * dpp = dp;
     static word e [50] = {0};
     word so[160];
     Gsm_Preprocess (S, s, so);
     Gsm_LPC_Analysis (S, so, LARc);
     Gsm_Short_Term_Analysis_Filter (S, LARc, so);
     for (k = 0; k <= 3; k++, xMc += 13) {
          Gsm_Long_Term_Predictor ( S,
                          so+k*40,
                          dp,
                         e + 5,
                         dpp,
                          Nc++,
                          bc++);
          Gsm_RPE_Encoding ( S,
                         e + 5,
                           xmaxc++, Mc++, xMc );
          { register int i;
            register longword ltmp;
            for (i = 0; i <= 39; i++)
               dp[ i ] = ((ulongword)((ltmp = (longword)(e[5 + i]) + (longword)(dpp[i])) - ((-32767)-1)) > ( 32767) - ((-32767)-1) ? (ltmp > 0 ? ( 32767) : ((-32767)-1)) : ltmp);
          }
          dp += 40;
          dpp += 40;
     }
     (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
          120 * sizeof(*S->dp0) );
}

canonical_original_code:
void Gsm_Coder(struct gsm_state *S, short *s, short *LARc, short *Nc, short *bc, short *Mc, short *xmaxc, short *xMc)
{
     int k;
     short *dp = S->dp0 + 120;
     short *dpp = dp;
     static short e[50] = {0};
     short so[160];
     Gsm_Preprocess (S, s, so);
     Gsm_LPC_Analysis (S, so, LARc);
     Gsm_Short_Term_Analysis_Filter (S, LARc, so);
     for (k = 0; k <= 3; k++, xMc += 13) {
          Gsm_Long_Term_Predictor ( S,
                          so+k*40,
                          dp,
                         e + 5,
                         dpp,
                          Nc++,
                          bc++);
          Gsm_RPE_Encoding ( S,
                         e + 5,
                           xmaxc++, Mc++, xMc );
          { register int i;
            register long ltmp;
            for (i = 0; i <= 39; i++)
               dp[ i ] = ((ulongword)((ltmp = (longword)(e[5 + i]) + (longword)(dpp[i])) - ((-32767)-1)) > ( 32767) - ((-32767)-1) ? (ltmp > 0 ? ( 32767) : ((-32767)-1)) : ltmp);
          }
          dp += 40;
          dpp += 40;
     }
     (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
          120 * sizeof(*S->dp0) );
}

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

variable_types:
s
short *

variable_types:
LARc
short *

variable_types:
Nc
short *

variable_types:
bc
short *

variable_types:
Mc
short *

variable_types:
xmaxc
short *

variable_types:
xMc
short *

variable_types: k int

variable_types:
dp
short *

variable_types:
dpp
short *

variable_types:
e
short [50]

variable_types:
so
short [160]

variable_types: i int

variable_types: ltmp long


decompiled_code:
__int64 __fastcall gsm_add(__int16 a1, __int16 a2)
{
__int64 result; // rax

result = a1 + (__int64)a2;
if ( result > 0x7FFF )
result = 0x7FFFLL;
if ( result < -32768 )
result = -32768LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 a1, __int16 a2)
{
__int64 result; // rax

result = a1 + (__int64)a2;
if ( result > 0x7FFF )
result = 0x7FFFLL;
if ( result < -32768 )
result = -32768LL;
return result;
}

variable_types: a short

variable_types: b short

variable_types: sum long

return_type: short


decompiled_code:
__int64 __fastcall gsm_sub(__int16 a1, __int16 a2)
{
__int64 result; // rax

result = a1 - (__int64)a2;
if ( result > 0x7FFF )
result = 0x7FFFLL;
if ( result < -32768 )
result = -32768LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1, __int16 a2)
{
__int64 result; // rax

result = a1 - (__int64)a2;
if ( result > 0x7FFF )
result = 0x7FFFLL;
if ( result < -32768 )
result = -32768LL;
return result;
}

original_code:
word gsm_sub (word a, word b)
{
     longword diff = (longword)a - (longword)b;
     return ((diff) < ((-32767)-1) ? ((-32767)-1) : (diff) > ( 32767) ? ( 32767): (diff));
}

canonical_original_code:
short gsm_sub(short a, short b)
{
     long diff = (longword)a - (longword)b;
     return ((diff) < ((-32767)-1) ? ((-32767)-1) : (diff) > ( 32767) ? ( 32767): (diff));
}

variable_types: diff long


decompiled_code:
__int64 __fastcall gsm_mult(__int16 a1, __int16 a2)
{
__int64 result; // rax

if ( a1 != (__int16)0x8000 || (result = 0x7FFFLL, a2 != (__int16)0x8000) )
result = (a2 * (__int64)a1) >> 15;
return result;
}


original_code:
word gsm_mult_r (word a, word b)
{
     if (b == ((-32767)-1) && a == ((-32767)-1)) return ( 32767);
     else {
          longword prod = (longword)a * (longword)b + 16384;
          prod >>= 15;
          return prod & 0xFFFF;
     }
}

canonical_original_code:
short gsm_mult_r(short a, short b)
{
     if (b == ((-32767)-1) && a == ((-32767)-1)) return ( 32767);
     else {
          long prod = (longword)a * (longword)b + 16384;
          prod >>= 15;
          return prod & 0xFFFF;
     }
}

variable_types: prod long


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

result = a1;
if ( (a1 & 0x8000u) != 0 )
{
result = -a1;
if ( (_WORD)a1 == 0x8000 )
result = 0x7FFFLL;
}
return result;
}

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

result = a1;
if ( (a1 & 0x8000u) != 0 )
{
result = -a1;
if ( (_WORD)a1 == 0x8000 )
result = 0x7FFFLL;
}
return result;
}


decompiled_code:
unsigned __int64 __fastcall gsm_L_add(__int64 a1, __int64 a2)
{
unsigned __int64 result; // rax

if ( a1 >= 0 )
{
if ( a2 > 0 )
{
result = a1 + a2;
if ( (unsigned __int64)(a1 + a2) > 0x7FFFFFFF )
result = 0x7FFFFFFFLL;
return result;
}
return a1 + a2;
}
if ( a2 >= 0 )
return a1 + a2;
result = a1 + a2;
if ( (unsigned __int64)(-2 - (a1 + a2)) > 0x7FFFFFFE )
result = 0xFFFFFFFF80000000LL;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned __int64 result; // rax

if ( a1 >= 0 )
{
if ( a2 > 0 )
{
result = a1 + a2;
if ( (unsigned __int64)(a1 + a2) > 0x7FFFFFFF )
result = 0x7FFFFFFFLL;
return result;
}
return a1 + a2;
}
if ( a2 >= 0 )
return a1 + a2;
result = a1 + a2;
if ( (unsigned __int64)(-2 - (a1 + a2)) > 0x7FFFFFFE )
result = 0xFFFFFFFF80000000LL;
return result;
}

original_code:
longword gsm_L_add (longword a, longword b)
{
     if (a < 0) {
          if (b >= 0) return a + b;
          else {
               ulongword A = (ulongword)-(a + 1) + (ulongword)-(b + 1);
               return A >= ( 2147483647) ? ((-2147483647)-1) :-(longword)A-2;
          }
     }
     else if (b <= 0) return a + b;
     else {
          ulongword A = (ulongword)a + (ulongword)b;
          return A > ( 2147483647) ? ( 2147483647) : A;
     }
}

canonical_original_code:
long gsm_L_add(long a, long b)
{
     if (a < 0) {
          if (b >= 0) return a + b;
          else {
               unsigned long A = (ulongword)-(a + 1) + (ulongword)-(b + 1);
               return A >= ( 2147483647) ? ((-2147483647)-1) :-(long)A-2;
          }
     }
     else if (b <= 0) return a + b;
     else {
          unsigned long A = (ulongword)a + (ulongword)b;
          return A > ( 2147483647) ? ( 2147483647) : A;
     }
}

variable_types: a long

variable_types: b long

variable_types:
A
unsigned long

return_type: long


decompiled_code:
unsigned __int64 __fastcall gsm_L_sub(__int64 a1, __int64 a2)
{
unsigned __int64 result; // rax
unsigned __int64 v3; // rdi
unsigned __int64 v4; // rax
unsigned __int64 v5; // rdi
bool v6; // cf

if ( a1 < 0 )
{
if ( a2 <= 0 )
return a1 - a2;
v4 = a2 - 1 - a1;
v5 = a1 - a2;
v6 = v4 < 0x7FFFFFFF;
result = 0xFFFFFFFF80000000LL;
if ( v6 )
result = v5;
}
else
{
if ( a2 >= 0 )
return a1 - a2;
v3 = a1 - a2 - 1;
if ( v3 > 0x7FFFFFFE )
v3 = 2147483646LL;
result = v3 + 1;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(__int64 a1, __int64 a2)
{
unsigned __int64 result; // rax
unsigned __int64 v3; // rdi
unsigned __int64 v4; // rax
unsigned __int64 v5; // rdi
bool v6; // cf

if ( a1 < 0 )
{
if ( a2 <= 0 )
return a1 - a2;
v4 = a2 - 1 - a1;
v5 = a1 - a2;
v6 = v4 < 0x7FFFFFFF;
result = 0xFFFFFFFF80000000LL;
if ( v6 )
result = v5;
}
else
{
if ( a2 >= 0 )
return a1 - a2;
v3 = a1 - a2 - 1;
if ( v3 > 0x7FFFFFFE )
v3 = 2147483646LL;
result = v3 + 1;
}
return result;
}

original_code:
longword gsm_L_sub (longword a, longword b)
{
     if (a >= 0) {
          if (b >= 0) return a - b;
          else {
               ulongword A = (ulongword)a + -(b + 1);
               return A >= ( 2147483647) ? ( 2147483647) : (A + 1);
          }
     }
     else if (b <= 0) return a - b;
     else {
          ulongword A = (ulongword)-(a + 1) + b;
          return A >= ( 2147483647) ? ((-2147483647)-1) : -(longword)A - 1;
     }
}

canonical_original_code:
long gsm_L_sub(long a, long b)
{
     if (a >= 0) {
          if (b >= 0) return a - b;
          else {
               unsigned long A = (ulongword)a + -(b + 1);
               return A >= ( 2147483647) ? ( 2147483647) : (A + 1);
          }
     }
     else if (b <= 0) return a - b;
     else {
          unsigned long A = (ulongword)-(a + 1) + b;
          return A >= ( 2147483647) ? ((-2147483647)-1) : -(long)A - 1;
     }
}


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

if ( !a1 )
_assert_fail("a != 0", "add.c", 0x89u, "gsm_norm");
if ( a1 < 0 )
{
result = 0LL;
if ( a1 < -1073741823 )
return result;
LODWORD(a1) = ~(_DWORD)a1;
}
if ( (a1 & 0xFFFF0000) != 0 )
{
if ( (a1 & 0xFF000000) != 0 )
result = (unsigned int)(unsigned __int8)bitoff[BYTE3(a1)] - 1;
else
result = (unsigned int)(unsigned __int8)bitoff[BYTE2(a1)] + 7;
}
else if ( (a1 & 0xFF00) != 0 )
{
result = (unsigned int)(unsigned __int8)bitoff[BYTE1(a1)] + 15;
}
else
{
result = (unsigned int)(unsigned __int8)bitoff[(unsigned __int8)a1] + 23;
}
return result;
}

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

if ( !a1 )
_assert_fail("a != 0", "add.c", 0x89u, "gsm_norm");
if ( a1 < 0 )
{
result = 0LL;
if ( a1 < -1073741823 )
return result;
LODWORD(a1) = ~(_DWORD)a1;
}
if ( (a1 & 0xFFFF0000) != 0 )
{
if ( (a1 & 0xFF000000) != 0 )
result = (unsigned int)(unsigned __int8)bitoff[BYTE3(a1)] - 1;
else
result = (unsigned int)(unsigned __int8)bitoff[BYTE2(a1)] + 7;
}
else if ( (a1 & 0xFF00) != 0 )
{
result = (unsigned int)(unsigned __int8)bitoff[BYTE1(a1)] + 15;
}
else
{
result = (unsigned int)(unsigned __int8)bitoff[(unsigned __int8)a1] + 23;
}
return result;
}


decompiled_code:
__int64 __fastcall gsm_L_asr(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v3; // rdi

if ( a2 > 31 )
return a1 >> 63;
result = 0LL;
if ( a2 >= -31 )
{
result = a1 << -(char)a2;
v3 = a1 >> a2;
if ( a2 >= 0 )
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
__int64 result; // rax
__int64 v3; // rdi

if ( a2 > 31 )
return a1 >> 63;
result = 0LL;
if ( a2 >= -31 )
{
result = a1 << -(char)a2;
v3 = a1 >> a2;
if ( a2 >= 0 )
result = v3;
}
return result;
}

original_code:
longword gsm_L_asr (longword a, int n)
{
     if (n >= 32) return -(a < 0);
     if (n <= -32) return 0;
     if (n < 0) return a << -n;
          return a >> n;
}

canonical_original_code:
long gsm_L_asr(long a, int n)
{
     if (n >= 32) return -(a < 0);
     if (n <= -32) return 0;
     if (n < 0) return a << -n;
          return a >> n;
}

variable_types: n int


decompiled_code:
__int64 __fastcall gsm_L_asl(__int64 a1, int a2)
{
__int64 result; // rax

if ( a2 > 31 )
return 0LL;
if ( a2 < -31 )
return a1 >> 63;
result = a1 << a2;
if ( a2 < 0 )
result = gsm_L_asr(a1, -a2);
return result;
}

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

if ( a2 > 31 )
return 0LL;
if ( a2 < -31 )
return a1 >> 63;
result = a1 << a2;
if ( a2 < 0 )
result = func9(a1, -a2);
return result;
}

original_code:
longword gsm_L_asl (longword a, int n)
{
     if (n >= 32) return 0;
     if (n <= -32) return -(a < 0);
     if (n < 0) return gsm_L_asr(a, -n);
     return a << n;
}

canonical_original_code:
long gsm_L_asl(long a, int n)
{
     if (n >= 32) return 0;
     if (n <= -32) return -(a < 0);
     if (n < 0) return gsm_L_asr(a, -n);
     return a << n;
}


decompiled_code:
__int16 __fastcall gsm_asr(__int16 a1, int a2)
{
int v2; // eax
int v3; // edi

if ( a2 > 15 )
{
LOWORD(v2) = a1 >> 15;
}
else
{
LOWORD(v2) = 0;
if ( a2 >= -15 )
{
v2 = a1 >> a2;
v3 = a1 << -(char)a2;
if ( a2 < 0 )
LOWORD(v2) = v3;
}
}
return v2;
}

original_code:
word gsm_asr (word a, int n)
{
     if (n >= 16) return -(a < 0);
     if (n <= -16) return 0;
     if (n < 0) return a << -n;
          return a >> n;
}

canonical_original_code:
short gsm_asr(short a, int n)
{
     if (n >= 16) return -(a < 0);
     if (n <= -16) return 0;
     if (n < 0) return a << -n;
          return a >> n;
}


decompiled_code:
__int16 __fastcall gsm_asl(__int16 a1, int a2)
{
int v2; // eax

if ( a2 > 15 )
{
LOWORD(v2) = 0;
}
else if ( a2 < -15 )
{
LOWORD(v2) = a1 >> 15;
}
else
{
v2 = a1 << a2;
if ( a2 < 0 )
LOWORD(v2) = gsm_asr(a1, -a2);
}
return v2;
}

canonical_decompiled_code:
__int16 __fastcall func12(__int16 a1, int a2)
{
int v2; // eax

if ( a2 > 15 )
{
LOWORD(v2) = 0;
}
else if ( a2 < -15 )
{
LOWORD(v2) = a1 >> 15;
}
else
{
v2 = a1 << a2;
if ( a2 < 0 )
LOWORD(v2) = func11(a1, -a2);
}
return v2;
}

original_code:
word gsm_asl (word a, int n)
{
     if (n >= 16) return 0;
     if (n <= -16) return -(a < 0);
     if (n < 0) return gsm_asr(a, -n);
     return a << n;
}

canonical_original_code:
short gsm_asl(short a, int n)
{
     if (n >= 16) return 0;
     if (n <= -16) return -(a < 0);
     if (n < 0) return gsm_asr(a, -n);
     return a << n;
}


decompiled_code:
__int64 __fastcall gsm_div(__int16 a1, __int16 a2)
{
__int64 result; // rax
__int64 v3; // rdx
int v4; // ecx

if ( a1 < 0 || a1 > a2 )
_assert_fail("num >= 0 && denum >= num", "add.c", 0xDCu, "gsm_div");
result = 0LL;
if ( a1 )
{
v3 = a1;
v4 = 15;
do
{
v3 *= 2LL;
result = (unsigned int)(2 * (__int16)result);
if ( a2 <= v3 )
{
v3 -= a2;
result = (unsigned int)(result + 1);
}
--v4;
}
while ( v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int16 a1, __int16 a2)
{
__int64 result; // rax
__int64 v3; // rdx
int v4; // ecx

if ( a1 < 0 || a1 > a2 )
_assert_fail("num >= 0 && denum >= num", "add.c", 0xDCu, "gsm_div");
result = 0LL;
if ( a1 )
{
v3 = a1;
v4 = 15;
do
{
v3 *= 2LL;
result = (unsigned int)(2 * (__int16)result);
if ( a2 <= v3 )
{
v3 -= a2;
result = (unsigned int)(result + 1);
}
--v4;
}
while ( v4 );
}
return result;
}

original_code:
word gsm_div (word num, word denum)
{
     longword L_num = num;
     longword L_denum = denum;
     word div = 0;
     int k = 15;
     ((void) sizeof ((num >= 0 && denum >= num) ? 1 : 0), __extension__ ({ if (num >= 0 && denum >= num) ; else __assert_fail ("num >= 0 && denum >= num", "add.c", 220, __extension__ __PRETTY_FUNCTION__); }));
     if (num == 0)
         return 0;
     while (k--) {
          div <<= 1;
          L_num <<= 1;
          if (L_num >= L_denum) {
               L_num -= L_denum;
               div++;
          }
     }
     return div;
}

canonical_original_code:
short gsm_div(short num, short denum)
{
     long L_num = num;
     long L_denum = denum;
     short div = 0;
     int k = 15;
     ((void) sizeof ((num >= 0 && denum >= num) ? 1 : 0), __extension__ ({ if (num >= 0 && denum >= num) ; else __assert_fail ("num >= 0 && denum >= num", "add.c", 220, __extension__ __PRETTY_FUNCTION__); }));
     if (num == 0)
         return 0;
     while (k--) {
          div <<= 1;
          L_num <<= 1;
          if (L_num >= L_denum) {
               L_num -= L_denum;
               div++;
          }
     }
     return div;
}

variable_types: num short

variable_types: denum short

variable_types: div short


decompiled_code:
__int64 no_modem_play_dtmf()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 146LL, "] ", "no_modem_play_dtmf", ":");
lprintf(3LL, "%s: play_dtmf called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func0()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 146LL, "] ", "no_modem_play_dtmf", ":");
lprintf(3LL, "%s: play_dtmf called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_play_dtmf(char* number)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 146, "] ", __FUNCTION__, ":"); lprintf(3, "%s: play_dtmf called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_play_dtmf(char *number)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 146, "] ", __FUNCTION__, ":"); lprintf(3, "%s: play_dtmf called", POS);
     return((-1));
     }

variable_types:
number
char *


decompiled_code:
__int64 no_modem_wait()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 140LL, "] ", "no_modem_wait", ":");
lprintf(3LL, "%s: wait called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func1()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 140LL, "] ", "no_modem_wait", ":");
lprintf(3LL, "%s: wait called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_wait(int wait_timeout)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 140, "] ", __FUNCTION__, ":"); lprintf(3, "%s: wait called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_voice_mode_on()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 134LL, "] ", "no_modem_voice_mode_on", ":");
lprintf(3LL, "%s: voice_mode_on called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func2()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 134LL, "] ", "no_modem_voice_mode_on", ":");
lprintf(3LL, "%s: voice_mode_on called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_voice_mode_on(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 134, "] ", __FUNCTION__, ":"); lprintf(3, "%s: voice_mode_on called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_voice_mode_on()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 134, "] ", __FUNCTION__, ":"); lprintf(3, "%s: voice_mode_on called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_voice_mode_off()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 128LL, "] ", "no_modem_voice_mode_off", ":");
lprintf(3LL, "%s: voice_mode_off called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func3()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 128LL, "] ", "no_modem_voice_mode_off", ":");
lprintf(3LL, "%s: voice_mode_off called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_voice_mode_off(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 128, "] ", __FUNCTION__, ":"); lprintf(3, "%s: voice_mode_off called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_voice_mode_off()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 128, "] ", __FUNCTION__, ":"); lprintf(3, "%s: voice_mode_off called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_switch_to_data_fax()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 122LL, "] ", "no_modem_switch_to_data_fax", ":");
lprintf(3LL, "%s: switch_to_data_fax called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func4()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 122LL, "] ", "no_modem_switch_to_data_fax", ":");
lprintf(3LL, "%s: switch_to_data_fax called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_switch_to_data_fax(char *mode)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 122, "] ", __FUNCTION__, ":"); lprintf(3, "%s: switch_to_data_fax called", POS);
     return((-1));
     }

variable_types:
mode
char *


decompiled_code:
__int64 no_modem_stop_waiting()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 116LL, "] ", "no_modem_stop_waiting", ":");
lprintf(3LL, "%s: stop_waiting called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func5()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 116LL, "] ", "no_modem_stop_waiting", ":");
lprintf(3LL, "%s: stop_waiting called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_stop_waiting(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 116, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_waiting called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_stop_waiting()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 116, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_waiting called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_stop_recording()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 110LL, "] ", "no_modem_stop_recording", ":");
lprintf(3LL, "%s: stop_recording called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func6()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 110LL, "] ", "no_modem_stop_recording", ":");
lprintf(3LL, "%s: stop_recording called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_stop_recording(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 110, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_recording called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_stop_recording()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 110, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_recording called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_stop_playing()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 104LL, "] ", "no_modem_stop_playing", ":");
lprintf(3LL, "%s: stop_playing called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func7()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 104LL, "] ", "no_modem_stop_playing", ":");
lprintf(3LL, "%s: stop_playing called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_stop_playing(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 104, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_playing called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_stop_playing()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 104, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_playing called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_stop_dialing()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 98LL, "] ", "no_modem_stop_dialing", ":");
lprintf(3LL, "%s: stop_dialing called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func8()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 98LL, "] ", "no_modem_stop_dialing", ":");
lprintf(3LL, "%s: stop_dialing called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_stop_dialing(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 98, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_dialing called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_stop_dialing()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 98, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_dialing called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_set_device()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 92LL, "] ", "no_modem_set_device", ":");
lprintf(3LL, "%s: set_device called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func9()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 92LL, "] ", "no_modem_set_device", ":");
lprintf(3LL, "%s: set_device called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_set_device(int device)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 92, "] ", __FUNCTION__, ":"); lprintf(3, "%s: set_device called", POS);
     return((-1));
     }

variable_types: device int


decompiled_code:
__int64 no_modem_set_compression()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 86LL, "] ", "no_modem_set_compression", ":");
lprintf(3LL, "%s: set_compression called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func10()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 86LL, "] ", "no_modem_set_compression", ":");
lprintf(3LL, "%s: set_compression called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_set_compression(p_int *compression, p_int *speed, int *bits)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 86, "] ", __FUNCTION__, ":"); lprintf(3, "%s: set_compression called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_set_compression(long *compression, long *speed, int *bits)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 86, "] ", __FUNCTION__, ":"); lprintf(3, "%s: set_compression called", POS);
     return((-1));
     }

variable_types:
compression
long *

variable_types:
speed
long *

variable_types:
bits
int *


decompiled_code:
__int64 no_modem_stop_play_file()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 68LL, "] ", "no_modem_stop_play_file", ":");
lprintf(3LL, "%s: stop_play_file called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func13()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 68LL, "] ", "no_modem_stop_play_file", ":");
lprintf(3LL, "%s: stop_play_file called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_stop_play_file(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 68, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_play_file called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_stop_play_file()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 68, "] ", __FUNCTION__, ":"); lprintf(3, "%s: stop_play_file called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_reset_play_file()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 62LL, "] ", "no_modem_reset_play_file", ":");
lprintf(3LL, "%s: next_play_file called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func14()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 62LL, "] ", "no_modem_reset_play_file", ":");
lprintf(3LL, "%s: next_play_file called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_reset_play_file(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 62, "] ", __FUNCTION__, ":"); lprintf(3, "%s: next_play_file called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_reset_play_file()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 62, "] ", __FUNCTION__, ":"); lprintf(3, "%s: next_play_file called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_start_play_file()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 56LL, "] ", "no_modem_start_play_file", ":");
lprintf(3LL, "%s: start_play_file called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func15()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 56LL, "] ", "no_modem_start_play_file", ":");
lprintf(3LL, "%s: start_play_file called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_start_play_file(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 56, "] ", __FUNCTION__, ":"); lprintf(3, "%s: start_play_file called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_start_play_file()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 56, "] ", __FUNCTION__, ":"); lprintf(3, "%s: start_play_file called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_message_light_on()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 50LL, "] ", "no_modem_message_light_on", ":");
lprintf(3LL, "%s: message_light_on called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func16()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 50LL, "] ", "no_modem_message_light_on", ":");
lprintf(3LL, "%s: message_light_on called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_message_light_on(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 50, "] ", __FUNCTION__, ":"); lprintf(3, "%s: message_light_on called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_message_light_on()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 50, "] ", __FUNCTION__, ":"); lprintf(3, "%s: message_light_on called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_message_light_off()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 44LL, "] ", "no_modem_message_light_off", ":");
lprintf(3LL, "%s: message_light_off called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func17()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 44LL, "] ", "no_modem_message_light_off", ":");
lprintf(3LL, "%s: message_light_off called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_message_light_off(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 44, "] ", __FUNCTION__, ":"); lprintf(3, "%s: message_light_off called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_message_light_off()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 44, "] ", __FUNCTION__, ":"); lprintf(3, "%s: message_light_off called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_init()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 38LL, "] ", "no_modem_init", ":");
lprintf(3LL, "%s: init called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func18()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 38LL, "] ", "no_modem_init", ":");
lprintf(3LL, "%s: init called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_init(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 38, "] ", __FUNCTION__, ":"); lprintf(3, "%s: init called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_init()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 38, "] ", __FUNCTION__, ":"); lprintf(3, "%s: init called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_handle_dle()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 32LL, "] ", "no_modem_handle_dle", ":");
lprintf(3LL, "%s: handle_dle called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func19()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 32LL, "] ", "no_modem_handle_dle", ":");
lprintf(3LL, "%s: handle_dle called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_handle_dle(char data)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 32, "] ", __FUNCTION__, ":"); lprintf(3, "%s: handle_dle called", POS);
     return((-1));
     }

variable_types: data char


decompiled_code:
__int64 no_modem_dial()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 26LL, "] ", "no_modem_dial", ":");
lprintf(3LL, "%s: dial called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func20()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 26LL, "] ", "no_modem_dial", ":");
lprintf(3LL, "%s: dial called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_dial(char *number)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 26, "] ", __FUNCTION__, ":"); lprintf(3, "%s: dial called", POS);
     return((-1));
     }


decompiled_code:
__int64 no_modem_beep()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 20LL, "] ", "no_modem_beep", ":");
lprintf(3LL, "%s: beep called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func21()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 20LL, "] ", "no_modem_beep", ":");
lprintf(3LL, "%s: beep called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_beep(int frequency, int length)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 20, "] ", __FUNCTION__, ":"); lprintf(3, "%s: beep called", POS);
     return((-1));
     }

variable_types: frequency int

variable_types: length int


decompiled_code:
__int64 no_modem_answer_phone()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 14LL, "] ", "no_modem_answer_phone", ":");
lprintf(3LL, "%s: answer_phone called", &POS);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func22()
{
sprintf(&POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 14LL, "] ", "no_modem_answer_phone", ":");
lprintf(3LL, "%s: answer_phone called", &POS);
return 0xFFFFFFFFLL;
}

original_code:
static int no_modem_answer_phone(void)
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 14, "] ", __FUNCTION__, ":"); lprintf(3, "%s: answer_phone called", POS);
     return((-1));
     }

canonical_original_code:
static int no_modem_answer_phone()
     {
     sprintf(POS, "%s%s%03d%s%s%s", "no_modem.c", " [", 14, "] ", __FUNCTION__, ":"); lprintf(3, "%s: answer_phone called", POS);
     return((-1));
     }


decompiled_code:
char *__fastcall event_name(unsigned int a1)
{
int *v1; // rdx
char v2; // si
int v3; // eax
int v4; // ecx

v1 = (int *)&unk_1038;
v2 = 0;
v3 = 0x2000;
v4 = 0;
i_1 = 0;
while ( a1 != v3 )
{
v3 = *v1;
v1 += 4;
++v4;
v2 = 1;
if ( !v3 )
{
i_1 = v4;
sprintf(tmp_string_0, "0x%04x", a1);
return tmp_string_0;
}
}
if ( v2 )
i_1 = v4;
return (&event_names)[2 * v4];
}

canonical_decompiled_code:
char *__fastcall func0(unsigned int a1)
{
int *v1; // rdx
char v2; // si
int v3; // eax
int v4; // ecx

v1 = (int *)&unk_1038;
v2 = 0;
v3 = 0x2000;
v4 = 0;
i_1 = 0;
while ( a1 != v3 )
{
v3 = *v1;
v1 += 4;
++v4;
v2 = 1;
if ( !v3 )
{
i_1 = v4;
sprintf(tmp_string_0, "0x%04x", a1);
return tmp_string_0;
}
}
if ( v2 )
i_1 = v4;
return (&event_names)[2 * v4];
}

original_code:
char *event_name(int event)
     {
     static int i = 0;
     static char tmp_string[10];
     for (i = 0; (event_names[i].number != 0); i++)
          if (event_names[i].number == event)
               return(event_names[i].name);
     sprintf(tmp_string, "0x%04x", event);
     return(tmp_string);
     }

variable_types: event int

variable_types: i int

return_type: char *


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

switch ( voice_modem_state )
{
case 0:
result = (*(__int64 (**)(void))(voice_modem + 384LL))();
break;
case 5:
result = (*(__int64 (**)(void))(voice_modem + 392LL))();
break;
case 6:
result = (*(__int64 (**)(void))(voice_modem + 400LL))();
break;
case 7:
result = (*(__int64 (**)(void))(voice_modem + 408LL))();
break;
case 8:
result = (*(__int64 (**)(void))(voice_modem + 472LL))();
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( voice_modem_state )
{
case 0:
result = (*(__int64 (**)(void))(voice_modem + 384LL))();
break;
case 5:
result = (*(__int64 (**)(void))(voice_modem + 392LL))();
break;
case 6:
result = (*(__int64 (**)(void))(voice_modem + 400LL))();
break;
case 7:
result = (*(__int64 (**)(void))(voice_modem + 408LL))();
break;
case 8:
result = (*(__int64 (**)(void))(voice_modem + 472LL))();
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
int voice_stop_current_action(void)
     {
     switch (voice_modem_state)
          {
          case (0x0000):
               return(voice_modem->stop_dialing());
          case (0x0005):
               return(voice_modem->stop_playing());
          case (0x0006):
               return(voice_modem->stop_recording());
          case (0x0007):
               return(voice_modem->stop_waiting());
   case (0x0008):
     return(voice_modem->stop_duplex_voice());
          };
     return((0));
     }

canonical_original_code:
int voice_stop_current_action()
     {
     switch (voice_modem_state)
          {
          case (0x0000):
               return(voice_modem->stop_dialing());
          case (0x0005):
               return(voice_modem->stop_playing());
          case (0x0006):
               return(voice_modem->stop_recording());
          case (0x0007):
               return(voice_modem->stop_waiting());
   case (0x0008):
     return(voice_modem->stop_duplex_voice());
          };
     return((0));
     }