decompiled_code:
int __fastcall Vector3fPrint(float *a1)
{
return printf("x: %.3f, y: %.3f, z: %.3f\n", *a1, a1[1], a1[2]);
}

canonical_decompiled_code:
int __fastcall func11(float *a1)
{
return printf("x: %.3f, y: %.3f, z: %.3f\n", *a1, a1[1], a1[2]);
}

original_code:
void Vector3fPrint(const Vector3f* v1){
 printf("x: %.3f, y: %.3f, z: %.3f\n",
  v1->xyz[0],
  v1->xyz[1],
  v1->xyz[2]);
}

canonical_original_code:
void Vector3fPrint(struct Vector3f *v1){
 printf("x: %.3f, y: %.3f, z: %.3f\n",
  v1->xyz[0],
  v1->xyz[1],
  v1->xyz[2]);
}


ImageFree

repo: kellpossible/CRayTracer

decompiled_code:
// attributes: thunk
void ImageFree(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func0(void *ptr)
{
free(ptr);
}

original_code:
void ImageFree(Image* self){
 free(self);
}

canonical_original_code:
void ImageFree(struct Image *self){
 free(self);
}

variable_types: struct Image { int width; int height; int n_rows; int row_pos; struct ColourRGB { int rgb[3]; } pixel_rows[10000][10000]; } *

return_type: void

user_defined_types: struct Image { int width; int height; int n_rows; int row_pos; struct ColourRGB pixel_rows[10000][10000]; }


ImageWritePoint

decompiled_code:
__int64 __fastcall ImageWritePoint(__int64 a1, __int64 a2, int a3, int a4, int a5)
{
__int64 result; // rax
__int64 v6; // rdi

result = 120000LL * a5 + 12LL * a4;
v6 = result + a1;
*(_QWORD *)(v6 + 16) = a2;
*(_DWORD *)(v6 + 24) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, int a3, int a4, int a5)
{
__int64 result; // rax
__int64 v6; // rdi

result = 120000LL * a5 + 12LL * a4;
v6 = result + a1;
*(_QWORD *)(v6 + 16) = a2;
*(_DWORD *)(v6 + 24) = a3;
return result;
}

original_code:
void ImageWritePoint(Image* self, ColourRGB col, int x, int y){
 self->pixel_rows[y][x] = col;
}

canonical_original_code:
void ImageWritePoint(struct Image *self, struct ColourRGB col, int x, int y){
 self->pixel_rows[y][x] = col;
}

variable_types:
col
struct ColourRGB

variable_types: x int

variable_types: y int


ImageGetWidth

decompiled_code:
__int64 __fastcall ImageGetWidth(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1)
{
return *a1;
}

original_code:
int ImageGetWidth(Image* self){
 return self->width;
}

canonical_original_code:
int ImageGetWidth(struct Image *self){
 return self->width;
}

return_type: int


ImageGetHeight

decompiled_code:
__int64 __fastcall ImageGetHeight(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
int ImageGetHeight(Image* self){
 return self->height;
}

canonical_original_code:
int ImageGetHeight(struct Image *self){
 return self->height;
}


LightCreate

decompiled_code:
double *__fastcall LightCreate(__int64 a1, double a2, __m128i a3, float a4)
{
double *result; // rax

result = (double *)malloc(0x18uLL);
*(_QWORD *)result = a1;
result[1] = a2;
*((float *)result + 5) = a4;
*((_DWORD *)result + 4) = _mm_cvtsi128_si32(a3);
return result;
}

canonical_decompiled_code:
double *__fastcall func0(__int64 a1, double a2, __m128i a3, float a4)
{
double *result; // rax

result = (double *)malloc(0x18uLL);
*(_QWORD *)result = a1;
result[1] = a2;
*((float *)result + 5) = a4;
*((_DWORD *)result + 4) = _mm_cvtsi128_si32(a3);
return result;
}

original_code:
Light* LightCreate(char* name, Vector3f position, float power){
 Light* self = malloc(sizeof(Light));
 self->name = name;
 self->position = position;
 self->power = power;
 return self;
}

canonical_original_code:
struct Light *LightCreate(char *name, struct Vector3f position, float power){
 struct Light *self = malloc(sizeof(Light));
 self->name = name;
 self->position = position;
 self->power = power;
 return self;
}

variable_types:
name
char *

variable_types:
position
struct Vector3f

variable_types: power float

variable_types: struct Light { char *name; struct Vector3f { float xyz[3]; } position; float power; } *

user_defined_types: struct Light { char *name; struct Vector3f position; float power; }


LightFree

decompiled_code:
// attributes: thunk
void LightFree(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void LightFree(Light* self){
 free(self);
}

canonical_original_code:
void LightFree(struct Light *self){
 free(self);
}


LightGetName

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

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

original_code:
char* LightGetName(Light* self){
 return self->name;
}

canonical_original_code:
char *LightGetName(struct Light *self){
 return self->name;
}

return_type: char *


LightGetPosition

decompiled_code:
__m128i __fastcall LightGetPosition(__int64 a1)
{
return _mm_loadl_epi64((const __m128i *)(a1 + 8));
}

canonical_decompiled_code:
__m128i __fastcall func3(__int64 a1)
{
return _mm_loadl_epi64((const __m128i *)(a1 + 8));
}

original_code:
Vector3f LightGetPosition(Light* self){
 return self->position;
}

canonical_original_code:
struct Vector3f LightGetPosition(struct Light *self){
 return self->position;
}

variable_types: struct Light { char *name; struct Vector3f position; float power; } *

return_type: struct Vector3f { float xyz[3]; }


LightGetPower

decompiled_code:
float __fastcall LightGetPower(__int64 a1)
{
return *(float *)(a1 + 20);
}

canonical_decompiled_code:
float __fastcall func4(__int64 a1)
{
return *(float *)(a1 + 20);
}

original_code:
float LightGetPower(Light* self){
 return self->power;
}

canonical_original_code:
float LightGetPower(struct Light *self){
 return self->power;
}

return_type: float


RandomCreate

decompiled_code:
// attributes: thunk
__int64 RandomCreate()
{
return RandomMwcCreate();
}

canonical_decompiled_code:
__int64 func0()
{
return RandomMwcCreate();
}

original_code:
RandomBuffer RandomCreate(unsigned int seed){
    return RandomMwcCreate(seed);
}

canonical_original_code:
struct RandomMwc RandomCreate(unsigned int seed){
    return RandomMwcCreate(seed);
}

variable_types:
seed
unsigned int

return_type: struct RandomMwc { unsigned int aSeeds[2]; }


RayCreate

decompiled_code:
char *__fastcall RayCreate(double a1, __m128i a2, double a3, __m128i a4)
{
char *result; // rax

result = (char *)malloc(0x18uLL);
*(double *)result = a1;
*((_DWORD *)result + 2) = _mm_cvtsi128_si32(a2);
*(double *)(result + 12) = a3;
*((_DWORD *)result + 5) = _mm_cvtsi128_si32(a4);
return result;
}

canonical_decompiled_code:
char *__fastcall func0(double a1, __m128i a2, double a3, __m128i a4)
{
char *result; // rax

result = (char *)malloc(0x18uLL);
*(double *)result = a1;
*((_DWORD *)result + 2) = _mm_cvtsi128_si32(a2);
*(double *)(result + 12) = a3;
*((_DWORD *)result + 5) = _mm_cvtsi128_si32(a4);
return result;
}

original_code:
Ray* RayCreate(Vector3f origin, Vector3f direction){
 Ray* self = malloc(sizeof(Ray));
 self->origin = origin;
 self->direction = direction;
 return self;
}

canonical_original_code:
struct Ray *RayCreate(struct Vector3f origin, struct Vector3f direction){
 struct Ray *self = malloc(sizeof(Ray));
 self->origin = origin;
 self->direction = direction;
 return self;
}

variable_types:
origin
struct Vector3f

variable_types:
direction
struct Vector3f

variable_types: struct Ray { struct Vector3f { float xyz[3]; } origin; struct Vector3f direction; } *

user_defined_types: struct Ray { struct Vector3f origin; struct Vector3f direction; }


RayFree

decompiled_code:
// attributes: thunk
void RayFree(void *ptr)
{
free(ptr);
}

original_code:
void RayFree(Ray* self){
 free(self);
}

canonical_original_code:
void RayFree(struct Ray *self){
 free(self);
}


RayGetOrigin

decompiled_code:
__m128i __fastcall RayGetOrigin(const __m128i *a1)
{
return _mm_loadl_epi64(a1);
}

canonical_decompiled_code:
__m128i __fastcall func2(const __m128i *a1)
{
return _mm_loadl_epi64(a1);
}

original_code:
Vector3f RayGetOrigin(Ray* self){
 return self->origin;
}

canonical_original_code:
struct Vector3f RayGetOrigin(struct Ray *self){
 return self->origin;
}

variable_types: struct Ray { struct Vector3f origin; struct Vector3f direction; } *


RayGetDirection

decompiled_code:
__m128i __fastcall RayGetDirection(__int64 a1)
{
return _mm_loadl_epi64((const __m128i *)(a1 + 12));
}

canonical_decompiled_code:
__m128i __fastcall func3(__int64 a1)
{
return _mm_loadl_epi64((const __m128i *)(a1 + 12));
}

original_code:
Vector3f RayGetDirection(Ray* self){
 return self->direction;
}

canonical_original_code:
struct Vector3f RayGetDirection(struct Ray *self){
 return self->direction;
}


RandomMwcCreate

decompiled_code:
__int64 __fastcall RandomMwcCreate(unsigned int a1)
{
__int64 v1; // rax

v1 = 362436069LL;
if ( a1 )
v1 = a1;
if ( !a1 )
a1 = 521288629;
return (v1 << 32) | a1;
}

original_code:
RandomMwc RandomMwcCreate
(
   dword seed
)
{
   RandomMwc r;
   r.aSeeds[0] = (0 != seed) ? (udword)seed : SEEDS[0];
   r.aSeeds[1] = (0 != seed) ? (udword)seed : SEEDS[1];
   return r;
}

canonical_original_code:
struct RandomMwc RandomMwcCreate(int seed)
{
   struct RandomMwc r;
   r.aSeeds[0] = (0 != seed) ? (unsigned int)seed : SEEDS[0];
   r.aSeeds[1] = (0 != seed) ? (unsigned int)seed : SEEDS[1];
   return r;
}

variable_types: seed int

variable_types: struct RandomMwc { unsigned int aSeeds[2]; }


RandomMwcDword

decompiled_code:
__int64 __fastcall RandomMwcDword(int *a1)
{
int v1; // eax
unsigned int v2; // edx
int v3; // edx

v1 = 18000 * (unsigned __int16)*a1 + HIWORD(*a1);
v2 = a1[1];
*a1 = v1;
v3 = 30903 * (unsigned __int16)v2 + HIWORD(v2);
a1[1] = v3;
return (unsigned int)(unsigned __int16)v3 + (v1 << 16);
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1)
{
int v1; // eax
unsigned int v2; // edx
int v3; // edx

v1 = 18000 * (unsigned __int16)*a1 + HIWORD(*a1);
v2 = a1[1];
*a1 = v1;
v3 = 30903 * (unsigned __int16)v2 + HIWORD(v2);
a1[1] = v3;
return (unsigned int)(unsigned __int16)v3 + (v1 << 16);
}

original_code:
dword RandomMwcDword
(
   RandomMwc* pR
)
{
   pR->aSeeds[0] = 18000u * (pR->aSeeds[0] & 0xFFFFu) + (pR->aSeeds[0] >> 16);
   pR->aSeeds[1] = 30903u * (pR->aSeeds[1] & 0xFFFFu) + (pR->aSeeds[1] >> 16);
   return (dword)( (pR->aSeeds[0] << 16) + (pR->aSeeds[1] & 0xFFFFu) );
}

canonical_original_code:
int RandomMwcDword(struct RandomMwc *pR)
{
   pR->aSeeds[0] = 18000u * (pR->aSeeds[0] & 0xFFFFu) + (pR->aSeeds[0] >> 16);
   pR->aSeeds[1] = 30903u * (pR->aSeeds[1] & 0xFFFFu) + (pR->aSeeds[1] >> 16);
   return (dword)( (pR->aSeeds[0] << 16) + (pR->aSeeds[1] & 0xFFFFu) );
}

variable_types: struct RandomMwc { unsigned int aSeeds[2]; } *


RandomMwcFloat

decompiled_code:
float __fastcall RandomMwcFloat(int *a1)
{
return (float)(int)RandomMwcDword(a1) * 2.3283064e-10;
}

canonical_decompiled_code:
float __fastcall func2(int *a1)
{
return (float)(int)func1(a1) * 2.3283064e-10;
}

original_code:
float RandomMwcFloat
(
   RandomMwc* pR
)
{
   return (float)((udword)RandomMwcDword( pR )) / 4294967296.0f;
}

canonical_original_code:
float RandomMwcFloat(struct RandomMwc *pR)
{
   return (float)((unsigned int)RandomMwcDword( pR )) / 4294967296.0f;
}

user_defined_types: struct RandomMwc { unsigned int aSeeds[2]; }


ToneMapSimple

decompiled_code:
__int64 __fastcall ToneMapSimple(double a1, __m128i a2)
{
double v3; // [rsp+10h] [rbp-28h] BYREF
int v4; // [rsp+18h] [rbp-20h]

v3 = a1;
v4 = _mm_cvtsi128_si32(a2);
return Vector3f2ColourRGB(&v3);
}

canonical_decompiled_code:
__int64 __fastcall func0(double a1, __m128i a2)
{
double v3; // [rsp+10h] [rbp-28h] BYREF
int v4; // [rsp+18h] [rbp-20h]

v3 = a1;
v4 = _mm_cvtsi128_si32(a2);
return Vector3f2ColourRGB(&v3);
}

original_code:
ColourRGB ToneMapSimple(Vector3f vec_colour){
 return Vector3f2ColourRGB(&vec_colour);
}

canonical_original_code:
struct ColourRGB ToneMapSimple(struct Vector3f vec_colour){
 return Vector3f2ColourRGB(&vec_colour);
}

return_type: struct ColourRGB { int rgb[3]; }

user_defined_types:
struct Vector3f { float xyz[3]; }
struct ColourRGB { int rgb[3]; }


repo: kenneaal/RhostMUSH

decompiled_code:
__int64 __fastcall log_name_and_loc(int a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = log_name(a1);
if ( (mudconf[2027] & 2) != 0 )
{
v2 = 88LL * a1;
result = 3LL * (*(_DWORD *)(db + v2 + 40) & 7);
if ( (object_types[24 * (*(_DWORD *)(db + v2 + 40) & 7) + 16] & 2) != 0 )
{
log_text(" in ");
result = log_name(*(_DWORD *)(db + 88LL * a1));
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
__int64 result; // rax
__int64 v2; // rbx

result = func7(a1);
if ( (mudconf[2027] & 2) != 0 )
{
v2 = 88LL * a1;
result = 3LL * (*(_DWORD *)(db + v2 + 40) & 7);
if ( (object_types[24 * (*(_DWORD *)(db + v2 + 40) & 7) + 16] & 2) != 0 )
{
func4(" in ");
result = func7(*(_DWORD *)(db + 88LL * a1));
}
}
return result;
}

original_code:
void
log_name_and_loc(dbref player)
{
    log_name(player);
    if ((mudconf.log_info & 0x02) && ((object_types[(db[player].flags & 0x7)].flags & 0x0002) != 0)) {
 log_text((char *) " in ");
 log_name(db[player].location);
    }
    return;
}

canonical_original_code:
void log_name_and_loc(int player)
{
    log_name(player);
    if ((mudconf.log_info & 0x02) && ((object_types[(db[player].flags & 0x7)].flags & 0x0002) != 0)) {
 log_text((char *) " in ");
 log_name(db[player].location);
    }
    return;
}

variable_types: player int


OBJTYP

decompiled_code:
char *__fastcall OBJTYP(int a1)
{
const char *v1; // r8
__int64 v2; // rax
char *result; // rax

v1 = "??OUT-OF-RANGE??";
if ( a1 < 0
|| *((_DWORD *)&mudstate + 1830) <= a1
|| (v2 = *(_DWORD *)(db + 88LL * a1 + 40) & 7, (*(_DWORD *)(db + 88LL * a1 + 40) & 7u) > 4)
|| (v1 = "??ILLEGAL??", (_DWORD)v2 == 4) )
{
result = (char *)v1;
}
else
{
result = CSWTCH_23[v2];
}
return result;
}

canonical_decompiled_code:
char *__fastcall func9(int a1)
{
const char *v1; // r8
__int64 v2; // rax
char *result; // rax

v1 = "??OUT-OF-RANGE??";
if ( a1 < 0
|| *((_DWORD *)&mudstate + 1830) <= a1
|| (v2 = *(_DWORD *)(db + 88LL * a1 + 40) & 7, (*(_DWORD *)(db + 88LL * a1 + 40) & 7u) > 4)
|| (v1 = "??ILLEGAL??", (_DWORD)v2 == 4) )
{
result = (char *)v1;
}
else
{
result = CSWTCH_23[v2];
}
return result;
}

original_code:
char *
OBJTYP(dbref thing)
{
    if (!(((thing) >= 0) && ((thing) < mudstate.db_top) && ((db[thing].flags & 0x7) <= 0x4))) {
 return (char *) "??OUT-OF-RANGE??";
    }
    switch ((db[thing].flags & 0x7)) {
    case 0x3:
 return (char *) "PLAYER";
    case 0x1:
 return (char *) "THING";
    case 0x0:
 return (char *) "ROOM";
    case 0x2:
 return (char *) "EXIT";
    default:
 return (char *) "??ILLEGAL??";
    }
    return ((void *)0);
}

canonical_original_code:
char *OBJTYP(int thing)
{
    if (!(((thing) >= 0) && ((thing) < mudstate.db_top) && ((db[thing].flags & 0x7) <= 0x4))) {
 return (char *) "??OUT-OF-RANGE??";
    }
    switch ((db[thing].flags & 0x7)) {
    case 0x3:
 return (char *) "PLAYER";
    case 0x1:
 return (char *) "THING";
    case 0x0:
 return (char *) "ROOM";
    case 0x2:
 return (char *) "EXIT";
    default:
 return (char *) "??ILLEGAL??";
    }
    return ((void *)0);
}

variable_types: thing int


decompiled_code:
int __fastcall log_type_and_name(int a1)
{
char *v1; // rax
char *v3; // rax
char v4[24]; // [rsp+0h] [rbp-18h] BYREF

v1 = OBJTYP(a1);
log_text(v1);
sprintf(v4, " #%d(", (unsigned int)a1);
log_text(v4);
if ( a1 >= 0 && *((_DWORD *)&mudstate + 1830) > a1 && (*(_DWORD *)(db + 88LL * a1 + 40) & 7u) <= 4 )
{
v3 = (char *)Name((unsigned int)a1);
log_text(v3);
}
return log_text(")");
}

canonical_decompiled_code:
int __fastcall func10(int a1)
{
char *v1; // rax
char *v3; // rax
char v4[24]; // [rsp+0h] [rbp-18h] BYREF

v1 = func9(a1);
func4(v1);
sprintf(v4, " #%d(", (unsigned int)a1);
func4(v4);
if ( a1 >= 0 && *((_DWORD *)&mudstate + 1830) > a1 && (*(_DWORD *)(db + 88LL * a1 + 40) & 7u) <= 4 )
{
v3 = (char *)Name((unsigned int)a1);
func4(v3);
}
return func4(")");
}

original_code:
void
log_type_and_name(dbref thing)
{
    char nbuf[16];
    log_text(OBJTYP(thing));
    sprintf(nbuf, " #%d(", thing);
    log_text(nbuf);
    if ((((thing) >= 0) && ((thing) < mudstate.db_top) && ((db[thing].flags & 0x7) <= 0x4)))
 log_text(Name(thing));
    log_text((char *) ")");
    return;
}

canonical_original_code:
void log_type_and_name(int thing)
{
    char nbuf[16];
    log_text(OBJTYP(thing));
    sprintf(nbuf, " #%d(", thing);
    log_text(nbuf);
    if ((((thing) >= 0) && ((thing) < mudstate.db_top) && ((db[thing].flags & 0x7) <= 0x4)))
 log_text(Name(thing));
    log_text((char *) ")");
    return;
}

variable_types:
nbuf
char [16]


decompiled_code:
int __fastcall log_type_and_num(unsigned int a1)
{
char *v1; // rax
char v3[24]; // [rsp+0h] [rbp-18h] BYREF

v1 = OBJTYP(a1);
log_text(v1);
sprintf(v3, " #%d", a1);
return log_text(v3);
}

canonical_decompiled_code:
int __fastcall func11(unsigned int a1)
{
char *v1; // rax
char v3[24]; // [rsp+0h] [rbp-18h] BYREF

v1 = func9(a1);
func4(v1);
sprintf(v3, " #%d", a1);
return func4(v3);
}

original_code:
void
log_type_and_num(dbref thing)
{
    char nbuf[16];
    log_text(OBJTYP(thing));
    sprintf(nbuf, " #%d", thing);
    log_text(nbuf);
    return;
}

canonical_original_code:
void log_type_and_num(int thing)
{
    char nbuf[16];
    log_text(OBJTYP(thing));
    sprintf(nbuf, " #%d", thing);
    log_text(nbuf);
    return;
}


decompiled_code:
__int64 __fastcall rwhocli_setup(char *name, __int16 a2, const char *a3, const char *a4, const char *a5)
{
size_t v9; // r13
void *v10; // rax
void *v11; // rbx
const char *v12; // rsi
char *v13; // rbp
__int64 v14; // rbx
__int16 v15; // ax
sa_family_t v16; // cx
int v17; // edx
size_t v18; // rax
struct hostent *v19; // rax
void *v21; // [rsp+10h] [rbp-258h]
size_t v22; // [rsp+18h] [rbp-250h]
void *dest; // [rsp+20h] [rbp-248h]
size_t n; // [rsp+28h] [rbp-240h]
char s[568]; // [rsp+30h] [rbp-238h] BYREF

if ( dgramfd != -1 )
return 1LL;
n = strlen(a3) + 1;
password = malloc(n);
dest = password;
v22 = strlen(a4) + 1;
localnam = malloc(v22);
v21 = localnam;
v9 = strlen(a5) + 1;
v10 = malloc(v9);
lcomment = (__int64)v10;
v11 = v10;
if ( dest == 0LL || v21 == 0LL || !v10 )
return 1LL;
memcpy(dest, a3, n);
v12 = a4;
v13 = name;
memcpy(v21, v12, v22);
memcpy(v11, a5, v9);
v14 = *name;
if ( (_BYTE)v14 )
{
while ( (_BYTE)v14 == 46 || ((*_ctype_b_loc())[v14] & 0x800) != 0 )
{
v14 = *++v13;
if ( !(_BYTE)v14 )
goto LABEL_9;
}
v19 = gethostbyname(name);
if ( !v19 )
return 1LL;
memmove(&addr.sa_data[2], *(const void **)v19->h_addr_list, v19->h_length);
}
else
{
LABEL_9:
*(_QWORD *)&addr.sa_data[2] = inet_addr(name);
}
v15 = _bswap_16(a2);
addr.sa_family = v16;
*(_WORD *)addr.sa_data = v15;
dgramfd = socket(2, 2, v17);
if ( dgramfd < 0 )
return 1LL;
sprintf(
s,
"U\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
mudstate[112],
a5);
v18 = strlen(s);
sendto(dgramfd, s, v18, 0, &addr, 0x10u);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *name, __int16 a2, const char *a3, const char *a4, const char *a5)
{
size_t v9; // r13
void *v10; // rax
void *v11; // rbx
const char *v12; // rsi
char *v13; // rbp
__int64 v14; // rbx
__int16 v15; // ax
sa_family_t v16; // cx
int v17; // edx
size_t v18; // rax
struct hostent *v19; // rax
void *v21; // [rsp+10h] [rbp-258h]
size_t v22; // [rsp+18h] [rbp-250h]
void *dest; // [rsp+20h] [rbp-248h]
size_t n; // [rsp+28h] [rbp-240h]
char s[568]; // [rsp+30h] [rbp-238h] BYREF

if ( dgramfd != -1 )
return 1LL;
n = strlen(a3) + 1;
password = malloc(n);
dest = password;
v22 = strlen(a4) + 1;
localnam = malloc(v22);
v21 = localnam;
v9 = strlen(a5) + 1;
v10 = malloc(v9);
lcomment = (__int64)v10;
v11 = v10;
if ( dest == 0LL || v21 == 0LL || !v10 )
return 1LL;
memcpy(dest, a3, n);
v12 = a4;
v13 = name;
memcpy(v21, v12, v22);
memcpy(v11, a5, v9);
v14 = *name;
if ( (_BYTE)v14 )
{
while ( (_BYTE)v14 == 46 || ((*_ctype_b_loc())[v14] & 0x800) != 0 )
{
v14 = *++v13;
if ( !(_BYTE)v14 )
goto LABEL_9;
}
v19 = gethostbyname(name);
if ( !v19 )
return 1LL;
memmove(&addr.sa_data[2], *(const void **)v19->h_addr_list, v19->h_length);
}
else
{
LABEL_9:
*(_QWORD *)&addr.sa_data[2] = inet_addr(name);
}
v15 = func0(a2);
addr.sa_family = v16;
*(_WORD *)addr.sa_data = v15;
dgramfd = socket(2, 2, v17);
if ( dgramfd < 0 )
return 1LL;
sprintf(
s,
"U\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
mudstate[112],
a5);
v18 = strlen(s);
sendto(dgramfd, s, v18, 0, &addr, 0x10u);
return 0LL;
}

original_code:
int rwhocli_setup(char *server, int dgramport, char *serverpw,
  char *myname, char *comment)
{
 struct hostent *hp;
 char pbuf[512];
 char *p;
 if(dgramfd != -1)
  return(1);
 password = malloc(strlen(serverpw) + 1);
 localnam = malloc(strlen(myname) + 1);
 lcomment = malloc(strlen(comment) + 1);
 if(password == (char *)0 || localnam == (char *)0 || lcomment == (char *)0)
  return(1);
 strcpy(password,serverpw);
 strcpy(localnam,myname);
 strcpy(lcomment,comment);
 p = server;
 while(*p != '\0' && (*p == '.' || ((*__ctype_b_loc ())[(int) (((int)*p))] & (unsigned short int) _ISdigit)))
  p++;
 if(*p != '\0') {
  if((hp = gethostbyname(server)) == (struct hostent *)0)
   return(1);
  (void)bcopy(hp->h_addr_list[0],(char *)&addr.sin_addr,hp->h_length);
 } else {
  unsigned long f;
  if((f = inet_addr(server)) == -1L)
   return(1);
  (void)bcopy((char *)&f,(char *)&addr.sin_addr,sizeof(f));
 }
 addr.sin_port = htons(dgramport);
 addr.sin_family = 2;
 if((dgramfd = socket(2,SOCK_DGRAM,0)) < 0)
  return(1);
 sprintf(pbuf,"U\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
  localnam,password,localnam,mudstate.now,comment);
 sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 return(0);
}

canonical_original_code:
int rwhocli_setup(char *server, int dgramport, char *serverpw, char *myname, char *comment)
{
 struct hostent *hp;
 char pbuf[512];
 char *p;
 if(dgramfd != -1)
  return(1);
 password = malloc(strlen(serverpw) + 1);
 localnam = malloc(strlen(myname) + 1);
 lcomment = malloc(strlen(comment) + 1);
 if(password == (char *)0 || localnam == (char *)0 || lcomment == (char *)0)
  return(1);
 strcpy(password,serverpw);
 strcpy(localnam,myname);
 strcpy(lcomment,comment);
 p = server;
 while(*p != '\0' && (*p == '.' || ((*__ctype_b_loc ())[(int) (((int)*p))] & (unsigned short) _ISdigit)))
  p++;
 if(*p != '\0') {
  if((hp = gethostbyname(server)) == (struct hostent *)0)
   return(1);
  (void)bcopy(hp->h_addr_list[0],(char *)&addr.sin_addr,hp->h_length);
 } else {
  unsigned long f;
  if((f = inet_addr(server)) == -1L)
   return(1);
  (void)bcopy((char *)&f,(char *)&addr.sin_addr,sizeof(f));
 }
 addr.sin_port = htons(dgramport);
 addr.sin_family = 2;
 if((dgramfd = socket(2,SOCK_DGRAM,0)) < 0)
  return(1);
 sprintf(pbuf,"U\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
  localnam,password,localnam,mudstate.now,comment);
 sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 return(0);
}

variable_types:
server
char *

variable_types: dgramport int

variable_types:
serverpw
char *

variable_types:
myname
char *

variable_types:
comment
char *

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

variable_types:
pbuf
char [512]

variable_types:
p
char *

variable_types:
f
unsigned long


decompiled_code:
__int64 rwhocli_shutdown()
{
size_t v1; // rax
char v2[520]; // [rsp-208h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(v2, "D\t%.20s\t%.20s\t%.20s", (const char *)localnam, (const char *)password, (const char *)localnam);
v1 = strlen(v2);
sendto(dgramfd, v2, v1, 0, &addr, 0x10u);
close(dgramfd);
dgramfd = -1;
free(password);
free(localnam);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
size_t v1; // rax
char v2[520]; // [rsp-208h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(v2, "D\t%.20s\t%.20s\t%.20s", (const char *)localnam, (const char *)password, (const char *)localnam);
v1 = strlen(v2);
sendto(dgramfd, v2, v1, 0, &addr, 0x10u);
close(dgramfd);
dgramfd = -1;
free(password);
free(localnam);
}
return 0LL;
}

original_code:
int rwhocli_shutdown(void)
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"D\t%.20s\t%.20s\t%.20s",
   localnam, password, localnam);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
  close(dgramfd);
  dgramfd = -1;
  free(password);
  free(localnam);
 }
 return(0);
}

canonical_original_code:
int rwhocli_shutdown()
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"D\t%.20s\t%.20s\t%.20s",
   localnam, password, localnam);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
  close(dgramfd);
  dgramfd = -1;
  free(password);
  free(localnam);
 }
 return(0);
}


