decompiled_code:
__int64 __fastcall Dr_Neuhaus_set_device(int a1)
{
reset_watchdog();
if ( a1 == 4 )
{
voice_command("AT+VLS=14", &unk_5A9);
return 0LL;
}
if ( a1 > 4 )
{
if ( a1 == 6 )
{
voice_command("AT+VLS=4", &unk_5A9);
return 0LL;
}
goto LABEL_9;
}
if ( a1 != 1 )
{
if ( a1 == 2 )
{
voice_command("AT+VLS=2", &unk_5A9);
return 0LL;
}
LABEL_9:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, (unsigned int)a1);
return 0xFFFFFFFFLL;
}
voice_command("AT+VLS=0", &unk_5A9);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
reset_watchdog();
if ( a1 == 4 )
{
voice_command("AT+VLS=14", &unk_5A9);
return 0LL;
}
if ( a1 > 4 )
{
if ( a1 == 6 )
{
voice_command("AT+VLS=4", &unk_5A9);
return 0LL;
}
goto LABEL_9;
}
if ( a1 != 1 )
{
if ( a1 == 2 )
{
voice_command("AT+VLS=2", &unk_5A9);
return 0LL;
}
LABEL_9:
lprintf(3LL, "%s: Unknown output device (%d)", (const char *)*voice_modem, (unsigned int)a1);
return 0xFFFFFFFFLL;
}
voice_command("AT+VLS=0", &unk_5A9);
return 0LL;
}

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

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


repo: Distrotech/mgetty

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

reset_watchdog();
if ( !*a1 )
*a1 = 129LL;
v4 = *a2;
if ( *a2 )
{
if ( v4 != 8000 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 8000LL;
}
v5 = *a1;
if ( *a1 == 129 )
{
*a3 = 2;
v7 = "AT+VSM=129";
}
else if ( v5 == 130 )
{
*a3 = 3;
v7 = "AT+VSM=130";
}
else
{
if ( v5 != 128 )
{
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v5);
return 0xFFFFFFFFLL;
}
*a3 = 8;
v7 = "AT+VSM=128";
}
return (unsigned int)-((unsigned int)voice_command(v7, &unk_5A9) != 4096);
}

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

reset_watchdog();
if ( !*a1 )
*a1 = 129LL;
v4 = *a2;
if ( *a2 )
{
if ( v4 != 8000 )
{
lprintf(3LL, "%s: Illegal sample rate (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 8000LL;
}
v5 = *a1;
if ( *a1 == 129 )
{
*a3 = 2;
v7 = "AT+VSM=129";
}
else if ( v5 == 130 )
{
*a3 = 3;
v7 = "AT+VSM=130";
}
else
{
if ( v5 != 128 )
{
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v5);
return 0xFFFFFFFFLL;
}
*a3 = 8;
v7 = "AT+VSM=128";
}
return (unsigned int)-((unsigned int)voice_command(v7, &unk_5A9) != 4096);
}

original_code:
static int Dr_Neuhaus_set_compression (p_int *compression, p_int *speed, int *bits)
     {
     reset_watchdog();
     if (*compression == 0)
          *compression = 129;
     if (*speed == 0)
          *speed = 8000;
     if (*speed != 8000)
          {
          lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name,
           *speed);
          return((-1));
          };
     switch (*compression)
          {
          case 128:
               *bits = 8;
               if (voice_command("AT+VSM=128", "OK") != (0x1000))
                    return((-1));
               break;
          case 129:
               *bits = 2;
               if (voice_command("AT+VSM=129", "OK") != (0x1000))
                    return((-1));
               break;
          case 130:
               *bits = 3;
               if (voice_command("AT+VSM=130", "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 Dr_Neuhaus_set_compression(long *compression, long *speed, int *bits)
     {
     reset_watchdog();
     if (*compression == 0)
          *compression = 129;
     if (*speed == 0)
          *speed = 8000;
     if (*speed != 8000)
          {
          lprintf(3, "%s: Illegal sample rate (%d)", voice_modem->name,
           *speed);
          return((-1));
          };
     switch (*compression)
          {
          case 128:
               *bits = 8;
               if (voice_command("AT+VSM=128", "OK") != (0x1000))
                    return((-1));
               break;
          case 129:
               *bits = 2;
               if (voice_command("AT+VSM=129", "OK") != (0x1000))
                    return((-1));
               break;
          case 130:
               *bits = 3;
               if (voice_command("AT+VSM=130", "OK") != (0x1000))
                    return((-1));
               break;
          default:
               lprintf(3, "%s: Illegal voice compression method (%d)",
                voice_modem->name, *compression);
               return((-1));
          };
     return((0));
     }

variable_types:
compression
long *

variable_types:
speed
long *

variable_types:
bits
int *

return_type: int


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

reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing Dr. Neuhaus voice modem");
sprintf(v5, "AT+VSD=%d,%d", (unsigned int)((int)*((_QWORD *)&cvd + 58) / 10 + 123), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v5, &unk_5A9) != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v0 = *((_QWORD *)&cvd + 82);
if ( v0 == -1 )
{
*((_QWORD *)&cvd + 82) = 100LL;
v1 = 133LL;
}
else
{
v1 = (unsigned int)((int)v0 / 10 + 123);
}
sprintf(v5, "AT+VGT=%d", v1);
if ( (unsigned int)voice_command(v5, &unk_5A9) != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v2 = *((_QWORD *)&cvd + 79);
if ( v2 == -1 )
{
*((_QWORD *)&cvd + 79) = 40LL;
v3 = 127LL;
}
else
{
v3 = (unsigned int)((int)v2 / 10 + 123);
}
sprintf(v5, "AT+VGR=%d", v3);
if ( (unsigned int)voice_command(v5, &unk_5A9) != 4096 )
lprintf(3LL, "setting receive gain didn't work");
if ( (unsigned int)voice_command("AT+VIT=0", &unk_5A9) != 4096 )
lprintf(3LL, "can't deactivate inactivity timer");
if ( (unsigned int)voice_command("AT+VPR=0", &unk_5A9) != 4096 )
lprintf(3LL, "can't select autobauding");
if ( (unsigned int)voice_command("AT+VLS=0", &unk_5A9) != 4096 )
lprintf(3LL, "can't deselect all input/output devices");
voice_modem_state = 1;
return 0LL;
}

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

reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing Dr. Neuhaus voice modem");
sprintf(v5, "AT+VSD=%d,%d", (unsigned int)((int)*((_QWORD *)&cvd + 58) / 10 + 123), *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(v5, &unk_5A9) != 4096 )
lprintf(3LL, "setting recording preferences didn't work");
v0 = *((_QWORD *)&cvd + 82);
if ( v0 == -1 )
{
*((_QWORD *)&cvd + 82) = 100LL;
v1 = 133LL;
}
else
{
v1 = (unsigned int)((int)v0 / 10 + 123);
}
sprintf(v5, "AT+VGT=%d", v1);
if ( (unsigned int)voice_command(v5, &unk_5A9) != 4096 )
lprintf(3LL, "setting transmit gain didn't work");
v2 = *((_QWORD *)&cvd + 79);
if ( v2 == -1 )
{
*((_QWORD *)&cvd + 79) = 40LL;
v3 = 127LL;
}
else
{
v3 = (unsigned int)((int)v2 / 10 + 123);
}
sprintf(v5, "AT+VGR=%d", v3);
if ( (unsigned int)voice_command(v5, &unk_5A9) != 4096 )
lprintf(3LL, "setting receive gain didn't work");
if ( (unsigned int)voice_command("AT+VIT=0", &unk_5A9) != 4096 )
lprintf(3LL, "can't deactivate inactivity timer");
if ( (unsigned int)voice_command("AT+VPR=0", &unk_5A9) != 4096 )
lprintf(3LL, "can't select autobauding");
if ( (unsigned int)voice_command("AT+VLS=0", &unk_5A9) != 4096 )
lprintf(3LL, "can't deselect all input/output devices");
voice_modem_state = 1;
return 0LL;
}

original_code:
static int Dr_Neuhaus_init (void)
     {
     char buffer[(256)];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing Dr. Neuhaus 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 = 100;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 10 / 100 + 123);
     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 = 40;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 10 / 100 + 123);
     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 Dr_Neuhaus_init()
     {
     char buffer[-1];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing Dr. Neuhaus 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 = 100;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 10 / 100 + 123);
     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 = 40;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 10 / 100 + 123);
     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));
     }

variable_types:
buffer
char [-1]


