main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
struct timespec tp; // [rsp+0h] [rbp-20h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-10h] BYREF
int v5; // [rsp+1Ch] [rbp-4h]

fd = open("/dev/midi1", 1, envp);
pthread_create(&newthread, 0LL, getTap, 0LL);
while ( 1 )
{
v5 = 0;
pthread_mutex_lock(&mutex);
do
{
if ( bTap == 1 )
break;
clock_gettime(0, &tp);
tp.tv_sec += period_ns / 1000000000;
tp.tv_nsec += period_ns % 1000000000;
if ( tp.tv_nsec > 1000000000 )
{
++tp.tv_sec;
tp.tv_nsec -= 1000000000LL;
}
v5 = pthread_cond_timedwait(&cond, &mutex, &tp);
}
while ( v5 != 110 );
tick();
bTap = 0;
pthread_mutex_unlock(&mutex);
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
struct timespec tp; // [rsp+0h] [rbp-20h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-10h] BYREF
int v5; // [rsp+1Ch] [rbp-4h]

fd = open("/dev/midi1", 1, envp);
pthread_create(&newthread, 0LL, getTap, 0LL);
while ( 1 )
{
v5 = 0;
pthread_mutex_lock(&mutex);
do
{
if ( bTap == 1 )
break;
clock_gettime(0, &tp);
tp.tv_sec += period_ns / 1000000000;
tp.tv_nsec += period_ns % 1000000000;
if ( tp.tv_nsec > 1000000000 )
{
++tp.tv_sec;
tp.tv_nsec -= 1000000000LL;
}
v5 = pthread_cond_timedwait(&cond, &mutex, &tp);
}
while ( v5 != 110 );
func7();
bTap = 0;
pthread_mutex_unlock(&mutex);
}
}

original_code:
int main(int argc, char *argv[]) {
  int my_private_data = 12;
  struct ukorg_callbacks my_callbacks = {
    on_tick,
    on_prog_msg
  };
  ukorg_register_listener(&my_callbacks,&my_private_data);
  ukorg_start();
  getchar();
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct ukorg_callbacks { void (*on_tick)(void *); void (*on_prog_msg)(struct _ProgMsg { char name[12]; char pad1[2]; char trigger; char pattern; char voiceMode; char scale; char pad2; char delaySync; char delayTime; char delayDepth; char delayType; char modLfoSpeed; char modDepth; char modType; char eqHiFreq; char eqHiGain; char eqLoFreq; char eqLoGain; char arpTempo[2]; char arpOnOff; char arpType; char arpGateTime; char arpResolution; char arpSwing; char kbdOctave; union { struct _LayeredParams { struct _SynthParams { char midiChannel; char assignMode; char unisonDetune; char pitchTune; char pitchBendRange; char pitchBendTranspose; char pitchVibratoInt; char osc1Wave; char osc1WaveformCtrl1; char osc1WaveformCtrl2; char osc1DgwsWave; char pad1; char osc2Wave; char osc2Semitone; char osc2Tune; char portamentoTime; char osc1Level; char osc2Level; char noiseLevel; char filterType; char filterCutoff; char filterResonance; char filterEg1Int; char filterVelocitySense; char filterKbdTrack; char ampLevel; char ampPanpot; char ampDistortion; char ampVelocitySense; char ampKeyboardTrack; char eg1Attack; char eg1Decay; char eg1Sustain; char eg1Release; char eg2Attack; char eg2Decay; char eg2Sustain; char eg2Release; char lfo1Wave; char lfo1Freq; char lfo1Sync; char lfo2Wave; char lfo2Freq; char lfo2Sync; char patch1SrcDst; char patch1Int; char patch2SrcDst; char patch2Int; char patch3SrcDst; char patch3Int; char patch4SrcDst; char patch4Int; char pad2[56]; } timbre[2]; } synths; struct _VocoderParams {  } vocoder; } params; } *, void *); }

user_defined_types: struct ukorg_callbacks { void (*on_tick)(void *); void (*on_prog_msg)(struct _ProgMsg *, void *); }

user_defined_types: struct _ProgMsg { char name[12]; char pad1[2]; char trigger; char pattern; char voiceMode; char scale; char pad2; char delaySync; char delayTime; char delayDepth; char delayType; char modLfoSpeed; char modDepth; char modType; char eqHiFreq; char eqHiGain; char eqLoFreq; char eqLoGain; char arpTempo[2]; char arpOnOff; char arpType; char arpGateTime; char arpResolution; char arpSwing; char kbdOctave; union { struct _LayeredParams synths; struct _VocoderParams vocoder; } params; }

user_defined_types: struct _LayeredParams { struct _SynthParams timbre[2]; }


decompiled_code:
int __fastcall nuevo_evento(void *ptr)
{
FILE *v1; // rax

v1 = fopen("eventos.dat", "ab");
file = v1;
if ( !v1 )
return puts("error: no se pudo abrir el archivo");
fwrite(ptr, 0xBCuLL, 1uLL, v1);
fclose(file);
return printf("Evento #%d creado exitosamente!\n", *(unsigned int *)ptr);
}

canonical_decompiled_code:
int __fastcall func1(void *ptr)
{
FILE *v1; // rax

v1 = fopen("eventos.dat", "ab");
file = v1;
if ( !v1 )
return puts("error: no se pudo abrir el archivo");
fwrite(ptr, 0xBCuLL, 1uLL, v1);
fclose(file);
return printf("Evento #%d creado exitosamente!\n", *(unsigned int *)ptr);
}

original_code:
void nuevo_evento(evento * ptr_evento)
{
 file = fopen("eventos.dat", "ab");
 if(file == ((void *)0)) printf("error: no se pudo abrir el archivo\n");
 else
 {
  fwrite(ptr_evento, sizeof(evento), 1, file);
  fclose(file);
  printf("Evento #%d creado exitosamente!\n", ptr_evento->id);
 }
}

canonical_original_code:
void nuevo_evento(struct _evento *ptr_evento)
{
 file = fopen("eventos.dat", "ab");
 if(file == ((void *)0)) printf("error: no se pudo abrir el archivo\n");
 else
 {
  fwrite(ptr_evento, sizeof(evento), 1, file);
  fclose(file);
  printf("Evento #%d creado exitosamente!\n", ptr_evento->id);
 }
}

variable_types: struct _evento { int id; char titl[60]; char desc[120]; int estado; } *

return_type: void


decompiled_code:
void mostrar_evento()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void mostrar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void mostrar_evento(struct _evento *ptr_evento)
{
}

user_defined_types: struct _evento { int id; char titl[60]; char desc[120]; int estado; }


decompiled_code:
void eliminar_evento()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void eliminar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void eliminar_evento(struct _evento *ptr_evento)
{
}


decompiled_code:
void modificar_evento()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void modificar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void modificar_evento(struct _evento *ptr_evento)
{
}


decompiled_code:
void concretar_evento()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void concretar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void concretar_evento(struct _evento *ptr_evento)
{
}


decompiled_code:
void listar_eventos()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void listar_eventos()
{
}

canonical_original_code:
void listar_eventos()
{
}


decompiled_code:
void vaciar_eventos()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void vaciar_eventos()
{
}

canonical_original_code:
void vaciar_eventos()
{
}


repo: dagit/Cyclone-Language

decompiled_code:
void term_reset_stats()
{
term_stats = 0LL;
*((_DWORD *)&term_stats + 2) = 0;
}

canonical_decompiled_code:
void func0()
{
term_stats = 0LL;
*((_DWORD *)&term_stats + 2) = 0;
}

original_code:
static void term_reset_stats(void)
{
  term_stats.fresh = 0;
  term_stats.fresh_small = 0;
  term_stats.fresh_large = 0;
}

canonical_original_code:
static void term_reset_stats()
{
  term_stats.fresh = 0;
  term_stats.fresh_small = 0;
  term_stats.fresh_large = 0;
}


decompiled_code:
__int64 __fastcall term_fresh(__int64 a1)
{
LODWORD(term_stats) = term_stats + 1;
return tv_fresh(term_sort_region, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
LODWORD(term_stats) = term_stats + 1;
return tv_fresh(term_sort_region, a1);
}

original_code:
gen_e term_fresh(const char *name)
{
  term_stats.fresh++;
  return (gen_e)tv_fresh(term_sort_region,name);
}

canonical_original_code:
struct gen_e_ *term_fresh(char *name)
{
  term_stats.fresh++;
  return (struct gen_e_ *)tv_fresh(term_sort_region,name);
}

variable_types:
name
char *

return_type: struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *


decompiled_code:
__int64 __fastcall term_fresh_large(__int64 a1)
{
++*((_DWORD *)&term_stats + 2);
return tv_fresh_large(term_sort_region, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
++*((_DWORD *)&term_stats + 2);
return tv_fresh_large(term_sort_region, a1);
}

original_code:
gen_e term_fresh_large(const char *name)
{
  term_stats.fresh_large++;
  return (gen_e)tv_fresh_large(term_sort_region,name);
}

canonical_original_code:
struct gen_e_ *term_fresh_large(char *name)
{
  term_stats.fresh_large++;
  return (struct gen_e_ *)tv_fresh_large(term_sort_region,name);
}

user_defined_types: enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 }


decompiled_code:
__int64 __fastcall term_fresh_small(__int64 a1)
{
++HIDWORD(term_stats);
return tv_fresh_small(term_sort_region, a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
++HIDWORD(term_stats);
return tv_fresh_small(term_sort_region, a1);
}

original_code:
gen_e term_fresh_small(const char *name)
{
  term_stats.fresh_small++;
  return (gen_e)tv_fresh_small(term_sort_region,name);
}

canonical_original_code:
struct gen_e_ *term_fresh_small(char *name)
{
  term_stats.fresh_small++;
  return (struct gen_e_ *)tv_fresh_small(term_sort_region,name);
}


decompiled_code:
void *term_zero()
{
return &zero;
}

canonical_decompiled_code:
void *func5()
{
return &zero;
}

original_code:
gen_e term_zero(void)
{
  return (gen_e)&zero;
}

canonical_original_code:
struct gen_e_ *term_zero()
{
  return (gen_e)&zero;
}


decompiled_code:
void *term_one()
{
return &one;
}

canonical_decompiled_code:
void *func6()
{
return &one;
}

original_code:
gen_e term_one(void)
{
  return (gen_e)&one;
}

canonical_original_code:
struct gen_e_ *term_one()
{
  return (gen_e)&one;
}


decompiled_code:
void *term_wild()
{
return &wild;
}

canonical_decompiled_code:
void *func7()
{
return &wild;
}

original_code:
gen_e term_wild(void)
{
  return (gen_e)&wild;
}

canonical_original_code:
struct gen_e_ *term_wild()
{
  return (gen_e)&wild;
}


decompiled_code:
__int64 __fastcall term_constant(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // r12
int v5; // eax
int v6[8]; // [rsp+8h] [rbp-20h] BYREF

v6[0] = 4;
v1 = _rc_rstrdup(banshee_nonptr_region, a1);
v6[1] = stamp_string(v1);
result = term_hash_find(term_sort_hash, v6, 2LL);
if ( !result )
{
v3 = _rc_ralloc_small0(term_constant_region, 24LL);
*(_DWORD *)(v3 + 4) = 4;
v4 = v3;
v5 = stamp_fresh();
*(_QWORD *)(v4 + 16) = v1;
*(_DWORD *)(v4 + 8) = v5;
term_hash_insert(term_sort_hash, v4, v6, 2LL);
result = v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax
__int64 v3; // rax
__int64 v4; // r12
int v5; // eax
int v6[8]; // [rsp+8h] [rbp-20h] BYREF

v6[0] = 4;
v1 = _rc_rstrdup(banshee_nonptr_region, a1);
v6[1] = stamp_string(v1);
result = term_hash_find(term_sort_hash, v6, 2LL);
if ( !result )
{
v3 = _rc_ralloc_small0(term_constant_region, 24LL);
*(_DWORD *)(v3 + 4) = 4;
v4 = v3;
v5 = stamp_fresh();
*(_QWORD *)(v4 + 16) = v1;
*(_DWORD *)(v4 + 8) = v5;
term_hash_insert(term_sort_hash, v4, v6, 2LL);
result = v4;
}
return result;
}

original_code:
gen_e term_constant(const char *str)
{
  stamp st[2];
  gen_e result;
  char *name = (((void)0), __rc_rstrdup)(banshee_nonptr_region,str);
  ((void) (0));
  st[0] = 4;
  st[1] = stamp_string(name);
  if ( (result = term_hash_find(term_sort_hash,st,2)) == ((void *)0))
    {
      term_constant_ c = (sizeof(struct term_constant_) < (1 << (13 - 3)) ? (((void)0), __rc_ralloc_small0)((term_constant_region), sizeof(struct term_constant_)) : (((void)0), __rc_typed_ralloc)((term_constant_region), sizeof(struct term_constant_), 0));
      c->type = 4;
      c->st = stamp_fresh();
      c->name = name;
      result = (gen_e) c;
      term_hash_insert(term_sort_hash,result,st,2);
      return result;
    }
  else
    {
      return result;
    }
}

canonical_original_code:
struct gen_e_ *term_constant(char *str)
{
  int st[2];
  struct gen_e_ *result;
  char *name = (((void)0), __rc_rstrdup)(banshee_nonptr_region,str);
  ((void) (0));
  st[0] = 4;
  st[1] = stamp_string(name);
  if ( (result = term_hash_find(term_sort_hash,st,2)) == ((void *)0))
    {
      struct term_constant_ *c = (sizeof(struct term_constant_) < (1 << (13 - 3)) ? (((void)0), __rc_ralloc_small0)((term_constant_region), sizeof(struct term_constant_)) : (((void)0), __rc_typed_ralloc)((term_constant_region), sizeof(struct term_constant_), 0));
      c->type = 4;
      c->st = stamp_fresh();
      c->name = name;
      result = (struct gen_e_ *) c;
      term_hash_insert(term_sort_hash,result,st,2);
      return result;
    }
  else
    {
      return result;
    }
}

variable_types:
str
char *

variable_types:
st
int [2]

variable_types: struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *

variable_types: struct term_constant_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; int type; int st; char *name; } *

user_defined_types: struct term_constant_ { enum sort_kind sort; int type; int st; char *name; }


decompiled_code:
bool __fastcall term_is_initial_var(__int64 a1)
{
return *(_DWORD *)(a1 + 4) == -1;
}

canonical_decompiled_code:
bool __fastcall func9(__int64 a1)
{
return *(_DWORD *)(a1 + 4) == -1;
}

original_code:
bool term_is_initial_var(gen_e e)
{
  return ((gen_term)e)->type == -1;
}

canonical_original_code:
unsigned char term_is_initial_var(struct gen_e_ *e)
{
  return ((struct gen_term *)e)->type == -1;
}

return_type: unsigned char

user_defined_types: struct gen_term { enum sort_kind sort; int type; int st; }


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

if ( *(_DWORD *)(a1 + 4) == -1 )
result = *(unsigned int *)(term_get_ecr(a1) + 8);
else
result = *(unsigned int *)(a1 + 8);
return result;
}

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

if ( *(_DWORD *)(a1 + 4) == -1 )
result = *(unsigned int *)(func10(a1) + 8);
else
result = *(unsigned int *)(a1 + 8);
return result;
}

original_code:
stamp term_get_stamp(gen_e e)
{
  if ( ((gen_term)e)->type == -1 )
    return ((gen_term)term_get_ecr(e))->st;
  else
    return ((gen_term)e)->st;
}

canonical_original_code:
int term_get_stamp(struct gen_e_ *e)
{
  if ( ((struct gen_term *)e)->type == -1 )
    return ((struct gen_term *)term_get_ecr(e))->st;
  else
    return ((struct gen_term *)e)->st;
}

return_type: int


decompiled_code:
bool __fastcall term_is_zero(__int64 a1)
{
return *(_DWORD *)(term_get_ecr(a1) + 4) == 0;
}

canonical_decompiled_code:
bool __fastcall func13(__int64 a1)
{
return *(_DWORD *)(func10(a1) + 4) == 0;
}

original_code:
bool term_is_zero(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 0);
}