decompiled_code:
__int64 rwhocli_pingalive()
{
size_t v1; // rax
char s[520]; // [rsp+0h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(
s,
"M\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
mudstate[112],
(const char *)lcomment);
v1 = strlen(s);
sendto(dgramfd, s, v1, 0, &addr, 0x10u);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
size_t v1; // rax
char s[520]; // [rsp+0h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(
s,
"M\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
mudstate[112],
(const char *)lcomment);
v1 = strlen(s);
sendto(dgramfd, s, v1, 0, &addr, 0x10u);
}
return 0LL;
}

original_code:
int rwhocli_pingalive(void)
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"M\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
   localnam, password, localnam,mudstate.now, lcomment);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 }
 return(0);
}

canonical_original_code:
int rwhocli_pingalive()
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"M\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.25s",
   localnam, password, localnam,mudstate.now, lcomment);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 }
 return(0);
}


decompiled_code:
__int64 __fastcall rwhocli_userlogin(const char *a1, const char *a2, __int64 a3)
{
size_t v4; // rax
char s[520]; // [rsp+0h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(
s,
"A\t%.20s\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.20s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
a1,
a3,
a2);
v4 = strlen(s);
sendto(dgramfd, s, v4, 0, &addr, 0x10u);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, const char *a2, __int64 a3)
{
size_t v4; // rax
char s[520]; // [rsp+0h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(
s,
"A\t%.20s\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.20s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
a1,
a3,
a2);
v4 = strlen(s);
sendto(dgramfd, s, v4, 0, &addr, 0x10u);
}
return 0LL;
}

