initMsQ

decompiled_code:
__int64 initMsQ()
{
FILE *v0; // rax
key_t v1; // edi
unsigned int v2; // edx
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax
int *v10; // rax
char *v11; // rax

v0 = fopen("/tmp/synchronator.msq", "w");
if ( v0 )
{
fclose(v0);
if ( chmod("/tmp/synchronator.msq", 0x192u) == -1 )
{
v4 = _errno_location();
v5 = strerror(*v4);
syslog(3, "Failed to set permissions message queue location: %s", v5);
v2 = 1;
}
else
{
v1 = ftok("/tmp/synchronator.msq", 66);
if ( v1 == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
syslog(3, "Failed to generate token: %s", v9);
v2 = 1;
}
else
{
msq_id = msgget(v1, 950);
v2 = 0;
if ( msq_id == -1 )
{
v10 = _errno_location();
v11 = strerror(*v10);
syslog(3, "Failed to create message queue: %s", v11);
v2 = 1;
}
}
}
}
else
{
v6 = _errno_location();
v7 = strerror(*v6);
syslog(3, "Failed to create message queue location: %s", v7);
v2 = 1;
}
return v2;
}

canonical_decompiled_code:
__int64 func0()
{
FILE *v0; // rax
key_t v1; // edi
unsigned int v2; // edx
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax
int *v10; // rax
char *v11; // rax

v0 = fopen("/tmp/synchronator.msq", "w");
if ( v0 )
{
fclose(v0);
if ( chmod("/tmp/synchronator.msq", 0x192u) == -1 )
{
v4 = _errno_location();
v5 = strerror(*v4);
syslog(3, "Failed to set permissions message queue location: %s", v5);
v2 = 1;
}
else
{
v1 = ftok("/tmp/synchronator.msq", 66);
if ( v1 == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
syslog(3, "Failed to generate token: %s", v9);
v2 = 1;
}
else
{
msq_id = msgget(v1, 950);
v2 = 0;
if ( msq_id == -1 )
{
v10 = _errno_location();
v11 = strerror(*v10);
syslog(3, "Failed to create message queue: %s", v11);
v2 = 1;
}
}
}
}
else
{
v6 = _errno_location();
v7 = strerror(*v6);
syslog(3, "Failed to create message queue location: %s", v7);
v2 = 1;
}
return v2;
}

original_code:
int initMsQ(void) {
    key_t msq_key;
    if((msq_file = fopen("/tmp/" "synchronator" ".msq","w")) != ((void *)0)) {
        fclose(msq_file);
        if(-1 == chmod("/tmp/" "synchronator" ".msq", 0200 | 0400 | (0200 >> 3) | ((0200 >> 3) >> 3))) {
            syslog(3, "Failed to set permissions message queue location: %s", strerror((*__errno_location ())));
            return 1;
        }
    }
    else {
        syslog(3, "Failed to create message queue location: %s", strerror((*__errno_location ())));
        return 1;
    }
    if((msq_key = ftok("/tmp/" "synchronator" ".msq", 'B')) == -1) {
        syslog(3, "Failed to generate token: %s", strerror((*__errno_location ())));
        return 1;
    }
    if((msq_id = msgget(msq_key, 0666 | 01000)) == -1) {
        syslog(3, "Failed to create message queue: %s", strerror((*__errno_location ())));
        return 1;
    }
    return 0;
}

canonical_original_code:
int initMsQ() {
    int msq_key;
    if((msq_file = fopen("/tmp/" "synchronator" ".msq","w")) != ((void *)0)) {
        fclose(msq_file);
        if(-1 == chmod("/tmp/" "synchronator" ".msq", 0200 | 0400 | (0200 >> 3) | ((0200 >> 3) >> 3))) {
            syslog(3, "Failed to set permissions message queue location: %s", strerror((*__errno_location ())));
            return 1;
        }
    }
    else {
        syslog(3, "Failed to create message queue location: %s", strerror((*__errno_location ())));
        return 1;
    }
    if((msq_key = ftok("/tmp/" "synchronator" ".msq", 'B')) == -1) {
        syslog(3, "Failed to generate token: %s", strerror((*__errno_location ())));
        return 1;
    }
    if((msq_id = msgget(msq_key, 0666 | 01000)) == -1) {
        syslog(3, "Failed to create message queue: %s", strerror((*__errno_location ())));
        return 1;
    }
    return 0;
}


deinitMsQ

repo: therealmuffin/synchronator

decompiled_code:
void deinitMsQ()
{
int *v0; // rax
char *v1; // rax
int *v2; // rax
char *v3; // rax

if ( msq_id >= 0 )
{
if ( msgctl(msq_id, 0, 0LL) == -1 )
{
v0 = _errno_location();
v1 = strerror(*v0);
syslog(4, "Unable to remove message queue: %s", v1);
}
if ( remove("/tmp/synchronator.msq") == -1 )
{
v2 = _errno_location();
v3 = strerror(*v2);
syslog(4, "Unable to delete message queue location: %s", v3);
}
}
}

canonical_decompiled_code:
void func2()
{
int *v0; // rax
char *v1; // rax
int *v2; // rax
char *v3; // rax

if ( msq_id >= 0 )
{
if ( msgctl(msq_id, 0, 0LL) == -1 )
{
v0 = _errno_location();
v1 = strerror(*v0);
syslog(4, "Unable to remove message queue: %s", v1);
}
if ( remove("/tmp/synchronator.msq") == -1 )
{
v2 = _errno_location();
v3 = strerror(*v2);
syslog(4, "Unable to delete message queue location: %s", v3);
}
}
}

original_code:
void deinitMsQ(void) {
    if(msq_id >= 0) {
        if(msgctl(msq_id, 0, ((void *)0)) == -1)
            syslog(4, "Unable to remove message queue: %s", strerror((*__errno_location ())));
        if(remove("/tmp/" "synchronator" ".msq") == -1)
            syslog(4, "Unable to delete message queue location: %s", strerror((*__errno_location ())));
    }
}

canonical_original_code:
void deinitMsQ() {
    if(msq_id >= 0) {
        if(msgctl(msq_id, 0, ((void *)0)) == -1)
            syslog(4, "Unable to remove message queue: %s", strerror((*__errno_location ())));
        if(remove("/tmp/" "synchronator" ".msq") == -1)
            syslog(4, "Unable to delete message queue location: %s", strerror((*__errno_location ())));
    }
}

return_type: void


decompiled_code:
void __fastcall convertInternal2External(_QWORD *a1, double *a2)
{
*a2 = (double)(int)*a1 * *(double *)&multiplierIntToExt + (double)common_data[6];
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1, double *a2)
{
*a2 = (double)(int)*a1 * *(double *)&multiplierIntToExt + (double)common_data[6];
}

original_code:
static void convertInternal2External(long *volumeInternal, double *volumeExternal) {
    *volumeExternal = (*volumeInternal * multiplierIntToExt) + common_data.volume_min;
}

variable_types:
volumeInternal
long *

variable_types:
volumeExternal
double *


getMixer

decompiled_code:
__int64 __fastcall getMixer(__int64 *a1)
{
const char *v2; // rax

if ( volumeNormalized )
{
*a1 = (unsigned int)(int)(get_normalized_playback_volume(snd_elem, 0LL) * 100.0);
LABEL_3:
(*(void (__fastcall **)(__int64 *))(common_data[18] + 48LL))(a1);
return 0LL;
}
if ( (int)snd_mixer_selem_get_playback_volume(snd_elem, 0LL, a1) >= 0 )
{
*a1 = 100 * (*a1 - common_data[5]) / common_data[7];
goto LABEL_3;
}
v2 = (const char *)snd_strerror(4294967294LL);
syslog(3, "Failed to get playback volume: %s (%i)", v2, 4294967294LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1)
{
const char *v2; // rax

if ( volumeNormalized )
{
*a1 = (unsigned int)(int)(get_normalized_playback_volume(snd_elem, 0LL) * 100.0);
LABEL_3:
(*(void (__fastcall **)(__int64 *))(common_data[18] + 48LL))(a1);
return 0LL;
}
if ( (int)snd_mixer_selem_get_playback_volume(snd_elem, 0LL, a1) >= 0 )
{
*a1 = 100 * (*a1 - common_data[5]) / common_data[7];
goto LABEL_3;
}
v2 = (const char *)snd_strerror(4294967294LL);
syslog(3, "Failed to get playback volume: %s (%i)", v2, 4294967294LL);
return 1LL;
}

original_code:
int getMixer(long *volume) {
    int status = -2;
    if(volumeNormalized) {
        *volume = 100 * get_normalized_playback_volume(snd_elem, 0);
    }
    else {
        if((snd_mixer_selem_get_playback_volume(snd_elem, 0, volume)) < 0) {
            syslog(3, "Failed to get playback volume: %s (%i)",
                snd_strerror(status), status);
            return 1;
        }
        *volume = 100 * (*volume - common_data.alsa_volume_min) / common_data.alsa_volume_range;
    }
    common_data.volume->convertMixer2Internal(volume);
    return 0;
}

variable_types:
volume
long *

variable_types: status int

return_type: int


setMixer

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

if ( volumeNormalized )
{
result = set_normalized_playback_volume(snd_elem, 0xFFFFFFFFLL, (double)a1 * 0.01);
if ( !(_DWORD)result )
return result;
LABEL_6:
syslog(4, "Setting mixer failed");
return 1LL;
}
result = snd_mixer_selem_set_playback_volume_all(snd_elem, a1);
if ( (_DWORD)result )
goto LABEL_6;
return result;
}

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

if ( volumeNormalized )
{
result = set_normalized_playback_volume(snd_elem, 0xFFFFFFFFLL, (double)a1 * 0.01);
if ( !(_DWORD)result )
return result;
LABEL_6:
syslog(4, "Setting mixer failed");
return 1LL;
}
result = snd_mixer_selem_set_playback_volume_all(snd_elem, a1);
if ( (_DWORD)result )
goto LABEL_6;
return result;
}

original_code:
int setMixer(int volume) {
    if(volumeNormalized) {
        if((set_normalized_playback_volume(snd_elem, 0.01 * volume, -1)) != 0) {
            syslog(4, "Setting mixer failed");
            return 1;
            syslog(3, "Volume (%i)", volume);
        }
    }
    else {
        if((snd_mixer_selem_set_playback_volume_all(snd_elem, volume)) != 0) {
            syslog(4, "Setting mixer failed");
            return 1;
        }
    }
    return 0;
}

variable_types: volume int


watchMixer

decompiled_code:
void __fastcall __noreturn watchMixer(__sigset_t *newmask)
{
int v1; // eax
unsigned int v2; // ebx
__int64 v3; // rbx
int *v4; // rax
const char *v5; // rax
__int64 v6[2]; // [rsp+8h] [rbp-10h] BYREF

if ( pthread_sigmask(0, newmask, 0LL) < 0 )
{
v4 = _errno_location();
syslog(3, "Failed to ignore signals in watchMixer: %i", (unsigned int)*v4);
pthread_kill(mainThread, 15);
pause();
}
v6[0] = -1LL;
if ( LODWORD(common_data[0]) || !HIDWORD(common_data[0]) )
goto LABEL_5;
if ( (unsigned int)getMixer(v6) == 1 )
{
pthread_kill(mainThread, 15);
pause();
}
if ( (*(unsigned int (__fastcall **)(__int64 *))(common_data[16] + 32LL))(v6) != 1 )
goto LABEL_5;
while ( 1 )
{
pthread_kill(mainThread, 15);
pause();
do
{
LABEL_5:
v1 = snd_mixer_wait(snd_handle, 0xFFFFFFFFLL);
v2 = v1;
if ( v1 < 0 )
{
v5 = (const char *)snd_strerror((unsigned int)v1);
syslog(3, "Failed waiting for mixer event: %s (%i)", v5, v2);
pthread_kill(mainThread, 15);
pause();
}
snd_mixer_handle_events(snd_handle);
v3 = v6[0];
if ( (unsigned int)getMixer(v6) == 1 )
{
pthread_kill(mainThread, 15);
pause();
}
}
while ( v6[0] == v3 || (*(unsigned int (__fastcall **)(__int64 *))(common_data[16] + 32LL))(v6) != 1 );
}
}

canonical_decompiled_code:
void __fastcall __noreturn func4(__sigset_t *newmask)
{
int v1; // eax
unsigned int v2; // ebx
__int64 v3; // rbx
int *v4; // rax
const char *v5; // rax
__int64 v6[2]; // [rsp+8h] [rbp-10h] BYREF

if ( pthread_sigmask(0, newmask, 0LL) < 0 )
{
v4 = _errno_location();
syslog(3, "Failed to ignore signals in watchMixer: %i", (unsigned int)*v4);
pthread_kill(mainThread, 15);
pause();
}
v6[0] = -1LL;
if ( LODWORD(common_data[0]) || !HIDWORD(common_data[0]) )
goto LABEL_5;
if ( (unsigned int)func1(v6) == 1 )
{
pthread_kill(mainThread, 15);
pause();
}
if ( (*(unsigned int (__fastcall **)(__int64 *))(common_data[16] + 32LL))(v6) != 1 )
goto LABEL_5;
while ( 1 )
{
pthread_kill(mainThread, 15);
pause();
do
{
LABEL_5:
v1 = snd_mixer_wait(snd_handle, 0xFFFFFFFFLL);
v2 = v1;
if ( v1 < 0 )
{
v5 = (const char *)snd_strerror((unsigned int)v1);
syslog(3, "Failed waiting for mixer event: %s (%i)", v5, v2);
pthread_kill(mainThread, 15);
pause();
}
snd_mixer_handle_events(snd_handle);
v3 = v6[0];
if ( (unsigned int)func1(v6) == 1 )
{
pthread_kill(mainThread, 15);
pause();
}
}
while ( v6[0] == v3 || (*(unsigned int (__fastcall **)(__int64 *))(common_data[16] + 32LL))(v6) != 1 );
}
}

