parseGPRMC

original_code:
void parseGPRMC(GPRMC *in, char *strToParse)
{
 strToParse = getNext(&strToParse, in->RMCMessageID );
 strToParse = getNext(&strToParse, in->UTCPosition );
 strToParse = getNext(&strToParse, in->Status );
 strToParse = getNext(&strToParse, in->RMCLatitude );
 strToParse = getNext(&strToParse, in->RMCNSIndicator );
 strToParse = getNext(&strToParse, in->RMCLongitude );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 strToParse = getNext(&strToParse, in->SpeedOverGround );
 strToParse = getNext(&strToParse, in->CourseOverGround );
 strToParse = getNext(&strToParse, in->Date );
 strToParse = getNext(&strToParse, in->MagneticVariation );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 getNext(&strToParse, in->Checksum );
}

canonical_original_code:
void parseGPRMC(struct GPRMC *in, char *strToParse)
{
 strToParse = getNext(&strToParse, in->RMCMessageID );
 strToParse = getNext(&strToParse, in->UTCPosition );
 strToParse = getNext(&strToParse, in->Status );
 strToParse = getNext(&strToParse, in->RMCLatitude );
 strToParse = getNext(&strToParse, in->RMCNSIndicator );
 strToParse = getNext(&strToParse, in->RMCLongitude );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 strToParse = getNext(&strToParse, in->SpeedOverGround );
 strToParse = getNext(&strToParse, in->CourseOverGround );
 strToParse = getNext(&strToParse, in->Date );
 strToParse = getNext(&strToParse, in->MagneticVariation );
 strToParse = getNext(&strToParse, in->RMCEWIndicator );
 getNext(&strToParse, in->Checksum );
}

variable_types: struct GPRMC { char RMCMessageID[7]; char UTCPosition[11]; char Status[2]; char RMCLatitude[11]; char RMCNSIndicator[2]; char RMCLongitude[11]; char RMCEWIndicator[2]; char SpeedOverGround[8]; char CourseOverGround[6]; char Date[7]; char MagneticVariation[4]; char RMCEWIndicator2[2]; char Checksum[8]; } *


getGpgga

decompiled_code:
char *__fastcall getGpgga(char *dest, int a2)
{
char v3[7]; // [rsp+0h] [rbp-E8h] BYREF
char v4[11]; // [rsp+7h] [rbp-E1h] BYREF
char v5[11]; // [rsp+12h] [rbp-D6h] BYREF
char v6[2]; // [rsp+1Dh] [rbp-CBh] BYREF
char v7[11]; // [rsp+1Fh] [rbp-C9h] BYREF
char v8[2]; // [rsp+2Ah] [rbp-BEh] BYREF
char v9[2]; // [rsp+2Ch] [rbp-BCh] BYREF
char v10[3]; // [rsp+2Eh] [rbp-BAh] BYREF
char v11[5]; // [rsp+31h] [rbp-B7h] BYREF
char v12[4]; // [rsp+36h] [rbp-B2h] BYREF
char v13[2]; // [rsp+3Ah] [rbp-AEh] BYREF
char v14[4]; // [rsp+3Ch] [rbp-ACh] BYREF
char v15[2]; // [rsp+40h] [rbp-A8h] BYREF
char v16[8]; // [rsp+42h] [rbp-A6h] BYREF
char v17[5]; // [rsp+4Ah] [rbp-9Eh] BYREF
char src[17]; // [rsp+4Fh] [rbp-99h] BYREF
char desta[136]; // [rsp+60h] [rbp-88h] BYREF

pthread_mutex_lock(&GPGGAMutex);
strcpy(desta, *(const char **)GPGGA_LIST);
pthread_mutex_unlock(&GPGGAMutex);
parseGPGGA(v3, desta);
switch ( a2 )
{
case 1:
strcpy(dest, v4);
break;
case 2:
strcpy(dest, v5);
break;
case 3:
strcpy(dest, v6);
break;
case 4:
strcpy(dest, v7);
break;
case 5:
strcpy(dest, v8);
break;
case 6:
strcpy(dest, v9);
break;
case 7:
strcpy(dest, v10);
break;
case 8:
strcpy(dest, v11);
break;
case 9:
strcpy(dest, v12);
break;
case 10:
strcpy(dest, v13);
break;
case 11:
strcpy(dest, v14);
break;
case 12:
strcpy(dest, v15);
break;
case 13:
strcpy(dest, v16);
break;
case 14:
strcpy(dest, v17);
break;
case 15:
strcpy(dest, src);
break;
default:
strcpy(dest, v3);
break;
}
return dest;
}

canonical_decompiled_code:
char *__fastcall func0(char *dest, int a2)
{
char v3[7]; // [rsp+0h] [rbp-E8h] BYREF
char v4[11]; // [rsp+7h] [rbp-E1h] BYREF
char v5[11]; // [rsp+12h] [rbp-D6h] BYREF
char v6[2]; // [rsp+1Dh] [rbp-CBh] BYREF
char v7[11]; // [rsp+1Fh] [rbp-C9h] BYREF
char v8[2]; // [rsp+2Ah] [rbp-BEh] BYREF
char v9[2]; // [rsp+2Ch] [rbp-BCh] BYREF
char v10[3]; // [rsp+2Eh] [rbp-BAh] BYREF
char v11[5]; // [rsp+31h] [rbp-B7h] BYREF
char v12[4]; // [rsp+36h] [rbp-B2h] BYREF
char v13[2]; // [rsp+3Ah] [rbp-AEh] BYREF
char v14[4]; // [rsp+3Ch] [rbp-ACh] BYREF
char v15[2]; // [rsp+40h] [rbp-A8h] BYREF
char v16[8]; // [rsp+42h] [rbp-A6h] BYREF
char v17[5]; // [rsp+4Ah] [rbp-9Eh] BYREF
char src[17]; // [rsp+4Fh] [rbp-99h] BYREF
char desta[136]; // [rsp+60h] [rbp-88h] BYREF

pthread_mutex_lock(&GPGGAMutex);
strcpy(desta, *(const char **)GPGGA_LIST);
pthread_mutex_unlock(&GPGGAMutex);
parseGPGGA(v3, desta);
switch ( a2 )
{
case 1:
strcpy(dest, v4);
break;
case 2:
strcpy(dest, v5);
break;
case 3:
strcpy(dest, v6);
break;
case 4:
strcpy(dest, v7);
break;
case 5:
strcpy(dest, v8);
break;
case 6:
strcpy(dest, v9);
break;
case 7:
strcpy(dest, v10);
break;
case 8:
strcpy(dest, v11);
break;
case 9:
strcpy(dest, v12);
break;
case 10:
strcpy(dest, v13);
break;
case 11:
strcpy(dest, v14);
break;
case 12:
strcpy(dest, v15);
break;
case 13:
strcpy(dest, v16);
break;
case 14:
strcpy(dest, v17);
break;
case 15:
strcpy(dest, src);
break;
default:
strcpy(dest, v3);
break;
}
return dest;
}

original_code:
static char *getGpgga(char *retval, int i)
{
 GPGGA gpgga;
 char line[100];
 pthread_mutex_lock(&GPGGAMutex);
 strcpy(line, GPGGA_LIST->string);
 pthread_mutex_unlock(&GPGGAMutex);
 parseGPGGA(&gpgga, line);
 switch (i){
  case 0:
   strcpy(retval, gpgga.MessageID);
   break;
  case 1:
   strcpy(retval, gpgga.UTCTime);
   break;
  case 2:
   strcpy(retval, gpgga.Latitude);
   break;
  case 3:
   strcpy(retval, gpgga.NSIndicator);
   break;
  case 4:
   strcpy(retval, gpgga.Longitude);
   break;
  case 5:
   strcpy(retval, gpgga.EWIndicator);
   break;
  case 6:
   strcpy(retval, gpgga.PositionFixIndicator);
   break;
  case 7:
   strcpy(retval, gpgga.SatellitesUsed);
   break;
  case 8:
   strcpy(retval, gpgga.HDOP);
   break;
  case 9:
   strcpy(retval, gpgga.MSLAltitude);
   break;
  case 10:
   strcpy(retval, gpgga.MSLUnits);
   break;
  case 11:
   strcpy(retval, gpgga.GeoidSeparation);
   break;
  case 12:
   strcpy(retval, gpgga.GeoidUnits);
   break;
  case 13:
   strcpy(retval, gpgga.AgeOfDiffCorr);
   break;
  case 14:
   strcpy(retval, gpgga.DiffRefStationID);
   break;
  case 15:
   strcpy(retval, gpgga.Checksum);
   break;
 }
 return retval;
}

canonical_original_code:
static char *getGpgga(char *retval, int i)
{
 struct GPGGA gpgga;
 char line[100];
 pthread_mutex_lock(&GPGGAMutex);
 strcpy(line, GPGGA_LIST->string);
 pthread_mutex_unlock(&GPGGAMutex);
 parseGPGGA(&gpgga, line);
 switch (i){
  case 0:
   strcpy(retval, gpgga.MessageID);
   break;
  case 1:
   strcpy(retval, gpgga.UTCTime);
   break;
  case 2:
   strcpy(retval, gpgga.Latitude);
   break;
  case 3:
   strcpy(retval, gpgga.NSIndicator);
   break;
  case 4:
   strcpy(retval, gpgga.Longitude);
   break;
  case 5:
   strcpy(retval, gpgga.EWIndicator);
   break;
  case 6:
   strcpy(retval, gpgga.PositionFixIndicator);
   break;
  case 7:
   strcpy(retval, gpgga.SatellitesUsed);
   break;
  case 8:
   strcpy(retval, gpgga.HDOP);
   break;
  case 9:
   strcpy(retval, gpgga.MSLAltitude);
   break;
  case 10:
   strcpy(retval, gpgga.MSLUnits);
   break;
  case 11:
   strcpy(retval, gpgga.GeoidSeparation);
   break;
  case 12:
   strcpy(retval, gpgga.GeoidUnits);
   break;
  case 13:
   strcpy(retval, gpgga.AgeOfDiffCorr);
   break;
  case 14:
   strcpy(retval, gpgga.DiffRefStationID);
   break;
  case 15:
   strcpy(retval, gpgga.Checksum);
   break;
 }
 return retval;
}

variable_types:
retval
char *

variable_types: i int

variable_types: struct GPGGA { char MessageID[7]; char UTCTime[11]; char Latitude[11]; char NSIndicator[2]; char Longitude[11]; char EWIndicator[2]; char PositionFixIndicator[2]; char SatellitesUsed[3]; char HDOP[5]; char MSLAltitude[4]; char MSLUnits[2]; char GeoidSeparation[4]; char GeoidUnits[2]; char AgeOfDiffCorr[8]; char DiffRefStationID[5]; char Checksum[8]; }

variable_types:
line
char [100]

return_type: char *


getGprmc

decompiled_code:
char *__fastcall getGprmc(char *dest, int a2)
{
char v3[7]; // [rsp+0h] [rbp-E8h] BYREF
char v4[11]; // [rsp+7h] [rbp-E1h] BYREF
char v5[2]; // [rsp+12h] [rbp-D6h] BYREF
char v6[11]; // [rsp+14h] [rbp-D4h] BYREF
char v7[2]; // [rsp+1Fh] [rbp-C9h] BYREF
char v8[11]; // [rsp+21h] [rbp-C7h] BYREF
char v9[2]; // [rsp+2Ch] [rbp-BCh] BYREF
char v10[8]; // [rsp+2Eh] [rbp-BAh] BYREF
char v11[6]; // [rsp+36h] [rbp-B2h] BYREF
char v12[7]; // [rsp+3Ch] [rbp-ACh] BYREF
char v13[4]; // [rsp+43h] [rbp-A5h] BYREF
char src[25]; // [rsp+47h] [rbp-A1h] BYREF
char desta[136]; // [rsp+60h] [rbp-88h] BYREF

pthread_mutex_lock(&GPRMCMutex);
strcpy(desta, *(const char **)GPRMC_LIST);
pthread_mutex_unlock(&GPRMCMutex);
parseGPRMC(v3, desta);
switch ( a2 )
{
case 2:
strcpy(dest, v4);
break;
case 3:
strcpy(dest, v5);
break;
case 4:
strcpy(dest, v6);
break;
case 5:
strcpy(dest, v7);
break;
case 6:
strcpy(dest, v8);
break;
case 7:
strcpy(dest, v9);
break;
case 8:
strcpy(dest, v10);
break;
case 9:
strcpy(dest, v11);
break;
case 10:
strcpy(dest, v12);
break;
case 11:
strcpy(dest, v13);
break;
case 12:
strcpy(dest, src);
break;
default:
strcpy(dest, v3);
break;
}
return dest;
}

canonical_decompiled_code:
char *__fastcall func1(char *dest, int a2)
{
char v3[7]; // [rsp+0h] [rbp-E8h] BYREF
char v4[11]; // [rsp+7h] [rbp-E1h] BYREF
char v5[2]; // [rsp+12h] [rbp-D6h] BYREF
char v6[11]; // [rsp+14h] [rbp-D4h] BYREF
char v7[2]; // [rsp+1Fh] [rbp-C9h] BYREF
char v8[11]; // [rsp+21h] [rbp-C7h] BYREF
char v9[2]; // [rsp+2Ch] [rbp-BCh] BYREF
char v10[8]; // [rsp+2Eh] [rbp-BAh] BYREF
char v11[6]; // [rsp+36h] [rbp-B2h] BYREF
char v12[7]; // [rsp+3Ch] [rbp-ACh] BYREF
char v13[4]; // [rsp+43h] [rbp-A5h] BYREF
char src[25]; // [rsp+47h] [rbp-A1h] BYREF
char desta[136]; // [rsp+60h] [rbp-88h] BYREF

pthread_mutex_lock(&GPRMCMutex);
strcpy(desta, *(const char **)GPRMC_LIST);
pthread_mutex_unlock(&GPRMCMutex);
parseGPRMC(v3, desta);
switch ( a2 )
{
case 2:
strcpy(dest, v4);
break;
case 3:
strcpy(dest, v5);
break;
case 4:
strcpy(dest, v6);
break;
case 5:
strcpy(dest, v7);
break;
case 6:
strcpy(dest, v8);
break;
case 7:
strcpy(dest, v9);
break;
case 8:
strcpy(dest, v10);
break;
case 9:
strcpy(dest, v11);
break;
case 10:
strcpy(dest, v12);
break;
case 11:
strcpy(dest, v13);
break;
case 12:
strcpy(dest, src);
break;
default:
strcpy(dest, v3);
break;
}
return dest;
}