original_code:
int rwhocli_userlogin(char *uid, char *name, time_t tim)
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"A\t%.20s\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.20s",
   localnam, password, localnam, uid, tim, name);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 }
 return(0);
}

canonical_original_code:
int rwhocli_userlogin(char *uid, char *name, long tim)
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"A\t%.20s\t%.20s\t%.20s\t%.20s\t%.10ld\t0\t%.20s",
   localnam, password, localnam, uid, tim, name);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 }
 return(0);
}

variable_types:
uid
char *

variable_types:
name
char *

variable_types: tim long


decompiled_code:
__int64 __fastcall rwhocli_userlogout(const char *a1)
{
size_t v2; // rax
char v3[520]; // [rsp-208h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(
v3,
"Z\t%.20s\t%.20s\t%.20s\t%.20s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
a1);
v2 = strlen(v3);
sendto(dgramfd, v3, v2, 0, &addr, 0x10u);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1)
{
size_t v2; // rax
char v3[520]; // [rsp-208h] [rbp-208h] BYREF

if ( dgramfd != -1 )
{
sprintf(
v3,
"Z\t%.20s\t%.20s\t%.20s\t%.20s",
(const char *)localnam,
(const char *)password,
(const char *)localnam,
a1);
v2 = strlen(v3);
sendto(dgramfd, v3, v2, 0, &addr, 0x10u);
}
return 0LL;
}

original_code:
int rwhocli_userlogout(char *uid)
{
 char pbuf[512];
 if(dgramfd != -1) {
  sprintf(pbuf,"Z\t%.20s\t%.20s\t%.20s\t%.20s",
   localnam, password, localnam, uid);
  sendto(dgramfd,pbuf,strlen(pbuf),0,(void *)&addr,sizeof(addr));
 }
 return(0);
}


decompiled_code:
__int64 local_startup()
{
local_sqlite_init();
return load_regexp_functions();
}

canonical_decompiled_code:
__int64 func0()
{
local_sqlite_init();
return load_regexp_functions();
}

original_code:
void local_startup(void) {
   local_sqlite_init();
   load_regexp_functions();
}

canonical_original_code:
void local_startup() {
   local_sqlite_init();
   load_regexp_functions();
}


decompiled_code:
void local_shutdown()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void local_shutdown(void) {
}

canonical_original_code:
void local_shutdown() {
}


decompiled_code:
void local_dump_reboot()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void local_dump_reboot(void) {
}

canonical_original_code:
void local_dump_reboot() {
}


decompiled_code:
void local_load_reboot()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void local_load_reboot(void) {
}

canonical_original_code:
void local_load_reboot() {
}


decompiled_code:
void local_dump()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void local_dump(int bPanicDump) {
}

canonical_original_code:
void local_dump(int bPanicDump) {
}

variable_types: bPanicDump int


decompiled_code:
void local_dbck()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void local_dbck(void) {
}

canonical_original_code:
void local_dbck() {
}


decompiled_code:
void local_tick()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void local_tick(void) {
}

canonical_original_code:
void local_tick() {
}


decompiled_code:
void local_second()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void local_second(void) {
}

canonical_original_code:
void local_second() {
}


decompiled_code:
void local_player_connect()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void local_player_connect(dbref player, int bNew) {
}

canonical_original_code:
void local_player_connect(int player, int bNew) {
}

variable_types: bNew int


decompiled_code:
void local_player_disconnect()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void local_player_disconnect(dbref player) {
}

canonical_original_code:
void local_player_disconnect(int player) {
}

variable_types: player int


decompiled_code:
__int64 __fastcall local_function(_BYTE *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, _QWORD *a6)
{
if ( !a1 || !*a1 || (unsigned int)stricmp(a1, "test") )
return safe_copy_str("#-1 NO FUNCTION", a2, a3, 3998LL);
safe_copy_str("This was a test. Function: '", a2, a3, 3998LL);
safe_copy_str(a1, a2, a3, 3998LL);
safe_copy_str("' First Arg: '", a2, a3, 3998LL);
safe_copy_str(*a6, a2, a3, 3998LL);
return safe_copy_chr(39LL, a2, a3, 3998LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(_BYTE *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, _QWORD *a6)
{
if ( !a1 || !*a1 || (unsigned int)stricmp(a1, "test") )
return safe_copy_str("#-1 NO FUNCTION", a2, a3, 3998LL);
safe_copy_str("This was a test. Function: '", a2, a3, 3998LL);
safe_copy_str(a1, a2, a3, 3998LL);
safe_copy_str("' First Arg: '", a2, a3, 3998LL);
safe_copy_str(*a6, a2, a3, 3998LL);
return safe_copy_chr(39LL, a2, a3, 3998LL);
}

original_code:
void local_function(char *funcname, char *buff, char **bufcx, dbref player, dbref cause,
                    char *fargs[], int nfargs, char *cargs[], int ncargs) {
   if ( !funcname || !*funcname ) {
      safe_copy_str("#-1 NO FUNCTION",buff,bufcx,(4000 -2));
      return;
   }
   if ( stricmp(funcname, "test") == 0 ) {
      safe_copy_str("This was a test. Function: '",buff,bufcx,(4000 -2));
      safe_copy_str(funcname,buff,bufcx,(4000 -2));
      safe_copy_str("' First Arg: '",buff,bufcx,(4000 -2));
      safe_copy_str(fargs[0],buff,bufcx,(4000 -2));
      safe_copy_chr('\'',buff,bufcx,(4000 -2));
   } else {
      safe_copy_str("#-1 NO FUNCTION",buff,bufcx,(4000 -2));
   }
}

canonical_original_code:
void local_function(char *funcname, char *buff, char **bufcx, int player, int cause, char *fargs[], int nfargs, char *cargs[], int ncargs) {
   if ( !funcname || !*funcname ) {
      safe_copy_str("#-1 NO FUNCTION",buff,bufcx,(4000 -2));
      return;
   }
   if ( stricmp(funcname, "test") == 0 ) {
      safe_copy_str("This was a test. Function: '",buff,bufcx,(4000 -2));
      safe_copy_str(funcname,buff,bufcx,(4000 -2));
      safe_copy_str("' First Arg: '",buff,bufcx,(4000 -2));
      safe_copy_str(fargs[0],buff,bufcx,(4000 -2));
      safe_copy_chr('\'',buff,bufcx,(4000 -2));
   } else {
      safe_copy_str("#-1 NO FUNCTION",buff,bufcx,(4000 -2));
   }
}

variable_types:
funcname
char *

variable_types:
buff
char *

variable_types:
bufcx
char **

variable_types: cause int

variable_types:
fargs
char *[]

variable_types: nfargs int

variable_types:
cargs
char *[]

variable_types: ncargs int


original_code:
static void pcache_reload1(dbref player, PCACHE *pp)
{
char *cp;
 cp = atr_get_raw(player, 25);
 if (cp && *cp)
  pp->money = atoi(cp);
 else
  pp->money = 0;
 cp = atr_get_raw(player, 31);
 if (cp && *cp)
  pp->qmax = atoi(cp);
 else if (!(evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))))
  pp->qmax = mudconf.queuemax;
 else
  pp->qmax = -1;
}

canonical_original_code:
static void pcache_reload1(int player, struct player_cache *pp)
{
char *cp;
 cp = atr_get_raw(player, 25);
 if (cp && *cp)
  pp->money = atoi(cp);
 else
  pp->money = 0;
 cp = atr_get_raw(player, 31);
 if (cp && *cp)
  pp->qmax = atoi(cp);
 else if (!(evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))))
  pp->qmax = mudconf.queuemax;
 else
  pp->qmax = -1;
}

variable_types: struct player_cache { int player; int money; int queue; int qmax; int cflags; struct player_cache *next; } *

variable_types:
cp
char *


decompiled_code:
__int64 __fastcall pcache_save(unsigned int *a1)
{
__int64 result; // rax
char v2[24]; // [rsp-18h] [rbp-18h] BYREF

result = a1[4];
if ( (result & 1) == 0 )
{
if ( (result & 4) != 0 )
{
sprintf(v2, "%d", a1[1]);
atr_add_raw(*a1, 25LL, v2);
LODWORD(result) = a1[4];
if ( (result & 8) == 0 )
goto LABEL_4;
}
else if ( (result & 8) == 0 )
{
LABEL_4:
result = (unsigned int)result & 0xFFFFFFF3;
a1[4] = result;
return result;
}
sprintf(v2, "%d", a1[3]);
atr_add_raw(*a1, 31LL, v2);
result = a1[4] & 0xFFFFFFF3;
a1[4] = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1)
{
__int64 result; // rax
char v2[24]; // [rsp-18h] [rbp-18h] BYREF

result = a1[4];
if ( (result & 1) == 0 )
{
if ( (result & 4) != 0 )
{
sprintf(v2, "%d", a1[1]);
atr_add_raw(*a1, 25LL, v2);
LODWORD(result) = a1[4];
if ( (result & 8) == 0 )
goto LABEL_4;
}
else if ( (result & 8) == 0 )
{
LABEL_4:
result = (unsigned int)result & 0xFFFFFFF3;
a1[4] = result;
return result;
}
sprintf(v2, "%d", a1[3]);
atr_add_raw(*a1, 31LL, v2);
result = a1[4] & 0xFFFFFFF3;
a1[4] = result;
}
return result;
}

original_code:
static void pcache_save(PCACHE *pp)
{
IBUF tbuf;
 if (pp->cflags & 0x0001)
  return;
 if (pp->cflags & 0x0004) {
  sprintf(tbuf, "%d", pp->money);
  atr_add_raw(pp->player, 25, tbuf);
 }
 if (pp->cflags & 0x0008) {
  sprintf(tbuf, "%d", pp->qmax);
  atr_add_raw(pp->player, 31, tbuf);
 }
 pp->cflags &= ~(0x0004|0x0008);
}

canonical_original_code:
static void pcache_save(struct player_cache *pp)
{
char tbuf[16];
 if (pp->cflags & 0x0001)
  return;
 if (pp->cflags & 0x0004) {
  sprintf(tbuf, "%d", pp->money);
  atr_add_raw(pp->player, 25, tbuf);
 }
 if (pp->cflags & 0x0008) {
  sprintf(tbuf, "%d", pp->qmax);
  atr_add_raw(pp->player, 31, tbuf);
 }
 pp->cflags &= ~(0x0004|0x0008);
}

variable_types:
tbuf
char [16]

user_defined_types: struct player_cache { int player; int money; int queue; int qmax; int cflags; struct player_cache *next; }


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

pool_init(6LL, 32LL);
result = real_hashinit(&pcache_htab, 23LL, "player_c.c", 35LL);
pcache_head = 0LL;
return result;
}

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

pool_init(6LL, 32LL);
result = real_hashinit(&pcache_htab, 23LL, "player_c.c", 35LL);
pcache_head = 0LL;
return result;
}

original_code:
void pcache_init(void)
{
 pool_init(6, sizeof(PCACHE));
 real_hashinit((HASHTAB *)&pcache_htab, 23 ,"player_c.c", 35);
 pcache_head = ((void *)0);
}

canonical_original_code:
void pcache_init()
{
 pool_init(6, sizeof(PCACHE));
 real_hashinit((struct hashtable *)&pcache_htab, 23 ,"player_c.c", 35);
 pcache_head = ((void *)0);
}

user_defined_types: struct hashtable { int hashsize; int mask; int checks; int scans; int max_scan; int hits; int entries; int deletes; int nulls; struct hasharray *entry; int last_hval; struct hashentry *last_entry; int bOnlyOriginals; }

user_defined_types: struct hasharray { struct hashentry *element[500]; }

user_defined_types: struct hashentry { char *target; int *data; int bIsOriginal; struct hashentry *next; }


decompiled_code:
__int64 __fastcall pcache_find(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rax
_DWORD *v4; // rax
__int64 v5; // r12
__int64 v6; // rax

if ( (int)a1 < 0 || mudstate[1830] <= (int)a1 || (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7u) > 4 )
return 0LL;
v1 = 0LL;
if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) == 0 )
return v1;
v2 = real_nhashfind(a1, &pcache_htab, "player_c.c", 65LL);
v1 = v2;
if ( v2 )
{
*(_DWORD *)(v2 + 16) |= 2u;
return v1;
}
v4 = (_DWORD *)pool_alloc(6LL, "pcache_find", 70LL, "player_c.c");
*v4 = a1;
v5 = (__int64)v4;
v4[2] = 0;
v4[4] = 2;
pcache_reload1((unsigned int)a1, (__int64)v4);
v6 = pcache_head;
pcache_head = v5;
*(_QWORD *)(v5 + 24) = v6;
real_nhashadd((unsigned int)a1, v5, &pcache_htab, "player_c.c", 77LL);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rax
_DWORD *v4; // rax
__int64 v5; // r12
__int64 v6; // rax

