IntersectPointGetDistance

decompiled_code:
float __fastcall IntersectPointGetDistance(__int64 a1)
{
return *(float *)(a1 + 24);
}

canonical_decompiled_code:
float __fastcall func5(__int64 a1)
{
return *(float *)(a1 + 24);
}

original_code:
float IntersectPointGetDistance(IntersectPoint* self){
 return self->distance;
}

canonical_original_code:
float IntersectPointGetDistance(struct IntersectPoint *self){
 return self->distance;
}

return_type: float


IntersectPointGetType

repo: kellpossible/CRayTracer

decompiled_code:
__int64 __fastcall IntersectPointGetType(__int64 a1)
{
return *(unsigned int *)(a1 + 28);
}

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

original_code:
int IntersectPointGetType(IntersectPoint* ip){
 return ip->type;
}

canonical_original_code:
int IntersectPointGetType(struct IntersectPoint *ip){
 return ip->type;
}

variable_types: struct IntersectPoint { struct Vector3f { float xyz[3]; } position; struct Vector3f normal; float distance; int type; } *

return_type: int

user_defined_types: struct IntersectPoint { struct Vector3f position; struct Vector3f normal; float distance; int type; }


ColourRGBCreateDefault

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

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

original_code:
ColourRGB ColourRGBCreateDefault(void){
 ColourRGB c1;
 c1.rgb[0] = 0;
 c1.rgb[1] = 0;
 c1.rgb[2] = 0;
 return c1;
}

canonical_original_code:
struct ColourRGB ColourRGBCreateDefault(){
 struct ColourRGB c1;
 c1.rgb[0] = 0;
 c1.rgb[1] = 0;
 c1.rgb[2] = 0;
 return c1;
}

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


ColourRGBCreate

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

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

original_code:
ColourRGB ColourRGBCreate(int r, int g, int b){
 ColourRGB c1;
 c1.rgb[0] = 0;
 c1.rgb[1] = 0;
 c1.rgb[2] = 0;
 return c1;
}

canonical_original_code:
struct ColourRGB ColourRGBCreate(int r, int g, int b){
 struct ColourRGB c1;
 c1.rgb[0] = 0;
 c1.rgb[1] = 0;
 c1.rgb[2] = 0;
 return c1;
}

variable_types: r int

variable_types: g int

variable_types: b int


ColourXYZCreateDefault

decompiled_code:
__int64 ColourXYZCreateDefault()
{
return 1065353216LL;
}

original_code:
Vector3f ColourXYZCreateDefault(void){
 Vector3f c1;
 c1.xyz[0] = 1.0f;
 c1.xyz[1] = 1.0f;
 c1.xyz[2] = 1.0f;
 return c1;
}

canonical_original_code:
struct Vector3f ColourXYZCreateDefault(){
 struct Vector3f c1;
 c1.xyz[0] = 1.0f;
 c1.xyz[1] = 1.0f;
 c1.xyz[2] = 1.0f;
 return c1;
}

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


ColourRGBAdd