original_code:
static char *getGprmc(char *retval, int i)
{
 GPRMC gprmc;
 char line[100];
 pthread_mutex_lock(&GPRMCMutex);
 strcpy(line, GPRMC_LIST->string);
 pthread_mutex_unlock(&GPRMCMutex);
 parseGPRMC(&gprmc, line);
 switch(i){
  case 1:
   strcpy(retval, gprmc.RMCMessageID);
   break;
  case 2:
   strcpy(retval, gprmc.UTCPosition);
   break;
  case 3:
   strcpy(retval, gprmc.Status );
   break;
  case 4:
   strcpy(retval, gprmc.RMCLatitude );
   break;
  case 5:
   strcpy(retval, gprmc.RMCNSIndicator );
   break;
  case 6:
   strcpy(retval, gprmc.RMCLongitude);
   break;
  case 7:
   strcpy(retval, gprmc.RMCEWIndicator);
   break;
  case 8:
   strcpy(retval, gprmc.SpeedOverGround);
   break;
  case 9:
   strcpy(retval, gprmc.CourseOverGround);
   break;
  case 10:
   strcpy(retval, gprmc.Date);
   break;
  case 11:
   strcpy(retval, gprmc.MagneticVariation);
   break;
  case 12:
   strcpy(retval, gprmc.RMCEWIndicator2);
   break;
  case 13:
   strcpy(retval, gprmc.Checksum);
   break;
 }
 return retval;
}

canonical_original_code:
static char *getGprmc(char *retval, int i)
{
 struct GPRMC gprmc;
 char line[100];
 pthread_mutex_lock(&GPRMCMutex);
 strcpy(line, GPRMC_LIST->string);
 pthread_mutex_unlock(&GPRMCMutex);
 parseGPRMC(&gprmc, line);
 switch(i){
  case 1:
   strcpy(retval, gprmc.RMCMessageID);
   break;
  case 2:
   strcpy(retval, gprmc.UTCPosition);
   break;
  case 3:
   strcpy(retval, gprmc.Status );
   break;
  case 4:
   strcpy(retval, gprmc.RMCLatitude );
   break;
  case 5:
   strcpy(retval, gprmc.RMCNSIndicator );
   break;
  case 6:
   strcpy(retval, gprmc.RMCLongitude);
   break;
  case 7:
   strcpy(retval, gprmc.RMCEWIndicator);
   break;
  case 8:
   strcpy(retval, gprmc.SpeedOverGround);
   break;
  case 9:
   strcpy(retval, gprmc.CourseOverGround);
   break;
  case 10:
   strcpy(retval, gprmc.Date);
   break;
  case 11:
   strcpy(retval, gprmc.MagneticVariation);
   break;
  case 12:
   strcpy(retval, gprmc.RMCEWIndicator2);
   break;
  case 13:
   strcpy(retval, gprmc.Checksum);
   break;
 }
 return retval;
}

variable_types: struct GPRMC { char RMCMessageID[7]; char UTCPosition[11]; char Status[2]; char RMCLatitude[11]; char RMCNSIndicator[2]; char RMCLongitude[11]; char RMCEWIndicator[2]; char SpeedOverGround[8]; char CourseOverGround[6]; char Date[7]; char MagneticVariation[4]; char RMCEWIndicator2[2]; char Checksum[8]; }


getMessageID

decompiled_code:
char *__fastcall getMessageID(char *a1)
{
return getGpgga(a1, 0);
}

canonical_decompiled_code:
char *__fastcall func2(char *a1)
{
return func0(a1, 0);
}

original_code: char *getMessageID(char *retval){return getGpgga(retval, 0);}


getUTCTime

decompiled_code:
char *__fastcall getUTCTime(char *a1)
{
return getGpgga(a1, 1);
}

canonical_decompiled_code:
char *__fastcall func3(char *a1)
{
return func0(a1, 1);
}

original_code: char *getUTCTime(char *retval){return getGpgga(retval, 1);}


getLatitude

decompiled_code:
char *__fastcall getLatitude(char *a1)
{
return getGpgga(a1, 2);
}

canonical_decompiled_code:
char *__fastcall func4(char *a1)
{
return func0(a1, 2);
}

original_code: char *getLatitude(char *retval){return getGpgga(retval, 2);}


getNSIndicator

decompiled_code:
char *__fastcall getNSIndicator(char *a1)
{
return getGpgga(a1, 3);
}

canonical_decompiled_code:
char *__fastcall func5(char *a1)
{
return func0(a1, 3);
}

original_code: char *getNSIndicator(char *retval){return getGpgga(retval, 3);}


getLongitude

decompiled_code:
char *__fastcall getLongitude(char *a1)
{
return getGpgga(a1, 4);
}

canonical_decompiled_code:
char *__fastcall func6(char *a1)
{
return func0(a1, 4);
}

original_code: char *getLongitude(char *retval){return getGpgga(retval, 4);}


getEWIndicator

decompiled_code:
char *__fastcall getEWIndicator(char *a1)
{
return getGpgga(a1, 5);
}

canonical_decompiled_code:
char *__fastcall func7(char *a1)
{
return func0(a1, 5);
}

original_code: char *getEWIndicator(char *retval){return getGpgga(retval, 5);}


getPositionFixIndicator

decompiled_code:
char *__fastcall getPositionFixIndicator(char *a1)
{
return getGpgga(a1, 6);
}

canonical_decompiled_code:
char *__fastcall func8(char *a1)
{
return func0(a1, 6);
}

original_code: char *getPositionFixIndicator(char *retval){return getGpgga(retval, 6);}


getSatellitesUsed

decompiled_code:
char *__fastcall getSatellitesUsed(char *a1)
{
return getGpgga(a1, 7);
}

canonical_decompiled_code:
char *__fastcall func9(char *a1)
{
return func0(a1, 7);
}

original_code: char *getSatellitesUsed(char *retval){return getGpgga(retval, 7);}


getHDOP

decompiled_code:
char *__fastcall getHDOP(char *a1)
{
return getGpgga(a1, 8);
}

canonical_decompiled_code:
char *__fastcall func10(char *a1)
{
return func0(a1, 8);
}

original_code: char *getHDOP(char *retval){return getGpgga(retval, 8);}


getMSLAltitude

decompiled_code:
char *__fastcall getMSLAltitude(char *a1)
{
return getGpgga(a1, 9);
}

canonical_decompiled_code:
char *__fastcall func11(char *a1)
{
return func0(a1, 9);
}

original_code: char *getMSLAltitude(char *retval){return getGpgga(retval, 9);}


getMSLUnits

decompiled_code:
char *__fastcall getMSLUnits(char *a1)
{
return getGpgga(a1, 10);
}

canonical_decompiled_code:
char *__fastcall func12(char *a1)
{
return func0(a1, 10);
}

original_code: char *getMSLUnits(char *retval){return getGpgga(retval, 10);}


getGeoidSeparation

decompiled_code:
char *__fastcall getGeoidSeparation(char *a1)
{
return getGpgga(a1, 11);
}

canonical_decompiled_code:
char *__fastcall func13(char *a1)
{
return func0(a1, 11);
}

original_code: char *getGeoidSeparation(char *retval){return getGpgga(retval, 11);}


getGeoidUnits

decompiled_code:
char *__fastcall getGeoidUnits(char *a1)
{
return getGpgga(a1, 12);
}

canonical_decompiled_code:
char *__fastcall func14(char *a1)
{
return func0(a1, 12);
}

original_code: char *getGeoidUnits(char *retval){return getGpgga(retval, 12);}


getAgeOfDiffCorr

decompiled_code:
char *__fastcall getAgeOfDiffCorr(char *a1)
{
return getGpgga(a1, 13);
}

canonical_decompiled_code:
char *__fastcall func15(char *a1)
{
return func0(a1, 13);
}

original_code: char *getAgeOfDiffCorr(char *retval){return getGpgga(retval, 13);}


getDiffRefStation

decompiled_code:
char *__fastcall getDiffRefStation(char *a1)
{
return getGpgga(a1, 14);
}

canonical_decompiled_code:
char *__fastcall func16(char *a1)
{
return func0(a1, 14);
}

original_code: char *getDiffRefStation(char *retval){return getGpgga(retval, 14);}


getChecksum

decompiled_code:
char *__fastcall getChecksum(char *a1)
{
return getGpgga(a1, 15);
}

canonical_decompiled_code:
char *__fastcall func17(char *a1)
{
return func0(a1, 15);
}

original_code: char *getChecksum(char *retval){return getGpgga(retval, 15);}


getRMCMessageID

decompiled_code:
char *__fastcall getRMCMessageID(char *a1)
{
return getGprmc(a1, 1);
}

canonical_decompiled_code:
char *__fastcall func18(char *a1)
{
return func1(a1, 1);
}

original_code: char *getRMCMessageID(char *retval){return getGprmc(retval, 1);}


getUTCPosition

decompiled_code:
char *__fastcall getUTCPosition(char *a1)
{
return getGprmc(a1, 2);
}

canonical_decompiled_code:
char *__fastcall func19(char *a1)
{
return func1(a1, 2);
}

original_code: char *getUTCPosition(char *retval){return getGprmc(retval, 2);}


getStatus

decompiled_code:
char *__fastcall getStatus(char *a1)
{
return getGprmc(a1, 3);
}

canonical_decompiled_code:
char *__fastcall func20(char *a1)
{
return func1(a1, 3);
}

original_code: char *getStatus(char *retval){return getGprmc(retval, 3);}


getRMCLatitude

decompiled_code:
char *__fastcall getRMCLatitude(char *a1)
{
return getGprmc(a1, 4);
}

canonical_decompiled_code:
char *__fastcall func21(char *a1)
{
return func1(a1, 4);
}

original_code: char *getRMCLatitude(char *retval){return getGprmc(retval, 4);}


getRMCNSIndicator

decompiled_code:
char *__fastcall getRMCNSIndicator(char *a1)
{
return getGprmc(a1, 5);
}

canonical_decompiled_code:
char *__fastcall func22(char *a1)
{
return func1(a1, 5);
}

original_code: char *getRMCNSIndicator(char *retval){return getGprmc(retval, 5);}


getRMCLongitude

decompiled_code:
char *__fastcall getRMCLongitude(char *a1)
{
return getGprmc(a1, 6);
}

canonical_decompiled_code:
char *__fastcall func23(char *a1)
{
return func1(a1, 6);
}

original_code: char *getRMCLongitude(char *retval){return getGprmc(retval, 6);}


getRMCEWIndicator

decompiled_code:
char *__fastcall getRMCEWIndicator(char *a1)
{
return getGprmc(a1, 7);
}

canonical_decompiled_code:
char *__fastcall func24(char *a1)
{
return func1(a1, 7);
}

original_code: char *getRMCEWIndicator(char *retval){return getGprmc(retval, 7);}


getSpeedOverGround

decompiled_code:
char *__fastcall getSpeedOverGround(char *a1)
{
return getGprmc(a1, 8);
}

canonical_decompiled_code:
char *__fastcall func25(char *a1)
{
return func1(a1, 8);
}

original_code: char *getSpeedOverGround(char *retval){return getGprmc(retval, 8);}


getCourseOverGround

decompiled_code:
char *__fastcall getCourseOverGround(char *a1)
{
return getGprmc(a1, 9);
}

canonical_decompiled_code:
char *__fastcall func26(char *a1)
{
return func1(a1, 9);
}

original_code: char *getCourseOverGround(char *retval){return getGprmc(retval, 9);}


getDate

decompiled_code:
char *__fastcall getDate(char *a1)
{
return getGprmc(a1, 10);
}

canonical_decompiled_code:
char *__fastcall func27(char *a1)
{
return func1(a1, 10);
}

original_code: char *getDate(char *retval){return getGprmc(retval, 10);}


getMagneticVariation

decompiled_code:
char *__fastcall getMagneticVariation(char *a1)
{
return getGprmc(a1, 11);
}

canonical_decompiled_code:
char *__fastcall func28(char *a1)
{
return func1(a1, 11);
}

original_code: char *getMagneticVariation(char *retval){return getGprmc(retval, 11);}


getRMCChecksum

decompiled_code:
char *__fastcall getRMCChecksum(char *a1)
{
return getGprmc(a1, 12);
}

canonical_decompiled_code:
char *__fastcall func29(char *a1)
{
return func1(a1, 12);
}

original_code: char *getRMCChecksum(char *retval){return getGprmc(retval, 12);}


BUinitGPS

