decompiled_code:
__int64 PITCH_LockMemory()
{
int v0; // ebx
__int64 result; // rax

v0 = DPMI_LockMemoryRegion(PITCH_GetScale, PITCH_LockEnd);
result = v0 | (unsigned int)DPMI_LockMemory(PitchTable, 2400LL);
if ( (_DWORD)result )
{
PITCH_UnlockMemory();
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
__int64 result; // rax

v0 = DPMI_LockMemoryRegion(PITCH_GetScale, PITCH_LockEnd);
result = v0 | (unsigned int)DPMI_LockMemory(PitchTable, 2400LL);
if ( (_DWORD)result )
{
func2();
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int PITCH_LockMemory
   (
   void
   )
   {
   int status;
   status = DPMI_LockMemoryRegion( PITCH_GetScale, PITCH_LockEnd );
   status |= ( DPMI_LockMemory( (void *) &( PitchTable ), sizeof( PitchTable ) ) );
   if ( status != DPMI_Ok )
      {
      PITCH_UnlockMemory();
      return( PITCH_Error );
      }
   return( PITCH_Ok );
   }

canonical_original_code:
int PITCH_LockMemory()
   {
   int status;
   status = DPMI_LockMemoryRegion( PITCH_GetScale, PITCH_LockEnd );
   status |= ( DPMI_LockMemory( (void *) &( PitchTable ), sizeof( PitchTable ) ) );
   if ( status != DPMI_Ok )
      {
      PITCH_UnlockMemory();
      return( PITCH_Error );
      }
   return( PITCH_Ok );
   }

variable_types: status int


repo: lantus/ROTT

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

switch ( a1 )
{
case -2:
case -1:
result = (const char *)FX_ErrorString((unsigned int)FX_ErrorCode);
break;
case 0:
result = "Fx ok.";
break;
case 1:
result = "Apogee Sound System Version 1.12 Programmed by Jim Dose\n"
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
break;
case 2:
result = "Unknown Fx error code.";
break;
case 3:
result = (const char *)DSL_ErrorString(0xFFFFFFFFLL);
break;
case 4:
result = "Invalid Sound Fx device.";
break;
case 5:
result = (const char *)MV_ErrorString(0xFFFFFFFFLL);
break;
case 6:
result = "DPMI Error in FX_MAN.";
break;
default:
result = "Unknown Fx error code.";
break;
}
return result;
}

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

switch ( a1 )
{
case -2:
case -1:
result = (const char *)func0((unsigned int)FX_ErrorCode);
break;
case 0:
result = "Fx ok.";
break;
case 1:
result = "Apogee Sound System Version 1.12 Programmed by Jim Dose\n"
"(c) Copyright 1995 James R. Dose. All Rights Reserved.\n";
break;
case 2:
result = "Unknown Fx error code.";
break;
case 3:
result = (const char *)DSL_ErrorString(0xFFFFFFFFLL);
break;
case 4:
result = "Invalid Sound Fx device.";
break;
case 5:
result = (const char *)MV_ErrorString(0xFFFFFFFFLL);
break;
case 6:
result = "DPMI Error in FX_MAN.";
break;
default:
result = "Unknown Fx error code.";
break;
}
return result;
}

original_code:
char *FX_ErrorString
   (
   int ErrorNumber
   )
   {
   char *ErrorString;
   switch( ErrorNumber )
      {
      case FX_Warning :
      case FX_Error :
         ErrorString = FX_ErrorString( FX_ErrorCode );
         break;
      case FX_Ok :
         ErrorString = "Fx ok.";
         break;
      case FX_ASSVersion :
         ErrorString = "Apogee Sound System Version " "1.12" "  "
            "Programmed by Jim Dose\n"
            "(c) Copyright 1995 James R. Dose.  All Rights Reserved.\n";
         break;
      case FX_SoundCardError :
         ErrorString = DSL_ErrorString( DSL_Error );
         break;
      case FX_InvalidCard :
         ErrorString = "Invalid Sound Fx device.";
         break;
      case FX_MultiVocError :
         ErrorString = MV_ErrorString( MV_Error );
         break;
      case FX_DPMI_Error :
         ErrorString = "DPMI Error in FX_MAN.";
         break;
      default :
         ErrorString = "Unknown Fx error code.";
         break;
      }
   return( ErrorString );
   }

canonical_original_code:
char *FX_ErrorString(int ErrorNumber)
   {
   char *ErrorString;
   switch( ErrorNumber )
      {
      case FX_Warning :
      case FX_Error :
         ErrorString = FX_ErrorString( FX_ErrorCode );
         break;
      case FX_Ok :
         ErrorString = "Fx ok.";
         break;
      case FX_ASSVersion :
         ErrorString = "Apogee Sound System Version " "1.12" "  "
            "Programmed by Jim Dose\n"
            "(c) Copyright 1995 James R. Dose.  All Rights Reserved.\n";
         break;
      case FX_SoundCardError :
         ErrorString = DSL_ErrorString( DSL_Error );
         break;
      case FX_InvalidCard :
         ErrorString = "Invalid Sound Fx device.";
         break;
      case FX_MultiVocError :
         ErrorString = MV_ErrorString( MV_Error );
         break;
      case FX_DPMI_Error :
         ErrorString = "DPMI Error in FX_MAN.";
         break;
      default :
         ErrorString = "Unknown Fx error code.";
         break;
      }
   return( ErrorString );
   }

variable_types: ErrorNumber int

variable_types:
ErrorString
char *

return_type: char *


decompiled_code:
__int64 __fastcall FX_SetupCard(int a1, _DWORD *a2)
{
__int64 result; // rax

if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
FX_ErrorCode = 0;
result = DSL_Init();
if ( (_DWORD)result )
{
FX_ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
*a2 = 32;
a2[1] = 0;
a2[2] = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, _DWORD *a2)
{
__int64 result; // rax

if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
FX_ErrorCode = 0;
result = DSL_Init();
if ( (_DWORD)result )
{
FX_ErrorCode = 3;
result = 0xFFFFFFFFLL;
}
else
{
*a2 = 32;
a2[1] = 0;
a2[2] = 0;
}
}
return result;
}

original_code:
int FX_SetupCard
   (
   int SoundCard,
   fx_device *device
   )
   {
   int status;
   int DeviceStatus;
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   FX_SoundDevice = SoundCard;
   status = FX_Ok;
   FX_ErrorCode = ( FX_Ok );;
      DeviceStatus = DSL_Init();
      if ( DeviceStatus != DSL_Ok )
         {
         FX_ErrorCode = ( FX_SoundCardError );;
         status = FX_Error;
         }
         else
         {
         device->MaxVoices = 32;
         device->MaxSampleBits = 0;
         device->MaxChannels = 0;
         }
   return( status );
   }

canonical_original_code:
int FX_SetupCard(int SoundCard, struct fx_device *device)
   {
   int status;
   int DeviceStatus;
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   FX_SoundDevice = SoundCard;
   status = FX_Ok;
   FX_ErrorCode = ( FX_Ok );;
      DeviceStatus = DSL_Init();
      if ( DeviceStatus != DSL_Ok )
         {
         FX_ErrorCode = ( FX_SoundCardError );;
         status = FX_Error;
         }
         else
         {
         device->MaxVoices = 32;
         device->MaxSampleBits = 0;
         device->MaxChannels = 0;
         }
   return( status );
   }

variable_types: SoundCard int

variable_types: struct fx_device { int MaxVoices; int MaxSampleBits; int MaxChannels; } *

variable_types: DeviceStatus int

return_type: int


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

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

original_code:
int FX_GetBlasterSettings
   (
   fx_blaster_config *blaster
   )
   {
   return( FX_Ok );
   }

canonical_original_code:
int FX_GetBlasterSettings(struct fx_blaster_config *blaster)
   {
   return( FX_Ok );
   }

variable_types: struct fx_blaster_config { unsigned long Address; unsigned long Type; unsigned long Interrupt; unsigned long Dma8; unsigned long Dma16; unsigned long Midi; unsigned long Emu; } *


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

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

original_code:
int FX_SetupSoundBlaster
   (
   fx_blaster_config blaster,
   int *MaxVoices,
   int *MaxSampleBits,
   int *MaxChannels
   )
   {
   return( FX_Ok );
   }

canonical_original_code:
int FX_SetupSoundBlaster(struct fx_blaster_config blaster, int *MaxVoices, int *MaxSampleBits, int *MaxChannels)
   {
   return( FX_Ok );
   }

variable_types: struct fx_blaster_config { unsigned long Address; unsigned long Type; unsigned long Interrupt; unsigned long Dma8; unsigned long Dma16; unsigned long Midi; unsigned long Emu; }

variable_types:
MaxVoices
int *

variable_types:
MaxSampleBits
int *

variable_types:
MaxChannels
int *


decompiled_code:
__int64 FX_Shutdown()
{
unsigned int v0; // ebx

v0 = FX_Installed;
if ( FX_Installed )
{
if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
v0 = MV_Shutdown();
if ( v0 )
{
FX_ErrorCode = 5;
v0 = -1;
}
}
else
{
FX_ErrorCode = 4;
v0 = -1;
}
FX_Installed = 0;
LL_UnlockMemory();
}
return v0;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // ebx

v0 = FX_Installed;
if ( FX_Installed )
{
if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
v0 = MV_Shutdown();
if ( v0 )
{
FX_ErrorCode = 5;
v0 = -1;
}
}
else
{
FX_ErrorCode = 4;
v0 = -1;
}
FX_Installed = 0;
LL_UnlockMemory();
}
return v0;
}