canonical_original_code:
unsigned char term_is_zero(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 0);
}


decompiled_code:
bool __fastcall term_is_wild(__int64 a1)
{
return *(_DWORD *)(term_get_ecr(a1) + 4) == 6;
}

canonical_decompiled_code:
bool __fastcall func14(__int64 a1)
{
return *(_DWORD *)(func10(a1) + 4) == 6;
}

original_code:
bool term_is_wild(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 6);
}

canonical_original_code:
unsigned char term_is_wild(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 6);
}


decompiled_code:
bool __fastcall term_is_one(__int64 a1)
{
return *(_DWORD *)(term_get_ecr(a1) + 4) == 1;
}

canonical_decompiled_code:
bool __fastcall func15(__int64 a1)
{
return *(_DWORD *)(func10(a1) + 4) == 1;
}

original_code:
bool term_is_one(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 1);
}

canonical_original_code:
unsigned char term_is_one(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 1);
}


decompiled_code:
bool __fastcall term_is_var(__int64 a1)
{
return *(_DWORD *)(term_get_ecr(a1) + 4) == -1;
}

canonical_decompiled_code:
bool __fastcall func16(__int64 a1)
{
return *(_DWORD *)(func10(a1) + 4) == -1;
}

original_code:
bool term_is_var(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == -1);
}

canonical_original_code:
unsigned char term_is_var(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == -1);
}


decompiled_code:
bool __fastcall term_is_bottom(__int64 a1)
{
bool v1; // r8
bool result; // al

v1 = term_is_zero(a1);
result = 1;
if ( !v1 )
result = term_is_var(a1);
return result;
}

canonical_decompiled_code:
bool __fastcall func17(__int64 a1)
{
bool v1; // r8
bool result; // al

v1 = func13(a1);
result = 1;
if ( !v1 )
result = func16(a1);
return result;
}

original_code:
static bool term_is_bottom(gen_e e)
{
  return (term_is_zero(e) || term_is_var(e));
}

canonical_original_code:
static unsigned char term_is_bottom(struct gen_e_ *e)
{
  return (term_is_zero(e) || term_is_var(e));
}


decompiled_code:
bool __fastcall term_is_constant(__int64 a1)
{
return *(_DWORD *)(term_get_ecr(a1) + 4) == 4;
}

canonical_decompiled_code:
bool __fastcall func18(__int64 a1)
{
return *(_DWORD *)(func10(a1) + 4) == 4;
}

original_code:
bool term_is_constant(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 4);
}

canonical_original_code:
unsigned char term_is_constant(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 4);
}


decompiled_code:
__int64 __fastcall term_get_constant_name(__int64 a1)
{
__int64 v1; // rbx
bool v2; // r8
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
__int64 v1; // rbx
bool v2; // r8
__int64 result; // rax

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

original_code:
char *term_get_constant_name(gen_e e)
{
  gen_e ecr = term_get_ecr(e);
  if(! term_is_constant(ecr))
    return ((void *)0);
  else
    return ((term_constant_)ecr)->name;
}

canonical_original_code:
char *term_get_constant_name(struct gen_e_ *e)
{
  struct gen_e_ *ecr = term_get_ecr(e);
  if(! term_is_constant(ecr))
    return ((void *)0);
  else
    return ((struct term_constant_ *)ecr)->name;
}

return_type: char *


decompiled_code:
// attributes: thunk
bool __fastcall term_eq(__int64 a1, __int64 a2)
{
return eq(a1, a2);
}

canonical_decompiled_code:
bool __fastcall func20(__int64 a1, __int64 a2)
{
return func12(a1, a2);
}

original_code:
bool term_eq(gen_e e1, gen_e e2)
{
  return eq(e1,e2);
}

canonical_original_code:
unsigned char term_eq(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return eq(e1,e2);
}


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

term_rollback_info_region = newregion();
term_constant_region = newregion();
term_var_region = newregion();
term_sort_region = newregion();
result = make_term_hash(0LL);
term_sort_hash = result;
return result;
}

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

term_rollback_info_region = newregion();
term_constant_region = newregion();
term_var_region = newregion();
term_sort_region = newregion();
result = make_term_hash(0LL);
term_sort_hash = result;
return result;
}

original_code:
void term_init(void)
{
  term_rollback_info_region = newregion();
  term_constant_region = newregion();
  term_var_region = newregion();
  term_sort_region = newregion();
  term_sort_hash = make_term_hash(((void *)0));
}

canonical_original_code:
void term_init()
{
  term_rollback_info_region = newregion();
  term_constant_region = newregion();
  term_var_region = newregion();
  term_sort_region = newregion();
  term_sort_hash = make_term_hash(((void *)0));
}


decompiled_code:
__int64 term_reset()
{
term_hash_delete(term_sort_hash);
deleteregion(term_sort_region);
deleteregion(term_var_region);
deleteregion(term_constant_region);
deleteregion(term_rollback_info_region);
term_reset_stats();
return term_init();
}

canonical_decompiled_code:
__int64 func28()
{
term_hash_delete(term_sort_hash);
deleteregion(term_sort_region);
deleteregion(term_var_region);
deleteregion(term_constant_region);
deleteregion(term_rollback_info_region);
func0();
return func27();
}

original_code:
void term_reset(void)
{
  term_hash_delete(term_sort_hash);
  deleteregion(term_sort_region);
  deleteregion(term_var_region);
  deleteregion(term_constant_region);
  deleteregion(term_rollback_info_region);
  term_reset_stats();
  term_init();
}

canonical_original_code:
void term_reset()
{
  term_hash_delete(term_sort_hash);
  deleteregion(term_sort_region);
  deleteregion(term_var_region);
  deleteregion(term_constant_region);
  deleteregion(term_rollback_info_region);
  term_reset_stats();
  term_init();
}


decompiled_code:
__int64 term_set_fields()
{
return deserialize_set_obj(&term_current_rollback_info);
}

canonical_decompiled_code:
__int64 func37()
{
return deserialize_set_obj(&term_current_rollback_info);
}

original_code:
void term_set_fields(void)
{
  deserialize_set_obj((void **)&term_current_rollback_info);
}

canonical_original_code:
void term_set_fields()
{
  deserialize_set_obj((void **)&term_current_rollback_info);
}


eq

decompiled_code:
bool __fastcall eq(__int64 a1, __int64 a2)
{
int v2; // ebx

v2 = term_get_stamp(a1);
return v2 == (unsigned int)term_get_stamp(a2);
}

canonical_decompiled_code:
bool __fastcall func12(__int64 a1, __int64 a2)
{
int v2; // ebx

v2 = func11(a1);
return v2 == (unsigned int)func11(a2);
}

original_code:
static bool eq(gen_e e1, gen_e e2)
{
  return term_get_stamp(e1) == term_get_stamp(e2);
}

canonical_original_code:
static unsigned char eq(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return term_get_stamp(e1) == term_get_stamp(e2);
}


decompiled_code:
__int64 __fastcall check2(int a1)
{
if ( a1 <= 0x1FFFFFFF )
return (unsigned int)a1;
_fail("stamp.c", 64LL, "check2", "Unable to create a stamp with regular index\n");
return check1();
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
if ( a1 <= 0x1FFFFFFF )
return (unsigned int)a1;
_fail("stamp.c", 64LL, "check2", "Unable to create a stamp with regular index\n");
return func1();
}

original_code:
static inline stamp check2(int i)
{
  if (i > bounds2)
    __fail("stamp.c", 64, __FUNCTION__, "Unable to create a stamp with regular index\n");
  return i;
}

canonical_original_code:
static inline int check2(int i)
{
  if (i > bounds2)
    __fail("stamp.c", 64, __FUNCTION__, "Unable to create a stamp with regular index\n");
  return i;
}