decompiled_code:
__int64 BUinitGPS()
{
pthread_t newthread; // [rsp+8h] [rbp-50h] BYREF
pthread_attr_t attr; // [rsp+10h] [rbp-48h] BYREF

pthread_mutex_init(&GPGSAMutex, 0LL);
pthread_mutex_init(&GPRMCMutex, 0LL);
pthread_mutex_init(&GPGGAMutex, 0LL);
pthread_mutex_init(&GPGSVMutex, 0LL);
pthread_attr_init(&attr);
if ( pthread_create(&newthread, &attr, (void *(*)(void *))&readSerial, 0LL) )
{
puts("Error could not create thread!");
exit(-1);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func30()
{
pthread_t newthread; // [rsp+8h] [rbp-50h] BYREF
pthread_attr_t attr; // [rsp+10h] [rbp-48h] BYREF

pthread_mutex_init(&GPGSAMutex, 0LL);
pthread_mutex_init(&GPRMCMutex, 0LL);
pthread_mutex_init(&GPGGAMutex, 0LL);
pthread_mutex_init(&GPGSVMutex, 0LL);
pthread_attr_init(&attr);
if ( pthread_create(&newthread, &attr, (void *(*)(void *))&readSerial, 0LL) )
{
puts("Error could not create thread!");
exit(-1);
}
return 0LL;
}

original_code:
int BUinitGPS(int flags, int numberOfObjects)
{
 int pt;
 pthread_mutex_init(&GPGSAMutex, ((void *)0));
 pthread_mutex_init(&GPRMCMutex, ((void *)0));
 pthread_mutex_init(&GPGGAMutex, ((void *)0));
 pthread_mutex_init(&GPGSVMutex, ((void *)0));
 pthread_t thread1;
 pthread_attr_t attr;
 pthread_attr_init(&attr);
 pt = pthread_create(&thread1, &attr, readSerial, ((void *)0));
 if (pt){
  printf("Error could not create thread!\n");
  exit(-1);
 }
 return pt;
}

canonical_original_code:
int BUinitGPS(int flags, int numberOfObjects)
{
 int pt;
 pthread_mutex_init(&GPGSAMutex, ((void *)0));
 pthread_mutex_init(&GPRMCMutex, ((void *)0));
 pthread_mutex_init(&GPGGAMutex, ((void *)0));
 pthread_mutex_init(&GPGSVMutex, ((void *)0));
 unsigned long thread1;
 union pthread_attr_t attr;
 pthread_attr_init(&attr);
 pt = pthread_create(&thread1, &attr, readSerial, ((void *)0));
 if (pt){
  printf("Error could not create thread!\n");
  exit(-1);
 }
 return pt;
}

variable_types: flags int

variable_types: numberOfObjects int

variable_types: pt int

variable_types: union pthread_attr_t { char __size[56]; long __align; }

return_type: int


decompiled_code:
_BOOL8 __fastcall nmea_checksum(char *a1)
{
char v1; // al
unsigned __int8 v2; // dl
char *v3; // rcx
__int64 v4; // rbx

v1 = *a1;
if ( !*a1 )
{
v4 = 0LL;
return strtoul(a1 + 1, 0LL, 16) == v4;
}
v2 = 0;
while ( 1 )
{
v3 = a1++;
if ( v1 != 36 )
break;
LABEL_6:
v1 = *a1;
if ( !*a1 )
{
v4 = v2;
return strtoul(a1 + 1, 0LL, 16) == v4;
}
}
if ( v1 != 42 )
{
v2 ^= v1;
goto LABEL_6;
}
v4 = v2;
a1 = v3;
return strtoul(a1 + 1, 0LL, 16) == v4;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *a1)
{
char v1; // al
unsigned __int8 v2; // dl
char *v3; // rcx
__int64 v4; // rbx

v1 = *a1;
if ( !*a1 )
{
v4 = 0LL;
return strtoul(a1 + 1, 0LL, 16) == v4;
}
v2 = 0;
while ( 1 )
{
v3 = a1++;
if ( v1 != 36 )
break;
LABEL_6:
v1 = *a1;
if ( !*a1 )
{
v4 = v2;
return strtoul(a1 + 1, 0LL, 16) == v4;
}
}
if ( v1 != 42 )
{
v2 ^= v1;
goto LABEL_6;
}
v4 = v2;
a1 = v3;
return strtoul(a1 + 1, 0LL, 16) == v4;
}

original_code:
static int nmea_checksum(char *line)
{
 uint8_t checksum = 0;
 while (*line){
  if (*line == '$'){
   line++;
   continue;
  }
  if (*line == '*')
   break;
  checksum ^= *line++;
 }
 return (strtoul(line+1, ((void *)0), 16) == checksum);
}

canonical_original_code:
static int nmea_checksum(char *line)
{
 unsigned char checksum = 0;
 while (*line){
  if (*line == '$'){
   line++;
   continue;
  }
  if (*line == '*')
   break;
  checksum ^= *line++;
 }
 return (strtoul(line+1, ((void *)0), 16) == checksum);
}

variable_types:
line
char *

variable_types:
checksum
unsigned char


readSerial

decompiled_code:
void __noreturn readSerial()
{
int v0; // eax
int v1; // ebx
int *v2; // rax
struct termios v3; // [rsp+0h] [rbp-A8h] BYREF
char buf[104]; // [rsp+40h] [rbp-68h] BYREF

v0 = open("/dev/ttyUSB0", 0);
if ( v0 != -1 )
{
v1 = v0;
v3.c_iflag = 20480;
*(_QWORD *)&v3.c_cflag = 0x2800008BCLL;
tcflush(v0, 0);
if ( tcsetattr(v1, 0, &v3) != -1 )
{
while ( 1 )
{
do
buf[(int)read(v1, buf, 0x51uLL)] = 0;
while ( !nmea_checksum(buf) );
if ( strstr(buf, "$GPGGA") )
{
pthread_mutex_lock(&GPGGAMutex);
GPGGA_LIST = pushItem(GPGGA_LIST, buf);
pthread_mutex_unlock(&GPGGAMutex);
}
if ( strstr(buf, "$GPGSA") )
{
pthread_mutex_lock(&GPGSAMutex);
GPGSA_LIST = pushItem(GPGSA_LIST, buf);
pthread_mutex_unlock(&GPGSAMutex);
}
if ( strstr(buf, "$GPRMC") )
{
pthread_mutex_lock(&GPRMCMutex);
GPRMC_LIST = pushItem(GPRMC_LIST, buf);
pthread_mutex_unlock(&GPRMCMutex);
}
if ( strstr(buf, "$GPGSV") )
{
pthread_mutex_lock(&GPGSVMutex);
GPGSV_LIST = pushItem(GPGSV_LIST, buf);
pthread_mutex_unlock(&GPGSVMutex);
}
}
}
puts("Could not set attributes!");
exit(1);
}
v2 = _errno_location();
printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (unsigned int)*v2);
exit(1);
}

canonical_decompiled_code:
void __noreturn func1()
{
int v0; // eax
int v1; // ebx
int *v2; // rax
struct termios v3; // [rsp+0h] [rbp-A8h] BYREF
char buf[104]; // [rsp+40h] [rbp-68h] BYREF

v0 = open("/dev/ttyUSB0", 0);
if ( v0 != -1 )
{
v1 = v0;
v3.c_iflag = 20480;
*(_QWORD *)&v3.c_cflag = 0x2800008BCLL;
tcflush(v0, 0);
if ( tcsetattr(v1, 0, &v3) != -1 )
{
while ( 1 )
{
do
buf[(int)read(v1, buf, 0x51uLL)] = 0;
while ( !func0(buf) );
if ( strstr(buf, "$GPGGA") )
{
pthread_mutex_lock(&GPGGAMutex);
GPGGA_LIST = pushItem(GPGGA_LIST, buf);
pthread_mutex_unlock(&GPGGAMutex);
}
if ( strstr(buf, "$GPGSA") )
{
pthread_mutex_lock(&GPGSAMutex);
GPGSA_LIST = pushItem(GPGSA_LIST, buf);
pthread_mutex_unlock(&GPGSAMutex);
}
if ( strstr(buf, "$GPRMC") )
{
pthread_mutex_lock(&GPRMCMutex);
GPRMC_LIST = pushItem(GPRMC_LIST, buf);
pthread_mutex_unlock(&GPRMCMutex);
}
if ( strstr(buf, "$GPGSV") )
{
pthread_mutex_lock(&GPGSVMutex);
GPGSV_LIST = pushItem(GPGSV_LIST, buf);
pthread_mutex_unlock(&GPGSVMutex);
}
}
}
puts("Could not set attributes!");
exit(1);
}
v2 = _errno_location();
printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (unsigned int)*v2);
exit(1);
}

original_code:
void *readSerial()
{
 int STOP=0;
 int fd, res;
 char line[82];
 struct termios attrib;
 fd = open("/dev/ttyUSB0", 00);
 if(fd == -1){
  printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (*__errno_location ()));
  exit(1);
 }
 attrib.c_lflag = 0000002;
 attrib.c_iflag = 0010000 | 0040000;
 attrib.c_cflag = 0000014 | 020000000000 | 0000060 | 0004000 | 0000200;
 tcflush(fd, 0);
 if(tcsetattr(fd, 0, &attrib) == -1){
  printf("Could not set attributes!\n");
  exit(1);
 }
 while (STOP==0){
  res = read( fd, line, 81);
  line[res]=0;
  if(nmea_checksum(line)){
   if(strstr(line, "$GPGGA")!=((void *)0)){
    pthread_mutex_lock(&GPGGAMutex);
    GPGGA_LIST = pushItem(GPGGA_LIST, line);
    pthread_mutex_unlock(&GPGGAMutex);
   }
   if(strstr(line, "$GPGSA")!=((void *)0)){
    pthread_mutex_lock(&GPGSAMutex);
    GPGSA_LIST = pushItem(GPGSA_LIST, line);
    pthread_mutex_unlock(&GPGSAMutex);
   }
   if(strstr(line, "$GPRMC")!=((void *)0)){
    pthread_mutex_lock(&GPRMCMutex);
    GPRMC_LIST = pushItem(GPRMC_LIST, line);
    pthread_mutex_unlock(&GPRMCMutex);
   }
   if(strstr(line, "$GPGSV")!=((void *)0)){
    pthread_mutex_lock(&GPGSVMutex);
    GPGSV_LIST = pushItem(GPGSV_LIST, line);
    pthread_mutex_unlock(&GPGSVMutex);
   }
  }
 }
  close(fd);
 return ((void *)0);
}

canonical_original_code:
void *readSerial()
{
 int STOP = 0;
 int fd; int res;
 char line[82];
 struct termios attrib;
 fd = open("/dev/ttyUSB0", 00);
 if(fd == -1){
  printf("Could not open %s, errno = %d", "/dev/ttyUSB0", (*__errno_location ()));
  exit(1);
 }
 attrib.c_lflag = 0000002;
 attrib.c_iflag = 0010000 | 0040000;
 attrib.c_cflag = 0000014 | 020000000000 | 0000060 | 0004000 | 0000200;
 tcflush(fd, 0);
 if(tcsetattr(fd, 0, &attrib) == -1){
  printf("Could not set attributes!\n");
  exit(1);
 }
 while (STOP==0){
  res = read( fd, line, 81);
  line[res]=0;
  if(nmea_checksum(line)){
   if(strstr(line, "$GPGGA")!=((void *)0)){
    pthread_mutex_lock(&GPGGAMutex);
    GPGGA_LIST = pushItem(GPGGA_LIST, line);
    pthread_mutex_unlock(&GPGGAMutex);
   }
   if(strstr(line, "$GPGSA")!=((void *)0)){
    pthread_mutex_lock(&GPGSAMutex);
    GPGSA_LIST = pushItem(GPGSA_LIST, line);
    pthread_mutex_unlock(&GPGSAMutex);
   }
   if(strstr(line, "$GPRMC")!=((void *)0)){
    pthread_mutex_lock(&GPRMCMutex);
    GPRMC_LIST = pushItem(GPRMC_LIST, line);
    pthread_mutex_unlock(&GPRMCMutex);
   }
   if(strstr(line, "$GPGSV")!=((void *)0)){
    pthread_mutex_lock(&GPGSVMutex);
    GPGSV_LIST = pushItem(GPGSV_LIST, line);
    pthread_mutex_unlock(&GPGSVMutex);
   }
  }
 }
  close(fd);
 return ((void *)0);
}

variable_types: STOP int

variable_types: fd int

variable_types: res int

variable_types:
line
char [82]

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

return_type: void *


printList