if ( (int)a1 < 0 || mudstate[1830] <= (int)a1 || (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7u) > 4 )
return 0LL;
v1 = 0LL;
if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) == 0 )
return v1;
v2 = real_nhashfind(a1, &pcache_htab, "player_c.c", 65LL);
v1 = v2;
if ( v2 )
{
*(_DWORD *)(v2 + 16) |= 2u;
return v1;
}
v4 = (_DWORD *)pool_alloc(6LL, "pcache_find", 70LL, "player_c.c");
*v4 = a1;
v5 = (__int64)v4;
v4[2] = 0;
v4[4] = 2;
func0((unsigned int)a1, (__int64)v4);
v6 = pcache_head;
pcache_head = v5;
*(_QWORD *)(v5 + 24) = v6;
real_nhashadd((unsigned int)a1, v5, &pcache_htab, "player_c.c", 77LL);
return v5;
}

original_code:
PCACHE *pcache_find(dbref player)
{
PCACHE *pp;
 if (!(((player) >= 0) && ((player) < mudstate.db_top) && ((db[player].flags & 0x7) <= 0x4)) || !((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0))
  return ((void *)0);
 pp = (PCACHE *)real_nhashfind(player, &pcache_htab, "player_c.c", 65);
 if (pp) {
  pp->cflags |= 0x0002;
  return pp;
 }
 pp = (PCACHE *)pool_alloc(6,"pcache_find",70,"player_c.c");
 pp->queue = 0;
 pp->cflags = 0x0002;
 pp->player = player;
 pcache_reload1(player, pp);
 pp->next = pcache_head;
 pcache_head = pp;
 real_nhashadd(player, (int *)pp, &pcache_htab, "player_c.c", 77);
 return pp;
}

canonical_original_code:
struct player_cache *pcache_find(int player)
{
struct player_cache *pp;
 if (!(((player) >= 0) && ((player) < mudstate.db_top) && ((db[player].flags & 0x7) <= 0x4)) || !((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0))
  return ((void *)0);
 pp = (struct player_cache *)real_nhashfind(player, &pcache_htab, "player_c.c", 65);
 if (pp) {
  pp->cflags |= 0x0002;
  return pp;
 }
 pp = (struct player_cache *)pool_alloc(6,"pcache_find",70,"player_c.c");
 pp->queue = 0;
 pp->cflags = 0x0002;
 pp->player = player;
 pcache_reload1(player, pp);
 pp->next = pcache_head;
 pcache_head = pp;
 real_nhashadd(player, (int *)pp, &pcache_htab, "player_c.c", 77);
 return pp;
}

return_type: struct player_cache { int player; int money; int queue; int qmax; int cflags; struct player_cache *next; } *


decompiled_code:
int __fastcall pcache_reload(__int64 a1)
{
__int64 v1; // rax

v1 = pcache_find(a1);
if ( v1 )
LODWORD(v1) = pcache_reload1((unsigned int)a1, v1);
return v1;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
__int64 v1; // rax

v1 = func3(a1);
if ( v1 )
LODWORD(v1) = func0((unsigned int)a1, v1);
return v1;
}

original_code:
void pcache_reload(dbref player)
{
PCACHE *pp;
 pp = pcache_find(player);
 if (!pp)
  return;
 pcache_reload1(player, pp);
}

canonical_original_code:
void pcache_reload(int player)
{
struct player_cache *pp;
 pp = pcache_find(player);
 if (!pp)
  return;
 pcache_reload1(player, pp);
}


decompiled_code:
void pcache_trim()
{
unsigned int *v0; // rbx
unsigned int *v1; // rbp
unsigned int v2; // eax
unsigned int *v3; // rdi
unsigned int *v4; // [rsp+8h] [rbp-20h] BYREF

v0 = (unsigned int *)pcache_head;
v4 = (unsigned int *)pcache_head;
if ( pcache_head )
{
v1 = 0LL;
do
{
while ( 1 )
{
v2 = v0[4];
v3 = v0;
v0 = (unsigned int *)*((_QWORD *)v0 + 3);
if ( (v2 & 1) != 0 || !(v3[2] | v2 & 2) )
break;
v4 = v0;
v1 = v3;
v3[4] = v2 & 0xFFFFFFFD;
if ( !v0 )
return;
}
if ( v1 )
*((_QWORD *)v1 + 3) = v0;
else
pcache_head = (__int64)v0;
if ( (v2 & 1) == 0 )
{
pcache_save(v3);
real_nhashdelete(*v4, &pcache_htab, "player_c.c", 128LL);
}
pool_free(6LL, &v4, 130LL, "player_c.c");
v4 = v0;
}
while ( v0 );
}
}

canonical_decompiled_code:
void func5()
{
unsigned int *v0; // rbx
unsigned int *v1; // rbp
unsigned int v2; // eax
unsigned int *v3; // rdi
unsigned int *v4; // [rsp+8h] [rbp-20h] BYREF

v0 = (unsigned int *)pcache_head;
v4 = (unsigned int *)pcache_head;
if ( pcache_head )
{
v1 = 0LL;
do
{
while ( 1 )
{
v2 = v0[4];
v3 = v0;
v0 = (unsigned int *)*((_QWORD *)v0 + 3);
if ( (v2 & 1) != 0 || !(v3[2] | v2 & 2) )
break;
v4 = v0;
v1 = v3;
v3[4] = v2 & 0xFFFFFFFD;
if ( !v0 )
return;
}
if ( v1 )
*((_QWORD *)v1 + 3) = v0;
else
pcache_head = (__int64)v0;
if ( (v2 & 1) == 0 )
{
func1(v3);
real_nhashdelete(*v4, &pcache_htab, "player_c.c", 128LL);
}
pool_free(6LL, &v4, 130LL, "player_c.c");
v4 = v0;
}
while ( v0 );
}
}

original_code:
void pcache_trim(void)
{
PCACHE *pp, *pplast, *ppnext;
 pp = pcache_head;
 pplast = ((void *)0);
 while (pp) {
  if (!(pp->cflags & 0x0001) &&
       (pp->queue || (pp->cflags & 0x0002))) {
   pp->cflags &= ~0x0002;
   pplast = pp;
   pp = pp->next;
  } else {
   ppnext = pp->next;
   if (pplast)
    pplast->next = ppnext;
   else
    pcache_head = ppnext;
   if (!(pp->cflags & 0x0001)) {
    pcache_save(pp);
    real_nhashdelete(pp->player, &pcache_htab, "player_c.c", 128);
   }
   pool_free(6,((char **)&(pp)),130,"player_c.c");
   pp = ppnext;
  }
 }
}

canonical_original_code:
void pcache_trim()
{
struct player_cache *pp; struct player_cache *pplast; struct player_cache *ppnext;
 pp = pcache_head;
 pplast = ((void *)0);
 while (pp) {
  if (!(pp->cflags & 0x0001) &&
       (pp->queue || (pp->cflags & 0x0002))) {
   pp->cflags &= ~0x0002;
   pplast = pp;
   pp = pp->next;
  } else {
   ppnext = pp->next;
   if (pplast)
    pplast->next = ppnext;
   else
    pcache_head = ppnext;
   if (!(pp->cflags & 0x0001)) {
    pcache_save(pp);
    real_nhashdelete(pp->player, &pcache_htab, "player_c.c", 128);
   }
   pool_free(6,((char **)&(pp)),130,"player_c.c");
   pp = ppnext;
  }
 }
}


decompiled_code:
__int64 pcache_sync()
{
__int64 i; // rbx
__int64 result; // rax

for ( i = pcache_head; i; i = *(_QWORD *)(i + 24) )
result = pcache_save((unsigned int *)i);
return result;
}

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

for ( i = pcache_head; i; i = *(_QWORD *)(i + 24) )
result = func1((unsigned int *)i);
return result;
}

original_code:
void pcache_sync(void)
{
PCACHE *pp;
 pp = pcache_head;
 while(pp) {
  pcache_save(pp);
  pp = pp->next;
 }
}

canonical_original_code:
void pcache_sync()
{
struct player_cache *pp;
 pp = pcache_head;
 while(pp) {
  pcache_save(pp);
  pp = pp->next;
 }
}


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

result = (unsigned int *)real_nhashfind(a1, &pcache_htab, "player_c.c", 151LL);
if ( result )
{
result[4] = 1;
result = (unsigned int *)real_nhashdelete(*result, &pcache_htab, "player_c.c", 155LL);
}
return result;
}

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

result = (unsigned int *)real_nhashfind(a1, &pcache_htab, "player_c.c", 151LL);
if ( result )
{
result[4] = 1;
result = (unsigned int *)real_nhashdelete(*result, &pcache_htab, "player_c.c", 155LL);
}
return result;
}

original_code:
void pcache_purge(dbref player)
{
PCACHE *pp;
 pp = (PCACHE *)real_nhashfind(player, &pcache_htab, "player_c.c", 151);
 if (!pp)
  return;
 pp->cflags = 0x0001;
 real_nhashdelete(pp->player, &pcache_htab, "player_c.c", 155);
}

canonical_original_code:
void pcache_purge(int player)
{
struct player_cache *pp;
 pp = (struct player_cache *)real_nhashfind(player, &pcache_htab, "player_c.c", 151);
 if (!pp)
  return;
 pp->cflags = 0x0001;
 real_nhashdelete(pp->player, &pcache_htab, "player_c.c", 155);
}


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

if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) == 0 )
return 0LL;
v3 = pcache_find(a1);
result = 0LL;
if ( v3 )
{
result = (unsigned int)(a2 + *(_DWORD *)(v3 + 8));
*(_DWORD *)(v3 + 8) = result;
}
return result;
}

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

if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) == 0 )
return 0LL;
v3 = func3(a1);
result = 0LL;
if ( v3 )
{
result = (unsigned int)(a2 + *(_DWORD *)(v3 + 8));
*(_DWORD *)(v3 + 8) = result;
}
return result;
}

original_code:
int a_Queue(dbref player, int adj)
{
PCACHE *pp;
 if (((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(player);
  if (pp) {
   pp->queue += adj;
   return pp->queue;
  }
 }
 return 0;
}

canonical_original_code:
int a_Queue(int player, int adj)
{
struct player_cache *pp;
 if (((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(player);
  if (pp) {
   pp->queue += adj;
   return pp->queue;
  }
 }
 return 0;
}

variable_types: adj int


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

result = 3LL * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7);
if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) != 0 )
{
result = pcache_find(a1);
if ( result )
*(_DWORD *)(result + 8) = a2;
}
return result;
}

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

result = 3LL * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7);
if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) != 0 )
{
result = func3(a1);
if ( result )
*(_DWORD *)(result + 8) = a2;
}
return result;
}

original_code:
void s_Queue(dbref player, int val)
{
PCACHE *pp;
 if (((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(player);
  if (pp)
   pp->queue = val;
 }
}

canonical_original_code:
void s_Queue(int player, int val)
{
struct player_cache *pp;
 if (((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(player);
  if (pp)
   pp->queue = val;
 }
}

variable_types: val int


QueueMax

decompiled_code:
__int64 __fastcall QueueMax(unsigned int a1)
{
__int64 v1; // rbp
__int64 result; // rax
__int64 v3; // rax
signed int v4; // eax
int v5; // er12
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // rcx
__int64 v9; // rax
__int64 v10; // rdx
__int64 v11; // rcx
int v12; // edx
int v13; // edx
__int64 v14; // rsi
int v15; // ecx

v1 = 88LL * (int)a1;
if ( (object_types[24 * (*(_DWORD *)(db + v1 + 40) & 7) + 16] & 0x20) == 0 )
return 0LL;
v3 = pcache_find(a1);
if ( !v3 )
return 0LL;
result = *(unsigned int *)(v3 + 12);
if ( (int)result < 0 )
{
v4 = mudstate[1830];
v5 = v4 + 1;
if ( v4 <= (int)a1 || (a1 & 0x80000000) != 0 || (*(_DWORD *)(db + v1 + 40) & 7u) > 4 )
goto LABEL_8;
if ( (unsigned int)evlevchk(a1, 2LL) )
{
if ( mudstate[2077] )
goto LABEL_14;
LABEL_8:
result = (unsigned int)v5;
if ( mudconf[1830] >= v5 )
result = (unsigned int)mudconf[1830];
return result;
}
if ( (*(_BYTE *)(db + v1 + 47) & 0x20) != 0 )
{
LABEL_14:
result = (unsigned int)v5;
if ( mudconf[1831] >= v5 )
result = (unsigned int)mudconf[1831];
return result;
}
if ( (unsigned int)evlevchk(a1, 3LL) )
{
v6 = db;
if ( mudstate[2077] )
goto LABEL_14;
goto LABEL_20;
}
if ( (*(_BYTE *)(db + v1 + 45) & 1) != 0 )
goto LABEL_14;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_14;
v6 = db;
goto LABEL_29;
}
if ( (*(_BYTE *)(db + v1 + 40) & 0x10) != 0 )
goto LABEL_14;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] || a1 == 1 )
goto LABEL_14;
v6 = db;
}
else
{
v6 = db;
v13 = *(_DWORD *)(db + v1 + 40);
if ( (v13 & 0x200000) != 0 || a1 == 1 )
goto LABEL_14;
v14 = *(int *)(db + v1 + 24);
v15 = *(_DWORD *)(db + 88 * v14 + 40);
if ( (v15 & 0x200000) != 0 )
{
if ( ((v15 | v13) & 0x2000000) != 0 || (_DWORD)v14 == a1 )
goto LABEL_14;
LABEL_29:
v8 = *(int *)(v6 + v1 + 24);
v10 = v6 + 88 * v8;
if ( (*(_BYTE *)(v10 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(v6 + v1 + 43) & 2) != 0 || (*(_BYTE *)(v10 + 43) & 2) != 0 )
goto LABEL_14;
LABEL_23:
if ( (_DWORD)v8 != a1 )
goto LABEL_8;
goto LABEL_14;
}
LABEL_20:
v7 = v6 + v1;
v8 = *(int *)(v7 + 24);
v9 = 88 * v8 + v6;
if ( (*(_BYTE *)(v9 + 47) & 0x20) == 0 )
goto LABEL_8;
if ( (*(_BYTE *)(v7 + 43) & 2) != 0 || (*(_BYTE *)(v9 + 43) & 2) != 0 )
goto LABEL_14;
goto LABEL_23;
}
}
v11 = *(int *)(v6 + v1 + 24);
v12 = *(_DWORD *)(v6 + 88 * v11 + 40);
if ( (v12 & 0x10) != 0 && (((*(_DWORD *)(v6 + v1 + 40) | v12) & 0x2000000) != 0 || (_DWORD)v11 == a1) )
goto LABEL_14;
goto LABEL_29;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1)
{
__int64 v1; // rbp
__int64 result; // rax
__int64 v3; // rax
signed int v4; // eax
int v5; // er12
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // rcx
__int64 v9; // rax
__int64 v10; // rdx
__int64 v11; // rcx
int v12; // edx
int v13; // edx
__int64 v14; // rsi
int v15; // ecx

v1 = 88LL * (int)a1;
if ( (object_types[24 * (*(_DWORD *)(db + v1 + 40) & 7) + 16] & 0x20) == 0 )
return 0LL;
v3 = func3(a1);
if ( !v3 )
return 0LL;
result = *(unsigned int *)(v3 + 12);
if ( (int)result < 0 )
{
v4 = mudstate[1830];
v5 = v4 + 1;
if ( v4 <= (int)a1 || (a1 & 0x80000000) != 0 || (*(_DWORD *)(db + v1 + 40) & 7u) > 4 )
goto LABEL_8;
if ( (unsigned int)evlevchk(a1, 2LL) )
{
if ( mudstate[2077] )
goto LABEL_14;
LABEL_8:
result = (unsigned int)v5;
if ( mudconf[1830] >= v5 )
result = (unsigned int)mudconf[1830];
return result;
}
if ( (*(_BYTE *)(db + v1 + 47) & 0x20) != 0 )
{
LABEL_14:
result = (unsigned int)v5;
if ( mudconf[1831] >= v5 )
result = (unsigned int)mudconf[1831];
return result;
}
if ( (unsigned int)evlevchk(a1, 3LL) )
{
v6 = db;
if ( mudstate[2077] )
goto LABEL_14;
goto LABEL_20;
}
if ( (*(_BYTE *)(db + v1 + 45) & 1) != 0 )
goto LABEL_14;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_14;
v6 = db;
goto LABEL_29;
}
if ( (*(_BYTE *)(db + v1 + 40) & 0x10) != 0 )
goto LABEL_14;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] || a1 == 1 )
goto LABEL_14;
v6 = db;
}
else
{
v6 = db;
v13 = *(_DWORD *)(db + v1 + 40);
if ( (v13 & 0x200000) != 0 || a1 == 1 )
goto LABEL_14;
v14 = *(int *)(db + v1 + 24);
v15 = *(_DWORD *)(db + 88 * v14 + 40);
if ( (v15 & 0x200000) != 0 )
{
if ( ((v15 | v13) & 0x2000000) != 0 || (_DWORD)v14 == a1 )
goto LABEL_14;
LABEL_29:
v8 = *(int *)(v6 + v1 + 24);
v10 = v6 + 88 * v8;
if ( (*(_BYTE *)(v10 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(v6 + v1 + 43) & 2) != 0 || (*(_BYTE *)(v10 + 43) & 2) != 0 )
goto LABEL_14;
LABEL_23:
if ( (_DWORD)v8 != a1 )
goto LABEL_8;
goto LABEL_14;
}
LABEL_20:
v7 = v6 + v1;
v8 = *(int *)(v7 + 24);
v9 = 88 * v8 + v6;
if ( (*(_BYTE *)(v9 + 47) & 0x20) == 0 )
goto LABEL_8;
if ( (*(_BYTE *)(v7 + 43) & 2) != 0 || (*(_BYTE *)(v9 + 43) & 2) != 0 )
goto LABEL_14;
goto LABEL_23;
}
}
v11 = *(int *)(v6 + v1 + 24);
v12 = *(_DWORD *)(v6 + 88 * v11 + 40);
if ( (v12 & 0x10) != 0 && (((*(_DWORD *)(v6 + v1 + 40) | v12) & 0x2000000) != 0 || (_DWORD)v11 == a1) )
goto LABEL_14;
goto LABEL_29;
}
return result;
}