variable_types: i int


decompiled_code:
__int64 __fastcall check1(unsigned int a1)
{
if ( a1 != 0x80000000 )
return a1;
_fail("stamp.c", 57LL, "check1", "Unable to create stamp with small index\n");
return check3();
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
if ( a1 != 0x80000000 )
return a1;
_fail("stamp.c", 57LL, "check1", "Unable to create stamp with small index\n");
return func2();
}

original_code:
static inline stamp check1(int i)
{
  if (i <= bounds1)
    __fail("stamp.c", 57, __FUNCTION__, "Unable to create stamp with small index\n");
  return i;
}

canonical_original_code:
static inline int check1(int i)
{
  if (i <= bounds1)
    __fail("stamp.c", 57, __FUNCTION__, "Unable to create stamp with small index\n");
  return i;
}


decompiled_code:
__int64 __fastcall check3(unsigned int a1)
{
if ( a1 != 0x7FFFFFFF )
return a1;
_fail("stamp.c", 71LL, "check3", "Unable to create a stamp with large index\n");
return new_stamp_list();
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
if ( a1 != 0x7FFFFFFF )
return a1;
_fail("stamp.c", 71LL, "check3", "Unable to create a stamp with large index\n");
return func3();
}

original_code:
static inline stamp check3(int i)
{
  if (i >= bounds3)
    __fail("stamp.c", 71, __FUNCTION__, "Unable to create a stamp with large index\n");
  return i;
}

canonical_original_code:
static inline int check3(int i)
{
  if (i >= bounds3)
    __fail("stamp.c", 71, __FUNCTION__, "Unable to create a stamp with large index\n");
  return i;
}


decompiled_code:
__int64 stamp_fresh()
{
return check2(++count2);
}

canonical_decompiled_code:
__int64 func31()
{
return func0(++count2);
}

original_code:
stamp stamp_fresh(void)
{
  return (check2(++count2));
}

canonical_original_code:
int stamp_fresh()
{
  return (check2(++count2));
}


decompiled_code:
__int64 stamp_fresh_small()
{
return check1(--count1);
}

canonical_decompiled_code:
__int64 func32()
{
return func1(--count1);
}

original_code:
stamp stamp_fresh_small(void)
{
  return (check1(--count1));
}

canonical_original_code:
int stamp_fresh_small()
{
  return (check1(--count1));
}


decompiled_code:
__int64 stamp_fresh_large()
{
return check3(++count3);
}

canonical_decompiled_code:
__int64 func33()
{
return func2(++count3);
}

original_code:
stamp stamp_fresh_large(void)
{
  return (check3(++count3));
}

canonical_original_code:
int stamp_fresh_large()
{
  return (check3(++count3));
}


decompiled_code:
__int64 __fastcall stamp_string(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !(unsigned __int8)hash_table_lookup(str_hash, a1, v2) )
{
v2[0] = stamp_fresh();
hash_table_insert(str_hash, a1, (int)v2[0]);
}
return v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func34(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !(unsigned __int8)hash_table_lookup(str_hash, a1, v2) )
{
v2[0] = func31();
hash_table_insert(str_hash, a1, (int)v2[0]);
}
return v2[0];
}

original_code:
stamp stamp_string(const char *str)
{
  int st;
  ((void) (0));
  if (! hash_table_lookup(str_hash,(hash_key)str, (hash_data *) &st))
    {
      st = stamp_fresh();
      (void)hash_table_insert(str_hash,(hash_key)str,(hash_data) st);
    }
  return st;
}

canonical_original_code:
int stamp_string(char *str)
{
  int st;
  ((void) (0));
  if (! hash_table_lookup(str_hash,(void *)str, (void **) &st))
    {
      st = stamp_fresh();
      (void)hash_table_insert(str_hash,(void *)str,(void *) st);
    }
  return st;
}

variable_types: st int


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

count1 = 0;
count2 = 2000;
count3 = 0x1FFFFFFF;
result = make_persistent_string_hash_table(32LL, 0LL);
str_hash = result;
return result;
}

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

count1 = 0;
count2 = 2000;
count3 = 0x1FFFFFFF;
result = make_persistent_string_hash_table(32LL, 0LL);
str_hash = result;
return result;
}

original_code:
void stamp_init(void)
{
  count1 = 0;
  count2 = 2000;
  count3 = 536870911;
  str_hash = make_persistent_string_hash_table(32,
            0);
}

canonical_original_code:
void stamp_init()
{
  count1 = 0;
  count2 = 2000;
  count3 = 536870911;
  str_hash = make_persistent_string_hash_table(32,
            0);
}


decompiled_code:
// attributes: thunk
__int64 stamp_reset()
{
return stamp_init();
}

canonical_decompiled_code:
__int64 func36()
{
return func35();
}

original_code:
void stamp_reset(void)
{
  stamp_init();
}

canonical_original_code:
void stamp_reset()
{
  stamp_init();
}


decompiled_code:
__int64 stamp_set_fields()
{
return deserialize_set_obj(&str_hash);
}

canonical_decompiled_code:
__int64 func40()
{
return deserialize_set_obj(&str_hash);
}

original_code:
void stamp_set_fields(void)
{
  deserialize_set_obj((void **)&str_hash);
}

canonical_original_code:
void stamp_set_fields()
{
  deserialize_set_obj((void **)&str_hash);
}