decompiled_code:
__int64 Cirrus_Logic_answer_phone()
{
__int64 result; // rax
int v1; // er8

reset_watchdog();
lprintf(4LL, "Answering Call");
if ( (unsigned int)voice_command("AT#VLN=1", "OK") != 4096
|| (v1 = voice_command("AT#VIP=1", "OK"), result = 8202LL, v1 != 4096) )
{
result = 8195LL;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
int v1; // er8

reset_watchdog();
lprintf(4LL, "Answering Call");
if ( (unsigned int)voice_command("AT#VLN=1", "OK") != 4096
|| (v1 = voice_command("AT#VIP=1", "OK"), result = 8202LL, v1 != 4096) )
{
result = 8195LL;
}
return result;
}

original_code:
int Cirrus_Logic_answer_phone (void)
     {
     reset_watchdog();
     lprintf(4, "Answering Call");
     if (voice_command("AT#VLN=1", "OK") != (0x1000))
          return((0x2003));
     if (voice_command("AT#VIP=1", "OK") != (0x1000))
          return((0x2003));
     return((0x200a));
     }

canonical_original_code:
int Cirrus_Logic_answer_phone()
     {
     reset_watchdog();
     lprintf(4, "Answering Call");
     if (voice_command("AT#VLN=1", "OK") != (0x1000))
          return((0x2003));
     if (voice_command("AT#VIP=1", "OK") != (0x1000))
          return((0x2003));
     return((0x200a));
     }


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

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

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

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

original_code:
int Cirrus_Logic_set_device (int device)
     {
     reset_watchdog();
     lprintf(4, "Setting device");
     switch (device)
          {
          case (0x0001):
               voice_command("AT#VLN=0", "OK");
               return((0));
          case (0x0002):
               voice_command("AT#VLN=1", "OK");
               return((0));
          case (0x0003):
               voice_command("AT#VLN=32", "OK");
               return((0));
          case (0x0006):
               voice_command("AT#VLN=16", "OK");
               return((0));
          case (0x0007):
               voice_command("AT#VLN=2","OK");
               return((0));
          }
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }

canonical_original_code:
int Cirrus_Logic_set_device(int device)
     {
     reset_watchdog();
     lprintf(4, "Setting device");
     switch (device)
          {
          case (0x0001):
               voice_command("AT#VLN=0", "OK");
               return((0));
          case (0x0002):
               voice_command("AT#VLN=1", "OK");
               return((0));
          case (0x0003):
               voice_command("AT#VLN=32", "OK");
               return((0));
          case (0x0006):
               voice_command("AT#VLN=16", "OK");
               return((0));
          case (0x0007):
               voice_command("AT#VLN=2","OK");
               return((0));
          }
     lprintf(3, "%s: Unknown output device (%d)", voice_modem->name,
      device);
     return((-1));
     }

variable_types: device int


decompiled_code:
__int64 __fastcall Cirrus_Logic_set_compression(_QWORD *a1, __int64 *a2, _DWORD *a3)
{
__int64 v4; // rcx
__int64 result; // rax

lprintf(4LL, "Setting compression");
reset_watchdog();
if ( !*a1 )
*a1 = 1LL;
v4 = *a2;
if ( *a2 )
{
if ( v4 != 9600 )
{
lprintf(3LL, "%s: Illegal sample speed (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 9600LL;
}
voice_command("AT#VSR=9600", "OK");
if ( *a1 == 3LL )
{
voice_command("AT#VSM=AD3", "OK");
*a3 = 3;
result = 0LL;
}
else
{
if ( *a1 == 4LL )
{
voice_command("AT#VSM=AD4", "OK");
*a3 = 4;
}
else
{
voice_command("AT#VSM=CL1", "OK");
*a3 = 5;
}
result = 0LL;
}
return result;
}

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

lprintf(4LL, "Setting compression");
reset_watchdog();
if ( !*a1 )
*a1 = 1LL;
v4 = *a2;
if ( *a2 )
{
if ( v4 != 9600 )
{
lprintf(3LL, "%s: Illegal sample speed (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 9600LL;
}
voice_command("AT#VSR=9600", "OK");
if ( *a1 == 3LL )
{
voice_command("AT#VSM=AD3", "OK");
*a3 = 3;
result = 0LL;
}
else
{
if ( *a1 == 4LL )
{
voice_command("AT#VSM=AD4", "OK");
*a3 = 4;
}
else
{
voice_command("AT#VSM=CL1", "OK");
*a3 = 5;
}
result = 0LL;
}
return result;
}

original_code:
static int Cirrus_Logic_set_compression (p_int *compression, p_int *speed,
 int *bits)
     {
     lprintf(4, "Setting compression");
     reset_watchdog();
     if (*compression == 0)
          *compression = 1;
     if (*speed == 0)
          *speed = 9600;
     if (*speed != 9600)
          {
          lprintf(3, "%s: Illegal sample speed (%d)",
           voice_modem->name, *speed);
          return((-1));
          }
     voice_command("AT#VSR=9600", "OK");
     switch (*compression)
          {
          case 3:
               voice_command("AT#VSM=AD3", "OK");
               *bits = 3;
               return((0));
          case 4:
               voice_command("AT#VSM=AD4", "OK");
               *bits = 4;
               return((0));
          default:
               voice_command("AT#VSM=CL1", "OK");
               *bits = 5;
               return((0));
          }
     return((0));
     }

canonical_original_code:
static int Cirrus_Logic_set_compression(long *compression, long *speed, int *bits)
     {
     lprintf(4, "Setting compression");
     reset_watchdog();
     if (*compression == 0)
          *compression = 1;
     if (*speed == 0)
          *speed = 9600;
     if (*speed != 9600)
          {
          lprintf(3, "%s: Illegal sample speed (%d)",
           voice_modem->name, *speed);
          return((-1));
          }
     voice_command("AT#VSR=9600", "OK");
     switch (*compression)
          {
          case 3:
               voice_command("AT#VSM=AD3", "OK");
               *bits = 3;
               return((0));
          case 4:
               voice_command("AT#VSM=AD4", "OK");
               *bits = 4;
               return((0));
          default:
               voice_command("AT#VSM=CL1", "OK");
               *bits = 5;
               return((0));
          }
     return((0));
     }


decompiled_code:
__int64 __fastcall Cirrus_Logic_switch_to_data_fax(const char *a1)
{
char v2[264]; // [rsp+0h] [rbp-108h] BYREF

lprintf(4LL, "Switching to data/fax");
reset_watchdog();
sprintf(v2, "AT+FCLASS=%s", a1);
return (unsigned int)-((unsigned int)voice_command(v2, "OK") != 4096);
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
char v2[264]; // [rsp+0h] [rbp-108h] BYREF

lprintf(4LL, "Switching to data/fax");
reset_watchdog();
sprintf(v2, "AT+FCLASS=%s", a1);
return (unsigned int)-((unsigned int)voice_command(v2, "OK") != 4096);
}

original_code:
int Cirrus_Logic_switch_to_data_fax (char *mode)
     {
     char buffer[(256)];
     lprintf(4, "Switching to data/fax");
     reset_watchdog();
     sprintf(buffer, "AT+FCLASS=%s", mode);
     if (voice_command(buffer, "OK") != (0x1000))
          return((-1));
     return((0));
     }

canonical_original_code:
int Cirrus_Logic_switch_to_data_fax(char *mode)
     {
     char buffer[-1];
     lprintf(4, "Switching to data/fax");
     reset_watchdog();
     sprintf(buffer, "AT+FCLASS=%s", mode);
     if (voice_command(buffer, "OK") != (0x1000))
          return((-1));
     return((0));
     }

variable_types:
mode
char *


decompiled_code:
__int64 Cirrus_Logic_beep()
{
__int64 v0; // rbx
__int64 v1; // rdi
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

reset_watchdog();
strcpy(v3, "AT#VBP");
lprintf(4LL, "Checking Beep");
if ( (unsigned int)voice_command(v3, &unk_B29) )
return 0xFFFFFFFFLL;
LODWORD(v0) = 0;
while ( !(unsigned __int8)check_for_input(voice_fd) )
{
if ( (int)v0 > 0 )
{
v1 = cvd[88];
LODWORD(v0) = v0 - 1;
}
else
{
reset_watchdog();
v1 = cvd[88];
v0 = 1000LL * cvd[76] / v1 / 2;
}
delay(v1);
}
return (unsigned int)-((unsigned int)voice_command(&unk_B29, "OK") != 4096);
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx
__int64 v1; // rdi
char v3[264]; // [rsp+0h] [rbp-108h] BYREF

reset_watchdog();
strcpy(v3, "AT#VBP");
lprintf(4LL, "Checking Beep");
if ( (unsigned int)voice_command(v3, &unk_B29) )
return 0xFFFFFFFFLL;
LODWORD(v0) = 0;
while ( !(unsigned __int8)check_for_input(voice_fd) )
{
if ( (int)v0 > 0 )
{
v1 = cvd[88];
LODWORD(v0) = v0 - 1;
}
else
{
reset_watchdog();
v1 = cvd[88];
v0 = 1000LL * cvd[76] / v1 / 2;
}
delay(v1);
}
return (unsigned int)-((unsigned int)voice_command(&unk_B29, "OK") != 4096);
}

original_code:
int Cirrus_Logic_beep (int frequency, int length)
     {
     char buffer[(256)];
     int watchdog_count = 0;
     reset_watchdog();
     sprintf(buffer, "AT#VBP");
     lprintf(4, "Checking Beep");
     if (voice_command(buffer, "") != (0))
          return((-1));
     while (!check_for_input(voice_fd))
          {
          if ((watchdog_count--) <= 0)
               {
               reset_watchdog();
               watchdog_count = cvd.watchdog_timeout.d.i * 1000 /
                cvd.poll_interval.d.i / 2;
               }
          delay(cvd.poll_interval.d.i);
          }
     if (voice_command("", "OK") != (0x1000))
          return((-1));
     return((0));
     }

canonical_original_code:
int Cirrus_Logic_beep(int frequency, int length)
     {
     char buffer[-1];
     int watchdog_count = 0;
     reset_watchdog();
     sprintf(buffer, "AT#VBP");
     lprintf(4, "Checking Beep");
     if (voice_command(buffer, "") != (0))
          return((-1));
     while (!check_for_input(voice_fd))
          {
          if ((watchdog_count--) <= 0)
               {
               reset_watchdog();
               watchdog_count = cvd.watchdog_timeout.d.i * 1000 /
                cvd.poll_interval.d.i / 2;
               }
          delay(cvd.poll_interval.d.i);
          }
     if (voice_command("", "OK") != (0x1000))
          return((-1));
     return((0));
     }

variable_types: frequency int

variable_types: length int


decompiled_code:
__int64 Cirrus_Logic_init()
{
__int64 v0; // rdx
int v1; // eax
int v2; // ecx
__int64 v3; // rdx
int v4; // eax
int v5; // ecx
__int64 result; // rax
__int64 v7; // [rsp+8h] [rbp-160h] BYREF
__int64 v8; // [rsp+10h] [rbp-158h] BYREF
__int64 v9; // [rsp+18h] [rbp-150h] BYREF
char v10[64]; // [rsp+20h] [rbp-148h] BYREF
char s[264]; // [rsp+60h] [rbp-108h] BYREF

v7 = 0LL;
v8 = 0LL;
v9 = 0LL;
reset_watchdog();
lprintf(4LL, "Initializing Cirrus Logic voice modem");
voice_modem_state = 2;
voice_command("AT#VRL=?", &unk_B29);
voice_read(&cirrus_logic_ans);
voice_flush(1LL);
get_range_constprop_0((__int64)&v8);
v0 = cvd[79];
v1 = HIDWORD(v8);
v2 = v8;
if ( v0 == -1 )
{
LODWORD(v0) = (HIDWORD(v8) + (int)v8) / 2;
cvd[79] = (int)v0;
}
sprintf(s, "AT#VRL=%.0f", (double)((int)v0 * (v1 - v2)) / 100.0 + (double)v2);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set recording volume");
voice_command("AT#VPL=?", &unk_B29);
voice_read(&cirrus_logic_ans);
voice_flush(1LL);
get_range_constprop_0((__int64)&v7);
v3 = cvd[82];
v4 = HIDWORD(v7);
v5 = v7;
if ( v3 == -1 )
{
LODWORD(v3) = (HIDWORD(v7) + (int)v7) / 2;
cvd[82] = (int)v3;
}
sprintf(s, "AT#VPL=%.0f", (double)((int)v3 * (v4 - v5)) / 100.0 + (double)v5);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set play volume");
if ( cvd[58] > 0x64uLL )
{
lprintf(3LL, "Invalid threshold value.");
result = 0xFFFFFFFFLL;
}
else
{
voice_command("AT#VSL=?", &unk_B29);
voice_read(&cirrus_logic_ans);
voice_flush(1LL);
get_range_constprop_0((__int64)&v9);
sprintf(s, "AT#VSL=%.0f", (double)(int)(cvd[58] * (HIDWORD(v9) - v9)) / 100.0 + (double)(int)v9);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence threshold");
sprintf(s, "AT#VSQT=%1u", LODWORD(cvd[55]));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence period record mode");
sprintf(s, "AT#VSST=%1u", LODWORD(cvd[55]));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence period record and command mode");
if ( (unsigned int)voice_command("AT\\Q3", "OK") == 4096 )
{
tio_get(voice_fd, v10);
tio_set_flow_control(voice_fd, v10, 1LL);
tio_set(voice_fd, v10);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rdx
int v1; // eax
int v2; // ecx
__int64 v3; // rdx
int v4; // eax
int v5; // ecx
__int64 result; // rax
__int64 v7; // [rsp+8h] [rbp-160h] BYREF
__int64 v8; // [rsp+10h] [rbp-158h] BYREF
__int64 v9; // [rsp+18h] [rbp-150h] BYREF
char v10[64]; // [rsp+20h] [rbp-148h] BYREF
char s[264]; // [rsp+60h] [rbp-108h] BYREF

v7 = 0LL;
v8 = 0LL;
v9 = 0LL;
reset_watchdog();
lprintf(4LL, "Initializing Cirrus Logic voice modem");
voice_modem_state = 2;
voice_command("AT#VRL=?", &unk_B29);
voice_read(&cirrus_logic_ans);
voice_flush(1LL);
func5((__int64)&v8);
v0 = cvd[79];
v1 = HIDWORD(v8);
v2 = v8;
if ( v0 == -1 )
{
LODWORD(v0) = (HIDWORD(v8) + (int)v8) / 2;
cvd[79] = (int)v0;
}
sprintf(s, "AT#VRL=%.0f", (double)((int)v0 * (v1 - v2)) / 100.0 + (double)v2);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set recording volume");
voice_command("AT#VPL=?", &unk_B29);
voice_read(&cirrus_logic_ans);
voice_flush(1LL);
func5((__int64)&v7);
v3 = cvd[82];
v4 = HIDWORD(v7);
v5 = v7;
if ( v3 == -1 )
{
LODWORD(v3) = (HIDWORD(v7) + (int)v7) / 2;
cvd[82] = (int)v3;
}
sprintf(s, "AT#VPL=%.0f", (double)((int)v3 * (v4 - v5)) / 100.0 + (double)v5);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set play volume");
if ( cvd[58] > 0x64uLL )
{
lprintf(3LL, "Invalid threshold value.");
result = 0xFFFFFFFFLL;
}
else
{
voice_command("AT#VSL=?", &unk_B29);
voice_read(&cirrus_logic_ans);
voice_flush(1LL);
func5((__int64)&v9);
sprintf(s, "AT#VSL=%.0f", (double)(int)(cvd[58] * (HIDWORD(v9) - v9)) / 100.0 + (double)(int)v9);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence threshold");
sprintf(s, "AT#VSQT=%1u", LODWORD(cvd[55]));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence period record mode");
sprintf(s, "AT#VSST=%1u", LODWORD(cvd[55]));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence period record and command mode");
if ( (unsigned int)voice_command("AT\\Q3", "OK") == 4096 )
{
tio_get(voice_fd, v10);
tio_set_flow_control(voice_fd, v10, 1LL);
tio_set(voice_fd, v10);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
result = 0LL;
}
return result;
}

original_code:
int Cirrus_Logic_init (void)
     {
     char buffer[(256)];
     range play_range = {0, 0};
     range rec_range = {0, 0};
     range rec_silence_threshold = {0, 0};
     reset_watchdog();
     lprintf(4, "Initializing Cirrus Logic voice modem");
     voice_modem_state = (0x0002);
     voice_command("AT#VRL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &rec_range);
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = (rec_range.max + rec_range.min) / 2;
     sprintf(buffer, "AT#VRL=%.0f", rec_range.min + ((rec_range.max -
      rec_range.min) * cvd.receive_gain.d.i / 100.0));
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set recording volume");
     voice_command("AT#VPL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &play_range);
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = (play_range.max + play_range.min) / 2;
     sprintf(buffer, "AT#VPL=%.0f", play_range.min + ((play_range.max -
      play_range.min) * cvd.transmit_gain.d.i / 100.0));
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set play volume");
     if ((cvd.rec_silence_threshold.d.i > 100) ||
        (cvd.rec_silence_threshold.d.i < 0))
          {
          lprintf(3, "Invalid threshold value.");
          return(-1);
          }
     voice_command("AT#VSL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &rec_silence_threshold);
     sprintf(buffer, "AT#VSL=%.0f", rec_silence_threshold.min +
      ((rec_silence_threshold.max - rec_silence_threshold.min) *
      cvd.rec_silence_threshold.d.i / 100.0));
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence threshold");
     sprintf(buffer, "AT#VSQT=%1u", (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence period record mode");
     sprintf(buffer, "AT#VSST=%1u", (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence period record and command mode");
     if (voice_command("AT\\Q3", "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:
int Cirrus_Logic_init()
     {
     char buffer[-1];
     struct range play_range = {0, 0};
     struct range rec_range = {0, 0};
     struct range rec_silence_threshold = {0, 0};
     reset_watchdog();
     lprintf(4, "Initializing Cirrus Logic voice modem");
     voice_modem_state = (0x0002);
     voice_command("AT#VRL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &rec_range);
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = (rec_range.max + rec_range.min) / 2;
     sprintf(buffer, "AT#VRL=%.0f", rec_range.min + ((rec_range.max -
      rec_range.min) * cvd.receive_gain.d.i / 100.0));
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set recording volume");
     voice_command("AT#VPL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &play_range);
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = (play_range.max + play_range.min) / 2;
     sprintf(buffer, "AT#VPL=%.0f", play_range.min + ((play_range.max -
      play_range.min) * cvd.transmit_gain.d.i / 100.0));
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set play volume");
     if ((cvd.rec_silence_threshold.d.i > 100) ||
        (cvd.rec_silence_threshold.d.i < 0))
          {
          lprintf(3, "Invalid threshold value.");
          return(-1);
          }
     voice_command("AT#VSL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &rec_silence_threshold);
     sprintf(buffer, "AT#VSL=%.0f", rec_silence_threshold.min +
      ((rec_silence_threshold.max - rec_silence_threshold.min) *
      cvd.rec_silence_threshold.d.i / 100.0));
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence threshold");
     sprintf(buffer, "AT#VSQT=%1u", (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence period record mode");
     sprintf(buffer, "AT#VSST=%1u", (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence period record and command mode");
     if (voice_command("AT\\Q3", "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: 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 Supra_switch_to_data_fax()
{
__int64 result; // rax

if ( (unsigned int)IS_101_switch_to_data_fax() )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-((unsigned int)voice_command("AT+FCLASS=2", &unk_808) != 4096);
return result;
}

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

if ( (unsigned int)IS_101_switch_to_data_fax() )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-((unsigned int)voice_command("AT+FCLASS=2", &unk_808) != 4096);
return result;
}

original_code:
static int Supra_switch_to_data_fax(char *mode)
     {
     if (IS_101_switch_to_data_fax(mode) != (0))
        return((-1));
     if (voice_command("AT+FCLASS=2", "OK") != (0x1000))
        return((-1));
     return((0));
     }


decompiled_code:
__int64 __fastcall Supra_set_device(int a1)
{
reset_watchdog();
if ( a1 == 4 )
{
lprintf(6LL, "%s: _INT_MIC: (%d)", (const char *)*voice_modem, 4LL);
voice_command("AT#VLS=9", "VCON");
return 0LL;
}
if ( a1 > 4 )
{
if ( a1 == 6 )
{
lprintf(6LL, "%s: _INT_SEAK: (%d)", (const char *)*voice_modem, 6LL);
voice_command("AT#VLS=3", "VCON");
return 0LL;
}
goto LABEL_9;
}
if ( a1 != 1 )
{
if ( a1 == 2 )
{
lprintf(6LL, "%s: _DIALUP: (%d)", (const char *)*voice_modem, 2LL);
voice_command("AT#VLS=4", &unk_808);
return 0LL;
}
LABEL_9:
lprintf(3LL, "%s: Unknown device (%d)", (const char *)*voice_modem, (unsigned int)a1);
return 0xFFFFFFFFLL;
}
lprintf(6LL, "%s: _NO_DEV: (%d)", (const char *)*voice_modem, 1LL);
voice_command("AT#VLS=0", &unk_808);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
reset_watchdog();
if ( a1 == 4 )
{
lprintf(6LL, "%s: _INT_MIC: (%d)", (const char *)*voice_modem, 4LL);
voice_command("AT#VLS=9", "VCON");
return 0LL;
}
if ( a1 > 4 )
{
if ( a1 == 6 )
{
lprintf(6LL, "%s: _INT_SEAK: (%d)", (const char *)*voice_modem, 6LL);
voice_command("AT#VLS=3", "VCON");
return 0LL;
}
goto LABEL_9;
}
if ( a1 != 1 )
{
if ( a1 == 2 )
{
lprintf(6LL, "%s: _DIALUP: (%d)", (const char *)*voice_modem, 2LL);
voice_command("AT#VLS=4", &unk_808);
return 0LL;
}
LABEL_9:
lprintf(3LL, "%s: Unknown device (%d)", (const char *)*voice_modem, (unsigned int)a1);
return 0xFFFFFFFFLL;
}
lprintf(6LL, "%s: _NO_DEV: (%d)", (const char *)*voice_modem, 1LL);
voice_command("AT#VLS=0", &unk_808);
return 0LL;
}

original_code:
static int Supra_set_device (int device)
     {
     reset_watchdog();
     switch (device)
          {
          case (0x0001):
               lprintf(6, "%s: _NO_DEV: (%d)", voice_modem->name, device);
               voice_command("AT#VLS=0", "OK");
               return((0));
          case (0x0002):
               lprintf(6, "%s: _DIALUP: (%d)", voice_modem->name, device);
               voice_command("AT#VLS=4", "OK");
        return((0));
          case (0x0004):
        lprintf(6, "%s: _INT_MIC: (%d)", voice_modem->name, device);
        voice_command("AT#VLS=9", "VCON");
        return((0));
          case (0x0006):
               lprintf(6, "%s: _INT_SEAK: (%d)", voice_modem->name, device);
        voice_command("AT#VLS=3", "VCON");
               return((0));
          }
     lprintf(3, "%s: Unknown device (%d)", voice_modem->name, device);
     return((-1));
     }

canonical_original_code:
static int Supra_set_device(int device)
     {
     reset_watchdog();
     switch (device)
          {
          case (0x0001):
               lprintf(6, "%s: _NO_DEV: (%d)", voice_modem->name, device);
               voice_command("AT#VLS=0", "OK");
               return((0));
          case (0x0002):
               lprintf(6, "%s: _DIALUP: (%d)", voice_modem->name, device);
               voice_command("AT#VLS=4", "OK");
        return((0));
          case (0x0004):
        lprintf(6, "%s: _INT_MIC: (%d)", voice_modem->name, device);
        voice_command("AT#VLS=9", "VCON");
        return((0));
          case (0x0006):
               lprintf(6, "%s: _INT_SEAK: (%d)", voice_modem->name, device);
        voice_command("AT#VLS=3", "VCON");
               return((0));
          }
     lprintf(3, "%s: Unknown device (%d)", voice_modem->name, device);
     return((-1));
     }


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

reset_watchdog();
if ( !*a1 )
*a1 = 2LL;
v4 = *a2;
if ( *a2 )
{
if ( v4 != 7200 && v4 != 11025 )
{
lprintf(3LL, "%s: Illegal sample speed (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 7200LL;
}
v5 = *a1;
if ( *a1 == 2 )
{
voice_command("AT#VBS=2", &unk_808);
*a3 = 2;
result = 0LL;
}
else if ( v5 == 3 )
{
voice_command("AT#VBS=3", &unk_808);
*a3 = 3;
result = 0LL;
}
else if ( v5 == 4 )
{
voice_command("AT#VBS=4", &unk_808);
*a3 = 4;
result = 0LL;
}
else
{
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v5);
result = 0xFFFFFFFFLL;
}
return result;
}

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

reset_watchdog();
if ( !*a1 )
*a1 = 2LL;
v4 = *a2;
if ( *a2 )
{
if ( v4 != 7200 && v4 != 11025 )
{
lprintf(3LL, "%s: Illegal sample speed (%d)", (const char *)*voice_modem, v4);
return 0xFFFFFFFFLL;
}
}
else
{
*a2 = 7200LL;
}
v5 = *a1;
if ( *a1 == 2 )
{
voice_command("AT#VBS=2", &unk_808);
*a3 = 2;
result = 0LL;
}
else if ( v5 == 3 )
{
voice_command("AT#VBS=3", &unk_808);
*a3 = 3;
result = 0LL;
}
else if ( v5 == 4 )
{
voice_command("AT#VBS=4", &unk_808);
*a3 = 4;
result = 0LL;
}
else
{
lprintf(3LL, "%s: Illegal voice compression method (%d)", (const char *)*voice_modem, v5);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int Supra_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 && *speed != 11025)
          {
          lprintf(3, "%s: Illegal sample speed (%d)",
           voice_modem->name, (int)*speed);
          return((-1));
          };
     if (*compression == 2)
          {
          voice_command("AT#VBS=2", "OK");
          *bits = 2;
          return((0));
          }
     if (*compression == 3)
          {
          voice_command("AT#VBS=3", "OK");
          *bits = 3;
          return((0));
          }
     if (*compression == 4)
          {
          voice_command("AT#VBS=4", "OK");
          *bits = 4;
          return((0));
          }
     lprintf(3, "%s: Illegal voice compression method (%d)",
      voice_modem->name, (int)*compression);
     return((-1));
     }

canonical_original_code:
static int Supra_set_compression(long *compression, long *speed, int *bits)
     {
     reset_watchdog();
     if (*compression == 0)
          *compression = 2;
     if (*speed == 0)
          *speed = 7200;
     if (*speed != 7200 && *speed != 11025)
          {
          lprintf(3, "%s: Illegal sample speed (%d)",
           voice_modem->name, (int)*speed);
          return((-1));
          };
     if (*compression == 2)
          {
          voice_command("AT#VBS=2", "OK");
          *bits = 2;
          return((0));
          }
     if (*compression == 3)
          {
          voice_command("AT#VBS=3", "OK");
          *bits = 3;
          return((0));
          }
     if (*compression == 4)
          {
          voice_command("AT#VBS=4", "OK");
          *bits = 4;
          return((0));
          }
     lprintf(3, "%s: Illegal voice compression method (%d)",
      voice_modem->name, (int)*compression);
     return((-1));
     }


decompiled_code:
__int64 Supra_init()
{
__int64 v0; // rax
__int64 v1; // rdx
_BYTE v3[64]; // [rsp+0h] [rbp-148h] BYREF
__m128i s[16]; // [rsp+40h] [rbp-108h] BYREF

reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing Supra 56e PRO voice modem");
sprintf((char *)s, "AT#VSP=%1u", *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set silence_len VSP");
strcpy((char *)s, "AT#VSD=0");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set VSD=0");
strcpy((char *)s, "AT#VBS=4");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set VBS=4");
strcpy((char *)s, "AT#BDR=16");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set BDR=16");
s[0] = _mm_load_si128((const __m128i *)&LC31);
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set VTD=3F");
sprintf((char *)s, "AT#VSS=%1u", (unsigned int)((int)(3 * *((_QWORD *)&cvd + 58)) / 100));
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set silence threshold VSS");
strcpy((char *)s, "ATS30=60");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set S30");
v0 = *((_QWORD *)&cvd + 82);
if ( v0 == -1 )
{
*((_QWORD *)&cvd + 82) = 50LL;
v1 = 129LL;
}
else
{
v1 = (unsigned int)(3 * (int)v0 / 100 + 128);
}
sprintf((char *)s, "AT#VGT=%d", v1);
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set speaker volume");
if ( *((_QWORD *)&cvd + 79) == -1LL )
*((_QWORD *)&cvd + 79) = 50LL;
(*(void (__fastcall **)(__int64))(voice_modem + 376LL))(2LL);
if ( *((_QWORD *)&cvd + 70) && (unsigned int)voice_command("AT&K3", &unk_808) == 4096 )
{
tio_get(voice_fd, v3);
tio_set_flow_control(voice_fd, v3, 1LL);
tio_set(voice_fd, v3);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rdx
_BYTE v3[64]; // [rsp+0h] [rbp-148h] BYREF
__m128i s[16]; // [rsp+40h] [rbp-108h] BYREF

reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing Supra 56e PRO voice modem");
sprintf((char *)s, "AT#VSP=%1u", *((unsigned int *)&cvd + 110));
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set silence_len VSP");
strcpy((char *)s, "AT#VSD=0");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set VSD=0");
strcpy((char *)s, "AT#VBS=4");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set VBS=4");
strcpy((char *)s, "AT#BDR=16");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set BDR=16");
s[0] = _mm_load_si128((const __m128i *)&LC31);
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set VTD=3F");
sprintf((char *)s, "AT#VSS=%1u", (unsigned int)((int)(3 * *((_QWORD *)&cvd + 58)) / 100));
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set silence threshold VSS");
strcpy((char *)s, "ATS30=60");
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set S30");
v0 = *((_QWORD *)&cvd + 82);
if ( v0 == -1 )
{
*((_QWORD *)&cvd + 82) = 50LL;
v1 = 129LL;
}
else
{
v1 = (unsigned int)(3 * (int)v0 / 100 + 128);
}
sprintf((char *)s, "AT#VGT=%d", v1);
if ( (unsigned int)voice_command(s, &unk_808) != 4096 )
lprintf(3LL, "can't set speaker volume");
if ( *((_QWORD *)&cvd + 79) == -1LL )
*((_QWORD *)&cvd + 79) = 50LL;
(*(void (__fastcall **)(__int64))(voice_modem + 376LL))(2LL);
if ( *((_QWORD *)&cvd + 70) && (unsigned int)voice_command("AT&K3", &unk_808) == 4096 )
{
tio_get(voice_fd, v3);
tio_set_flow_control(voice_fd, v3, 1LL);
tio_set(voice_fd, v3);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_modem_state = 1;
return 0LL;
}

original_code:
static int Supra_init (void)
     {
     char buffer[(256)];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing Supra 56e PRO voice modem");
     sprintf(buffer, "AT#VSP=%1u", (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence_len VSP");
     sprintf(buffer, "AT#VSD=0");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set VSD=0");
     sprintf(buffer, "AT#VBS=4");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set VBS=4");
     sprintf(buffer, "AT#BDR=16");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set BDR=16");
     sprintf(buffer, "AT#VTD=3F,3F,3F");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set VTD=3F");
     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 VSS");
     sprintf(buffer, "ATS30=60");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set S30");
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = 50;
     sprintf(buffer, "AT#VGT=%d", (int)cvd.transmit_gain.d.i * 3 / 100 + 128);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set speaker volume");
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = 50;
     voice_modem->set_device((0x0002));
     if ((cvd.do_hard_flow.d.i) && (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 Supra_init()
     {
     char buffer[-1];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing Supra 56e PRO voice modem");
     sprintf(buffer, "AT#VSP=%1u", (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence_len VSP");
     sprintf(buffer, "AT#VSD=0");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set VSD=0");
     sprintf(buffer, "AT#VBS=4");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set VBS=4");
     sprintf(buffer, "AT#BDR=16");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set BDR=16");
     sprintf(buffer, "AT#VTD=3F,3F,3F");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set VTD=3F");
     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 VSS");
     sprintf(buffer, "ATS30=60");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set S30");
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = 50;
     sprintf(buffer, "AT#VGT=%d", (int)cvd.transmit_gain.d.i * 3 / 100 + 128);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set speaker volume");
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = 50;
     voice_modem->set_device((0x0002));
     if ((cvd.do_hard_flow.d.i) && (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));
     }

user_defined_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:
void fax_sig_alarm()
{
signal(14, fax_sig_alarm);
lprintf(4LL, "timeout...");
fax_timeout = 1;
}

canonical_decompiled_code:
void func0()
{
signal(14, fax_sig_alarm);
lprintf(4LL, "timeout...");
fax_timeout = 1;
}

original_code:
RETSIGTYPE fax_sig_alarm()
{
    signal( 14, fax_sig_alarm );
    lprintf( 4, "timeout..." );
    fax_timeout = (1==1);
}

canonical_original_code:
void fax_sig_alarm()
{
    signal( 14, fax_sig_alarm );
    lprintf( 4, "timeout..." );
    fax_timeout = (1==1);
}

return_type: void


decompiled_code:
void fax_sig_hangup()
{
signal(1, fax_sig_hangup);
if ( !fax_hangup )
{
lprintf(3LL, "how rude, got hangup! exiting...");
exit(5);
}
}

canonical_decompiled_code:
void func1()
{
signal(1, fax_sig_hangup);
if ( !fax_hangup )
{
lprintf(3LL, "how rude, got hangup! exiting...");
exit(5);
}
}

original_code:
RETSIGTYPE fax_sig_hangup()
{
    signal( 1, fax_sig_hangup );
    if ( ! fax_hangup )
    {
 lprintf( 3, "how rude, got hangup! exiting..." );
 exit(5);
    }
}

canonical_original_code:
void fax_sig_hangup()
{
    signal( 1, fax_sig_hangup );
    if ( ! fax_hangup )
    {
 lprintf( 3, "how rude, got hangup! exiting..." );
 exit(5);
    }
}


decompiled_code:
__int64 __fastcall fax_find_directory(void *src, char *name, int a3)
{
int v3; // er14
__int64 result; // rax
int v7; // eax
__int64 v8; // rbx
char *v9; // rax

v3 = a3 - 1;
do
{
while ( 1 )
{
v7 = strlen((const char *)src) + 1;
if ( v7 >= a3 )
v7 = v3;
v8 = v7;
v9 = (char *)memccpy(name, src, 58, v7);
if ( v9 )
{
*(v9 - 1) = 0;
src = (char *)src + 1;
}
name[v8] = 0;
src = (char *)src + strlen(name);
if ( access(name, 2) >= 0 )
break;
result = lprintf(1LL, "fax_find_dir: can't write to '%s'", name);
if ( !*(_BYTE *)src )
return result;
}
result = checkspace(name);
if ( (int)result > 1 )
break;
result = lprintf(3LL, "fax_find_dir: not enough disk space in '%s'", name);
}
while ( *(_BYTE *)src );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *src, char *name, int a3)
{
int v3; // er14
__int64 result; // rax
int v7; // eax
__int64 v8; // rbx
char *v9; // rax

v3 = a3 - 1;
do
{
while ( 1 )
{
v7 = strlen((const char *)src) + 1;
if ( v7 >= a3 )
v7 = v3;
v8 = v7;
v9 = (char *)memccpy(name, src, 58, v7);
if ( v9 )
{
*(v9 - 1) = 0;
src = (char *)src + 1;
}
name[v8] = 0;
src = (char *)src + strlen(name);
if ( access(name, 2) >= 0 )
break;
result = lprintf(1LL, "fax_find_dir: can't write to '%s'", name);
if ( !*(_BYTE *)src )
return result;
}
result = checkspace(name);
if ( (int)result > 1 )
break;
result = lprintf(3LL, "fax_find_dir: not enough disk space in '%s'", name);
}
while ( *(_BYTE *)src );
return result;
}

original_code:
void fax_find_directory (char * dirlist,char * directory,int size)
{
char *p, *p_help;
    p = dirlist;
    do
    {
        int l = strlen(p)+1;
 if ( l > size-1 ) l=size-1;
     p_help = memccpy( directory, p, ':', l );
 if ( p_help != ((void *)0) ) { *(p_help-1) = '\0'; p++; }
 directory[l] = '\0';
 p += strlen(directory);
 if ( access( directory, 2 ) < 0 )
 {
     lprintf( 1, "fax_find_dir: can't write to '%s'", directory);
     continue;
 }
        if ( checkspace(directory) > 1 ) { break; }
 lprintf( 3, "fax_find_dir: not enough disk space in '%s'",
   directory);
    }
    while( *p != '\0' );
}

canonical_original_code:
void fax_find_directory(char *dirlist, char *directory, int size)
{
char *p; char *p_help;
    p = dirlist;
    do
    {
        int l = strlen(p)+1;
 if ( l > size-1 ) l=size-1;
     p_help = memccpy( directory, p, ':', l );
 if ( p_help != ((void *)0) ) { *(p_help-1) = '\0'; p++; }
 directory[l] = '\0';
 p += strlen(directory);
 if ( access( directory, 2 ) < 0 )
 {
     lprintf( 1, "fax_find_dir: can't write to '%s'", directory);
     continue;
 }
        if ( checkspace(directory) > 1 ) { break; }
 lprintf( 3, "fax_find_dir: not enough disk space in '%s'",
   directory);
    }
    while( *p != '\0' );
}

variable_types:
dirlist
char *

variable_types:
directory
char *

variable_types: size int

variable_types:
p
char *

variable_types: l int


decompiled_code:
__int64 __fastcall fax_get_pages(int fd, unsigned int *a2, void *a3, __uid_t a4, __gid_t a5, __mode_t a6)
{
unsigned int v10; // er8
__int64 v12; // rdx
__int64 v13; // rcx
__int64 v14; // r8
unsigned int v15; // esi
unsigned int v16; // eax
__int64 v17; // rdx
__int64 v18; // rcx
char v19; // ah
int v20; // edx
char name[1080]; // [rsp+10h] [rbp-438h] BYREF

fax_find_directory(a3, name, 1024);
*a2 = 0;
if ( fax_hangup | fax_poll_req )
{
lprintf(4LL, "fax_get_pages: no pages to receive");
v10 = 0;
}
else if ( (unsigned int)fax_command("AT+FDR", "CONNECT", (unsigned int)fd) == -1 )
{
lprintf(3LL, "fax_get_pages: cannot start page receive");
v10 = -1;
}
else
{
while ( 1 )
{
if ( fax_poll_req | fax_hangup )
return 0;
lprintf(5LL, "sending DC2");
write(fd, &start_rcv_0, 1uLL);
v15 = *a2 + 1;
*a2 = v15;
v16 = fax_get_page_data(fd, v15, name, a4, a5, a6);
v10 = v16;
if ( v16 == -1 )
break;
if ( (unsigned int)fax_wait_for("OK", (unsigned int)fd, v17, v18, v16) == -1 )
return (unsigned int)-1;
v19 = *(&modem_quirks + 1);
if ( (modem_quirks & 4) == 0 && fhs_details )
{
if ( fhs_lc <= 49 )
goto LABEL_17;
v20 = fhs_lc / 10 + 30;
if ( v20 > 500 )
v20 = 500;
if ( fhs_blc > v20 )
{
LABEL_17:
lprintf(3LL, "Page doesn't look good, request retrain (MPS)");
fax_command("AT+FPS=2", "OK", (unsigned int)fd);
v19 = *(&modem_quirks + 1);
}
}
if ( (v19 & 1) != 0 )
{
lprintf(3LL, "teergrubing -> signalling 'page bad'");
fax_command("AT+FPS=2", "OK", (unsigned int)fd);
v19 = *(&modem_quirks + 1);
}
if ( (v19 & 2) != 0 )
{
lprintf(3LL, "teergrubing -> hanging up hard");
fax_command("ATH0", "OK", (unsigned int)fd);
return (unsigned int)-1;
}
fax_send("AT+FDR", (unsigned int)fd);
if ( (unsigned int)fax_wait_for("CONNECT", (unsigned int)fd, v12, v13, v14) == -1 )
return (unsigned int)-1;
}
fax_hangup_code = -1;
}
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd, unsigned int *a2, void *a3, __uid_t a4, __gid_t a5, __mode_t a6)
{
unsigned int v10; // er8
__int64 v12; // rdx
__int64 v13; // rcx
__int64 v14; // r8
unsigned int v15; // esi
unsigned int v16; // eax
__int64 v17; // rdx
__int64 v18; // rcx
char v19; // ah
int v20; // edx
char name[1080]; // [rsp+10h] [rbp-438h] BYREF

func3(a3, name, 1024);
*a2 = 0;
if ( fax_hangup | fax_poll_req )
{
lprintf(4LL, "fax_get_pages: no pages to receive");
v10 = 0;
}
else if ( (unsigned int)fax_command("AT+FDR", "CONNECT", (unsigned int)fd) == -1 )
{
lprintf(3LL, "fax_get_pages: cannot start page receive");
v10 = -1;
}
else
{
while ( 1 )
{
if ( fax_poll_req | fax_hangup )
return 0;
lprintf(5LL, "sending DC2");
write(fd, &start_rcv_0, 1uLL);
v15 = *a2 + 1;
*a2 = v15;
v16 = func2(fd, v15, name, a4, a5, a6);
v10 = v16;
if ( v16 == -1 )
break;
if ( (unsigned int)fax_wait_for("OK", (unsigned int)fd, v17, v18, v16) == -1 )
return (unsigned int)-1;
v19 = *(&modem_quirks + 1);
if ( (modem_quirks & 4) == 0 && fhs_details )
{
if ( fhs_lc <= 49 )
goto LABEL_17;
v20 = fhs_lc / 10 + 30;
if ( v20 > 500 )
v20 = 500;
if ( fhs_blc > v20 )
{
LABEL_17:
lprintf(3LL, "Page doesn't look good, request retrain (MPS)");
fax_command("AT+FPS=2", "OK", (unsigned int)fd);
v19 = *(&modem_quirks + 1);
}
}
if ( (v19 & 1) != 0 )
{
lprintf(3LL, "teergrubing -> signalling 'page bad'");
fax_command("AT+FPS=2", "OK", (unsigned int)fd);
v19 = *(&modem_quirks + 1);
}
if ( (v19 & 2) != 0 )
{
lprintf(3LL, "teergrubing -> hanging up hard");
fax_command("ATH0", "OK", (unsigned int)fd);
return (unsigned int)-1;
}
fax_send("AT+FDR", (unsigned int)fd);
if ( (unsigned int)fax_wait_for("CONNECT", (unsigned int)fd, v12, v13, v14) == -1 )
return (unsigned int)-1;
}
fax_hangup_code = -1;
}
return v10;
}

original_code:
int fax_get_pages (int fd,int * pagenum,char * dirlist,int uid,int gid,int mode)
{
static const char start_rcv = 022;
    char directory[1024];
    fax_find_directory( dirlist, directory, sizeof(directory) );
    *pagenum = 0;
    if ( fax_poll_req || fax_hangup )
    {
 lprintf( 4, "fax_get_pages: no pages to receive" );
 return 0;
    }
    if ( fax_command( "AT+FDR", "CONNECT", fd ) == -1 )
    {
 lprintf( 3, "fax_get_pages: cannot start page receive" );
 return -1;
    }
    while ( !fax_hangup && !fax_poll_req )
    {
 lprintf( 5, "sending DC2" );
 write( fd, &start_rcv, 1);
 if ( fax_get_page_data( fd, ++(*pagenum), directory,
           uid, gid, mode ) == -1 )
 {
     fax_hangup_code = -1;
     return -1;
 }
 if ( fax_wait_for( "OK", fd ) == -1 ) return -1;
 if ( ( modem_quirks & 0x04 ) == 0 &&
      fhs_details &&
      ( fhs_lc < 50 || fhs_blc > (fhs_lc/10)+30 || fhs_blc > 500 ) )
 {
     lprintf( 3, "Page doesn't look good, request retrain (MPS)" );
     fax_command( "AT+FPS=2", "OK", fd );
 }
 if ( modem_quirks & 0x100 )
 {
     lprintf( 3, "teergrubing -> signalling 'page bad'" );
     fax_command( "AT+FPS=2", "OK", fd );
 }
 if ( modem_quirks & 0x200 )
 {
     lprintf( 3, "teergrubing -> hanging up hard" );
     fax_command( "ATH0", "OK", fd );
     return -1;
 }
 fax_send( "AT+FDR", fd );
 if ( fax_wait_for( "CONNECT", fd ) == -1 ) return -1;
    }
    return 0;
}

canonical_original_code:
int fax_get_pages(int fd, int *pagenum, char *dirlist, int uid, int gid, int mode)
{
static char start_rcv = 022;
    char directory[1024];
    fax_find_directory( dirlist, directory, sizeof(directory) );
    *pagenum = 0;
    if ( fax_poll_req || fax_hangup )
    {
 lprintf( 4, "fax_get_pages: no pages to receive" );
 return 0;
    }
    if ( fax_command( "AT+FDR", "CONNECT", fd ) == -1 )
    {
 lprintf( 3, "fax_get_pages: cannot start page receive" );
 return -1;
    }
    while ( !fax_hangup && !fax_poll_req )
    {
 lprintf( 5, "sending DC2" );
 write( fd, &start_rcv, 1);
 if ( fax_get_page_data( fd, ++(*pagenum), directory,
           uid, gid, mode ) == -1 )
 {
     fax_hangup_code = -1;
     return -1;
 }
 if ( fax_wait_for( "OK", fd ) == -1 ) return -1;
 if ( ( modem_quirks & 0x04 ) == 0 &&
      fhs_details &&
      ( fhs_lc < 50 || fhs_blc > (fhs_lc/10)+30 || fhs_blc > 500 ) )
 {
     lprintf( 3, "Page doesn't look good, request retrain (MPS)" );
     fax_command( "AT+FPS=2", "OK", fd );
 }
 if ( modem_quirks & 0x100 )
 {
     lprintf( 3, "teergrubing -> signalling 'page bad'" );
     fax_command( "AT+FPS=2", "OK", fd );
 }
 if ( modem_quirks & 0x200 )
 {
     lprintf( 3, "teergrubing -> hanging up hard" );
     fax_command( "ATH0", "OK", fd );
     return -1;
 }
 fax_send( "AT+FDR", fd );
 if ( fax_wait_for( "CONNECT", fd ) == -1 ) return -1;
    }
    return 0;
}

variable_types: fd int

variable_types:
pagenum
int *

variable_types: uid int

variable_types: gid int

variable_types: mode int

variable_types:
directory
char [1024]


decompiled_code:
__int64 __fastcall V253modem_set_compression(__int64 *a1, unsigned int *a2, int *a3)
{
__int64 v4; // rdx
unsigned int v5; // er12
__int64 v6; // rcx
__int64 v7; // rax
__int64 v8; // rdx
char v10[280]; // [rsp+0h] [rbp-118h] BYREF

reset_watchdog();
v4 = *a1;
if ( (unsigned __int64)*a1 <= 0xFF )
{
v5 = Kompressiontable[v4];
switch ( v4 )
{
case 0LL:
case 1LL:
case 6LL:
case 7LL:
case 8LL:
case 9LL:
case 10LL:
case 11LL:
*a3 = 8;
break;
case 2LL:
*a3 = 2;
break;
case 4LL:
case 5LL:
*a3 = 4;
break;
case 12LL:
*a3 = 16;
break;
default:
goto LABEL_2;
}
}
else
{
LABEL_2:
v5 = 1;
lprintf(3LL, "compression method %d is not supported -> edit voice.conf", v4);
*a3 = 8;
}
v6 = *(_QWORD *)a2;
if ( !*(_QWORD *)a2 )
{
*(_QWORD *)a2 = 8000LL;
v6 = 8000LL;
}
sprintf(v10, "AT+VSM=%d,%d", v5, v6);
if ( (unsigned int)voice_command(v10, "OK") != 4096 )
sprintf(v10, "AT+VSM=%d,%d,%d,%d", v5, *a2, 0LL, 0LL);
if ( (unsigned int)voice_command(v10, "OK") != 4096 )
{
lprintf(3LL, "can't set compression and speed");
voice_command("AT+VSM?", "OK");
}
v7 = 10 * *(_QWORD *)a2 * *a3;
v8 = v7 + 7;
if ( v7 >= 0 )
v8 = 10 * *(_QWORD *)a2 * *a3;
lprintf(5LL, "Just for info: port_speed should be greater than %d bps", v8 >> 3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, unsigned int *a2, int *a3)
{
__int64 v4; // rdx
unsigned int v5; // er12
__int64 v6; // rcx
__int64 v7; // rax
__int64 v8; // rdx
char v10[280]; // [rsp+0h] [rbp-118h] BYREF

reset_watchdog();
v4 = *a1;
if ( (unsigned __int64)*a1 <= 0xFF )
{
v5 = Kompressiontable[v4];
switch ( v4 )
{
case 0LL:
case 1LL:
case 6LL:
case 7LL:
case 8LL:
case 9LL:
case 10LL:
case 11LL:
*a3 = 8;
break;
case 2LL:
*a3 = 2;
break;
case 4LL:
case 5LL:
*a3 = 4;
break;
case 12LL:
*a3 = 16;
break;
default:
goto LABEL_2;
}
}
else
{
LABEL_2:
v5 = 1;
lprintf(3LL, "compression method %d is not supported -> edit voice.conf", v4);
*a3 = 8;
}
v6 = *(_QWORD *)a2;
if ( !*(_QWORD *)a2 )
{
*(_QWORD *)a2 = 8000LL;
v6 = 8000LL;
}
sprintf(v10, "AT+VSM=%d,%d", v5, v6);
if ( (unsigned int)voice_command(v10, "OK") != 4096 )
sprintf(v10, "AT+VSM=%d,%d,%d,%d", v5, *a2, 0LL, 0LL);
if ( (unsigned int)voice_command(v10, "OK") != 4096 )
{
lprintf(3LL, "can't set compression and speed");
voice_command("AT+VSM?", "OK");
}
v7 = 10 * *(_QWORD *)a2 * *a3;
v8 = v7 + 7;
if ( v7 >= 0 )
v8 = 10 * *(_QWORD *)a2 * *a3;
lprintf(5LL, "Just for info: port_speed should be greater than %d bps", v8 >> 3);
return 0LL;
}

original_code:
int V253modem_set_compression (p_int *compression, p_int *speed, int *bits)
     {
     char buffer[(256)];
     int Kompressionmethod = 1;
     int sil_sense = 0;
     int sil_clip = 0;
     reset_watchdog();
     if(*compression < sizeof(Kompressiontable)/sizeof(int) ) {
       Kompressionmethod = Kompressiontable[*compression];
     }
     switch (*compression)
     {
       case 0:
       case 1:
       case 8:
       {
          *bits=8;
          break;
       }
       case 2:
       {
         *bits = 2;
         break;
        }
       case 4:
       {
         *bits=4;
         break;
       }
       case 5:
       {
         *bits = 4;
         break;
       }
       case 6:
       {
         *bits = 8;
         break;
       }
       case 7:
       {
         *bits = 8;
         break;
       }
       case 9:
       {
          *bits=8;
          break;
       }
       case 10:
       {
          *bits=8;
          break;
       }
       case 11:
       {
          *bits=8;
          break;
       }
       case 12:
       {
  *bits=16;
  break;
       }
       default:
       {
          lprintf(3, "compression method %d is not supported -> edit voice.conf",*compression);
          Kompressionmethod = 1;
          *bits=8;
       }
     }
     if (*speed == 0)
          *speed = 8000;
     sprintf(buffer, "AT+VSM=%d,%d",Kompressionmethod, (int)*speed);
     if (voice_command(buffer, "OK")!= (0x1000))
     sprintf(buffer, "AT+VSM=%d,%d,%d,%d",Kompressionmethod, (int)*speed, sil_sense, sil_clip);
     if (voice_command(buffer, "OK")!= (0x1000))
      {
         lprintf(3, "can't set compression and speed");
         voice_command("AT+VSM?", "OK");
      }
     lprintf(5, "Just for info: port_speed should be greater than %d bps",(*bits)*(*speed)*10/8);
     return((0)) ;
     }

canonical_original_code:
int V253modem_set_compression(long *compression, long *speed, int *bits)
     {
     char buffer[-1];
     int Kompressionmethod = 1;
     int sil_sense = 0;
     int sil_clip = 0;
     reset_watchdog();
     if(*compression < sizeof(Kompressiontable)/sizeof(int) ) {
       Kompressionmethod = Kompressiontable[*compression];
     }
     switch (*compression)
     {
       case 0:
       case 1:
       case 8:
       {
          *bits=8;
          break;
       }
       case 2:
       {
         *bits = 2;
         break;
        }
       case 4:
       {
         *bits=4;
         break;
       }
       case 5:
       {
         *bits = 4;
         break;
       }
       case 6:
       {
         *bits = 8;
         break;
       }
       case 7:
       {
         *bits = 8;
         break;
       }
       case 9:
       {
          *bits=8;
          break;
       }
       case 10:
       {
          *bits=8;
          break;
       }
       case 11:
       {
          *bits=8;
          break;
       }
       case 12:
       {
  *bits=16;
  break;
       }
       default:
       {
          lprintf(3, "compression method %d is not supported -> edit voice.conf",*compression);
          Kompressionmethod = 1;
          *bits=8;
       }
     }
     if (*speed == 0)
          *speed = 8000;
     sprintf(buffer, "AT+VSM=%d,%d",Kompressionmethod, (int)*speed);
     if (voice_command(buffer, "OK")!= (0x1000))
     sprintf(buffer, "AT+VSM=%d,%d,%d,%d",Kompressionmethod, (int)*speed, sil_sense, sil_clip);
     if (voice_command(buffer, "OK")!= (0x1000))
      {
         lprintf(3, "can't set compression and speed");
         voice_command("AT+VSM?", "OK");
      }
     lprintf(5, "Just for info: port_speed should be greater than %d bps",(*bits)*(*speed)*10/8);
     return((0)) ;
     }

variable_types:
compression
long *

variable_types:
speed
long *

variable_types:
bits
int *

variable_types:
buffer
char [-1]

variable_types: Kompressionmethod int


decompiled_code:
__int64 V253modem_stop_duplex()
{
voice_modem_state = 1;
return voice_command(*(_QWORD *)(voice_modem + 256LL), *(_QWORD *)(voice_modem + 264LL));
}

canonical_decompiled_code:
__int64 func1()
{
voice_modem_state = 1;
return voice_command(*(_QWORD *)(voice_modem + 256LL), *(_QWORD *)(voice_modem + 264LL));
}

original_code:
int V253modem_stop_duplex (void)
{
  voice_modem_state = (0x0001);
  return voice_command( voice_modem->stop_duplex_voice_cmnd ,
   voice_modem->stop_duplex_voice_answr );
}

canonical_original_code:
int V253modem_stop_duplex()
{
  voice_modem_state = (0x0001);
  return voice_command( voice_modem->stop_duplex_voice_cmnd ,
   voice_modem->stop_duplex_voice_answr );
}


decompiled_code:
__int64 __fastcall V253modem_set_device(unsigned int a1)
{
const char *v1; // rax
int v2; // eax
unsigned int v3; // er8
__int64 result; // rax
const char *v5; // rax

reset_watchdog();
v1 = (const char *)voice_device_mode_name(a1);
lprintf(6LL, "%s: %s: (%d)", (const char *)*voice_modem, v1, a1);
switch ( a1 )
{
case 1u:
v2 = voice_command("AT+VLS=0", "OK");
goto LABEL_3;
case 2u:
v2 = voice_command("AT+VLS=1", "OK");
goto LABEL_3;
case 3u:
v2 = voice_command("AT+VLS=11", "OK");
goto LABEL_3;
case 4u:
v2 = voice_command("AT+VLS=6", "OK");
goto LABEL_3;
case 5u:
v2 = voice_command("AT+VLS=8", "OK");
goto LABEL_3;
case 6u:
v2 = voice_command("AT+VLS=4", "OK");
goto LABEL_3;
case 7u:
v2 = voice_command("AT+VLS=2", "OK");
goto LABEL_3;
case 8u:
v2 = voice_command("AT+VLS=9", "OK");
goto LABEL_3;
case 9u:
v2 = voice_command("AT+VLS=5", "OK");
goto LABEL_3;
case 0xAu:
v2 = voice_command("AT+VLS=3", "OK");
goto LABEL_3;
case 0xBu:
v2 = voice_command("AT+VLS=13", "OK");
goto LABEL_3;
case 0xCu:
v2 = voice_command("AT+VLS=7", "OK");
LABEL_3:
v3 = 0;
if ( v2 == 4096 )
goto LABEL_4;
v5 = (const char *)voice_device_mode_name(a1);
lprintf(3LL, "can't set %s (modem hardware can't do that)", v5);
result = 16385LL;
break;
default:
lprintf(3LL, "%s: Unknown device (%d)", (const char *)*voice_modem, a1);
v3 = -1;
LABEL_4:
result = v3;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
const char *v1; // rax
int v2; // eax
unsigned int v3; // er8
__int64 result; // rax
const char *v5; // rax

reset_watchdog();
v1 = (const char *)voice_device_mode_name(a1);
lprintf(6LL, "%s: %s: (%d)", (const char *)*voice_modem, v1, a1);
switch ( a1 )
{
case 1u:
v2 = voice_command("AT+VLS=0", "OK");
goto LABEL_3;
case 2u:
v2 = voice_command("AT+VLS=1", "OK");
goto LABEL_3;
case 3u:
v2 = voice_command("AT+VLS=11", "OK");
goto LABEL_3;
case 4u:
v2 = voice_command("AT+VLS=6", "OK");
goto LABEL_3;
case 5u:
v2 = voice_command("AT+VLS=8", "OK");
goto LABEL_3;
case 6u:
v2 = voice_command("AT+VLS=4", "OK");
goto LABEL_3;
case 7u:
v2 = voice_command("AT+VLS=2", "OK");
goto LABEL_3;
case 8u:
v2 = voice_command("AT+VLS=9", "OK");
goto LABEL_3;
case 9u:
v2 = voice_command("AT+VLS=5", "OK");
goto LABEL_3;
case 0xAu:
v2 = voice_command("AT+VLS=3", "OK");
goto LABEL_3;
case 0xBu:
v2 = voice_command("AT+VLS=13", "OK");
goto LABEL_3;
case 0xCu:
v2 = voice_command("AT+VLS=7", "OK");
LABEL_3:
v3 = 0;
if ( v2 == 4096 )
goto LABEL_4;
v5 = (const char *)voice_device_mode_name(a1);
lprintf(3LL, "can't set %s (modem hardware can't do that)", v5);
result = 16385LL;
break;
default:
lprintf(3LL, "%s: Unknown device (%d)", (const char *)*voice_modem, a1);
v3 = -1;
LABEL_4:
result = v3;
break;
}
return result;
}

original_code:
int V253modem_set_device (int device)
     {
       int Result;
       reset_watchdog();
       lprintf(6, "%s: %s: (%d)", voice_modem->name,
        voice_device_mode_name(device), device);
     switch (device)
          {
          case (0x0001):
     Result = voice_command("AT+VLS=0", "OK");
     break;
          case (0x0002):
     Result = voice_command("AT+VLS=1", "OK");
     break;
          case (0x0003):
     Result = voice_command("AT+VLS=11", "OK");
     break;
          case (0x0004):
     Result = voice_command("AT+VLS=6", "OK");
     break;
          case (0x0006):
     Result = voice_command("AT+VLS=4", "OK");
     break;
          case (0x0005):
     Result = voice_command("AT+VLS=8", "OK");
     break;
          case (0x0007) :
     Result = voice_command("AT+VLS=2", "OK");
     break;
          case (0x0008) :
     Result = voice_command("AT+VLS=9", "OK");
     break;
          case (0x0009) :
     Result = voice_command("AT+VLS=5", "OK");
     break;
          case (0x000A) :
     Result = voice_command("AT+VLS=3", "OK");
     break;
          case (0x000B):
     Result = voice_command("AT+VLS=13", "OK");
     break;
          case (0x000C):
     Result = voice_command("AT+VLS=7", "OK");
     break;
   default:
     lprintf(3, "%s: Unknown device (%d)",
      voice_modem->name, device);
     return((-1));
          }
     if (Result != (0x1000))
       {
  lprintf(3, "can't set %s (modem hardware can't do that)",
   voice_device_mode_name(device));
  return((0x4001));
       }
     return((0));
     }

canonical_original_code:
int V253modem_set_device(int device)
     {
       int Result;
       reset_watchdog();
       lprintf(6, "%s: %s: (%d)", voice_modem->name,
        voice_device_mode_name(device), device);
     switch (device)
          {
          case (0x0001):
     Result = voice_command("AT+VLS=0", "OK");
     break;
          case (0x0002):
     Result = voice_command("AT+VLS=1", "OK");
     break;
          case (0x0003):
     Result = voice_command("AT+VLS=11", "OK");
     break;
          case (0x0004):
     Result = voice_command("AT+VLS=6", "OK");
     break;
          case (0x0006):
     Result = voice_command("AT+VLS=4", "OK");
     break;
          case (0x0005):
     Result = voice_command("AT+VLS=8", "OK");
     break;
          case (0x0007) :
     Result = voice_command("AT+VLS=2", "OK");
     break;
          case (0x0008) :
     Result = voice_command("AT+VLS=9", "OK");
     break;
          case (0x0009) :
     Result = voice_command("AT+VLS=5", "OK");
     break;
          case (0x000A) :
     Result = voice_command("AT+VLS=3", "OK");
     break;
          case (0x000B):
     Result = voice_command("AT+VLS=13", "OK");
     break;
          case (0x000C):
     Result = voice_command("AT+VLS=7", "OK");
     break;
   default:
     lprintf(3, "%s: Unknown device (%d)",
      voice_modem->name, device);
     return((-1));
          }
     if (Result != (0x1000))
       {
  lprintf(3, "can't set %s (modem hardware can't do that)",
   voice_device_mode_name(device));
  return((0x4001));
       }
     return((0));
     }

variable_types: device int

variable_types: Result int


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

v1 = 1;
if ( strcmp(a1, "V253modem") )
v1 = strcmp(a1, "Elsa") == 0;
return v1;
}

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

v1 = 1;
if ( strcmp(a1, "V253modem") )
v1 = strcmp(a1, "Elsa") == 0;
return v1;
}

original_code:
int V253_check_rmd_adequation(char *rmd_name)
{
   return !strncmp(rmd_name,
                   "V253modem",
                   sizeof("V253modem"))
          || !strncmp(rmd_name,
                      "Elsa",
                      sizeof("Elsa"));
}


decompiled_code:
__int64 V253_init_compression_table()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rax
__int64 result; // rax

v0 = cvd[106];
memset(Kompressiontable, 1u, sizeof(Kompressiontable));
v1 = cvd[115];
Kompressiontable[0] = v0;
Kompressiontable[2] = v1;
v2 = cvd[118];
Kompressiontable[1] = v0;
Kompressiontable[4] = v2;
v3 = cvd[121];
Kompressiontable[8] = v0;
v4 = cvd[100];
Kompressiontable[5] = v3;
v5 = cvd[109];
Kompressiontable[9] = v4;
Kompressiontable[6] = v5;
Kompressiontable[7] = v5;
Kompressiontable[10] = v5;
Kompressiontable[11] = cvd[112];
result = cvd[103];
Kompressiontable[12] = result;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rdx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rax
__int64 result; // rax

v0 = cvd[106];
memset(Kompressiontable, 1u, sizeof(Kompressiontable));
v1 = cvd[115];
Kompressiontable[0] = v0;
Kompressiontable[2] = v1;
v2 = cvd[118];
Kompressiontable[1] = v0;
Kompressiontable[4] = v2;
v3 = cvd[121];
Kompressiontable[8] = v0;
v4 = cvd[100];
Kompressiontable[5] = v3;
v5 = cvd[109];
Kompressiontable[9] = v4;
Kompressiontable[6] = v5;
Kompressiontable[7] = v5;
Kompressiontable[10] = v5;
Kompressiontable[11] = cvd[112];
result = cvd[103];
Kompressiontable[12] = result;
return result;
}

original_code:
void V253_init_compression_table() {
  memset( Kompressiontable, 1, sizeof(Kompressiontable) );
  Kompressiontable[0]=cvd.compression_8bit_linear_unsigned.d.i;
  Kompressiontable[1]=cvd.compression_8bit_linear_unsigned.d.i;
  Kompressiontable[2]=cvd.compression_2bit_adpcm.d.i;
  Kompressiontable[4]=cvd.compression_4bit_adpcm.d.i;
  Kompressiontable[5]=cvd.compression_4bit_ima_adpcm.d.i;
  Kompressiontable[6]=cvd.compression_8bit_ulaw.d.i;
  Kompressiontable[7]=cvd.compression_8bit_ulaw.d.i;
  Kompressiontable[8]=cvd.compression_8bit_linear_unsigned.d.i;
  Kompressiontable[9]=cvd.compression_8bit_linear_signed.d.i;
  Kompressiontable[10]=cvd.compression_8bit_ulaw.d.i;
  Kompressiontable[11]=cvd.compression_8bit_alaw.d.i;
  Kompressiontable[12]=cvd.compression_16bit_linear_signed.d.i;
}


decompiled_code:
__int64 V253_querry_compressions()
{
bool v0; // zf
__int64 v1; // rax
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
_WORD v9[132]; // [rsp+0h] [rbp-108h] BYREF

v0 = cvd[97] == 0LL;
memset(v9, 0, 0x100uLL);
if ( v0 )
return lprintf(5LL, "voice compression querry disabled");
if ( !(unsigned int)voice_command("AT+VSM=?", &unk_16CA) )
{
while ( !(unsigned int)voice_read(v9) )
{
if ( strstr((const char *)v9, "\"SIGNED PCM\",8") )
{
v1 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[9] = v1;
result = lprintf(5LL, "Mapped signed PCM, 9 -> %d", v1);
}
else if ( strstr((const char *)v9, "\"SIGNED PCM\",16") )
{
v3 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[12] = v3;
result = lprintf(5LL, "Mapped signed PCM, 12 -> %d", v3);
}
else if ( strstr((const char *)v9, "UNSIGNED PCM\",8") || strstr((const char *)v9, "8-BIT LINEAR") )
{
v4 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[8] = v4;
Kompressiontable[1] = v4;
Kompressiontable[0] = v4;
lprintf(5LL, "Mapped default (8 bit linear), 0 -> %d", v4);
lprintf(5LL, "Mapped unsigned PCM, 1 -> %d", (unsigned int)Kompressiontable[1]);
result = lprintf(5LL, "Mapped 8 bit linear, 8 -> %d", (unsigned int)Kompressiontable[8]);
}
else if ( strstr((const char *)v9, "IMA ADPCM\",4") || strstr((const char *)v9, "4-BIT ADPCM") )
{
v5 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[5] = v5;
result = lprintf(5LL, "Mapped 4 bit IMA ADPCM, 5 -> %d", v5);
}
else if ( strstr((const char *)v9, "ULAW") )
{
v6 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[10] = v6;
result = lprintf(5LL, "Mapped ulaw, 10 -> %d", v6);
}
else if ( strstr((const char *)v9, "ALAW") )
{
v7 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[11] = v7;
result = lprintf(5LL, "Mapped alaw, 11 -> %d", v7);
}
else if ( strstr((const char *)v9, "16-BIT LINEAR") )
{
v8 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[13] = v8;
result = lprintf(5LL, "Mapped 16 bit linear, 13 -> %d", v8);
}
else
{
result = lprintf(5LL, "Unknown: %s", (const char *)v9);
}
if ( v9[0] == 19279 )
return result;
}
}
return lprintf(3LL, "voice compression querry failed");
}

canonical_decompiled_code:
__int64 func6()
{
bool v0; // zf
__int64 v1; // rax
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
_WORD v9[132]; // [rsp+0h] [rbp-108h] BYREF

v0 = cvd[97] == 0LL;
memset(v9, 0, 0x100uLL);
if ( v0 )
return lprintf(5LL, "voice compression querry disabled");
if ( !(unsigned int)voice_command("AT+VSM=?", &unk_16CA) )
{
while ( !(unsigned int)voice_read(v9) )
{
if ( strstr((const char *)v9, "\"SIGNED PCM\",8") )
{
v1 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[9] = v1;
result = lprintf(5LL, "Mapped signed PCM, 9 -> %d", v1);
}
else if ( strstr((const char *)v9, "\"SIGNED PCM\",16") )
{
v3 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[12] = v3;
result = lprintf(5LL, "Mapped signed PCM, 12 -> %d", v3);
}
else if ( strstr((const char *)v9, "UNSIGNED PCM\",8") || strstr((const char *)v9, "8-BIT LINEAR") )
{
v4 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[8] = v4;
Kompressiontable[1] = v4;
Kompressiontable[0] = v4;
lprintf(5LL, "Mapped default (8 bit linear), 0 -> %d", v4);
lprintf(5LL, "Mapped unsigned PCM, 1 -> %d", (unsigned int)Kompressiontable[1]);
result = lprintf(5LL, "Mapped 8 bit linear, 8 -> %d", (unsigned int)Kompressiontable[8]);
}
else if ( strstr((const char *)v9, "IMA ADPCM\",4") || strstr((const char *)v9, "4-BIT ADPCM") )
{
v5 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[5] = v5;
result = lprintf(5LL, "Mapped 4 bit IMA ADPCM, 5 -> %d", v5);
}
else if ( strstr((const char *)v9, "ULAW") )
{
v6 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[10] = v6;
result = lprintf(5LL, "Mapped ulaw, 10 -> %d", v6);
}
else if ( strstr((const char *)v9, "ALAW") )
{
v7 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[11] = v7;
result = lprintf(5LL, "Mapped alaw, 11 -> %d", v7);
}
else if ( strstr((const char *)v9, "16-BIT LINEAR") )
{
v8 = strtol((const char *)v9, 0LL, 10);
Kompressiontable[13] = v8;
result = lprintf(5LL, "Mapped 16 bit linear, 13 -> %d", v8);
}
else
{
result = lprintf(5LL, "Unknown: %s", (const char *)v9);
}
if ( v9[0] == 19279 )
return result;
}
}
return lprintf(3LL, "voice compression querry failed");
}

original_code:
void V253_querry_compressions() {
     char buffer[(256)];
     memset( buffer, '\0', sizeof(buffer) );
     if (!cvd.enable_compression_mapping_querry.d.i) {
       lprintf(5, "voice compression querry disabled");
       return;
     }
     if (voice_command("AT+VSM=?", "") != (0))
       {
  lprintf(3, "voice compression querry failed");
  return;
       }
     do {
       if (voice_read(buffer) != (0))
  {
    lprintf(3, "voice compression querry failed");
    break;
   }
       if(strstr(buffer,"\"SIGNED PCM\",8")) {
  Kompressiontable[9]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped signed PCM, 9 -> %d",Kompressiontable[9]);
       } else if(strstr(buffer,"\"SIGNED PCM\",16")) {
  Kompressiontable[12]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped signed PCM, 12 -> %d",Kompressiontable[12]);
       } else if(strstr(buffer,"UNSIGNED PCM\",8")) {
  Kompressiontable[0]=
    Kompressiontable[1]=
    Kompressiontable[8]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped default (8 bit linear), 0 -> %d",Kompressiontable[0]);
  lprintf(5, "Mapped unsigned PCM, 1 -> %d",Kompressiontable[1]);
  lprintf(5, "Mapped 8 bit linear, 8 -> %d",Kompressiontable[8]);
       } else if(strstr(buffer,"8-BIT LINEAR")) {
  Kompressiontable[0]=
    Kompressiontable[1]=
    Kompressiontable[8]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped default (8 bit linear), 0 -> %d",Kompressiontable[0]);
  lprintf(5, "Mapped unsigned PCM, 1 -> %d",Kompressiontable[1]);
  lprintf(5, "Mapped 8 bit linear, 8 -> %d",Kompressiontable[8]);
       } else if(strstr(buffer,"IMA ADPCM\",4")) {
  Kompressiontable[5]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped 4 bit IMA ADPCM, 5 -> %d",Kompressiontable[5]);
       } else if(strstr(buffer,"4-BIT ADPCM")) {
  Kompressiontable[5]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped 4 bit IMA ADPCM, 5 -> %d",Kompressiontable[5]);
       } else if(strstr(buffer,"ULAW")) {
  Kompressiontable[10]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped ulaw, 10 -> %d",Kompressiontable[10]);
       } else if(strstr(buffer,"ALAW")) {
  Kompressiontable[11]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped alaw, 11 -> %d",Kompressiontable[11]);
       } else if(strstr(buffer,"16-BIT LINEAR")) {
  Kompressiontable[13]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped 16 bit linear, 13 -> %d",Kompressiontable[13]);
       } else
  {
    lprintf(5, "Unknown: %s",buffer);
  }
     } while (strncmp("OK",buffer,2));
}

canonical_original_code:
void V253_querry_compressions() {
     char buffer[-1];
     memset( buffer, '\0', sizeof(buffer) );
     if (!cvd.enable_compression_mapping_querry.d.i) {
       lprintf(5, "voice compression querry disabled");
       return;
     }
     if (voice_command("AT+VSM=?", "") != (0))
       {
  lprintf(3, "voice compression querry failed");
  return;
       }
     do {
       if (voice_read(buffer) != (0))
  {
    lprintf(3, "voice compression querry failed");
    break;
   }
       if(strstr(buffer,"\"SIGNED PCM\",8")) {
  Kompressiontable[9]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped signed PCM, 9 -> %d",Kompressiontable[9]);
       } else if(strstr(buffer,"\"SIGNED PCM\",16")) {
  Kompressiontable[12]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped signed PCM, 12 -> %d",Kompressiontable[12]);
       } else if(strstr(buffer,"UNSIGNED PCM\",8")) {
  Kompressiontable[0]=
    Kompressiontable[1]=
    Kompressiontable[8]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped default (8 bit linear), 0 -> %d",Kompressiontable[0]);
  lprintf(5, "Mapped unsigned PCM, 1 -> %d",Kompressiontable[1]);
  lprintf(5, "Mapped 8 bit linear, 8 -> %d",Kompressiontable[8]);
       } else if(strstr(buffer,"8-BIT LINEAR")) {
  Kompressiontable[0]=
    Kompressiontable[1]=
    Kompressiontable[8]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped default (8 bit linear), 0 -> %d",Kompressiontable[0]);
  lprintf(5, "Mapped unsigned PCM, 1 -> %d",Kompressiontable[1]);
  lprintf(5, "Mapped 8 bit linear, 8 -> %d",Kompressiontable[8]);
       } else if(strstr(buffer,"IMA ADPCM\",4")) {
  Kompressiontable[5]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped 4 bit IMA ADPCM, 5 -> %d",Kompressiontable[5]);
       } else if(strstr(buffer,"4-BIT ADPCM")) {
  Kompressiontable[5]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped 4 bit IMA ADPCM, 5 -> %d",Kompressiontable[5]);
       } else if(strstr(buffer,"ULAW")) {
  Kompressiontable[10]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped ulaw, 10 -> %d",Kompressiontable[10]);
       } else if(strstr(buffer,"ALAW")) {
  Kompressiontable[11]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped alaw, 11 -> %d",Kompressiontable[11]);
       } else if(strstr(buffer,"16-BIT LINEAR")) {
  Kompressiontable[13]= strtol(buffer, ((void *)0), 10);
  lprintf(5, "Mapped 16 bit linear, 13 -> %d",Kompressiontable[13]);
       } else
  {
    lprintf(5, "Unknown: %s",buffer);
  }
     } while (strncmp("OK",buffer,2));
}


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

reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing V253 voice modem");
V253_init_compression_table(4LL, "OK");
strcpy(s, "AT+FCLASS=8");
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "could not set +FCLASS=8");
V253_querry_compressions();
sprintf(s, "AT+VSD=%d,%d", LODWORD(cvd[58]), LODWORD(cvd[55]));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence threshold VSD");
v0 = cvd[82];
if ( v0 == -1 )
{
cvd[82] = 50LL;
v1 = 127LL;
}
else
{
v1 = (unsigned int)(255 * (int)v0 / 100);
}
sprintf(s, "AT+VGT=%d", v1);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set speaker volume");
v2 = cvd[79];
if ( v2 == -1 )
{
cvd[79] = 50LL;
v3 = 127LL;
}
else
{
v3 = (unsigned int)(255 * (int)v2 / 100);
}
sprintf(s, "AT+VGR=%d", v3);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set record volume");
sprintf(s, "AT+VRA=%d;+VRN=%d", LODWORD(cvd[199]), (unsigned int)((int)cvd[202] / 10));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "setting ringback delay didn't work");
if ( cvd[70] && (unsigned int)voice_command("AT+IFC=2,2", "OK") == 4096 )
{
tio_get(voice_fd, v5);
tio_set_flow_control(voice_fd, v5, 1LL);
tio_set(voice_fd, v5);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_command("AT+VCID=1", "OK");
voice_command("AT+VNH=0", "OK");
voice_command("AT+VIT=0", "OK");
sprintf(s, "AT+VDR=1,%d", LODWORD(cvd[205]));
voice_command(s, "OK");
result = 0LL;
voice_modem_state = 1;
return result;
}

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

reset_watchdog();
voice_modem_state = 2;
lprintf(4LL, "initializing V253 voice modem");
func5(4LL, "OK");
strcpy(s, "AT+FCLASS=8");
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "could not set +FCLASS=8");
func6();
sprintf(s, "AT+VSD=%d,%d", LODWORD(cvd[58]), LODWORD(cvd[55]));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set silence threshold VSD");
v0 = cvd[82];
if ( v0 == -1 )
{
cvd[82] = 50LL;
v1 = 127LL;
}
else
{
v1 = (unsigned int)(255 * (int)v0 / 100);
}
sprintf(s, "AT+VGT=%d", v1);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set speaker volume");
v2 = cvd[79];
if ( v2 == -1 )
{
cvd[79] = 50LL;
v3 = 127LL;
}
else
{
v3 = (unsigned int)(255 * (int)v2 / 100);
}
sprintf(s, "AT+VGR=%d", v3);
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "can't set record volume");
sprintf(s, "AT+VRA=%d;+VRN=%d", LODWORD(cvd[199]), (unsigned int)((int)cvd[202] / 10));
if ( (unsigned int)voice_command(s, "OK") != 4096 )
lprintf(3LL, "setting ringback delay didn't work");
if ( cvd[70] && (unsigned int)voice_command("AT+IFC=2,2", "OK") == 4096 )
{
tio_get(voice_fd, v5);
tio_set_flow_control(voice_fd, v5, 1LL);
tio_set(voice_fd, v5);
}
else
{
lprintf(3LL, "can't turn on hardware flow control");
}
voice_command("AT+VCID=1", "OK");
voice_command("AT+VNH=0", "OK");
voice_command("AT+VIT=0", "OK");
sprintf(s, "AT+VDR=1,%d", LODWORD(cvd[205]));
voice_command(s, "OK");
result = 0LL;
voice_modem_state = 1;
return result;
}

original_code:
int V253modem_init (void)
     {
     char buffer[(256)];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing V253 voice modem");
     V253_init_compression_table();
     sprintf(buffer, "AT+FCLASS=8");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "could not set +FCLASS=8");
     V253_querry_compressions();
     sprintf(buffer, "AT+VSD=%d,%d", (int)cvd.rec_silence_threshold.d.i , (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence threshold VSD");
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = 50;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 255 / 100 );
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set speaker volume");
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = 50;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 255 / 100 );
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set record volume");
     sprintf(buffer,
             "AT+VRA=%d;+VRN=%d",
             (int)cvd.ringback_goes_away.d.i,
             (int)cvd.ringback_never_came.d.i/10);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting ringback delay didn't work");
     if ((cvd.do_hard_flow.d.i) && (voice_command("AT+IFC=2,2", "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_command("AT+VCID=1", "OK");
     voice_command("AT+VNH=0", "OK");
     voice_command("AT+VIT=0", "OK");
     sprintf(buffer, "AT+VDR=1,%d", (int)cvd.ring_report_delay.d.i);
     voice_command(buffer, "OK");
     voice_modem_state = (0x0001);
     return((0));
     }

canonical_original_code:
int V253modem_init()
     {
     char buffer[-1];
     reset_watchdog();
     voice_modem_state = (0x0002);
     lprintf(4, "initializing V253 voice modem");
     V253_init_compression_table();
     sprintf(buffer, "AT+FCLASS=8");
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "could not set +FCLASS=8");
     V253_querry_compressions();
     sprintf(buffer, "AT+VSD=%d,%d", (int)cvd.rec_silence_threshold.d.i , (int)cvd.rec_silence_len.d.i);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set silence threshold VSD");
     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = 50;
     sprintf(buffer, "AT+VGT=%d", (int)cvd.transmit_gain.d.i * 255 / 100 );
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set speaker volume");
     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = 50;
     sprintf(buffer, "AT+VGR=%d", (int)cvd.receive_gain.d.i * 255 / 100 );
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "can't set record volume");
     sprintf(buffer,
             "AT+VRA=%d;+VRN=%d",
             (int)cvd.ringback_goes_away.d.i,
             (int)cvd.ringback_never_came.d.i/10);
     if (voice_command(buffer, "OK") != (0x1000))
          lprintf(3, "setting ringback delay didn't work");
     if ((cvd.do_hard_flow.d.i) && (voice_command("AT+IFC=2,2", "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_command("AT+VCID=1", "OK");
     voice_command("AT+VNH=0", "OK");
     voice_command("AT+VIT=0", "OK");
     sprintf(buffer, "AT+VDR=1,%d", (int)cvd.ring_report_delay.d.i);
     voice_command(buffer, "OK");
     voice_modem_state = (0x0001);
     return((0));
     }

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; }


oops

decompiled_code:
void oops()
{
got_interrupt = 1;
}

canonical_decompiled_code:
void func0()
{
got_interrupt = 1;
}

original_code:
RETSIGTYPE oops()
  { got_interrupt=(1==1); }

canonical_original_code:
void oops()
  { got_interrupt=(1==1); }


lprintf

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

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

original_code: int lprintf(int level, const char *format, ...) { return 0; }

canonical_original_code: int lprintf(int level, char *format, ...) { return 0; }

variable_types: level int

variable_types:
format
char *


lputs

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

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

original_code: int lputs( int level, char * string ) { return 0; }

canonical_original_code: int lputs(int level, char *string) { return 0; }

variable_types:
string
char *


decompiled_code:
void __fastcall __noreturn exit_usage(const char *a1, const char *a2)
{
if ( a2 )
fprintf(stderr, "%s: %s\n", a1, a2);
fwrite("valid options: -m, -M <mailaddr>, -f <file>, -Q, -s <speed>\n", 1uLL, 0x3CuLL, stderr);
exit(99);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(const char *a1, const char *a2)
{
if ( a2 )
fprintf(stderr, "%s: %s\n", a1, a2);
fwrite("valid options: -m, -M <mailaddr>, -f <file>, -Q, -s <speed>\n", 1uLL, 0x3CuLL, stderr);
exit(99);
}

original_code:
void exit_usage( char * program, char * msg )
{
    if ( msg != ((void *)0) )
 fprintf( stderr, "%s: %s\n", program, msg );
    fprintf( stderr, "valid options: -m, -M <mailaddr>, -f <file>, -Q, -s <speed>\n" );
    exit(99);
}

canonical_original_code:
void exit_usage(char *program, char *msg)
{
    if ( msg != ((void *)0) )
 fprintf( stderr, "%s: %s\n", program, msg );
    fprintf( stderr, "valid options: -m, -M <mailaddr>, -f <file>, -Q, -s <speed>\n" );
    exit(99);
}

variable_types:
program
char *

variable_types:
msg
char *


decompiled_code:
__int64 __fastcall Elsa_set_device(unsigned int a1)
{
const char *v1; // rax
unsigned int v2; // er12
__int64 result; // rax
const char *v4; // rax

reset_watchdog();
v1 = (const char *)voice_device_mode_name(a1);
lprintf(6LL, "%s: %s: (%d)", (const char *)*voice_modem, v1, a1);
switch ( a1 )
{
case 1u:
case 2u:
v2 = voice_command("AT#VLS=0", "OK|VCON");
goto LABEL_3;
case 4u:
v2 = voice_command("AT#VLS=3", "OK|VCON");
goto LABEL_3;
case 6u:
v2 = voice_command("AT#VLS=2", "OK|VCON");
result = 0LL;
if ( v2 - 4096 > 1 )
goto LABEL_7;
return result;
case 7u:
v2 = voice_command("AT#VLS=1", "OK|VCON");
goto LABEL_3;
case 9u:
v2 = voice_command("AT#VLS=4", "OK|VCON");
goto LABEL_3;
case 0xCu:
v2 = voice_command("AT#VLS=5", "OK|VCON");
LABEL_3:
result = 0LL;
if ( v2 - 4096 > 1 )
{
LABEL_7:
v4 = (const char *)voice_device_mode_name(a1);
lprintf(3LL, "can't set %s (modem hardware can't do that), error 0x%x", v4, v2);
result = 16385LL;
}
break;
default:
lprintf(3LL, "%s: Unknown device (%d)", (const char *)*voice_modem, a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
const char *v1; // rax
unsigned int v2; // er12
__int64 result; // rax
const char *v4; // rax

reset_watchdog();
v1 = (const char *)voice_device_mode_name(a1);
lprintf(6LL, "%s: %s: (%d)", (const char *)*voice_modem, v1, a1);
switch ( a1 )
{
case 1u:
case 2u:
v2 = voice_command("AT#VLS=0", "OK|VCON");
goto LABEL_3;
case 4u:
v2 = voice_command("AT#VLS=3", "OK|VCON");
goto LABEL_3;
case 6u:
v2 = voice_command("AT#VLS=2", "OK|VCON");
result = 0LL;
if ( v2 - 4096 > 1 )
goto LABEL_7;
return result;
case 7u:
v2 = voice_command("AT#VLS=1", "OK|VCON");
goto LABEL_3;
case 9u:
v2 = voice_command("AT#VLS=4", "OK|VCON");
goto LABEL_3;
case 0xCu:
v2 = voice_command("AT#VLS=5", "OK|VCON");
LABEL_3:
result = 0LL;
if ( v2 - 4096 > 1 )
{
LABEL_7:
v4 = (const char *)voice_device_mode_name(a1);
lprintf(3LL, "can't set %s (modem hardware can't do that), error 0x%x", v4, v2);
result = 16385LL;
}
break;
default:
lprintf(3LL, "%s: Unknown device (%d)", (const char *)*voice_modem, a1);
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
static int Elsa_set_device (int device)
     {
       int Result;
       reset_watchdog();
       lprintf(6, "%s: %s: (%d)", voice_modem->name,
        voice_device_mode_name(device), device);
       switch (device)
  {
  case (0x0001):
    Result = voice_command("AT#VLS=0", "OK|VCON");
    break;
  case (0x0002):
    Result = voice_command("AT#VLS=0", "OK|VCON");
    break;
  case (0x0009):
    Result = voice_command("AT#VLS=4", "OK|VCON");
    break;
  case (0x0004):
    Result = voice_command("AT#VLS=3", "OK|VCON");
    break;
  case (0x0006):
    Result = voice_command("AT#VLS=2", "OK|VCON");
    break;
  case (0x000C):
    Result = voice_command("AT#VLS=5", "OK|VCON");
    break;
  case (0x0007):
    Result = voice_command("AT#VLS=1", "OK|VCON");
    break;
  default:
    lprintf(3, "%s: Unknown device (%d)",
     voice_modem->name, device);
    return((-1));
          }
       if ((Result != (0x1000)) && (Result != (0x1001)))
  {
    lprintf(3,
     "can't set %s (modem hardware can't do that), error 0x%x",
     voice_device_mode_name(device),
     Result);
    return((0x4001));
  }
       return((0));
     }

canonical_original_code:
static int Elsa_set_device(int device)
     {
       int Result;
       reset_watchdog();
       lprintf(6, "%s: %s: (%d)", voice_modem->name,
        voice_device_mode_name(device), device);
       switch (device)
  {
  case (0x0001):
    Result = voice_command("AT#VLS=0", "OK|VCON");
    break;
  case (0x0002):
    Result = voice_command("AT#VLS=0", "OK|VCON");
    break;
  case (0x0009):
    Result = voice_command("AT#VLS=4", "OK|VCON");
    break;
  case (0x0004):
    Result = voice_command("AT#VLS=3", "OK|VCON");
    break;
  case (0x0006):
    Result = voice_command("AT#VLS=2", "OK|VCON");
    break;
  case (0x000C):
    Result = voice_command("AT#VLS=5", "OK|VCON");
    break;
  case (0x0007):
    Result = voice_command("AT#VLS=1", "OK|VCON");
    break;
  default:
    lprintf(3, "%s: Unknown device (%d)",
     voice_modem->name, device);
    return((-1));
          }
       if ((Result != (0x1000)) && (Result != (0x1001)))
  {
    lprintf(3,
     "can't set %s (modem hardware can't do that), error 0x%x",
     voice_device_mode_name(device),
     Result);
    return((0x4001));
  }
       return((0));
     }