original_code:
int QueueMax(dbref player)
{
   PCACHE *pp;
   int m;
   m = 0;
   if (((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0)) {
      pp = pcache_find(player);
      if (pp) {
         if (pp->qmax >= 0) {
            m = pp->qmax;
         } else {
            m = mudstate.db_top + 1;
            if ( (((player) >= 0) && ((player) < mudstate.db_top) && ((db[player].flags & 0x7) <= 0x4)) && (evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
               if (m < mudconf.wizqueuemax)
                  m = mudconf.wizqueuemax;
            } else {
               if (m < mudconf.queuemax)
                  m = mudconf.queuemax;
            }
         }
      }
   }
   return m;
}

canonical_original_code:
int QueueMax(int player)
{
   struct player_cache *pp;
   int m;
   m = 0;
   if (((object_types[(db[player].flags & 0x7)].flags & 0x0020) != 0)) {
      pp = pcache_find(player);
      if (pp) {
         if (pp->qmax >= 0) {
            m = pp->qmax;
         } else {
            m = mudstate.db_top + 1;
            if ( (((player) >= 0) && ((player) < mudstate.db_top) && ((db[player].flags & 0x7) <= 0x4)) && (evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
               if (m < mudconf.wizqueuemax)
                  m = mudconf.wizqueuemax;
            } else {
               if (m < mudconf.queuemax)
                  m = mudconf.queuemax;
            }
         }
      }
   }
   return m;
}

variable_types: m int


Pennies

decompiled_code:
int __fastcall Pennies(__int64 a1)
{
__int64 v1; // rax
const char *v2; // rdi
int result; // eax
__int64 v4; // rax

v1 = db + 88LL * (int)a1;
if ( (*(_BYTE *)(v1 + 46) & 0x40) == 0 && (object_types[24 * (*(_DWORD *)(v1 + 40) & 7) + 16] & 0x20) != 0 )
{
v4 = pcache_find(a1);
a1 = (unsigned int)a1;
if ( v4 )
return *(_DWORD *)(v4 + 4);
}
v2 = (const char *)atr_get_raw(a1, 25LL);
if ( v2 )
result = atoi(v2);
else
result = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
__int64 v1; // rax
const char *v2; // rdi
int result; // eax
__int64 v4; // rax

v1 = db + 88LL * (int)a1;
if ( (*(_BYTE *)(v1 + 46) & 0x40) == 0 && (object_types[24 * (*(_DWORD *)(v1 + 40) & 7) + 16] & 0x20) != 0 )
{
v4 = func3(a1);
a1 = (unsigned int)a1;
if ( v4 )
return *(_DWORD *)(v4 + 4);
}
v2 = (const char *)atr_get_raw(a1, 25LL);
if ( v2 )
result = atoi(v2);
else
result = 0;
return result;
}

original_code:
int Pennies(dbref obj)
{
char *cp;
int val;
PCACHE *pp;
 if (!((db[obj].flags2 & 0x00400000) != 0) && ((object_types[(db[obj].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(obj);
  if (pp)
   return pp->money;
 }
 cp = atr_get_raw(obj, 25);
 if (cp)
   val = atoi(cp);
 else
   val = 0;
 return (val);
}

canonical_original_code:
int Pennies(int obj)
{
char *cp;
int val;
struct player_cache *pp;
 if (!((db[obj].flags2 & 0x00400000) != 0) && ((object_types[(db[obj].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(obj);
  if (pp)
   return pp->money;
 }
 cp = atr_get_raw(obj, 25);
 if (cp)
   val = atoi(cp);
 else
   val = 0;
 return (val);
}

variable_types: obj int


decompiled_code:
__int64 __fastcall s_Pennies(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) != 0
&& (result = pcache_find(a1)) != 0 )
{
*(_DWORD *)(result + 16) |= 4u;
*(_DWORD *)(result + 4) = a2;
}
else
{
sprintf(v3, "%d", a2);
result = atr_add_raw(a1, 25LL, v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1, unsigned int a2)
{
__int64 result; // rax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

if ( (object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) != 0
&& (result = func3(a1)) != 0 )
{
*(_DWORD *)(result + 16) |= 4u;
*(_DWORD *)(result + 4) = a2;
}
else
{
sprintf(v3, "%d", a2);
result = atr_add_raw(a1, 25LL, v3);
}
return result;
}

original_code:
void s_Pennies(dbref obj, int howfew)
{
IBUF tbuf;
PCACHE *pp;
 if (((object_types[(db[obj].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(obj);
  if (pp) {
   pp->money = howfew;
   pp->cflags |= 0x0004;
   return;
  }
 }
 sprintf(tbuf, "%d", howfew);
 atr_add_raw(obj, 25, tbuf);
}

canonical_original_code:
void s_Pennies(int obj, int howfew)
{
char tbuf[16];
struct player_cache *pp;
 if (((object_types[(db[obj].flags & 0x7)].flags & 0x0020) != 0)) {
  pp = pcache_find(obj);
  if (pp) {
   pp->money = howfew;
   pp->cflags |= 0x0004;
   return;
  }
 }
 sprintf(tbuf, "%d", howfew);
 atr_add_raw(obj, 25, tbuf);
}

variable_types: howfew int


growbit

decompiled_code:
unsigned __int64 __fastcall growbit(int a1)
{
int v1; // edi
unsigned __int64 result; // rax
int v3; // er13
int v4; // ebx
char *v5; // rax
void *v6; // r14
int v7; // er13
char *v8; // rbp

v1 = a1 + 15;
result = (unsigned int)bm_top;
if ( bm_top < (int)(v1 & 0xFFFFFFF8) )
{
v3 = bm_top + 7;
v4 = v1 >> 3;
if ( bm_top >= 0 )
v3 = bm_top;
v5 = (char *)malloc(v4);
v6 = bitm;
v7 = v3 >> 3;
v8 = v5;
if ( bitm )
{
memmove(v5, bitm, v7);
free(v6);
bitm = v8;
}
else
{
bitm = v5;
if ( !v5 )
{
fatal("db_init cannot grow bitmap ", -1LL, &unk_CD8, 0LL);
v8 = (char *)bitm;
}
}
result = (unsigned __int64)memset(&v8[v7], 0, v4 - v7);
bm_top = v1 & 0xFFFFFFF8;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(int a1)
{
int v1; // edi
unsigned __int64 result; // rax
int v3; // er13
int v4; // ebx
char *v5; // rax
void *v6; // r14
int v7; // er13
char *v8; // rbp

v1 = a1 + 15;
result = (unsigned int)bm_top;
if ( bm_top < (int)(v1 & 0xFFFFFFF8) )
{
v3 = bm_top + 7;
v4 = v1 >> 3;
if ( bm_top >= 0 )
v3 = bm_top;
v5 = (char *)malloc(v4);
v6 = bitm;
v7 = v3 >> 3;
v8 = v5;
if ( bitm )
{
memmove(v5, bitm, v7);
free(v6);
bitm = v8;
}
else
{
bitm = v5;
if ( !v5 )
{
fatal("db_init cannot grow bitmap ", -1LL, &unk_CD8, 0LL);
v8 = (char *)bitm;
}
}
result = (unsigned __int64)memset(&v8[v7], 0, v4 - v7);
bm_top = v1 & 0xFFFFFFF8;
}
return result;
}

original_code:
static void
growbit(int maxblok)
{
 int newtop, newbytes, topbytes;
 char *nbit;
 newtop = (maxblok + 15) & 0xfffffff8;
 if (newtop <= bm_top)
  return;
 newbytes = newtop / 8;
 topbytes = bm_top / 8;
 nbit = (char *)malloc(newbytes);
 if(bitm != (char *)0) {
  bcopy(bitm,(char *)nbit, topbytes);
  free((mall_t)bitm);
 }
 bitm = nbit;
 if(bitm == (char *)0)
  fatal("db_init cannot grow bitmap ",(char *)-1,"\n",(char *)0);
 bzero(bitm+topbytes, (newbytes-topbytes));
 bm_top = newtop;
}

canonical_original_code:
static void growbit(int maxblok)
{
 int newtop; int newbytes; int topbytes;
 char *nbit;
 newtop = (maxblok + 15) & 0xfffffff8;
 if (newtop <= bm_top)
  return;
 newbytes = newtop / 8;
 topbytes = bm_top / 8;
 nbit = (char *)malloc(newbytes);
 if(bitm != (char *)0) {
  bcopy(bitm,(char *)nbit, topbytes);
  free((char *)bitm);
 }
 bitm = nbit;
 if(bitm == (char *)0)
  fatal("db_init cannot grow bitmap ",(char *)-1,"\n",(char *)0);
 bzero(bitm+topbytes, (newbytes-topbytes));
 bm_top = newtop;
}

variable_types: maxblok int

variable_types: newtop int

variable_types: newbytes int

variable_types: topbytes int

variable_types:
nbit
char *


original_code:
static void
dddb_mark(off_t lbn, int siz, int taken)
{
 int bcnt;
 bcnt = (siz % bsiz ? (siz / bsiz) + 1 : (siz / bsiz));
 if(!taken)
  last_free = lbn;
 while(bcnt--) {
  if(lbn >= bm_top - 32)
   growbit(lbn + 512);
  if(taken)
   bitm[lbn >> 3] |= (1 << (lbn & 7));
  else
   bitm[lbn >> 3] &= ~(1 << (lbn & 7));
  lbn++;
 }
}

canonical_original_code:
static void dddb_mark(long lbn, int siz, int taken)
{
 int bcnt;
 bcnt = (siz % bsiz ? (siz / bsiz) + 1 : (siz / bsiz));
 if(!taken)
  last_free = lbn;
 while(bcnt--) {
  if(lbn >= bm_top - 32)
   growbit(lbn + 512);
  if(taken)
   bitm[lbn >> 3] |= (1 << (lbn & 7));
  else
   bitm[lbn >> 3] &= ~(1 << (lbn & 7));
  lbn++;
 }
}

variable_types: lbn long

variable_types: siz int

variable_types: taken int

variable_types: bcnt int


original_code:
static int
dddb_alloc(int siz)
{
 int bcnt;
 int lbn;
 int tbcnt;
 int slbn;
 int overthetop = 0;
 lbn = last_free;
 bcnt = siz % bsiz ? (siz / bsiz) + 1 : (siz / bsiz);
 while(1) {
  if(lbn >= bm_top - 32) {
   if(!overthetop) {
    lbn = 0;
    overthetop++;
   } else {
    growbit(lbn + 512);
   }
  }
  slbn = lbn;
  tbcnt = bcnt;
  while(1) {
   if((bitm[lbn >> 3] & (1 << (lbn & 7))) != 0)
    break;
   if(--tbcnt == 0) {
    for(tbcnt = slbn; bcnt > 0; tbcnt++, bcnt--)
     bitm[tbcnt >> 3] |= (1 << (tbcnt & 7));
    last_free = lbn;
    return(slbn);
   }
   lbn++;
   if(lbn >= bm_top - 32)
    growbit(lbn + 512);
  }
  lbn++;
 }
}

variable_types: lbn int

variable_types: tbcnt int

variable_types: slbn int

variable_types: overthetop int


decompiled_code:
__int64 dddb_initted()
{
return (unsigned int)db_initted;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)db_initted;
}

original_code:
int dddb_initted()
{
 return(db_initted);
}


decompiled_code:
__int64 __fastcall dddb_setbsiz(unsigned int a1)
{
bsiz = a1;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
bsiz = a1;
return a1;
}

original_code:
int dddb_setbsiz(int nbsiz)
{
 return(bsiz = nbsiz);
}

variable_types: nbsiz int


decompiled_code:
__int64 __fastcall dddb_setfile(void *src)
{
unsigned int v1; // er12
size_t v3; // rbx
void *v4; // rax

v1 = db_initted;
if ( db_initted )
return 1LL;
v3 = strlen((const char *)src);
v4 = malloc((unsigned int)(v3 + 1));
if ( !v4 )
return 1LL;
dbfile = memcpy(v4, src, v3 + 1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(void *src)
{
unsigned int v1; // er12
size_t v3; // rbx
void *v4; // rax

v1 = db_initted;
if ( db_initted )
return 1LL;
v3 = strlen((const char *)src);
v4 = malloc((unsigned int)(v3 + 1));
if ( !v4 )
return 1LL;
dbfile = memcpy(v4, src, v3 + 1);
return v1;
}

original_code:
int dddb_setfile(char *fil)
{
 char *xp;
 if(db_initted)
  return(1);
 xp = (char *)malloc((unsigned)strlen(fil) + 1);
 if(xp == (char *)0)
  return(1);
 (void)strcpy(xp,fil);
 dbfile = xp;
 return(0);
}

canonical_original_code:
int dddb_setfile(char *fil)
{
 char *xp;
 if(db_initted)
  return(1);
 xp = (char *)malloc((unsigned int)strlen(fil) + 1);
 if(xp == (char *)0)
  return(1);
 (void)strcpy(xp,fil);
 dbfile = xp;
 return(0);
}

variable_types:
fil
char *

variable_types:
xp
char *


decompiled_code:
__int64 __fastcall dddb_get(__int64 a1)
{
__int64 *v1; // rax
__int64 v2; // rdx
__int64 v3; // rsi
__int64 v4; // rax
__int64 v5; // r8
__int64 v6; // r9
__int64 v7; // r12

if ( !db_initted )
return 0LL;
key = a1;
LODWORD(qword_C78) = 4;
v1 = (__int64 *)dbm_fetch(dbp, a1, qword_C78);
dat = (__int64)v1;
qword_C88 = v2;
if ( !v1 )
return 0LL;
v3 = *v1;
v4 = v1[1];
hbuf = v3;
*(&hbuf + 1) = v4;
if ( fseek(dbf, v3, 0) )
return 0LL;
v7 = objfromFILE(dbf);
if ( !v7 )
mush_logf("db_get: cannot decode ", a1, &unk_CD8, 0LL, v5, v6);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 *v1; // rax
__int64 v2; // rdx
__int64 v3; // rsi
__int64 v4; // rax
__int64 v5; // r8
__int64 v6; // r9
__int64 v7; // r12

if ( !db_initted )
return 0LL;
key = a1;
LODWORD(qword_C78) = 4;
v1 = (__int64 *)dbm_fetch(dbp, a1, qword_C78);
dat = (__int64)v1;
qword_C88 = v2;
if ( !v1 )
return 0LL;
v3 = *v1;
v4 = v1[1];
hbuf = v3;
*(&hbuf + 1) = v4;
if ( fseek(dbf, v3, 0) )
return 0LL;
v7 = objfromFILE(dbf);
if ( !v7 )
mush_logf("db_get: cannot decode ", a1, &unk_CD8, 0LL, v5, v6);
return v7;
}

original_code:
Obj *
dddb_get(Objname *nam)
{
 Obj *ret;
 if(!db_initted)
  return((Obj *)0);
 key.dptr = (char *) nam;
 key.dsize = sizeof(Objname);
 dat = dbm_fetch(dbp,key);
 if(dat.dptr == (char *)0)
  return((Obj *)0);
 bcopy(dat.dptr,(char *)&hbuf,sizeof(hbuf));
 if(fseek(dbf,(long)hbuf.off,0))
  return((Obj *)0);
 if((ret = objfromFILE(dbf)) == (Obj *)0)
  mush_logf("db_get: cannot decode ",nam,"\n",(char *)0);
 return(ret);
}

canonical_original_code:
struct Obj *dddb_get(unsigned int *nam)
{
 struct Obj *ret;
 if(!db_initted)
  return((struct Obj *)0);
 key.dptr = (char *) nam;
 key.dsize = sizeof(Objname);
 dat = dbm_fetch(dbp,key);
 if(dat.dptr == (char *)0)
  return((struct Obj *)0);
 bcopy(dat.dptr,(char *)&hbuf,sizeof(hbuf));
 if(fseek(dbf,(long)hbuf.off,0))
  return((struct Obj *)0);
 if((ret = objfromFILE(dbf)) == (struct Obj *)0)
  mush_logf("db_get: cannot decode ",nam,"\n",(char *)0);
 return(ret);
}

variable_types:
nam
unsigned int *

variable_types: struct Obj { unsigned int name; int at_count; struct Attrib { int attrnum; int size; char *data; } *atrs; } *

user_defined_types: struct Obj { unsigned int name; int at_count; struct Attrib *atrs; }


decompiled_code:
int __fastcall dddb_put(__int64 a1, __int64 a2)
{
int result; // eax
int v5; // eax
int v6; // er13
__int128 *v7; // rax
__int64 v8; // rdx
__int128 v9; // rdi

result = 1;
if ( !db_initted )
return result;
v5 = obj_siz();
LODWORD(qword_C78) = 4;
v6 = v5;
key = a2;
v7 = (__int128 *)dbm_fetch(dbp, a2, qword_C78);
qword_C88 = v8;
dat = (__int64)v7;
if ( v7 )
{
v9 = *v7;
*(_OWORD *)&hbuf = v9;
if ( v6 / bsiz - ((v6 % bsiz == 0) - 1) <= SDWORD2(v9) / bsiz - ((SDWORD2(v9) % bsiz == 0) - 1) )
goto LABEL_4;
dddb_mark((__int64)v9 / bsiz, SDWORD2(v9), 0);
}
hbuf = (int)(bsiz * dddb_alloc(v6));
LABEL_4:
LODWORD(qword_C88) = 16;
*((_DWORD *)&hbuf + 2) = v6;
dat = (__int64)&hbuf;
if ( (unsigned int)dbm_store(dbp, key, qword_C78, &hbuf, qword_C88, 1LL) )
{
mush_logf("db_put: can't dbm_store ", a2, " ", -1LL, &unk_CD8, 0LL);
result = 1;
}
else if ( fseek(dbf, hbuf, 0) )
{
mush_logf("db_put: can't seek ", a2, " ", -1LL, &unk_CD8, 0LL);
result = 1;
}
else if ( (unsigned int)objtoFILE(a1, dbf) || (result = fflush(dbf)) != 0 )
{
mush_logf("db_put: can't save ", a2, " ", -1LL, &unk_CD8, 0LL);
result = 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, __int64 a2)
{
int result; // eax
int v5; // eax
int v6; // er13
__int128 *v7; // rax
__int64 v8; // rdx
__int128 v9; // rdi

result = 1;
if ( !db_initted )
return result;
v5 = obj_siz();
LODWORD(qword_C78) = 4;
v6 = v5;
key = a2;
v7 = (__int128 *)dbm_fetch(dbp, a2, qword_C78);
qword_C88 = v8;
dat = (__int64)v7;
if ( v7 )
{
v9 = *v7;
*(_OWORD *)&hbuf = v9;
if ( v6 / bsiz - ((v6 % bsiz == 0) - 1) <= SDWORD2(v9) / bsiz - ((SDWORD2(v9) % bsiz == 0) - 1) )
goto LABEL_4;
func1((__int64)v9 / bsiz, SDWORD2(v9), 0);
}
hbuf = (int)(bsiz * func2(v6));
LABEL_4:
LODWORD(qword_C88) = 16;
*((_DWORD *)&hbuf + 2) = v6;
dat = (__int64)&hbuf;
if ( (unsigned int)dbm_store(dbp, key, qword_C78, &hbuf, qword_C88, 1LL) )
{
mush_logf("db_put: can't dbm_store ", a2, " ", -1LL, &unk_CD8, 0LL);
result = 1;
}
else if ( fseek(dbf, hbuf, 0) )
{
mush_logf("db_put: can't seek ", a2, " ", -1LL, &unk_CD8, 0LL);
result = 1;
}
else if ( (unsigned int)objtoFILE(a1, dbf) || (result = fflush(dbf)) != 0 )
{
mush_logf("db_put: can't save ", a2, " ", -1LL, &unk_CD8, 0LL);
result = 1;
}
return result;
}

original_code:
int
dddb_put(Obj *obj, Objname *nam)
{
 int nsiz;
 if(!db_initted)
  return(1);
 nsiz = obj_siz(obj);
 key.dptr = (char *) nam;
 key.dsize = sizeof(Objname);
 dat = dbm_fetch(dbp,key);
 if(dat.dptr != (char *)0) {
  bcopy(dat.dptr,(char *)&hbuf,sizeof(hbuf));
  if((nsiz % bsiz ? (nsiz / bsiz) + 1 : (nsiz / bsiz)) > (hbuf.siz % bsiz ? (hbuf.siz / bsiz) + 1 : (hbuf.siz / bsiz))) {
   dddb_mark((hbuf.off/bsiz),hbuf.siz,0);
   hbuf.off = (dddb_alloc(nsiz)*bsiz);
   hbuf.siz = nsiz;
  } else {
   hbuf.siz = nsiz;
  }
 } else {
  hbuf.off = (dddb_alloc(nsiz)*bsiz);
  hbuf.siz = nsiz;
 }
 dat.dptr = (char *)&hbuf;
 dat.dsize = sizeof(hbuf);
 if(dbm_store(dbp,key,dat,1)) {
  mush_logf("db_put: can't dbm_store ",nam," ",(char *)-1,"\n",(char *)0);
  return(1);
 }
 if(fseek(dbf,(long)hbuf.off,0)) {
  mush_logf("db_put: can't seek ",nam," ",(char *)-1,"\n",(char *)0);
  return(1);
 }
 if(objtoFILE(obj,dbf) != 0 || fflush(dbf) != 0) {
  mush_logf("db_put: can't save ",nam," ",(char *)-1,"\n",(char *)0);
  return(1);
 }
 return(0);
}

canonical_original_code:
int dddb_put(struct Obj *obj, unsigned int *nam)
{
 int nsiz;
 if(!db_initted)
  return(1);
 nsiz = obj_siz(obj);
 key.dptr = (char *) nam;
 key.dsize = sizeof(Objname);
 dat = dbm_fetch(dbp,key);
 if(dat.dptr != (char *)0) {
  bcopy(dat.dptr,(char *)&hbuf,sizeof(hbuf));
  if((nsiz % bsiz ? (nsiz / bsiz) + 1 : (nsiz / bsiz)) > (hbuf.siz % bsiz ? (hbuf.siz / bsiz) + 1 : (hbuf.siz / bsiz))) {
   dddb_mark((hbuf.off/bsiz),hbuf.siz,0);
   hbuf.off = (dddb_alloc(nsiz)*bsiz);
   hbuf.siz = nsiz;
  } else {
   hbuf.siz = nsiz;
  }
 } else {
  hbuf.off = (dddb_alloc(nsiz)*bsiz);
  hbuf.siz = nsiz;
 }
 dat.dptr = (char *)&hbuf;
 dat.dsize = sizeof(hbuf);
 if(dbm_store(dbp,key,dat,1)) {
  mush_logf("db_put: can't dbm_store ",nam," ",(char *)-1,"\n",(char *)0);
  return(1);
 }
 if(fseek(dbf,(long)hbuf.off,0)) {
  mush_logf("db_put: can't seek ",nam," ",(char *)-1,"\n",(char *)0);
  return(1);
 }
 if(objtoFILE(obj,dbf) != 0 || fflush(dbf) != 0) {
  mush_logf("db_put: can't save ",nam," ",(char *)-1,"\n",(char *)0);
  return(1);
 }
 return(0);
}

variable_types: nsiz int

user_defined_types: struct Attrib { int attrnum; int size; char *data; }


decompiled_code:
__int64 __fastcall dddb_check(const char *a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = (unsigned int)db_initted;
if ( db_initted )
{
key = (__int64)a1;
LODWORD(qword_C78) = strlen(a1) + 1;
dat = dbm_fetch(dbp, a1, qword_C78);
qword_C88 = v2;
result = dat != 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = (unsigned int)db_initted;
if ( db_initted )
{
key = (__int64)a1;
LODWORD(qword_C78) = strlen(a1) + 1;
dat = dbm_fetch(dbp, a1, qword_C78);
qword_C88 = v2;
result = dat != 0;
}
return result;
}

original_code:
int
dddb_check(char *nam)
{
 if(!db_initted)
  return(0);
 key.dptr = nam;
 key.dsize = strlen(nam) + 1;
 dat = dbm_fetch(dbp,key);
 if(dat.dptr == (char *)0)
  return(0);
 return(1);
}

variable_types:
nam
char *


decompiled_code:
__int64 __fastcall dddb_del(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
const __m128i *v3; // rax
__int64 v4; // rdx
__int64 v5; // r8
__int64 v6; // r9

v1 = -1;
if ( !db_initted )
return v1;
key = a1;
LODWORD(qword_C78) = 4;
v1 = 0;
v3 = (const __m128i *)dbm_fetch(dbp, a1, qword_C78);
dat = (__int64)v3;
qword_C88 = v4;
if ( !v3 )
return v1;
*(__m128i *)&hbuf = _mm_loadu_si128(v3);
if ( (unsigned int)dbm_delete(dbp, key, qword_C78) )
{
mush_logf("db_del: can't delete key ", a1, &unk_CD8, 0LL, v5, v6);
result = 1LL;
}
else
{
dddb_mark(hbuf / bsiz, *((int *)&hbuf + 2), 0);
if ( fseek(dbf, hbuf, 0) )
{
mush_logf("db_del: can't seek ", a1, " ", -1LL, &unk_CD8, 0LL);
}
else
{
fwrite("delobj", 1uLL, 6uLL, dbf);
fflush(dbf);
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
unsigned int v1; // er12
__int64 result; // rax
const __m128i *v3; // rax
__int64 v4; // rdx
__int64 v5; // r8
__int64 v6; // r9

v1 = -1;
if ( !db_initted )
return v1;
key = a1;
LODWORD(qword_C78) = 4;
v1 = 0;
v3 = (const __m128i *)dbm_fetch(dbp, a1, qword_C78);
dat = (__int64)v3;
qword_C88 = v4;
if ( !v3 )
return v1;
*(__m128i *)&hbuf = _mm_loadu_si128(v3);
if ( (unsigned int)dbm_delete(dbp, key, qword_C78) )
{
mush_logf("db_del: can't delete key ", a1, &unk_CD8, 0LL, v5, v6);
result = 1LL;
}
else
{
func1(hbuf / bsiz, *((int *)&hbuf + 2), 0);
if ( fseek(dbf, hbuf, 0) )
{
mush_logf("db_del: can't seek ", a1, " ", -1LL, &unk_CD8, 0LL);
}
else
{
fwrite("delobj", 1uLL, 6uLL, dbf);
fflush(dbf);
}
result = 0LL;
}
return result;
}

original_code:
int
dddb_del(Objname *nam)
{
 if(!db_initted)
  return(-1);
 key.dptr = (char *) nam;
 key.dsize = sizeof(Objname);
 dat = dbm_fetch(dbp,key);
 if(dat.dptr == (char *)0)
  return(0);
 bcopy(dat.dptr,(char *)&hbuf,sizeof(hbuf));
 if(dbm_delete(dbp,key)) {
  mush_logf("db_del: can't delete key ",nam,"\n",(char *)0);
  return(1);
 }
 dddb_mark((hbuf.off/bsiz),hbuf.siz,0);
 if(fseek(dbf,(long)hbuf.off,0))
  mush_logf("db_del: can't seek ",nam," ",(char *)-1,"\n",(char *)0);
 else {
  fprintf(dbf,"delobj");
  fflush(dbf);
 }
 return(0);
}

canonical_original_code:
int dddb_del(unsigned int *nam)
{
 if(!db_initted)
  return(-1);
 key.dptr = (char *) nam;
 key.dsize = sizeof(Objname);
 dat = dbm_fetch(dbp,key);
 if(dat.dptr == (char *)0)
  return(0);
 bcopy(dat.dptr,(char *)&hbuf,sizeof(hbuf));
 if(dbm_delete(dbp,key)) {
  mush_logf("db_del: can't delete key ",nam,"\n",(char *)0);
  return(1);
 }
 dddb_mark((hbuf.off/bsiz),hbuf.siz,0);
 if(fseek(dbf,(long)hbuf.off,0))
  mush_logf("db_del: can't seek ",nam," ",(char *)-1,"\n",(char *)0);
 else {
  fprintf(dbf,"delobj");
  fflush(dbf);
 }
 return(0);
}


fixcase

decompiled_code:
void __fastcall fixcase(_BYTE *a1)
{
char v1; // bl
_BYTE *v2; // rbp
const unsigned __int16 **v3; // r12

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = _ctype_b_loc();
do
{
if ( ((*v3)[v1] & 0x200) != 0 )
*v2 = toupper(v1);
v1 = *++v2;
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func0(_BYTE *a1)
{
char v1; // bl
_BYTE *v2; // rbp
const unsigned __int16 **v3; // r12

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = _ctype_b_loc();
do
{
if ( ((*v3)[v1] & 0x200) != 0 )
*v2 = toupper(v1);
v1 = *++v2;
}
while ( v1 );
}
}

original_code:
static void fixcase(char *name)
{
 char *cp = name;
 while (*cp) {
  if (((*__ctype_b_loc ())[(int) (((int)*cp))] & (unsigned short int) _ISlower)) *cp = toupper((int)*cp);
  cp++;
 }
 return;
}

canonical_original_code:
static void fixcase(char *name)
{
 char *cp = name;
 while (*cp) {
  if (((*__ctype_b_loc ())[(int) (((int)*cp))] & (unsigned short) _ISlower)) *cp = toupper((int)*cp);
  cp++;
 }
 return;
}

variable_types:
name
char *

variable_types:
cp
char *


decompiled_code:
void *__fastcall store_string(void *src)
{
size_t v1; // rbx
int v2; // er12
void *v3; // r8

v1 = strlen((const char *)src);
if ( stringblock )
{
v2 = stringblock_hwm;
if ( 1000 - stringblock_hwm > (int)v1 )
{
v3 = (void *)(stringblock_hwm + stringblock);
goto LABEL_5;
}
}
stringblock = (__int64)malloc(0x3E8uLL);
v3 = (void *)stringblock;
if ( stringblock )
{
v2 = 0;
LABEL_5:
v3 = memcpy(v3, src, v1 + 1);
stringblock_hwm = v2 + v1 + 1;
}
return v3;
}

canonical_decompiled_code:
void *__fastcall func1(void *src)
{
size_t v1; // rbx
int v2; // er12
void *v3; // r8

v1 = strlen((const char *)src);
if ( stringblock )
{
v2 = stringblock_hwm;
if ( 1000 - stringblock_hwm > (int)v1 )
{
v3 = (void *)(stringblock_hwm + stringblock);
goto LABEL_5;
}
}
stringblock = (__int64)malloc(0x3E8uLL);
v3 = (void *)stringblock;
if ( stringblock )
{
v2 = 0;
LABEL_5:
v3 = memcpy(v3, src, v1 + 1);
stringblock_hwm = v2 + v1 + 1;
}
return v3;
}

original_code:
static char *store_string(char *str)
{
 int len;
 char *ret;
 len = strlen(str);
 if(!stringblock || (1000 - stringblock_hwm) < (len+1)){
  stringblock = (char *) malloc(1000);
  if(!stringblock)
   return((char *)0);
  stringblock_hwm = 0;
 }
 ret = stringblock + stringblock_hwm;
 strcpy(ret, str);
 stringblock_hwm += (len + 1);
 return(ret);
}

variable_types:
str
char *

variable_types: len int

variable_types:
ret
char *


decompiled_code:
void *vattr_init()
{
void *result; // rax

result = calloc(0x800uLL, 1uLL);
vfreelist = 0LL;
vhash = (__int64)result;
vstats_count = 0;
vstats_name_cnt = 0;
vstats_lookups = 0;
return result;
}

canonical_decompiled_code:
void *func2()
{
void *result; // rax

result = calloc(0x800uLL, 1uLL);
vfreelist = 0LL;
vhash = (__int64)result;
vstats_count = 0;
vstats_name_cnt = 0;
vstats_lookups = 0;
return result;
}

original_code:
void vattr_init(void)
{
 VATTR **vpp;
 int i;
 vhash = (VATTR **)malloc(256*sizeof(VATTR *));
 vfreelist = ((void *)0);
 for (i = 0, vpp = vhash; i < 256; i++)
  *vpp++ = ((void *)0);
 vstats_count = 0;
 vstats_name_cnt = 0;
 vstats_lookups = 0;
}

canonical_original_code:
void vattr_init()
{
 struct user_attribute **vpp;
 int i;
 vhash = (struct user_attribute **)malloc(256*sizeof(struct user_attribute *));
 vfreelist = ((void *)0);
 for (i = 0, vpp = vhash; i < 256; i++)
  *vpp++ = ((void *)0);
 vstats_count = 0;
 vstats_name_cnt = 0;
 vstats_lookups = 0;
}

variable_types: struct user_attribute { char *name; int number; int flags; struct user_attribute *next; } **

variable_types: i int


decompiled_code:
__int64 __fastcall vattr_find(char *s1)
{
int v1; // eax
__int64 *v2; // r13
__int64 v3; // r12
__int64 v4; // rbp
__int64 result; // rax

fixcase(s1);
if ( !(unsigned int)ok_attr_name(s1) )
return 0LL;
v1 = real_hashval(s1, 255LL, "vattr.c", 80LL);
++vstats_lookups;
v2 = (__int64 *)(vhash + 8LL * v1);
v3 = *v2;
if ( !*v2 )
return 0LL;
v4 = 0LL;
while ( strcmp(s1, *(const char **)v3) )
{
v4 = v3;
if ( !*(_QWORD *)(v3 + 16) )
return 0LL;
v3 = *(_QWORD *)(v3 + 16);
}
if ( v4 )
{
*(_QWORD *)(v4 + 16) = *(_QWORD *)(v3 + 16);
*(_QWORD *)(v3 + 16) = *v2;
result = v3;
*v2 = v3;
return result;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1)
{
int v1; // eax
__int64 *v2; // r13
__int64 v3; // r12
__int64 v4; // rbp
__int64 result; // rax

func0(s1);
if ( !(unsigned int)ok_attr_name(s1) )
return 0LL;
v1 = real_hashval(s1, 255LL, "vattr.c", 80LL);
++vstats_lookups;
v2 = (__int64 *)(vhash + 8LL * v1);
v3 = *v2;
if ( !*v2 )
return 0LL;
v4 = 0LL;
while ( strcmp(s1, *(const char **)v3) )
{
v4 = v3;
if ( !*(_QWORD *)(v3 + 16) )
return 0LL;
v3 = *(_QWORD *)(v3 + 16);
}
if ( v4 )
{
*(_QWORD *)(v4 + 16) = *(_QWORD *)(v3 + 16);
*(_QWORD *)(v3 + 16) = *v2;
result = v3;
*v2 = v3;
return result;
}
return v3;
}

original_code:
VATTR *vattr_find(char *name)
{
 register VATTR *vp,*vprev;
 int hash;
 fixcase(name);
 if (!ok_attr_name(name))
  return(((void *)0));
 hash = real_hashval((name), 0xff, "vattr.c", 80);
 vstats_lookups++;
 vprev = ((void *)0);
 for (vp = vhash[hash]; vp != ((void *)0);vprev = vp, vp = vp->next) {
  if (!strcmp(name, vp->name))
   break;
 }
 if(vp && vprev){
  vprev->next = vp->next;
  vp->next = vhash[hash];
  vhash[hash] = vp;
 }
 return(vp);
}

canonical_original_code:
struct user_attribute *vattr_find(char *name)
{
 register struct user_attribute *vp; register struct user_attribute *vprev;
 int hash;
 fixcase(name);
 if (!ok_attr_name(name))
  return(((void *)0));
 hash = real_hashval((name), 0xff, "vattr.c", 80);
 vstats_lookups++;
 vprev = ((void *)0);
 for (vp = vhash[hash]; vp != ((void *)0);vprev = vp, vp = vp->next) {
  if (!strcmp(name, vp->name))
   break;
 }
 if(vp && vprev){
  vprev->next = vp->next;
  vp->next = vhash[hash];
  vhash[hash] = vp;
 }
 return(vp);
}

variable_types: struct user_attribute { char *name; int number; int flags; struct user_attribute *next; } *

variable_types: hash int


decompiled_code:
__int64 __fastcall vattr_define(char *s1, int a2, int a3)
{
__int64 v4; // r12
int v5; // eax
__int64 v6; // rdx
void *v7; // rax
int v8; // eax
__int64 v9; // rdi
__int64 *v10; // rax
char *v12; // rax
char *v13; // rdx

if ( strlen(s1) > 0x40 )
s1[63] = 0;
fixcase(s1);
if ( !(unsigned int)ok_attr_name(s1) || vattr_find(s1) )
return 0LL;
v4 = vfreelist;
if ( vfreelist )
{
v5 = vstats_freecnt - 1;
}
else
{
v12 = (char *)malloc(0x3B10uLL);
v4 = (__int64)v12;
v13 = v12 + 15096;
do
{
v12 += 24;
*((_QWORD *)v12 - 1) = v12;
}
while ( v12 != v13 );
*(_QWORD *)(v4 + 15112) = 0LL;
v5 = 629;
}
v6 = *(_QWORD *)(v4 + 16);
++vstats_count;
vstats_freecnt = v5;
vfreelist = v6;
vstats_name_cnt += strlen(s1);
v7 = store_string(s1);
*(_DWORD *)(v4 + 12) = a3;
*(_DWORD *)(v4 + 8) = a2;
*(_QWORD *)v4 = v7;
v8 = real_hashval(s1, 255LL, "vattr.c", 146LL);
v9 = *(unsigned int *)(v4 + 8);
v10 = (__int64 *)(vhash + 8LL * v8);
*(_QWORD *)(v4 + 16) = *v10;
*v10 = v4;
anum_extend(v9);
*(_QWORD *)(anum_table + 8LL * *(int *)(v4 + 8)) = v4;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s1, int a2, int a3)
{
__int64 v4; // r12
int v5; // eax
__int64 v6; // rdx
void *v7; // rax
int v8; // eax
__int64 v9; // rdi
__int64 *v10; // rax
char *v12; // rax
char *v13; // rdx

if ( strlen(s1) > 0x40 )
s1[63] = 0;
func0(s1);
if ( !(unsigned int)ok_attr_name(s1) || func3(s1) )
return 0LL;
v4 = vfreelist;
if ( vfreelist )
{
v5 = vstats_freecnt - 1;
}
else
{
v12 = (char *)malloc(0x3B10uLL);
v4 = (__int64)v12;
v13 = v12 + 15096;
do
{
v12 += 24;
*((_QWORD *)v12 - 1) = v12;
}
while ( v12 != v13 );
*(_QWORD *)(v4 + 15112) = 0LL;
v5 = 629;
}
v6 = *(_QWORD *)(v4 + 16);
++vstats_count;
vstats_freecnt = v5;
vfreelist = v6;
vstats_name_cnt += strlen(s1);
v7 = func1(s1);
*(_DWORD *)(v4 + 12) = a3;
*(_DWORD *)(v4 + 8) = a2;
*(_QWORD *)v4 = v7;
v8 = real_hashval(s1, 255LL, "vattr.c", 146LL);
v9 = *(unsigned int *)(v4 + 8);
v10 = (__int64 *)(vhash + 8LL * v8);
*(_QWORD *)(v4 + 16) = *v10;
*v10 = v4;
anum_extend(v9);
*(_QWORD *)(anum_table + 8LL * *(int *)(v4 + 8)) = v4;
return v4;
}

original_code:
VATTR *vattr_define(char *name, int number, int flags)
{
 VATTR *vp;
 int hash;
 if(strlen(name) > 64)
  name[64 - 1] = '\0';
 fixcase(name);
 if(!ok_attr_name(name))
  return(((void *)0));
 if ((vp = vattr_find(name)) != ((void *)0))
  return(((void *)0));
 if (vfreelist == ((void *)0)) {
  vfreelist = vp = (VATTR *)malloc(630 * sizeof(VATTR));
  for (hash = 0; hash < (630 -1); hash++, vp++)
   vp->next = vp + 1;
  vp->next = ((void *)0);
  vstats_freecnt = 630;
 }
 vp = vfreelist;
 vfreelist = vp->next;
 vstats_freecnt--;
 vstats_count++;
 vstats_name_cnt += strlen(name);
 vp->name = store_string(name);
 vp->flags = flags;
 vp->number = number;
 hash = real_hashval((name), 0xff, "vattr.c", 146);
 vp->next = vhash[hash];
 vhash[hash] = vp;
 anum_extend(vp->number);
 anum_table[(vp->number)] = (ATTR *)vp;
 return(vp);
}

canonical_original_code:
struct user_attribute *vattr_define(char *name, int number, int flags)
{
 struct user_attribute *vp;
 int hash;
 if(strlen(name) > 64)
  name[64 - 1] = '\0';
 fixcase(name);
 if(!ok_attr_name(name))
  return(((void *)0));
 if ((vp = vattr_find(name)) != ((void *)0))
  return(((void *)0));
 if (vfreelist == ((void *)0)) {
  vfreelist = vp = (struct user_attribute *)malloc(630 * sizeof(VATTR));
  for (hash = 0; hash < (630 -1); hash++, vp++)
   vp->next = vp + 1;
  vp->next = ((void *)0);
  vstats_freecnt = 630;
 }
 vp = vfreelist;
 vfreelist = vp->next;
 vstats_freecnt--;
 vstats_count++;
 vstats_name_cnt += strlen(name);
 vp->name = store_string(name);
 vp->flags = flags;
 vp->number = number;
 hash = real_hashval((name), 0xff, "vattr.c", 146);
 vp->next = vhash[hash];
 vhash[hash] = vp;
 anum_extend(vp->number);
 anum_table[(vp->number)] = (struct attr *)vp;
 return(vp);
}

variable_types: number int

variable_types: flags int

return_type: struct user_attribute { char *name; int number; int flags; struct user_attribute *next; } *

user_defined_types: struct attr { char *name; int number; int flags; int (*check)(int, int, int, int, char *); }


decompiled_code:
__int64 __fastcall vattr_alloc(char *s1, int a2)
{
unsigned int v2; // eax
unsigned int v3; // er12

v2 = mudstate[1783];
v3 = v2 + 1;
if ( (v2 & 0x7F) != 0 )
{
mudstate[1783] = v3;
v3 = v2;
}
else
{
mudstate[1783] = v2 + 2;
}
anum_extend(v3);
return vattr_define(s1, v3, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s1, int a2)
{
unsigned int v2; // eax
unsigned int v3; // er12

v2 = mudstate[1783];
v3 = v2 + 1;
if ( (v2 & 0x7F) != 0 )
{
mudstate[1783] = v3;
v3 = v2;
}
else
{
mudstate[1783] = v2 + 2;
}
anum_extend(v3);
return func4(s1, v3, a2);
}

original_code:
VATTR *vattr_alloc(char *name, int flags)
{
 int number;
 if (((number = mudstate.attr_next++) & 0x7f) == 0)
  number = mudstate.attr_next++;
 anum_extend(number);
 return(vattr_define(name, number, flags));
}

canonical_original_code:
struct user_attribute *vattr_alloc(char *name, int flags)
{
 int number;
 if (((number = mudstate.attr_next++) & 0x7f) == 0)
  number = mudstate.attr_next++;
 anum_extend(number);
 return(vattr_define(name, number, flags));
}

user_defined_types: struct user_attribute { char *name; int number; int flags; struct user_attribute *next; }


decompiled_code:
__int64 __fastcall vattr_delete(char *s1)
{
__int64 result; // rax
__int64 *v2; // r14
__int64 v3; // rbx
__int64 v4; // r13
const char *v5; // r12
int v6; // er8
__int64 v7; // rbp

fixcase(s1);
result = ok_attr_name(s1);
if ( (_DWORD)result )
{
result = (int)real_hashval(s1, 255LL, "vattr.c", 165LL);
v2 = (__int64 *)(vhash + 8LL * (int)result);
v3 = *v2;
if ( *v2 )
{
v4 = 0LL;
while ( 1 )
{
v5 = *(const char **)v3;
v6 = strcmp(s1, *(const char **)v3);
result = *(_QWORD *)(v3 + 16);
if ( !v6 )
break;
v4 = v3;
if ( !result )
return result;
v3 = *(_QWORD *)(v3 + 16);
}
v7 = *(int *)(v3 + 8);
if ( v4 )
*(_QWORD *)(v4 + 16) = result;
else
*v2 = result;
vstats_name_cnt -= strlen(v5);
result = vfreelist;
--vstats_count;
++vstats_freecnt;
*(_QWORD *)(v3 + 16) = vfreelist;
vfreelist = v3;
if ( (_DWORD)v7 )
{
result = anum_table;
*(_QWORD *)(anum_table + 8 * v7) = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *s1)
{
__int64 result; // rax
__int64 *v2; // r14
__int64 v3; // rbx
__int64 v4; // r13
const char *v5; // r12
int v6; // er8
__int64 v7; // rbp

func0(s1);
result = ok_attr_name(s1);
if ( (_DWORD)result )
{
result = (int)real_hashval(s1, 255LL, "vattr.c", 165LL);
v2 = (__int64 *)(vhash + 8LL * (int)result);
v3 = *v2;
if ( *v2 )
{
v4 = 0LL;
while ( 1 )
{
v5 = *(const char **)v3;
v6 = strcmp(s1, *(const char **)v3);
result = *(_QWORD *)(v3 + 16);
if ( !v6 )
break;
v4 = v3;
if ( !result )
return result;
v3 = *(_QWORD *)(v3 + 16);
}
v7 = *(int *)(v3 + 8);
if ( v4 )
*(_QWORD *)(v4 + 16) = result;
else
*v2 = result;
vstats_name_cnt -= strlen(v5);
result = vfreelist;
--vstats_count;
++vstats_freecnt;
*(_QWORD *)(v3 + 16) = vfreelist;
vfreelist = v3;
if ( (_DWORD)v7 )
{
result = anum_table;
*(_QWORD *)(anum_table + 8 * v7) = 0LL;
}
}
}
return result;
}

original_code:
void vattr_delete(char *name)
{
 VATTR *vp, *vpo;
 int number, hash;
 fixcase(name);
 if (!ok_attr_name(name))
  return;
 number = 0;
 hash = real_hashval((name), 0xff, "vattr.c", 165);
 for (vp = vhash[hash], vpo = ((void *)0); vp != ((void *)0);) {
  if (!strcmp(name, vp->name)) {
   number = vp->number;
   if (vpo == ((void *)0))
    vhash[hash] = vp->next;
   else
    vpo->next = vp->next;
                  vstats_name_cnt-=strlen(vp->name);
   vp->next = vfreelist;
   vfreelist = vp;
   vstats_count--;
   vstats_freecnt++;
   break;
  }
  vpo = vp;
  vp = vp->next;
 }
 if (number)
  anum_table[(number)] = ((void *)0);
 return;
}

canonical_original_code:
void vattr_delete(char *name)
{
 struct user_attribute *vp; struct user_attribute *vpo;
 int number; int hash;
 fixcase(name);
 if (!ok_attr_name(name))
  return;
 number = 0;
 hash = real_hashval((name), 0xff, "vattr.c", 165);
 for (vp = vhash[hash], vpo = ((void *)0); vp != ((void *)0);) {
  if (!strcmp(name, vp->name)) {
   number = vp->number;
   if (vpo == ((void *)0))
    vhash[hash] = vp->next;
   else
    vpo->next = vp->next;
                  vstats_name_cnt-=strlen(vp->name);
   vp->next = vfreelist;
   vfreelist = vp;
   vstats_count--;
   vstats_freecnt++;
   break;
  }
  vpo = vp;
  vp = vp->next;
 }
 if (number)
  anum_table[(number)] = ((void *)0);
 return;
}


decompiled_code:
__int64 __fastcall vattr_rename(char *s1, void *src)
{
__int64 *v2; // r14
__int64 v3; // r12
__int64 v4; // r13
int v5; // er8
__int64 v6; // rax
_QWORD *v7; // rax

fixcase(s1);
if ( !(unsigned int)ok_attr_name(s1) )
return 0LL;
if ( strlen((const char *)src) > 0x40 )
*((_BYTE *)src + 63) = 0;
fixcase(src);
if ( !(unsigned int)ok_attr_name(src) )
return 0LL;
v2 = (__int64 *)(vhash + 8LL * (int)real_hashval(s1, 255LL, "vattr.c", 206LL));
v3 = *v2;
if ( !*v2 )
LABEL_15:
vattr_rename_cold();
v4 = 0LL;
while ( 1 )
{
v5 = strcmp(s1, *(const char **)v3);
v6 = *(_QWORD *)(v3 + 16);
if ( !v5 )
break;
v4 = v3;
if ( !v6 )
goto LABEL_15;
v3 = *(_QWORD *)(v3 + 16);
}
if ( v4 )
*(_QWORD *)(v4 + 16) = v6;
else
*v2 = v6;
*(_QWORD *)v3 = store_string(src);
v7 = (_QWORD *)(vhash + 8LL * (int)real_hashval(src, 255LL, "vattr.c", 220LL));
*(_QWORD *)(v3 + 16) = *v7;
*v7 = v3;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *s1, void *src)
{
__int64 *v2; // r14
__int64 v3; // r12
__int64 v4; // r13
int v5; // er8
__int64 v6; // rax
_QWORD *v7; // rax

func0(s1);
if ( !(unsigned int)ok_attr_name(s1) )
return 0LL;
if ( strlen((const char *)src) > 0x40 )
*((_BYTE *)src + 63) = 0;
func0(src);
if ( !(unsigned int)ok_attr_name(src) )
return 0LL;
v2 = (__int64 *)(vhash + 8LL * (int)real_hashval(s1, 255LL, "vattr.c", 206LL));
v3 = *v2;
if ( !*v2 )
LABEL_15:
func12();
v4 = 0LL;
while ( 1 )
{
v5 = strcmp(s1, *(const char **)v3);
v6 = *(_QWORD *)(v3 + 16);
if ( !v5 )
break;
v4 = v3;
if ( !v6 )
goto LABEL_15;
v3 = *(_QWORD *)(v3 + 16);
}
if ( v4 )
*(_QWORD *)(v4 + 16) = v6;
else
*v2 = v6;
*(_QWORD *)v3 = func1(src);
v7 = (_QWORD *)(vhash + 8LL * (int)real_hashval(src, 255LL, "vattr.c", 220LL));
*(_QWORD *)(v3 + 16) = *v7;
*v7 = v3;
return v3;
}

original_code:
VATTR *vattr_rename(char *name, char *newname)
{
 VATTR *vp, *vpo;
 int hash;
 fixcase(name);
 if (!ok_attr_name(name))
  return(((void *)0));
 if(strlen(newname) > 64)
  newname[64 - 1] = '\0';
 fixcase(newname);
 if (!ok_attr_name(newname))
  return(((void *)0));
 hash = real_hashval((name), 0xff, "vattr.c", 206);
 for (vp = vhash[hash], vpo = ((void *)0); vp != ((void *)0);) {
  if (!strcmp(name, vp->name)) {
   if (vpo == ((void *)0))
    vhash[hash] = vp->next;
   else
    vpo->next = vp->next;
   break;
  }
  vpo = vp;
  vp = vp->next;
 }
 vp->name = store_string(newname);
 hash = real_hashval((newname), 0xff, "vattr.c", 220);
 vp->next = vhash[hash];
 vhash[hash] = vp;
 return(vp);
}

canonical_original_code:
struct user_attribute *vattr_rename(char *name, char *newname)
{
 struct user_attribute *vp; struct user_attribute *vpo;
 int hash;
 fixcase(name);
 if (!ok_attr_name(name))
  return(((void *)0));
 if(strlen(newname) > 64)
  newname[64 - 1] = '\0';
 fixcase(newname);
 if (!ok_attr_name(newname))
  return(((void *)0));
 hash = real_hashval((name), 0xff, "vattr.c", 206);
 for (vp = vhash[hash], vpo = ((void *)0); vp != ((void *)0);) {
  if (!strcmp(name, vp->name)) {
   if (vpo == ((void *)0))
    vhash[hash] = vp->next;
   else
    vpo->next = vp->next;
   break;
  }
  vpo = vp;
  vp = vp->next;
 }
 vp->name = store_string(newname);
 hash = real_hashval((newname), 0xff, "vattr.c", 220);
 vp->next = vhash[hash];
 vhash[hash] = vp;
 return(vp);
}

variable_types:
newname
char *


decompiled_code:
__int64 vattr_first()
{
__int64 v0; // rax
char i; // dl
int v2; // esi
__int64 v3; // r8

vhash_index = 0;
v0 = 0LL;
for ( i = 0; ; i = 1 )
{
v3 = *(_QWORD *)(vhash + 8 * v0);
if ( v3 )
break;
v2 = ++v0;
if ( v0 == 256 )
{
vhash_index = v2;
return 0LL;
}
}
if ( i )
vhash_index = v0;
return v3;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v0; // rax
char i; // dl
int v2; // esi
__int64 v3; // r8

vhash_index = 0;
v0 = 0LL;
for ( i = 0; ; i = 1 )
{
v3 = *(_QWORD *)(vhash + 8 * v0);
if ( v3 )
break;
v2 = ++v0;
if ( v0 == 256 )
{
vhash_index = v2;
return 0LL;
}
}
if ( i )
vhash_index = v0;
return v3;
}

original_code:
VATTR *vattr_first(void)
{
 for (vhash_index=0; vhash_index < 256; vhash_index++) {
  if (vhash[vhash_index])
   return vhash[vhash_index];
 }
 return ((void *)0);
}

canonical_original_code:
struct user_attribute *vattr_first()
{
 for (vhash_index=0; vhash_index < 256; vhash_index++) {
  if (vhash[vhash_index])
   return vhash[vhash_index];
 }
 return ((void *)0);
}


decompiled_code:
__int64 __fastcall vattr_next(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rdx
int v4; // ecx

if ( !a1 )
return vattr_first();
if ( *(_QWORD *)(a1 + 16) )
return *(_QWORD *)(a1 + 16);
v2 = vhash_index + 1;
do
{
v4 = v2;
if ( (int)v2 > 255 )
{
vhash_index = v2;
return 0LL;
}
++v2;
v3 = *(_QWORD *)(vhash + 8 * v2 - 8);
}
while ( !v3 );
vhash_index = v4;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rdx
int v4; // ecx

if ( !a1 )
return func8();
if ( *(_QWORD *)(a1 + 16) )
return *(_QWORD *)(a1 + 16);
v2 = vhash_index + 1;
do
{
v4 = v2;
if ( (int)v2 > 255 )
{
vhash_index = v2;
return 0LL;
}
++v2;
v3 = *(_QWORD *)(vhash + 8 * v2 - 8);
}
while ( !v3 );
vhash_index = v4;
return v3;
}

original_code:
VATTR *vattr_next(VATTR *vp)
{
 if (vp == ((void *)0))
  return(vattr_first());
 if (vp->next == ((void *)0)) {
  while (++vhash_index < 256) {
   if (vhash[vhash_index])
    return vhash[vhash_index];
  }
  return(((void *)0));
 }
 return(vp->next);
}

canonical_original_code:
struct user_attribute *vattr_next(struct user_attribute *vp)
{
 if (vp == ((void *)0))
  return(vattr_first());
 if (vp->next == ((void *)0)) {
  while (++vhash_index < 256) {
   if (vhash[vhash_index])
    return vhash[vhash_index];
  }
  return(((void *)0));
 }
 return(vp->next);
}

variable_types:
vp
struct user_attribute *