decompiled_code:
__int64 __fastcall ColourRGBAdd(_DWORD *a1, _DWORD *a2)
{
__int64 v3; // [rsp+0h] [rbp-14h]

LODWORD(v3) = *a1 + *a2;
HIDWORD(v3) = a1[1] + a2[1];
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(_DWORD *a1, _DWORD *a2)
{
__int64 v3; // [rsp+0h] [rbp-14h]

LODWORD(v3) = *a1 + *a2;
HIDWORD(v3) = a1[1] + a2[1];
return v3;
}

original_code:
ColourRGB ColourRGBAdd(const ColourRGB* c1, const ColourRGB* c2){
 ColourRGB c3;
 c3.rgb[0] = c1->rgb[0] + c2->rgb[0];
 c3.rgb[1] = c1->rgb[1] + c2->rgb[1];
 c3.rgb[2] = c1->rgb[2] + c2->rgb[2];
 return c3;
}

canonical_original_code:
struct ColourRGB ColourRGBAdd(struct ColourRGB *c1, struct ColourRGB *c2){
 struct ColourRGB c3;
 c3.rgb[0] = c1->rgb[0] + c2->rgb[0];
 c3.rgb[1] = c1->rgb[1] + c2->rgb[1];
 c3.rgb[2] = c1->rgb[2] + c2->rgb[2];
 return c3;
}


ColourRGBSub

decompiled_code:
__int64 __fastcall ColourRGBSub(_DWORD *a1, _DWORD *a2)
{
__int64 v3; // [rsp+0h] [rbp-14h]

LODWORD(v3) = *a1 - *a2;
HIDWORD(v3) = a1[1] - a2[1];
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1, _DWORD *a2)
{
__int64 v3; // [rsp+0h] [rbp-14h]

LODWORD(v3) = *a1 - *a2;
HIDWORD(v3) = a1[1] - a2[1];
return v3;
}

original_code:
ColourRGB ColourRGBSub(const ColourRGB* c1, const ColourRGB* c2){
 ColourRGB c3;
 c3.rgb[0] = c1->rgb[0] - c2->rgb[0];
 c3.rgb[1] = c1->rgb[1] - c2->rgb[1];
 c3.rgb[2] = c1->rgb[2] - c2->rgb[2];
 return c3;
}

canonical_original_code:
struct ColourRGB ColourRGBSub(struct ColourRGB *c1, struct ColourRGB *c2){
 struct ColourRGB c3;
 c3.rgb[0] = c1->rgb[0] - c2->rgb[0];
 c3.rgb[1] = c1->rgb[1] - c2->rgb[1];
 c3.rgb[2] = c1->rgb[2] - c2->rgb[2];
 return c3;
}


original_code:
ColourRGB ColourRGBAverage4(ColourRGB* c1,
                            ColourRGB* c2,
                            ColourRGB* c3,
                            ColourRGB* c4){
    ColourRGB* c_array[4] = {c1, c2, c3, c4};
    int r_sum = 0, b_sum = 0, g_sum = 0;
    int i=0;
    while (i < 3){
        r_sum += (*(c_array[i])).rgb[0];
        g_sum += (*(c_array[i])).rgb[1];
        b_sum += (*(c_array[i])).rgb[2];
        i++;
    }
    ColourRGB ret_col;
    ret_col.rgb[0] = ((float)r_sum)/3.0f;
    ret_col.rgb[1] = ((float)g_sum)/3.0f;
    ret_col.rgb[2] = ((float)b_sum)/3.0f;
    return ret_col;
}

canonical_original_code:
struct ColourRGB ColourRGBAverage4(struct ColourRGB *c1, struct ColourRGB *c2, struct ColourRGB *c3, struct ColourRGB *c4){
    struct ColourRGB *c_array[4] = {c1, c2, c3, c4};
    int r_sum = 0; int b_sum = 0; int g_sum = 0;
    int i = 0;
    while (i < 3){
        r_sum += (*(c_array[i])).rgb[0];
        g_sum += (*(c_array[i])).rgb[1];
        b_sum += (*(c_array[i])).rgb[2];
        i++;
    }
    struct ColourRGB ret_col;
    ret_col.rgb[0] = ((float)r_sum)/3.0f;
    ret_col.rgb[1] = ((float)g_sum)/3.0f;
    ret_col.rgb[2] = ((float)b_sum)/3.0f;
    return ret_col;
}

variable_types: i int


ColourRGBPrint

decompiled_code:
int __fastcall ColourRGBPrint(unsigned int *a1)
{
return printf("r: %d, g: %d, b: %d\n", *a1, a1[1], a1[2]);
}

canonical_decompiled_code:
int __fastcall func6(unsigned int *a1)
{
return printf("r: %d, g: %d, b: %d\n", *a1, a1[1], a1[2]);
}

original_code:
void ColourRGBPrint(const ColourRGB* c1){
 printf("r: %d, g: %d, b: %d\n",
  c1->rgb[0],
  c1->rgb[1],
  c1->rgb[2]);
}

canonical_original_code:
void ColourRGBPrint(struct ColourRGB *c1){
 printf("r: %d, g: %d, b: %d\n",
  c1->rgb[0],
  c1->rgb[1],
  c1->rgb[2]);
}

return_type: void


decompiled_code:
int __fastcall Colour3fPrint(float *a1)
{
return printf("r: %.3f, g: %.3f, b: %.3f\n", *a1, a1[1], a1[2]);
}

canonical_decompiled_code:
int __fastcall func7(float *a1)
{
return printf("r: %.3f, g: %.3f, b: %.3f\n", *a1, a1[1], a1[2]);
}

original_code:
void Colour3fPrint(const Vector3f* v1){
 printf("r: %.3f, g: %.3f, b: %.3f\n",
  v1->xyz[0],
  v1->xyz[1],
  v1->xyz[2]);
}

canonical_original_code:
void Colour3fPrint(struct Vector3f *v1){
 printf("r: %.3f, g: %.3f, b: %.3f\n",
  v1->xyz[0],
  v1->xyz[1],
  v1->xyz[2]);
}


original_code:
Vector3f ColourRGB2Vector3f(ColourRGB* c1){
 Vector3f v1;
 v1.xyz[0] = ((float)c1->rgb[0])/255.0f;
 v1.xyz[1] = ((float)c1->rgb[1])/255.0f;
 v1.xyz[2] = ((float)c1->rgb[2])/255.0f;
 return v1;
}

canonical_original_code:
struct Vector3f ColourRGB2Vector3f(struct ColourRGB *c1){
 struct Vector3f v1;
 v1.xyz[0] = ((float)c1->rgb[0])/255.0f;
 v1.xyz[1] = ((float)c1->rgb[1])/255.0f;
 v1.xyz[2] = ((float)c1->rgb[2])/255.0f;
 return v1;
}

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


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


decompiled_code:
float __fastcall Vector3fDot(float *a1, float *a2)
{
return (float)((float)(*a1 * *a2) + (float)(a1[1] * a2[1])) + (float)(a1[2] * a2[2]);
}

canonical_decompiled_code:
float __fastcall func0(float *a1, float *a2)
{
return (float)((float)(*a1 * *a2) + (float)(a1[1] * a2[1])) + (float)(a1[2] * a2[2]);
}

original_code:
float Vector3fDot(const Vector3f* v1, const Vector3f* v2){
 return (v1->xyz[0] * v2->xyz[0]) +
  (v1->xyz[1] * v2->xyz[1]) +
  (v1->xyz[2] * v2->xyz[2]);
}

canonical_original_code:
float Vector3fDot(struct Vector3f *v1, struct Vector3f *v2){
 return (v1->xyz[0] * v2->xyz[0]) +
  (v1->xyz[1] * v2->xyz[1]) +
  (v1->xyz[2] * v2->xyz[2]);
}


canonical_original_code:
struct Vector3f Vector3fCross(struct Vector3f *v1, struct Vector3f *v2){
 struct Vector3f v3;
 v3.xyz[0] = (v1->xyz[1] * v2->xyz[2]) - (v1->xyz[2] * v2->xyz[1]);
 v3.xyz[1] = (v1->xyz[2] * v2->xyz[0]) - (v1->xyz[0] * v2->xyz[2]);
 v3.xyz[2] = (v1->xyz[0] * v2->xyz[1]) - (v1->xyz[1] * v2->xyz[0]);
 return v3;
}


original_code:
Vector3f Vector3fSub(const Vector3f* v1, const Vector3f* v2){
 Vector3f v3;
 v3.xyz[0] = v1->xyz[0] - v2->xyz[0];
 v3.xyz[1] = v1->xyz[1] - v2->xyz[1];
 v3.xyz[2] = v1->xyz[2] - v2->xyz[2];
 return v3;
}

canonical_original_code:
struct Vector3f Vector3fSub(struct Vector3f *v1, struct Vector3f *v2){
 struct Vector3f v3;
 v3.xyz[0] = v1->xyz[0] - v2->xyz[0];
 v3.xyz[1] = v1->xyz[1] - v2->xyz[1];
 v3.xyz[2] = v1->xyz[2] - v2->xyz[2];
 return v3;
}


original_code:
Vector3f Vector3fAdd(const Vector3f* v1, const Vector3f* v2){
 Vector3f v3;
 v3.xyz[0] = v1->xyz[0] + v2->xyz[0];
 v3.xyz[1] = v1->xyz[1] + v2->xyz[1];
 v3.xyz[2] = v1->xyz[2] + v2->xyz[2];
 return v3;
}

canonical_original_code:
struct Vector3f Vector3fAdd(struct Vector3f *v1, struct Vector3f *v2){
 struct Vector3f v3;
 v3.xyz[0] = v1->xyz[0] + v2->xyz[0];
 v3.xyz[1] = v1->xyz[1] + v2->xyz[1];
 v3.xyz[2] = v1->xyz[2] + v2->xyz[2];
 return v3;
}


original_code:
Vector3f Vector3fNeg(const Vector3f* v1){
 Vector3f v2;
 v2.xyz[0] = v1->xyz[0] * -1.0f;
 v2.xyz[1] = v1->xyz[1] * -1.0f;
 v2.xyz[2] = v1->xyz[2] * -1.0f;
 return v2;
}

canonical_original_code:
struct Vector3f Vector3fNeg(struct Vector3f *v1){
 struct Vector3f v2;
 v2.xyz[0] = v1->xyz[0] * -1.0f;
 v2.xyz[1] = v1->xyz[1] * -1.0f;
 v2.xyz[2] = v1->xyz[2] * -1.0f;
 return v2;
}


original_code:
Vector3f Vector3fMulV(const Vector3f* v1, const Vector3f* v2){
 Vector3f v3;
 v3.xyz[0] = v1->xyz[0] * v2->xyz[0];
 v3.xyz[1] = v1->xyz[1] * v2->xyz[1];
 v3.xyz[2] = v1->xyz[2] * v2->xyz[2];
 return v3;
}

canonical_original_code:
struct Vector3f Vector3fMulV(struct Vector3f *v1, struct Vector3f *v2){
 struct Vector3f v3;
 v3.xyz[0] = v1->xyz[0] * v2->xyz[0];
 v3.xyz[1] = v1->xyz[1] * v2->xyz[1];
 v3.xyz[2] = v1->xyz[2] * v2->xyz[2];
 return v3;
}


decompiled_code:
__m128i __fastcall Vector3fMulF(float *a1, float a2)
{
unsigned int v2; // xmm2_4
unsigned int v3; // xmm1_4
__m128i v5; // [rsp+0h] [rbp-14h] BYREF

*(float *)&v2 = a2 * a1[1];
*(float *)&v3 = a2 * a1[2];
*(float *)v5.m128i_i32 = a2 * *a1;
*(__int64 *)((char *)v5.m128i_i64 + 4) = __PAIR64__(v3, v2);
return _mm_loadl_epi64(&v5);
}

original_code:
Vector3f Vector3fMulF(const Vector3f* v1, float f1){
 Vector3f v3;
 v3.xyz[0] = v1->xyz[0] * f1;
 v3.xyz[1] = v1->xyz[1] * f1;
 v3.xyz[2] = v1->xyz[2] * f1;
 return v3;
}

canonical_original_code:
struct Vector3f Vector3fMulF(struct Vector3f *v1, float f1){
 struct Vector3f v3;
 v3.xyz[0] = v1->xyz[0] * f1;
 v3.xyz[1] = v1->xyz[1] * f1;
 v3.xyz[2] = v1->xyz[2] * f1;
 return v3;
}


original_code:
Vector3f Vector3fDivF(const Vector3f* v1, float f1){
 Vector3f v2;
 v2.xyz[0] = fDiv(v1->xyz[0], f1);
 v2.xyz[1] = fDiv(v1->xyz[1], f1);
 v2.xyz[2] = fDiv(v1->xyz[2], f1);
 return v2;
}

canonical_original_code:
struct Vector3f Vector3fDivF(struct Vector3f *v1, float f1){
 struct Vector3f v2;
 v2.xyz[0] = fDiv(v1->xyz[0], f1);
 v2.xyz[1] = fDiv(v1->xyz[1], f1);
 v2.xyz[2] = fDiv(v1->xyz[2], f1);
 return v2;
}


decompiled_code:
__int64 __fastcall Vector3fNormalize(float *a1, double a2)
{
float v2; // xmm0_4

v2 = Vector3fDot(a1, a1);
if ( v2 < 0.0 )
*(float *)&a2 = sqrtf(v2);
else
*(float *)&a2 = fsqrt(v2);
Vector3fDivF(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(float *a1, double a2)
{
float v2; // xmm0_4

v2 = func0(a1, a1);
if ( v2 < 0.0 )
*(float *)&a2 = sqrtf(v2);
else
*(float *)&a2 = fsqrt(v2);
func7(a1, a2);
return 0LL;
}

original_code:
Vector3f Vector3fNormalize(const Vector3f* v1){
 float v1_mag = (float)sqrt((float)Vector3fDot(v1, v1));
 Vector3f v2 = Vector3fDivF(v1, v1_mag);
 return v2;
}

canonical_original_code:
struct Vector3f Vector3fNormalize(struct Vector3f *v1){
 float v1_mag = (float)sqrt((float)Vector3fDot(v1, v1));
 struct Vector3f v2 = Vector3fDivF(v1, v1_mag);
 return v2;
}


decompiled_code:
float __fastcall Vector3fMag(float *a1)
{
float v1; // xmm0_4
float result; // xmm0_4

v1 = Vector3fDot(a1, a1);
if ( v1 < 0.0 )
result = sqrtf(v1);
else
result = fsqrt(v1);
return result;
}

canonical_decompiled_code:
float __fastcall func9(float *a1)
{
float v1; // xmm0_4
float result; // xmm0_4

v1 = func0(a1, a1);
if ( v1 < 0.0 )
result = sqrtf(v1);
else
result = fsqrt(v1);
return result;
}

original_code:
float Vector3fMag(const Vector3f* v1){
 return (float)sqrt((float)Vector3fDot(v1, v1));
}

canonical_original_code:
float Vector3fMag(struct Vector3f *v1){
 return (float)sqrt((float)Vector3fDot(v1, v1));
}


decompiled_code:
float __fastcall Vector3fLen(float *a1)
{
float v1; // xmm0_4
float result; // xmm0_4

v1 = Vector3fDot(a1, a1);
if ( v1 < 0.0 )
result = sqrtf(v1);
else
result = fsqrt(v1);
return result;
}

canonical_decompiled_code:
float __fastcall func10(float *a1)
{
float v1; // xmm0_4
float result; // xmm0_4

v1 = func0(a1, a1);
if ( v1 < 0.0 )
result = sqrtf(v1);
else
result = fsqrt(v1);
return result;
}

original_code:
float Vector3fLen(const Vector3f* v1){
 return (float)sqrt((float)Vector3fDot(v1, v1));
}

canonical_original_code:
float Vector3fLen(struct Vector3f *v1){
 return (float)sqrt((float)Vector3fDot(v1, v1));
}


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

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

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

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]; } *

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;
}


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, __m128i a4)
{
double *result; // rax

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

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

result = (double *)malloc(0x18uLL);
*(_QWORD *)result = a1;
result[1] = a2;
*((_DWORD *)result + 4) = _mm_cvtsi128_si32(a3);
*((_DWORD *)result + 5) = _mm_cvtsi128_si32(a4);
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:
void __fastcall LightFree(void *a1)
{
free(a1);
}

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

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; } *


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;
}