original_code:
int FX_Shutdown
   (
   void
   )
   {
   int status;
   if ( !FX_Installed )
      {
      return( FX_Ok );
      }
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         status = MV_Shutdown();
         if ( status != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   FX_Installed = ( !( 1 == 1 ) );
   LL_UnlockMemory();
   return( status );
   }

canonical_original_code:
int FX_Shutdown()
   {
   int status;
   if ( !FX_Installed )
      {
      return( FX_Ok );
      }
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         status = MV_Shutdown();
         if ( status != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   FX_Installed = ( !( 1 == 1 ) );
   LL_UnlockMemory();
   return( status );
   }


decompiled_code:
__int64 __fastcall FX_Init(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
__int64 result; // rax

if ( FX_Installed )
FX_Shutdown();
if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)LL_LockMemory() )
{
FX_ErrorCode = 6;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
if ( a1 <= 0xB && ((1LL << a1) & 0xF47) != 0 )
{
result = MV_Init(a1, a5, a2, a3, a4);
if ( !(_DWORD)result )
{
FX_Installed = 1;
return result;
}
FX_ErrorCode = 5;
}
else
{
FX_ErrorCode = 4;
}
LL_UnlockMemory();
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
__int64 result; // rax

if ( FX_Installed )
func4();
if ( (unsigned int)USER_CheckParameter("ASSVER") )
{
FX_ErrorCode = 1;
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)LL_LockMemory() )
{
FX_ErrorCode = 6;
result = 0xFFFFFFFFLL;
}
else
{
FX_SoundDevice = a1;
if ( a1 <= 0xB && ((1LL << a1) & 0xF47) != 0 )
{
result = MV_Init(a1, a5, a2, a3, a4);
if ( !(_DWORD)result )
{
FX_Installed = 1;
return result;
}
FX_ErrorCode = 5;
}
else
{
FX_ErrorCode = 4;
}
LL_UnlockMemory();
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int FX_Init
   (
   int SoundCard,
   int numvoices,
   int numchannels,
   int samplebits,
   unsigned mixrate
   )
   {
   int status;
   int devicestatus;
   if ( FX_Installed )
      {
      FX_Shutdown();
      }
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   status = LL_LockMemory();
   if ( status != LL_Ok )
      {
      FX_ErrorCode = ( FX_DPMI_Error );;
      return( FX_Error );
      }
   FX_MixRate = mixrate;
   status = FX_Ok;
   FX_SoundDevice = SoundCard;
   switch( SoundCard )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices,
            numchannels, samplebits );
         if ( devicestatus != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   if ( status != FX_Ok )
      {
      LL_UnlockMemory();
      }
   else
      {
      FX_Installed = ( 1 == 1 );
      }
   return( status );
   }

canonical_original_code:
int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits, unsigned int mixrate)
   {
   int status;
   int devicestatus;
   if ( FX_Installed )
      {
      FX_Shutdown();
      }
   if ( USER_CheckParameter( "ASSVER" ) )
      {
      FX_ErrorCode = ( FX_ASSVersion );;
      return( FX_Error );
      }
   status = LL_LockMemory();
   if ( status != LL_Ok )
      {
      FX_ErrorCode = ( FX_DPMI_Error );;
      return( FX_Error );
      }
   FX_MixRate = mixrate;
   status = FX_Ok;
   FX_SoundDevice = SoundCard;
   switch( SoundCard )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         devicestatus = MV_Init( SoundCard, FX_MixRate, numvoices,
            numchannels, samplebits );
         if ( devicestatus != MV_Ok )
            {
            FX_ErrorCode = ( FX_MultiVocError );;
            status = FX_Error;
            }
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   if ( status != FX_Ok )
      {
      LL_UnlockMemory();
      }
   else
      {
      FX_Installed = ( 1 == 1 );
      }
   return( status );
   }

variable_types: numvoices int

variable_types: numchannels int

variable_types: samplebits int

variable_types:
mixrate
unsigned int

variable_types: devicestatus int


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

if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
MV_SetCallBack();
result = 0LL;
}
else
{
FX_ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( (unsigned int)FX_SoundDevice <= 0xB && ((1LL << FX_SoundDevice) & 0xF47) != 0 )
{
MV_SetCallBack();
result = 0LL;
}
else
{
FX_ErrorCode = 4;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int FX_SetCallBack
   (
   void ( *function )( unsigned long )
   )
   {
   int status;
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         MV_SetCallBack( function );
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   return( status );
   }

canonical_original_code:
int FX_SetCallBack(void (*function)(unsigned long))
   {
   int status;
   status = FX_Ok;
   switch( FX_SoundDevice )
      {
      case SoundBlaster :
      case Awe32 :
      case ProAudioSpectrum :
      case SoundMan16 :
      case SoundScape :
      case SoundSource :
      case TandySoundSource :
      case UltraSound :
         MV_SetCallBack( function );
         break;
      default :
         FX_ErrorCode = ( FX_InvalidCard );;
         status = FX_Error;
      }
   return( status );
   }

variable_types:
function
void (*)(unsigned long)


decompiled_code:
__int64 FX_SetVolume()
{
return MV_SetVolume();
}

canonical_decompiled_code:
__int64 func7()
{
return MV_SetVolume();
}

original_code:
void FX_SetVolume
   (
   int volume
   )
   {
   int status;
   MV_SetVolume( volume );
   }

canonical_original_code:
void FX_SetVolume(int volume)
   {
   int status;
   MV_SetVolume( volume );
   }

variable_types: volume int

variable_types: status int

return_type: void


decompiled_code:
__int64 FX_GetVolume()
{
return MV_GetVolume();
}

canonical_decompiled_code:
__int64 func8()
{
return MV_GetVolume();
}

original_code:
int FX_GetVolume
   (
   void
   )
   {
   int volume;
   volume = MV_GetVolume();
   return( volume );
   }

canonical_original_code:
int FX_GetVolume()
   {
   int volume;
   volume = MV_GetVolume();
   return( volume );
   }


decompiled_code:
__int64 FX_SetReverseStereo()
{
return MV_SetReverseStereo();
}

canonical_decompiled_code:
__int64 func9()
{
return MV_SetReverseStereo();
}

original_code:
void FX_SetReverseStereo
   (
   int setting
   )
   {
   MV_SetReverseStereo( setting );
   }

canonical_original_code:
void FX_SetReverseStereo(int setting)
   {
   MV_SetReverseStereo( setting );
   }

variable_types: setting int


decompiled_code:
__int64 FX_GetReverseStereo()
{
return MV_GetReverseStereo();
}

canonical_decompiled_code:
__int64 func10()
{
return MV_GetReverseStereo();
}

original_code:
int FX_GetReverseStereo
   (
   void
   )
   {
   return MV_GetReverseStereo();
   }

canonical_original_code:
int FX_GetReverseStereo()
   {
   return MV_GetReverseStereo();
   }


decompiled_code:
__int64 FX_SetReverb()
{
return MV_SetReverb();
}

canonical_decompiled_code:
__int64 func11()
{
return MV_SetReverb();
}

original_code:
void FX_SetReverb
   (
   int reverb
   )
   {
   MV_SetReverb( reverb );
   }

canonical_original_code:
void FX_SetReverb(int reverb)
   {
   MV_SetReverb( reverb );
   }

variable_types: reverb int


decompiled_code:
__int64 FX_SetFastReverb()
{
return MV_SetFastReverb();
}

canonical_decompiled_code:
__int64 func12()
{
return MV_SetFastReverb();
}

original_code:
void FX_SetFastReverb
   (
   int reverb
   )
   {
   MV_SetFastReverb( reverb );
   }

canonical_original_code:
void FX_SetFastReverb(int reverb)
   {
   MV_SetFastReverb( reverb );
   }


decompiled_code:
__int64 FX_GetMaxReverbDelay()
{
return MV_GetMaxReverbDelay();
}

canonical_decompiled_code:
__int64 func13()
{
return MV_GetMaxReverbDelay();
}

original_code:
int FX_GetMaxReverbDelay
   (
   void
   )
   {
   return MV_GetMaxReverbDelay();
   }

canonical_original_code:
int FX_GetMaxReverbDelay()
   {
   return MV_GetMaxReverbDelay();
   }


decompiled_code:
__int64 FX_GetReverbDelay()
{
return MV_GetReverbDelay();
}

canonical_decompiled_code:
__int64 func14()
{
return MV_GetReverbDelay();
}

original_code:
int FX_GetReverbDelay
   (
   void
   )
   {
   return MV_GetReverbDelay();
   }

canonical_original_code:
int FX_GetReverbDelay()
   {
   return MV_GetReverbDelay();
   }


decompiled_code:
__int64 FX_SetReverbDelay()
{
return MV_SetReverbDelay();
}

canonical_decompiled_code:
__int64 func15()
{
return MV_SetReverbDelay();
}

original_code:
void FX_SetReverbDelay
   (
   int delay
   )
   {
   MV_SetReverbDelay( delay );
   }

canonical_original_code:
void FX_SetReverbDelay(int delay)
   {
   MV_SetReverbDelay( delay );
   }

variable_types: delay int


decompiled_code:
__int64 FX_VoiceAvailable()
{
return MV_VoiceAvailable();
}

canonical_decompiled_code:
__int64 func16()
{
return MV_VoiceAvailable();
}

original_code:
int FX_VoiceAvailable
   (
   int priority
   )
   {
   return MV_VoiceAvailable( priority );
   }

canonical_original_code:
int FX_VoiceAvailable(int priority)
   {
   return MV_VoiceAvailable( priority );
   }

variable_types: priority int


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

result = MV_EndLooping();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_EndLooping();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_EndLooping
   (
   int handle
   )
   {
   int status;
   status = MV_EndLooping( handle );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_EndLooping(int handle)
   {
   int status;
   status = MV_EndLooping( handle );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: handle int


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

result = MV_SetPan();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_SetPan();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_SetPan
   (
   int handle,
   int vol,
   int left,
   int right
   )
   {
   int status;
   status = MV_SetPan( handle, vol, left, right );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_SetPan(int handle, int vol, int left, int right)
   {
   int status;
   status = MV_SetPan( handle, vol, left, right );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: vol int

variable_types: left int

variable_types: right int


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

result = MV_SetPitch();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_SetPitch();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_SetPitch
   (
   int handle,
   int pitchoffset
   )
   {
   int status;
   status = MV_SetPitch( handle, pitchoffset );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_SetPitch(int handle, int pitchoffset)
   {
   int status;
   status = MV_SetPitch( handle, pitchoffset );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: pitchoffset int


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

result = MV_SetFrequency();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_SetFrequency();
if ( (_DWORD)result == -1 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_SetFrequency
   (
   int handle,
   int frequency
   )
   {
   int status;
   status = MV_SetFrequency( handle, frequency );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_SetFrequency(int handle, int frequency)
   {
   int status;
   status = MV_SetFrequency( handle, frequency );
   if ( status == MV_Error )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: frequency int


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

result = MV_PlayVOC(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayVOC(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayVOC
   (
   char *ptr,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayVOC(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayVOC( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types:
ptr
char *

variable_types:
callbackval
unsigned long


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

result = MV_PlayLoopedVOC(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayLoopedVOC(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayLoopedVOC
   (
   char *ptr,
   long loopstart,
   long loopend,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayLoopedVOC(char *ptr, long loopstart, long loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayLoopedVOC( ptr, loopstart, loopend, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types: loopstart long

variable_types: loopend long


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

result = MV_PlayWAV(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayWAV(a1);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayWAV
   (
   char *ptr,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayWAV(char *ptr, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayWAV( ptr, pitchoffset, vol, left, right,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }


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

result = MV_PlayLoopedWAV(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayLoopedWAV(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayLoopedWAV
   (
   char *ptr,
   long loopstart,
   long loopend,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayLoopedWAV( ptr, loopstart, loopend,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayLoopedWAV(char *ptr, long loopstart, long loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayLoopedWAV( ptr, loopstart, loopend,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }


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

result = MV_PlayVOC3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayVOC3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayVOC3D
   (
   char *ptr,
   int pitchoffset,
   int angle,
   int distance,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayVOC3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayVOC3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types: angle int

variable_types: distance int


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

result = MV_PlayWAV3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayWAV3D();
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayWAV3D
   (
   char *ptr,
   int pitchoffset,
   int angle,
   int distance,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayWAV3D(char *ptr, int pitchoffset, int angle, int distance, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayWAV3D( ptr, pitchoffset, angle, distance,
      priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }


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

result = MV_PlayRaw(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_PlayRaw(a1, a2, a3);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayRaw
   (
   char *ptr,
   unsigned long length,
   unsigned rate,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayRaw( ptr, length, rate, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayRaw(char *ptr, unsigned long length, unsigned int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayRaw( ptr, length, rate, pitchoffset,
      vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types:
length
unsigned long

variable_types:
rate
unsigned int


decompiled_code:
__int64 __fastcall FX_PlayLoopedRaw(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

result = MV_PlayLoopedRaw(a1, a2, a3, a4, a5);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func28(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

result = MV_PlayLoopedRaw(a1, a2, a3, a4, a5);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_PlayLoopedRaw
   (
   char *ptr,
   unsigned long length,
   char *loopstart,
   char *loopend,
   unsigned rate,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend,
      rate, pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_PlayLoopedRaw(char *ptr, unsigned long length, char *loopstart, char *loopend, unsigned int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_PlayLoopedRaw( ptr, length, loopstart, loopend,
      rate, pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types:
loopstart
char *

variable_types:
loopend
char *


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

result = MV_Pan3D();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_Pan3D();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_Pan3D
   (
   int handle,
   int angle,
   int distance
   )
   {
   int status;
   status = MV_Pan3D( handle, angle, distance );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

canonical_original_code:
int FX_Pan3D(int handle, int angle, int distance)
   {
   int status;
   status = MV_Pan3D( handle, angle, distance );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      status = FX_Warning;
      }
   return( status );
   }

variable_types: status int


decompiled_code:
__int64 FX_SoundActive()
{
return MV_VoicePlaying();
}

canonical_decompiled_code:
__int64 func30()
{
return MV_VoicePlaying();
}

original_code:
int FX_SoundActive
   (
   int handle
   )
   {
   return( MV_VoicePlaying( handle ) );
   }

canonical_original_code:
int FX_SoundActive(int handle)
   {
   return( MV_VoicePlaying( handle ) );
   }

variable_types: handle int


decompiled_code:
__int64 FX_SoundsPlaying()
{
return MV_VoicesPlaying();
}

canonical_decompiled_code:
__int64 func31()
{
return MV_VoicesPlaying();
}

original_code:
int FX_SoundsPlaying
   (
   void
   )
   {
   return( MV_VoicesPlaying() );
   }

canonical_original_code:
int FX_SoundsPlaying()
   {
   return( MV_VoicesPlaying() );
   }


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

result = MV_Kill();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_Kill();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_StopSound
   (
   int handle
   )
   {
   int status;
   status = MV_Kill( handle );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }

canonical_original_code:
int FX_StopSound(int handle)
   {
   int status;
   status = MV_Kill( handle );
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }


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

result = MV_KillAllVoices();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_KillAllVoices();
if ( (_DWORD)result )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_StopAllSounds
   (
   void
   )
   {
   int status;
   status = MV_KillAllVoices();
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }

canonical_original_code:
int FX_StopAllSounds()
   {
   int status;
   status = MV_KillAllVoices();
   if ( status != MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      return( FX_Warning );
      }
   return( FX_Ok );
   }


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

result = MV_StartDemandFeedPlayback(a1, a2);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

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

result = MV_StartDemandFeedPlayback(a1, a2);
if ( (int)result < 0 )
{
FX_ErrorCode = 5;
result = 4294967294LL;
}
return result;
}

original_code:
int FX_StartDemandFeedPlayback
   (
   void ( *function )( char **ptr, unsigned long *length ),
   int rate,
   int pitchoffset,
   int vol,
   int left,
   int right,
   int priority,
   unsigned long callbackval
   )
   {
   int handle;
   handle = MV_StartDemandFeedPlayback( function, rate,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

canonical_original_code:
int FX_StartDemandFeedPlayback(void (*function)(char **ptr, unsigned long *length), int rate, int pitchoffset, int vol, int left, int right, int priority, unsigned long callbackval)
   {
   int handle;
   handle = MV_StartDemandFeedPlayback( function, rate,
      pitchoffset, vol, left, right, priority, callbackval );
   if ( handle < MV_Ok )
      {
      FX_ErrorCode = ( FX_MultiVocError );;
      handle = FX_Warning;
      }
   return( handle );
   }

variable_types: void (*)(char **ptr, unsigned long *length)

variable_types: rate int

variable_types: vol int

variable_types: priority int


decompiled_code:
__int64 FX_StartRecording()
{
FX_ErrorCode = 4;
return 4294967294LL;
}

canonical_decompiled_code:
__int64 func35()
{
FX_ErrorCode = 4;
return 4294967294LL;
}

original_code:
int FX_StartRecording
   (
   int MixRate,
   void ( *function )( char *ptr, int length )
   )
   {
   int status;
   FX_ErrorCode = ( FX_InvalidCard );;
   status = FX_Warning;
   return( status );
   }

canonical_original_code:
int FX_StartRecording(int MixRate, void (*function)(char *ptr, int length))
   {
   int status;
   FX_ErrorCode = ( FX_InvalidCard );;
   status = FX_Warning;
   return( status );
   }

variable_types: MixRate int

variable_types:
function
void (*)(char *ptr, int length)


decompiled_code:
void FX_StopRecord()
{
;
}

canonical_decompiled_code:
void func36()
{
;
}

original_code:
void FX_StopRecord
   (
   void
   )
   {
   }

canonical_original_code:
void FX_StopRecord()
   {
   }


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

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

original_code:
unsigned long DPMI_GetRealModeVector
   (
   int num
   )
   {
   return 0;
   }

canonical_original_code:
unsigned long DPMI_GetRealModeVector(int num)
   {
   return 0;
   }

variable_types: num int

return_type: unsigned long


decompiled_code:
void DPMI_SetRealModeVector()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void DPMI_SetRealModeVector
   (
   int num,
   unsigned long vector
   )
   {
   }

canonical_original_code:
void DPMI_SetRealModeVector(int num, unsigned long vector)
   {
   }

variable_types:
vector
unsigned long


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

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

original_code:
int DPMI_CallRealModeFunction
   (
   dpmi_regs *callregs
   )
   {
   return( DPMI_Ok );
   }

canonical_original_code:
int DPMI_CallRealModeFunction(struct dpmi_regs *callregs)
   {
   return( DPMI_Ok );
   }

variable_types: struct dpmi_regs { unsigned long EDI; unsigned long ESI; unsigned long EBP; unsigned long Reserved; unsigned long EBX; unsigned long EDX; unsigned long ECX; unsigned long EAX; unsigned short Flags; unsigned short ES; unsigned short DS; unsigned short FS; unsigned short GS; unsigned short IP; unsigned short CS; unsigned short SP; unsigned short SS; } *


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

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

original_code:
int DPMI_LockMemory
   (
   void *address,
   unsigned length
   )
   {
   return ( DPMI_Ok );
   }

canonical_original_code:
int DPMI_LockMemory(void *address, unsigned int length)
   {
   return ( DPMI_Ok );
   }

variable_types:
address
void *

variable_types:
length
unsigned int


decompiled_code:
__int64 __fastcall DPMI_LockMemoryRegion(__int64 a1, __int64 a2)
{
return DPMI_LockMemory(a1, a2 - a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
return func3(a1, a2 - a1);
}

original_code:
int DPMI_LockMemoryRegion
   (
   void *start,
   void *end
   )
   {
   int status;
   status = DPMI_LockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }

canonical_original_code:
int DPMI_LockMemoryRegion(void *start, void *end)
   {
   int status;
   status = DPMI_LockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }

variable_types:
start
void *

variable_types:
end
void *


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

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

original_code:
int DPMI_UnlockMemory
   (
   void *address,
   unsigned length
   )
   {
   return ( DPMI_Ok );
   }

canonical_original_code:
int DPMI_UnlockMemory(void *address, unsigned int length)
   {
   return ( DPMI_Ok );
   }


decompiled_code:
__int64 __fastcall DPMI_UnlockMemoryRegion(__int64 a1, __int64 a2)
{
return DPMI_UnlockMemory(a1, a2 - a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
return func5(a1, a2 - a1);
}

original_code:
int DPMI_UnlockMemoryRegion
   (
   void *start,
   void *end
   )
   {
   int status;
   status = DPMI_UnlockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }

canonical_original_code:
int DPMI_UnlockMemoryRegion(void *start, void *end)
   {
   int status;
   status = DPMI_UnlockMemory( start, ( char * )end - ( char * )start );
   return( status );
   }


decompiled_code:
__int64 __fastcall DPMI_GetDOSMemory(_QWORD *a1, _QWORD *a2, unsigned int a3)
{
void *v3; // rax

v3 = malloc(a3);
*a1 = v3;
*a2 = v3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, _QWORD *a2, unsigned int a3)
{
void *v3; // rax

v3 = malloc(a3);
*a1 = v3;
*a2 = v3;
return 0LL;
}

original_code:
int DPMI_GetDOSMemory( void **ptr, long *descriptor, unsigned length )
{
 *ptr = (void *)malloc(length);
 *descriptor = (long) *ptr;
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

canonical_original_code:
int DPMI_GetDOSMemory(void **ptr, long *descriptor, unsigned int length)
{
 *ptr = (void *)malloc(length);
 *descriptor = (long) *ptr;
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

variable_types:
ptr
void **

variable_types:
descriptor
long *


decompiled_code:
__int64 __fastcall DPMI_FreeDOSMemory(void *a1)
{
free(a1);
return (unsigned int)-(a1 == 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func8(void *a1)
{
free(a1);
return (unsigned int)-(a1 == 0LL);
}

original_code:
int DPMI_FreeDOSMemory( long descriptor )
{
 free((void *)descriptor);
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

canonical_original_code:
int DPMI_FreeDOSMemory(long descriptor)
{
 free((void *)descriptor);
 return (descriptor == 0) ? DPMI_Error : DPMI_Ok;
}

variable_types: descriptor long


original_code:
void MV_16BitReverb( const char *src, char *dest, const VOLUME16 *volume, int count )
{
 int i;
 short *pdest = (short *)dest;
 for (i = 0; i < count; i++) {
  int sl = src[i*2+0];
  int sh = src[i*2+1] ^ 0x80;
  sl = (*volume)[sl] >> 8;
  sh = (*volume)[sh];
  pdest[i] = (short)(sl + sh + 0x80);
 }
}

canonical_original_code:
void MV_16BitReverb(char *src, char *dest, short (*volume)[256], int count)
{
 int i;
 short *pdest = (short *)dest;
 for (i = 0; i < count; i++) {
  int sl = src[i*2+0];
  int sh = src[i*2+1] ^ 0x80;
  sl = (*volume)[sl] >> 8;
  sh = (*volume)[sh];
  pdest[i] = (short)(sl + sh + 0x80);
 }
}

variable_types:
src
char *

variable_types:
dest
char *

variable_types:
volume
short (*)[256]

variable_types: count int

variable_types: i int

variable_types:
pdest
short *

variable_types: sl int

variable_types: sh int


original_code:
void MV_8BitReverb( const signed char *src, signed char *dest, const VOLUME16 *volume, int count )
{
 int i;
 for (i = 0; i < count; i++) {
  unsigned char s = (unsigned char) src[i];
  s = (*volume)[s] & 0xff;
  dest[i] = (char)(s + 0x80);
 }
}

canonical_original_code:
void MV_8BitReverb(char *src, char *dest, short (*volume)[256], int count)
{
 int i;
 for (i = 0; i < count; i++) {
  unsigned char s = (unsigned char) src[i];
  s = (*volume)[s] & 0xff;
  dest[i] = (char)(s + 0x80);
 }
}

variable_types:
s
unsigned char


original_code:
void MV_16BitReverbFast( const char *src, char *dest, int count, int shift )
{
 int i;
 short *pdest = (short *)dest;
 const short *psrc = (const short *)src;
 for (i = 0; i < count; i++) {
  pdest[i] = psrc[i] >> shift;
 }
}

canonical_original_code:
void MV_16BitReverbFast(char *src, char *dest, int count, int shift)
{
 int i;
 short *pdest = (short *)dest;
 short *psrc = (const short *)src;
 for (i = 0; i < count; i++) {
  pdest[i] = psrc[i] >> shift;
 }
}

variable_types: shift int

variable_types:
psrc
short *


decompiled_code:
__int64 __fastcall MV_8BitReverbFast(__int64 a1, __int64 a2, int a3, char a4)
{
__int64 result; // rax
int v7; // er10
__int64 v8; // rdi
__int64 i; // rsi
int v10; // edx

result = 128 >> a4;
v7 = -128 - result;
if ( a3 > 0 )
{
v8 = (unsigned int)a3;
for ( i = 0LL; i != v8; ++i )
{
v10 = (int)*(unsigned __int8 *)(a1 + i) >> a4;
result = v10 + v7 + (unsigned int)!(*(_BYTE *)(a1 + i) >> 7);
*(_BYTE *)(a2 + i) = v10 + v7 + !(*(_BYTE *)(a1 + i) >> 7);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3, char a4)
{
__int64 result; // rax
int v7; // er10
__int64 v8; // rdi
__int64 i; // rsi
int v10; // edx

result = 128 >> a4;
v7 = -128 - result;
if ( a3 > 0 )
{
v8 = (unsigned int)a3;
for ( i = 0LL; i != v8; ++i )
{
v10 = (int)*(unsigned __int8 *)(a1 + i) >> a4;
result = v10 + v7 + (unsigned int)!(*(_BYTE *)(a1 + i) >> 7);
*(_BYTE *)(a2 + i) = v10 + v7 + !(*(_BYTE *)(a1 + i) >> 7);
}
}
return result;
}

original_code:
void MV_8BitReverbFast( const signed char *src, signed char *dest, int count, int shift )
{
 int i;
 unsigned char sh = 0x80 - (0x80 >> shift);
 for (i = 0; i < count; i++) {
  unsigned char a = ((unsigned char) src[i]) >> shift;
  unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7;
  dest[i] = (signed char) (a + sh + c);
 }
}

canonical_original_code:
void MV_8BitReverbFast(char *src, char *dest, int count, int shift)
{
 int i;
 unsigned char sh = 0x80 - (0x80 >> shift);
 for (i = 0; i < count; i++) {
  unsigned char a = ((unsigned char) src[i]) >> shift;
  unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7;
  dest[i] = (char) (a + sh + c);
 }
}

variable_types:
sh
unsigned char

variable_types:
a
unsigned char

variable_types:
c
unsigned char


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

original_code:
int USER_CheckParameter
   (
   const char *parameter
   )
   {
   return ( !( 1 == 1 ) );
   }

canonical_original_code:
int USER_CheckParameter(char *parameter)
   {
   return ( !( 1 == 1 ) );
   }

variable_types:
parameter
char *


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

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

original_code:
char *USER_GetText
   (
   const char *parameter
   )
   {
   return ((void *)0);
   }

canonical_original_code:
char *USER_GetText(char *parameter)
   {
   return ((void *)0);
   }


decompiled_code:
__int64 __fastcall USRHOOKS_GetMem(_QWORD *a1, size_t a2)
{
void *v2; // rax

v2 = malloc(a2);
if ( !v2 )
return 0xFFFFFFFFLL;
*a1 = v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, size_t a2)
{
void *v2; // rax

v2 = malloc(a2);
if ( !v2 )
return 0xFFFFFFFFLL;
*a1 = v2;
return 0LL;
}

original_code:
int USRHOOKS_GetMem
   (
   void **ptr,
   unsigned long size
   )
   {
   void *memory;
   memory = malloc( size );
   if ( memory == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   *ptr = memory;
   return( USRHOOKS_Ok );
   }

canonical_original_code:
int USRHOOKS_GetMem(void **ptr, unsigned long size)
   {
   void *memory;
   memory = malloc( size );
   if ( memory == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   *ptr = memory;
   return( USRHOOKS_Ok );
   }

variable_types:
ptr
void **

variable_types:
size
unsigned long

variable_types:
memory
void *


decompiled_code:
__int64 __fastcall USRHOOKS_FreeMem(void *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
free(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
free(a1);
return 0LL;
}

original_code:
int USRHOOKS_FreeMem
   (
   void *ptr
   )
   {
   if ( ptr == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   free( ptr );
   return( USRHOOKS_Ok );
   }

canonical_original_code:
int USRHOOKS_FreeMem(void *ptr)
   {
   if ( ptr == ((void *)0) )
      {
      return( USRHOOKS_Error );
      }
   free( ptr );
   return( USRHOOKS_Ok );
   }

variable_types:
ptr
void *


decompiled_code:
void __fastcall lbs_arg_qopt_free_generic(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

if ( ptr )
{
lbs_strv_unref_generic(*(_QWORD *)ptr);
lbs_array_unref_generic(*((_QWORD *)ptr + 1));
v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
{
v3 = (char *)ptr + 40;
do
{
free(v2);
v3 += 16;
v2 = (void *)*((_QWORD *)v3 - 2);
}
while ( v2 );
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

if ( ptr )
{
lbs_strv_unref_generic(*(_QWORD *)ptr);
lbs_array_unref_generic(*((_QWORD *)ptr + 1));
v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
{
v3 = (char *)ptr + 40;
do
{
free(v2);
v3 += 16;
v2 = (void *)*((_QWORD *)v3 - 2);
}
while ( v2 );
}
free(ptr);
}
}

original_code:
void lbs_arg_qopt_free_generic (void* qopt_generic) {
    if (qopt_generic == ((void *)0)) {
        return;
    }
    LbsArgQopt* qopt = qopt_generic;
    (lbs_strv_unref_generic ((_Generic (((qopt->strv)), LbsStrv*: ((qopt->strv))))));
    (lbs_array_unref_generic ((_Generic (((qopt->detail)), LbsArray*: ((qopt->detail))))));
    for (int i = 0; qopt->opts[i].name != ((void *)0); i++) {
        free (qopt->opts[i].name);
    }
    free (qopt);
}

canonical_original_code:
void lbs_arg_qopt_free_generic(void *qopt_generic) {
    if (qopt_generic == ((void *)0)) {
        return;
    }
    struct LbsArgQoptStruct *qopt = qopt_generic;
    (lbs_strv_unref_generic ((_Generic (((qopt->strv)), struct LbsStrvStruct *: ((qopt->strv))))));
    (lbs_array_unref_generic ((_Generic (((qopt->detail)), struct LbsArrayStruct *: ((qopt->detail))))));
    for (int i = 0; qopt->opts[i].name != ((void *)0); i++) {
        free (qopt->opts[i].name);
    }
    free (qopt);
}

variable_types: struct LbsArgQoptStruct { struct LbsStrvStruct { struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; } array; unsigned int ref_count; _Bool is_alloc; } *strv; struct LbsArrayStruct *detail; unsigned long len; struct LbsArgQoptItemStruct { char *name; char *value; } opts[]; } *

user_defined_types: struct LbsArgQoptStruct { struct LbsStrvStruct *strv; struct LbsArrayStruct *detail; unsigned long len; struct LbsArgQoptItemStruct opts[]; }

user_defined_types: struct LbsStrvStruct { struct LbsArrayStruct array; unsigned int ref_count; _Bool is_alloc; }


decompiled_code:
__int64 __fastcall lbs_str_has_prefix(unsigned __int8 *a1, __int64 a2)
{
unsigned int v2; // edx
__int64 i; // rax
char v4; // cl

v2 = *a1;
for ( i = 0LL; (_BYTE)v2; v2 = a1[i] )
{
v4 = *(_BYTE *)(a2 + i);
if ( !v4 )
goto LABEL_8;
if ( v4 != (_BYTE)v2 )
return 0;
++i;
}
v2 = 1;
if ( *(_BYTE *)(a2 + i) )
{
v2 = 0;
LABEL_8:
LOBYTE(v2) = (_BYTE)v2 != 0;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, __int64 a2)
{
unsigned int v2; // edx
__int64 i; // rax
char v4; // cl

v2 = *a1;
for ( i = 0LL; (_BYTE)v2; v2 = a1[i] )
{
v4 = *(_BYTE *)(a2 + i);
if ( !v4 )
goto LABEL_8;
if ( v4 != (_BYTE)v2 )
return 0;
++i;
}
v2 = 1;
if ( *(_BYTE *)(a2 + i) )
{
v2 = 0;
LABEL_8:
LOBYTE(v2) = (_BYTE)v2 != 0;
}
return v2;
}

original_code:
_Bool lbs_str_has_prefix (const char* str, const char* prefix) {
    int i;
    for (i = 0; str[i] != '\0' && prefix[i] != '\0'; i++) {
        if (str[i] != prefix[i]) {
            return 0;
        }
    }
    if (str[i] == '\0' && prefix[i] == '\0') {
        return 1;
    }
    if (str[i] == '\0') {
        return 0;
    }
    return 1;
}

canonical_original_code:
_Bool lbs_str_has_prefix(char *str, char *prefix) {
    int i;
    for (i = 0; str[i] != '\0' && prefix[i] != '\0'; i++) {
        if (str[i] != prefix[i]) {
            return 0;
        }
    }
    if (str[i] == '\0' && prefix[i] == '\0') {
        return 1;
    }
    if (str[i] == '\0') {
        return 0;
    }
    return 1;
}

variable_types:
str
char *

variable_types:
prefix
char *


original_code:
_Bool lbs_str_has_suffix (const char* str, const char* suffix) {
    size_t len = strlen (str);
    size_t suflen = strlen (suffix);
    int i, j;
    for (i = len - 1, j = suflen - 1; i >= 0 && j >= 0; i--, j--) {
        if (str[i] != suffix[j]) {
            return 0;
        }
    }
    if (i < 0 && j >= 0) {
        return 0;
    }
    return 1;
}

canonical_original_code:
_Bool lbs_str_has_suffix(char *str, char *suffix) {
    unsigned long len = strlen (str);
    unsigned long suflen = strlen (suffix);
    int i; int j;
    for (i = len - 1, j = suflen - 1; i >= 0 && j >= 0; i--, j--) {
        if (str[i] != suffix[j]) {
            return 0;
        }
    }
    if (i < 0 && j >= 0) {
        return 0;
    }
    return 1;
}

variable_types:
suffix
char *

variable_types:
len
unsigned long

variable_types:
suflen
unsigned long

variable_types: i int

variable_types: j int


decompiled_code:
char *__fastcall lbs_str_vprintf(char *format, const __m128i *a2)
{
size_t v2; // rbx
char *v3; // r12
__m128i v5; // [rsp+0h] [rbp-58h] BYREF
__int64 v6; // [rsp+10h] [rbp-48h]
__m128i arg; // [rsp+18h] [rbp-40h] BYREF
__int64 v8; // [rsp+28h] [rbp-30h]

arg = _mm_loadu_si128(a2);
v8 = a2[1].m128i_i64[0];
v2 = vsnprintf(0LL, 0LL, format, &arg) + 1;
v3 = (char *)malloc(v2);
v5 = _mm_loadu_si128(a2);
v6 = a2[1].m128i_i64[0];
vsnprintf(v3, v2, format, &v5);
return v3;
}

canonical_decompiled_code:
char *__fastcall func2(char *format, const __m128i *a2)
{
size_t v2; // rbx
char *v3; // r12
__m128i v5; // [rsp+0h] [rbp-58h] BYREF
__int64 v6; // [rsp+10h] [rbp-48h]
__m128i arg; // [rsp+18h] [rbp-40h] BYREF
__int64 v8; // [rsp+28h] [rbp-30h]

arg = _mm_loadu_si128(a2);
v8 = a2[1].m128i_i64[0];
v2 = vsnprintf(0LL, 0LL, format, &arg) + 1;
v3 = (char *)malloc(v2);
v5 = _mm_loadu_si128(a2);
v6 = a2[1].m128i_i64[0];
vsnprintf(v3, v2, format, &v5);
return v3;
}

original_code:
char* lbs_str_vprintf (const char* format, va_list ap) {
    va_list ap1, ap2;
    char* newstr;
    int len;
    __builtin_va_copy(ap1,ap);
    len = vsnprintf (((void *)0), 0, format, ap1) + 1;
    __builtin_va_end(ap1);
    newstr = malloc (len);
    __builtin_va_copy(ap2,ap);
    vsnprintf (newstr, len, format, ap2);
    __builtin_va_end(ap2);
    return newstr;
}

canonical_original_code:
char *lbs_str_vprintf(char *format, __builtin_va_list ap) {
    __builtin_va_list ap1; __builtin_va_list ap2;
    char *newstr;
    int len;
    __builtin_va_copy(ap1,ap);
    len = vsnprintf (((void *)0), 0, format, ap1) + 1;
    __builtin_va_end(ap1);
    newstr = malloc (len);
    __builtin_va_copy(ap2,ap);
    vsnprintf (newstr, len, format, ap2);
    __builtin_va_end(ap2);
    return newstr;
}

variable_types:
format
char *

variable_types:
newstr
char *

variable_types: len int


decompiled_code:
char *lbs_str_printf(char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return lbs_str_vprintf(a1, (const __m128i *)va);
}

canonical_decompiled_code:
char *func3(char *a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return func2(a1, (const __m128i *)va);
}

original_code:
char* lbs_str_printf (const char* format, ...) {
    va_list ap;
    char* newstr;
    __builtin_va_start(ap,format);
    newstr = lbs_str_vprintf (format, ap);
    __builtin_va_end(ap);
    return newstr;
}

canonical_original_code:
char *lbs_str_printf(char *format, ...) {
    __builtin_va_list ap;
    char *newstr;
    __builtin_va_start(ap,format);
    newstr = lbs_str_vprintf (format, ap);
    __builtin_va_end(ap);
    return newstr;
}


decompiled_code:
__int64 __fastcall lbs_strv_init_with_max(__int64 a1, __int64 a2)
{
if ( (int)lbs_array_init_with_max(a1, 48LL, a2) < 0 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 48) = 1;
*(_BYTE *)(a1 + 52) = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
if ( (int)lbs_array_init_with_max(a1, 48LL, a2) < 0 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 48) = 1;
*(_BYTE *)(a1 + 52) = 0;
return 0LL;
}

original_code:
int lbs_strv_init_with_max (LbsStrv* strv, size_t max) {
    if (lbs_array_init_with_max (&strv->array, sizeof (LbsArray), max) < 0) {
        return -1;
    }
    strv->ref_count = 1;
    strv->is_alloc = 0;
    return 0;
}

canonical_original_code:
int lbs_strv_init_with_max(struct LbsStrvStruct *strv, unsigned long max) {
    if (lbs_array_init_with_max (&strv->array, sizeof (LbsArray), max) < 0) {
        return -1;
    }
    strv->ref_count = 1;
    strv->is_alloc = 0;
    return 0;
}

variable_types: struct LbsStrvStruct { struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; } array; unsigned int ref_count; _Bool is_alloc; } *

variable_types:
max
unsigned long


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

result = a1;
++*(_DWORD *)(a1 + 48);
return result;
}

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

result = a1;
++*(_DWORD *)(a1 + 48);
return result;
}

original_code:
void* lbs_strv_ref_generic (void* strv_generic) {
    LbsStrv* strv = ((LbsStrv*)(strv_generic));
    strv->ref_count++;
    return strv;
}

canonical_original_code:
void *lbs_strv_ref_generic(void *strv_generic) {
    struct LbsStrvStruct *strv = ((LbsStrv*)(strv_generic));
    strv->ref_count++;
    return strv;
}

return_type: void *

user_defined_types: struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; }


decompiled_code:
void __fastcall lbs_strv_free_generic(void *ptr)
{
unsigned __int64 v1; // rbx

if ( ptr )
{
if ( *((_QWORD *)ptr + 3) )
{
v1 = 0LL;
do
lbs_array_unref_generic(*(_QWORD *)ptr + 48 * v1++);
while ( *((_QWORD *)ptr + 3) > v1 );
}
lbs_array_unref_generic(ptr);
if ( *((_BYTE *)ptr + 52) )
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
unsigned __int64 v1; // rbx

if ( ptr )
{
if ( *((_QWORD *)ptr + 3) )
{
v1 = 0LL;
do
lbs_array_unref_generic(*(_QWORD *)ptr + 48 * v1++);
while ( *((_QWORD *)ptr + 3) > v1 );
}
lbs_array_unref_generic(ptr);
if ( *((_BYTE *)ptr + 52) )
free(ptr);
}
}

original_code:
void lbs_strv_free_generic (void* strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    LbsStrv* strv = ((LbsStrv*)(strv_generic));
    size_t i = 0;
    for (; i < (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len)); i++) {
        LbsArray* str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((i))))));
        (lbs_array_unref_generic ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))));
    }
    (lbs_array_unref_generic ((_Generic (((&strv->array)), LbsArray*: ((&strv->array))))));
    if (strv->is_alloc) {
        free (strv);
    }
}

canonical_original_code:
void lbs_strv_free_generic(void *strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    struct LbsStrvStruct *strv = ((LbsStrv*)(strv_generic));
    unsigned long i = 0;
    for (; i < (((_Generic (((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array))), struct LbsArrayStruct *: ((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array)))))->len)); i++) {
        struct LbsArrayStruct *str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((i))))));
        (lbs_array_unref_generic ((_Generic (((str_wrapper)), struct LbsArrayStruct *: ((str_wrapper))))));
    }
    (lbs_array_unref_generic ((_Generic (((&strv->array)), struct LbsArrayStruct *: ((&strv->array))))));
    if (strv->is_alloc) {
        free (strv);
    }
}

variable_types:
i
unsigned long

variable_types: struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; } *


decompiled_code:
void __fastcall lbs_strv_unref_generic(_DWORD *a1)
{
int v1; // eax

if ( a1 )
{
v1 = a1[12] - 1;
a1[12] = v1;
if ( !v1 )
lbs_strv_free_generic(a1);
}
}

original_code:
void lbs_strv_unref_generic (void* strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    LbsStrv* strv = ((LbsStrv*)(strv_generic));
    strv->ref_count--;
    if (strv->ref_count <= 0) {
        (lbs_strv_free_generic ((_Generic (((strv)), LbsStrv*: ((strv))))));
    }
}

canonical_original_code:
void lbs_strv_unref_generic(void *strv_generic) {
    if (strv_generic == ((void *)0)) {
        return;
    }
    struct LbsStrvStruct *strv = ((LbsStrv*)(strv_generic));
    strv->ref_count--;
    if (strv->ref_count <= 0) {
        (lbs_strv_free_generic ((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))));
    }
}


decompiled_code:
char *__fastcall lbs_strv_dup_str(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax
size_t v3; // rbp
const char *v4; // r12
char *v5; // rbx
char *result; // rax

v2 = *a1 + 48 * a2;
v3 = *(_QWORD *)(v2 + 24);
v4 = *(const char **)v2;
v5 = (char *)malloc(v3 + 1);
result = strncpy(v5, v4, v3);
v5[v3] = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func5(_QWORD *a1, __int64 a2)
{
__int64 v2; // rax
size_t v3; // rbp
const char *v4; // r12
char *v5; // rbx
char *result; // rax

v2 = *a1 + 48 * a2;
v3 = *(_QWORD *)(v2 + 24);
v4 = *(const char **)v2;
v5 = (char *)malloc(v3 + 1);
result = strncpy(v5, v4, v3);
v5[v3] = 0;
return result;
}

original_code:
char* lbs_strv_dup_str (LbsStrv* strv, size_t stri) {
    LbsArray* str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    size_t len = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->len);
    char* str = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->data);
    char* str_new = malloc (len + sizeof (char));
    strncpy (str_new, str, len);
    str_new[len] = '\0';
    return str_new;
}

canonical_original_code:
char *lbs_strv_dup_str(struct LbsStrvStruct *strv, unsigned long stri) {
    struct LbsArrayStruct *str_wrapper = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    unsigned long len = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->len);
    char *str = ((_Generic (((str_wrapper)), LbsArray*: ((str_wrapper))))->data);
    char *str_new = malloc (len + sizeof (char));
    strncpy (str_new, str, len);
    str_new[len] = '\0';
    return str_new;
}

variable_types:
stri
unsigned long


decompiled_code:
__int64 __fastcall lbs_strv_append_char(_QWORD *a1, unsigned __int64 a2, char a3)
{
unsigned __int64 v3; // rbp
char v5[4]; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[72]; // [rsp+10h] [rbp-48h] BYREF

v5[0] = a3;
if ( !a3 )
return 0xFFFFFFFFLL;
v3 = a1[3];
if ( v3 > a2 )
return lbs_array_append_data(*a1 + 48 * a2, v5);
if ( (int)lbs_array_init_with_max(v6, 1LL, 0LL) >= 0 )
{
if ( (int)lbs_array_append_data(a1, v6) >= 0 )
{
a2 = v3;
return lbs_array_append_data(*a1 + 48 * a2, v5);
}
lbs_array_unref_generic(v6);
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, unsigned __int64 a2, char a3)
{
unsigned __int64 v3; // rbp
char v5[4]; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[72]; // [rsp+10h] [rbp-48h] BYREF

v5[0] = a3;
if ( !a3 )
return 0xFFFFFFFFLL;
v3 = a1[3];
if ( v3 > a2 )
return lbs_array_append_data(*a1 + 48 * a2, v5);
if ( (int)lbs_array_init_with_max(v6, 1LL, 0LL) >= 0 )
{
if ( (int)lbs_array_append_data(a1, v6) >= 0 )
{
a2 = v3;
return lbs_array_append_data(*a1 + 48 * a2, v5);
}
lbs_array_unref_generic(v6);
}
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_append_char (LbsStrv* strv, size_t stri, char chr) {
    if (chr == '\0') {
        return -1;
    }
    if (stri >= (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len))) {
        stri = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
        LbsArray str_struct;
        LbsArray* str = &str_struct;
        if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
            return -1;
        }
        if (lbs_array_append_data (&strv->array, str) < 0) {
            (lbs_array_unref_generic ((_Generic (((str)), LbsArray*: ((str))))));
            return -1;
        }
    }
    LbsArray* str = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    return lbs_array_append_data (str, &chr);
}

canonical_original_code:
int lbs_strv_append_char(struct LbsStrvStruct *strv, unsigned long stri, char chr) {
    if (chr == '\0') {
        return -1;
    }
    if (stri >= (((_Generic (((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array))), struct LbsArrayStruct *: ((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array)))))->len))) {
        stri = (((_Generic (((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array))), struct LbsArrayStruct *: ((&((_Generic (((strv)), struct LbsStrvStruct *: ((strv))))->array)))))->len));
        struct LbsArrayStruct str_struct;
        struct LbsArrayStruct *str = &str_struct;
        if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
            return -1;
        }
        if (lbs_array_append_data (&strv->array, str) < 0) {
            (lbs_array_unref_generic ((_Generic (((str)), struct LbsArrayStruct *: ((str))))));
            return -1;
        }
    }
    struct LbsArrayStruct *str = (&((*(((LbsArray*)((&((strv)->array))->data))+((stri))))));
    return lbs_array_append_data (str, &chr);
}

variable_types: chr char

variable_types: struct LbsArrayStruct { void *data; void (*free_func)(void *data); unsigned long size; unsigned long len; unsigned long max; unsigned int ref_count; _Bool is_alloc; }


decompiled_code:
__int64 __fastcall lbs_strv_append_str_empty(__int64 a1)
{
_BYTE v2[56]; // [rsp+0h] [rbp-38h] BYREF

if ( (int)lbs_array_init_with_max(v2, 1LL, 0LL) < 0 )
return 0xFFFFFFFFLL;
if ( (int)lbs_array_append_data(a1, v2) >= 0 )
return 0LL;
lbs_array_unref_generic(v2);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
_BYTE v2[56]; // [rsp+0h] [rbp-38h] BYREF

if ( (int)lbs_array_init_with_max(v2, 1LL, 0LL) < 0 )
return 0xFFFFFFFFLL;
if ( (int)lbs_array_append_data(a1, v2) >= 0 )
return 0LL;
lbs_array_unref_generic(v2);
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_append_str_empty (LbsStrv* strv) {
    LbsArray str_struct, *str = &str_struct;
    if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), LbsArray*: ((str))))));
        return -1;
    }
    return 0;
}

canonical_original_code:
int lbs_strv_append_str_empty(struct LbsStrvStruct *strv) {
    struct LbsArrayStruct str_struct; struct LbsArrayStruct *str = &str_struct;
    if ((lbs_array_init_with_max (str, sizeof (char), 0)) < 0) {
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), struct LbsArrayStruct *: ((str))))));
        return -1;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall lbs_strv_append_str(__int64 a1, const char *a2)
{
size_t v2; // rbx
char *v3; // rax
char *v4; // r12
__int64 result; // rax
_BYTE v6[88]; // [rsp-58h] [rbp-58h] BYREF

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = strlen(a2);
v3 = (char *)malloc(v2);
v4 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
strncpy(v3, a2, v2);
if ( lbs_array_make_struct(v6, 1LL, v2, v2, v4) )
{
if ( (int)lbs_array_append_data(a1, v6) < 0 )
{
lbs_array_unref_generic(v6);
free(v4);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
free(v4);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2)
{
size_t v2; // rbx
char *v3; // rax
char *v4; // r12
__int64 result; // rax
_BYTE v6[88]; // [rsp-58h] [rbp-58h] BYREF

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = strlen(a2);
v3 = (char *)malloc(v2);
v4 = v3;
if ( !v3 )
return 0xFFFFFFFFLL;
strncpy(v3, a2, v2);
if ( lbs_array_make_struct(v6, 1LL, v2, v2, v4) )
{
if ( (int)lbs_array_append_data(a1, v6) < 0 )
{
lbs_array_unref_generic(v6);
free(v4);
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
else
{
free(v4);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int lbs_strv_append_str (LbsStrv* strv, const char* bstr) {
    if (bstr == ((void *)0)) {
        return -1;
    }
    size_t len = strlen (bstr);
    char* str_copy = malloc (sizeof (char) * len);
    if (str_copy == ((void *)0)) {
        return -1;
    }
    strncpy (str_copy, bstr, len);
    LbsArray str_struct, *str = &str_struct;
    if (lbs_array_make_struct (str, sizeof (char), len, len, str_copy) == ((void *)0))
    {
        free (str_copy);
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), LbsArray*: ((str))))));
        free (str_copy);
        return -1;
    }
    return 0;
}

canonical_original_code:
int lbs_strv_append_str(struct LbsStrvStruct *strv, char *bstr) {
    if (bstr == ((void *)0)) {
        return -1;
    }
    unsigned long len = strlen (bstr);
    char *str_copy = malloc (sizeof (char) * len);
    if (str_copy == ((void *)0)) {
        return -1;
    }
    strncpy (str_copy, bstr, len);
    struct LbsArrayStruct str_struct; struct LbsArrayStruct *str = &str_struct;
    if (lbs_array_make_struct (str, sizeof (char), len, len, str_copy) == ((void *)0))
    {
        free (str_copy);
        return -1;
    }
    if (lbs_array_append_data (&strv->array, &str_struct) < 0) {
        (lbs_array_unref_generic ((_Generic (((str)), struct LbsArrayStruct *: ((str))))));
        free (str_copy);
        return -1;
    }
    return 0;
}

variable_types:
bstr
char *


decompiled_code:
__int64 __fastcall lbs_strv_append_strv(__int64 a1, const char **a2)
{
const char *v3; // rsi
const char **v4; // rbx

if ( !a2 )
return 0xFFFFFFFFLL;
v3 = *a2;
if ( !v3 )
return 0LL;
v4 = a2 + 1;
while ( (int)lbs_strv_append_str(a1, v3) >= 0 )
{
v3 = *v4++;
if ( !v3 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const char **a2)
{
const char *v3; // rsi
const char **v4; // rbx

if ( !a2 )
return 0xFFFFFFFFLL;
v3 = *a2;
if ( !v3 )
return 0LL;
v4 = a2 + 1;
while ( (int)func8(a1, v3) >= 0 )
{
v3 = *v4++;
if ( !v3 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_append_strv (LbsStrv* strv, const char* const* bstrv) {
    if (bstrv == ((void *)0)) {
        return -1;
    }
    int i;
    for (i = 0; bstrv[i] != ((void *)0); i++) {
        if (lbs_strv_append_str (strv, bstrv[i]) < 0) {
            return -1;
        }
    }
    return 0;
}

canonical_original_code:
int lbs_strv_append_strv(struct LbsStrvStruct *strv, char **bstrv) {
    if (bstrv == ((void *)0)) {
        return -1;
    }
    int i;
    for (i = 0; bstrv[i] != ((void *)0); i++) {
        if (lbs_strv_append_str (strv, bstrv[i]) < 0) {
            return -1;
        }
    }
    return 0;
}

variable_types:
bstrv
char **


decompiled_code:
__int64 __fastcall lbs_strv_remove_str(_QWORD *a1)
{
__int64 v1; // rax

v1 = a1[3];
if ( !v1 )
return 0xFFFFFFFFLL;
lbs_array_unref_generic(*a1 + 48 * v1 - 48);
return lbs_array_remove(a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1)
{
__int64 v1; // rax

v1 = a1[3];
if ( !v1 )
return 0xFFFFFFFFLL;
lbs_array_unref_generic(*a1 + 48 * v1 - 48);
return lbs_array_remove(a1);
}

original_code:
int lbs_strv_remove_str (LbsStrv* strv) {
    size_t len = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
    if (len <= 0) {
        return -1;
    }
    (lbs_array_unref_generic ((_Generic ((((&((*(((LbsArray*)((&((strv)->array))->data))+((len - 1)))))))), LbsArray*: (((&((*(((LbsArray*)((&((strv)->array))->data))+((len - 1))))))))))));
    return lbs_array_remove (&strv->array);
}

canonical_original_code:
int lbs_strv_remove_str(struct LbsStrvStruct *strv) {
    unsigned long len = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
    if (len <= 0) {
        return -1;
    }
    (lbs_array_unref_generic ((_Generic ((((&((*(((struct LbsArrayStruct *)((&((strv)->array))->data))+((len - 1)))))))), struct LbsArrayStruct *: (((&((*(((struct LbsArrayStruct *)((&((strv)->array))->data))+((len - 1))))))))))));
    return lbs_array_remove (&strv->array);
}


decompiled_code:
__int64 __fastcall lbs_strv_minimize(_QWORD *a1)
{
__int64 v1; // r12
__int64 v2; // rbx

if ( (int)((__int64 (*)(void))lbs_array_minimize)() < 0 )
return 0xFFFFFFFFLL;
v1 = a1[3];
if ( !v1 )
return 0LL;
v2 = 0LL;
while ( (int)lbs_array_minimize(*a1 + 48 * v2) >= 0 )
{
if ( v1 == ++v2 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1)
{
__int64 v1; // r12
__int64 v2; // rbx

if ( (int)((__int64 (*)(void))lbs_array_minimize)() < 0 )
return 0xFFFFFFFFLL;
v1 = a1[3];
if ( !v1 )
return 0LL;
v2 = 0LL;
while ( (int)lbs_array_minimize(*a1 + 48 * v2) >= 0 )
{
if ( v1 == ++v2 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int lbs_strv_minimize (LbsStrv* strv) {
    if (lbs_array_minimize (&strv->array) < 0) {
        return -1;
    }
    size_t i;
    size_t len = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
    for (i = 0; i < len; i++) {
        LbsArray* str = (&((*(((LbsArray*)((&((strv)->array))->data))+((i))))));
        if (lbs_array_minimize (str) < 0) {
            return -1;
        }
    }
    return 0;
}

canonical_original_code:
int lbs_strv_minimize(struct LbsStrvStruct *strv) {
    if (lbs_array_minimize (&strv->array) < 0) {
        return -1;
    }
    unsigned long i;
    unsigned long len = (((_Generic (((&((_Generic (((strv)), LbsStrv*: ((strv))))->array))), LbsArray*: ((&((_Generic (((strv)), LbsStrv*: ((strv))))->array)))))->len));
    for (i = 0; i < len; i++) {
        struct LbsArrayStruct *str = (&((*(((LbsArray*)((&((strv)->array))->data))+((i))))));
        if (lbs_array_minimize (str) < 0) {
            return -1;
        }
    }
    return 0;
}


decompiled_code:
int __fastcall lbs_strv_generic_cmp(const char **a1, __int64 a2)
{
const char *v4; // rdi
unsigned __int64 v5; // rbx
const char *v6; // rsi
int result; // eax

v4 = *a1;
v5 = 0LL;
if ( !v4 )
return -(*(_QWORD *)(a2 + v5) != 0LL);
while ( 1 )
{
v6 = *(const char **)(a2 + v5);
if ( !v6 )
break;
result = strcmp(v4, v6);
if ( result )
return result;
v5 += 8LL;
v4 = a1[v5 / 8];
if ( !v4 )
return -(*(_QWORD *)(a2 + v5) != 0LL);
}
return 1;
}

canonical_decompiled_code:
int __fastcall func13(const char **a1, __int64 a2)
{
const char *v4; // rdi
unsigned __int64 v5; // rbx
const char *v6; // rsi
int result; // eax

v4 = *a1;
v5 = 0LL;
if ( !v4 )
return -(*(_QWORD *)(a2 + v5) != 0LL);
while ( 1 )
{
v6 = *(const char **)(a2 + v5);
if ( !v6 )
break;
result = strcmp(v4, v6);
if ( result )
return result;
v5 += 8LL;
v4 = a1[v5 / 8];
if ( !v4 )
return -(*(_QWORD *)(a2 + v5) != 0LL);
}
return 1;
}

original_code:
int lbs_strv_generic_cmp (
    const char* const* bstrv1, const char* const* bstrv2) {
    int i;
    for (i = 0; bstrv1[i] != ((void *)0) && bstrv2[i] != ((void *)0); i++) {
        int r = strcmp (bstrv1[i], bstrv2[i]);
        if (r != 0) {
            return r;
        }
    }
    if (bstrv1[i] != ((void *)0)) {
        return 1;
    }
    if (bstrv2[i] != ((void *)0)) {
        return -1;
    }
    return 0;
}

canonical_original_code:
int lbs_strv_generic_cmp(char **bstrv1, char **bstrv2) {
    int i;
    for (i = 0; bstrv1[i] != ((void *)0) && bstrv2[i] != ((void *)0); i++) {
        int r = strcmp (bstrv1[i], bstrv2[i]);
        if (r != 0) {
            return r;
        }
    }
    if (bstrv1[i] != ((void *)0)) {
        return 1;
    }
    if (bstrv2[i] != ((void *)0)) {
        return -1;
    }
    return 0;
}

variable_types: r int


decompiled_code:
void __fastcall lbs_strv_generic_free(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func14(void *ptr)
{
void *v2; // rdi
char *v3; // rbx

v2 = *(void **)ptr;
if ( v2 )
{
v3 = (char *)ptr + 8;
do
{
free(v2);
v3 += 8;
v2 = (void *)*((_QWORD *)v3 - 1);
}
while ( v2 );
}
free(ptr);
}

original_code:
void lbs_strv_generic_free (char** bstrv) {
    int i;
    for (i = 0; bstrv[i] != ((void *)0); i++) {
        free (bstrv[i]);
    }
    free (bstrv);
}

canonical_original_code:
void lbs_strv_generic_free(char **bstrv) {
    int i;
    for (i = 0; bstrv[i] != ((void *)0); i++) {
        free (bstrv[i]);
    }
    free (bstrv);
}


decompiled_code:
void *__fastcall lbs_array2_copy_in(_QWORD *a1, const void *a2)
{
return memcpy((char *)a1 + 28, a2, a1[2] * a1[1] * *a1);
}

canonical_decompiled_code:
void *__fastcall func0(_QWORD *a1, const void *a2)
{
return memcpy((char *)a1 + 28, a2, a1[2] * a1[1] * *a1);
}

original_code:
void lbs_array2_copy_in (LbsArray2* array2, const void* copy_in) {
    memcpy (array2->data, copy_in, array2->size * array2->lenx * array2->leny);
}

canonical_original_code:
void lbs_array2_copy_in(struct LbsArray2Struct *array2, void *copy_in) {
    memcpy (array2->data, copy_in, array2->size * array2->lenx * array2->leny);
}

variable_types: struct LbsArray2Struct { unsigned long size; unsigned long lenx; unsigned long leny; unsigned int ref_count; char data[]; } *


decompiled_code:
void *__fastcall lbs_array2_copy_out(_QWORD *a1, void *a2)
{
return memcpy(a2, (char *)a1 + 28, a1[2] * a1[1] * *a1);
}

canonical_decompiled_code:
void *__fastcall func1(_QWORD *a1, void *a2)
{
return memcpy(a2, (char *)a1 + 28, a1[2] * a1[1] * *a1);
}

original_code:
void lbs_array2_copy_out (LbsArray2* array2, void* copy_out) {
    memcpy (copy_out, array2->data, array2->size * array2->lenx * array2->leny);
}

canonical_original_code:
void lbs_array2_copy_out(struct LbsArray2Struct *array2, void *copy_out) {
    memcpy (copy_out, array2->data, array2->size * array2->lenx * array2->leny);
}

user_defined_types: struct LbsArray2Struct { unsigned long size; unsigned long lenx; unsigned long leny; unsigned int ref_count; char data[]; }


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

result = a1;
++*(_DWORD *)(a1 + 24);
return result;
}

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

result = a1;
++*(_DWORD *)(a1 + 24);
return result;
}

original_code:
void* lbs_array2_ref_generic (void* array2_generic) {
    LbsArray2* array2 = ((LbsArray2*)(array2_generic));
    array2->ref_count++;
    return array2;
}

canonical_original_code:
void *lbs_array2_ref_generic(void *array2_generic) {
    struct LbsArray2Struct *array2 = ((LbsArray2*)(array2_generic));
    array2->ref_count++;
    return array2;
}


decompiled_code:
void __fastcall lbs_array2_unref_generic(_DWORD *a1)
{
if ( a1 )
{
if ( a1[6] == 1 )
free(a1);
else
--a1[6];
}
}

canonical_decompiled_code:
void __fastcall func3(_DWORD *a1)
{
if ( a1 )
{
if ( a1[6] == 1 )
free(a1);
else
--a1[6];
}
}

original_code:
void lbs_array2_unref_generic (void* array2_generic) {
    if (array2_generic == ((void *)0)) {
        return;
    }
    LbsArray2* array2 = ((LbsArray2*)(array2_generic));
    array2->ref_count--;
    if (array2->ref_count <= 0) {
        free (array2_generic);
    }
}

canonical_original_code:
void lbs_array2_unref_generic(void *array2_generic) {
    if (array2_generic == ((void *)0)) {
        return;
    }
    struct LbsArray2Struct *array2 = ((LbsArray2*)(array2_generic));
    array2->ref_count--;
    if (array2->ref_count <= 0) {
        free (array2_generic);
    }
}


decompiled_code:
__int64 __fastcall lbs_array_init_with_max(__int64 a1, __int64 a2, __int64 a3)
{
void *v5; // rax

if ( !a2 )
return 0xFFFFFFFFLL;
if ( a3 )
{
v5 = malloc(a3 * a2);
if ( !v5 )
return 0xFFFFFFFFLL;
*(_QWORD *)a1 = v5;
}
else
{
*(_QWORD *)a1 = 0LL;
}
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = a2;
*(_QWORD *)(a1 + 24) = a3;
*(_QWORD *)(a1 + 32) = a3;
*(_DWORD *)(a1 + 40) = 1;
*(_BYTE *)(a1 + 44) = 0;
return 0LL;
}

original_code:
int lbs_array_init_with_max (LbsArray* array, size_t size, size_t max) {
    if (size <= 0) {
        return -1;
    }
    if (max > 0) {
        void* data = malloc (size * max);
        if (data == ((void *)0)) {
            return -1;
        }
        array->data = data;
    } else {
        array->data = ((void *)0);
    }
    array->free_func = ((void *)0);
    array->size = size;
    array->len = max;
    array->max = max;
    array->ref_count = 1;
    array->is_alloc = 0;
    return 0;
}

canonical_original_code:
int lbs_array_init_with_max(struct LbsArrayStruct *array, unsigned long size, unsigned long max) {
    if (size <= 0) {
        return -1;
    }
    if (max > 0) {
        void *data = malloc (size * max);
        if (data == ((void *)0)) {
            return -1;
        }
        array->data = data;
    } else {
        array->data = ((void *)0);
    }
    array->free_func = ((void *)0);
    array->size = size;
    array->len = max;
    array->max = max;
    array->ref_count = 1;
    array->is_alloc = 0;
    return 0;
}

variable_types:
size
unsigned long

variable_types:
data
void *


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

result = a1;
++*(_DWORD *)(a1 + 40);
return result;
}

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

result = a1;
++*(_DWORD *)(a1 + 40);
return result;
}

original_code:
void* lbs_array_ref_generic (void* array_generic) {
    LbsArray* array = ((LbsArray*)(array_generic));
    array->ref_count++;
    return array;
}

canonical_original_code:
void *lbs_array_ref_generic(void *array_generic) {
    struct LbsArrayStruct *array = ((LbsArray*)(array_generic));
    array->ref_count++;
    return array;
}


decompiled_code:
void __fastcall lbs_array_free_generic(void *ptr)
{
_QWORD *v1; // rbp
unsigned __int64 v2; // r12

if ( ptr )
{
if ( *((_QWORD *)ptr + 1) )
{
v1 = *(_QWORD **)ptr;
if ( *((_QWORD *)ptr + 3) )
{
v2 = 0LL;
do
{
(*((void (__fastcall **)(_QWORD))ptr + 1))(*v1);
++v2;
v1 = (_QWORD *)((char *)v1 + *((_QWORD *)ptr + 2));
}
while ( *((_QWORD *)ptr + 3) > v2 );
}
}
free(*(void **)ptr);
if ( *((_BYTE *)ptr + 44) )
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
_QWORD *v1; // rbp
unsigned __int64 v2; // r12

if ( ptr )
{
if ( *((_QWORD *)ptr + 1) )
{
v1 = *(_QWORD **)ptr;
if ( *((_QWORD *)ptr + 3) )
{
v2 = 0LL;
do
{
(*((void (__fastcall **)(_QWORD))ptr + 1))(*v1);
++v2;
v1 = (_QWORD *)((char *)v1 + *((_QWORD *)ptr + 2));
}
while ( *((_QWORD *)ptr + 3) > v2 );
}
}
free(*(void **)ptr);
if ( *((_BYTE *)ptr + 44) )
free(ptr);
}
}

original_code:
void lbs_array_free_generic (void* array_generic) {
    if (array_generic == ((void *)0)) {
        return;
    }
    LbsArray* array = ((LbsArray*)(array_generic));
    if (array->free_func != ((void *)0)) {
        size_t i = 0;
        char* d = array->data;
        for (; i < array->len; i++, d += array->size) {
            (*(array->free_func)) (*((void**)d));
        }
    }
    free (array->data);
    if (array->is_alloc) {
        free (array);
    }
}

canonical_original_code:
void lbs_array_free_generic(void *array_generic) {
    if (array_generic == ((void *)0)) {
        return;
    }
    struct LbsArrayStruct *array = ((LbsArray*)(array_generic));
    if (array->free_func != ((void *)0)) {
        unsigned long i = 0;
        char *d = array->data;
        for (; i < array->len; i++, d += array->size) {
            (*(array->free_func)) (*((void **)d));
        }
    }
    free (array->data);
    if (array->is_alloc) {
        free (array);
    }
}

variable_types:
d
char *


decompiled_code:
void __fastcall lbs_array_unref_generic(_DWORD *a1)
{
int v1; // eax

if ( a1 )
{
v1 = a1[10] - 1;
a1[10] = v1;
if ( !v1 )
lbs_array_free_generic(a1);
}
}

original_code:
void lbs_array_unref_generic (void* array_generic) {
    if (array_generic == ((void *)0)) {
        return;
    }
    LbsArray* array = ((LbsArray*)(array_generic));
    array->ref_count--;
    if (array->ref_count <= 0) {
        (lbs_array_free_generic ((_Generic (((array)), LbsArray*: ((array))))));
    }
}

canonical_original_code:
void lbs_array_unref_generic(void *array_generic) {
    if (array_generic == ((void *)0)) {
        return;
    }
    struct LbsArrayStruct *array = ((LbsArray*)(array_generic));
    array->ref_count--;
    if (array->ref_count <= 0) {
        (lbs_array_free_generic ((_Generic (((array)), struct LbsArrayStruct *: ((array))))));
    }
}


decompiled_code:
__int64 __fastcall lbs_array_drop_struct(_BYTE *a1)
{
__int64 v1; // rbx

v1 = *(_QWORD *)a1;
if ( a1[44] )
free(a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func5(_BYTE *a1)
{
__int64 v1; // rbx

v1 = *(_QWORD *)a1;
if ( a1[44] )
free(a1);
return v1;
}

original_code:
void* lbs_array_drop_struct (LbsArray* array) {
    if (!array->is_alloc) {
        return array->data;
    }
    void* data = array->data;
    free (array);
    return data;
}

canonical_original_code:
void *lbs_array_drop_struct(struct LbsArrayStruct *array) {
    if (!array->is_alloc) {
        return array->data;
    }
    void *data = array->data;
    free (array);
    return data;
}


decompiled_code:
__int64 __fastcall lbs_array_set_max(__int64 a1, __int64 a2)
{
void *v2; // rax

v2 = realloc(*(void **)a1, *(_QWORD *)(a1 + 16) * a2);
if ( !v2 )
return 0xFFFFFFFFLL;
*(_QWORD *)(a1 + 32) = a2;
*(_QWORD *)a1 = v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
void *v2; // rax

v2 = realloc(*(void **)a1, *(_QWORD *)(a1 + 16) * a2);
if ( !v2 )
return 0xFFFFFFFFLL;
*(_QWORD *)(a1 + 32) = a2;
*(_QWORD *)a1 = v2;
return 0LL;
}

original_code:
int lbs_array_set_max (LbsArray* array, size_t max) {
    void* ptr = realloc (array->data, array->size * max);
    if (ptr == ((void *)0)) {
        return -1;
    }
    array->max = max;
    array->data = ptr;
    return 0;
}

canonical_original_code:
int lbs_array_set_max(struct LbsArrayStruct *array, unsigned long max) {
    void *ptr = realloc (array->data, array->size * max);
    if (ptr == ((void *)0)) {
        return -1;
    }
    array->max = max;
    array->data = ptr;
    return 0;
}

variable_types:
ptr
void *


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

if ( *(_QWORD *)(a1 + 32) < a2 )
{
if ( (int)lbs_array_set_max(a1, a2) < 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
*(_QWORD *)(a1 + 24) = a2;
result = 0LL;
}
}
else
{
*(_QWORD *)(a1 + 24) = a2;
result = 0LL;
}
return result;
}

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

if ( *(_QWORD *)(a1 + 32) < a2 )
{
if ( (int)func6(a1, a2) < 0 )
{
result = 0xFFFFFFFFLL;
}
else
{
*(_QWORD *)(a1 + 24) = a2;
result = 0LL;
}
}
else
{
*(_QWORD *)(a1 + 24) = a2;
result = 0LL;
}
return result;
}

original_code:
int lbs_array_set_len (LbsArray* array, size_t len) {
    if (len > (array->max)){
        if (lbs_array_set_max (array, len) < 0) {
            return -1;
        } else {
            array->len = len;
        }
    } else {
        array->len = len;
        return 0;
    }
    return 0;
}

canonical_original_code:
int lbs_array_set_len(struct LbsArrayStruct *array, unsigned long len) {
    if (len > (array->max)){
        if (lbs_array_set_max (array, len) < 0) {
            return -1;
        } else {
            array->len = len;
        }
    } else {
        array->len = len;
        return 0;
    }
    return 0;
}

variable_types:
len
unsigned long


decompiled_code:
__int64 __fastcall lbs_array_append_data(_QWORD *a1, const void *a2)
{
unsigned __int64 v3; // rsi
__int64 result; // rax

v3 = a1[4];
if ( v3 >= a1[3] + 1LL )
goto LABEL_4;
if ( v3 )
{
if ( (int)lbs_array_set_max((__int64)a1, 2 * v3) >= 0 )
{
LABEL_4:
memcpy((void *)(*a1 + a1[3] * a1[2]), a2, a1[2]);
++a1[3];
return 0LL;
}
result = 0xFFFFFFFFLL;
}
else
{
if ( (int)lbs_array_set_max((__int64)a1, 1LL) >= 0 )
goto LABEL_4;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_QWORD *a1, const void *a2)
{
unsigned __int64 v3; // rsi
__int64 result; // rax

v3 = a1[4];
if ( v3 >= a1[3] + 1LL )
goto LABEL_4;
if ( v3 )
{
if ( (int)func6((__int64)a1, 2 * v3) >= 0 )
{
LABEL_4:
memcpy((void *)(*a1 + a1[3] * a1[2]), a2, a1[2]);
++a1[3];
return 0LL;
}
result = 0xFFFFFFFFLL;
}
else
{
if ( (int)func6((__int64)a1, 1LL) >= 0 )
goto LABEL_4;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int lbs_array_append_data (LbsArray* array, const void* data) {
    if (array->max < array->len + 1) {
        if (array->max > 0) {
            if (lbs_array_set_max (array, array->max * 2) < 0) {
                return -1;
            }
        } else {
            if (lbs_array_set_max (array, 1) < 0){
                return -1;
            }
        }
    }
    memcpy (((void*)(((char*)((array)->data))+(((array)->size)*(array->len)))), data, array->size);
    array->len++;
    return 0;
}

canonical_original_code:
int lbs_array_append_data(struct LbsArrayStruct *array, void *data) {
    if (array->max < array->len + 1) {
        if (array->max > 0) {
            if (lbs_array_set_max (array, array->max * 2) < 0) {
                return -1;
            }
        } else {
            if (lbs_array_set_max (array, 1) < 0){
                return -1;
            }
        }
    }
    memcpy (((void *)(((char *)((array)->data))+(((array)->size)*(array->len)))), data, array->size);
    array->len++;
    return 0;
}


decompiled_code:
__int64 __fastcall lbs_array_append_ptr(_QWORD *a1, __int64 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
return lbs_array_append_data(a1, &v3);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1, __int64 a2)
{
__int64 v3; // [rsp+8h] [rbp-10h] BYREF

v3 = a2;
return func9(a1, &v3);
}

original_code:
int lbs_array_append_ptr (LbsArray* array, const void* ptr) {
    return lbs_array_append_data (array, &ptr);
}

canonical_original_code:
int lbs_array_append_ptr(struct LbsArrayStruct *array, void *ptr) {
    return lbs_array_append_data (array, &ptr);
}


decompiled_code:
__int64 __fastcall lbs_array_append_mass(_QWORD *a1, const void *a2, __int64 a3)
{
unsigned __int64 v5; // rsi
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rax

v5 = a1[4];
v6 = a1[3] + a3;
if ( v5 < v6 )
{
do
{
v7 = 2 * v5;
if ( !v5 )
v7 = 1LL;
v5 = v7;
}
while ( v7 < v6 );
a1[4] = v7;
if ( (int)lbs_array_set_max((__int64)a1, v7) < 0 )
return 0xFFFFFFFFLL;
}
memcpy((void *)(*a1 + a1[3] * a1[2]), a2, a3 * a1[2]);
a1[3] += a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1, const void *a2, __int64 a3)
{
unsigned __int64 v5; // rsi
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rax

v5 = a1[4];
v6 = a1[3] + a3;
if ( v5 < v6 )
{
do
{
v7 = 2 * v5;
if ( !v5 )
v7 = 1LL;
v5 = v7;
}
while ( v7 < v6 );
a1[4] = v7;
if ( (int)func6((__int64)a1, v7) < 0 )
return 0xFFFFFFFFLL;
}
memcpy((void *)(*a1 + a1[3] * a1[2]), a2, a3 * a1[2]);
a1[3] += a3;
return 0LL;
}

original_code:
int lbs_array_append_mass (LbsArray* array, const void* data, size_t count) {
    _Bool need_expand = 0;
    while (array->max < array->len + count) {
        need_expand = 1;
        if (array->max > 0) {
            array->max *= 2;
        } else {
            array->max = 1;
        }
    }
    if (need_expand) {
        if (lbs_array_set_max (array, array->max) < 0) {
            return -1;
        }
    }
    memcpy (((void*)(((char*)((array)->data))+(((array)->size)*(array->len)))), data, array->size * count);
    array->len += count;
    return 0;
}

canonical_original_code:
int lbs_array_append_mass(struct LbsArrayStruct *array, void *data, unsigned long count) {
    _Bool need_expand = 0;
    while (array->max < array->len + count) {
        need_expand = 1;
        if (array->max > 0) {
            array->max *= 2;
        } else {
            array->max = 1;
        }
    }
    if (need_expand) {
        if (lbs_array_set_max (array, array->max) < 0) {
            return -1;
        }
    }
    memcpy (((void *)(((char *)((array)->data))+(((array)->size)*(array->len)))), data, array->size * count);
    array->len += count;
    return 0;
}

variable_types:
count
unsigned long


decompiled_code:
__int64 __fastcall lbs_array_minimize(__int64 a1)
{
unsigned __int64 v1; // rsi
__int64 result; // rax
void *v3; // rax

v1 = *(_QWORD *)(a1 + 24);
result = 0LL;
if ( *(_QWORD *)(a1 + 32) > v1 )
{
v3 = realloc(*(void **)a1, *(_QWORD *)(a1 + 16) * v1);
if ( v3 )
{
*(_QWORD *)(a1 + 32) = *(_QWORD *)(a1 + 24);
*(_QWORD *)a1 = v3;
result = 0LL;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
unsigned __int64 v1; // rsi
__int64 result; // rax
void *v3; // rax

v1 = *(_QWORD *)(a1 + 24);
result = 0LL;
if ( *(_QWORD *)(a1 + 32) > v1 )
{
v3 = realloc(*(void **)a1, *(_QWORD *)(a1 + 16) * v1);
if ( v3 )
{
*(_QWORD *)(a1 + 32) = *(_QWORD *)(a1 + 24);
*(_QWORD *)a1 = v3;
result = 0LL;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int lbs_array_minimize (LbsArray* array) {
    if (array->max > array->len) {
        void* ptr = realloc (array->data, array->size * array->len);
        if (ptr == ((void *)0)) {
            return -1;
        }
        array->max = array->len;
        array->data = ptr;
    }
    return 0;
}

canonical_original_code:
int lbs_array_minimize(struct LbsArrayStruct *array) {
    if (array->max > array->len) {
        void *ptr = realloc (array->data, array->size * array->len);
        if (ptr == ((void *)0)) {
            return -1;
        }
        array->max = array->len;
        array->data = ptr;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall lbs_array_remove(__int64 a1)
{
__int64 v1; // rax
unsigned __int64 v2; // rax
unsigned int v3; // ecx

v1 = *(_QWORD *)(a1 + 24);
if ( !v1 )
return (unsigned int)-1;
v2 = v1 - 1;
*(_QWORD *)(a1 + 24) = v2;
v3 = 0;
if ( v2 >= 2LL * *(_QWORD *)(a1 + 32) )
return v3;
lbs_array_minimize(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
__int64 v1; // rax
unsigned __int64 v2; // rax
unsigned int v3; // ecx

v1 = *(_QWORD *)(a1 + 24);
if ( !v1 )
return (unsigned int)-1;
v2 = v1 - 1;
*(_QWORD *)(a1 + 24) = v2;
v3 = 0;
if ( v2 >= 2LL * *(_QWORD *)(a1 + 32) )
return v3;
func12(a1);
return 0LL;
}

original_code:
int lbs_array_remove (LbsArray* array) {
    if (array->len <= 0) {
        return -1;
    }
    array->len--;
    if (array->len < array->max * 2) {
        lbs_array_minimize (array);
    }
    return 0;
}

canonical_original_code:
int lbs_array_remove(struct LbsArrayStruct *array) {
    if (array->len <= 0) {
        return -1;
    }
    array->len--;
    if (array->len < array->max * 2) {
        lbs_array_minimize (array);
    }
    return 0;
}