original_code:
unsigned long stamp_hash(hash_key key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

canonical_original_code:
unsigned long stamp_hash(void *key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

variable_types:
key
void *

variable_types:
keyval
unsigned long

return_type: unsigned long


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

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

original_code:
bool stamp_eq(hash_key s1, hash_key s2)
{
  return s1 == s2;
}

canonical_original_code:
unsigned char stamp_eq(void *s1, void *s2)
{
  return s1 == s2;
}


blowup

decompiled_code:
void __fastcall __noreturn blowup(char a1)
{
if ( (a1 & 1) != 0 )
longjmp(Lo_exception, 1);
longjmp(Hi_exception, 1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(char a1)
{
if ( (a1 & 1) != 0 )
longjmp(Lo_exception, 1);
longjmp(Hi_exception, 1);
}

original_code:
void blowup (int n) {
    if (n & 1) {
 longjmp(Lo_exception, 1);
    } else {
 longjmp(Hi_exception, 1);
    }
}

canonical_original_code:
void blowup(int n) {
    if (n & 1) {
 longjmp(Lo_exception, 1);
    } else {
 longjmp(Hi_exception, 1);
    }
}

variable_types: n int


decompiled_code:
int __fastcall lo_function(char a1)
{
int result; // eax

result = _setjmp(Lo_exception);
if ( !result )
blowup(a1);
++LO;
return result;
}

canonical_decompiled_code:
int __fastcall func8(char a1)
{
int result; // eax

result = _setjmp(Lo_exception);
if ( !result )
func7(a1);
++LO;
return result;
}

original_code:
void lo_function (volatile int n) {
    if (_setjmp (Lo_exception) != 0) {
 LO++;
    } else {
 blowup(n);
    }
}

canonical_original_code:
void lo_function(int n) {
    if (_setjmp (Lo_exception) != 0) {
 LO++;
    } else {
 blowup(n);
    }
}


decompiled_code:
int __fastcall hi_function(char a1)
{
int result; // eax

result = _setjmp(Hi_exception);
if ( !result )
return lo_function(a1);
++HI;
return result;
}

canonical_decompiled_code:
int __fastcall func9(char a1)
{
int result; // eax

result = _setjmp(Hi_exception);
if ( !result )
return func8(a1);
++HI;
return result;
}

original_code:
void hi_function (volatile int n) {
    if (_setjmp (Hi_exception) != 0) {
 HI++;
    } else {
 lo_function(n);
    }
}

canonical_original_code:
void hi_function(int n) {
    if (_setjmp (Hi_exception) != 0) {
 HI++;
    } else {
 lo_function(n);
    }
}


decompiled_code:
// attributes: thunk
int __fastcall some_function(char a1)
{
return hi_function(a1);
}

canonical_decompiled_code:
int __fastcall func10(char a1)
{
return func9(a1);
}

original_code:
void some_function (int n) {
    hi_function(n);
}

canonical_original_code:
void some_function(int n) {
    hi_function(n);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__time_t v4; // rsi
int v6; // [rsp+Ch] [rbp-2Ch]
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF
struct timeval v8; // [rsp+20h] [rbp-18h] BYREF

v3 = 1;
if ( argc == 2 )
v3 = atoi(argv[1]);
v6 = v3;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
v8.tv_sec = 0LL;
v8.tv_usec = 0LL;
gettimeofday(&tv, 0LL);
while ( v6 )
{
--v6;
some_function();
}
printf("Exceptions: HI=%d / LO=%d\n", (unsigned int)HI, (unsigned int)LO);
gettimeofday(&v8, 0LL);
v4 = v8.tv_sec - tv.tv_sec;
tv.tv_sec = v8.tv_sec - tv.tv_sec;
if ( v8.tv_usec - tv.tv_usec < 0 )
{
tv.tv_usec = v8.tv_usec - tv.tv_usec + 1000000;
tv.tv_sec = v4 - 1;
}
else
{
tv.tv_usec = v8.tv_usec - tv.tv_usec;
}
fprintf(_bss_start, "%d.%06d\n", tv.tv_sec, tv.tv_usec);
fflush(_bss_start);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__time_t v4; // rsi
int v6; // [rsp+Ch] [rbp-2Ch]
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF
struct timeval v8; // [rsp+20h] [rbp-18h] BYREF

v3 = 1;
if ( argc == 2 )
v3 = atoi(argv[1]);
v6 = v3;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
v8.tv_sec = 0LL;
v8.tv_usec = 0LL;
gettimeofday(&tv, 0LL);
while ( v6 )
{
--v6;
func10();
}
printf("Exceptions: HI=%d / LO=%d\n", (unsigned int)HI, (unsigned int)LO);
gettimeofday(&v8, 0LL);
v4 = v8.tv_sec - tv.tv_sec;
tv.tv_sec = v8.tv_sec - tv.tv_sec;
if ( v8.tv_usec - tv.tv_usec < 0 )
{
tv.tv_usec = v8.tv_usec - tv.tv_usec + 1000000;
tv.tv_sec = v4 - 1;
}
else
{
tv.tv_usec = v8.tv_usec - tv.tv_usec;
}
fprintf(_bss_start, "%d.%06d\n", tv.tv_sec, tv.tv_usec);
fflush(_bss_start);
return 0;
}

original_code:
int
main(int argc, char *argv[]) {
    int volatile N = ((argc == 2) ? atoi(argv[1]) : 1);
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    while (N) {
 some_function(N--);
    }
    printf("Exceptions: HI=%d / LO=%d\n", HI, LO);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

canonical_original_code:
int main(int argc, char *argv[]) {
    int N = ((argc == 2) ? atoi(argv[1]) : 1);
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    while (N) {
 some_function(N--);
    }
    printf("Exceptions: HI=%d / LO=%d\n", HI, LO);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

variable_types: N int

variable_types: struct timeval { long tv_sec; long tv_usec; }


hash

decompiled_code:
__int64 __fastcall hash(int a1, __int64 a2, int a3)
{
__int64 v5; // r9
__int64 v6; // rsi
int v7; // ecx
unsigned int v8; // er11
unsigned int v9; // eax
unsigned int v10; // edx

if ( a3 <= 0 )
return 0LL;
v5 = (unsigned int)(a3 + 1);
v6 = 1LL;
v7 = 83;
v8 = 0;
while ( 1 )
{
v9 = abs32(*(_DWORD *)(a2 + 4 * v6 - 4));
v10 = v6++;
v8 = a1 & (v8 + v7 * v9);
if ( v5 == v6 )
break;
v7 = primes[v10 % 0xF];
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, int a3)
{
__int64 v5; // r9
__int64 v6; // rsi
int v7; // ecx
unsigned int v8; // er11
unsigned int v9; // eax
unsigned int v10; // edx

if ( a3 <= 0 )
return 0LL;
v5 = (unsigned int)(a3 + 1);
v6 = 1LL;
v7 = 83;
v8 = 0;
while ( 1 )
{
v9 = abs32(*(_DWORD *)(a2 + 4 * v6 - 4));
v10 = v6++;
v8 = a1 & (v8 + v7 * v9);
if ( v5 == v6 )
break;
v7 = primes[v10 % 0xF];
}
return v8;
}

original_code:
static int hash(int ub, stamp stamps[], int len)
{
  int i, n;
  n = 0;
  for (i = 0; i < len; i++)
    {
      n = (n + (primes[i % 15] * abs(stamps[i]))) & ub;
    }
  return n;
}

canonical_original_code:
static int hash(int ub, int stamps[], int len)
{
  int i; int n;
  n = 0;
  for (i = 0; i < len; i++)
    {
      n = (n + (primes[i % 15] * abs(stamps[i]))) & ub;
    }
  return n;
}

variable_types: ub int

variable_types:
stamps
int []

variable_types: len int


rehash

original_code:
static void rehash(hash_set hs)
{
  int *old_table;
  int old_capacity, i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

canonical_original_code:
static void rehash(struct hash_set *hs)
{
  int *old_table;
  int old_capacity; int i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

variable_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; } *


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

result = (unsigned int)(*(_DWORD *)(a1 + 28) + 1);
*(_DWORD *)(a1 + 28) = result;
if ( *(_DWORD *)(a1 + 24) == (_DWORD)result )
result = rehash(a1);
return result;
}

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

result = (unsigned int)(*(_DWORD *)(a1 + 28) + 1);
*(_DWORD *)(a1 + 28) = result;
if ( *(_DWORD *)(a1 + 24) == (_DWORD)result )
result = func1(a1);
return result;
}

original_code:
static void post_insert(hash_set hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

canonical_original_code:
static void post_insert(struct hash_set *hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

variable_types: capacity int

variable_types: inserts int

user_defined_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; }


walk

decompiled_code:
const void ***__fastcall walk(const void ***a1, const void *a2, int a3)
{
const void ***v3; // r12
size_t v5; // r14
const void **v6; // rbx

if ( !a1 )
return 0LL;
v3 = a1;
v5 = 4LL * a3;
while ( 1 )
{
v6 = *v3;
if ( *(_DWORD *)*v3 == a3 && !memcmp(a2, v6[1], v5) )
break;
v3 = (const void ***)v3[1];
if ( !v3 )
return v3;
}
return (const void ***)v6[2];
}

canonical_decompiled_code:
const void ***__fastcall func3(const void ***a1, const void *a2, int a3)
{
const void ***v3; // r12
size_t v5; // r14
const void **v6; // rbx

if ( !a1 )
return 0LL;
v3 = a1;
v5 = 4LL * a3;
while ( 1 )
{
v6 = *v3;
if ( *(_DWORD *)*v3 == a3 && !memcmp(a2, v6[1], v5) )
break;
v3 = (const void ***)v3[1];
if ( !v3 )
return v3;
}
return (const void ***)v6[2];
}

original_code:
static gen_e walk(term_bucket b, stamp stamps[], int len)
{
  term_bucket cur;
  for(cur = b; cur; cur = cur->next)
    {
      if (len == cur->entry->length
   && (memcmp(stamps, cur->entry->stamps, sizeof(int)*len) == 0) )
 return cur->entry->e;
    }
  return ((void *)0);
}

canonical_original_code:
static struct gen_e_ *walk(struct term_bucket *b, int stamps[], int len)
{
  struct term_bucket *cur;
  for(cur = b; cur; cur = cur->next)
    {
      if (len == cur->entry->length
   && (memcmp(stamps, cur->entry->stamps, sizeof(int)*len) == 0) )
 return cur->entry->e;
    }
  return ((void *)0);
}

variable_types: struct term_bucket { struct hash_entry { int length; int *stamps; struct gen_e_ *e; } *entry; struct term_bucket *next; } *

variable_types: struct term_bucket { struct hash_entry { int length; int *stamps; struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *e; } *entry; struct term_bucket *next; } *

user_defined_types: struct term_bucket { struct hash_entry *entry; struct term_bucket *next; }


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

term_bucketptr_region = newregion();
term_bucket_region = newregion();
term_hash_region = newregion();
result = newregion();
hash_entry_region = result;
return result;
}

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

term_bucketptr_region = newregion();
term_bucket_region = newregion();
term_hash_region = newregion();
result = newregion();
hash_entry_region = result;
return result;
}

original_code:
void term_hash_init()
{
  term_bucketptr_region = newregion();
  term_bucket_region = newregion();
  term_hash_region = newregion();
  hash_entry_region = newregion();
}


decompiled_code:
__int64 term_hash_reset()
{
deleteregion(term_bucketptr_region);
deleteregion(term_bucket_region);
deleteregion(term_hash_region);
deleteregion(hash_entry_region);
return term_hash_init();
}

canonical_decompiled_code:
__int64 func10()
{
deleteregion(term_bucketptr_region);
deleteregion(term_bucket_region);
deleteregion(term_hash_region);
deleteregion(hash_entry_region);
return func9();
}

original_code:
void term_hash_reset()
{
  deleteregion(term_bucketptr_region);
  deleteregion(term_bucket_region);
  deleteregion(term_hash_region);
  deleteregion(hash_entry_region);
  term_hash_init();
}


startoutputingbits

decompiled_code:
void startoutputingbits()
{
S_buffer = 0;
S_bitstogo = 8;
}

canonical_decompiled_code:
void func2()
{
S_buffer = 0;
S_bitstogo = 8;
}


startinputingbits

decompiled_code:
void startinputingbits()
{
S_buffer = 0;
S_bitstogo = 0;
}

canonical_decompiled_code:
void func3()
{
S_buffer = 0;
S_bitstogo = 0;
}


doneoutputingbits

decompiled_code:
int doneoutputingbits()
{
int result; // eax

if ( S_bitstogo <= 7 )
{
result = putc(S_buffer >> S_bitstogo, stdout);
++cmpbytes;
}
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax

if ( S_bitstogo <= 7 )
{
result = putc(S_buffer >> S_bitstogo, stdout);
++cmpbytes;
}
return result;
}

original_code:
void
doneoutputingbits()
{
 if (S_bitstogo<8)
 {
  putc(S_buffer>>S_bitstogo, stdout);
  cmpbytes += 1;
 }
}


startencoding

decompiled_code:
void startencoding()
{
S_low = 0LL;
S_high = 0xFFFFLL;
S_bitstofollow = 0LL;
}

canonical_decompiled_code:
void func5()
{
S_low = 0LL;
S_high = 0xFFFFLL;
S_bitstofollow = 0LL;
}

original_code:
void
startencoding()
{
 S_low = 0;
 S_high = ((codevalue)((1<<16)-1));
 S_bitstofollow = 0;
}


startdecoding

decompiled_code:
__int64 __fastcall startdecoding()
{
__int64 result; // rax
int v1; // ebx
int v2; // edx
char v3; // cl

v1 = 16;
v2 = S_bitstogo;
S_low = 0LL;
S_high = 0xFFFFLL;
S_value = 0LL;
do
{
if ( v2 )
{
--v2;
}
else
{
LODWORD(result) = getc(stdin);
v2 = 7;
}
v3 = result;
result = (unsigned int)((int)result >> 1);
S_value = (v3 & 1) + 2 * S_value;
--v1;
}
while ( v1 );
S_bitstogo = v2;
S_buffer = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6()
{
__int64 result; // rax
int v1; // ebx
int v2; // edx
char v3; // cl

v1 = 16;
v2 = S_bitstogo;
S_low = 0LL;
S_high = 0xFFFFLL;
S_value = 0LL;
do
{
if ( v2 )
{
--v2;
}
else
{
LODWORD(result) = getc(stdin);
v2 = 7;
}
v3 = result;
result = (unsigned int)((int)result >> 1);
S_value = (v3 & 1) + 2 * S_value;
--v1;
}
while ( v1 );
S_bitstogo = v2;
S_buffer = result;
return result;
}

original_code:
void
startdecoding()
{
 register int i;
 register int buffer, bitstogo;
 S_low = 0;
 S_high = ((codevalue)((1<<16)-1));
 S_value = 0;
 bitstogo = S_bitstogo;
 for (i=0; i<16; i++)
  { if (bitstogo==0) { buffer = getc(stdin); bitstogo = 8; } S_value = (S_value<<1)+(buffer&1); buffer >>= 1; bitstogo -=1; };
 S_bitstogo = bitstogo;
 S_buffer = buffer;
}

canonical_original_code:
void startdecoding()
{
 register int i;
 register int buffer; register int bitstogo;
 S_low = 0;
 S_high = ((codevalue)((1<<16)-1));
 S_value = 0;
 bitstogo = S_bitstogo;
 for (i=0; i<16; i++)
  { if (bitstogo==0) { buffer = getc(stdin); bitstogo = 8; } S_value = (S_value<<1)+(buffer&1); buffer >>= 1; bitstogo -=1; };
 S_bitstogo = bitstogo;
 S_buffer = buffer;
}

variable_types: buffer int

variable_types: bitstogo int


doneencoding

decompiled_code:
__int64 doneencoding()
{
__int64 v0; // rbp
int v1; // ebx
__int64 result; // rax

v0 = S_bitstofollow + 1;
v1 = S_buffer >> 1;
result = (unsigned int)(S_bitstogo - 1);
if ( (unsigned __int64)S_low > 0x3FFF )
{
LOBYTE(v1) = v1 | 0x80;
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
if ( !v0 )
goto LABEL_4;
}
else if ( S_bitstofollow == -1 )
{
goto LABEL_4;
}
v1 >>= 1;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
goto LABEL_13;
while ( --v0 )
{
v1 >>= 1;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
LABEL_13:
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
}
}
else
{
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
if ( !v0 )
goto LABEL_4;
}
else if ( S_bitstofollow == -1 )
{
goto LABEL_4;
}
do
{
v1 >>= 1;
LOBYTE(v1) = v1 | 0x80;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
--v0;
}
while ( v0 );
}
LABEL_4:
S_buffer = v1;
S_bitstofollow = 0LL;
S_bitstogo = result;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rbp
int v1; // ebx
__int64 result; // rax

v0 = S_bitstofollow + 1;
v1 = S_buffer >> 1;
result = (unsigned int)(S_bitstogo - 1);
if ( (unsigned __int64)S_low > 0x3FFF )
{
LOBYTE(v1) = v1 | 0x80;
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
if ( !v0 )
goto LABEL_4;
}
else if ( S_bitstofollow == -1 )
{
goto LABEL_4;
}
v1 >>= 1;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
goto LABEL_13;
while ( --v0 )
{
v1 >>= 1;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
LABEL_13:
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
}
}
else
{
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
if ( !v0 )
goto LABEL_4;
}
else if ( S_bitstofollow == -1 )
{
goto LABEL_4;
}
do
{
v1 >>= 1;
LOBYTE(v1) = v1 | 0x80;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
--v0;
}
while ( v0 );
}
LABEL_4:
S_buffer = v1;
S_bitstofollow = 0LL;
S_bitstogo = result;
return result;
}

original_code:
void
doneencoding()
{
 register long bitstofollow;
 register int buffer, bitstogo;
 bitstofollow = S_bitstofollow;
 buffer = S_buffer;
 bitstogo = S_bitstogo;
 bitstofollow += 1;
 if (S_low<(((codevalue)((1<<16)-1))/4+1))
 {
  { { buffer >>= 1; if ((0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 else
 {
  { { buffer >>= 1; if ((1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 S_bitstofollow = bitstofollow;
 S_buffer = buffer;
 S_bitstogo = bitstogo;
}

canonical_original_code:
void doneencoding()
{
 register long bitstofollow;
 register int buffer; register int bitstogo;
 bitstofollow = S_bitstofollow;
 buffer = S_buffer;
 bitstogo = S_bitstogo;
 bitstofollow += 1;
 if (S_low<(((codevalue)((1<<16)-1))/4+1))
 {
  { { buffer >>= 1; if ((0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 else
 {
  { { buffer >>= 1; if ((1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 S_bitstofollow = bitstofollow;
 S_buffer = buffer;
 S_bitstogo = bitstogo;
}

variable_types: bitstofollow long


vfail

decompiled_code:
void __fastcall __noreturn vfail(char *format, __gnuc_va_list arg)
{
vfprintf(stderr, format, arg);
fflush(stderr);
fflush(stdout);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *format, __gnuc_va_list arg)
{
vfprintf(stderr, format, arg);
fflush(stderr);
fflush(stdout);
abort();
}

original_code:
static void vfail(const char *fmt, va_list args)
{
  vfprintf(stderr, fmt, args);
  fflush(stderr);
  fflush(stdout);
  abort();
  while (1);
}

canonical_original_code:
static void vfail(char *fmt, __builtin_va_list args)
{
  vfprintf(stderr, fmt, args);
  fflush(stderr);
  fflush(stdout);
  abort();
  while (1);
}

variable_types:
fmt
char *


xmalloc

decompiled_code:
void *__fastcall xmalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
xmalloc_cold();
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
func20();
return result;
}

original_code:
void *xmalloc(size_t size)
{
  void *x = malloc(size);
  if (!x) abort();
  return x;
}

canonical_original_code:
void *xmalloc(unsigned long size)
{
  void *x = malloc(size);
  if (!x) abort();
  return x;
}

variable_types:
size
unsigned long

variable_types:
x
void *

return_type: void *


xrealloc

decompiled_code:
void *__fastcall xrealloc(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
xrealloc_cold();
return result;
}

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

result = realloc(a1, a2);
if ( !result )
func21();
return result;
}

original_code:
void *xrealloc(void *p, size_t newsize)
{
  void *x = realloc(p, newsize);
  if (!x) abort();
  return x;
}

canonical_original_code:
void *xrealloc(void *p, unsigned long newsize)
{
  void *x = realloc(p, newsize);
  if (!x) abort();
  return x;
}

variable_types:
p
void *

variable_types:
newsize
unsigned long


decompiled_code:
__int64 __fastcall align_to(__int64 a1, unsigned __int64 a2)
{
return a2 * (int)((a2 + a1 - 1) / a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int64 a2)
{
return a2 * (int)((a2 + a1 - 1) / a2);
}

original_code:
unsigned long align_to(unsigned long n, unsigned long alignment)
{
  int count = (n + alignment - 1) / alignment;
  return count * alignment;
}

variable_types:
n
unsigned long

variable_types:
alignment
unsigned long

variable_types: count int


gcd

decompiled_code:
unsigned __int64 __fastcall gcd(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
unsigned __int64 i; // r8

v2 = a1;
v3 = a2;
for ( i = a1; v3; v2 = i )
{
i = v3;
v3 = v2 % v3;
}
return i;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
unsigned __int64 i; // r8

v2 = a1;
v3 = a2;
for ( i = a1; v3; v2 = i )
{
i = v3;
v3 = v2 % v3;
}
return i;
}

original_code:
unsigned long gcd(unsigned long x, unsigned long y)
{
  unsigned long z;
  for (;;)
    {
      if (y == 0)
 return x;
      z = x % y; x = y; y = z;
    }
}

variable_types:
x
unsigned long

variable_types:
y
unsigned long

variable_types:
z
unsigned long


lcm

decompiled_code:
unsigned __int64 __fastcall lcm(unsigned __int64 a1, unsigned __int64 a2)
{
return a2 * a1 / gcd(a1, a2);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int64 a1, unsigned __int64 a2)
{
return a2 * a1 / func4(a1, a2);
}

original_code:
unsigned long lcm(unsigned long x, unsigned long y)
{
  return (x * y) / gcd(x, y);
}


decompiled_code:
char *__fastcall ptr_to_ascii(const void *a1)
{
int v1; // eax

v1 = snprintf(addr_1, 0x13uLL, "%p", a1);
if ( v1 == -1 || v1 > 18 )
_fail(
"utils.c",
0xF3u,
(__int64)"ptr_to_ascii",
"Unable to convert ptr to ascii (need %d bytes, have %d)\n",
(unsigned int)v1,
19LL);
return addr_1;
}

canonical_decompiled_code:
char *__fastcall func12(const void *a1)
{
int v1; // eax

v1 = snprintf(addr_1, 0x13uLL, "%p", a1);
if ( v1 == -1 || v1 > 18 )
func6(
"utils.c",
0xF3u,
(__int64)"ptr_to_ascii",
"Unable to convert ptr to ascii (need %d bytes, have %d)\n",
(unsigned int)v1,
19LL);
return addr_1;
}

original_code:
char *ptr_to_ascii(void *ptr) {
  static char addr[((int) (3 + sizeof(void *)*2))];
  int nchars;
  nchars = snprintf(addr, ((int) (3 + sizeof(void *)*2)), "%p", ptr);
  if (nchars == -1 || nchars >= ((int) (3 + sizeof(void *)*2)))
    __fail("utils.c", 243, __FUNCTION__, "Unable to convert ptr to ascii (need %d bytes, have %d)\n", nchars, ((int) (3 + sizeof(void *)*2)));
  return addr;
}

canonical_original_code:
char *ptr_to_ascii(void *ptr) {
  static char addr[-1];
  int nchars;
  nchars = snprintf(addr, ((int) (3 + sizeof(void *)*2)), "%p", ptr);
  if (nchars == -1 || nchars >= ((int) (3 + sizeof(void *)*2)))
    __fail("utils.c", 243, __FUNCTION__, "Unable to convert ptr to ascii (need %d bytes, have %d)\n", nchars, ((int) (3 + sizeof(void *)*2)));
  return addr;
}

variable_types:
ptr
void *

variable_types:
addr
char [-1]

variable_types: nchars int


decompiled_code:
unsigned __int64 __fastcall ptr_hash(unsigned __int64 a1)
{
return a1 >> 3;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func13(unsigned __int64 a1)
{
return a1 >> 3;
}

original_code:
unsigned long ptr_hash(void *ptr)
{
  return (unsigned long) ptr >> 3;
}


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

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

original_code:
bool ptr_eq(void *ptr1, void *ptr2)
{
  return ptr1 == ptr2;
}

canonical_original_code:
unsigned char ptr_eq(void *ptr1, void *ptr2)
{
  return ptr1 == ptr2;
}


decompiled_code:
__int64 __fastcall string_hash(char *a1)
{
__int64 v1; // rax
__int64 i; // r8

if ( !a1 )
return 0LL;
v1 = *a1;
for ( i = 0LL; (_BYTE)v1; v1 = *a1 )
{
++a1;
i = 33 * i + v1 + 720;
}
return i;
}

original_code:
unsigned long string_hash(const char *str)
{
  const char *c;
  unsigned long h;
  c = str;
  h = 0;
  if (!c)
    return 0;
  while (*c)
    h = 33*h + 720 + *c++;
  return h;
}

canonical_original_code:
unsigned long string_hash(char *str)
{
  char *c;
  unsigned long h;
  c = str;
  h = 0;
  if (!c)
    return 0;
  while (*c)
    h = 33*h + 720 + *c++;
  return h;
}

variable_types:
str
char *

variable_types:
c
char *

variable_types:
h
unsigned long


decompiled_code:
bool __fastcall string_eq(const char *a1, const char *a2)
{
bool result; // al

if ( a1 && a2 )
result = strcmp(a1, a2) == 0;
else
result = 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func16(const char *a1, const char *a2)
{
bool result; // al

if ( a1 && a2 )
result = strcmp(a1, a2) == 0;
else
result = 0;
return result;
}

original_code:
bool string_eq(const char *s1, const char *s2)
{
  if (!s1 || !s2)
    return 0;
  return !strcmp(s1, s2);
}

canonical_original_code:
unsigned char string_eq(char *s1, char *s2)
{
  if (!s1 || !s2)
    return 0;
  return !strcmp(s1, s2);
}


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

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

original_code:
int ptr_cmp(void *ptr1, void *ptr2)
{
  return (char *) ptr1 - (char *) ptr2;
}


min

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

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

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

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

original_code: int min(int a, int b) { if (a < b) return a; else return b; }

variable_types: a int

variable_types: b int


max

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

result = a2;
if ( (int)a1 >= (int)a2 )
result = a1;
return result;
}

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

result = a2;
if ( (int)a1 >= (int)a2 )
result = a1;
return result;
}

original_code: int max(int a, int b) { if (a < b) return b; else return a; }


decompiled_code:
// attributes: thunk
__int64 banshee_serialize_end()
{
return serialize_end();
}

canonical_decompiled_code:
__int64 func5()
{
return serialize_end();
}

original_code:
void banshee_serialize_end()
{
  serialize_end();
}


decompiled_code:
// attributes: thunk
__int64 banshee_deserialize_end()
{
return deserialize_end();
}

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

original_code:
void banshee_deserialize_end(void)
{
  deserialize_end();
}

canonical_original_code:
void banshee_deserialize_end()
{
  deserialize_end();
}


decompiled_code:
__int64 gen_e_set_fields()
{
return 1LL;
}

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

original_code:
bool gen_e_set_fields(void *obj)
{
  return 1;
}

canonical_original_code:
unsigned char gen_e_set_fields(void *obj)
{
  return 1;
}

variable_types:
obj
void *


original_code:
void
do_heapsort(int n, double *ra) {
    int i, j;
    int ir = n;
    int l = (n >> 1) + 1;
    double rra;
    for (;;) {
 if (l > 1) {
     rra = ra[--l];
 } else {
     rra = ra[ir];
     ra[ir] = ra[1];
     if (--ir == 1) {
  ra[1] = rra;
  return;
     }
 }
 i = l;
 j = l << 1;
 while (j <= ir) {
     if (j < ir && ra[j] < ra[j+1]) { ++j; }
     if (rra < ra[j]) {
  ra[i] = ra[j];
  j += (i = j);
     } else {
  j = ir + 1;
     }
 }
 ra[i] = rra;
    }
}

canonical_original_code:
void do_heapsort(int n, double *ra) {
    int i; int j;
    int ir = n;
    int l = (n >> 1) + 1;
    double rra;
    for (;;) {
 if (l > 1) {
     rra = ra[--l];
 } else {
     rra = ra[ir];
     ra[ir] = ra[1];
     if (--ir == 1) {
  ra[1] = rra;
  return;
     }
 }
 i = l;
 j = l << 1;
 while (j <= ir) {
     if (j < ir && ra[j] < ra[j+1]) { ++j; }
     if (rra < ra[j]) {
  ra[i] = ra[j];
  j += (i = j);
     } else {
  j = ir + 1;
     }
 }
 ra[i] = rra;
    }
}

variable_types: n int

variable_types:
ra
double *

variable_types: i int

variable_types: j int

variable_types: ir int

variable_types: l int

variable_types: rra double


main

original_code:
int
main(int argc, char *argv[]) {
    int N = ((argc == 2) ? atoi(argv[1]) : 1);
    double *ary;
    int i;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    ary = (double *)malloc((N+1) * sizeof(double));
    for (i=1; i<=N; i++) {
 ary[i] = gen_random(1);
    }
    do_heapsort(N, ary);
    printf("%.10f\n", ary[N]);
    free(ary);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: N int

variable_types:
ary
double *

variable_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
double __fastcall gen_random(double a1)
{
last_0 = (3877 * last_0 + 29573) % 139968;
return (double)(int)last_0 * a1 / 139968.0;
}

canonical_decompiled_code:
double __fastcall func7(double a1)
{
last_0 = (3877 * last_0 + 29573) % 139968;
return (double)(int)last_0 * a1 / 139968.0;
}

original_code:
double
gen_random(double max) {
    static long last = 42;
    return( max * (last = (last * 3877 + 29573) % 139968) / 139968 );
}

variable_types: max double

variable_types: last long

return_type: double


original_code:
static unsigned long state_hash(hash_key key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

canonical_original_code:
static unsigned long state_hash(void *key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

variable_types:
key
void *

variable_types:
keyval
unsigned long


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

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

original_code:
static bool state_eq(hash_key state1, hash_key state2)
{
  return state1 == state2;
}

canonical_original_code:
static unsigned char state_eq(void *state1, void *state2)
{
  return state1 == state2;
}


decompiled_code:
void *regexp_calloc()
{
return calloc(1uLL, 0x30uLL);
}

canonical_decompiled_code:
void *func2()
{
return calloc(1uLL, 0x30uLL);
}

original_code:
static regexp regexp_calloc() {
  return (regexp) calloc (1, sizeof(struct regexp_));
}

canonical_original_code:
static struct regexp_ *regexp_calloc() {
  return (struct regexp_ *) calloc (1, sizeof(struct regexp_));
}

return_type: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; } *


decompiled_code:
void *__fastcall regexp_alloc_str(unsigned __int8 a1)
{
return malloc(a1);
}

canonical_decompiled_code:
void *__fastcall func3(unsigned __int8 a1)
{
return malloc(a1);
}

original_code:
static letter* regexp_alloc_str(unsigned char length) {
  return (unsigned char *) malloc (sizeof(letter) * length);
}

canonical_original_code:
static unsigned char *regexp_alloc_str(unsigned char length) {
  return (unsigned char *) malloc (sizeof(letter) * length);
}

variable_types:
length
unsigned char

return_type: unsigned char *


decompiled_code:
__int64 __fastcall regexp_print_subexpr(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
unsigned __int8 v3; // r13
__int64 v4; // rbp
__int64 v5; // rbx
unsigned __int64 v6; // r12
unsigned __int8 v7; // r15
unsigned __int8 v8; // r14
int v9; // edi
__int64 result; // rax

while ( 1 )
{
v3 = a3;
v4 = a1;
if ( a2 >= a3 )
break;
v5 = a2;
v6 = a2 + (unsigned __int64)(unsigned __int8)(a3 - 1 - a2) + 1;
while ( 1 )
{
v7 = v5;
v8 = v5 + 1;
v9 = *(unsigned __int8 *)(*(_QWORD *)(v4 + 8) + v5);
if ( v9 == 1 )
break;
putchar(v9);
if ( v6 == ++v5 )
goto LABEL_7;
}
LABEL_5:
putchar(40);
regexp_print_subexpr(
v4,
(unsigned __int8)(v7 + 2),
(unsigned __int8)(v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1)));
putchar(41);
putchar(42);
a3 = v3;
a1 = v4;
a2 = v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1) + 1;
}
v8 = a2;
LABEL_7:
result = *(_QWORD *)(v4 + 8);
v5 = v8;
if ( *(_BYTE *)(result + v8) == 1 )
{
v7 = v8;
goto LABEL_5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
unsigned __int8 v3; // r13
__int64 v4; // rbp
__int64 v5; // rbx
unsigned __int64 v6; // r12
unsigned __int8 v7; // r15
unsigned __int8 v8; // r14
int v9; // edi
__int64 result; // rax

while ( 1 )
{
v3 = a3;
v4 = a1;
if ( a2 >= a3 )
break;
v5 = a2;
v6 = a2 + (unsigned __int64)(unsigned __int8)(a3 - 1 - a2) + 1;
while ( 1 )
{
v7 = v5;
v8 = v5 + 1;
v9 = *(unsigned __int8 *)(*(_QWORD *)(v4 + 8) + v5);
if ( v9 == 1 )
break;
putchar(v9);
if ( v6 == ++v5 )
goto LABEL_7;
}
LABEL_5:
putchar(40);
func4(
v4,
(unsigned __int8)(v7 + 2),
(unsigned __int8)(v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1)));
putchar(41);
putchar(42);
a3 = v3;
a1 = v4;
a2 = v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1) + 1;
}
v8 = a2;
LABEL_7:
result = *(_QWORD *)(v4 + 8);
v5 = v8;
if ( *(_BYTE *)(result + v8) == 1 )
{
v7 = v8;
goto LABEL_5;
}
return result;
}

original_code:
static void regexp_print_subexpr(regexp r, unsigned char start,
     unsigned char end) {
  while (start < end && r->expr[start] != STAR) {
    putchar(r->expr[start]);
    start++;
  }
  if (r->expr[start] == STAR) {
    putchar('(');
    regexp_print_subexpr(r, start + 2, start + r->expr[start + 1]);
    putchar(')');
    putchar('*');
    regexp_print_subexpr(r, start + r->expr[start+1] + 1, end);
  }
}

canonical_original_code:
static void regexp_print_subexpr(struct regexp_ *r, unsigned char start, unsigned char end) {
  while (start < end && r->expr[start] != STAR) {
    putchar(r->expr[start]);
    start++;
  }
  if (r->expr[start] == STAR) {
    putchar('(');
    regexp_print_subexpr(r, start + 2, start + r->expr[start + 1]);
    putchar(')');
    putchar('*');
    regexp_print_subexpr(r, start + r->expr[start+1] + 1, end);
  }
}

variable_types: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; } *

variable_types:
start
unsigned char

variable_types:
end
unsigned char


decompiled_code:
_BYTE *regexp_empty()
{
_BYTE *v0; // rax
_BYTE *v1; // r12
_BYTE *v2; // rax

v0 = regexp_calloc();
*v0 = 0;
v1 = v0;
v2 = regexp_alloc_str(1u);
*((_QWORD *)v1 + 1) = v2;
*v2 = 0;
return v1;
}

original_code:
regexp regexp_empty() {
  regexp result = regexp_calloc();
  result->length = 0;
  result->expr = regexp_alloc_str(1);
  result->expr[0] = 0;
  return result;
}

canonical_original_code:
struct regexp_ *regexp_empty() {
  struct regexp_ *result = regexp_calloc();
  result->length = 0;
  result->expr = regexp_alloc_str(1);
  result->expr[0] = 0;
  return result;
}

user_defined_types: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; }


decompiled_code:
__int64 __fastcall regexp_fast_disinclusion(__int64 a1, __int64 a2)
{
return 2 * (unsigned int)(memcmp((const void *)(a1 + 16), (const void *)(a2 + 16), 0x20uLL) > 0) - 1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return 2 * (unsigned int)(memcmp((const void *)(a1 + 16), (const void *)(a2 + 16), 0x20uLL) > 0) - 1;
}

original_code:
int regexp_fast_disinclusion(regexp r1, regexp r2) {
  if (memcmp(r1->necessary, r2->necessary, sizeof(unsigned char) * 32) > 0) {
    return 1;
  }
  return -1;
}

canonical_original_code:
int regexp_fast_disinclusion(struct regexp_ *r1, struct regexp_ *r2) {
  if (memcmp(r1->necessary, r2->necessary, sizeof(unsigned char) * 32) > 0) {
    return 1;
  }
  return -1;
}


decompiled_code:
int __fastcall regexp_print_expr(unsigned __int8 *a1)
{
regexp_print_subexpr((__int64)a1, 0, *a1);
return fflush(stdout);
}

canonical_decompiled_code:
int __fastcall func10(unsigned __int8 *a1)
{
func4((__int64)a1, 0, *a1);
return fflush(stdout);
}

original_code:
void regexp_print_expr(regexp r) {
  regexp_print_subexpr(r, 0, r->length);
  fflush(stdout);
}

canonical_original_code:
void regexp_print_expr(struct regexp_ *r) {
  regexp_print_subexpr(r, 0, r->length);
  fflush(stdout);
}


decompiled_code:
int __fastcall regexp_print_necessary(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rax

v1 = 0LL;
printf("Necessary characters in %s:\n", *(const char **)(a1 + 8));
do
{
while ( 1 )
{
v2 = v1++;
v3 = bfx(a1 + 16, v1, 1LL);
if ( v3 )
break;
if ( v1 == 256 )
return v3;
}
LODWORD(v3) = printf("%c (%d) \n", v2, v2);
}
while ( v1 != 256 );
return v3;
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rax

v1 = 0LL;
printf("Necessary characters in %s:\n", *(const char **)(a1 + 8));
do
{
while ( 1 )
{
v2 = v1++;
v3 = bfx(a1 + 16, v1, 1LL);
if ( v3 )
break;
if ( v1 == 256 )
return v3;
}
LODWORD(v3) = printf("%c (%d) \n", v2, v2);
}
while ( v1 != 256 );
return v3;
}

original_code:
void regexp_print_necessary(regexp r) {
  int i;
  printf("Necessary characters in %s:\n", r->expr);
  for (i = 0; i < 256; i++) {
    if (bfx(r->necessary, i+1, 1)) {
      printf("%c (%d) \n",i, i);
    }
  }
}

canonical_original_code:
void regexp_print_necessary(struct regexp_ *r) {
  int i;
  printf("Necessary characters in %s:\n", r->expr);
  for (i = 0; i < 256; i++) {
    if (bfx(r->necessary, i+1, 1)) {
      printf("%c (%d) \n",i, i);
    }
  }
}

variable_types: i int


member

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

LODWORD(result) = *(_DWORD *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return 0LL;
while ( a4 != (_DWORD)result )
{
a3 = a2 & (a3 + 5189);
result = *(unsigned int *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return result;
}
return 1LL;
}

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

LODWORD(result) = *(_DWORD *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return 0LL;
while ( a4 != (_DWORD)result )
{
a3 = a2 & (a3 + 5189);
result = *(unsigned int *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return result;
}
return 1LL;
}

original_code:
static bool member(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  return 0;
}

canonical_original_code:
static unsigned char member(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  return 0;
}

variable_types:
table
int *

variable_types: ub int

variable_types: value int


reinsert

decompiled_code:
__int64 __fastcall reinsert(__int64 a1, int a2, int a3)
{
int i; // eax
__int64 result; // rax
_DWORD *v5; // rcx

for ( i = 83 * a3; ; i = result + 5189 )
{
result = a2 & (unsigned int)i;
v5 = (_DWORD *)(a1 + 4LL * (int)result);
if ( !*v5 )
break;
if ( a3 == *v5 )
return result;
}
*v5 = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3)
{
int i; // eax
__int64 result; // rax
_DWORD *v5; // rcx

for ( i = 83 * a3; ; i = result + 5189 )
{
result = a2 & (unsigned int)i;
v5 = (_DWORD *)(a1 + 4LL * (int)result);
if ( !*v5 )
break;
if ( a3 == *v5 )
return result;
}
*v5 = a3;
return result;
}

original_code:
static inline void reinsert(int *table, int ub, int value)
{
  int i;
  i = ub & (prime_1 * value);
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
}


decompiled_code:
__int64 __fastcall member_or_insert(__int64 a1, int a2, int a3, int a4)
{
_DWORD *v6; // rcx

while ( 1 )
{
v6 = (_DWORD *)(a1 + 4LL * a3);
if ( !*v6 )
{
*v6 = a4;
return 0LL;
}
if ( a4 == *v6 )
break;
a3 = a2 & (a3 + 5189);
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, int a3, int a4)
{
_DWORD *v6; // rcx

while ( 1 )
{
v6 = (_DWORD *)(a1 + 4LL * a3);
if ( !*v6 )
{
*v6 = a4;
return 0LL;
}
if ( a4 == *v6 )
break;
a3 = a2 & (a3 + 5189);
}
return 1LL;
}

original_code:
static bool member_or_insert(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
  return 0;
}

canonical_original_code:
static unsigned char member_or_insert(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
  return 0;
}


rehash

original_code:
static void rehash(hash_set hs)
{
  int *old_table;
  int old_capacity, i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

canonical_original_code:
static void rehash(struct hash_set *hs)
{
  int *old_table;
  int old_capacity; int i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

variable_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; } *


original_code:
static void post_insert(hash_set hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

canonical_original_code:
static void post_insert(struct hash_set *hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

variable_types: capacity int

variable_types: inserts int


decompiled_code:
__int64 __fastcall hs_num_items(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int hs_num_items(hash_set hs)
{
  return hs->inserts;
}

canonical_original_code:
int hs_num_items(struct hash_set *hs)
{
  return hs->inserts;
}


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

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

original_code:
int *hs_list_items(hash_set hs)
{
  return hs->table;
}

canonical_original_code:
int *hs_list_items(struct hash_set *hs)
{
  return hs->table;
}

return_type: int *


original_code:
bool hs_query(hash_set hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  return member(hs->table, ub, hash, entry);
}

canonical_original_code:
unsigned char hs_query(struct hash_set *hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  return member(hs->table, ub, hash, entry);
}

variable_types: entry int

variable_types: hash int


decompiled_code:
__int64 __fastcall hs_member(__int64 a1, int a2)
{
__int64 v2; // r9

if ( (unsigned __int8)member_or_insert(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 8) & (83 * abs32(a2)), a2) )
return 1LL;
post_insert(v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
__int64 v2; // r9

if ( (unsigned __int8)func2(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 8) & (83 * abs32(a2)), a2) )
return 1LL;
func4(v2);
return 0LL;
}

original_code:
bool hs_member(hash_set hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  if (member_or_insert(hs->table, ub, hash, entry))
    return 1;
  else
    {
      post_insert(hs);
      return 0;
    }
}

canonical_original_code:
unsigned char hs_member(struct hash_set *hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  if (member_or_insert(hs->table, ub, hash, entry))
    return 1;
  else
    {
      post_insert(hs);
      return 0;
    }
}


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

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

original_code:
void hs_delete(hash_set hs)
{
  free(hs->table);
}

canonical_original_code:
void hs_delete(struct hash_set *hs)
{
  free(hs->table);
}


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

added_edge_info_region = newregion();
result = newregion();
bounds_region = result;
return result;
}

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

added_edge_info_region = newregion();
result = newregion();
bounds_region = result;
return result;
}

original_code:
void bounds_init()
{
  added_edge_info_region = newregion();
  bounds_region = newregion();
}


decompiled_code:
__int64 bounds_reset()
{
deleteregion(bounds_region);
deleteregion(added_edge_info_region);
return bounds_init();
}

canonical_decompiled_code:
__int64 func20()
{
deleteregion(bounds_region);
deleteregion(added_edge_info_region);
return func19();
}

original_code:
void bounds_reset()
{
  deleteregion(bounds_region);
  deleteregion(added_edge_info_region);
  bounds_init();
}


Mother

original_code:
double Mother(unsigned long *pSeed)
{
 unsigned long number, number1, number2;
 short n, *p;
 unsigned short sNumber;
 if (mStart)
   {
    sNumber= *pSeed&0xFFFF;
    number = *pSeed&0x7FFFFFFF;
    p = mother1;
    for (n=18;n--;)
  {
   number=30903*sNumber+(number>>16);
   *p++=sNumber=number&0xFFFF;
   if (n==9) p = mother2;
  }
    mother1[0]&=0x7FFF;
    mother2[0]&=0x7FFF;
    mStart=0;
   }
 memmove(mother1+2,mother1+1,8*sizeof(short));
 memmove(mother2+2,mother2+1,8*sizeof(short));
 number1=mother1[0];
 number2=mother2[0];
 number1+=1941*mother1[2]+1860*mother1[3]+1812*mother1[4]+
 1776*mother1[5]+1492*mother1[6]+1215*mother1[7]+
 1066*mother1[8]+12013*mother1[9];
 number2+=1111*mother2[2]+2222*mother2[3]+3333*mother2[4]+
 4444*mother2[5]+5555*mother2[6]+6666*mother2[7]+
 7777*mother2[8]+9272*mother2[9];
 mother1[0]=number1/65536L;
 mother2[0]=number2/65536L;
 mother1[1]=0xFFFF&number1;
 mother2[1]=0xFFFF&number2;
 *pSeed=(((long)mother1[1])<<16)+(long)mother2[1];
 return ((double)*pSeed)/4294967295.0;
}

canonical_original_code:
double Mother(unsigned long *pSeed)
{
 unsigned long number; unsigned long number1; unsigned long number2;
 short n; short *p;
 unsigned short sNumber;
 if (mStart)
   {
    sNumber= *pSeed&0xFFFF;
    number = *pSeed&0x7FFFFFFF;
    p = mother1;
    for (n=18;n--;)
  {
   number=30903*sNumber+(number>>16);
   *p++=sNumber=number&0xFFFF;
   if (n==9) p = mother2;
  }
    mother1[0]&=0x7FFF;
    mother2[0]&=0x7FFF;
    mStart=0;
   }
 memmove(mother1+2,mother1+1,8*sizeof(short));
 memmove(mother2+2,mother2+1,8*sizeof(short));
 number1=mother1[0];
 number2=mother2[0];
 number1+=1941*mother1[2]+1860*mother1[3]+1812*mother1[4]+
 1776*mother1[5]+1492*mother1[6]+1215*mother1[7]+
 1066*mother1[8]+12013*mother1[9];
 number2+=1111*mother2[2]+2222*mother2[3]+3333*mother2[4]+
 4444*mother2[5]+5555*mother2[6]+6666*mother2[7]+
 7777*mother2[8]+9272*mother2[9];
 mother1[0]=number1/65536L;
 mother2[0]=number2/65536L;
 mother1[1]=0xFFFF&number1;
 mother2[1]=0xFFFF&number2;
 *pSeed=(((long)mother1[1])<<16)+(long)mother2[1];
 return ((double)*pSeed)/4294967295.0;
}

variable_types:
pSeed
unsigned long *

variable_types:
number
unsigned long

variable_types: n short

variable_types:
p
short *

variable_types:
sNumber
unsigned short


shuffle

original_code:
int shuffle()
{
 int i, j, k, l, m, n;
 unsigned long kr = 3141592;
 double r, scale, Mother();
 scale = 1.0;
 j = 52 * 4;
 r = (double)j * scale;
 k = 10 * j;
 for (i = 1; i <= k; i++)
    {
     m = (int)(r * Mother(&kr));
     n = (int)(r * Mother(&kr));
     l = card[n];
     card[n] = card[m];
     card[m] = l;
    }
 return 0;
}

canonical_original_code:
int shuffle()
{
 int i; int j; int k; int l; int m; int n;
 unsigned long kr = 3141592;
 double r; double scale; double Mother();
 scale = 1.0;
 j = 52 * 4;
 r = (double)j * scale;
 k = 10 * j;
 for (i = 1; i <= k; i++)
    {
     m = (int)(r * Mother(&kr));
     n = (int)(r * Mother(&kr));
     l = card[n];
     card[n] = card[m];
     card[m] = l;
    }
 return 0;
}

variable_types: j int

variable_types: k int

variable_types: l int

variable_types: m int

variable_types: n int

variable_types:
kr
unsigned long

variable_types: r double

variable_types: scale double

variable_types:
Mother
double ()


main

original_code:
int main(int argc, char* argv[])
{
 int i, j, k, m, n;
 int ICard, NCards, NShuf, shuffle();
 double x, y;
 char cname[13][10] = { "ACE", "TWO", "THREE",
    "FOUR", "FIVE", "SIX",
    "SEVEN", "EIGHT", "NINE",
    "TEN", "JACK", "QUEEN",
    "KING"
    };
 NCards = 52 * 4;
 NShuf = 26000;
 ICard = 103;
 if (argc > 1)
  NShuf = atoi(argv[1]);
 for (i = 0; i < 14; i++)
    {
     suit[i] = 0;
    }
 printf("SHUFFLE: Test of Random Number Generator.\n");
 printf("Counts number of occurrences of card type at position\n");
 printf("%d in card deck for %d shuffles. Ideal would be\n",ICard,NShuf);
 printf("%d occurrences for each type of card.\n", NShuf/13);
 printf(" Card   Number    Percent\n");
 printf(" value  observed  from ideal\n");
 for (k = 0; k < 4; k++)
    {
     n = 52 * k;
     for (j = 0; j < 4; j++)
   {
    m = 13 * j + n;
    for (i = 1; i < 14; i++)
  {
   card[i + m - 1] = i;
  }
   }
    }
 shuffle();
 for (i = 1; i <= NShuf; i++)
    {
     shuffle();
     j = card[ICard];
     suit[j] = suit[j] + 1;
    }
 j = 0;
 y = 13.0 / (double)NShuf;
 for (i = 1; i < 14; i++)
    {
     k = suit[i];
     x = 100.0 * ((double)k * y - 1.0);
     printf("%5s   %5d    %5.1f\n",cname[i-1],k,x);
     j = j + k;
    }
 printf("Total Cards = %d\n",j);
 return(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int i; int j; int k; int m; int n;
 int ICard; int NCards; int NShuf; int shuffle();
 double x; double y;
 char cname[13][10] = { "ACE", "TWO", "THREE",
    "FOUR", "FIVE", "SIX",
    "SEVEN", "EIGHT", "NINE",
    "TEN", "JACK", "QUEEN",
    "KING"
    };
 NCards = 52 * 4;
 NShuf = 26000;
 ICard = 103;
 if (argc > 1)
  NShuf = atoi(argv[1]);
 for (i = 0; i < 14; i++)
    {
     suit[i] = 0;
    }
 printf("SHUFFLE: Test of Random Number Generator.\n");
 printf("Counts number of occurrences of card type at position\n");
 printf("%d in card deck for %d shuffles. Ideal would be\n",ICard,NShuf);
 printf("%d occurrences for each type of card.\n", NShuf/13);
 printf(" Card   Number    Percent\n");
 printf(" value  observed  from ideal\n");
 for (k = 0; k < 4; k++)
    {
     n = 52 * k;
     for (j = 0; j < 4; j++)
   {
    m = 13 * j + n;
    for (i = 1; i < 14; i++)
  {
   card[i + m - 1] = i;
  }
   }
    }
 shuffle();
 for (i = 1; i <= NShuf; i++)
    {
     shuffle();
     j = card[ICard];
     suit[j] = suit[j] + 1;
    }
 j = 0;
 y = 13.0 / (double)NShuf;
 for (i = 1; i < 14; i++)
    {
     k = suit[i];
     x = 100.0 * ((double)k * y - 1.0);
     printf("%5s   %5d    %5.1f\n",cname[i-1],k,x);
     j = j + k;
    }
 printf("Total Cards = %d\n",j);
 return(0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int

variable_types: ICard int

variable_types: NCards int

variable_types: NShuf int

variable_types:
shuffle
int ()

variable_types: x double

variable_types: y double

variable_types:
cname
char [13][10]


decompiled_code:
__int64 __fastcall tv_combine(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code:
static gen_e tv_combine(const gen_e e1,const gen_e e2)
{
  return e1;
}

canonical_original_code:
static struct gen_e_ *tv_combine(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return e1;
}


ItemCheck

original_code:
long ItemCheck(treeNode* tree)
{
    if (tree->left == ((void *)0))
        return tree->item;
    else
        return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
}

canonical_original_code:
long ItemCheck(struct tn *tree)
{
    if (tree->left == ((void *)0))
        return tree->item;
    else
        return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
}

variable_types: struct tn { struct tn *left; struct tn *right; long item; } *

return_type: long


DeleteTree

decompiled_code:
void __fastcall DeleteTree(__int64 *a1)
{
__int64 v2; // rdi

v2 = *a1;
if ( v2 )
{
DeleteTree(v2);
DeleteTree(a1[1]);
}
free(a1);
}

original_code:
void DeleteTree(treeNode* tree)
{
    if (tree->left != ((void *)0))
    {
        DeleteTree(tree->left);
        DeleteTree(tree->right);
    }
    free(tree);
}

canonical_original_code:
void DeleteTree(struct tn *tree)
{
    if (tree->left != ((void *)0))
    {
        DeleteTree(tree->left);
        DeleteTree(tree->right);
    }
    free(tree);
}

user_defined_types: struct tn { struct tn *left; struct tn *right; long item; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er14
unsigned int v4; // eax
__int64 v5; // rsi
__int64 v6; // rbp
__int64 v7; // rax
__int64 v8; // rdi
int v9; // ebp
unsigned int v10; // er15
double v11; // xmm0_8
__int64 v12; // rbx
__int64 v13; // r14
__int64 v14; // rax
__int64 v15; // r12
__int64 v16; // r8
__int64 v17; // rax
__int64 v18; // r12
__int64 v19; // rcx
__int64 v20; // rsi
__int64 v21; // r12
__int64 v22; // rax
__int64 v23; // r9
__int64 v24; // r13
__int64 v25; // rax
__int64 v26; // r12
__int64 v27; // r10
__int64 v28; // rdi
__int64 v29; // rax
__int64 v30; // r12
__int64 v31; // r11
__int64 v32; // rax
__int64 v33; // r12
__int64 v34; // rdx
__int64 v35; // rax
__int64 v36; // r8
__int64 v37; // rax
__time_t v38; // r12
unsigned int v40; // [rsp+4h] [rbp-64h]
__int64 v41; // [rsp+8h] [rbp-60h]
struct timeval tv; // [rsp+10h] [rbp-58h] BYREF
struct timeval v43; // [rsp+20h] [rbp-48h] BYREF

v3 = 6;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
v43.tv_sec = 0LL;
v43.tv_usec = 0LL;
gettimeofday(&tv, 0LL);
v4 = atol(argv[1]);
if ( v4 >= 6 )
v3 = v4;
v40 = v3;
v5 = v3 + 1;
v6 = BottomUpTree(0LL, v5);
v7 = ItemCheck(v6, v5);
printf("stretch tree of depth %u\t check: %li\n", v5, v7);
v8 = v6;
v9 = 0;
DeleteTree(v8);
v41 = BottomUpTree(0LL, v3);
while ( 1 )
{
v10 = v9 + 4;
v11 = pow(2.0, (double)(int)(v40 - v9));
v12 = (unsigned int)(int)v11;
if ( (int)v11 )
{
v13 = 2LL;
v14 = BottomUpTree(1LL, v10);
v15 = ItemCheck(v14, v10);
DeleteTree(v16);
v17 = BottomUpTree(-1LL, v10);
v18 = ItemCheck(v17, v10) + v15;
DeleteTree(v19);
if ( (unsigned int)(int)v11 >= 2uLL )
{
if ( (((_BYTE)v12 - 1) & 1) == 0
|| (v13 = 3LL,
v20 = BottomUpTree(2LL, v10),
v21 = ItemCheck(v20, v20) + v18,
DeleteTree(v20),
v22 = BottomUpTree(-2LL, v10),
v18 = ItemCheck(v22, v10) + v21,
DeleteTree(v23),
(unsigned int)(int)v11 >= 3uLL) )
{
do
{
v24 = v13 + 1;
v25 = BottomUpTree(v13, v10);
v26 = ItemCheck(v25, v10) + v18;
DeleteTree(v27);
v28 = v13;
v13 += 2LL;
v29 = BottomUpTree(-v28, v10);
v30 = ItemCheck(v29, v10) + v26;
DeleteTree(v31);
v32 = BottomUpTree(v24, v10);
v33 = ItemCheck(v32, v10) + v30;
DeleteTree(v34);
v35 = BottomUpTree(-v24, v10);
v18 = ItemCheck(v35, v10) + v33;
DeleteTree(v36);
}
while ( v12 >= v13 );
}
}
}
else
{
v18 = 0LL;
}
printf("%li\t trees of depth %u\t check: %li\n", 2 * v12, v10, v18);
if ( v40 < v9 + 6 )
break;
v9 += 2;
}
v37 = ItemCheck(v41, 2 * v12);
printf("long lived tree of depth %u\t check: %li\n", v40, v37);
gettimeofday(&v43, 0LL);
v38 = v43.tv_sec - tv.tv_sec;
tv.tv_sec = v43.tv_sec - tv.tv_sec;
if ( v43.tv_usec - tv.tv_usec < 0 )
{
tv.tv_usec = v43.tv_usec - tv.tv_usec + 1000000;
tv.tv_sec = v38 - 1;
}
else
{
tv.tv_usec = v43.tv_usec - tv.tv_usec;
}
fprintf(stderr, "%d.%06d\n", tv.tv_sec, tv.tv_usec);
fflush(stderr);
return 0;
}

original_code:
int main(int argc, char* argv[])
{
    unsigned N, depth, minDepth, maxDepth, stretchDepth;
    treeNode *stretchTree, *longLivedTree, *tempTree;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    N = atol(argv[1]);
    minDepth = 4;
    if ((minDepth + 2) > N)
        maxDepth = minDepth + 2;
    else
        maxDepth = N;
    stretchDepth = maxDepth + 1;
    stretchTree = BottomUpTree(0, stretchDepth);
    printf
    (
        "stretch tree of depth %u\t check: %li\n",
        stretchDepth,
        ItemCheck(stretchTree)
    );
    DeleteTree(stretchTree);
    longLivedTree = BottomUpTree(0, maxDepth);
    for (depth = minDepth; depth <= maxDepth; depth += 2)
    {
        long i, iterations, check;
        iterations = pow(2, maxDepth - depth + minDepth);
        check = 0;
        for (i = 1; i <= iterations; i++)
        {
            tempTree = BottomUpTree(i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
            tempTree = BottomUpTree(-i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
        }
        printf
        (
            "%li\t trees of depth %u\t check: %li\n",
            iterations * 2,
            depth,
            check
        );
    }
    printf
    (
        "long lived tree of depth %u\t check: %li\n",
        maxDepth,
        ItemCheck(longLivedTree)
    );
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned int N; unsigned int depth; unsigned int minDepth; unsigned int maxDepth; unsigned int stretchDepth;
    struct tn *stretchTree; struct tn *longLivedTree; struct tn *tempTree;
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    N = atol(argv[1]);
    minDepth = 4;
    if ((minDepth + 2) > N)
        maxDepth = minDepth + 2;
    else
        maxDepth = N;
    stretchDepth = maxDepth + 1;
    stretchTree = BottomUpTree(0, stretchDepth);
    printf
    (
        "stretch tree of depth %u\t check: %li\n",
        stretchDepth,
        ItemCheck(stretchTree)
    );
    DeleteTree(stretchTree);
    longLivedTree = BottomUpTree(0, maxDepth);
    for (depth = minDepth; depth <= maxDepth; depth += 2)
    {
        long i; long iterations; long check;
        iterations = pow(2, maxDepth - depth + minDepth);
        check = 0;
        for (i = 1; i <= iterations; i++)
        {
            tempTree = BottomUpTree(i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
            tempTree = BottomUpTree(-i, depth);
            check += ItemCheck(tempTree);
            DeleteTree(tempTree);
        }
        printf
        (
            "%li\t trees of depth %u\t check: %li\n",
            iterations * 2,
            depth,
            check
        );
    }
    printf
    (
        "long lived tree of depth %u\t check: %li\n",
        maxDepth,
        ItemCheck(longLivedTree)
    );
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return 0;
}

variable_types:
N
unsigned int

variable_types:
depth
unsigned int

variable_types:
minDepth
unsigned int

variable_types:
maxDepth
unsigned int

variable_types:
stretchDepth
unsigned int

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: i long

variable_types: iterations long

variable_types: check long


decompiled_code:
__int64 is_empty_annotation()
{
return 1LL;
}

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

original_code:
bool is_empty_annotation(annotation a) {
  return 1;
}

canonical_original_code:
unsigned char is_empty_annotation(struct annotation_ *a) {
  return 1;
}

variable_types:
a
struct annotation_ {  } *


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

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

original_code:
annotation get_empty_annotation(void) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *get_empty_annotation() {
  return ((void *)0);
}

return_type: struct annotation_ {  } *


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

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

original_code:
annotation concat_annotation(annotation a1, annotation a2) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *concat_annotation(struct annotation_ *a1, struct annotation_ *a2) {
  return ((void *)0);
}


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

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

original_code:
annotation star_annotation(annotation a) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *star_annotation(struct annotation_ *a) {
  return ((void *)0);
}

variable_types:
a
struct annotation_ *


decompiled_code:
__int64 subsumed_by_annotation()
{
return 1LL;
}

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

original_code:
bool subsumed_by_annotation(annotation a1, annotation a2) {
  return 1;
}

canonical_original_code:
unsigned char subsumed_by_annotation(struct annotation_ *a1, struct annotation_ *a2) {
  return 1;
}


decompiled_code:
void print_annotation()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void print_annotation(annotation a) {
}

canonical_original_code:
void print_annotation(struct annotation_ *a) {
}


bfi

decompiled_code:
unsigned __int64 __fastcall bfi(__int64 a1, __int64 a2, char a3, __int64 a4)
{
unsigned __int64 v4; // rsi
char v5; // dl
unsigned __int64 result; // rax

v4 = a2 - 1;
v5 = (v4 & 0xF8) - a3 + 32 - v4;
result = (unsigned __int64)(0xFFFFFFFFLL << v5 << ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u))) >> ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u));
*(_DWORD *)(a1 + (v4 >> 3)) ^= result & (*(_DWORD *)(a1 + (v4 >> 3)) ^ (a4 << v5));
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, __int64 a2, char a3, __int64 a4)
{
unsigned __int64 v4; // rsi
char v5; // dl
unsigned __int64 result; // rax

v4 = a2 - 1;
v5 = (v4 & 0xF8) - a3 + 32 - v4;
result = (unsigned __int64)(0xFFFFFFFFLL << v5 << ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u))) >> ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u));
*(_DWORD *)(a1 + (v4 >> 3)) ^= result & (*(_DWORD *)(a1 + (v4 >> 3)) ^ (a4 << v5));
return result;
}

original_code:
void
bfi(unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len, long value)
{
   unsigned long l;
   unsigned long mask = 0xffffffff;
   unsigned long byte_offset;
   unsigned long pre_shift;
   unsigned long post_shift;
   byte_offset = (bit_offset-1)/8;
   pre_shift = bit_offset - byte_offset*8 - 1;
   post_shift = 32 - bit_len - pre_shift;
   value <<= post_shift;
   mask <<= post_shift;
   mask <<= pre_shift;
   mask >>= pre_shift;
   value &= mask;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   l = (l & (~mask)) | value;
   memmove(&cptr[byte_offset], (unsigned char *)&l, 4);
}

variable_types:
cptr
unsigned char *

variable_types: value long

variable_types:
l
unsigned long

variable_types:
mask
unsigned long


bfx

original_code:
unsigned long
bfx(const unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len)
{
   unsigned long l;
   unsigned long byte_offset;
   unsigned long left_shift;
   unsigned long right_shift;
   byte_offset = (bit_offset-1)/8;
   left_shift = bit_offset - byte_offset*8 - 1;
   right_shift = 32 - bit_len;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   return ( l << left_shift ) >> right_shift;
}

canonical_original_code:
unsigned long bfx(unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len)
{
   unsigned long l;
   unsigned long byte_offset;
   unsigned long left_shift;
   unsigned long right_shift;
   byte_offset = (bit_offset-1)/8;
   left_shift = bit_offset - byte_offset*8 - 1;
   right_shift = 32 - bit_len;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   return ( l << left_shift ) >> right_shift;
}


decompiled_code:
__int64 __fastcall jcoll_accum(__int64 a1)
{
return gen_e_list_cons(a1, jf_accum);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return gen_e_list_cons(a1, jf_accum);
}

original_code:
static void jcoll_accum(void *e) {
 gen_e_list_cons((gen_e) e, jf_accum);
}

canonical_original_code:
static void jcoll_accum(void *e) {
 gen_e_list_cons((struct gen_e_ *) e, jf_accum);
}

variable_types:
e
void *