RandomCreate

decompiled_code:
__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:
void __fastcall RayFree(void *a1)
{
free(a1);
}

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(__int64 a1)
{
unsigned int v1; // eax

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

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
int v2; // edx

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

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

v1 = 18000 * (unsigned __int16)*a1 + HIWORD(*a1);
*a1 = v1;
v2 = 30903 * (unsigned __int16)a1[1] + HIWORD(a1[1]);
a1[1] = v2;
return (unsigned int)(unsigned __int16)v2 + (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);
}


repo: kenneaal/RhostMUSH

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

result = log_name(a1);
if ( (mudconf[92] & 2) != 0 )
{
v2 = 88LL * a1;
result = 3 * (*(_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:
int __fastcall func8(int a1)
{
int result; // eax
__int64 v2; // rbx

result = func7(a1);
if ( (mudconf[92] & 2) != 0 )
{
v2 = 88LL * a1;
result = 3 * (*(_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:
const char *__fastcall OBJTYP(int a1)
{
const char *result; // rax
unsigned int v2; // edx

result = "??OUT-OF-RANGE??";
if ( a1 >= 0 && *((_DWORD *)&mudstate + 81) > a1 )
{
v2 = *(_DWORD *)(db + 88LL * a1 + 40) & 7;
result = "??OUT-OF-RANGE??";
if ( v2 <= 4 )
{
if ( v2 == 2 )
{
result = "EXIT";
}
else if ( (*(_DWORD *)(db + 88LL * a1 + 40) & 7u) > 2 )
{
result = "??ILLEGAL??";
if ( v2 == 3 )
result = "PLAYER";
}
else
{
result = "ROOM";
if ( v2 )
result = "THING";
}
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func9(int a1)
{
const char *result; // rax
unsigned int v2; // edx

result = "??OUT-OF-RANGE??";
if ( a1 >= 0 && *((_DWORD *)&mudstate + 81) > a1 )
{
v2 = *(_DWORD *)(db + 88LL * a1 + 40) & 7;
result = "??OUT-OF-RANGE??";
if ( v2 <= 4 )
{
if ( v2 == 2 )
{
result = "EXIT";
}
else if ( (*(_DWORD *)(db + 88LL * a1 + 40) & 7u) > 2 )
{
result = "??ILLEGAL??";
if ( v2 == 3 )
result = "PLAYER";
}
else
{
result = "ROOM";
if ( v2 )
result = "THING";
}
}
}
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 = (char *)OBJTYP(a1);
log_text(v1);
sprintf(v4, " #%d(", (unsigned int)a1);
log_text(v4);
if ( a1 >= 0 && *((_DWORD *)&mudstate + 81) > 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 = (char *)func9(a1);
func4(v1);
sprintf(v4, " #%d(", (unsigned int)a1);
func4(v4);
if ( a1 >= 0 && *((_DWORD *)&mudstate + 81) > 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 = (char *)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 = (char *)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)
{
__int64 result; // rax
size_t v8; // rax
void *v9; // r15
size_t v10; // rax
void *v11; // r14
size_t v12; // rax
char *v13; // r13
char v14; // r12
char *v15; // r13
size_t v16; // rax
struct hostent *v17; // rdx
char buf[568]; // [rsp+10h] [rbp-238h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func1(char *name, __int16 a2, const char *a3, const char *a4, const char *a5)
{
__int64 result; // rax
size_t v8; // rax
void *v9; // r15
size_t v10; // rax
void *v11; // r14
size_t v12; // rax
char *v13; // r13
char v14; // r12
char *v15; // r13
size_t v16; // rax
struct hostent *v17; // rdx
char buf[568]; // [rsp+10h] [rbp-238h] BYREF

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

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 )
return safe_copy_str("#-1 NO FUNCTION", a2, a3, 3998LL);
if ( (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 )
return safe_copy_str("#-1 NO FUNCTION", a2, a3, 3998LL);
if ( (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


decompiled_code:
int __fastcall pcache_reload1(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v3; // rdi
int v4; // eax
const char *v5; // rax
int result; // eax
__int64 v7; // r12
__int64 v8; // r12
__int64 v9; // rdx
__int64 v10; // rdx
int v11; // edx
int v12; // eax
int v13; // ecx
int v14; // edx

v2 = a1;
v3 = (const char *)atr_get_raw(a1, 25LL);
v4 = 0;
if ( v3 && *v3 )
v4 = atoi(v3);
*(_DWORD *)(a2 + 4) = v4;
v5 = (const char *)atr_get_raw(v2, 31LL);
if ( v5 && *v5 )
{
result = atoi(v5);
*(_DWORD *)(a2 + 12) = result;
return result;
}
result = evlevchk(v2, 2LL);
if ( result )
{
if ( !mudstate[2077] )
{
LABEL_9:
result = mudconf[1830];
*(_DWORD *)(a2 + 12) = result;
return result;
}
goto LABEL_11;
}
result = 11 * v2;
v7 = 88LL * (int)v2;
if ( (*(_BYTE *)(db + v7 + 47) & 0x20) != 0 )
goto LABEL_11;
result = evlevchk(v2, 3LL);
if ( result )
{
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_14;
}
result = db;
if ( (*(_BYTE *)(db + v7 + 45) & 1) != 0 )
goto LABEL_11;
result = evlevchk(v2, 4LL);
if ( result )
{
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_22;
}
result = db;
if ( (*(_BYTE *)(db + v7 + 40) & 0x10) == 0 )
{
result = evlevchk(v2, 5LL);
if ( result )
{
if ( mudstate[2077] || v2 == 1 )
goto LABEL_11;
}
else
{
result = *(_DWORD *)(db + v7 + 40);
if ( (result & 0x200000) != 0 )
goto LABEL_11;
if ( v2 == 1 )
goto LABEL_11;
v13 = *(_DWORD *)(db + v7 + 24);
v14 = *(_DWORD *)(db + 88LL * v13 + 40);
if ( (v14 & 0x200000) != 0 )
{
result |= v14;
if ( (result & 0x2000000) != 0 || v13 == v2 )
goto LABEL_11;
}
}
v11 = *(_DWORD *)(db + v7 + 24);
v12 = *(_DWORD *)(db + 88LL * v11 + 40);
if ( (v12 & 0x10) == 0 || (result = *(_DWORD *)(db + v7 + 40) | v12, (result & 0x2000000) == 0) && v11 != v2 )
{
LABEL_22:
result = *(_DWORD *)(db + v7 + 24);
v10 = db + 88LL * result;
if ( (*(_BYTE *)(v10 + 45) & 1) != 0
&& ((*(_BYTE *)(db + v7 + 43) & 2) != 0 || (*(_BYTE *)(v10 + 43) & 2) != 0 || result == v2) )
{
goto LABEL_11;
}
LABEL_14:
v8 = db + v7;
result = *(_DWORD *)(v8 + 24);
v9 = db + 88LL * result;
if ( (*(_BYTE *)(v9 + 47) & 0x20) == 0
|| (*(_BYTE *)(v8 + 43) & 2) == 0 && (*(_BYTE *)(v9 + 43) & 2) == 0 && result != v2 )
{
goto LABEL_9;
}
goto LABEL_11;
}
}
LABEL_11:
*(_DWORD *)(a2 + 12) = -1;
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
const char *v3; // rdi
int v4; // eax
const char *v5; // rax
int result; // eax
__int64 v7; // r12
__int64 v8; // r12
__int64 v9; // rdx
__int64 v10; // rdx
int v11; // edx
int v12; // eax
int v13; // ecx
int v14; // edx

v2 = a1;
v3 = (const char *)atr_get_raw(a1, 25LL);
v4 = 0;
if ( v3 && *v3 )
v4 = atoi(v3);
*(_DWORD *)(a2 + 4) = v4;
v5 = (const char *)atr_get_raw(v2, 31LL);
if ( v5 && *v5 )
{
result = atoi(v5);
*(_DWORD *)(a2 + 12) = result;
return result;
}
result = evlevchk(v2, 2LL);
if ( result )
{
if ( !mudstate[2077] )
{
LABEL_9:
result = mudconf[1830];
*(_DWORD *)(a2 + 12) = result;
return result;
}
goto LABEL_11;
}
result = 11 * v2;
v7 = 88LL * (int)v2;
if ( (*(_BYTE *)(db + v7 + 47) & 0x20) != 0 )
goto LABEL_11;
result = evlevchk(v2, 3LL);
if ( result )
{
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_14;
}
result = db;
if ( (*(_BYTE *)(db + v7 + 45) & 1) != 0 )
goto LABEL_11;
result = evlevchk(v2, 4LL);
if ( result )
{
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_22;
}
result = db;
if ( (*(_BYTE *)(db + v7 + 40) & 0x10) == 0 )
{
result = evlevchk(v2, 5LL);
if ( result )
{
if ( mudstate[2077] || v2 == 1 )
goto LABEL_11;
}
else
{
result = *(_DWORD *)(db + v7 + 40);
if ( (result & 0x200000) != 0 )
goto LABEL_11;
if ( v2 == 1 )
goto LABEL_11;
v13 = *(_DWORD *)(db + v7 + 24);
v14 = *(_DWORD *)(db + 88LL * v13 + 40);
if ( (v14 & 0x200000) != 0 )
{
result |= v14;
if ( (result & 0x2000000) != 0 || v13 == v2 )
goto LABEL_11;
}
}
v11 = *(_DWORD *)(db + v7 + 24);
v12 = *(_DWORD *)(db + 88LL * v11 + 40);
if ( (v12 & 0x10) == 0 || (result = *(_DWORD *)(db + v7 + 40) | v12, (result & 0x2000000) == 0) && v11 != v2 )
{
LABEL_22:
result = *(_DWORD *)(db + v7 + 24);
v10 = db + 88LL * result;
if ( (*(_BYTE *)(v10 + 45) & 1) != 0
&& ((*(_BYTE *)(db + v7 + 43) & 2) != 0 || (*(_BYTE *)(v10 + 43) & 2) != 0 || result == v2) )
{
goto LABEL_11;
}
LABEL_14:
v8 = db + v7;
result = *(_DWORD *)(v8 + 24);
v9 = db + 88LL * result;
if ( (*(_BYTE *)(v9 + 47) & 0x20) == 0
|| (*(_BYTE *)(v8 + 43) & 2) == 0 && (*(_BYTE *)(v9 + 43) & 2) == 0 && result != v2 )
{
goto LABEL_9;
}
goto LABEL_11;
}
}
LABEL_11:
*(_DWORD *)(a2 + 12) = -1;
return result;
}

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]);
result = atr_add_raw(*a1, 25LL, v2);
}
if ( (a1[4] & 8) != 0 )
{
sprintf(v2, "%d", a1[3]);
result = atr_add_raw(*a1, 31LL, v2);
}
a1[4] &= 0xFFFFFFF3;
}
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]);
result = atr_add_raw(*a1, 25LL, v2);
}
if ( (a1[4] & 8) != 0 )
{
sprintf(v2, "%d", a1[3]);
result = atr_add_raw(*a1, 31LL, v2);
}
a1[4] &= 0xFFFFFFF3;
}
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; // rbp
__int64 v2; // rax

if ( (int)a1 < 0 )
return 0LL;
if ( mudstate[1830] <= (int)a1 )
return 0LL;
if ( (*(_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 )
{
v2 = real_nhashfind(a1, &pcache_htab, "player_c.c", 65LL);
v1 = v2;
if ( v2 )
{
*(_DWORD *)(v2 + 16) |= 2u;
}
else
{
v1 = pool_alloc(6LL, "pcache_find", 70LL, "player_c.c");
*(_DWORD *)(v1 + 8) = 0;
*(_DWORD *)(v1 + 16) = 2;
*(_DWORD *)v1 = a1;
pcache_reload1((unsigned int)a1, v1);
*(_QWORD *)(v1 + 24) = pcache_head;
pcache_head = v1;
real_nhashadd((unsigned int)a1, v1, &pcache_htab, "player_c.c", 77LL);
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax

if ( (int)a1 < 0 )
return 0LL;
if ( mudstate[1830] <= (int)a1 )
return 0LL;
if ( (*(_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 )
{
v2 = real_nhashfind(a1, &pcache_htab, "player_c.c", 65LL);
v1 = v2;
if ( v2 )
{
*(_DWORD *)(v2 + 16) |= 2u;
}
else
{
v1 = pool_alloc(6LL, "pcache_find", 70LL, "player_c.c");
*(_DWORD *)(v1 + 8) = 0;
*(_DWORD *)(v1 + 16) = 2;
*(_DWORD *)v1 = a1;
func0((unsigned int)a1, v1);
*(_QWORD *)(v1 + 24) = pcache_head;
pcache_head = v1;
real_nhashadd((unsigned int)a1, v1, &pcache_htab, "player_c.c", 77LL);
}
}
return v1;
}

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()
{
__int64 v0; // rdi
__int64 v1; // rbp
unsigned int *v2; // rbx
int v3; // eax
unsigned int *v4; // [rsp+8h] [rbp-20h] BYREF

v0 = pcache_head;
v4 = (unsigned int *)pcache_head;
if ( pcache_head )
{
v1 = 0LL;
do
{
v3 = *(_DWORD *)(v0 + 16);
if ( (v3 & 1) != 0 || !(*(_DWORD *)(v0 + 8) | *(_DWORD *)(v0 + 16) & 2) )
{
v2 = *(unsigned int **)(v0 + 24);
if ( v1 )
*(_QWORD *)(v1 + 24) = v2;
else
pcache_head = *(_QWORD *)(v0 + 24);
if ( (*(_BYTE *)(v0 + 16) & 1) == 0 )
{
pcache_save((unsigned int *)v0);
real_nhashdelete(*v4, &pcache_htab, "player_c.c", 128LL);
}
pool_free(6LL, &v4, 130LL, "player_c.c");
v4 = v2;
}
else
{
*(_DWORD *)(v0 + 16) = v3 & 0xFFFFFFFD;
v4 = *(unsigned int **)(v0 + 24);
v1 = v0;
}
v0 = (__int64)v4;
}
while ( v4 );
}
}

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

v0 = pcache_head;
v4 = (unsigned int *)pcache_head;
if ( pcache_head )
{
v1 = 0LL;
do
{
v3 = *(_DWORD *)(v0 + 16);
if ( (v3 & 1) != 0 || !(*(_DWORD *)(v0 + 8) | *(_DWORD *)(v0 + 16) & 2) )
{
v2 = *(unsigned int **)(v0 + 24);
if ( v1 )
*(_QWORD *)(v1 + 24) = v2;
else
pcache_head = *(_QWORD *)(v0 + 24);
if ( (*(_BYTE *)(v0 + 16) & 1) == 0 )
{
func1((unsigned int *)v0);
real_nhashdelete(*v4, &pcache_htab, "player_c.c", 128LL);
}
pool_free(6LL, &v4, 130LL, "player_c.c");
v4 = v2;
}
else
{
*(_DWORD *)(v0 + 16) = v3 & 0xFFFFFFFD;
v4 = *(unsigned int **)(v0 + 24);
v1 = v0;
}
v0 = (__int64)v4;
}
while ( v4 );
}
}

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

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

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

result = *(_DWORD *)&object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20;
if ( (*(_DWORD *)&object_types[24 * (*(_DWORD *)(db + 88LL * (int)a1 + 40) & 7) + 16] & 0x20) != 0 )
{
v3 = func3(a1);
result = 0LL;
if ( v3 )
{
result = (unsigned int)(*(_DWORD *)(v3 + 8) + a2);
*(_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(__int64 a1)
{
__int64 v1; // r12
__int64 result; // rax
__int64 v3; // rdx
int v4; // eax
int v5; // ebx
__int64 v6; // r12
int v7; // edx
__int64 v8; // rax
int v9; // edx
__int64 v10; // rax
int v11; // edx
int v12; // eax
int v13; // eax
int v14; // ecx
int v15; // edx

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

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

v1 = 88LL * (int)a1;
result = *(_DWORD *)&object_types[24 * (*(_DWORD *)(db + v1 + 40) & 7) + 16] & 0x20;
if ( (*(_DWORD *)&object_types[24 * (*(_DWORD *)(db + v1 + 40) & 7) + 16] & 0x20) == 0 )
return result;
v3 = func3(a1);
result = 0LL;
if ( !v3 )
return result;
result = *(unsigned int *)(v3 + 12);
if ( (int)result >= 0 )
return result;
v4 = mudstate[1830];
v5 = v4 + 1;
if ( v4 <= (int)a1 || (int)a1 < 0 || (*(_DWORD *)(db + v1 + 40) & 7u) > 4 )
goto LABEL_7;
if ( (unsigned int)evlevchk((unsigned int)a1, 2LL) )
{
if ( !mudstate[2077] )
{
LABEL_7:
result = (unsigned int)v5;
if ( mudconf[1830] >= v5 )
result = (unsigned int)mudconf[1830];
return result;
}
goto LABEL_15;
}
if ( (*(_BYTE *)(db + v1 + 47) & 0x20) == 0 )
{
if ( (unsigned int)evlevchk((unsigned int)a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_15;
goto LABEL_20;
}
if ( (*(_BYTE *)(db + v1 + 45) & 1) != 0 )
goto LABEL_15;
if ( (unsigned int)evlevchk((unsigned int)a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_15;
goto LABEL_26;
}
if ( (*(_BYTE *)(db + v1 + 40) & 0x10) != 0 )
goto LABEL_15;
if ( (unsigned int)evlevchk((unsigned int)a1, 5LL) )
{
if ( mudstate[2077] || (_DWORD)a1 == 1 )
goto LABEL_15;
}
else
{
v13 = *(_DWORD *)(db + v1 + 40);
if ( (v13 & 0x200000) != 0 || (_DWORD)a1 == 1 )
goto LABEL_15;
v14 = *(_DWORD *)(db + v1 + 24);
v15 = *(_DWORD *)(db + 88LL * v14 + 40);
if ( (v15 & 0x200000) != 0 )
{
if ( ((v15 | v13) & 0x2000000) != 0 || v14 == (_DWORD)a1 )
goto LABEL_15;
LABEL_26:
v9 = *(_DWORD *)(db + v1 + 24);
v10 = db + 88LL * v9;
if ( (*(_BYTE *)(v10 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(db + v1 + 43) & 2) != 0 || (*(_BYTE *)(v10 + 43) & 2) != 0 || v9 == (_DWORD)a1 )
goto LABEL_15;
v7 = *(_DWORD *)(db + v1 + 24);
v8 = 88LL * v7 + db;
if ( (*(_BYTE *)(v8 + 47) & 0x20) == 0 )
goto LABEL_7;
LABEL_31:
if ( (*(_BYTE *)(v8 + 43) & 2) == 0 && (_DWORD)a1 != v7 )
goto LABEL_7;
goto LABEL_15;
}
LABEL_20:
v6 = db + v1;
v7 = *(_DWORD *)(v6 + 24);
v8 = db + 88LL * v7;
if ( (*(_BYTE *)(v8 + 47) & 0x20) == 0 )
goto LABEL_7;
if ( (*(_BYTE *)(v6 + 43) & 2) != 0 )
goto LABEL_15;
goto LABEL_31;
}
}
v11 = *(_DWORD *)(db + v1 + 24);
v12 = *(_DWORD *)(db + 88LL * v11 + 40);
if ( (v12 & 0x10) != 0 && (((*(_DWORD *)(db + v1 + 40) | v12) & 0x2000000) != 0 || v11 == (_DWORD)a1) )
goto LABEL_15;
goto LABEL_26;
}
LABEL_15:
result = (unsigned int)v5;
if ( mudconf[1831] >= v5 )
result = (unsigned int)mudconf[1831];
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);
if ( v4 )
return *(_DWORD *)(v4 + 4);
}
v2 = (const char *)atr_get_raw((unsigned int)a1, 25LL);
result = 0;
if ( v2 )
result = atoi(v2);
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);
if ( v4 )
return *(_DWORD *)(v4 + 4);
}
v2 = (const char *)atr_get_raw((unsigned int)a1, 25LL);
result = 0;
if ( v2 )
result = atoi(v2);
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(__int64 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 + 4) = a2;
*(_DWORD *)(result + 16) |= 4u;
}
else
{
sprintf(v3, "%d", a2);
result = atr_add_raw((unsigned int)a1, 25LL, v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 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 + 4) = a2;
*(_DWORD *)(result + 16) |= 4u;
}
else
{
sprintf(v3, "%d", a2);
result = atr_add_raw((unsigned int)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; // er12
void *v4; // rax
void *v5; // r13
void *v6; // r14

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

canonical_decompiled_code:
unsigned __int64 __fastcall func0(int a1)
{
int v1; // edi
unsigned __int64 result; // rax
int v3; // er12
void *v4; // rax
void *v5; // r13
void *v6; // r14

v1 = a1 + 15;
result = (unsigned int)bm_top;
if ( bm_top < (int)(v1 & 0xFFFFFFF8) )
{
v3 = bm_top / 8;
v4 = malloc(v1 >> 3);
v5 = v4;
v6 = bitm;
if ( bitm )
{
memmove(v4, bitm, v3);
free(v6);
bitm = v5;
}
else
{
bitm = v4;
if ( !v4 )
fatal("db_init cannot grow bitmap ", -1LL, &unk_CA8, 0LL);
}
result = (unsigned __int64)memset((char *)bitm + v3, 0, (v1 >> 3) - v3);
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 *


decompiled_code:
unsigned __int64 __fastcall dddb_mark(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
unsigned __int64 result; // rax
__int64 v6; // r13

v3 = a1;
if ( a2 % bsiz )
result = (unsigned int)(a2 / bsiz + 1);
else
result = (unsigned int)(a2 / bsiz);
if ( !a3 )
last_free = a1;
if ( (_DWORD)result )
{
v6 = a1 + (unsigned int)(result - 1) + 1;
do
{
if ( bm_top - 32 <= v3 )
growbit(v3 + 512);
result = (unsigned __int64)bitm + (v3 >> 3);
if ( a3 )
*(_BYTE *)result |= 1 << (v3 & 7);
else
*(_BYTE *)result &= ~(1 << (v3 & 7));
++v3;
}
while ( v6 != v3 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
unsigned __int64 result; // rax
__int64 v6; // r13

v3 = a1;
if ( a2 % bsiz )
result = (unsigned int)(a2 / bsiz + 1);
else
result = (unsigned int)(a2 / bsiz);
if ( !a3 )
last_free = a1;
if ( (_DWORD)result )
{
v6 = a1 + (unsigned int)(result - 1) + 1;
do
{
if ( bm_top - 32 <= v3 )
func0(v3 + 512);
result = (unsigned __int64)bitm + (v3 >> 3);
if ( a3 )
*(_BYTE *)result |= 1 << (v3 & 7);
else
*(_BYTE *)result &= ~(1 << (v3 & 7));
++v3;
}
while ( v6 != v3 );
}
return result;
}

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


decompiled_code:
__int64 __fastcall dddb_alloc(int a1)
{
int v1; // er12
int v2; // ebp
int v3; // er13
_BYTE *v4; // rdx
int v5; // ecx
int v6; // edi
int v7; // ebx
int v8; // esi
int v9; // ebp
int v11; // ecx

v1 = last_free;
if ( a1 % bsiz )
v2 = a1 / bsiz + 1;
else
v2 = a1 / bsiz;
v3 = 0;
while ( 1 )
{
if ( bm_top - 32 <= v1 )
{
if ( v3 )
{
growbit(v1 + 512);
}
else
{
v1 = 0;
v3 = 1;
}
}
v4 = bitm;
v11 = *((char *)bitm + (v1 >> 3));
if ( _bittest(&v11, v1 & 7) )
{
v7 = v1;
goto LABEL_16;
}
if ( v2 == 1 )
break;
v7 = v1;
while ( 1 )
{
v6 = v7++;
if ( bm_top - 32 <= v7 )
growbit(v6 + 513);
v4 = bitm;
v5 = *((char *)bitm + (v7 >> 3));
if ( _bittest(&v5, v7 & 7) )
break;
if ( !(v1 + v2 + ~v7) )
{
if ( v2 <= 0 )
goto LABEL_13;
goto LABEL_11;
}
}
LABEL_16:
v1 = v7 + 1;
}
v7 = v1;
LABEL_11:
v8 = v1;
v9 = v1 + v2;
do
{
v4[v8 >> 3] |= 1 << (v8 & 7);
++v8;
}
while ( v9 - v8 > 0 );
LABEL_13:
last_free = v7;
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
int v1; // er12
int v2; // ebp
int v3; // er13
_BYTE *v4; // rdx
int v5; // ecx
int v6; // edi
int v7; // ebx
int v8; // esi
int v9; // ebp
int v11; // ecx

v1 = last_free;
if ( a1 % bsiz )
v2 = a1 / bsiz + 1;
else
v2 = a1 / bsiz;
v3 = 0;
while ( 1 )
{
if ( bm_top - 32 <= v1 )
{
if ( v3 )
{
func0(v1 + 512);
}
else
{
v1 = 0;
v3 = 1;
}
}
v4 = bitm;
v11 = *((char *)bitm + (v1 >> 3));
if ( _bittest(&v11, v1 & 7) )
{
v7 = v1;
goto LABEL_16;
}
if ( v2 == 1 )
break;
v7 = v1;
while ( 1 )
{
v6 = v7++;
if ( bm_top - 32 <= v7 )
func0(v6 + 513);
v4 = bitm;
v5 = *((char *)bitm + (v7 >> 3));
if ( _bittest(&v5, v7 & 7) )
break;
if ( !(v1 + v2 + ~v7) )
{
if ( v2 <= 0 )
goto LABEL_13;
goto LABEL_11;
}
}
LABEL_16:
v1 = v7 + 1;
}
v7 = v1;
LABEL_11:
v8 = v1;
v9 = v1 + v2;
do
{
v4[v8 >> 3] |= 1 << (v8 & 7);
++v8;
}
while ( v9 - v8 > 0 );
LABEL_13:
last_free = v7;
return (unsigned int)v1;
}

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)
{
__int64 result; // rax

result = a1;
bsiz = a1;
return result;
}

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

result = a1;
bsiz = a1;
return result;
}

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

variable_types: nbsiz int


decompiled_code:
__int64 __fastcall dddb_setfile(char *src)
{
unsigned int v1; // ebp
int v3; // eax
char *v4; // rax
char *v5; // r12

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

canonical_decompiled_code:
__int64 __fastcall func7(char *src)
{
unsigned int v1; // ebp
int v3; // eax
char *v4; // rax
char *v5; // r12

v1 = db_initted;
if ( db_initted )
return 1;
v3 = strlen(src);
v4 = (char *)malloc((unsigned int)(v3 + 1));
v5 = v4;
if ( !v4 )
return 1;
strcpy(v4, src);
dbfile = v5;
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; // rbx
__int64 v2; // rax
__int64 v3; // rdx
__int64 v4; // rbx
__int64 *v5; // rdx
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // r8
__int64 v9; // r9

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

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

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

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; // ebp
__int64 *v6; // rax
__int64 v7; // rdx
__int64 v8; // rdi
__int64 v9; // rsi
int v10; // er9
int v11; // eax

result = 1;
if ( db_initted )
{
v5 = obj_siz();
key = a2;
LODWORD(qword_C48) = 4;
v6 = (__int64 *)dbm_fetch(dbp, a2, qword_C48);
dat = (__int64)v6;
qword_C58 = v7;
if ( v6 )
{
v8 = *v6;
v9 = v6[1];
hbuf = *v6;
*(&hbuf + 1) = v9;
if ( v5 % bsiz )
v10 = v5 / bsiz + 1;
else
v10 = v5 / bsiz;
if ( (int)v9 % bsiz )
v11 = (int)v9 / bsiz + 1;
else
v11 = (int)v9 / bsiz;
if ( v10 > v11 )
{
dddb_mark(v8 / bsiz, v9, 0);
hbuf = (int)(bsiz * dddb_alloc(v5));
}
*((_DWORD *)&hbuf + 2) = v5;
}
else
{
hbuf = (int)(bsiz * dddb_alloc(v5));
*((_DWORD *)&hbuf + 2) = v5;
}
dat = (__int64)&hbuf;
LODWORD(qword_C58) = 16;
if ( (unsigned int)dbm_store(dbp, key, qword_C48, &hbuf, qword_C58, 1LL) )
{
mush_logf("db_put: can't dbm_store ", a2, " ", -1LL, &unk_CA8, 0LL);
result = 1;
}
else if ( fseek(dbf, hbuf, 0) )
{
mush_logf("db_put: can't seek ", a2, " ", -1LL, &unk_CA8, 0LL);
result = 1;
}
else if ( (unsigned int)objtoFILE(a1, dbf) || (result = fflush(dbf)) != 0 )
{
mush_logf("db_put: can't save ", a2, " ", -1LL, &unk_CA8, 0LL);
result = 1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, __int64 a2)
{
int result; // eax
int v5; // ebp
__int64 *v6; // rax
__int64 v7; // rdx
__int64 v8; // rdi
__int64 v9; // rsi
int v10; // er9
int v11; // eax

result = 1;
if ( db_initted )
{
v5 = obj_siz();
key = a2;
LODWORD(qword_C48) = 4;
v6 = (__int64 *)dbm_fetch(dbp, a2, qword_C48);
dat = (__int64)v6;
qword_C58 = v7;
if ( v6 )
{
v8 = *v6;
v9 = v6[1];
hbuf = *v6;
*(&hbuf + 1) = v9;
if ( v5 % bsiz )
v10 = v5 / bsiz + 1;
else
v10 = v5 / bsiz;
if ( (int)v9 % bsiz )
v11 = (int)v9 / bsiz + 1;
else
v11 = (int)v9 / bsiz;
if ( v10 > v11 )
{
func1(v8 / bsiz, v9, 0);
hbuf = (int)(bsiz * func2(v5));
}
*((_DWORD *)&hbuf + 2) = v5;
}
else
{
hbuf = (int)(bsiz * func2(v5));
*((_DWORD *)&hbuf + 2) = v5;
}
dat = (__int64)&hbuf;
LODWORD(qword_C58) = 16;
if ( (unsigned int)dbm_store(dbp, key, qword_C48, &hbuf, qword_C58, 1LL) )
{
mush_logf("db_put: can't dbm_store ", a2, " ", -1LL, &unk_CA8, 0LL);
result = 1;
}
else if ( fseek(dbf, hbuf, 0) )
{
mush_logf("db_put: can't seek ", a2, " ", -1LL, &unk_CA8, 0LL);
result = 1;
}
else if ( (unsigned int)objtoFILE(a1, dbf) || (result = fflush(dbf)) != 0 )
{
mush_logf("db_put: can't save ", a2, " ", -1LL, &unk_CA8, 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_C48) = strlen(a1) + 1;
dat = dbm_fetch(dbp, a1, qword_C48);
qword_C58 = 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_C48) = strlen(a1) + 1;
dat = dbm_fetch(dbp, a1, qword_C48);
qword_C58 = 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; // ebp
const __m128i *v3; // rax
__int64 v4; // rdx
__int64 v5; // r8
__int64 v6; // r9

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

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

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

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);
}