decompiled_code:
int __fastcall printList(__int64 a1)
{
unsigned int v1; // ebp
__int64 v2; // rbx
__int64 v3; // rsi
int result; // eax

if ( a1 )
{
v1 = 0;
v2 = a1;
do
{
v3 = v1++;
result = printf("%d: %s", v3, *(const char **)v2);
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
unsigned int v1; // ebp
__int64 v2; // rbx
__int64 v3; // rsi
int result; // eax

if ( a1 )
{
v1 = 0;
v2 = a1;
do
{
v3 = v1++;
result = printf("%d: %s", v3, *(const char **)v2);
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
}
return result;
}

original_code:
void printList(Item *head)
{
 int i=0;
 while(head != ((void *)0)){
  printf("%d: %s", i++, head->string);
  head = head->next;
 }
}

canonical_original_code:
void printList(struct Item *head)
{
 int i = 0;
 while(head != ((void *)0)){
  printf("%d: %s", i++, head->string);
  head = head->next;
 }
}

variable_types: struct Item { char *string; struct Item *next; } *

return_type: void


noOfItems

decompiled_code:
__int64 __fastcall noOfItems(__int64 a1)
{
unsigned int v1; // er8
__int64 i; // rax

v1 = 0;
if ( a1 )
{
for ( i = *(_QWORD *)(a1 + 8); i; ++v1 )
i = *(_QWORD *)(i + 8);
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // er8
__int64 i; // rax

v1 = 0;
if ( a1 )
{
for ( i = *(_QWORD *)(a1 + 8); i; ++v1 )
i = *(_QWORD *)(i + 8);
}
return v1;
}

original_code:
int noOfItems(Item *head)
{
 int i=0;
 if(head!=((void *)0))
 while(head->next != ((void *)0)){
  i++;
  head = head->next;
 }
 return i;
}

canonical_original_code:
int noOfItems(struct Item *head)
{
 int i = 0;
 if(head!=((void *)0))
 while(head->next != ((void *)0)){
  i++;
  head = head->next;
 }
 return i;
}

user_defined_types: struct Item { char *string; struct Item *next; }


deleteLast

decompiled_code:
void __fastcall deleteLast(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rax
_QWORD *v3; // rdi

v1 = a1;
v2 = (_QWORD *)a1[1];
while ( 1 )
{
v3 = v2;
v2 = (_QWORD *)v2[1];
if ( !v2 )
break;
v1 = v3;
}
free(v3);
v1[1] = 0LL;
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rax
_QWORD *v3; // rdi

v1 = a1;
v2 = (_QWORD *)a1[1];
while ( 1 )
{
v3 = v2;
v2 = (_QWORD *)v2[1];
if ( !v2 )
break;
v1 = v3;
}
free(v3);
v1[1] = 0LL;
}

original_code:
void deleteLast(Item *head)
{
 while((head->next)->next!=((void *)0))
  head=head->next;
 free(head->next);
 head->next=((void *)0);
}

canonical_original_code:
void deleteLast(struct Item *head)
{
 while((head->next)->next!=((void *)0))
  head=head->next;
 free(head->next);
 head->next=((void *)0);
}


decompiled_code:
void *__fastcall assoc_array_init(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
void *v4; // rax
void *result; // rax

*a1 = a2;
a1[5] = 8LL;
a1[6] = 0LL;
a1[3] = a3;
a1[4] = a4;
a1[7] = a1;
a1[8] = 0LL;
v4 = calloc(8uLL, 8uLL);
a1[1] = v4;
if ( !v4 || (result = calloc(8uLL, 8uLL), (a1[2] = result) == 0LL) )
{
perror("calloc()");
abort();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func4(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
void *v4; // rax
void *result; // rax

*a1 = a2;
a1[5] = 8LL;
a1[6] = 0LL;
a1[3] = a3;
a1[4] = a4;
a1[7] = a1;
a1[8] = 0LL;
v4 = calloc(8uLL, 8uLL);
a1[1] = v4;
if ( !v4 || (result = calloc(8uLL, 8uLL), (a1[2] = result) == 0LL) )
{
perror("calloc()");
abort();
}
return result;
}

original_code:
void
assoc_array_init(AssocArray *array, CompareFunc compare_keys, FreeFunc free_key, FreeFunc free_value)
{
 ((void) (0));
 ((void) (0));
 array->compare_keys = compare_keys;
 array->size = 8;
 array->count = 0;
 array->free_key = free_key;
 array->free_value = free_value;
 array->pair.array = array;
 array->pair.offset = 0;
 array->keys = (void **)calloc(array->size, sizeof(void *));
 if(!array->keys)
 {
  perror("calloc()");
  abort();
 }
 array->values = (void **)calloc(array->size, sizeof(void *));
 if(!array->values)
 {
  perror("calloc()");
  abort();
 }
}

canonical_original_code:
void assoc_array_init(struct _AssocArray *array, int (*compare_keys)(void *a, void *b), void (*free_key)(void *p), void (*free_value)(void *p))
{
 ((void) (0));
 ((void) (0));
 array->compare_keys = compare_keys;
 array->size = 8;
 array->count = 0;
 array->free_key = free_key;
 array->free_value = free_value;
 array->pair.array = array;
 array->pair.offset = 0;
 array->keys = (void **)calloc(array->size, sizeof(void *));
 if(!array->keys)
 {
  perror("calloc()");
  abort();
 }
 array->values = (void **)calloc(array->size, sizeof(void *));
 if(!array->values)
 {
  perror("calloc()");
  abort();
 }
}

variable_types: struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair { struct _AssocArray *array; long offset; } pair; } *

user_defined_types: struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair pair; }


decompiled_code:
void __fastcall assoc_array_free(__int64 a1)
{
assoc_array_free_memory((_QWORD *)a1);
free(*(void **)(a1 + 8));
free(*(void **)(a1 + 16));
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
assoc_array_free_memory((_QWORD *)a1);
free(*(void **)(a1 + 8));
free(*(void **)(a1 + 16));
}

original_code:
void
assoc_array_free(AssocArray *array)
{
 ((void) (0));
 _assoc_array_free_memory(array);
 free(array->keys);
 free(array->values);
}

canonical_original_code:
void assoc_array_free(struct _AssocArray *array)
{
 ((void) (0));
 _assoc_array_free_memory(array);
 free(array->keys);
 free(array->values);
}

user_defined_types: struct _AssocArrayPair { struct _AssocArray *array; long offset; }


decompiled_code:
void __fastcall assoc_array_destroy(void *ptr)
{
assoc_array_free((__int64)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
func5((__int64)ptr);
free(ptr);
}

original_code:
void
assoc_array_destroy(AssocArray *array)
{
 ((void) (0));
 assoc_array_free(array);
 free(array);
}

canonical_original_code:
void assoc_array_destroy(struct _AssocArray *array)
{
 ((void) (0));
 assoc_array_free(array);
 free(array);
}


decompiled_code:
__int64 __fastcall assoc_array_set(_QWORD *a1, __int64 a2, __int64 a3, char a4)
{
__int64 v7; // rdx
_QWORD *v8; // rsi
__int64 (__fastcall *v9)(__int64, _QWORD); // rdi
int v11; // er14
__int64 result; // rax
__int64 v13[6]; // [rsp+8h] [rbp-30h] BYREF

v7 = a1[6];
if ( v7 )
{
v8 = (_QWORD *)a1[1];
v9 = (__int64 (__fastcall *)(__int64, _QWORD))*a1;
v13[0] = 0LL;
v11 = assoc_array_binary_search_constprop_0(v9, v8, v7, a2, v13);
if ( v11 )
{
assoc_array_resize_if_necessary((__int64)a1);
if ( v11 < 0 )
assoc_array_insert_before_offset(a1, a2, a3, v13[0]);
else
assoc_array_insert_after_offset(a1, a2, a3, v13[0]);
++a1[6];
result = 0LL;
}
else
{
assoc_array_replace(a1, a2, a3, v13[0], a4);
result = 1LL;
}
}
else
{
assoc_array_insert_first((__int64)a1, a2, a3);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, __int64 a2, __int64 a3, char a4)
{
__int64 v7; // rdx
_QWORD *v8; // rsi
__int64 (__fastcall *v9)(__int64, _QWORD); // rdi
int v11; // er14
__int64 result; // rax
__int64 v13[6]; // [rsp+8h] [rbp-30h] BYREF

v7 = a1[6];
if ( v7 )
{
v8 = (_QWORD *)a1[1];
v9 = (__int64 (__fastcall *)(__int64, _QWORD))*a1;
v13[0] = 0LL;
v11 = func3(v9, v8, v7, a2, v13);
if ( v11 )
{
func0((__int64)a1);
if ( v11 < 0 )
func1(a1, a2, a3, v13[0]);
else
func2(a1, a2, a3, v13[0]);
++a1[6];
result = 0LL;
}
else
{
assoc_array_replace(a1, a2, a3, v13[0], a4);
result = 1LL;
}
}
else
{
assoc_array_insert_first((__int64)a1, a2, a3);
result = 0LL;
}
return result;
}

original_code:
AssocArrayInsertResult
assoc_array_set(AssocArray *array, void *key, void *value, _Bool overwrite_key)
{
 AssocArrayInsertResult result = ASSOCARRAY_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  int cmp = _assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
  if(cmp)
  {
   result = ASSOCARRAY_INSERT_RESULT_NEW;
   _assoc_array_resize_if_necessary(array);
   if(cmp < 0)
   {
    _assoc_array_insert_before_offset(array, key, value, offset);
   }
   else
   {
    _assoc_array_insert_after_offset(array, key, value, offset);
   }
   ++array->count;
  }
  else
  {
   result = ASSOCARRAY_INSERT_RESULT_REPLACED;
   _assoc_array_replace(array, key, value, offset, overwrite_key);
  }
 }
 else
 {
  result = ASSOCARRAY_INSERT_RESULT_NEW;
  _assoc_array_insert_first(array, key, value);
 }
 return result;
}

canonical_original_code:
enum AssocArrayInsertResult assoc_array_set(struct _AssocArray *array, void *key, void *value, _Bool overwrite_key)
{
 enum AssocArrayInsertResult result = ASSOCARRAY_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  int cmp = _assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
  if(cmp)
  {
   result = ASSOCARRAY_INSERT_RESULT_NEW;
   _assoc_array_resize_if_necessary(array);
   if(cmp < 0)
   {
    _assoc_array_insert_before_offset(array, key, value, offset);
   }
   else
   {
    _assoc_array_insert_after_offset(array, key, value, offset);
   }
   ++array->count;
  }
  else
  {
   result = ASSOCARRAY_INSERT_RESULT_REPLACED;
   _assoc_array_replace(array, key, value, offset, overwrite_key);
  }
 }
 else
 {
  result = ASSOCARRAY_INSERT_RESULT_NEW;
  _assoc_array_insert_first(array, key, value);
 }
 return result;
}

variable_types:
key
void *

variable_types:
value
void *

variable_types: enum AssocArrayInsertResult { ASSOCARRAY_INSERT_RESULT_NEW=0, ASSOCARRAY_INSERT_RESULT_REPLACED=1, ASSOCARRAY_INSERT_RESULT_FAILED=2 }

variable_types: offset long

variable_types: cmp int


original_code:
void
assoc_array_remove(AssocArray *array, const void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   if(array->free_key)
   {
    array->free_key(array->keys[offset]);
   }
   if(array->free_value && array->values[offset])
   {
    array->free_value(array->values[offset]);
   }
   if((size_t)offset < array->count - 1)
   {
    memmove(&array->keys[offset], &array->keys[offset + 1], (array->count - 1 - offset) * sizeof(void *));
    memmove(&array->values[offset], &array->values[offset + 1], (array->count - 1 - offset) * sizeof(void *));
   }
   --array->count;
  }
 }
}

canonical_original_code:
void assoc_array_remove(struct _AssocArray *array, void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   if(array->free_key)
   {
    array->free_key(array->keys[offset]);
   }
   if(array->free_value && array->values[offset])
   {
    array->free_value(array->values[offset]);
   }
   if((unsigned long)offset < array->count - 1)
   {
    memmove(&array->keys[offset], &array->keys[offset + 1], (array->count - 1 - offset) * sizeof(void *));
    memmove(&array->values[offset], &array->values[offset + 1], (array->count - 1 - offset) * sizeof(void *));
   }
   --array->count;
  }
 }
}


original_code:
AssocArrayPair *
assoc_array_lookup(AssocArray *array, const void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   array->pair.offset = offset;
   return &array->pair;
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct _AssocArrayPair *assoc_array_lookup(struct _AssocArray *array, void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  if(!_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset))
  {
   array->pair.offset = offset;
   return &array->pair;
  }
 }
 return ((void *)0);
}

variable_types:
array
struct _AssocArray *

return_type: struct _AssocArrayPair { struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair pair; } *array; long offset; } *


decompiled_code:
bool __fastcall assoc_array_key_exists(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
_QWORD *v4; // r9
__int64 (__fastcall *v5)(__int64, _QWORD); // rdi
__int64 v6; // [rsp+0h] [rbp-10h] BYREF

v2 = *(_QWORD *)(a1 + 48);
if ( !v2 )
return 0;
v4 = *(_QWORD **)(a1 + 8);
v5 = *(__int64 (__fastcall **)(__int64, _QWORD))a1;
v6 = 0LL;
return (unsigned int)assoc_array_binary_search_constprop_0(v5, v4, v2, a2, &v6) == 0;
}

original_code:
_Bool
assoc_array_key_exists(const AssocArray *array, const void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  ssize_t offset = 0;
  return !_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
 }
 return 0;
}

canonical_original_code:
_Bool assoc_array_key_exists(struct _AssocArray *array, void *key)
{
 ((void) (0));
 ((void) (0));
 if(array->count)
 {
  long offset = 0;
  return !_assoc_array_binary_search(array->compare_keys, array->keys, array->count, key, &offset);
 }
 return 0;
}


decompiled_code:
__int64 __fastcall assoc_array_count(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
return *(_QWORD *)(a1 + 48);
}

original_code:
size_t
assoc_array_count(const AssocArray *array)
{
 ((void) (0));
 return array->count;
}