original_code:
void *watchMixer(void *arg) {
    sigset_t *thread_sigmask = (sigset_t *)arg;
    if(pthread_sigmask(0, thread_sigmask, ((void *)0)) < 0) {
        syslog(3, "Failed to ignore signals in watchMixer: %i", (*__errno_location ()));
        pthread_kill(mainThread, 15);
        pause();
    }
    long volume = -1;
    long volume_old = -1;
    int status = -2;
    int events = -1;
    if(!common_data.sync_2way && common_data.discrete_volume) {
        if(getMixer(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
        if(common_data.process->compileVolumeCommand(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
    }
    while(1) {
        if((status = snd_mixer_wait(snd_handle, -1)) < 0) {
            syslog(3, "Failed waiting for mixer event: %s (%i)",
                snd_strerror(status), status);
            pthread_kill(mainThread, 15);
            pause();
        }
        events = snd_mixer_handle_events(snd_handle);
        volume_old = volume;
        if(getMixer(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
        if(volume == volume_old)
            continue;
        if(common_data.process->compileVolumeCommand(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
        }
    pthread_kill(mainThread, 15);
    pause();
}

canonical_original_code:
void *watchMixer(void *arg) {
    struct __sigset_t *thread_sigmask = (sigset_t *)arg;
    if(pthread_sigmask(0, thread_sigmask, ((void *)0)) < 0) {
        syslog(3, "Failed to ignore signals in watchMixer: %i", (*__errno_location ()));
        pthread_kill(mainThread, 15);
        pause();
    }
    long volume = -1;
    long volume_old = -1;
    int status = -2;
    int events = -1;
    if(!common_data.sync_2way && common_data.discrete_volume) {
        if(getMixer(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
        if(common_data.process->compileVolumeCommand(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
    }
    while(1) {
        if((status = snd_mixer_wait(snd_handle, -1)) < 0) {
            syslog(3, "Failed waiting for mixer event: %s (%i)",
                snd_strerror(status), status);
            pthread_kill(mainThread, 15);
            pause();
        }
        events = snd_mixer_handle_events(snd_handle);
        volume_old = volume;
        if(getMixer(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
        if(volume == volume_old)
            continue;
        if(common_data.process->compileVolumeCommand(&volume) == 1) {
            pthread_kill(mainThread, 15);
            pause();
        }
        }
    pthread_kill(mainThread, 15);
    pause();
}

variable_types:
arg
void *

variable_types: struct __sigset_t { unsigned long __val[-1]; } *

variable_types: volume long

variable_types: events int

return_type: void *


deinitMixer

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

if ( snd_handle )
result = snd_mixer_close();
return result;
}

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

if ( snd_handle )
result = snd_mixer_close();
return result;
}

original_code:
void deinitMixer(void) {
    if(snd_handle != ((void *)0))
        snd_mixer_close(snd_handle);
}

canonical_original_code:
void deinitMixer() {
    if(snd_handle != ((void *)0))
        snd_mixer_close(snd_handle);
}


reinit

decompiled_code:
__int64 reinit()
{
int v0; // eax
double v2[2]; // [rsp+0h] [rbp-10h] BYREF

v0 = common_data[21];
if ( v0 >= SLODWORD(common_data[4]) )
{
v2[0] = (double)v0;
(*(void (__fastcall **)(double *))(common_data[18] + 40LL))(v2);
setMixer((int)v2[0]);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // eax
double v2[2]; // [rsp+0h] [rbp-10h] BYREF

v0 = common_data[21];
if ( v0 >= SLODWORD(common_data[4]) )
{
v2[0] = (double)v0;
(*(void (__fastcall **)(double *))(common_data[18] + 40LL))(v2);
func2((int)v2[0]);
}
return 0LL;
}

original_code:
static int reinit(void) {
    if(common_data.defaultExternalVolume < common_data.initial_volume_min)
        return 0;
    double defaultVolume = common_data.defaultExternalVolume;
    common_data.volume->convertExternal2Mixer(&defaultVolume);
    setMixer((int)defaultVolume);
    return 0;
}

canonical_original_code:
static int reinit() {
    if(common_data.defaultExternalVolume < common_data.initial_volume_min)
        return 0;
    double defaultVolume = common_data.defaultExternalVolume;
    common_data.volume->convertExternal2Mixer(&defaultVolume);
    setMixer((int)defaultVolume);
    return 0;
}

variable_types: defaultVolume double


decompiled_code:
bool __fastcall use_linear_dB_scale(__int64 a1, __int64 a2)
{
return a2 - a1 <= 2400;
}

canonical_decompiled_code:
bool __fastcall func0(__int64 a1, __int64 a2)
{
return a2 - a1 <= 2400;
}

original_code:
static inline _Bool use_linear_dB_scale(long dBmin, long dBmax)
{
 return dBmax - dBmin <= 24 * 100;
}

variable_types: dBmin long

variable_types: dBmax long


original_code:
static long lrint_dir(double x, int dir)
{
 if (dir > 0)
  return lrint(ceil(x));
 else if (dir < 0)
  return lrint(floor(x));
 else
  return lrint(x);
}

variable_types: x double

variable_types: dir int

return_type: long


processUpper

decompiled_code:
void __fastcall processUpper(double *a1)
{
if ( *a1 > (double)responseLimit )
*a1 = *a1 / *(double *)&responseDivisor;
}

canonical_decompiled_code:
void __fastcall func0(double *a1)
{
if ( *a1 > (double)responseLimit )
*a1 = *a1 / *(double *)&responseDivisor;
}

original_code:
static void processUpper(double *volume_level) {
    if(*volume_level > responseLimit)
        *volume_level = *volume_level / responseDivisor;
}


processLower

decompiled_code:
void __fastcall processLower(double *a1)
{
if ( (double)responseLimit > *a1 )
*a1 = *a1 / *(double *)&responseDivisor;
}

canonical_decompiled_code:
void __fastcall func1(double *a1)
{
if ( (double)responseLimit > *a1 )
*a1 = *a1 / *(double *)&responseDivisor;
}

original_code:
static void processLower(double *volume_level) {
    if(*volume_level < responseLimit)
        *volume_level = *volume_level / responseDivisor;
}


deinit

decompiled_code:
void deinit()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
static void deinit(void) {
}

canonical_original_code:
static void deinit() {
}


init

decompiled_code:
__int64 init()
{
__int64 result; // rax
const char *v1; // [rsp+8h] [rbp-10h] BYREF

if ( !(unsigned int)validateConfigString(&config, "volume.response.type", &v1, 0xFFFFFFFFLL) )
{
if ( !strcmp(v1, "lower_limit") )
{
result = 1LL;
if ( !strcmp(v1, "upper_limit") )
return result;
*(&modVolumeResponseCondResize + 3) = (char *)processUpper;
}
else
{
*(&modVolumeResponseCondResize + 3) = (char *)processLower;
}
}
result = validateConfigInt(&config, "volume.response.limit", &responseLimit, 0xFFFFFFFFLL, 0LL, 0LL, -1LL);
if ( (_DWORD)result != 1 )
{
result = validateConfigDouble(&config, "volume.response.divisor", &responseDivisor, 0xFFFFFFFFLL, 0LL, 0LL, -1.0);
if ( (_DWORD)result != 1 )
{
if ( 1.0 == *(double *)&responseDivisor )
*(_QWORD *)(common_data[19] + 8LL) = 0LL;
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
const char *v1; // [rsp+8h] [rbp-10h] BYREF

if ( !(unsigned int)validateConfigString(&config, "volume.response.type", &v1, 0xFFFFFFFFLL) )
{
if ( !strcmp(v1, "lower_limit") )
{
result = 1LL;
if ( !strcmp(v1, "upper_limit") )
return result;
*(&modVolumeResponseCondResize + 3) = (char *)processUpper;
}
else
{
*(&modVolumeResponseCondResize + 3) = (char *)processLower;
}
}
result = validateConfigInt(&config, "volume.response.limit", &responseLimit, 0xFFFFFFFFLL, 0LL, 0LL, -1LL);
if ( (_DWORD)result != 1 )
{
result = validateConfigDouble(&config, "volume.response.divisor", &responseDivisor, 0xFFFFFFFFLL, 0LL, 0LL, -1.0);
if ( (_DWORD)result != 1 )
{
if ( 1.0 == *(double *)&responseDivisor )
*(_QWORD *)(common_data[19] + 8LL) = 0LL;
result = 0LL;
}
}
return result;
}

original_code:
static int init(void) {
const char *type;
    if(validateConfigString(&config, "volume.response.type", &type, -1) == 0) {
        if(strcmp(type, "lower_limit"))
            modVolumeResponseCondResize.process = &processLower;
        else
        if(strcmp(type, "upper_limit"))
            modVolumeResponseCondResize.process = &processUpper;
        else
            return 1;
    }
    if(validateConfigInt(&config, "volume.response.limit", &responseLimit, -1, 0, 0, -1) == 1)
        return 1;
    if(validateConfigDouble(&config, "volume.response.divisor", &responseDivisor, -1, 0, 0, -1) == 1)
        return 1;
    if(responseDivisor == 1)
        common_data.mod->volumeResponse = ((void *)0);
    return 0;
}

canonical_original_code:
static int init() {
char *type;
    if(validateConfigString(&config, "volume.response.type", &type, -1) == 0) {
        if(strcmp(type, "lower_limit"))
            modVolumeResponseCondResize.process = &processLower;
        else
        if(strcmp(type, "upper_limit"))
            modVolumeResponseCondResize.process = &processUpper;
        else
            return 1;
    }
    if(validateConfigInt(&config, "volume.response.limit", &responseLimit, -1, 0, 0, -1) == 1)
        return 1;
    if(validateConfigDouble(&config, "volume.response.divisor", &responseDivisor, -1, 0, 0, -1) == 1)
        return 1;
    if(responseDivisor == 1)
        common_data.mod->volumeResponse = ((void *)0);
    return 0;
}

variable_types:
type
char *


help

decompiled_code:
int help()
{
return puts("Conditional Resize");
}

canonical_decompiled_code:
int func4()
{
return puts("Conditional Resize");
}

original_code:
static void help(void) {
    printf("Conditional Resize\n"
          );
}

canonical_original_code:
static void help() {
    printf("Conditional Resize\n"
          );
}


validateConfigString

decompiled_code:
__int64 __fastcall validateConfigString(__int64 a1, const char *a2, const char **a3, int a4)
{
const char *v4; // rbx
__int64 result; // rax
char v7[136]; // [rsp+0h] [rbp-88h] BYREF

v4 = a2;
if ( a4 >= 0 )
{
snprintf(v7, 0x64uLL, "%s.[%i]", a2, (unsigned int)a4);
v4 = v7;
}
if ( (unsigned int)config_lookup_string(a1, v4, a3) )
{
syslog(6, "[OK] %s: %s", v4, *a3);
result = 0LL;
}
else
{
syslog(3, "[ERROR] Setting not present or formatted as string: %s", v4);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, const char **a3, int a4)
{
const char *v4; // rbx
__int64 result; // rax
char v7[136]; // [rsp+0h] [rbp-88h] BYREF

v4 = a2;
if ( a4 >= 0 )
{
snprintf(v7, 0x64uLL, "%s.[%i]", a2, (unsigned int)a4);
v4 = v7;
}
if ( (unsigned int)config_lookup_string(a1, v4, a3) )
{
syslog(6, "[OK] %s: %s", v4, *a3);
result = 0LL;
}
else
{
syslog(3, "[ERROR] Setting not present or formatted as string: %s", v4);
result = 1LL;
}
return result;
}

original_code:
int validateConfigString(config_t *config, char *configSettingSource,
const char **configSettingDestination, int position) {
    if(position >= 0) {
        char configQuery[100];
        snprintf(configQuery, 100, "%s.[%i]", configSettingSource, position);
        configSettingSource = &configQuery[0];
    }
    if(!config_lookup_string(config, configSettingSource, configSettingDestination)) {
        syslog(3, "[ERROR] Setting not present or formatted as string: %s", configSettingSource);
        return 1;
    }
    else {
        syslog(6, "[OK] %s: %s", configSettingSource, *configSettingDestination);
        return 0;
    }
}

canonical_original_code:
int validateConfigString(struct config_t *config, char *configSettingSource, char **configSettingDestination, int position) {
    if(position >= 0) {
        char configQuery[100];
        snprintf(configQuery, 100, "%s.[%i]", configSettingSource, position);
        configSettingSource = &configQuery[0];
    }
    if(!config_lookup_string(config, configSettingSource, configSettingDestination)) {
        syslog(3, "[ERROR] Setting not present or formatted as string: %s", configSettingSource);
        return 1;
    }
    else {
        syslog(6, "[OK] %s: %s", configSettingSource, *configSettingDestination);
        return 0;
    }
}

variable_types: struct config_t { struct config_setting_t { char *name; short type; short format; union config_value_t { int ival; long long llval; double fval; char *sval; struct config_list_t { unsigned int length; struct config_setting_t **elements; } *list; } value; struct config_setting_t *parent; struct config_t *config; void *hook; unsigned int line; char *file; } *root; void (*destructor)(void *); int options; unsigned short tab_width; short default_format; char *include_dir; char *error_text; char *error_file; int error_line; enum config_error_t { CONFIG_ERR_NONE=0, CONFIG_ERR_FILE_IO=1, CONFIG_ERR_PARSE=2 } error_type; char **filenames; unsigned int num_filenames; } *

variable_types:
configSettingSource
char *

variable_types:
configSettingDestination
char **

variable_types: position int

variable_types:
configQuery
char [100]

user_defined_types: struct config_t { struct config_setting_t *root; void (*destructor)(void *); int options; unsigned short tab_width; short default_format; char *include_dir; char *error_text; char *error_file; int error_line; enum config_error_t error_type; char **filenames; unsigned int num_filenames; }

user_defined_types: struct config_setting_t { char *name; short type; short format; union config_value_t value; struct config_setting_t *parent; struct config_t *config; void *hook; unsigned int line; char *file; }

user_defined_types: union config_value_t { int ival; long long llval; double fval; char *sval; struct config_list_t *list; }


validateConfigInt

decompiled_code:
__int64 __fastcall validateConfigInt(__int64 a1, const char *a2, unsigned int *a3, int a4, unsigned int a5, unsigned int a6, unsigned int a7)
{
const char *v7; // rbx
__int64 v11; // rcx
__int64 result; // rax
char v13[108]; // [rsp+0h] [rbp-A8h] BYREF
unsigned int v14[15]; // [rsp+6Ch] [rbp-3Ch] BYREF

v7 = a2;
v14[0] = -1;
if ( a4 >= 0 )
{
snprintf(v13, 0x64uLL, "%s.[%i]", a2, (unsigned int)a4);
v7 = v13;
}
if ( !(unsigned int)config_lookup_int(a1, v7, v14) )
{
if ( a7 == -1 )
{
syslog(3, "[ERROR] Setting not present or not an integer: %s", v7);
return 1LL;
}
if ( a7 == -2 )
{
syslog(6, "[NOTICE] Setting not found, ignoring %s", v7);
return 1LL;
}
v14[0] = a7;
}
if ( a6 | a5 && ((int)v14[0] > (int)a6 || (int)v14[0] < (int)a5) )
{
syslog(3, "[ERROR] Setting '%s' is out of range: %i [%i-%i]", v7, v14[0], a5, a6);
result = 1LL;
}
else
{
v11 = v14[0];
*a3 = v14[0];
syslog(6, "[OK] %s: %i", v7, v11);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char *a2, unsigned int *a3, int a4, unsigned int a5, unsigned int a6, unsigned int a7)
{
const char *v7; // rbx
__int64 v11; // rcx
__int64 result; // rax
char v13[108]; // [rsp+0h] [rbp-A8h] BYREF
unsigned int v14[15]; // [rsp+6Ch] [rbp-3Ch] BYREF

v7 = a2;
v14[0] = -1;
if ( a4 >= 0 )
{
snprintf(v13, 0x64uLL, "%s.[%i]", a2, (unsigned int)a4);
v7 = v13;
}
if ( !(unsigned int)config_lookup_int(a1, v7, v14) )
{
if ( a7 == -1 )
{
syslog(3, "[ERROR] Setting not present or not an integer: %s", v7);
return 1LL;
}
if ( a7 == -2 )
{
syslog(6, "[NOTICE] Setting not found, ignoring %s", v7);
return 1LL;
}
v14[0] = a7;
}
if ( a6 | a5 && ((int)v14[0] > (int)a6 || (int)v14[0] < (int)a5) )
{
syslog(3, "[ERROR] Setting '%s' is out of range: %i [%i-%i]", v7, v14[0], a5, a6);
result = 1LL;
}
else
{
v11 = v14[0];
*a3 = v14[0];
syslog(6, "[OK] %s: %i", v7, v11);
result = 0LL;
}
return result;
}

original_code:
int validateConfigInt(config_t *config, char *configSettingSource, int *configSettingDestination,
int position, int valueMin, int valueMax, int valueDefault) {
    int configReturnedInt = -1;
    if(position >= 0) {
        char configQuery[100];
        snprintf(configQuery, 100, "%s.[%i]", configSettingSource, position);
        configSettingSource = &configQuery[0];
    }
    if(!config_lookup_int(config, configSettingSource, &configReturnedInt)) {
        if(valueDefault == -1) {
            syslog(3, "[ERROR] Setting not present or not an integer: %s", configSettingSource);
            return 1;
        }
        else if (valueDefault == -2) {
            syslog(6, "[NOTICE] Setting not found, ignoring %s", configSettingSource);
            return 1;
        }
        else
            configReturnedInt = valueDefault;
    }
    if(!(valueMin == 0 && valueMax == 0) && (configReturnedInt < valueMin || configReturnedInt > valueMax)) {
        syslog(3, "[ERROR] Setting '%s' is out of range: %i [%i-%i]", configSettingSource,
                configReturnedInt, valueMin, valueMax);
        return 1;
    }
    *configSettingDestination = configReturnedInt;
    syslog(6, "[OK] %s: %i", configSettingSource, *configSettingDestination);
    return 0;
}

canonical_original_code:
int validateConfigInt(struct config_t *config, char *configSettingSource, int *configSettingDestination, int position, int valueMin, int valueMax, int valueDefault) {
    int configReturnedInt = -1;
    if(position >= 0) {
        char configQuery[100];
        snprintf(configQuery, 100, "%s.[%i]", configSettingSource, position);
        configSettingSource = &configQuery[0];
    }
    if(!config_lookup_int(config, configSettingSource, &configReturnedInt)) {
        if(valueDefault == -1) {
            syslog(3, "[ERROR] Setting not present or not an integer: %s", configSettingSource);
            return 1;
        }
        else if (valueDefault == -2) {
            syslog(6, "[NOTICE] Setting not found, ignoring %s", configSettingSource);
            return 1;
        }
        else
            configReturnedInt = valueDefault;
    }
    if(!(valueMin == 0 && valueMax == 0) && (configReturnedInt < valueMin || configReturnedInt > valueMax)) {
        syslog(3, "[ERROR] Setting '%s' is out of range: %i [%i-%i]", configSettingSource,
                configReturnedInt, valueMin, valueMax);
        return 1;
    }
    *configSettingDestination = configReturnedInt;
    syslog(6, "[OK] %s: %i", configSettingSource, *configSettingDestination);
    return 0;
}

variable_types:
configSettingDestination
int *

variable_types: valueMin int

variable_types: valueMax int

variable_types: valueDefault int

variable_types: configReturnedInt int

user_defined_types: enum config_error_t { CONFIG_ERR_NONE=0, CONFIG_ERR_FILE_IO=1, CONFIG_ERR_PARSE=2 }

user_defined_types: struct config_list_t { unsigned int length; struct config_setting_t **elements; }


validateConfigDouble

decompiled_code:
__int64 __fastcall validateConfigDouble(__int64 a1, const char *a2, double *a3, int a4, int a5, int a6, double a7)
{
const char *v7; // rbx
__int64 result; // rax
char v12[104]; // [rsp+0h] [rbp-A8h] BYREF
double v13[8]; // [rsp+68h] [rbp-40h] BYREF

v7 = a2;
v13[0] = *(double *)&LC7;
if ( a4 >= 0 )
{
snprintf(v12, 0x64uLL, "%s.[%i]", a2, (unsigned int)a4);
v7 = v12;
}
if ( !(unsigned int)config_lookup_float(a1, v7, v13) )
{
if ( a7 == -1.0 )
{
syslog(3, "[ERROR] Setting not present or not an integer/float: %s", v7);
return 1LL;
}
if ( a7 == -2.0 )
{
syslog(6, "[NOTICE] Setting not found, ignoring %s", v7);
return 1LL;
}
v13[0] = a7;
}
if ( a6 | a5 && ((double)a5 > v13[0] || v13[0] > (double)a6) )
{
syslog(3, "[ERROR] Setting '%s' is out of range: %.2f [%i-%i]", v7, v13[0], (unsigned int)a5, (unsigned int)a6);
result = 1LL;
}
else
{
*a3 = v13[0];
syslog(6, "[OK] %s: %.2f", v7);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2, double *a3, int a4, int a5, int a6, double a7)
{
const char *v7; // rbx
__int64 result; // rax
char v12[104]; // [rsp+0h] [rbp-A8h] BYREF
double v13[8]; // [rsp+68h] [rbp-40h] BYREF

v7 = a2;
v13[0] = *(double *)&LC7;
if ( a4 >= 0 )
{
snprintf(v12, 0x64uLL, "%s.[%i]", a2, (unsigned int)a4);
v7 = v12;
}
if ( !(unsigned int)config_lookup_float(a1, v7, v13) )
{
if ( a7 == -1.0 )
{
syslog(3, "[ERROR] Setting not present or not an integer/float: %s", v7);
return 1LL;
}
if ( a7 == -2.0 )
{
syslog(6, "[NOTICE] Setting not found, ignoring %s", v7);
return 1LL;
}
v13[0] = a7;
}
if ( a6 | a5 && ((double)a5 > v13[0] || v13[0] > (double)a6) )
{
syslog(3, "[ERROR] Setting '%s' is out of range: %.2f [%i-%i]", v7, v13[0], (unsigned int)a5, (unsigned int)a6);
result = 1LL;
}
else
{
*a3 = v13[0];
syslog(6, "[OK] %s: %.2f", v7);
result = 0LL;
}
return result;
}

original_code:
int validateConfigDouble(config_t *config, char *configSettingSource, double *configSettingDestination,
int position, int valueMin, int valueMax, double valueDefault) {
    double configReturnedDouble = -1;
    if(position >= 0) {
        char configQuery[100];
        snprintf(configQuery, 100, "%s.[%i]", configSettingSource, position);
        configSettingSource = &configQuery[0];
    }
    if(!config_lookup_float(config, configSettingSource, &configReturnedDouble)) {
        if(valueDefault == -1) {
            syslog(3, "[ERROR] Setting not present or not an integer/float: %s", configSettingSource);
            return 1;
        }
        else if (valueDefault == -2) {
            syslog(6, "[NOTICE] Setting not found, ignoring %s", configSettingSource);
            return 1;
        }
        else
            configReturnedDouble = valueDefault;
    }
    if(!(valueMin == 0 && valueMax == 0) && (configReturnedDouble < valueMin || configReturnedDouble > valueMax)) {
        syslog(3, "[ERROR] Setting '%s' is out of range: %.2f [%i-%i]", configSettingSource,
                configReturnedDouble, valueMin, valueMax);
        return 1;
    }
    *configSettingDestination = configReturnedDouble;
    syslog(6, "[OK] %s: %.2f", configSettingSource, *configSettingDestination);
    return 0;
}

canonical_original_code:
int validateConfigDouble(struct config_t *config, char *configSettingSource, double *configSettingDestination, int position, int valueMin, int valueMax, double valueDefault) {
    double configReturnedDouble = -1;
    if(position >= 0) {
        char configQuery[100];
        snprintf(configQuery, 100, "%s.[%i]", configSettingSource, position);
        configSettingSource = &configQuery[0];
    }
    if(!config_lookup_float(config, configSettingSource, &configReturnedDouble)) {
        if(valueDefault == -1) {
            syslog(3, "[ERROR] Setting not present or not an integer/float: %s", configSettingSource);
            return 1;
        }
        else if (valueDefault == -2) {
            syslog(6, "[NOTICE] Setting not found, ignoring %s", configSettingSource);
            return 1;
        }
        else
            configReturnedDouble = valueDefault;
    }
    if(!(valueMin == 0 && valueMax == 0) && (configReturnedDouble < valueMin || configReturnedDouble > valueMax)) {
        syslog(3, "[ERROR] Setting '%s' is out of range: %.2f [%i-%i]", configSettingSource,
                configReturnedDouble, valueMin, valueMax);
        return 1;
    }
    *configSettingDestination = configReturnedDouble;
    syslog(6, "[OK] %s: %.2f", configSettingSource, *configSettingDestination);
    return 0;
}

variable_types:
configSettingDestination
double *

variable_types: valueDefault double

variable_types: configReturnedDouble double


validateConfigBool

decompiled_code:
__int64 __fastcall validateConfigBool(__int64 a1, const char *a2, int *a3, int a4)
{
__int64 v7[5]; // [rsp+0h] [rbp-28h]

v7[0] = (__int64)"FALSE";
v7[1] = (__int64)"TRUE";
if ( (unsigned int)config_lookup_bool(a1, a2) )
syslog(6, "[OK] %s: %s", a2, (const char *)v7[*a3]);
else
*a3 = a4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2, int *a3, int a4)
{
__int64 v7[5]; // [rsp+0h] [rbp-28h]

v7[0] = (__int64)"FALSE";
v7[1] = (__int64)"TRUE";
if ( (unsigned int)config_lookup_bool(a1, a2) )
syslog(6, "[OK] %s: %s", a2, (const char *)v7[*a3]);
else
*a3 = a4;
return 0LL;
}

original_code:
int validateConfigBool(config_t *config, char *configSettingSource, int *configSettingDestination,
int valueDefault) {
    const char* boolNaming[2];
    boolNaming[0] = "FALSE";
    boolNaming[1] = "TRUE";
    if(!config_lookup_bool(config, configSettingSource, configSettingDestination))
        *configSettingDestination = valueDefault;
    else {
        syslog(6, "[OK] %s: %s", configSettingSource, boolNaming[*configSettingDestination]);
        return 0;
    }
    return 0;
}

canonical_original_code:
int validateConfigBool(struct config_t *config, char *configSettingSource, int *configSettingDestination, int valueDefault) {
    char *boolNaming[2];
    boolNaming[0] = "FALSE";
    boolNaming[1] = "TRUE";
    if(!config_lookup_bool(config, configSettingSource, configSettingDestination))
        *configSettingDestination = valueDefault;
    else {
        syslog(6, "[OK] %s: %s", configSettingSource, boolNaming[*configSettingDestination]);
        return 0;
    }
    return 0;
}

variable_types:
boolNaming
char *[2]


deinitVolume

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

result = *(_QWORD *)(*((_QWORD *)&common_data + 19) + 8LL);
if ( result )
result = (*(__int64 (**)(void))(result + 32))();
return result;
}

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

result = *(_QWORD *)(*((_QWORD *)&common_data + 19) + 8LL);
if ( result )
result = (*(__int64 (**)(void))(result + 32))();
return result;
}

original_code:
static void deinitVolume(void) {
    if(common_data.mod->volumeResponse != ((void *)0))
        common_data.mod->volumeResponse->deinit();
}

canonical_original_code:
static void deinitVolume() {
    if(common_data.mod->volumeResponse != ((void *)0))
        common_data.mod->volumeResponse->deinit();
}


processVolume

decompiled_code:
__int64 __fastcall processVolume(__int64 *a1)
{
__int64 v1; // rdx
__int64 v2; // rax
int v3; // eax
int v4; // eax
__m128d v5; // xmm3
__m128d v6; // xmm1
int v8; // eax
int v9; // eax
unsigned __int64 v10; // xmm3_8
__m128d v11; // xmm3
__int64 v12[2]; // [rsp+0h] [rbp-10h] BYREF

if ( *((_QWORD *)&common_data + 6) != *((_QWORD *)&common_data + 5) )
{
pthread_setcancelstate(1, 0LL);
if ( pthread_mutex_trylock(&lockProcess) )
{
pthread_setcancelstate(0, 0LL);
syslog(7, "Skipping incoming volume command");
}
else
{
clock_gettime(1, &timestampCurrent);
v1 = (unsigned int)(LODWORD(timestampCurrent.tv_sec) - *((_DWORD *)&common_data + 24));
if ( (int)v1 <= 2 )
{
syslog(7, "Incoming volume level processing timeout (completed): %i/%i", v1, 2LL);
pthread_mutex_unlock(&lockProcess);
pthread_setcancelstate(0, 0LL);
}
else
{
v12[0] = *a1;
v2 = *(_QWORD *)(*((_QWORD *)&common_data + 19) + 8LL);
if ( v2 )
(*(void (__fastcall **)(__int64 *))(v2 + 24))(v12);
v3 = *((_DWORD *)&common_data + 7);
if ( *(double *)v12 <= (double)v3 && (v3 == *((_DWORD *)&common_data + 9) || (double)v3 <= *(double *)v12) )
{
v8 = *((_DWORD *)&common_data + 6);
if ( (double)v8 <= *(double *)v12 && (v8 == *((_DWORD *)&common_data + 8) || *(double *)v12 <= (double)v8) )
{
if ( (int)*(double *)v12 == (int)*((double *)&common_data + 8) )
{
pthread_mutex_unlock(&lockProcess);
pthread_setcancelstate(0, 0LL);
return 0LL;
}
}
else
{
v9 = *((_DWORD *)&common_data + 8);
if ( (double)v9 > *(double *)v12 )
{
v10 = v12[0];
if ( COERCE_DOUBLE(v12[0] & LC3) < 4.503599627370496e15 )
{
v11.m128d_f64[0] = (double)(int)*(double *)v12;
v10 = COERCE_UNSIGNED_INT64(
v11.m128d_f64[0]
- COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v11, (__m128d)(unsigned __int64)v12[0]) & LC4)) | ~LC3 & v12[0];
}
v9 = (int)*(double *)&v10;
}
*((_DWORD *)&common_data + 6) = v9;
(*(void (**)(void))(*((_QWORD *)&common_data + 18) + 32LL))();
syslog(
7,
"Volume level lower range has been adjusted: %i -> %i",
*((unsigned int *)&common_data + 8),
*((unsigned int *)&common_data + 6));
}
}
else
{
v4 = *((_DWORD *)&common_data + 9);
if ( *(double *)v12 > (double)v4 )
{
*(_QWORD *)&v5.m128d_f64[0] = v12[0];
if ( COERCE_DOUBLE(v12[0] & LC3) < 4.503599627370496e15 )
{
v6.m128d_f64[0] = (double)(int)*(double *)v12;
*(_QWORD *)&v5.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v5, v6) & LC4) + v6.m128d_f64[0]) | ~LC3 & v12[0];
}
v4 = (int)v5.m128d_f64[0];
}
*((_DWORD *)&common_data + 7) = v4;
(*(void (**)(void))(*((_QWORD *)&common_data + 18) + 32LL))();
syslog(
7,
"Volume upper range has been adjusted: %i -> %i",
*((unsigned int *)&common_data + 9),
*((unsigned int *)&common_data + 7));
}
*((_QWORD *)&common_data + 8) = v12[0];
(*(void (__fastcall **)(__int64 *))(*((_QWORD *)&common_data + 18) + 40LL))(v12);
setMixer((unsigned int)(int)*(double *)v12);
clock_gettime(1, (struct timespec *)(unsigned int)((_DWORD)&common_data + 80));
syslog(
7,
"Volume level mutation (ext. initiated): ext. (int.): %.2f (%.2f)",
*((double *)&common_data + 8),
*(double *)v12);
pthread_mutex_unlock(&lockProcess);
pthread_setcancelstate(0, 0LL);
}
}
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1)
{
__int64 v1; // rdx
__int64 v2; // rax
int v3; // eax
int v4; // eax
__m128d v5; // xmm3
__m128d v6; // xmm1
int v8; // eax
int v9; // eax
unsigned __int64 v10; // xmm3_8
__m128d v11; // xmm3
__int64 v12[2]; // [rsp+0h] [rbp-10h] BYREF

if ( *((_QWORD *)&common_data + 6) != *((_QWORD *)&common_data + 5) )
{
pthread_setcancelstate(1, 0LL);
if ( pthread_mutex_trylock(&lockProcess) )
{
pthread_setcancelstate(0, 0LL);
syslog(7, "Skipping incoming volume command");
}
else
{
clock_gettime(1, &timestampCurrent);
v1 = (unsigned int)(LODWORD(timestampCurrent.tv_sec) - *((_DWORD *)&common_data + 24));
if ( (int)v1 <= 2 )
{
syslog(7, "Incoming volume level processing timeout (completed): %i/%i", v1, 2LL);
pthread_mutex_unlock(&lockProcess);
pthread_setcancelstate(0, 0LL);
}
else
{
v12[0] = *a1;
v2 = *(_QWORD *)(*((_QWORD *)&common_data + 19) + 8LL);
if ( v2 )
(*(void (__fastcall **)(__int64 *))(v2 + 24))(v12);
v3 = *((_DWORD *)&common_data + 7);
if ( *(double *)v12 <= (double)v3 && (v3 == *((_DWORD *)&common_data + 9) || (double)v3 <= *(double *)v12) )
{
v8 = *((_DWORD *)&common_data + 6);
if ( (double)v8 <= *(double *)v12 && (v8 == *((_DWORD *)&common_data + 8) || *(double *)v12 <= (double)v8) )
{
if ( (int)*(double *)v12 == (int)*((double *)&common_data + 8) )
{
pthread_mutex_unlock(&lockProcess);
pthread_setcancelstate(0, 0LL);
return 0LL;
}
}
else
{
v9 = *((_DWORD *)&common_data + 8);
if ( (double)v9 > *(double *)v12 )
{
v10 = v12[0];
if ( COERCE_DOUBLE(v12[0] & LC3) < 4.503599627370496e15 )
{
v11.m128d_f64[0] = (double)(int)*(double *)v12;
v10 = COERCE_UNSIGNED_INT64(
v11.m128d_f64[0]
- COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v11, (__m128d)(unsigned __int64)v12[0]) & LC4)) | ~LC3 & v12[0];
}
v9 = (int)*(double *)&v10;
}
*((_DWORD *)&common_data + 6) = v9;
(*(void (**)(void))(*((_QWORD *)&common_data + 18) + 32LL))();
syslog(
7,
"Volume level lower range has been adjusted: %i -> %i",
*((unsigned int *)&common_data + 8),
*((unsigned int *)&common_data + 6));
}
}
else
{
v4 = *((_DWORD *)&common_data + 9);
if ( *(double *)v12 > (double)v4 )
{
*(_QWORD *)&v5.m128d_f64[0] = v12[0];
if ( COERCE_DOUBLE(v12[0] & LC3) < 4.503599627370496e15 )
{
v6.m128d_f64[0] = (double)(int)*(double *)v12;
*(_QWORD *)&v5.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v5, v6) & LC4) + v6.m128d_f64[0]) | ~LC3 & v12[0];
}
v4 = (int)v5.m128d_f64[0];
}
*((_DWORD *)&common_data + 7) = v4;
(*(void (**)(void))(*((_QWORD *)&common_data + 18) + 32LL))();
syslog(
7,
"Volume upper range has been adjusted: %i -> %i",
*((unsigned int *)&common_data + 9),
*((unsigned int *)&common_data + 7));
}
*((_QWORD *)&common_data + 8) = v12[0];
(*(void (__fastcall **)(__int64 *))(*((_QWORD *)&common_data + 18) + 40LL))(v12);
setMixer((unsigned int)(int)*(double *)v12);
clock_gettime(1, (struct timespec *)(unsigned int)((_DWORD)&common_data + 80));
syslog(
7,
"Volume level mutation (ext. initiated): ext. (int.): %.2f (%.2f)",
*((double *)&common_data + 8),
*(double *)v12);
pthread_mutex_unlock(&lockProcess);
pthread_setcancelstate(0, 0LL);
}
}
return 0LL;
}
return 0LL;
}

original_code:
static int processVolume(double *volumeExternal) {
    if(common_data.alsa_volume_max == common_data.alsa_volume_min)
        return 0;
    pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, ((void *)0));
    if(pthread_mutex_trylock(&lockProcess) != 0) {
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, ((void *)0));
        syslog(7, "Skipping incoming volume command");
        return 0;
    }
    int timeout;
    clock_gettime(1, &timestampCurrent);
    if((timeout = timestampCurrent.tv_sec - common_data.timestampLastTX.tv_sec) <= 2) {
        syslog(7, "Incoming volume level processing timeout (completed): %i/%i", timeout, 2);
        pthread_mutex_unlock(&lockProcess);
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, ((void *)0));
        return 0;
    }
    double volume_level = *volumeExternal;
    if(common_data.mod->volumeResponse)
        common_data.mod->volumeResponse->process(&volume_level);
    if(volume_level > common_data.volume_max || common_data.volume_max != common_data.initial_volume_max
    && volume_level < common_data.volume_max) {
        if(volume_level > common_data.initial_volume_max)
            common_data.volume_max = (int)ceil(volume_level);
        else
            common_data.volume_max = common_data.initial_volume_max;
        common_data.volume->regenerateMultipliers();
        syslog(7, "Volume upper range has been adjusted: %i -> %i",
        common_data.initial_volume_max, common_data.volume_max);
    }
    else if(volume_level < common_data.volume_min || common_data.volume_min != common_data.initial_volume_min
    && volume_level > common_data.volume_min) {
        if(volume_level < common_data.initial_volume_min)
            common_data.volume_min = (int)floor(volume_level);
        else
            common_data.volume_min = common_data.initial_volume_min;
        common_data.volume->regenerateMultipliers();
        syslog(7, "Volume level lower range has been adjusted: %i -> %i",
        common_data.initial_volume_min, common_data.volume_min);
    }
    else if((int)volume_level == (int)common_data.volume_level_status) {
        pthread_mutex_unlock(&lockProcess);
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, ((void *)0));
        return 0;
    }
    common_data.volume_level_status = volume_level;
    common_data.volume->convertExternal2Mixer(&volume_level);
    setMixer((int)volume_level);
    clock_gettime(1 , &common_data.timestampLastRX);
    syslog(7, "Volume level mutation (ext. initiated): ext. (int.): %.2f (%.2f)", common_data.volume_level_status, volume_level);
    pthread_mutex_unlock(&lockProcess);
    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, ((void *)0));
    return 0;
}

variable_types:
volumeExternal
double *

variable_types: timeout int


initVolume

decompiled_code:
__int64 initVolume()
{
__int64 result; // rax
__int64 v1; // rax

*((_QWORD *)&common_data + 8) = LC8;
*((_QWORD *)&common_data + 12) = 0LL;
*((_QWORD *)&common_data + 13) = 0LL;
*((__m128i *)&common_data + 5) = _mm_loadu_si128((const __m128i *)&common_data + 6);
*((_QWORD *)&common_data + 5) = 0LL;
*((_QWORD *)&common_data + 6) = 0LL;
*((_DWORD *)&common_data + 6) = 0;
*((_DWORD *)&common_data + 7) = 100;
if ( !config_lookup(&config, "volume") )
{
syslog(3, "[Error] Category 'volume' is not present");
return 1LL;
}
validateConfigBool(&config, "volume.discrete", (unsigned int)((_DWORD)&common_data + 4), 1LL);
validateConfigInt(&config, "volume.timeout", (unsigned int)((_DWORD)&common_data + 72), 0xFFFFFFFFLL, 0LL, 100LL, 0LL);
if ( HIDWORD(common_data.tv_sec) )
{
result = validateConfigInt(
&config,
"volume.min",
(unsigned int)((_DWORD)&common_data + 24),
0xFFFFFFFFLL,
0LL,
0LL,
-1LL);
if ( (_DWORD)result == 1 )
return result;
result = validateConfigInt(
&config,
"volume.max",
(unsigned int)((_DWORD)&common_data + 28),
0xFFFFFFFFLL,
0LL,
0LL,
-1LL);
if ( (_DWORD)result == 1 )
return result;
goto LABEL_6;
}
if ( strcmp("linear", *(const char **)(*((_QWORD *)&common_data + 18) + 24LL)) )
syslog(3, "[Error] Volume curve must be 'linear' when using relative volume control");
result = validateConfigInt(
&config,
"volume.multiplier",
(unsigned int)((_DWORD)&common_data + 76),
0xFFFFFFFFLL,
1LL,
100LL,
1LL);
if ( (_DWORD)result != 1 )
{
LABEL_6:
if ( (unsigned int)validateConfigInt(
&config,
"volume.default",
(unsigned int)((_DWORD)&common_data + 168),
0xFFFFFFFFLL,
*((unsigned int *)&common_data + 6),
*((unsigned int *)&common_data + 7),
-2LL) == 1 )
*((_DWORD *)&common_data + 42) = *((_DWORD *)&common_data + 6) - 1;
v1 = *(_QWORD *)(*((_QWORD *)&common_data + 19) + 8LL);
if ( !v1 || (result = (*(__int64 (**)(void))(v1 + 16))(), (_DWORD)result != 1) )
{
*((_DWORD *)&common_data + 8) = *((_DWORD *)&common_data + 6);
*((_DWORD *)&common_data + 9) = *((_DWORD *)&common_data + 7);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
__int64 v1; // rax

*((_QWORD *)&common_data + 8) = LC8;
*((_QWORD *)&common_data + 12) = 0LL;
*((_QWORD *)&common_data + 13) = 0LL;
*((__m128i *)&common_data + 5) = _mm_loadu_si128((const __m128i *)&common_data + 6);
*((_QWORD *)&common_data + 5) = 0LL;
*((_QWORD *)&common_data + 6) = 0LL;
*((_DWORD *)&common_data + 6) = 0;
*((_DWORD *)&common_data + 7) = 100;
if ( !config_lookup(&config, "volume") )
{
syslog(3, "[Error] Category 'volume' is not present");
return 1LL;
}
validateConfigBool(&config, "volume.discrete", (unsigned int)((_DWORD)&common_data + 4), 1LL);
validateConfigInt(&config, "volume.timeout", (unsigned int)((_DWORD)&common_data + 72), 0xFFFFFFFFLL, 0LL, 100LL, 0LL);
if ( HIDWORD(common_data.tv_sec) )
{
result = validateConfigInt(
&config,
"volume.min",
(unsigned int)((_DWORD)&common_data + 24),
0xFFFFFFFFLL,
0LL,
0LL,
-1LL);
if ( (_DWORD)result == 1 )
return result;
result = validateConfigInt(
&config,
"volume.max",
(unsigned int)((_DWORD)&common_data + 28),
0xFFFFFFFFLL,
0LL,
0LL,
-1LL);
if ( (_DWORD)result == 1 )
return result;
goto LABEL_6;
}
if ( strcmp("linear", *(const char **)(*((_QWORD *)&common_data + 18) + 24LL)) )
syslog(3, "[Error] Volume curve must be 'linear' when using relative volume control");
result = validateConfigInt(
&config,
"volume.multiplier",
(unsigned int)((_DWORD)&common_data + 76),
0xFFFFFFFFLL,
1LL,
100LL,
1LL);
if ( (_DWORD)result != 1 )
{
LABEL_6:
if ( (unsigned int)validateConfigInt(
&config,
"volume.default",
(unsigned int)((_DWORD)&common_data + 168),
0xFFFFFFFFLL,
*((unsigned int *)&common_data + 6),
*((unsigned int *)&common_data + 7),
-2LL) == 1 )
*((_DWORD *)&common_data + 42) = *((_DWORD *)&common_data + 6) - 1;
v1 = *(_QWORD *)(*((_QWORD *)&common_data + 19) + 8LL);
if ( !v1 || (result = (*(__int64 (**)(void))(v1 + 16))(), (_DWORD)result != 1) )
{
*((_DWORD *)&common_data + 8) = *((_DWORD *)&common_data + 6);
*((_DWORD *)&common_data + 9) = *((_DWORD *)&common_data + 7);
result = 0LL;
}
}
return result;
}

original_code:
static int initVolume(void) {
    common_data.volume_level_status = -1;
    common_data.timestampLastRX = common_data.timestampLastTX = (struct timespec) { 0, 0 };
    common_data.alsa_volume_max = common_data.alsa_volume_min = 0;
    config_setting_t *conf_setting = ((void *)0);
    int int_setting = -1;
    common_data.volume_min = 0;
    common_data.volume_max = 100;
    if(config_lookup(&config, "volume") == ((void *)0)) {
        syslog(3, "[Error] Category 'volume' is not present");
        return 1;
    }
    validateConfigBool(&config, "volume.discrete", &common_data.discrete_volume, 1);
    validateConfigInt(&config, "volume.timeout", &common_data.volume_timeout, -1, 0, 100, 0);
    if(!common_data.discrete_volume) {
        if(strcmp("linear", common_data.volume->curve) != 0)
            syslog(3, "[Error] Volume curve must be 'linear' when using relative volume control");
        if(validateConfigInt(&config, "volume.multiplier", &common_data.nd_vol_multiplier, -1, 1, 100, 1) == 1)
            return 1;
    }
    else {
        if(validateConfigInt(&config, "volume.min", &common_data.volume_min, -1, 0, 0, -1) == 1)
            return 1;
        if(validateConfigInt(&config, "volume.max", &common_data.volume_max, -1, 0, 0, -1) == 1)
            return 1;
    }
    if(validateConfigInt(&config, "volume.default", &common_data.defaultExternalVolume, -1,
    common_data.volume_min, common_data.volume_max, -2) == 1)
        common_data.defaultExternalVolume = common_data.volume_min-1;
    if(common_data.mod->volumeResponse) {
        if(common_data.mod->volumeResponse->init() == 1)
            return 1;
    }
    common_data.initial_volume_min = common_data.volume_min;
    common_data.initial_volume_max = common_data.volume_max;
    return 0;
}

canonical_original_code:
static int initVolume() {
    common_data.volume_level_status = -1;
    common_data.timestampLastRX = common_data.timestampLastTX = (struct timespec) { 0, 0 };
    common_data.alsa_volume_max = common_data.alsa_volume_min = 0;
    struct config_setting_t *conf_setting = ((void *)0);
    int int_setting = -1;
    common_data.volume_min = 0;
    common_data.volume_max = 100;
    if(config_lookup(&config, "volume") == ((void *)0)) {
        syslog(3, "[Error] Category 'volume' is not present");
        return 1;
    }
    validateConfigBool(&config, "volume.discrete", &common_data.discrete_volume, 1);
    validateConfigInt(&config, "volume.timeout", &common_data.volume_timeout, -1, 0, 100, 0);
    if(!common_data.discrete_volume) {
        if(strcmp("linear", common_data.volume->curve) != 0)
            syslog(3, "[Error] Volume curve must be 'linear' when using relative volume control");
        if(validateConfigInt(&config, "volume.multiplier", &common_data.nd_vol_multiplier, -1, 1, 100, 1) == 1)
            return 1;
    }
    else {
        if(validateConfigInt(&config, "volume.min", &common_data.volume_min, -1, 0, 0, -1) == 1)
            return 1;
        if(validateConfigInt(&config, "volume.max", &common_data.volume_max, -1, 0, 0, -1) == 1)
            return 1;
    }
    if(validateConfigInt(&config, "volume.default", &common_data.defaultExternalVolume, -1,
    common_data.volume_min, common_data.volume_max, -2) == 1)
        common_data.defaultExternalVolume = common_data.volume_min-1;
    if(common_data.mod->volumeResponse) {
        if(common_data.mod->volumeResponse->init() == 1)
            return 1;
    }
    common_data.initial_volume_min = common_data.volume_min;
    common_data.initial_volume_max = common_data.volume_max;
    return 0;
}

variable_types: struct config_setting_t { char *name; short type; short format; union config_value_t { int ival; long long llval; double fval; char *sval; struct config_list_t { unsigned int length; struct config_setting_t **elements; } *list; } value; struct config_setting_t *parent; struct config_t { struct config_setting_t *root; void (*destructor)(void *); int options; unsigned short tab_width; short default_format; char *include_dir; char *error_text; char *error_file; int error_line; enum config_error_t { CONFIG_ERR_NONE=0, CONFIG_ERR_FILE_IO=1, CONFIG_ERR_PARSE=2 } error_type; char **filenames; unsigned int num_filenames; } *config; void *hook; unsigned int line; char *file; } *

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


getInterface

decompiled_code:
const char **__fastcall getInterface(const char **a1)
{
const char **v1; // rbx
const char *v2; // r12
void **v3; // rbp

if ( !*a1 )
*a1 = (const char *)*((_QWORD *)list_interfaces + 1);
v1 = (const char **)list_interfaces;
if ( list_interfaces )
{
v2 = *a1;
v3 = &list_interfaces;
do
{
if ( !strcasecmp(v2, v1[1]) )
break;
v1 = (const char **)*++v3;
}
while ( *v3 );
}
return v1;
}

canonical_decompiled_code:
const char **__fastcall func0(const char **a1)
{
const char **v1; // rbx
const char *v2; // r12
void **v3; // rbp

if ( !*a1 )
*a1 = (const char *)*((_QWORD *)list_interfaces + 1);
v1 = (const char **)list_interfaces;
if ( list_interfaces )
{
v2 = *a1;
v3 = &list_interfaces;
do
{
if ( !strcasecmp(v2, v1[1]) )
break;
v1 = (const char **)*++v3;
}
while ( *v3 );
}
return v1;
}

original_code:
interface_t *getInterface(const char **name) {
    interface_t **interface;
    if (!*name)
        *name = list_interfaces[0]->name;
    for (interface=list_interfaces; *interface; interface++)
        if (!strcasecmp(*name, (*interface)->name))
            return *interface;
    return ((void *)0);
}

canonical_original_code:
struct interface_t *getInterface(char **name) {
    struct interface_t **interface;
    if (!*name)
        *name = list_interfaces[0]->name;
    for (interface=list_interfaces; *interface; interface++)
        if (!strcasecmp(*name, (*interface)->name))
            return *interface;
    return ((void *)0);
}

variable_types:
name
char **

variable_types: struct interface_t { void (*help)(); char *name; int (*init)(); int (*deinit)(); int (*reply)(void *message, unsigned long messageLength); int (*send)(void *message, unsigned long messageLength); void *(*listen)(void *arg); } **


repo: theseoafs/haris

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

v1 = strformat(
"static void haris_lib_write_scalar(unsigned char *message, const void *src,\n"
" HarisScalarType type)\n"
"{\n"
" haris_lib_scalar_writers[type](message, src);\n"
"}\n"
"\n");
result = add_private_function(a1, v1);
if ( (_DWORD)result )
result = 4LL;
return result;
}

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

v1 = strformat(
"static void haris_lib_write_scalar(unsigned char *message, const void *src,\n"
" HarisScalarType type)\n"
"{\n"
" haris_lib_scalar_writers[type](message, src);\n"
"}\n"
"\n");
result = add_private_function(a1, v1);
if ( (_DWORD)result )
result = 4LL;
return result;
}

original_code:
static CJobStatus write_scalar_writer_function(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_lib_write_scalar(unsigned char *message, const void *src,\n                                    HarisScalarType type)\n{\n  haris_lib_scalar_writers[type](message, src);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_scalar_writer_function(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_lib_write_scalar(unsigned char *message, const void *src,\n                                    HarisScalarType type)\n{\n  haris_lib_scalar_writers[type](message, src);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

variable_types: struct CJob { struct ParsedSchema { int num_structs; int structs_alloc; struct _ParsedStruct { char *name; struct StructMetadata { unsigned long max_size; } meta; int schema_index; int offset; int num_scalars; int scalars_alloc; struct ScalarField { char *name; int offset; struct ScalarType { enum ScalarTag { SCALAR_UINT8=0, SCALAR_INT8=1, SCALAR_UINT16=2, SCALAR_INT16=3, SCALAR_UINT32=4, SCALAR_INT32=5, SCALAR_UINT64=6, SCALAR_INT64=7, SCALAR_FLOAT32=8, SCALAR_FLOAT64=9, SCALAR_BOOL=10, SCALAR_ENUM=11 } tag; struct _ParsedEnum { char *name; int num_values; int values_alloc; char **values; } *enum_type; } type; } *scalars; int num_children; int children_alloc; struct ChildField { char *name; int nullable; struct ChildMetadata { int embeddable; } meta; enum ChildTag { CHILD_TEXT=0, CHILD_STRUCT=1, CHILD_SCALAR_LIST=2, CHILD_STRUCT_LIST=3 } tag; union ChildType { struct _ParsedStruct *strct; struct ScalarType scalar_list; struct _ParsedStruct *struct_list; } type; } *children; } *structs; int num_enums; int enums_alloc; struct _ParsedEnum *enums; } *schema; char *prefix; char *output; struct CJobProtocols { int buffer; int file; int fd; } protocols; struct CJobStrings { struct CJobStringStack { int num_strings; int strings_alloc; char **strings; } header_strings; struct CJobStringStack header_bottom_strings; struct CJobStringStack source_strings; struct CJobStringStack public_functions; struct CJobStringStack private_functions; } strings; } *

return_type: enum CJobStatus { CJOB_SUCCESS=0, CJOB_SCHEMA_ERROR=1, CJOB_JOB_ERROR=2, CJOB_IO_ERROR=3, CJOB_MEM_ERROR=4, CJOB_PARSE_ERROR=5 }

user_defined_types: struct CJob { struct ParsedSchema *schema; char *prefix; char *output; struct CJobProtocols protocols; struct CJobStrings strings; }

user_defined_types: struct CJobStrings { struct CJobStringStack header_strings; struct CJobStringStack header_bottom_strings; struct CJobStringStack source_strings; struct CJobStringStack public_functions; struct CJobStringStack private_functions; }

user_defined_types: struct ParsedSchema { int num_structs; int structs_alloc; struct _ParsedStruct *structs; int num_enums; int enums_alloc; struct _ParsedEnum *enums; }

user_defined_types: struct _ParsedStruct { char *name; struct StructMetadata meta; int schema_index; int offset; int num_scalars; int scalars_alloc; struct ScalarField *scalars; int num_children; int children_alloc; struct ChildField *children; }

user_defined_types: struct ScalarField { char *name; int offset; struct ScalarType type; }

user_defined_types: struct ChildField { char *name; int nullable; struct ChildMetadata meta; enum ChildTag tag; union ChildType type; }

user_defined_types: struct ScalarType { enum ScalarTag tag; struct _ParsedEnum *enum_type; }


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

v1 = strformat(
"static void haris_lib_read_scalar(const unsigned char *message, void *src,\n"
" HarisScalarType type)\n"
"{\n"
" haris_lib_scalar_readers[type](message, src);\n"
"}\n"
"\n");
result = add_private_function(a1, v1);
if ( (_DWORD)result )
result = 4LL;
return result;
}

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

v1 = strformat(
"static void haris_lib_read_scalar(const unsigned char *message, void *src,\n"
" HarisScalarType type)\n"
"{\n"
" haris_lib_scalar_readers[type](message, src);\n"
"}\n"
"\n");
result = add_private_function(a1, v1);
if ( (_DWORD)result )
result = 4LL;
return result;
}

original_code:
static CJobStatus write_scalar_reader_function(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_lib_read_scalar(const unsigned char *message, void *src,\n                                   HarisScalarType type)\n{\n  haris_lib_scalar_readers[type](message, src);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_scalar_reader_function(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_lib_read_scalar(const unsigned char *message, void *src,\n                                   HarisScalarType type)\n{\n  haris_lib_scalar_readers[type](message, src);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

user_defined_types: enum CJobStatus { CJOB_SUCCESS=0, CJOB_SCHEMA_ERROR=1, CJOB_JOB_ERROR=2, CJOB_IO_ERROR=3, CJOB_MEM_ERROR=4, CJOB_PARSE_ERROR=5 }

user_defined_types: struct CJobProtocols { int buffer; int file; int fd; }

user_defined_types: struct CJobStringStack { int num_strings; int strings_alloc; char **strings; }

user_defined_types: struct StructMetadata { unsigned long max_size; }

user_defined_types: struct ChildMetadata { int embeddable; }

user_defined_types: enum ChildTag { CHILD_TEXT=0, CHILD_STRUCT=1, CHILD_SCALAR_LIST=2, CHILD_STRUCT_LIST=3 }

user_defined_types: union ChildType { struct _ParsedStruct *strct; struct ScalarType scalar_list; struct _ParsedStruct *struct_list; }

user_defined_types: enum ScalarTag { SCALAR_UINT8=0, SCALAR_INT8=1, SCALAR_UINT16=2, SCALAR_INT16=3, SCALAR_UINT32=4, SCALAR_INT32=5, SCALAR_UINT64=6, SCALAR_INT64=7, SCALAR_FLOAT32=8, SCALAR_FLOAT64=9, SCALAR_BOOL=10, SCALAR_ENUM=11 }

user_defined_types: struct _ParsedEnum { char *name; int num_values; int values_alloc; char **values; }


decompiled_code:
__int64 __fastcall write_writefloat(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax

v1 = strformat(
"static void haris_write_float32(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_float32 f = *(const haris_float32*)_ptr;\n"
" haris_float64 fnorm;\n"
" int shift;\n"
" const int float32_sigbits = 23;\n"
" long sign, exp, significand;\n"
" haris_uint32_t result;\n"
"\n"
" if (f == 0.0) {\n"
" result = 0.0;\n"
" goto Finish;\n"
" } \n"
"\n"
" if (f < 0) {\n"
" sign = 1; \n"
" fnorm = -f; \n"
" } else { \n"
" sign = 0; \n"
" fnorm = f; \n"
" }\n"
"\n"
" shift = 0;\n"
" while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n"
" while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n"
" fnorm = fnorm - 1.0;\n"
"\n"
" significand = fnorm * (((haris_uint32_t)1 << float32_sigbits)\n"
" + 0.5f);\n"
"\n"
" exp = shift + ((1<<7) - 1); \n"
"\n"
" result = (sign<<31) | (exp<<23) | significand;\n"
" Finish:\n"
" haris_write_uint32(b, &result);\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_write_float64(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_float64 fnorm, f = *(const haris_float64*)_ptr;\n"
" const int float64_sigbits = 52;\n"
" int shift;\n"
" long sign, exp, significand;\n"
" haris_uint64_t result;\n"
"\n"
" if (f == 0.0) {\n"
" result = 0.0;\n"
" goto Finish;\n"
" }\n"
"\n"
" if (f < 0) {\n"
" sign = 1; \n"
" fnorm = -f; \n"
" } else { \n"
" sign = 0; \n"
" fnorm = f; \n"
" }\n"
"\n"
" shift = 0;\n"
" while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n"
" while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n"
" fnorm = fnorm - 1.0;\n"
"\n"
" significand = fnorm * (((haris_uint64_t)1<<float64_sigbits)\n"
" + 0.5f);\n"
"\n"
" exp = shift + ((1<<10) - 1); \n"
"\n"
" result = (sign<<63) | (exp<<52) | significand;\n"
" Finish:\n"
" haris_write_uint64(b, &result);\n"
"}\n"
"\n");
result = add_private_function(a1, v4);
if ( (_DWORD)result )
result = 4LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax

v1 = strformat(
"static void haris_write_float32(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_float32 f = *(const haris_float32*)_ptr;\n"
" haris_float64 fnorm;\n"
" int shift;\n"
" const int float32_sigbits = 23;\n"
" long sign, exp, significand;\n"
" haris_uint32_t result;\n"
"\n"
" if (f == 0.0) {\n"
" result = 0.0;\n"
" goto Finish;\n"
" } \n"
"\n"
" if (f < 0) {\n"
" sign = 1; \n"
" fnorm = -f; \n"
" } else { \n"
" sign = 0; \n"
" fnorm = f; \n"
" }\n"
"\n"
" shift = 0;\n"
" while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n"
" while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n"
" fnorm = fnorm - 1.0;\n"
"\n"
" significand = fnorm * (((haris_uint32_t)1 << float32_sigbits)\n"
" + 0.5f);\n"
"\n"
" exp = shift + ((1<<7) - 1); \n"
"\n"
" result = (sign<<31) | (exp<<23) | significand;\n"
" Finish:\n"
" haris_write_uint32(b, &result);\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_write_float64(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_float64 fnorm, f = *(const haris_float64*)_ptr;\n"
" const int float64_sigbits = 52;\n"
" int shift;\n"
" long sign, exp, significand;\n"
" haris_uint64_t result;\n"
"\n"
" if (f == 0.0) {\n"
" result = 0.0;\n"
" goto Finish;\n"
" }\n"
"\n"
" if (f < 0) {\n"
" sign = 1; \n"
" fnorm = -f; \n"
" } else { \n"
" sign = 0; \n"
" fnorm = f; \n"
" }\n"
"\n"
" shift = 0;\n"
" while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n"
" while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n"
" fnorm = fnorm - 1.0;\n"
"\n"
" significand = fnorm * (((haris_uint64_t)1<<float64_sigbits)\n"
" + 0.5f);\n"
"\n"
" exp = shift + ((1<<10) - 1); \n"
"\n"
" result = (sign<<63) | (exp<<52) | significand;\n"
" Finish:\n"
" haris_write_uint64(b, &result);\n"
"}\n"
"\n");
result = add_private_function(a1, v4);
if ( (_DWORD)result )
result = 4LL;
}
return result;
}

original_code:
static CJobStatus write_writefloat(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_write_float32(unsigned char *b, const void *_ptr)\n{\n  haris_float32 f = *(const haris_float32*)_ptr;\n  haris_float64 fnorm;\n  int shift;\n  const int float32_sigbits = 23;\n  long sign, exp, significand;\n  haris_uint32_t result;\n\n  if (f == 0.0) {\n    result = 0.0;\n    goto Finish;\n  } \n\n  if (f < 0) {\n    sign = 1; \n    fnorm = -f; \n  } else { \n    sign = 0; \n    fnorm = f; \n  }\n\n  shift = 0;\n  while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n  while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n  fnorm = fnorm - 1.0;\n\n  significand = fnorm * (((haris_uint32_t)1 << float32_sigbits)\n                          + 0.5f);\n\n  exp = shift + ((1<<7) - 1); \n\n  result = (sign<<31) | (exp<<23) | significand;\n  Finish:\n  haris_write_uint32(b, &result);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_float64(unsigned char *b, const void *_ptr)\n{\n  haris_float64 fnorm, f = *(const haris_float64*)_ptr;\n  const int float64_sigbits = 52;\n  int shift;\n  long sign, exp, significand;\n  haris_uint64_t result;\n\n  if (f == 0.0) {\n    result = 0.0;\n    goto Finish;\n  }\n\n  if (f < 0) {\n    sign = 1; \n    fnorm = -f; \n  } else { \n    sign = 0; \n    fnorm = f; \n  }\n\n  shift = 0;\n  while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n  while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n  fnorm = fnorm - 1.0;\n\n  significand = fnorm * (((haris_uint64_t)1<<float64_sigbits)\n                         + 0.5f);\n\n  exp = shift + ((1<<10) - 1); \n\n  result = (sign<<63) | (exp<<52) | significand;\n  Finish:\n  haris_write_uint64(b, &result);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_writefloat(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_write_float32(unsigned char *b, const void *_ptr)\n{\n  haris_float32 f = *(const haris_float32*)_ptr;\n  haris_float64 fnorm;\n  int shift;\n  const int float32_sigbits = 23;\n  long sign, exp, significand;\n  haris_uint32_t result;\n\n  if (f == 0.0) {\n    result = 0.0;\n    goto Finish;\n  } \n\n  if (f < 0) {\n    sign = 1; \n    fnorm = -f; \n  } else { \n    sign = 0; \n    fnorm = f; \n  }\n\n  shift = 0;\n  while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n  while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n  fnorm = fnorm - 1.0;\n\n  significand = fnorm * (((haris_uint32_t)1 << float32_sigbits)\n                          + 0.5f);\n\n  exp = shift + ((1<<7) - 1); \n\n  result = (sign<<31) | (exp<<23) | significand;\n  Finish:\n  haris_write_uint32(b, &result);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_float64(unsigned char *b, const void *_ptr)\n{\n  haris_float64 fnorm, f = *(const haris_float64*)_ptr;\n  const int float64_sigbits = 52;\n  int shift;\n  long sign, exp, significand;\n  haris_uint64_t result;\n\n  if (f == 0.0) {\n    result = 0.0;\n    goto Finish;\n  }\n\n  if (f < 0) {\n    sign = 1; \n    fnorm = -f; \n  } else { \n    sign = 0; \n    fnorm = f; \n  }\n\n  shift = 0;\n  while (fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n  while (fnorm < 1.0) { fnorm *= 2.0; shift--; }\n  fnorm = fnorm - 1.0;\n\n  significand = fnorm * (((haris_uint64_t)1<<float64_sigbits)\n                         + 0.5f);\n\n  exp = shift + ((1<<10) - 1); \n\n  result = (sign<<63) | (exp<<52) | significand;\n  Finish:\n  haris_write_uint64(b, &result);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}


decompiled_code:
__int64 __fastcall write_readfloat(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax

v1 = strformat(
"static void haris_read_float32(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_float32 *ptr = (haris_float32*)_ptr;\n"
" const int float32_sigbits = 23, float32_bias = 127;\n"
" haris_float64 result;\n"
" haris_int64_t shift;\n"
" haris_uint32_t i;\n"
" haris_read_uint32(b, &i);\n"
" \n"
" if (i == 0) { *ptr = 0.0; return; }\n"
" \n"
" result = (i & (((haris_uint32_t)1 << float32_sigbits) - 1));\n"
" result /= ((haris_uint32_t)1 << float32_sigbits); \n"
" result += 1.0;\n"
"\n"
" shift = ((i >> float32_sigbits) & 255) - float32_bias;\n"
" while (shift > 0) { result *= 2.0; shift--; }\n"
" while (shift < 0) { result /= 2.0; shift++; }\n"
"\n"
" result *= (i >> 31) & 1 ? -1.0: 1.0;\n"
"\n"
" *ptr = (haris_float32)result;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_read_float64(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_float64 result, *ptr = (haris_float64*)_ptr;\n"
" const int float64_sigbits = 52, float64_bias = 1023;\n"
" haris_int64_t shift;\n"
" haris_uint64_t i;\n"
" haris_read_uint64(b, &i);\n"
" \n"
" if (i == 0) { *ptr = 0.0; return; }\n"
" \n"
" result = (i & (((haris_uint64_t)1 << float64_sigbits) - 1));\n"
" result /= ((haris_uint64_t)1 << float64_sigbits); \n"
" result += 1.0;\n"
"\n"
" shift = ((i >> float64_sigbits) & 2047) - float64_bias;\n"
" while (shift > 0) { result *= 2.0; shift--; }\n"
" while (shift < 0) { result /= 2.0; shift++; }\n"
"\n"
" result *= (i >> 63) & 1 ? -1.0: 1.0;\n"
"\n"
" *ptr = result;\n"
"}\n"
"\n");
result = add_private_function(a1, v4);
if ( (_DWORD)result )
result = 4LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax

v1 = strformat(
"static void haris_read_float32(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_float32 *ptr = (haris_float32*)_ptr;\n"
" const int float32_sigbits = 23, float32_bias = 127;\n"
" haris_float64 result;\n"
" haris_int64_t shift;\n"
" haris_uint32_t i;\n"
" haris_read_uint32(b, &i);\n"
" \n"
" if (i == 0) { *ptr = 0.0; return; }\n"
" \n"
" result = (i & (((haris_uint32_t)1 << float32_sigbits) - 1));\n"
" result /= ((haris_uint32_t)1 << float32_sigbits); \n"
" result += 1.0;\n"
"\n"
" shift = ((i >> float32_sigbits) & 255) - float32_bias;\n"
" while (shift > 0) { result *= 2.0; shift--; }\n"
" while (shift < 0) { result /= 2.0; shift++; }\n"
"\n"
" result *= (i >> 31) & 1 ? -1.0: 1.0;\n"
"\n"
" *ptr = (haris_float32)result;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_read_float64(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_float64 result, *ptr = (haris_float64*)_ptr;\n"
" const int float64_sigbits = 52, float64_bias = 1023;\n"
" haris_int64_t shift;\n"
" haris_uint64_t i;\n"
" haris_read_uint64(b, &i);\n"
" \n"
" if (i == 0) { *ptr = 0.0; return; }\n"
" \n"
" result = (i & (((haris_uint64_t)1 << float64_sigbits) - 1));\n"
" result /= ((haris_uint64_t)1 << float64_sigbits); \n"
" result += 1.0;\n"
"\n"
" shift = ((i >> float64_sigbits) & 2047) - float64_bias;\n"
" while (shift > 0) { result *= 2.0; shift--; }\n"
" while (shift < 0) { result /= 2.0; shift++; }\n"
"\n"
" result *= (i >> 63) & 1 ? -1.0: 1.0;\n"
"\n"
" *ptr = result;\n"
"}\n"
"\n");
result = add_private_function(a1, v4);
if ( (_DWORD)result )
result = 4LL;
}
return result;
}

original_code:
static CJobStatus write_readfloat(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_read_float32(const unsigned char *b, void *_ptr)\n{\n  haris_float32 *ptr = (haris_float32*)_ptr;\n  const int float32_sigbits = 23, float32_bias = 127;\n  haris_float64 result;\n  haris_int64_t shift;\n  haris_uint32_t i;\n  haris_read_uint32(b, &i);\n  \n  if (i == 0) { *ptr = 0.0; return; }\n  \n  result = (i & (((haris_uint32_t)1 << float32_sigbits) - 1));\n  result /= ((haris_uint32_t)1 << float32_sigbits); \n  result += 1.0;\n\n  shift = ((i >> float32_sigbits) & 255) - float32_bias;\n  while (shift > 0) { result *= 2.0; shift--; }\n  while (shift < 0) { result /= 2.0; shift++; }\n\n  result *= (i >> 31) & 1 ? -1.0: 1.0;\n\n  *ptr = (haris_float32)result;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_float64(const unsigned char *b, void *_ptr)\n{\n  haris_float64 result, *ptr = (haris_float64*)_ptr;\n  const int float64_sigbits = 52, float64_bias = 1023;\n  haris_int64_t shift;\n  haris_uint64_t i;\n  haris_read_uint64(b, &i);\n  \n  if (i == 0) { *ptr = 0.0; return; }\n  \n  result = (i & (((haris_uint64_t)1 << float64_sigbits) - 1));\n  result /= ((haris_uint64_t)1 << float64_sigbits); \n  result += 1.0;\n\n  shift = ((i >> float64_sigbits) & 2047) - float64_bias;\n  while (shift > 0) { result *= 2.0; shift--; }\n  while (shift < 0) { result /= 2.0; shift++; }\n\n  result *= (i >> 63) & 1 ? -1.0: 1.0;\n\n  *ptr = result;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_readfloat(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_read_float32(const unsigned char *b, void *_ptr)\n{\n  haris_float32 *ptr = (haris_float32*)_ptr;\n  const int float32_sigbits = 23, float32_bias = 127;\n  haris_float64 result;\n  haris_int64_t shift;\n  haris_uint32_t i;\n  haris_read_uint32(b, &i);\n  \n  if (i == 0) { *ptr = 0.0; return; }\n  \n  result = (i & (((haris_uint32_t)1 << float32_sigbits) - 1));\n  result /= ((haris_uint32_t)1 << float32_sigbits); \n  result += 1.0;\n\n  shift = ((i >> float32_sigbits) & 255) - float32_bias;\n  while (shift > 0) { result *= 2.0; shift--; }\n  while (shift < 0) { result /= 2.0; shift++; }\n\n  result *= (i >> 31) & 1 ? -1.0: 1.0;\n\n  *ptr = (haris_float32)result;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_float64(const unsigned char *b, void *_ptr)\n{\n  haris_float64 result, *ptr = (haris_float64*)_ptr;\n  const int float64_sigbits = 52, float64_bias = 1023;\n  haris_int64_t shift;\n  haris_uint64_t i;\n  haris_read_uint64(b, &i);\n  \n  if (i == 0) { *ptr = 0.0; return; }\n  \n  result = (i & (((haris_uint64_t)1 << float64_sigbits) - 1));\n  result /= ((haris_uint64_t)1 << float64_sigbits); \n  result += 1.0;\n\n  shift = ((i >> float64_sigbits) & 2047) - float64_bias;\n  while (shift > 0) { result *= 2.0; shift--; }\n  while (shift < 0) { result /= 2.0; shift++; }\n\n  result *= (i >> 63) & 1 ? -1.0: 1.0;\n\n  *ptr = result;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}


decompiled_code:
__int64 __fastcall write_writeuint(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // edx
__int64 v6; // rax
int v7; // edx
__int64 v8; // rax
int v9; // edx
__int64 v10; // rax

v1 = strformat(
"static void haris_write_uint8(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint8_t i = *(const haris_uint8_t*)_ptr;\n"
" *b = i;\n"
" return;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_write_uint16(unsigned char *b, const void *_ptr)\n"
"{ \n"
" haris_uint16_t i = *(const haris_uint16_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" return;\n"
"}\n"
"\n");
v5 = add_private_function(a1, v4);
result = 4LL;
if ( !v5 )
{
v6 = strformat(
"static void haris_write_uint24(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" *(b+2) = i >> 16;\n"
" return;\n"
"}\n"
"\n");
v7 = add_private_function(a1, v6);
result = 4LL;
if ( !v7 )
{
v8 = strformat(
"static void haris_write_uint32(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" *(b+2) = i >> 16;\n"
" *(b+3) = i >> 24;\n"
" return;\n"
"}\n"
"\n");
v9 = add_private_function(a1, v8);
result = 4LL;
if ( !v9 )
{
v10 = strformat(
"static void haris_write_uint64(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint64_t i = *(const haris_uint64_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" *(b+2) = i >> 16;\n"
" *(b+3) = i >> 24;\n"
" *(b+4) = i >> 32;\n"
" *(b+5) = i >> 40;\n"
" *(b+6) = i >> 48;\n"
" *(b+7) = i >> 56;\n"
" return;\n"
"}\n"
"\n");
result = add_private_function(a1, v10);
if ( (_DWORD)result )
result = 4LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // edx
__int64 v6; // rax
int v7; // edx
__int64 v8; // rax
int v9; // edx
__int64 v10; // rax

v1 = strformat(
"static void haris_write_uint8(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint8_t i = *(const haris_uint8_t*)_ptr;\n"
" *b = i;\n"
" return;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_write_uint16(unsigned char *b, const void *_ptr)\n"
"{ \n"
" haris_uint16_t i = *(const haris_uint16_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" return;\n"
"}\n"
"\n");
v5 = add_private_function(a1, v4);
result = 4LL;
if ( !v5 )
{
v6 = strformat(
"static void haris_write_uint24(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" *(b+2) = i >> 16;\n"
" return;\n"
"}\n"
"\n");
v7 = add_private_function(a1, v6);
result = 4LL;
if ( !v7 )
{
v8 = strformat(
"static void haris_write_uint32(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" *(b+2) = i >> 16;\n"
" *(b+3) = i >> 24;\n"
" return;\n"
"}\n"
"\n");
v9 = add_private_function(a1, v8);
result = 4LL;
if ( !v9 )
{
v10 = strformat(
"static void haris_write_uint64(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_uint64_t i = *(const haris_uint64_t*)_ptr;\n"
" *b = i;\n"
" *(b+1) = i >> 8;\n"
" *(b+2) = i >> 16;\n"
" *(b+3) = i >> 24;\n"
" *(b+4) = i >> 32;\n"
" *(b+5) = i >> 40;\n"
" *(b+6) = i >> 48;\n"
" *(b+7) = i >> 56;\n"
" return;\n"
"}\n"
"\n");
result = add_private_function(a1, v10);
if ( (_DWORD)result )
result = 4LL;
}
}
}
}
return result;
}

original_code:
static CJobStatus write_writeuint(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_write_uint8(unsigned char *b, const void *_ptr)\n{\n  haris_uint8_t i = *(const haris_uint8_t*)_ptr;\n  *b = i;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint16(unsigned char *b, const void *_ptr)\n{  \n  haris_uint16_t i = *(const haris_uint16_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint24(unsigned char *b, const void *_ptr)\n{\n  haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  *(b+2) = i >> 16;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint32(unsigned char *b, const void *_ptr)\n{\n  haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  *(b+2) = i >> 16;\n  *(b+3) = i >> 24;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint64(unsigned char *b, const void *_ptr)\n{\n  haris_uint64_t i = *(const haris_uint64_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  *(b+2) = i >> 16;\n  *(b+3) = i >> 24;\n  *(b+4) = i >> 32;\n  *(b+5) = i >> 40;\n  *(b+6) = i >> 48;\n  *(b+7) = i >> 56;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_writeuint(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_write_uint8(unsigned char *b, const void *_ptr)\n{\n  haris_uint8_t i = *(const haris_uint8_t*)_ptr;\n  *b = i;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint16(unsigned char *b, const void *_ptr)\n{  \n  haris_uint16_t i = *(const haris_uint16_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint24(unsigned char *b, const void *_ptr)\n{\n  haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  *(b+2) = i >> 16;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint32(unsigned char *b, const void *_ptr)\n{\n  haris_uint32_t i = *(const haris_uint32_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  *(b+2) = i >> 16;\n  *(b+3) = i >> 24;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_uint64(unsigned char *b, const void *_ptr)\n{\n  haris_uint64_t i = *(const haris_uint64_t*)_ptr;\n  *b = i;\n  *(b+1) = i >> 8;\n  *(b+2) = i >> 16;\n  *(b+3) = i >> 24;\n  *(b+4) = i >> 32;\n  *(b+5) = i >> 40;\n  *(b+6) = i >> 48;\n  *(b+7) = i >> 56;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}


decompiled_code:
__int64 __fastcall write_writeint(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // edx
__int64 v6; // rax
int v7; // edx
__int64 v8; // rax

v1 = strformat(
"static void haris_write_int8(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int8_t i = *(const haris_int8_t*)_ptr;\n"
" if (i >= 0)\n"
" *b = (unsigned char)i;\n"
" else\n"
" *b = ~(unsigned char)(-i) + (unsigned char)1;\n"
" return;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_write_int16(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int16_t i = *(const haris_int16_t*)_ptr;\n"
" haris_uint16_t ui;\n"
" if (i >= 0)\n"
" ui = (haris_uint16_t)i;\n"
" else\n"
" ui = ~(haris_uint16_t)(-i) + 1;\n"
" haris_write_uint16(b, &ui);\n"
" return;\n"
"}\n"
"\n");
v5 = add_private_function(a1, v4);
result = 4LL;
if ( !v5 )
{
v6 = strformat(
"static void haris_write_int32(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int32_t i = *(const haris_int32_t*)_ptr;\n"
" haris_uint32_t ui;\n"
" if (i >= 0)\n"
" ui = (haris_uint32_t)i;\n"
" else\n"
" ui = ~(haris_uint32_t)(-i) + 1;\n"
" haris_write_uint32(b, &ui);\n"
" return;\n"
"}\n"
"\n");
v7 = add_private_function(a1, v6);
result = 4LL;
if ( !v7 )
{
v8 = strformat(
"static void haris_write_int64(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int64_t i = *(const haris_int64_t*)_ptr;\n"
" haris_uint64_t ui;\n"
" if (i >= 0)\n"
" ui = (haris_uint64_t)i;\n"
" else\n"
" ui = ~(haris_uint64_t)(-i) + 1;\n"
" haris_write_uint64(b, &ui);\n"
" return;\n"
"}\n"
"\n");
result = add_private_function(a1, v8);
if ( (_DWORD)result )
result = 4LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // edx
__int64 v6; // rax
int v7; // edx
__int64 v8; // rax

v1 = strformat(
"static void haris_write_int8(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int8_t i = *(const haris_int8_t*)_ptr;\n"
" if (i >= 0)\n"
" *b = (unsigned char)i;\n"
" else\n"
" *b = ~(unsigned char)(-i) + (unsigned char)1;\n"
" return;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_write_int16(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int16_t i = *(const haris_int16_t*)_ptr;\n"
" haris_uint16_t ui;\n"
" if (i >= 0)\n"
" ui = (haris_uint16_t)i;\n"
" else\n"
" ui = ~(haris_uint16_t)(-i) + 1;\n"
" haris_write_uint16(b, &ui);\n"
" return;\n"
"}\n"
"\n");
v5 = add_private_function(a1, v4);
result = 4LL;
if ( !v5 )
{
v6 = strformat(
"static void haris_write_int32(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int32_t i = *(const haris_int32_t*)_ptr;\n"
" haris_uint32_t ui;\n"
" if (i >= 0)\n"
" ui = (haris_uint32_t)i;\n"
" else\n"
" ui = ~(haris_uint32_t)(-i) + 1;\n"
" haris_write_uint32(b, &ui);\n"
" return;\n"
"}\n"
"\n");
v7 = add_private_function(a1, v6);
result = 4LL;
if ( !v7 )
{
v8 = strformat(
"static void haris_write_int64(unsigned char *b, const void *_ptr)\n"
"{\n"
" haris_int64_t i = *(const haris_int64_t*)_ptr;\n"
" haris_uint64_t ui;\n"
" if (i >= 0)\n"
" ui = (haris_uint64_t)i;\n"
" else\n"
" ui = ~(haris_uint64_t)(-i) + 1;\n"
" haris_write_uint64(b, &ui);\n"
" return;\n"
"}\n"
"\n");
result = add_private_function(a1, v8);
if ( (_DWORD)result )
result = 4LL;
}
}
}
return result;
}

original_code:
static CJobStatus write_writeint(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_write_int8(unsigned char *b, const void *_ptr)\n{\n  haris_int8_t i = *(const haris_int8_t*)_ptr;\n  if (i >= 0)\n    *b = (unsigned char)i;\n  else\n    *b = ~(unsigned char)(-i) + (unsigned char)1;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_int16(unsigned char *b, const void *_ptr)\n{\n  haris_int16_t i = *(const haris_int16_t*)_ptr;\n  haris_uint16_t ui;\n  if (i >= 0)\n    ui = (haris_uint16_t)i;\n  else\n    ui = ~(haris_uint16_t)(-i) + 1;\n  haris_write_uint16(b, &ui);\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_int32(unsigned char *b, const void *_ptr)\n{\n  haris_int32_t i = *(const haris_int32_t*)_ptr;\n  haris_uint32_t ui;\n  if (i >= 0)\n    ui = (haris_uint32_t)i;\n  else\n    ui = ~(haris_uint32_t)(-i) + 1;\n  haris_write_uint32(b, &ui);\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_int64(unsigned char *b, const void *_ptr)\n{\n  haris_int64_t i = *(const haris_int64_t*)_ptr;\n  haris_uint64_t ui;\n  if (i >= 0)\n    ui = (haris_uint64_t)i;\n  else\n    ui = ~(haris_uint64_t)(-i) + 1;\n  haris_write_uint64(b, &ui);\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_writeint(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_write_int8(unsigned char *b, const void *_ptr)\n{\n  haris_int8_t i = *(const haris_int8_t*)_ptr;\n  if (i >= 0)\n    *b = (unsigned char)i;\n  else\n    *b = ~(unsigned char)(-i) + (unsigned char)1;\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_int16(unsigned char *b, const void *_ptr)\n{\n  haris_int16_t i = *(const haris_int16_t*)_ptr;\n  haris_uint16_t ui;\n  if (i >= 0)\n    ui = (haris_uint16_t)i;\n  else\n    ui = ~(haris_uint16_t)(-i) + 1;\n  haris_write_uint16(b, &ui);\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_int32(unsigned char *b, const void *_ptr)\n{\n  haris_int32_t i = *(const haris_int32_t*)_ptr;\n  haris_uint32_t ui;\n  if (i >= 0)\n    ui = (haris_uint32_t)i;\n  else\n    ui = ~(haris_uint32_t)(-i) + 1;\n  haris_write_uint32(b, &ui);\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_write_int64(unsigned char *b, const void *_ptr)\n{\n  haris_int64_t i = *(const haris_int64_t*)_ptr;\n  haris_uint64_t ui;\n  if (i >= 0)\n    ui = (haris_uint64_t)i;\n  else\n    ui = ~(haris_uint64_t)(-i) + 1;\n  haris_write_uint64(b, &ui);\n  return;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}


decompiled_code:
__int64 __fastcall write_readuint(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // edx
__int64 v6; // rax
int v7; // edx
__int64 v8; // rax
int v9; // edx
__int64 v10; // rax

v1 = strformat(
"static void haris_read_uint8(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint8_t *ptr = (haris_uint8_t*)_ptr;\n"
" *ptr = *b;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_read_uint16(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint16_t *ptr = (haris_uint16_t*)_ptr;\n"
" *ptr = ((haris_uint16_t)b[0]) | ((haris_uint16_t)b[1] << 8);\n"
"}\n"
"\n");
v5 = add_private_function(a1, v4);
result = 4LL;
if ( !v5 )
{
v6 = strformat(
"static void haris_read_uint24(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n"
" *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n"
" ((haris_uint32_t)b[2] << 16);\n"
"}\n"
"\n");
v7 = add_private_function(a1, v6);
result = 4LL;
if ( !v7 )
{
v8 = strformat(
"static void haris_read_uint32(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n"
" *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n"
" ((haris_uint32_t)b[2] << 16) | ((haris_uint32_t)b[3] << 24);\n"
"}\n"
"\n");
v9 = add_private_function(a1, v8);
result = 4LL;
if ( !v9 )
{
v10 = strformat(
"static void haris_read_uint64(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint64_t *ptr = (haris_uint64_t*)_ptr;\n"
" *ptr = ((haris_uint64_t)b[0]) | ((haris_uint64_t)b[1] << 8) |\n"
" ((haris_uint64_t)b[2] << 16) | ((haris_uint64_t)b[3] << 24) |\n"
" ((haris_uint64_t)b[4] << 32) | ((haris_uint64_t)b[5] << 40) |\n"
" ((haris_uint64_t)b[6] << 48) | ((haris_uint64_t)b[7] << 56);\n"
"}\n"
"\n");
result = add_private_function(a1, v10);
if ( (_DWORD)result )
result = 4LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // rax
int v2; // edx
__int64 result; // rax
__int64 v4; // rax
int v5; // edx
__int64 v6; // rax
int v7; // edx
__int64 v8; // rax
int v9; // edx
__int64 v10; // rax

v1 = strformat(
"static void haris_read_uint8(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint8_t *ptr = (haris_uint8_t*)_ptr;\n"
" *ptr = *b;\n"
"}\n"
"\n");
v2 = add_private_function(a1, v1);
result = 4LL;
if ( !v2 )
{
v4 = strformat(
"static void haris_read_uint16(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint16_t *ptr = (haris_uint16_t*)_ptr;\n"
" *ptr = ((haris_uint16_t)b[0]) | ((haris_uint16_t)b[1] << 8);\n"
"}\n"
"\n");
v5 = add_private_function(a1, v4);
result = 4LL;
if ( !v5 )
{
v6 = strformat(
"static void haris_read_uint24(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n"
" *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n"
" ((haris_uint32_t)b[2] << 16);\n"
"}\n"
"\n");
v7 = add_private_function(a1, v6);
result = 4LL;
if ( !v7 )
{
v8 = strformat(
"static void haris_read_uint32(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n"
" *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n"
" ((haris_uint32_t)b[2] << 16) | ((haris_uint32_t)b[3] << 24);\n"
"}\n"
"\n");
v9 = add_private_function(a1, v8);
result = 4LL;
if ( !v9 )
{
v10 = strformat(
"static void haris_read_uint64(const unsigned char *b, void *_ptr)\n"
"{\n"
" haris_uint64_t *ptr = (haris_uint64_t*)_ptr;\n"
" *ptr = ((haris_uint64_t)b[0]) | ((haris_uint64_t)b[1] << 8) |\n"
" ((haris_uint64_t)b[2] << 16) | ((haris_uint64_t)b[3] << 24) |\n"
" ((haris_uint64_t)b[4] << 32) | ((haris_uint64_t)b[5] << 40) |\n"
" ((haris_uint64_t)b[6] << 48) | ((haris_uint64_t)b[7] << 56);\n"
"}\n"
"\n");
result = add_private_function(a1, v10);
if ( (_DWORD)result )
result = 4LL;
}
}
}
}
return result;
}

original_code:
static CJobStatus write_readuint(CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_read_uint8(const unsigned char *b, void *_ptr)\n{\n  haris_uint8_t *ptr = (haris_uint8_t*)_ptr;\n  *ptr = *b;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint16(const unsigned char *b, void *_ptr)\n{\n  haris_uint16_t *ptr = (haris_uint16_t*)_ptr;\n  *ptr = ((haris_uint16_t)b[0]) | ((haris_uint16_t)b[1] << 8);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint24(const unsigned char *b, void *_ptr)\n{\n  haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n  *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n    ((haris_uint32_t)b[2] << 16);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint32(const unsigned char *b, void *_ptr)\n{\n  haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n  *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n    ((haris_uint32_t)b[2] << 16) | ((haris_uint32_t)b[3] << 24);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint64(const unsigned char *b, void *_ptr)\n{\n  haris_uint64_t *ptr = (haris_uint64_t*)_ptr;\n  *ptr = ((haris_uint64_t)b[0]) | ((haris_uint64_t)b[1] << 8) |\n    ((haris_uint64_t)b[2] << 16) | ((haris_uint64_t)b[3] << 24) |\n    ((haris_uint64_t)b[4] << 32) | ((haris_uint64_t)b[5] << 40) |\n    ((haris_uint64_t)b[6] << 48) | ((haris_uint64_t)b[7] << 56);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}

canonical_original_code:
static enum CJobStatus write_readuint(struct CJob *job)
{
  do { if (add_private_function(job, strformat("static void haris_read_uint8(const unsigned char *b, void *_ptr)\n{\n  haris_uint8_t *ptr = (haris_uint8_t*)_ptr;\n  *ptr = *b;\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint16(const unsigned char *b, void *_ptr)\n{\n  haris_uint16_t *ptr = (haris_uint16_t*)_ptr;\n  *ptr = ((haris_uint16_t)b[0]) | ((haris_uint16_t)b[1] << 8);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint24(const unsigned char *b, void *_ptr)\n{\n  haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n  *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n    ((haris_uint32_t)b[2] << 16);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint32(const unsigned char *b, void *_ptr)\n{\n  haris_uint32_t *ptr = (haris_uint32_t*)_ptr;\n  *ptr = ((haris_uint32_t)b[0]) | ((haris_uint32_t)b[1] << 8) |\n    ((haris_uint32_t)b[2] << 16) | ((haris_uint32_t)b[3] << 24);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  do { if (add_private_function(job, strformat("static void haris_read_uint64(const unsigned char *b, void *_ptr)\n{\n  haris_uint64_t *ptr = (haris_uint64_t*)_ptr;\n  *ptr = ((haris_uint64_t)b[0]) | ((haris_uint64_t)b[1] << 8) |\n    ((haris_uint64_t)b[2] << 16) | ((haris_uint64_t)b[3] << 24) |\n    ((haris_uint64_t)b[4] << 32) | ((haris_uint64_t)b[5] << 40) |\n    ((haris_uint64_t)b[6] << 48) | ((haris_uint64_t)b[7] << 56);\n}\n\n")) != CJOB_SUCCESS) return CJOB_MEM_ERROR; } while (0);
  return CJOB_SUCCESS;
}