canonical_original_code:
unsigned long assoc_array_count(struct _AssocArray *array)
{
 ((void) (0));
 return array->count;
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall assoc_array_size(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

original_code:
size_t
assoc_array_size(const AssocArray *array)
{
 ((void) (0));
 return array->size;
}

canonical_original_code:
unsigned long assoc_array_size(struct _AssocArray *array)
{
 ((void) (0));
 return array->size;
}


decompiled_code:
bool __fastcall assoc_array_iter_next(_QWORD *a1)
{
unsigned __int64 v1; // rax
bool v2; // cf

v1 = a1[1] + 1LL;
v2 = v1 < *(_QWORD *)(*a1 + 48LL);
a1[1] = v1;
return v2;
}

canonical_decompiled_code:
bool __fastcall func16(_QWORD *a1)
{
unsigned __int64 v1; // rax
bool v2; // cf

v1 = a1[1] + 1LL;
v2 = v1 < *(_QWORD *)(*a1 + 48LL);
a1[1] = v1;
return v2;
}

original_code:
_Bool
assoc_array_iter_next(AssocArrayIter *iter)
{
 ((void) (0));
 ++iter->offset;
 return (size_t)iter->offset < iter->array->count;
}

canonical_original_code:
_Bool assoc_array_iter_next(struct _AssocArrayPair *iter)
{
 ((void) (0));
 ++iter->offset;
 return (unsigned long)iter->offset < iter->array->count;
}

variable_types: struct _AssocArrayPair { struct _AssocArray { int (*compare_keys)(void *a, void *b); void **keys; void **values; void (*free_key)(void *p); void (*free_value)(void *p); unsigned long size; unsigned long count; struct _AssocArrayPair pair; } *array; long offset; } *


decompiled_code:
// attributes: thunk
__int64 __fastcall assoc_array_iter_get_key(_QWORD *a1)
{
return assoc_array_pair_get_key_localalias(a1);
}

canonical_decompiled_code:
__int64 __fastcall func17(_QWORD *a1)
{
return func10(a1);
}

original_code:
void *
assoc_array_iter_get_key(const AssocArrayIter *iter)
{
 ((void) (0));
 return iter->array->keys[iter->offset];
}

canonical_original_code:
void *assoc_array_iter_get_key(struct _AssocArrayPair *iter)
{
 ((void) (0));
 return iter->array->keys[iter->offset];
}


decompiled_code:
// attributes: thunk
__int64 __fastcall assoc_array_iter_get_value(_QWORD *a1)
{
return assoc_array_pair_get_value_localalias(a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(_QWORD *a1)
{
return func11(a1);
}

original_code:
void *
assoc_array_iter_get_value(const AssocArrayIter *iter)
{
 ((void) (0));
 return iter->array->values[iter->offset];
}

canonical_original_code:
void *assoc_array_iter_get_value(struct _AssocArrayPair *iter)
{
 ((void) (0));
 return iter->array->values[iter->offset];
}


decompiled_code:
void __fastcall slist_free(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
slist_item_free((__int64)a1, v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
func0((__int64)a1, v2);
}
while ( v1 );
}
}

original_code:
void
slist_free(SList *list)
{
 ((void) (0));
 SListItem *iter = list->head;
 while(iter)
 {
  SListItem *item = iter;
  iter = iter->next;
  _slist_item_free(list, item);
 }
}

canonical_original_code:
void slist_free(struct _SList *list)
{
 ((void) (0));
 struct _SListItem *iter = list->head;
 while(iter)
 {
  struct _SListItem *item = iter;
  iter = iter->next;
  _slist_item_free(list, item);
 }
}

variable_types: struct _SList { struct _SListItem { void *data; struct _SListItem *next; } *head; struct _SListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

user_defined_types: struct _SList { struct _SListItem *head; struct _SListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool *pool; }


decompiled_code:
void __fastcall slist_destroy(void *ptr)
{
slist_free(ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
func3(ptr);
free(ptr);
}

original_code:
void
slist_destroy(SList *list)
{
 ((void) (0));
 slist_free(list);
 free(list);
}

canonical_original_code:
void slist_destroy(struct _SList *list)
{
 ((void) (0));
 slist_free(list);
 free(list);
}

user_defined_types: struct _SListItem { void *data; struct _SListItem *next; }

user_defined_types: struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); }


decompiled_code:
void __fastcall slist_remove(_QWORD *a1, _QWORD *a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rcx
_QWORD *v5; // rdi
_QWORD *v6; // rdx
__int64 v7; // rax

v2 = (_QWORD *)*a1;
if ( *a1 )
{
v3 = a1;
v5 = 0LL;
if ( a2 == v2 )
{
LABEL_5:
v7 = a2[1];
if ( !v7 )
a1[1] = v5;
*v3 = v7;
slist_item_free((__int64)a1, a2);
--a1[2];
}
else
{
while ( 1 )
{
v6 = (_QWORD *)v2[1];
v3 = v2 + 1;
v5 = v2;
if ( !v6 )
break;
v2 = (_QWORD *)v2[1];
if ( a2 == v6 )
goto LABEL_5;
}
}
}
}

original_code:
void
slist_remove(SList *list, SListItem *item)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 SListItem **ptr = &list->head;
 SListItem *tail = ((void *)0);
 _Bool found = 0;
 while(*ptr && !found)
 {
  if(*ptr == item)
  {
   found = 1;
   if(!item->next)
   {
    list->tail = tail;
   }
   *ptr = item->next;
   _slist_item_free(list, item);
   --list->count;
  }
  else
  {
   tail = *ptr;
   ptr = &(*ptr)->next;
  }
 }
}

canonical_original_code:
void slist_remove(struct _SList *list, struct _SListItem *item)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 struct _SListItem **ptr = &list->head;
 struct _SListItem *tail = ((void *)0);
 _Bool found = 0;
 while(*ptr && !found)
 {
  if(*ptr == item)
  {
   found = 1;
   if(!item->next)
   {
    list->tail = tail;
   }
   *ptr = item->next;
   _slist_item_free(list, item);
   --list->count;
  }
  else
  {
   tail = *ptr;
   ptr = &(*ptr)->next;
  }
 }
}

variable_types:
item
struct _SListItem *

variable_types: struct _SListItem { void *data; struct _SListItem *next; } **


original_code:
void *
slist_pop(SList *list)
{
 ((void) (0));
 void *data = ((void *)0);
 SListItem *item = list->head;
 if(item)
 {
  list->head = item->next;
  if(!list->head)
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}

canonical_original_code:
void *slist_pop(struct _SList *list)
{
 ((void) (0));
 void *data = ((void *)0);
 struct _SListItem *item = list->head;
 if(item)
 {
  list->head = item->next;
  if(!list->head)
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}

variable_types:
data
void *

variable_types: struct _SListItem { void *data; struct _SListItem *next; } *


decompiled_code:
bool __fastcall slist_contains(__int64 a1, __int64 a2)
{
return slist_find(a1, 0LL, a2) != 0LL;
}

canonical_decompiled_code:
bool __fastcall func8(__int64 a1, __int64 a2)
{
return slist_find(a1, 0LL, a2) != 0LL;
}

original_code:
_Bool
slist_contains(const SList *list, const void *data)
{
 ((void) (0));
 ((void) (0));
 return _slist_find(list, ((void *)0), data) != ((void *)0);
}

canonical_original_code:
_Bool slist_contains(struct _SList *list, void *data)
{
 ((void) (0));
 ((void) (0));
 return _slist_find(list, ((void *)0), data) != ((void *)0);
}


decompiled_code:
__int64 __fastcall slist_count(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
size_t
slist_count(const SList *list)
{
 ((void) (0));
 return list->count;
}

canonical_original_code:
unsigned long slist_count(struct _SList *list)
{
 ((void) (0));
 return list->count;
}


decompiled_code:
__int64 __fastcall slist_head(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
SListItem *
slist_head(const SList *list)
{
 ((void) (0));
 return list->head;
}

canonical_original_code:
struct _SListItem *slist_head(struct _SList *list)
{
 ((void) (0));
 return list->head;
}

variable_types: struct _SList { struct _SListItem *head; struct _SListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

return_type: struct _SListItem { void *data; struct _SListItem *next; } *


decompiled_code:
bool __fastcall slist_empty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
bool __fastcall func12(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
_Bool
slist_empty(const SList *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}

canonical_original_code:
_Bool slist_empty(struct _SList *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}


decompiled_code:
void __fastcall list_free(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
list_item_free((__int64)a1, v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func6(_QWORD *a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rsi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v2 = v1;
v1 = (_QWORD *)v1[1];
func3((__int64)a1, v2);
}
while ( v1 );
}
}

original_code:
void
list_free(List *list)
{
 ((void) (0));
 ListItem *iter = list->head;
 while(iter)
 {
  ListItem *item = iter;
  iter = iter->next;
  _list_item_free(list, item);
 }
}

canonical_original_code:
void list_free(struct List *list)
{
 ((void) (0));
 struct _ListItem *iter = list->head;
 while(iter)
 {
  struct _ListItem *item = iter;
  iter = iter->next;
  _list_item_free(list, item);
 }
}

variable_types: struct List { struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; } *head; struct _ListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

user_defined_types: struct List { struct _ListItem *head; struct _ListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool *pool; }


decompiled_code:
void __fastcall list_destroy(void *ptr)
{
list_free(ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
func6(ptr);
free(ptr);
}

original_code:
void
list_destroy(List *list)
{
 ((void) (0));
 list_free(list);
 free(list);
}

canonical_original_code:
void list_destroy(struct List *list)
{
 ((void) (0));
 list_free(list);
 free(list);
}

user_defined_types: struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; }


decompiled_code:
void __fastcall list_remove_by_data(__int64 a1, __int64 a2, char a3)
{
_QWORD *v3; // rbx
_QWORD *v5; // rbp
int v6; // er8
char v7; // al

v3 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
do
{
v5 = v3;
v3 = (_QWORD *)v3[1];
v6 = (*(__int64 (__fastcall **)(_QWORD, __int64))(a1 + 24))(*v5, a2);
v7 = 1;
if ( v6 )
{
if ( !v3 )
return;
}
else
{
list_remove((_QWORD *)a1, v5);
v7 = a3;
if ( !v3 )
return;
}
}
while ( v7 );
}
}

original_code:
void
list_remove_by_data(List *list, void *data, _Bool remove_all)
{
 ((void) (0));
 ((void) (0));
 ListItem *iter = list->head;
 _Bool completed = 0;
 while(iter && !completed)
 {
  ListItem *next = iter->next;
  if(!list->compare(iter->data, data))
  {
   completed = !remove_all;
   list_remove(list, iter);
  }
  iter = next;
 }
}

canonical_original_code:
void list_remove_by_data(struct List *list, void *data, _Bool remove_all)
{
 ((void) (0));
 ((void) (0));
 struct _ListItem *iter = list->head;
 _Bool completed = 0;
 while(iter && !completed)
 {
  struct _ListItem *next = iter->next;
  if(!list->compare(iter->data, data))
  {
   completed = !remove_all;
   list_remove(list, iter);
  }
  iter = next;
 }
}

variable_types: struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; } *


original_code:
void *
list_pop(List *list)
{
 ((void) (0));
 ListItem *item = list->head;
 void *data = ((void *)0);
 if(item)
 {
  list->head = item->next;
  if(list->head)
  {
   list->head->prev = ((void *)0);
  }
  else
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}

canonical_original_code:
void *list_pop(struct List *list)
{
 ((void) (0));
 struct _ListItem *item = list->head;
 void *data = ((void *)0);
 if(item)
 {
  list->head = item->next;
  if(list->head)
  {
   list->head->prev = ((void *)0);
  }
  else
  {
   list->tail = ((void *)0);
  }
  data = item->data;
  if(list->pool)
  {
   list->pool->free(list->pool, item);
  }
  else
  {
   free(item);
  }
  --list->count;
 }
 return data;
}


decompiled_code:
bool __fastcall list_contains(__int64 a1, __int64 a2)
{
return list_find(a1, 0LL, a2) != 0LL;
}

canonical_decompiled_code:
bool __fastcall func14(__int64 a1, __int64 a2)
{
return list_find(a1, 0LL, a2) != 0LL;
}

original_code:
_Bool
list_contains(const List *list, const void *data)
{
 ((void) (0));
 ((void) (0));
 return _list_find(list, ((void *)0), data) != ((void *)0);
}

canonical_original_code:
_Bool list_contains(struct List *list, void *data)
{
 ((void) (0));
 ((void) (0));
 return _list_find(list, ((void *)0), data) != ((void *)0);
}


decompiled_code:
__int64 __fastcall list_head(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
ListItem *
list_head(const List *list)
{
 ((void) (0));
 return list->head;
}

canonical_original_code:
struct _ListItem *list_head(struct List *list)
{
 ((void) (0));
 return list->head;
}

variable_types: struct List { struct _ListItem *head; struct _ListItem *tail; unsigned long count; int (*compare)(void *a, void *b); void (*free)(void *p); struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; } *

return_type: struct _ListItem { void *data; struct _ListItem *next; struct _ListItem *prev; } *


decompiled_code:
__int64 __fastcall list_tail(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
ListItem *
list_tail(const List *list)
{
 ((void) (0));
 return list->tail;
}

canonical_original_code:
struct _ListItem *list_tail(struct List *list)
{
 ((void) (0));
 return list->tail;
}


decompiled_code:
__int64 __fastcall list_count(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
size_t
list_count(const List *list)
{
 ((void) (0));
 return list->count;
}

canonical_original_code:
unsigned long list_count(struct List *list)
{
 ((void) (0));
 return list->count;
}


decompiled_code:
bool __fastcall list_empty(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
bool __fastcall func19(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
_Bool
list_empty(const List *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}

canonical_original_code:
_Bool list_empty(struct List *list)
{
 ((void) (0));
 return list->head == ((void *)0);
}


decompiled_code:
__int64 __fastcall stack_pop(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

if ( slist_count() )
{
v3 = slist_pop(a1);
result = 1LL;
if ( a2 )
*a2 = v3;
}
else
{
result = 0LL;
if ( a2 )
*a2 = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

if ( slist_count() )
{
v3 = slist_pop(a1);
result = 1LL;
if ( a2 )
*a2 = v3;
}
else
{
result = 0LL;
if ( a2 )
*a2 = 0LL;
}
return result;
}

original_code:
_Bool
stack_pop(Stack *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 _Bool success = 0;
 if(slist_count(stack))
 {
  void *ptr = slist_pop(stack);
  if(data)
  {
   *data = ptr;
  }
  success = 1;
 }
 else if(data)
 {
  *data = ((void *)0);
 }
 return success;
}

canonical_original_code:
_Bool stack_pop(struct _SList *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 _Bool success = 0;
 if(slist_count(stack))
 {
  void *ptr = slist_pop(stack);
  if(data)
  {
   *data = ptr;
  }
  success = 1;
 }
 else if(data)
 {
  *data = ((void *)0);
 }
 return success;
}

variable_types:
data
void **

variable_types:
ptr
void *


decompiled_code:
__int64 __fastcall stack_head(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
unsigned int v3; // er8

v2 = (_QWORD *)slist_head();
v3 = 0;
if ( v2 )
{
v3 = 1;
*a2 = *v2;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
unsigned int v3; // er8

v2 = (_QWORD *)slist_head();
v3 = 0;
if ( v2 )
{
v3 = 1;
*a2 = *v2;
}
return v3;
}

original_code:
_Bool
stack_head(const Stack *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 SListItem *iter = slist_head(stack);
 _Bool success = 0;
 if(iter)
 {
  *data = iter->data;
  success = 1;
 }
 return success;
}

canonical_original_code:
_Bool stack_head(struct _SList *stack, void **data)
{
 ((void) (0));
 ((void) (0));
 struct _SListItem *iter = slist_head(stack);
 _Bool success = 0;
 if(iter)
 {
  *data = iter->data;
  success = 1;
 }
 return success;
}


original_code:
void
hashtable_init(HashTable *table, size_t size, HashFunc hash_func, EqualFunc compare_keys, FreeFunc free_key, FreeFunc free_value)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 ((void) (0));
 size_t table_size = 257;
 if(size != 0)
 {
  table_size = size;
 }
 table->buckets = (struct _Bucket **)calloc(table_size, sizeof(struct _Bucket *));
 if(!table->buckets)
 {
  perror("calloc()");
  abort();
 }
 table->pool = (Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
 table->compare_keys = compare_keys;
 table->free_key = free_key;
 table->free_value = free_value;
 table->size = table_size;
 if(size == 0)
 {
  table->grow = 1;
  table->sizeptr = PRIMES;
 }
 else
 {
  table->grow = 0;
  table->sizeptr = ((void *)0);
 }
 table->hash = hash_func;
 table->count = 0;
 table->pair.free_value = free_value;
 table->pair.bucket = ((void *)0);
}

canonical_original_code:
void hashtable_init(struct _HashTable *table, unsigned long size, unsigned int (*hash_func)(void *ptr), _Bool (*compare_keys)(void *a, void *b), void (*free_key)(void *p), void (*free_value)(void *p))
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 ((void) (0));
 unsigned long table_size = 257;
 if(size != 0)
 {
  table_size = size;
 }
 table->buckets = (struct _Bucket **)calloc(table_size, sizeof(struct _Bucket *));
 if(!table->buckets)
 {
  perror("calloc()");
  abort();
 }
 table->pool = (struct _Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
 table->compare_keys = compare_keys;
 table->free_key = free_key;
 table->free_value = free_value;
 table->size = table_size;
 if(size == 0)
 {
  table->grow = 1;
  table->sizeptr = PRIMES;
 }
 else
 {
  table->grow = 0;
  table->sizeptr = ((void *)0);
 }
 table->hash = hash_func;
 table->count = 0;
 table->pair.free_value = free_value;
 table->pair.bucket = ((void *)0);
}

variable_types: struct _HashTable { _Bool (*compare_keys)(void *a, void *b); void (*free_key)(void *p); void (*free_value)(void *p); unsigned int (*hash)(void *ptr); unsigned long size; unsigned long *sizeptr; _Bool grow; struct _Bucket { void *key; void *data; struct _Bucket *next; } **buckets; unsigned long count; struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; struct _HashTablePair { void (*free_value)(void *p); struct _Bucket *bucket; } pair; } *

variable_types:
size
unsigned long

user_defined_types: struct _HashTable { _Bool (*compare_keys)(void *a, void *b); void (*free_key)(void *p); void (*free_value)(void *p); unsigned int (*hash)(void *ptr); unsigned long size; unsigned long *sizeptr; _Bool grow; struct _Bucket **buckets; unsigned long count; struct _Pool *pool; struct _HashTablePair pair; }


decompiled_code:
void __fastcall hashtable_free(__int64 a1)
{
hashtable_free_memory((_QWORD *)a1);
memory_pool_destroy(*(_QWORD *)(a1 + 72));
free(*(void **)(a1 + 56));
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
func0((_QWORD *)a1);
memory_pool_destroy(*(_QWORD *)(a1 + 72));
free(*(void **)(a1 + 56));
}

original_code:
void
hashtable_free(HashTable *table)
{
 ((void) (0));
 _hashtable_free_memory(table);
 memory_pool_destroy((MemoryPool *)table->pool);
 free(table->buckets);
}

canonical_original_code:
void hashtable_free(struct _HashTable *table)
{
 ((void) (0));
 _hashtable_free_memory(table);
 memory_pool_destroy((struct MemoryPool *)table->pool);
 free(table->buckets);
}

user_defined_types: struct MemoryPool { struct _Pool padding; struct _MemoryBlock *block; struct _MemoryPtrBlock *free_block; unsigned long block_size; unsigned long item_size; }

user_defined_types: struct _HashTablePair { void (*free_value)(void *p); struct _Bucket *bucket; }

user_defined_types: struct _MemoryBlock { char *items; unsigned long offset; struct _MemoryBlock *next; }

user_defined_types: struct _MemoryPtrBlock { void **items; unsigned long offset; struct _MemoryPtrBlock *next; }

user_defined_types: struct _Bucket { void *key; void *data; struct _Bucket *next; }


decompiled_code:
void __fastcall hashtable_destroy(void *ptr)
{
hashtable_free((__int64)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
func5((__int64)ptr);
free(ptr);
}

original_code:
void
hashtable_destroy(HashTable *table)
{
 ((void) (0));
 hashtable_free(table);
 free(table);
}

canonical_original_code:
void hashtable_destroy(struct _HashTable *table)
{
 ((void) (0));
 hashtable_free(table);
 free(table);
}


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

*(_QWORD *)(a1 + 64) = 0LL;
hashtable_free_memory((_QWORD *)a1);
memset(*(void **)(a1 + 56), 0, 8LL * *(_QWORD *)(a1 + 32));
memory_pool_destroy(*(_QWORD *)(a1 + 72));
result = memory_pool_new(24LL, 128LL);
*(_QWORD *)(a1 + 72) = result;
return result;
}

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

*(_QWORD *)(a1 + 64) = 0LL;
func0((_QWORD *)a1);
memset(*(void **)(a1 + 56), 0, 8LL * *(_QWORD *)(a1 + 32));
memory_pool_destroy(*(_QWORD *)(a1 + 72));
result = memory_pool_new(24LL, 128LL);
*(_QWORD *)(a1 + 72) = result;
return result;
}

original_code:
void
hashtable_clear(HashTable *table)
{
 ((void) (0));
 table->count = 0;
 _hashtable_free_memory(table);
 memset(table->buckets, 0, sizeof(struct _Bucket *) * table->size);
 memory_pool_destroy((MemoryPool *)table->pool);
 table->pool = (Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
}

canonical_original_code:
void hashtable_clear(struct _HashTable *table)
{
 ((void) (0));
 table->count = 0;
 _hashtable_free_memory(table);
 memset(table->buckets, 0, sizeof(struct _Bucket *) * table->size);
 memory_pool_destroy((struct MemoryPool *)table->pool);
 table->pool = (struct _Pool *)memory_pool_new(sizeof(struct _Bucket), 128);
}


original_code:
HashTableInsertResult
hashtable_set(HashTable *table, void *key, void *value, _Bool overwrite_key)
{
 HashTableInsertResult result = HASHTABLE_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(table->grow && table->count > table->size)
 {
  _hashtable_resize(table);
 }
 size_t index = table->hash(key) % table->size;
 struct _Bucket *head = table->buckets[index];
 struct _Bucket *item = _hashtable_find_bucket(table, head, key);
 if(item)
 {
  result = HASHTABLE_INSERT_RESULT_REPLACED;
  if(overwrite_key)
  {
   if(table->free_key)
   {
    table->free_key(item->key);
   }
   item->key = key;
  }
  if(table->free_value && item->data)
  {
   table->free_value(item->data);
  }
  item->data = value;
 }
 else if(table->count < (18446744073709551615UL))
 {
  result = HASHTABLE_INSERT_RESULT_NEW;
  item = (struct _Bucket *)table->pool->alloc(table->pool);
  item->key = key;
  item->data = value;
  table->buckets[index] = item;
  item->next = head;
  ++table->count;
 }
 else
 {
  fprintf(stderr, "%s(): integer overflow.\n", __func__);
 }
 return result;
}

canonical_original_code:
enum HashTableInsertResult hashtable_set(struct _HashTable *table, void *key, void *value, _Bool overwrite_key)
{
 enum HashTableInsertResult result = HASHTABLE_INSERT_RESULT_FAILED;
 ((void) (0));
 ((void) (0));
 if(table->grow && table->count > table->size)
 {
  _hashtable_resize(table);
 }
 unsigned long index = table->hash(key) % table->size;
 struct _Bucket *head = table->buckets[index];
 struct _Bucket *item = _hashtable_find_bucket(table, head, key);
 if(item)
 {
  result = HASHTABLE_INSERT_RESULT_REPLACED;
  if(overwrite_key)
  {
   if(table->free_key)
   {
    table->free_key(item->key);
   }
   item->key = key;
  }
  if(table->free_value && item->data)
  {
   table->free_value(item->data);
  }
  item->data = value;
 }
 else if(table->count < (18446744073709551615UL))
 {
  result = HASHTABLE_INSERT_RESULT_NEW;
  item = (struct _Bucket *)table->pool->alloc(table->pool);
  item->key = key;
  item->data = value;
  table->buckets[index] = item;
  item->next = head;
  ++table->count;
 }
 else
 {
  fprintf(stderr, "%s(): integer overflow.\n", __func__);
 }
 return result;
}

variable_types:
key
void *

variable_types:
value
void *

variable_types: enum HashTableInsertResult { HASHTABLE_INSERT_RESULT_NEW=0, HASHTABLE_INSERT_RESULT_REPLACED=1, HASHTABLE_INSERT_RESULT_FAILED=2 }

variable_types:
index
unsigned long

variable_types: struct _Bucket { void *key; void *data; struct _Bucket *next; } *


decompiled_code:
__int64 __fastcall hashtable_pair_get_key(__int64 a1)
{
return **(_QWORD **)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return **(_QWORD **)(a1 + 8);
}

original_code:
void *
hashtable_pair_get_key(const HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->key;
}

canonical_original_code:
void *hashtable_pair_get_key(struct _HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->key;
}

variable_types: struct _HashTablePair { void (*free_value)(void *p); struct _Bucket { void *key; void *data; struct _Bucket *next; } *bucket; } *


decompiled_code:
__int64 __fastcall hashtable_pair_get_value(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
}

original_code:
void *
hashtable_pair_get_value(const HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->data;
}

canonical_original_code:
void *hashtable_pair_get_value(struct _HashTablePair *pair)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 return pair->bucket->data;
}


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

result = *(_QWORD *)(a1 + 8);
if ( *(_QWORD *)a1 && *(_QWORD *)(result + 8) )
{
(*(void (**)(void))a1)();
result = *(_QWORD *)(a1 + 8);
}
*(_QWORD *)(result + 8) = a2;
return result;
}

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

result = *(_QWORD *)(a1 + 8);
if ( *(_QWORD *)a1 && *(_QWORD *)(result + 8) )
{
(*(void (**)(void))a1)();
result = *(_QWORD *)(a1 + 8);
}
*(_QWORD *)(result + 8) = a2;
return result;
}

original_code:
void
hashtable_pair_set_value(HashTablePair *pair, void *value)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(pair->free_value && pair->bucket->data)
 {
  pair->free_value(pair->bucket->data);
 }
 pair->bucket->data = value;
}

canonical_original_code:
void hashtable_pair_set_value(struct _HashTablePair *pair, void *value)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(pair->free_value && pair->bucket->data)
 {
  pair->free_value(pair->bucket->data);
 }
 pair->bucket->data = value;
}


decompiled_code:
bool __fastcall hashtable_key_exists(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
unsigned int v3; // eax

v2 = *(_QWORD *)(a1 + 56);
v3 = (*(__int64 (__fastcall **)(__int64))(a1 + 24))(a2);
return hashtable_find_bucket(
(unsigned __int8 (__fastcall **)(__int64, _QWORD))a1,
*(_QWORD **)(v2 + 8 * ((unsigned __int64)v3 % *(_QWORD *)(a1 + 32))),
a2) != 0LL;
}

canonical_decompiled_code:
bool __fastcall func13(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
unsigned int v3; // eax

v2 = *(_QWORD *)(a1 + 56);
v3 = (*(__int64 (__fastcall **)(__int64))(a1 + 24))(a2);
return hashtable_find_bucket(
(unsigned __int8 (__fastcall **)(__int64, _QWORD))a1,
*(_QWORD **)(v2 + 8 * ((unsigned __int64)v3 % *(_QWORD *)(a1 + 32))),
a2) != 0LL;
}

original_code:
_Bool
hashtable_key_exists(const HashTable *table, const void *key)
{
 ((void) (0));
 ((void) (0));
 struct _Bucket *head = table->buckets[table->hash(key) % table->size];
 return _hashtable_find_bucket(table, head, key) != ((void *)0);
}

canonical_original_code:
_Bool hashtable_key_exists(struct _HashTable *table, void *key)
{
 ((void) (0));
 ((void) (0));
 struct _Bucket *head = table->buckets[table->hash(key) % table->size];
 return _hashtable_find_bucket(table, head, key) != ((void *)0);
}


decompiled_code:
__int64 __fastcall hashtable_count(__int64 a1)
{
return *(_QWORD *)(a1 + 64);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
return *(_QWORD *)(a1 + 64);
}

original_code:
size_t
hashtable_count(const HashTable *table)
{
 ((void) (0));
 return table->count;
}

canonical_original_code:
unsigned long hashtable_count(struct _HashTable *table)
{
 ((void) (0));
 return table->count;
}


decompiled_code:
__int64 __fastcall hashtable_iter_next(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
char v4; // al

if ( !*(_BYTE *)(a1 + 24) )
{
while ( 1 )
{
v1 = *(_QWORD *)(a1 + 16);
if ( !v1 )
break;
v2 = *(_QWORD *)(v1 + 16);
*(_QWORD *)(a1 + 16) = v2;
if ( v2 )
return 1LL;
}
v4 = hashtable_iter_get_next_bucket((__int64 *)a1);
*(_BYTE *)(a1 + 24) = v4 ^ 1;
if ( v4 )
return 1LL;
}
return 0LL;
}

original_code:
_Bool
hashtable_iter_next(HashTableIter *iter)
{
 ((void) (0));
 _Bool success = 0;
 while(!success && !iter->finished)
 {
  if(iter->liter)
  {
   iter->liter = iter->liter->next;
   success = iter->liter != ((void *)0);
  }
  else
  {
   success = _hashtable_iter_get_next_bucket(iter);
   iter->finished = !success;
  }
 }
 return success;
}

canonical_original_code:
_Bool hashtable_iter_next(struct HashTableIter *iter)
{
 ((void) (0));
 _Bool success = 0;
 while(!success && !iter->finished)
 {
  if(iter->liter)
  {
   iter->liter = iter->liter->next;
   success = iter->liter != ((void *)0);
  }
  else
  {
   success = _hashtable_iter_get_next_bucket(iter);
   iter->finished = !success;
  }
 }
 return success;
}

variable_types: struct HashTableIter { struct _HashTable { _Bool (*compare_keys)(void *a, void *b); void (*free_key)(void *p); void (*free_value)(void *p); unsigned int (*hash)(void *ptr); unsigned long size; unsigned long *sizeptr; _Bool grow; struct _Bucket { void *key; void *data; struct _Bucket *next; } **buckets; unsigned long count; struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } *pool; struct _HashTablePair { void (*free_value)(void *p); struct _Bucket *bucket; } pair; } *table; unsigned long offset; struct _Bucket *liter; _Bool finished; } *

user_defined_types: struct HashTableIter { struct _HashTable *table; unsigned long offset; struct _Bucket *liter; _Bool finished; }


decompiled_code:
__int64 __fastcall hashtable_iter_get_key(__int64 a1)
{
return **(_QWORD **)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
return **(_QWORD **)(a1 + 16);
}

original_code:
void *
hashtable_iter_get_key(const HashTableIter *iter)
{
 ((void) (0));
 return iter->liter->key;
}

canonical_original_code:
void *hashtable_iter_get_key(struct HashTableIter *iter)
{
 ((void) (0));
 return iter->liter->key;
}


decompiled_code:
__int64 __fastcall hashtable_iter_get_value(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL);
}

original_code:
void *
hashtable_iter_get_value(const HashTableIter *iter)
{
 ((void) (0));
 return iter->liter->data;
}

canonical_original_code:
void *hashtable_iter_get_value(struct HashTableIter *iter)
{
 ((void) (0));
 return iter->liter->data;
}


decompiled_code:
__int64 __fastcall str_hash(_BYTE *a1)
{
int v1; // eax
unsigned int i; // er8

v1 = (char)*a1;
for ( i = 0; *a1; v1 = (char)*a1 )
{
++a1;
i = v1 + 65599 * i;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
int v1; // eax
unsigned int i; // er8

v1 = (char)*a1;
for ( i = 0; *a1; v1 = (char)*a1 )
{
++a1;
i = v1 + 65599 * i;
}
return i;
}

original_code:
uint32_t
str_hash(const void *ptr)
{
 ((void) (0));
 const char *plain = ptr;
 uint32_t hash = 0;
 while(*plain)
 {
  hash = *plain++ + (hash << 6) + (hash << 16) - hash;
 }
 return hash;
}

canonical_original_code:
unsigned int str_hash(void *ptr)
{
 ((void) (0));
 char *plain = ptr;
 unsigned int hash = 0;
 while(*plain)
 {
  hash = *plain++ + (hash << 6) + (hash << 16) - hash;
 }
 return hash;
}

variable_types:
plain
char *

variable_types:
hash
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall direct_hash(unsigned __int64 a1)
{
if ( a1 <= 0xFFFFFFFF )
return (unsigned int)a1;
fprintf(stderr, "%s(): integer overflow.\n", "direct_hash");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 a1)
{
if ( a1 <= 0xFFFFFFFF )
return (unsigned int)a1;
fprintf(stderr, "%s(): integer overflow.\n", "direct_hash");
return 0xFFFFFFFFLL;
}

original_code:
uint32_t
direct_hash(const void *ptr)
{
 uintptr_t v = (uintptr_t)ptr;
 if(v > (4294967295U))
 {
  fprintf(stderr, "%s(): integer overflow.\n", __func__);
  v = (4294967295U);
 }
 return (uint32_t)v;
}

canonical_original_code:
unsigned int direct_hash(void *ptr)
{
 unsigned long v = (uintptr_t)ptr;
 if(v > (4294967295U))
 {
  fprintf(stderr, "%s(): integer overflow.\n", __func__);
  v = (4294967295U);
 }
 return (unsigned int)v;
}

variable_types:
v
unsigned long


decompiled_code:
bool __fastcall str_equal(__int64 a1, __int64 a2)
{
__int64 v2; // rax
char v3; // dl
char v4; // cl

v2 = 0LL;
do
{
v3 = *(_BYTE *)(a1 + v2);
v4 = *(_BYTE *)(a2 + v2);
if ( !v3 || !v4 )
return v3 == v4;
++v2;
}
while ( v3 == v4 );
return 0;
}

original_code:
_Bool
str_equal(const void *a, const void *b)
{
 ((void) (0));
 ((void) (0));
 const char *s0 = (const char *)a;
 const char *s1 = (const char *)b;
 while(*s0 && *s1)
 {
  if(*s0++ != *s1++)
  {
   return 0;
  }
 }
 return *s0 == *s1;
}

canonical_original_code:
_Bool str_equal(void *a, void *b)
{
 ((void) (0));
 ((void) (0));
 char *s0 = (const char *)a;
 char *s1 = (const char *)b;
 while(*s0 && *s1)
 {
  if(*s0++ != *s1++)
  {
   return 0;
  }
 }
 return *s0 == *s1;
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
__int64 __fastcall direct_compare(unsigned __int64 a1, unsigned __int64 a2)
{
return (a1 > a2) - (unsigned int)(a1 < a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 a1, unsigned __int64 a2)
{
return (a1 > a2) - (unsigned int)(a1 < a2);
}

original_code:
int32_t
direct_compare(const void *a, const void *b)
{
 ((void) (0));
 ((void) (0));
 return (a > b) - (a < b);
}

canonical_original_code:
int direct_compare(void *a, void *b)
{
 ((void) (0));
 ((void) (0));
 return (a > b) - (a < b);
}


decompiled_code:
bool __fastcall direct_equal(__int64 a1, __int64 a2)
{
return a2 == a1;
}

canonical_decompiled_code:
bool __fastcall func2(__int64 a1, __int64 a2)
{
return a2 == a1;
}

original_code:
_Bool
direct_equal(const void *a, const void *b)
{
 ((void) (0));
 ((void) (0));
 return a == b;
}

canonical_original_code:
_Bool direct_equal(void *a, void *b)
{
 ((void) (0));
 ((void) (0));
 return a == b;
}


decompiled_code:
void *__fastcall buffer_init(__int64 a1, __int64 a2)
{
void *result; // rax

*(_QWORD *)(a1 + 32) = 0LL;
*(_OWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 24) = 64LL;
*(_BYTE *)(a1 + 32) = 1;
result = malloc(0x40uLL);
*(_QWORD *)a1 = result;
if ( !result )
{
perror("malloc()");
abort();
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, __int64 a2)
{
void *result; // rax

*(_QWORD *)(a1 + 32) = 0LL;
*(_OWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 8) = a2;
*(_QWORD *)(a1 + 24) = 64LL;
*(_BYTE *)(a1 + 32) = 1;
result = malloc(0x40uLL);
*(_QWORD *)a1 = result;
if ( !result )
{
perror("malloc()");
abort();
}
return result;
}

original_code:
void
buffer_init(Buffer *buf, size_t max_size)
{
 ((void) (0));
 ((void) (0));
 memset(buf, 0, sizeof(Buffer));
 buf->max_size = max_size;
 buf->msize = 64;
 buf->valid = 1;
 buf->data = (char *)malloc(buf->msize);
 if(!buf->data)
 {
  perror("malloc()");
  abort();
 }
}

canonical_original_code:
void buffer_init(struct Buffer *buf, unsigned long max_size)
{
 ((void) (0));
 ((void) (0));
 memset(buf, 0, sizeof(Buffer));
 buf->max_size = max_size;
 buf->msize = 64;
 buf->valid = 1;
 buf->data = (char *)malloc(buf->msize);
 if(!buf->data)
 {
  perror("malloc()");
  abort();
 }
}

variable_types: struct Buffer { char *data; unsigned long max_size; unsigned long len; unsigned long msize; _Bool valid; } *


decompiled_code:
void __fastcall buffer_free(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func4(void **a1)
{
free(*a1);
}

original_code:
void
buffer_free(Buffer *buf)
{
 ((void) (0));
 free(buf->data);
}

canonical_original_code:
void buffer_free(struct Buffer *buf)
{
 ((void) (0));
 free(buf->data);
}

user_defined_types: struct Buffer { char *data; unsigned long max_size; unsigned long len; unsigned long msize; _Bool valid; }


decompiled_code:
void __fastcall buffer_destroy(void *ptr)
{
buffer_free((void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func5(void *ptr)
{
func4((void **)ptr);
free(ptr);
}

original_code:
void
buffer_destroy(Buffer *buf)
{
 ((void) (0));
 buffer_free(buf);
 free(buf);
}

canonical_original_code:
void buffer_destroy(struct Buffer *buf)
{
 ((void) (0));
 buffer_free(buf);
 free(buf);
}


decompiled_code:
void __fastcall buffer_clear(__int64 a1)
{
*(_QWORD *)(a1 + 16) = 0LL;
*(_BYTE *)(a1 + 32) = 1;
}

original_code:
void
buffer_clear(Buffer *buf)
{
 ((void) (0));
 buf->len = 0;
 buf->valid = 1;
}

canonical_original_code:
void buffer_clear(struct Buffer *buf)
{
 ((void) (0));
 buf->len = 0;
 buf->valid = 1;
}


decompiled_code:
__int64 __fastcall buffer_is_valid(__int64 a1)
{
return *(unsigned __int8 *)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(unsigned __int8 *)(a1 + 32);
}

original_code:
_Bool
buffer_is_valid(const Buffer *buf)
{
 ((void) (0));
 return buf->valid;
}

canonical_original_code:
_Bool buffer_is_valid(struct Buffer *buf)
{
 ((void) (0));
 return buf->valid;
}


decompiled_code:
__int64 __fastcall buffer_len(__int64 a1)
{
char v1; // r8
__int64 result; // rax

v1 = buffer_is_valid(a1);
result = 0LL;
if ( v1 )
result = *(_QWORD *)(a1 + 16);
return result;
}

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

v1 = func7(a1);
result = 0LL;
if ( v1 )
result = *(_QWORD *)(a1 + 16);
return result;
}

original_code:
size_t
buffer_len(const Buffer *buf)
{
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 return buf->len;
}

canonical_original_code:
unsigned long buffer_len(struct Buffer *buf)
{
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 return buf->len;
}


decompiled_code:
char __fastcall buffer_is_empty(__int64 a1)
{
char result; // al

result = buffer_is_valid(a1);
if ( result )
result = *(_QWORD *)(a1 + 16) == 0LL;
return result;
}

canonical_decompiled_code:
char __fastcall func9(__int64 a1)
{
char result; // al

result = func7(a1);
if ( result )
result = *(_QWORD *)(a1 + 16) == 0LL;
return result;
}

original_code:
_Bool
buffer_is_empty(const Buffer *buf)
{
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 return buf->len == 0;
}

canonical_original_code:
_Bool buffer_is_empty(struct Buffer *buf)
{
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 return buf->len == 0;
}


decompiled_code:
__int64 __fastcall buffer_fill(__int64 a1, const void *a2, size_t a3)
{
__int64 result; // rax
__int64 v6; // rdi
unsigned __int64 v7; // rax
char *v8; // rdi
char *v9; // rax

result = buffer_is_valid(a1);
if ( (_BYTE)result )
{
v6 = *(_QWORD *)(a1 + 16);
if ( *(_QWORD *)(a1 + 8) - v6 < a3 )
{
fprintf(stderr, "%s(): buffer exceeds allowed maximum size.\n", "buffer_fill");
*(_BYTE *)(a1 + 32) = 0;
result = 0LL;
}
else
{
if ( *(_QWORD *)(a1 + 24) - v6 >= a3 )
{
v9 = *(char **)a1;
}
else
{
v7 = buffer_new_realloc_size(*(_QWORD *)(a1 + 24), *(_QWORD *)(a1 + 24) + a3);
v8 = *(char **)a1;
*(_QWORD *)(a1 + 24) = v7;
v9 = (char *)realloc(v8, v7);
*(_QWORD *)a1 = v9;
if ( !v9 )
{
perror("realloc()");
abort();
}
v6 = *(_QWORD *)(a1 + 16);
}
memcpy(&v9[v6], a2, a3);
*(_QWORD *)(a1 + 16) += a3;
result = *(unsigned __int8 *)(a1 + 32);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, const void *a2, size_t a3)
{
__int64 result; // rax
__int64 v6; // rdi
unsigned __int64 v7; // rax
char *v8; // rdi
char *v9; // rax

result = func7(a1);
if ( (_BYTE)result )
{
v6 = *(_QWORD *)(a1 + 16);
if ( *(_QWORD *)(a1 + 8) - v6 < a3 )
{
fprintf(stderr, "%s(): buffer exceeds allowed maximum size.\n", "buffer_fill");
*(_BYTE *)(a1 + 32) = 0;
result = 0LL;
}
else
{
if ( *(_QWORD *)(a1 + 24) - v6 >= a3 )
{
v9 = *(char **)a1;
}
else
{
v7 = func0(*(_QWORD *)(a1 + 24), *(_QWORD *)(a1 + 24) + a3);
v8 = *(char **)a1;
*(_QWORD *)(a1 + 24) = v7;
v9 = (char *)realloc(v8, v7);
*(_QWORD *)a1 = v9;
if ( !v9 )
{
perror("realloc()");
abort();
}
v6 = *(_QWORD *)(a1 + 16);
}
memcpy(&v9[v6], a2, a3);
*(_QWORD *)(a1 + 16) += a3;
result = *(unsigned __int8 *)(a1 + 32);
}
}
return result;
}

original_code:
_Bool
buffer_fill(Buffer *buf, const char *data, size_t len)
{
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 if(buf->max_size - buf->len < len)
 {
  fprintf(stderr, "%s(): buffer exceeds allowed maximum size.\n", __func__);
  buf->valid = 0;
 }
 else
 {
  if(len > buf->msize - buf->len)
  {
   size_t new_size = _buffer_new_realloc_size(buf->msize, buf->msize + len);
   buf->msize = new_size;
   buf->data = (char *)realloc(buf->data, new_size);
   if(!buf->data)
   {
    perror("realloc()");
    abort();
   }
  }
  memcpy(buf->data + buf->len, data, len);
  buf->len += len;
 }
 return buf->valid;
}

canonical_original_code:
_Bool buffer_fill(struct Buffer *buf, char *data, unsigned long len)
{
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 if(buf->max_size - buf->len < len)
 {
  fprintf(stderr, "%s(): buffer exceeds allowed maximum size.\n", __func__);
  buf->valid = 0;
 }
 else
 {
  if(len > buf->msize - buf->len)
  {
   unsigned long new_size = _buffer_new_realloc_size(buf->msize, buf->msize + len);
   buf->msize = new_size;
   buf->data = (char *)realloc(buf->data, new_size);
   if(!buf->data)
   {
    perror("realloc()");
    abort();
   }
  }
  memcpy(buf->data + buf->len, data, len);
  buf->len += len;
 }
 return buf->valid;
}

variable_types:
data
char *

variable_types:
len
unsigned long


decompiled_code:
__int64 __fastcall buffer_fill_from_fd(__int64 a1, int a2, size_t a3)
{
__int64 v4; // r12
void *v6; // rsp
signed __int64 v7; // rax
_BYTE v8[32]; // [rsp+0h] [rbp-20h] BYREF

v4 = 0LL;
if ( (unsigned __int8)buffer_is_valid(a1) )
{
v6 = alloca(a3);
v7 = read(a2, v8, a3);
v4 = v7;
if ( v7 > 0 )
{
if ( !(unsigned __int8)buffer_fill(a1, v8, v7) )
v4 = -1LL;
}
else if ( v7 == -1 )
{
perror("read()");
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2, size_t a3)
{
__int64 v4; // r12
void *v6; // rsp
signed __int64 v7; // rax
_BYTE v8[32]; // [rsp+0h] [rbp-20h] BYREF

v4 = 0LL;
if ( (unsigned __int8)func7(a1) )
{
v6 = alloca(a3);
v7 = read(a2, v8, a3);
v4 = v7;
if ( v7 > 0 )
{
if ( !(unsigned __int8)func10(a1, v8, v7) )
v4 = -1LL;
}
else if ( v7 == -1 )
{
perror("read()");
}
}
return v4;
}

original_code:
ssize_t
buffer_fill_from_fd(Buffer *buf, int fd, size_t count)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 ssize_t bytes;
 char data[count];
 if((bytes = read(fd, data, count)) > 0)
 {
  if(!buffer_fill(buf, data, bytes))
  {
   bytes = -1;
  }
 }
 else if(bytes == -1)
 {
  perror("read()");
 }
 return bytes;
}

canonical_original_code:
long buffer_fill_from_fd(struct Buffer *buf, int fd, unsigned long count)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 long bytes;
 char data[-1];
 if((bytes = read(fd, data, count)) > 0)
 {
  if(!buffer_fill(buf, data, bytes))
  {
   bytes = -1;
  }
 }
 else if(bytes == -1)
 {
  perror("read()");
 }
 return bytes;
}

variable_types: fd int

variable_types:
count
unsigned long

variable_types: bytes long

variable_types:
data
char [-1]

return_type: long


decompiled_code:
__int64 __fastcall buffer_read_line(__int64 a1, void **a2, size_t *a3)
{
unsigned int v5; // er12
_BYTE *v6; // r15
_BYTE *v7; // rax
_BYTE *v8; // rbp
void *v9; // rdi
size_t v10; // rdx
signed __int64 v12; // [rsp+8h] [rbp-40h]

v5 = buffer_is_valid(a1);
if ( (_BYTE)v5 )
{
v6 = *(_BYTE **)a1;
v7 = memchr(*(const void **)a1, 10, *(_QWORD *)(a1 + 16));
v8 = v7;
if ( v7 )
{
v12 = v7 - v6;
buffer_copy_to_string((const void **)a1, v7 - v6, a2, a3);
v9 = *(void **)a1;
v10 = ~v12 + *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = v10;
memmove(v9, v8 + 1, v10);
}
else
{
v5 = 0;
}
}
return v5;
}

original_code:
_Bool
buffer_read_line(Buffer *buf, char **dst, size_t *len)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 char *ptr;
 _Bool found = 0;
 if((ptr = memchr(buf->data, '\n', buf->len)))
 {
  size_t slen = ptr - buf->data;
  _buffer_copy_to_string(buf, slen, dst, len);
  buf->len -= slen + 1;
  memmove(buf->data, ptr + 1, buf->len);
  found = 1;
 }
 return found;
}

canonical_original_code:
_Bool buffer_read_line(struct Buffer *buf, char **dst, unsigned long *len)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 char *ptr;
 _Bool found = 0;
 if((ptr = memchr(buf->data, '\n', buf->len)))
 {
  unsigned long slen = ptr - buf->data;
  _buffer_copy_to_string(buf, slen, dst, len);
  buf->len -= slen + 1;
  memmove(buf->data, ptr + 1, buf->len);
  found = 1;
 }
 return found;
}

variable_types:
dst
char **

variable_types:
len
unsigned long *

variable_types:
ptr
char *

variable_types:
slen
unsigned long


decompiled_code:
__int64 __fastcall buffer_flush(__int64 a1, void **a2, size_t *a3)
{
__int64 result; // rax
size_t v6; // rsi
unsigned __int8 v7; // [rsp+Fh] [rbp-19h]

result = buffer_is_valid(a1);
if ( (_BYTE)result )
{
v6 = *(_QWORD *)(a1 + 16);
if ( v6 )
{
v7 = result;
buffer_copy_to_string((const void **)a1, v6, a2, a3);
result = v7;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, void **a2, size_t *a3)
{
__int64 result; // rax
size_t v6; // rsi
unsigned __int8 v7; // [rsp+Fh] [rbp-19h]

result = func7(a1);
if ( (_BYTE)result )
{
v6 = *(_QWORD *)(a1 + 16);
if ( v6 )
{
v7 = result;
func1((const void **)a1, v6, a2, a3);
result = v7;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
_Bool
buffer_flush(const Buffer *buf, char **dst, size_t *len)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 _Bool flushed = 0;
 if(buf->len)
 {
  _buffer_copy_to_string(buf, buf->len, dst, len);
  flushed = 1;
 }
 return flushed;
}

canonical_original_code:
_Bool buffer_flush(struct Buffer *buf, char **dst, unsigned long *len)
{
 ((void) (0));
 ((void) (0));
 ((void) (0));
 if(!buffer_is_valid(buf)) return 0;
 _Bool flushed = 0;
 if(buf->len)
 {
  _buffer_copy_to_string(buf, buf->len, dst, len);
  flushed = 1;
 }
 return flushed;
}


decompiled_code:
void __fastcall memory_pool_destroy(void *ptr)
{
__int64 v1; // rbx
void **v2; // rbp
__int64 v3; // rbx
void **v4; // rbp

v1 = *((_QWORD *)ptr + 2);
while ( v1 )
{
v2 = (void **)v1;
v1 = *(_QWORD *)(v1 + 16);
free(*v2);
free(v2);
}
v3 = *((_QWORD *)ptr + 3);
while ( v3 )
{
v4 = (void **)v3;
v3 = *(_QWORD *)(v3 + 16);
free(*v4);
free(v4);
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
__int64 v1; // rbx
void **v2; // rbp
__int64 v3; // rbx
void **v4; // rbp

v1 = *((_QWORD *)ptr + 2);
while ( v1 )
{
v2 = (void **)v1;
v1 = *(_QWORD *)(v1 + 16);
free(*v2);
free(v2);
}
v3 = *((_QWORD *)ptr + 3);
while ( v3 )
{
v4 = (void **)v3;
v3 = *(_QWORD *)(v3 + 16);
free(*v4);
free(v4);
}
free(ptr);
}

original_code:
void
memory_pool_destroy(MemoryPool *pool)
{
 struct _MemoryBlock *iter;
 struct _MemoryPtrBlock *piter;
 ((void) (0));
 iter = pool->block;
 while(iter)
 {
  struct _MemoryBlock *block;
  block = iter;
  iter = iter->next;
  free(block->items);
  free(block);
 }
 piter = pool->free_block;
 while(piter)
 {
  struct _MemoryPtrBlock *pblock;
  pblock = piter;
  piter = piter->next;
  free(pblock->items);
  free(pblock);
 }
 free(pool);
}

canonical_original_code:
void memory_pool_destroy(struct MemoryPool *pool)
{
 struct _MemoryBlock *iter;
 struct _MemoryPtrBlock *piter;
 ((void) (0));
 iter = pool->block;
 while(iter)
 {
  struct _MemoryBlock *block;
  block = iter;
  iter = iter->next;
  free(block->items);
  free(block);
 }
 piter = pool->free_block;
 while(piter)
 {
  struct _MemoryPtrBlock *pblock;
  pblock = piter;
  piter = piter->next;
  free(pblock->items);
  free(pblock);
 }
 free(pool);
}

variable_types: struct MemoryPool { struct _Pool { void *(*alloc)(struct _Pool *pool); void (*free)(struct _Pool *pool, void *ptr); } padding; struct _MemoryBlock { char *items; unsigned long offset; struct _MemoryBlock *next; } *block; struct _MemoryPtrBlock { void **items; unsigned long offset; struct _MemoryPtrBlock *next; } *free_block; unsigned long block_size; unsigned long item_size; } *


waz

decompiled_code:
__int64 __fastcall waz(const char *a1)
{
unsigned int v1; // er8
bool v2; // zf

v1 = 3;
v2 = strcmp(a1, "LOOKUP") == 0;
if ( strcmp(a1, "UPDATE") )
v1 = v2;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
unsigned int v1; // er8
bool v2; // zf

v1 = 3;
v2 = strcmp(a1, "LOOKUP") == 0;
if ( strcmp(a1, "UPDATE") )
v1 = v2;
return v1;
}

original_code:
int
waz(char *up) {
 int upbit;
 upbit = NONE;
 upbit = (strcmp(up , "LOOKUP")) ? upbit : LOOKUP;
 upbit = (strcmp(up , "UPDATE")) ? upbit : UPDATE;
 return upbit;
}

variable_types:
up
char *

variable_types: upbit int


decompiled_code:
char *__fastcall mk_btreel(char *dest, char *src, int a3, const char *a4, const char *a5, const char *a6)
{
Dlog("mk_btreel");
if ( a3 == 1 )
{
*(_WORD *)dest = 49;
}
else if ( a3 == 3 )
{
*(_WORD *)dest = 51;
}
strcat(dest, src);
strcat(dest, a4);
strcat(dest, src);
strcat(dest, a5);
strcat(dest, src);
return strcat(dest, a6);
}

canonical_decompiled_code:
char *__fastcall func1(char *dest, char *src, int a3, const char *a4, const char *a5, const char *a6)
{
Dlog("mk_btreel");
if ( a3 == 1 )
{
*(_WORD *)dest = 49;
}
else if ( a3 == 3 )
{
*(_WORD *)dest = 51;
}
strcat(dest, src);
strcat(dest, a4);
strcat(dest, src);
strcat(dest, a5);
strcat(dest, src);
return strcat(dest, a6);
}

original_code:
char *
mk_btreel(char *l, char *delim, int op, char *phon, char *name, char *last) {
 Dlog("mk_btreel");
 switch (op) {
  case LOOKUP:
   l = strcpy(l, "1");
   break;
  case UPDATE:
   l = strcpy(l, "3");
   break;
  default:
   break;
 }
 l = strcat(l, delim);
 l = strcat(l, phon);
 l = strcat(l, delim);
 l = strcat(l, name);
 l = strcat(l, delim);
 l = strcat(l, last);
 return l;
}

canonical_original_code:
char *mk_btreel(char *l, char *delim, int op, char *phon, char *name, char *last) {
 Dlog("mk_btreel");
 switch (op) {
  case LOOKUP:
   l = strcpy(l, "1");
   break;
  case UPDATE:
   l = strcpy(l, "3");
   break;
  default:
   break;
 }
 l = strcat(l, delim);
 l = strcat(l, phon);
 l = strcat(l, delim);
 l = strcat(l, name);
 l = strcat(l, delim);
 l = strcat(l, last);
 return l;
}

variable_types:
l
char *

variable_types:
delim
char *

variable_types: op int

variable_types:
phon
char *

variable_types:
name
char *

variable_types:
last
char *