lsIsObjectSpecial

decompiled_code:
char __fastcall lsIsObjectSpecial(__int64 a1)
{
char result; // al
int v2; // edx

result = setup[1];
if ( result )
{
v2 = *(_DWORD *)(a1 + 20);
if ( v2 != 9281 )
result = (unsigned int)(v2 - 9293) <= 7;
}
return result;
}

canonical_decompiled_code:
char __fastcall func6(__int64 a1)
{
char result; // al
int v2; // edx

result = setup[1];
if ( result )
{
v2 = *(_DWORD *)(a1 + 20);
if ( v2 != 9281 )
result = (unsigned int)(v2 - 9293) <= 7;
}
return result;
}

original_code:
_Bool lsIsObjectSpecial(LSObject lso)
{
    if (setup.Profidisk) {
        switch (lso->Type) {
        case 9281U:
        case 9293U:
        case 9294U:
        case 9295U:
        case 9296U:
        case 9297U:
        case 9298U:
        case 9299U:
        case 9300U:
     return 1;
        }
    }
    return 0;
}

canonical_original_code:
_Bool lsIsObjectSpecial(struct _LSObject *lso)
{
    if (setup.Profidisk) {
        switch (lso->Type) {
        case 9281U:
        case 9293U:
        case 9294U:
        case 9295U:
        case 9296U:
        case 9297U:
        case 9298U:
        case 9299U:
        case 9300U:
     return 1;
        }
    }
    return 0;
}


lsIsObjectAnAddOn

repo: vcosta/derclou

decompiled_code:
bool __fastcall lsIsObjectAnAddOn(__int64 a1)
{
unsigned int v1; // ecx
bool result; // al

v1 = *(_DWORD *)(a1 + 20) - 9233;
if ( v1 > 0x23 )
result = 0;
else
result = ((1LL << v1) & 0x820000019LL) != 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func7(__int64 a1)
{
unsigned int v1; // ecx
bool result; // al

v1 = *(_DWORD *)(a1 + 20) - 9233;
if ( v1 > 0x23 )
result = 0;
else
result = ((1LL << v1) & 0x820000019LL) != 0;
return result;
}

original_code:
_Bool lsIsObjectAnAddOn(LSObject lso)
{
    switch (lso->Type) {
    case 9262U:
    case 9268U:
    case 9233U:
    case 9236U:
    case 9237U:
 return 1;
    }
    return 0;
}

canonical_original_code:
_Bool lsIsObjectAnAddOn(struct _LSObject *lso)
{
    switch (lso->Type) {
    case 9262U:
    case 9268U:
    case 9233U:
    case 9236U:
    case 9237U:
 return 1;
    }
    return 0;
}

variable_types: struct _LSObject { unsigned short us_OffsetFact; unsigned short us_DestX; unsigned short us_DestY; unsigned char uch_ExactX; unsigned char uch_ExactY; unsigned char uch_ExactX1; unsigned char uch_ExactY1; unsigned char uch_Size; unsigned char uch_Visible; unsigned char uch_Chained; unsigned int ul_Status; unsigned int Type; } *


lsIsObjectAStdObj

decompiled_code:
__int64 __fastcall lsIsObjectAStdObj(__int64 a1)
{
unsigned int v1; // er8
int v2; // eax

if ( lsIsObjectADoor(a1) )
return 0LL;
if ( !lsIsObjectAWall(a1) && !lsIsObjectAnAddOn(a1) )
{
LOBYTE(v2) = lsIsObjectSpecial(a1);
v1 = v2 ^ 1;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
unsigned int v1; // er8
int v2; // eax

if ( func4(a1) )
return 0LL;
if ( !func5(a1) && !func7(a1) )
{
LOBYTE(v2) = func6(a1);
v1 = v2 ^ 1;
}
return v1;
}

original_code:
_Bool lsIsObjectAStdObj(LSObject lso)
{
    if (lsIsObjectADoor(lso))
 return 0;
    if (lsIsObjectAWall(lso))
 return 0;
    if (lsIsObjectAnAddOn(lso))
 return 0;
    if (lsIsObjectSpecial(lso))
 return 0;
    return 1;
}

canonical_original_code:
_Bool lsIsObjectAStdObj(struct _LSObject *lso)
{
    if (lsIsObjectADoor(lso))
 return 0;
    if (lsIsObjectAWall(lso))
 return 0;
    if (lsIsObjectAnAddOn(lso))
 return 0;
    if (lsIsObjectSpecial(lso))
 return 0;
    return 1;
}

user_defined_types: struct _LSObject { unsigned short us_OffsetFact; unsigned short us_DestX; unsigned short us_DestY; unsigned char uch_ExactX; unsigned char uch_ExactY; unsigned char uch_ExactX1; unsigned char uch_ExactY1; unsigned char uch_Size; unsigned char uch_Visible; unsigned char uch_Chained; unsigned int ul_Status; unsigned int Type; }


lsGetObjectCount

decompiled_code:
__int64 lsGetObjectCount()
{
return GetNrOfNodes(*(_QWORD *)(ls + 336LL));
}

canonical_decompiled_code:
__int64 func9()
{
return GetNrOfNodes(*(_QWORD *)(ls + 336LL));
}

original_code:
uword lsGetObjectCount(void)
{
    return ((uword) GetNrOfNodes(ls->p_ObjectRetrieval));
}

canonical_original_code:
unsigned short lsGetObjectCount()
{
    return ((unsigned short) GetNrOfNodes(ls->p_ObjectRetrieval));
}

return_type: unsigned short


lsGetObjectState

decompiled_code:
__int64 __fastcall lsGetObjectState(__int64 a1)
{
return *(unsigned __int16 *)(dbGetObject(a1) + 16);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return *(unsigned __int16 *)(dbGetObject(a1) + 16);
}

original_code:
U32 lsGetObjectState(U32 objID)
{
    LSObject obj = dbGetObject(objID);
    return ((((obj)->ul_Status) & 0xffff));
}

canonical_original_code:
unsigned int lsGetObjectState(unsigned int objID)
{
    struct _LSObject *obj = dbGetObject(objID);
    return ((((obj)->ul_Status) & 0xffff));
}

variable_types:
objID
unsigned int

return_type: unsigned int


lsGetStartArea

decompiled_code:
__int64 lsGetStartArea()
{
__int64 v0; // rax

SetObjectListAttr(0LL, 509992LL);
v0 = dbGetObject((unsigned int)*ls);
AskAll(v0, 500001LL, &BuildObjectList);
return *(unsigned int *)(*ObjectList + 32LL);
}

canonical_decompiled_code:
__int64 func11()
{
__int64 v0; // rax

SetObjectListAttr(0LL, 509992LL);
v0 = dbGetObject((unsigned int)*ls);
AskAll(v0, 500001LL, &BuildObjectList);
return *(unsigned int *)(*ObjectList + 32LL);
}

original_code:
U32 lsGetStartArea(void)
{
    U32 areaID;
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (ls->ul_BuildingID), 500001, BuildObjectList); };
    areaID = (((struct ObjectNode *)((((NODE *)((&((ObjectList))->Head)))->Succ)))->nr);
    return (areaID);
}

canonical_original_code:
unsigned int lsGetStartArea()
{
    unsigned int areaID;
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (ls->ul_BuildingID), 500001, BuildObjectList); };
    areaID = (((struct ObjectNode *)((((struct Node *)((&((ObjectList))->Head)))->Succ)))->nr);
    return (areaID);
}

variable_types:
areaID
unsigned int

user_defined_types: struct ObjectNode { struct Node Link; unsigned int nr; unsigned int type; void *data; }

user_defined_types: struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; }


lsGetFloorIndex

decompiled_code:
__int64 __fastcall lsGetFloorIndex(int a1, int a2)
{
LOWORD(a2) = (unsigned __int16)a2 >> 5;
LOWORD(a1) = (unsigned __int16)a1 >> 5;
return (unsigned int)(a1 + 20 * a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
LOWORD(a2) = (unsigned __int16)a2 >> 5;
LOWORD(a1) = (unsigned __int16)a1 >> 5;
return (unsigned int)(a1 + 20 * a2);
}

original_code:
uword lsGetFloorIndex(uword x, uword y)
{
    register uword fpl, row, line;
    fpl = (640/32);
    row = x / 32;
    line = y / 32;
    return (uword) (line * fpl + row);
}

canonical_original_code:
unsigned short lsGetFloorIndex(unsigned short x, unsigned short y)
{
    register unsigned short fpl; register unsigned short row; register unsigned short line;
    fpl = (640/32);
    row = x / 32;
    line = y / 32;
    return (uword) (line * fpl + row);
}

variable_types:
x
unsigned short

variable_types:
y
unsigned short

variable_types:
fpl
unsigned short

variable_types:
row
unsigned short

variable_types:
line
unsigned short


lsGetLoudness

original_code:
ubyte lsGetLoudness(uword x, uword y)
{
    word floorIndex = lsGetFloorIndex(x, y), i, j, k;
    ubyte loudness = 255;
    if ((!((ls->p_CurrFloor[floorIndex].uch_FloorType) & (1<<5))) &&
 ((ls->p_CurrFloor[floorIndex].uch_FloorType) & (1<<6)))
 loudness = 15;
    else {
 for (i = -1; (i < 2) && (loudness == 255); i++) {
     for (j = -1; (j < 2) && (loudness == 255); j++) {
  k = floorIndex + i * (640/32) + j;
  if ((k >= 0) && (k < (640/32) * (256/32))) {
      if ((!((ls->p_CurrFloor[k].uch_FloorType) & (1<<5))) &&
   ((ls->p_CurrFloor[k].uch_FloorType) & (1<<6)))
   loudness = 50;
  }
     }
 }
    }
    return loudness;
}

canonical_original_code:
unsigned char lsGetLoudness(unsigned short x, unsigned short y)
{
    short floorIndex = lsGetFloorIndex(x, y); short i; short j; short k;
    unsigned char loudness = 255;
    if ((!((ls->p_CurrFloor[floorIndex].uch_FloorType) & (1<<5))) &&
 ((ls->p_CurrFloor[floorIndex].uch_FloorType) & (1<<6)))
 loudness = 15;
    else {
 for (i = -1; (i < 2) && (loudness == 255); i++) {
     for (j = -1; (j < 2) && (loudness == 255); j++) {
  k = floorIndex + i * (640/32) + j;
  if ((k >= 0) && (k < (640/32) * (256/32))) {
      if ((!((ls->p_CurrFloor[k].uch_FloorType) & (1<<5))) &&
   ((ls->p_CurrFloor[k].uch_FloorType) & (1<<6)))
   loudness = 50;
  }
     }
 }
    }
    return loudness;
}

variable_types: floorIndex short

variable_types: i short

variable_types: j short

variable_types: k short

variable_types:
loudness
unsigned char

return_type: unsigned char


lsGetObjectsByList

original_code:
LIST *lsGetObjectsByList(uword x, uword y, uword width, uword height,
    ubyte showInvisible, ubyte addLootBags)
{
    struct ObjectNode *node;
    LIST *list = CreateList();
    U32 i;
    for (node = (struct ObjectNode *) ((((NODE *)((&((ls->p_ObjectRetrieval))->Head)))->Succ));
  (((NODE *)((NODE *) node))->Succ);
  node = (struct ObjectNode *) (((NODE *)((NODE *) node))->Succ)) {
 LSObject lso = (LSObject) (((struct ObjectNode *)node)->data);
 if ((lso->ul_Status & (1L << 4))
     || (GamePlayMode & (1<< 3)))
     if (showInvisible || lso->uch_Visible)
  if (lsIsInside(lso, x, y, x + width, y + height))
      lsExtendGetList(list, (((struct ObjectNode *)node)->nr), lso->Type, lso);
    }
    if (addLootBags) {
 for (i = 9701; i <= 9708; i++) {
     LSObject lso = dbGetObject(i);
     if (lso->uch_Visible == ((ubyte) 1))
  if (lsIsInside(lso, x, y, x + width, y + height))
      lsExtendGetList(list, i, 9270U, lso);
 }
    }
    return (list);
}

canonical_original_code:
struct List *lsGetObjectsByList(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char showInvisible, unsigned char addLootBags)
{
    struct ObjectNode *node;
    struct List *list = CreateList();
    unsigned int i;
    for (node = (struct ObjectNode *) ((((struct Node *)((&((ls->p_ObjectRetrieval))->Head)))->Succ));
  (((struct Node *)((struct Node *) node))->Succ);
  node = (struct ObjectNode *) (((struct Node *)((struct Node *) node))->Succ)) {
 struct _LSObject *lso = (LSObject) (((struct ObjectNode *)node)->data);
 if ((lso->ul_Status & (1L << 4))
     || (GamePlayMode & (1<< 3)))
     if (showInvisible || lso->uch_Visible)
  if (lsIsInside(lso, x, y, x + width, y + height))
      lsExtendGetList(list, (((struct ObjectNode *)node)->nr), lso->Type, lso);
    }
    if (addLootBags) {
 for (i = 9701; i <= 9708; i++) {
     struct _LSObject *lso = dbGetObject(i);
     if (lso->uch_Visible == ((unsigned char) 1))
  if (lsIsInside(lso, x, y, x + width, y + height))
      lsExtendGetList(list, i, 9270U, lso);
 }
    }
    return (list);
}

variable_types:
width
unsigned short

variable_types:
height
unsigned short

variable_types:
showInvisible
unsigned char

variable_types:
addLootBags
unsigned char

variable_types: struct ObjectNode { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned int nr; unsigned int type; void *data; } *

variable_types: struct List { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Head; struct Node Tail; } *

variable_types:
i
unsigned int

user_defined_types: struct List { struct Node Head; struct Node Tail; }


lsGetWindowXPos

decompiled_code:
__int64 lsGetWindowXPos()
{
return *(unsigned __int16 *)(ls + 14LL);
}

canonical_decompiled_code:
__int64 func15()
{
return *(unsigned __int16 *)(ls + 14LL);
}

original_code:
uword lsGetWindowXPos(void)
{
    return (ls->us_WindowXPos);
}

canonical_original_code:
unsigned short lsGetWindowXPos()
{
    return (ls->us_WindowXPos);
}


lsGetWindowYPos

decompiled_code:
__int64 lsGetWindowYPos()
{
return *(unsigned __int16 *)(ls + 16LL);
}

canonical_decompiled_code:
__int64 func16()
{
return *(unsigned __int16 *)(ls + 16LL);
}

original_code:
uword lsGetWindowYPos(void)
{
    return (ls->us_WindowYPos);
}

canonical_original_code:
unsigned short lsGetWindowYPos()
{
    return (ls->us_WindowYPos);
}


lsGetTotalXPos

decompiled_code:
__int16 lsGetTotalXPos()
{
return *(_WORD *)(ls + 14LL) + *(_WORD *)(ls + 18LL);
}

original_code:
uword lsGetTotalXPos(void)
{
    return (uword) (ls->us_WindowXPos + ls->us_PersonXPos);
}

canonical_original_code:
unsigned short lsGetTotalXPos()
{
    return (uword) (ls->us_WindowXPos + ls->us_PersonXPos);
}


lsGetTotalYPos

decompiled_code:
__int16 lsGetTotalYPos()
{
return *(_WORD *)(ls + 16LL) + *(_WORD *)(ls + 20LL);
}

original_code:
uword lsGetTotalYPos(void)
{
    return (uword) (ls->us_WindowYPos + ls->us_PersonYPos);
}

canonical_original_code:
unsigned short lsGetTotalYPos()
{
    return (uword) (ls->us_WindowYPos + ls->us_PersonYPos);
}


lsSetCollMode

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

result = ls;
*(_BYTE *)(ls + 24LL) = a1;
return result;
}

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

result = ls;
*(_BYTE *)(ls + 24LL) = a1;
return result;
}

original_code:
void lsSetCollMode(ubyte collMode)
{
    ls->uch_CollMode = collMode;
}

canonical_original_code:
void lsSetCollMode(unsigned char collMode)
{
    ls->uch_CollMode = collMode;
}

variable_types:
collMode
unsigned char

return_type: void


lsGetCurrBuildingID

decompiled_code:
__int64 lsGetCurrBuildingID()
{
return (unsigned int)*ls;
}

canonical_decompiled_code:
__int64 func20()
{
return (unsigned int)*ls;
}

original_code:
U32 lsGetCurrBuildingID(void)
{
    return ls->ul_BuildingID;
}

canonical_original_code:
unsigned int lsGetCurrBuildingID()
{
    return ls->ul_BuildingID;
}


lsGetActivAreaID

decompiled_code:
__int64 lsGetActivAreaID()
{
return *(unsigned int *)(ls + 4LL);
}

canonical_decompiled_code:
__int64 func21()
{
return *(unsigned int *)(ls + 4LL);
}

original_code:
U32 lsGetActivAreaID(void)
{
    return (ls->ul_AreaID);
}

canonical_original_code:
unsigned int lsGetActivAreaID()
{
    return (ls->ul_AreaID);
}


lsGetRoomsOfArea

decompiled_code:
__int64 __fastcall lsGetRoomsOfArea(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
__int64 v3; // r8
_QWORD *v4; // r10
_QWORD *v5; // rax
__int16 *v6; // rdi

v1 = dbGetObject(a1);
v2 = *(_DWORD *)(v1 + 20) + 10;
SetObjectListAttr(4LL, 509993LL);
AskAll(v1, v2, &BuildObjectList);
v3 = ObjectListPrivate;
v4 = (_QWORD *)*ObjectListPrivate;
v5 = *(_QWORD **)*ObjectListPrivate;
if ( v5 )
{
while ( 1 )
{
v6 = (__int16 *)v4[5];
if ( *v6 < 0 )
*v6 = 0;
if ( v6[1] < 0 )
v6[1] = 0;
v4 = v5;
if ( !*v5 )
break;
v5 = (_QWORD *)*v5;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
__int64 v3; // r8
_QWORD *v4; // r10
_QWORD *v5; // rax
__int16 *v6; // rdi

v1 = dbGetObject(a1);
v2 = *(_DWORD *)(v1 + 20) + 10;
SetObjectListAttr(4LL, 509993LL);
AskAll(v1, v2, &BuildObjectList);
v3 = ObjectListPrivate;
v4 = (_QWORD *)*ObjectListPrivate;
v5 = *(_QWORD **)*ObjectListPrivate;
if ( v5 )
{
while ( 1 )
{
v6 = (__int16 *)v4[5];
if ( *v6 < 0 )
*v6 = 0;
if ( v6[1] < 0 )
v6[1] = 0;
v4 = v5;
if ( !*v5 )
break;
v5 = (_QWORD *)*v5;
}
}
return v3;
}

original_code:
LIST *lsGetRoomsOfArea(U32 ul_AreaId)
{
    LSArea area = (LSArea) dbGetObject(ul_AreaId);
    U32 roomRelId = area->ul_ObjectBaseNr + 10;
    NODE *room;
    SetObjectListAttr((1 << 2), 509993L);
    AskAll(area, roomRelId, BuildObjectList);
    for (room = ((((NODE *)((&((ObjectListPrivate))->Head)))->Succ)); (((NODE *)(room))->Succ);
  room = (((NODE *)(room))->Succ)) {
 LSRoom myroom = (((struct ObjectNode *)room)->data);
 if ((word) myroom->us_LeftEdge < 0)
     myroom->us_LeftEdge = 0;
 if ((word) myroom->us_TopEdge < 0)
     myroom->us_TopEdge = 0;
    }
    return ObjectListPrivate;
}

canonical_original_code:
struct List *lsGetRoomsOfArea(unsigned int ul_AreaId)
{
    struct _LSArea *area = (LSArea) dbGetObject(ul_AreaId);
    unsigned int roomRelId = area->ul_ObjectBaseNr + 10;
    struct Node *room;
    SetObjectListAttr((1 << 2), 509993L);
    AskAll(area, roomRelId, BuildObjectList);
    for (room = ((((struct Node *)((&((ObjectListPrivate))->Head)))->Succ)); (((struct Node *)(room))->Succ);
  room = (((struct Node *)(room))->Succ)) {
 struct _LSRoom *myroom = (((struct ObjectNode *)room)->data);
 if ((short) myroom->us_LeftEdge < 0)
     myroom->us_LeftEdge = 0;
 if ((short) myroom->us_TopEdge < 0)
     myroom->us_TopEdge = 0;
    }
    return ObjectListPrivate;
}

variable_types: struct _LSArea { unsigned short us_Coll16ID; unsigned short us_Coll32ID; unsigned short us_Coll48ID; unsigned short us_PlanColl16ID; unsigned short us_PlanColl32ID; unsigned short us_PlanColl48ID; unsigned short us_FloorCollID; unsigned short us_PlanFloorCollID; unsigned short us_Width; unsigned short us_Height; unsigned int ul_ObjectBaseNr; unsigned char uch_Darkness; unsigned short us_StartX0; unsigned short us_StartX1; unsigned short us_StartX2; unsigned short us_StartX3; unsigned short us_StartX4; unsigned short us_StartX5; unsigned short us_StartY0; unsigned short us_StartY1; unsigned short us_StartY2; unsigned short us_StartY3; unsigned short us_StartY4; unsigned short us_StartY5; } *

variable_types:
roomRelId
unsigned int

variable_types: struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } *

variable_types: struct _LSRoom { unsigned short us_LeftEdge; unsigned short us_TopEdge; unsigned short us_Width; unsigned short us_Height; } *

return_type: struct List { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Head; struct Node Tail; } *


tcRefreshAfterLoad

decompiled_code:
__int64 __fastcall tcRefreshAfterLoad(char a1)
{
unsigned int v1; // eax
__int64 result; // rax
_DWORD *v3; // rdx
int v4; // esi
int v5; // edi
__int64 v6; // rdi

v1 = getKey(1LL);
result = dbGetObject(v1);
if ( a1 )
{
if ( result )
{
v3 = (_DWORD *)film;
v4 = *(_DWORD *)(result + 24);
v5 = *(_DWORD *)(film + 52LL);
*(_DWORD *)(film + 44LL) = *(_DWORD *)(result + 20);
v3[12] = v4;
v3[14] = v5;
v6 = *(unsigned int *)(result + 28);
v3[13] = -1;
result = *(unsigned int *)GetLocScene(v6);
SceneArgs[1] = result;
}
}
else
{
if ( result )
*(_DWORD *)(result + 16) = 0;
result = ErrorMsg(3LL, 9LL, 2LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
unsigned int v1; // eax
__int64 result; // rax
_DWORD *v3; // rdx
int v4; // esi
int v5; // edi
__int64 v6; // rdi

v1 = getKey(1LL);
result = dbGetObject(v1);
if ( a1 )
{
if ( result )
{
v3 = (_DWORD *)film;
v4 = *(_DWORD *)(result + 24);
v5 = *(_DWORD *)(film + 52LL);
*(_DWORD *)(film + 44LL) = *(_DWORD *)(result + 20);
v3[12] = v4;
v3[14] = v5;
v6 = *(unsigned int *)(result + 28);
v3[13] = -1;
result = *(unsigned int *)GetLocScene(v6);
SceneArgs[1] = result;
}
}
else
{
if ( result )
*(_DWORD *)(result + 16) = 0;
result = ErrorMsg(3LL, 9LL, 2LL);
}
return result;
}

original_code:
void tcRefreshAfterLoad(ubyte loaded)
{
    Player player = dbGetObject(getKey(_Player_Player_1));
    if (!loaded) {
 if (player)
     player->CurrScene = 0L;
 ErrorMsg(Disk_Defect, ERROR_MODULE_LOADSAVE, 2);
    } else {
 if (player) {
     (film->akt_Tag=(U32)(player->CurrDay));
     (film->akt_Minute=(U32)(player->CurrMinute));
     {film->alter_Ort = film->akt_Ort; film->akt_Ort=(U32)(-1);};
     SceneArgs.ReturnValue = GetLocScene(player->CurrLocation)->EventNr;
 }
    }
}

canonical_original_code:
void tcRefreshAfterLoad(unsigned char loaded)
{
    struct _Player *player = dbGetObject(getKey(_Player_Player_1));
    if (!loaded) {
 if (player)
     player->CurrScene = 0L;
 ErrorMsg(Disk_Defect, ERROR_MODULE_LOADSAVE, 2);
    } else {
 if (player) {
     (film->akt_Tag=(U32)(player->CurrDay));
     (film->akt_Minute=(U32)(player->CurrMinute));
     {film->alter_Ort = film->akt_Ort; film->akt_Ort=(U32)(-1);};
     SceneArgs.ReturnValue = GetLocScene(player->CurrLocation)->EventNr;
 }
    }
}

variable_types:
loaded
unsigned char

variable_types: struct _Player { unsigned int Money; unsigned int StolenMoney; unsigned int MyStolenMoney; unsigned char NrOfBurglaries; unsigned char JobOfferCount; unsigned char MattsPart; unsigned int CurrScene; unsigned int CurrDay; unsigned int CurrMinute; unsigned int CurrLocation; } *


tcSaveTheClou

decompiled_code:
__int64 tcSaveTheClou()
{
__int64 v0; // rbp
__int64 v1; // rdi
_DWORD *v2; // rbx
int v3; // er8
int v4; // ecx
unsigned int v6; // er12
const char *v7; // rax
size_t v8; // rax
__int64 v9; // r13
__int64 v10; // rax
char v11[256]; // [rsp+0h] [rbp-528h] BYREF
char dest[2]; // [rsp+100h] [rbp-428h] BYREF
char v13[254]; // [rsp+102h] [rbp-426h] BYREF
char src[256]; // [rsp+200h] [rbp-328h] BYREF
char v15[552]; // [rsp+300h] [rbp-228h] BYREF

v0 = CreateList();
v1 = (unsigned int)getKey(1LL);
v2 = (_DWORD *)dbGetObject(v1);
ShowMenuBackground();
txtGetNthString(4LL, "SaveGame", 0LL, v11);
LODWORD(v1) = *(_DWORD *)(film + 48LL);
v3 = *(_DWORD *)(film + 52LL);
v4 = **(_DWORD **)(film + 8LL);
v2[5] = *(_DWORD *)(film + 44LL);
v2[6] = v1;
v2[4] = v4;
v2[7] = v3;
dskBuildPathName(0LL, "datadisk", "games.lst", v15);
if ( (unsigned int)ReadList(v0, 0LL, v15) )
{
inpTurnESC(1LL);
inpTurnFunctionKey(0LL);
v6 = (unsigned __int8)Menu(v0, 15LL, 0LL, 0LL, 0LL);
inpTurnFunctionKey(1LL);
if ( (_BYTE)v6 != 0xFF )
{
v7 = (const char *)GetCurrLocName();
strcpy(dest, v7);
BuildDate(*(unsigned int *)(film + 44LL), src);
tcCutName(dest, 32LL, 15LL);
v8 = strlen(dest);
*(_WORD *)&dest[v8] = 8236;
strcpy(&v13[v8], src);
sprintf(src, "(%d)", v6 + 1);
strcat(dest, src);
v9 = CreateNode(0LL, 0LL, dest);
v10 = GetNthNode(v0, v6);
ReplaceNode(v0, *(_QWORD *)(v10 + 16), v9);
ShowMenuBackground();
txtGetNthString(4LL, "SAVING", 0LL, v11);
PrintStatus(v11);
WriteList(v0, v15);
sprintf(v11, "%s%d%s", "tcmain", v6, ".dat");
dskBuildPathName(1LL, "datadisk", v11, v15);
dbSaveAllObjects(v15, 0LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcmain", v6, ".rel");
dskBuildPathName(1LL, "datadisk", v11, v15);
SaveRelations(v15, 0LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcbuild", v6, ".dat");
dskBuildPathName(1LL, "datadisk", v11, v15);
dbSaveAllObjects(v15, 500000LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcbuild", v6, ".rel");
dskBuildPathName(1LL, "datadisk", v11, v15);
SaveRelations(v15, 500000LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcstory", v6, ".dat");
dskBuildPathName(1LL, "datadisk", v11, v15);
tcSaveChangesInScenes((__int64)v15);
}
}
return RemoveList(v0);
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbp
__int64 v1; // rdi
_DWORD *v2; // rbx
int v3; // er8
int v4; // ecx
unsigned int v6; // er12
const char *v7; // rax
size_t v8; // rax
__int64 v9; // r13
__int64 v10; // rax
char v11[256]; // [rsp+0h] [rbp-528h] BYREF
char dest[2]; // [rsp+100h] [rbp-428h] BYREF
char v13[254]; // [rsp+102h] [rbp-426h] BYREF
char src[256]; // [rsp+200h] [rbp-328h] BYREF
char v15[552]; // [rsp+300h] [rbp-228h] BYREF

v0 = CreateList();
v1 = (unsigned int)getKey(1LL);
v2 = (_DWORD *)dbGetObject(v1);
ShowMenuBackground();
txtGetNthString(4LL, "SaveGame", 0LL, v11);
LODWORD(v1) = *(_DWORD *)(film + 48LL);
v3 = *(_DWORD *)(film + 52LL);
v4 = **(_DWORD **)(film + 8LL);
v2[5] = *(_DWORD *)(film + 44LL);
v2[6] = v1;
v2[4] = v4;
v2[7] = v3;
dskBuildPathName(0LL, "datadisk", "games.lst", v15);
if ( (unsigned int)ReadList(v0, 0LL, v15) )
{
inpTurnESC(1LL);
inpTurnFunctionKey(0LL);
v6 = (unsigned __int8)Menu(v0, 15LL, 0LL, 0LL, 0LL);
inpTurnFunctionKey(1LL);
if ( (_BYTE)v6 != 0xFF )
{
v7 = (const char *)GetCurrLocName();
strcpy(dest, v7);
BuildDate(*(unsigned int *)(film + 44LL), src);
tcCutName(dest, 32LL, 15LL);
v8 = strlen(dest);
*(_WORD *)&dest[v8] = 8236;
strcpy(&v13[v8], src);
sprintf(src, "(%d)", v6 + 1);
strcat(dest, src);
v9 = CreateNode(0LL, 0LL, dest);
v10 = GetNthNode(v0, v6);
ReplaceNode(v0, *(_QWORD *)(v10 + 16), v9);
ShowMenuBackground();
txtGetNthString(4LL, "SAVING", 0LL, v11);
PrintStatus(v11);
WriteList(v0, v15);
sprintf(v11, "%s%d%s", "tcmain", v6, ".dat");
dskBuildPathName(1LL, "datadisk", v11, v15);
dbSaveAllObjects(v15, 0LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcmain", v6, ".rel");
dskBuildPathName(1LL, "datadisk", v11, v15);
SaveRelations(v15, 0LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcbuild", v6, ".dat");
dskBuildPathName(1LL, "datadisk", v11, v15);
dbSaveAllObjects(v15, 500000LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcbuild", v6, ".rel");
dskBuildPathName(1LL, "datadisk", v11, v15);
SaveRelations(v15, 500000LL, 10000LL, 0LL);
sprintf(v11, "%s%d%s", "tcstory", v6, ".dat");
dskBuildPathName(1LL, "datadisk", v11, v15);
func1((__int64)v15);
}
}
return RemoveList(v0);
}

original_code:
void tcSaveTheClou(void)
{
    char line[256];
    char location[256];
    char date[256];
    char pathname[512];
    LIST *games = CreateList();
    NODE *game;
    uword activ;
    Player player = dbGetObject(getKey(_Player_Player_1));
    ShowMenuBackground();
    (txtGetNthString(4U, "SaveGame", 0, line));
    player->CurrScene = film->act_scene->EventNr;
    player->CurrDay = (film->akt_Tag);
    player->CurrMinute = (film->akt_Minute);
    player->CurrLocation = (film->akt_Ort);
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", "games.lst", pathname);
    if (ReadList(games, 0L, pathname)) {
 inpTurnESC(1);
 inpTurnFunctionKey(0);
 activ = (uword) Menu(games, 15L, 0, ((void *)0), 0L);
 inpTurnFunctionKey(1);
 if (activ != ((U8)-1)) {
     strcpy(location, GetCurrLocName());
     BuildDate((film->akt_Tag), date);
     tcCutName(location, (ubyte) ' ', 15);
     strcat(location, ", ");
     strcat(location, date);
     sprintf(date, "(%d)", activ + 1);
     strcat(location, date);
     game = CreateNode(0L, 0L, location);
     ReplaceNode(games, (((NODE *)(GetNthNode(games, activ)))->Name), game);
     ShowMenuBackground();
     (txtGetNthString(4U, "SAVING", 0, line));
     PrintStatus(line);
     WriteList(games, pathname);
            sprintf(line, "%s%d%s", "tcmain", activ, ".dat");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     dbSaveAllObjects(pathname, 0, 10000, 0);
            sprintf(line, "%s%d%s", "tcmain", activ, ".rel");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     SaveRelations(pathname, 0, 10000, 0);
            sprintf(line, "%s%d%s", "tcbuild", activ, ".dat");
     dskBuildPathName(DISK_CHECK_DIR , "datadisk", line, pathname);
     dbSaveAllObjects(pathname, (U32) (500000),
        (U32) (10000), 0);
            sprintf(line, "%s%d%s", "tcbuild", activ, ".rel");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     SaveRelations(pathname, (U32) 500000, (U32) 10000,
     0);
            sprintf(line, "%s%d%s", "tcstory", activ, ".dat");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     tcSaveChangesInScenes(pathname);
 }
    }
    RemoveList(games);
}

canonical_original_code:
void tcSaveTheClou()
{
    char line[256];
    char location[256];
    char date[256];
    char pathname[512];
    struct List *games = CreateList();
    struct Node *game;
    unsigned short activ;
    struct _Player *player = dbGetObject(getKey(_Player_Player_1));
    ShowMenuBackground();
    (txtGetNthString(4U, "SaveGame", 0, line));
    player->CurrScene = film->act_scene->EventNr;
    player->CurrDay = (film->akt_Tag);
    player->CurrMinute = (film->akt_Minute);
    player->CurrLocation = (film->akt_Ort);
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", "games.lst", pathname);
    if (ReadList(games, 0L, pathname)) {
 inpTurnESC(1);
 inpTurnFunctionKey(0);
 activ = (unsigned short) Menu(games, 15L, 0, ((void *)0), 0L);
 inpTurnFunctionKey(1);
 if (activ != ((U8)-1)) {
     strcpy(location, GetCurrLocName());
     BuildDate((film->akt_Tag), date);
     tcCutName(location, (unsigned char) ' ', 15);
     strcat(location, ", ");
     strcat(location, date);
     sprintf(date, "(%d)", activ + 1);
     strcat(location, date);
     game = CreateNode(0L, 0L, location);
     ReplaceNode(games, (((struct Node *)(GetNthNode(games, activ)))->Name), game);
     ShowMenuBackground();
     (txtGetNthString(4U, "SAVING", 0, line));
     PrintStatus(line);
     WriteList(games, pathname);
            sprintf(line, "%s%d%s", "tcmain", activ, ".dat");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     dbSaveAllObjects(pathname, 0, 10000, 0);
            sprintf(line, "%s%d%s", "tcmain", activ, ".rel");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     SaveRelations(pathname, 0, 10000, 0);
            sprintf(line, "%s%d%s", "tcbuild", activ, ".dat");
     dskBuildPathName(DISK_CHECK_DIR , "datadisk", line, pathname);
     dbSaveAllObjects(pathname, (U32) (500000),
        (U32) (10000), 0);
            sprintf(line, "%s%d%s", "tcbuild", activ, ".rel");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     SaveRelations(pathname, (unsigned int) 500000, (unsigned int) 10000,
     0);
            sprintf(line, "%s%d%s", "tcstory", activ, ".dat");
     dskBuildPathName(DISK_CHECK_DIR, "datadisk", line, pathname);
     tcSaveChangesInScenes(pathname);
 }
    }
    RemoveList(games);
}

variable_types:
line
char [256]

variable_types:
location
char [256]

variable_types:
date
char [256]

variable_types:
pathname
char [512]

variable_types:
activ
unsigned short

user_defined_types: struct _Player { unsigned int Money; unsigned int StolenMoney; unsigned int MyStolenMoney; unsigned char NrOfBurglaries; unsigned char JobOfferCount; unsigned char MattsPart; unsigned int CurrScene; unsigned int CurrDay; unsigned int CurrMinute; unsigned int CurrLocation; }


tcLoadIt

decompiled_code:
bool __fastcall tcLoadIt(char a1)
{
char v2[256]; // [rsp+0h] [rbp-308h] BYREF
char v3[520]; // [rsp+100h] [rbp-208h] BYREF

ShowMenuBackground();
txtGetNthString(4LL, "LOADING", 0LL, v2);
PrintStatus(v2);
tcResetOrganisation();
RemRelations(0LL, 10000LL);
RemRelations(500000LL, 10000LL);
dbDeleteAllObjects(0LL, 10000LL);
dbDeleteAllObjects(500000LL, 10000LL);
txtReset(1LL);
sprintf(v2, "%s%d%s", "tcmain", (unsigned int)a1, ".dat");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned __int8)dbLoadAllObjects(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcbuild", (unsigned int)a1, ".dat");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned __int8)dbLoadAllObjects(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcmain", (unsigned int)a1, ".rel");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned int)LoadRelations(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcbuild", (unsigned int)a1, ".rel");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned int)LoadRelations(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcstory", (unsigned int)a1, ".dat");
dskBuildPathName(0LL, "datadisk", v2, v3);
return (unsigned __int8)tcLoadChangesInScenes((__int64)v3) != 0;
}

canonical_decompiled_code:
bool __fastcall func4(char a1)
{
char v2[256]; // [rsp+0h] [rbp-308h] BYREF
char v3[520]; // [rsp+100h] [rbp-208h] BYREF

ShowMenuBackground();
txtGetNthString(4LL, "LOADING", 0LL, v2);
PrintStatus(v2);
tcResetOrganisation();
RemRelations(0LL, 10000LL);
RemRelations(500000LL, 10000LL);
dbDeleteAllObjects(0LL, 10000LL);
dbDeleteAllObjects(500000LL, 10000LL);
txtReset(1LL);
sprintf(v2, "%s%d%s", "tcmain", (unsigned int)a1, ".dat");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned __int8)dbLoadAllObjects(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcbuild", (unsigned int)a1, ".dat");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned __int8)dbLoadAllObjects(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcmain", (unsigned int)a1, ".rel");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned int)LoadRelations(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcbuild", (unsigned int)a1, ".rel");
dskBuildPathName(0LL, "datadisk", v2, v3);
if ( !(unsigned int)LoadRelations(v3, 0LL) )
return 0;
sprintf(v2, "%s%d%s", "tcstory", (unsigned int)a1, ".dat");
dskBuildPathName(0LL, "datadisk", v2, v3);
return (unsigned __int8)func3((__int64)v3) != 0;
}

original_code:
ubyte tcLoadIt(char activ)
{
    char pathname[512];
    char line[256];
    ubyte loaded = 0;
    ShowMenuBackground();
    (txtGetNthString(4U, "LOADING", 0, line));
    PrintStatus(line);
    tcResetOrganisation();
    RemRelations((U32) 0, (U32) 10000);
    RemRelations((U32) 500000, (U32) 10000);
    dbDeleteAllObjects((U32) 0, (U32) 10000);
    dbDeleteAllObjects((U32) 500000, (U32) 10000);
    txtReset(1U);
    sprintf(line, "%s%d%s", "tcmain", (int) activ, ".dat");
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
    if (dbLoadAllObjects(pathname, 0)) {
        sprintf(line, "%s%d%s", "tcbuild", (int) activ, ".dat");
        dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
 if (dbLoadAllObjects(pathname, 0)) {
            sprintf(line, "%s%d%s", "tcmain", (int) activ, ".rel");
            dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
     if (LoadRelations(pathname, 0)) {
                sprintf(line, "%s%d%s", "tcbuild", (int) activ, ".rel");
                dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
  if (LoadRelations(pathname, 0)) {
                    sprintf(line, "%s%d%s", "tcstory", (int) activ, ".dat");
                    dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
      if (tcLoadChangesInScenes(pathname))
   loaded = 1;
  }
     }
 }
    }
    return loaded;
}

canonical_original_code:
unsigned char tcLoadIt(char activ)
{
    char pathname[512];
    char line[256];
    unsigned char loaded = 0;
    ShowMenuBackground();
    (txtGetNthString(4U, "LOADING", 0, line));
    PrintStatus(line);
    tcResetOrganisation();
    RemRelations((unsigned int) 0, (unsigned int) 10000);
    RemRelations((unsigned int) 500000, (unsigned int) 10000);
    dbDeleteAllObjects((unsigned int) 0, (unsigned int) 10000);
    dbDeleteAllObjects((unsigned int) 500000, (unsigned int) 10000);
    txtReset(1U);
    sprintf(line, "%s%d%s", "tcmain", (int) activ, ".dat");
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
    if (dbLoadAllObjects(pathname, 0)) {
        sprintf(line, "%s%d%s", "tcbuild", (int) activ, ".dat");
        dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
 if (dbLoadAllObjects(pathname, 0)) {
            sprintf(line, "%s%d%s", "tcmain", (int) activ, ".rel");
            dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
     if (LoadRelations(pathname, 0)) {
                sprintf(line, "%s%d%s", "tcbuild", (int) activ, ".rel");
                dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
  if (LoadRelations(pathname, 0)) {
                    sprintf(line, "%s%d%s", "tcstory", (int) activ, ".dat");
                    dskBuildPathName(DISK_CHECK_FILE, "datadisk", line, pathname);
      if (tcLoadChangesInScenes(pathname))
   loaded = 1;
  }
     }
 }
    }
    return loaded;
}

variable_types: activ char


tcLoadTheClou

decompiled_code:
_BOOL8 tcLoadTheClou()
{
__int64 v0; // rbp
__int64 v1; // r12
_BOOL4 v2; // er13
bool v3; // di
unsigned int v5; // er14
const char *v6; // r15
__int64 v7; // rax
__int64 v8; // rax
int v9; // edx
unsigned int v10; // eax
__int64 v11; // rax
int v12; // edi
_BYTE v13[256]; // [rsp+0h] [rbp-528h] BYREF
char v14[512]; // [rsp+100h] [rbp-428h] BYREF
char v15[552]; // [rsp+300h] [rbp-228h] BYREF

v0 = CreateList();
v1 = CreateList();
dskBuildPathName(0LL, "datadisk", "games.lst", v14);
dskBuildPathName(0LL, "datadisk", "origin.lst", v15);
if ( !(unsigned int)ReadList(v0, 0LL, v14) || !(unsigned int)ReadList(v1, 0LL, v15) )
{
v2 = 0;
ErrorMsg(3LL, 9LL, 1LL);
v3 = 0;
LABEL_4:
tcRefreshAfterLoad(v3);
RemoveList(v0);
RemoveList(v1);
return v2;
}
ShowMenuBackground();
txtGetNthString(4LL, "LoadAGame", 0LL, v13);
inpTurnFunctionKey(0LL);
inpTurnESC(1LL);
v5 = (unsigned __int8)Menu(v0, 15LL, 0LL, 0LL, 0LL);
inpTurnFunctionKey(1LL);
if ( v5 != 255 )
{
v6 = *(const char **)(GetNthNode(v1, v5) + 16);
v7 = GetNthNode(v0, v5);
if ( strcmp(*(const char **)(v7 + 16), v6) )
{
v3 = tcLoadIt(v5);
v2 = v3;
goto LABEL_4;
}
}
ShowMenuBackground();
v2 = 0;
txtGetNthString(4LL, "NOT_LOADING", 0LL, v13);
PrintStatus(v13);
inpWaitFor(32LL);
ShowMenuBackground();
v8 = film;
v9 = *(_DWORD *)(film + 52LL);
*(_DWORD *)(film + 52LL) = -1;
*(_DWORD *)(v8 + 56) = v9;
RemoveList(v0);
RemoveList(v1);
v10 = getKey(1LL);
v11 = dbGetObject(v10);
if ( v11 )
{
v12 = **(_DWORD **)(film + 8LL);
*(_DWORD *)(v11 + 16) = v12;
SceneArgs[1] = v12;
}
return v2;
}

canonical_decompiled_code:
_BOOL8 func5()
{
__int64 v0; // rbp
__int64 v1; // r12
_BOOL4 v2; // er13
bool v3; // di
unsigned int v5; // er14
const char *v6; // r15
__int64 v7; // rax
__int64 v8; // rax
int v9; // edx
unsigned int v10; // eax
__int64 v11; // rax
int v12; // edi
_BYTE v13[256]; // [rsp+0h] [rbp-528h] BYREF
char v14[512]; // [rsp+100h] [rbp-428h] BYREF
char v15[552]; // [rsp+300h] [rbp-228h] BYREF

v0 = CreateList();
v1 = CreateList();
dskBuildPathName(0LL, "datadisk", "games.lst", v14);
dskBuildPathName(0LL, "datadisk", "origin.lst", v15);
if ( !(unsigned int)ReadList(v0, 0LL, v14) || !(unsigned int)ReadList(v1, 0LL, v15) )
{
v2 = 0;
ErrorMsg(3LL, 9LL, 1LL);
v3 = 0;
LABEL_4:
func0(v3);
RemoveList(v0);
RemoveList(v1);
return v2;
}
ShowMenuBackground();
txtGetNthString(4LL, "LoadAGame", 0LL, v13);
inpTurnFunctionKey(0LL);
inpTurnESC(1LL);
v5 = (unsigned __int8)Menu(v0, 15LL, 0LL, 0LL, 0LL);
inpTurnFunctionKey(1LL);
if ( v5 != 255 )
{
v6 = *(const char **)(GetNthNode(v1, v5) + 16);
v7 = GetNthNode(v0, v5);
if ( strcmp(*(const char **)(v7 + 16), v6) )
{
v3 = func4(v5);
v2 = v3;
goto LABEL_4;
}
}
ShowMenuBackground();
v2 = 0;
txtGetNthString(4LL, "NOT_LOADING", 0LL, v13);
PrintStatus(v13);
inpWaitFor(32LL);
ShowMenuBackground();
v8 = film;
v9 = *(_DWORD *)(film + 52LL);
*(_DWORD *)(film + 52LL) = -1;
*(_DWORD *)(v8 + 56) = v9;
RemoveList(v0);
RemoveList(v1);
v10 = getKey(1LL);
v11 = dbGetObject(v10);
if ( v11 )
{
v12 = **(_DWORD **)(film + 8LL);
*(_DWORD *)(v11 + 16) = v12;
SceneArgs[1] = v12;
}
return v2;
}

original_code:
ubyte tcLoadTheClou(void)
{
    char line[256];
    ubyte loaded = 0;
    LIST *games = CreateList();
    LIST *origin = CreateList();
    U32 activ;
    Player player;
    char pathname1[512];
    char pathname2[512];
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", "games.lst", pathname1);
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", "origin.lst", pathname2);
    if (ReadList(games, 0L, pathname1) && ReadList(origin, 0L, pathname2)) {
 ShowMenuBackground();
 (txtGetNthString(4U, "LoadAGame", 0, line));
 inpTurnFunctionKey(0);
 inpTurnESC(1);
 activ = (U32) Menu(games, 15L, 0, ((void *)0), 0L);
 inpTurnFunctionKey(1);
 if ((activ != ((U8)-1))
     &&
     (strcmp
      ((((NODE *)(GetNthNode(games, (S32) activ)))->Name),
       (((NODE *)(GetNthNode(origin, (S32) activ)))->Name)))) {
     loaded = tcLoadIt((ubyte) activ);
 } else {
     ShowMenuBackground();
     (txtGetNthString(4U, "NOT_LOADING", 0, line));
     PrintStatus(line);
     inpWaitFor((1<<5));
     ShowMenuBackground();
     {film->alter_Ort = film->akt_Ort; film->akt_Ort=(U32)(-1);};
     RemoveList(games);
     RemoveList(origin);
     if ((player = dbGetObject(getKey(_Player_Player_1)))) {
  player->CurrScene = film->act_scene->EventNr;
  SceneArgs.ReturnValue = film->act_scene->EventNr;
     }
     return 0;
 }
    } else
 ErrorMsg(Disk_Defect, ERROR_MODULE_LOADSAVE, 1);
    tcRefreshAfterLoad(loaded);
    RemoveList(games);
    RemoveList(origin);
    return loaded;
}

canonical_original_code:
unsigned char tcLoadTheClou()
{
    char line[256];
    unsigned char loaded = 0;
    struct List *games = CreateList();
    struct List *origin = CreateList();
    unsigned int activ;
    struct _Player *player;
    char pathname1[512];
    char pathname2[512];
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", "games.lst", pathname1);
    dskBuildPathName(DISK_CHECK_FILE, "datadisk", "origin.lst", pathname2);
    if (ReadList(games, 0L, pathname1) && ReadList(origin, 0L, pathname2)) {
 ShowMenuBackground();
 (txtGetNthString(4U, "LoadAGame", 0, line));
 inpTurnFunctionKey(0);
 inpTurnESC(1);
 activ = (unsigned int) Menu(games, 15L, 0, ((void *)0), 0L);
 inpTurnFunctionKey(1);
 if ((activ != ((U8)-1))
     &&
     (strcmp
      ((((struct Node *)(GetNthNode(games, (int) activ)))->Name),
       (((struct Node *)(GetNthNode(origin, (int) activ)))->Name)))) {
     loaded = tcLoadIt((unsigned char) activ);
 } else {
     ShowMenuBackground();
     (txtGetNthString(4U, "NOT_LOADING", 0, line));
     PrintStatus(line);
     inpWaitFor((1<<5));
     ShowMenuBackground();
     {film->alter_Ort = film->akt_Ort; film->akt_Ort=(U32)(-1);};
     RemoveList(games);
     RemoveList(origin);
     if ((player = dbGetObject(getKey(_Player_Player_1)))) {
  player->CurrScene = film->act_scene->EventNr;
  SceneArgs.ReturnValue = film->act_scene->EventNr;
     }
     return 0;
 }
    } else
 ErrorMsg(Disk_Defect, ERROR_MODULE_LOADSAVE, 1);
    tcRefreshAfterLoad(loaded);
    RemoveList(games);
    RemoveList(origin);
    return loaded;
}

variable_types:
activ
unsigned int


lsGetPredObject

original_code:
NODE *lsGetPredObject(NODE * start)
{
    NODE *n;
    LSObject lso;
    n = (NODE *) (((NODE *)(start))->Pred);
    while ((((NODE *)(n))->Pred)) {
 lso = (LSObject) (((struct ObjectNode *)n)->data);
 if (lso->ul_Status & (1L << 4))
     return (n);
 n = (NODE *) (((NODE *)(n))->Pred);
    }
    return start;
}

canonical_original_code:
struct Node *lsGetPredObject(struct Node *start)
{
    struct Node *n;
    struct _LSObject *lso;
    n = (struct Node *) (((struct Node *)(start))->Pred);
    while ((((struct Node *)(n))->Pred)) {
 lso = (LSObject) (((struct ObjectNode *)n)->data);
 if (lso->ul_Status & (1L << 4))
     return (n);
 n = (struct Node *) (((struct Node *)(n))->Pred);
    }
    return start;
}

variable_types:
start
struct Node *

variable_types: struct _LSObject { unsigned short us_OffsetFact; unsigned short us_DestX; unsigned short us_DestY; unsigned char uch_ExactX; unsigned char uch_ExactY; unsigned char uch_ExactX1; unsigned char uch_ExactY1; unsigned char uch_Size; unsigned char uch_Visible; unsigned char uch_Chained; unsigned int ul_Status; unsigned int Type; } *

return_type: struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } *


lsGetRasterXSize

decompiled_code:
__int64 lsGetRasterXSize()
{
return 320 / (*(_WORD *)(dbGetObject() + 16) >> 2);
}

original_code:
uword lsGetRasterXSize(U32 areaID)
{
    LSArea area = dbGetObject(areaID);
    return (uword) (320 /
      ((area->us_Width) / 4));
}

canonical_original_code:
unsigned short lsGetRasterXSize(unsigned int areaID)
{
    struct _LSArea *area = dbGetObject(areaID);
    return (uword) (320 /
      ((area->us_Width) / 4));
}

variable_types:
areaID
unsigned int

user_defined_types: struct _LSArea { unsigned short us_Coll16ID; unsigned short us_Coll32ID; unsigned short us_Coll48ID; unsigned short us_PlanColl16ID; unsigned short us_PlanColl32ID; unsigned short us_PlanColl48ID; unsigned short us_FloorCollID; unsigned short us_PlanFloorCollID; unsigned short us_Width; unsigned short us_Height; unsigned int ul_ObjectBaseNr; unsigned char uch_Darkness; unsigned short us_StartX0; unsigned short us_StartX1; unsigned short us_StartX2; unsigned short us_StartX3; unsigned short us_StartX4; unsigned short us_StartX5; unsigned short us_StartY0; unsigned short us_StartY1; unsigned short us_StartY2; unsigned short us_StartY3; unsigned short us_StartY4; unsigned short us_StartY5; }


lsGetRasterYSize

decompiled_code:
__int64 lsGetRasterYSize()
{
return 140 / (*(_WORD *)(dbGetObject() + 18) >> 2);
}

original_code:
uword lsGetRasterYSize(U32 areaID)
{
    LSArea area = dbGetObject(areaID);
    return (uword) (140 /
      ((area->us_Height) / 4));
}

canonical_original_code:
unsigned short lsGetRasterYSize(unsigned int areaID)
{
    struct _LSArea *area = dbGetObject(areaID);
    return (uword) (140 /
      ((area->us_Height) / 4));
}


lsFadeRasterObject

decompiled_code:
__int64 __fastcall lsFadeRasterObject(unsigned int a1, __int64 a2, char a3)
{
unsigned int v5; // ebx
unsigned __int16 v6; // ax
unsigned int v7; // edx
unsigned int v8; // ecx
int v9; // er8
__int16 v10; // dx
unsigned int v11; // esi
unsigned int v12; // ebx
int v13; // er10
__int16 v14; // si
__int64 v15; // rsi
unsigned __int16 v17; // [rsp+8h] [rbp-30h] BYREF
unsigned __int16 v18; // [rsp+Ah] [rbp-2Eh] BYREF
unsigned __int16 v19; // [rsp+Ch] [rbp-2Ch] BYREF
unsigned __int16 v20[21]; // [rsp+Eh] [rbp-2Ah] BYREF

v5 = (unsigned __int16)lsGetRasterXSize();
v6 = lsGetRasterYSize(a1);
if ( v5 > v6 )
v5 = v6;
lsCalcExactSize(a2, &v17, &v18, &v19, v20);
v7 = (v5 * v17) >> 2;
v8 = (v5 * v19) >> 2;
v9 = (unsigned __int16)v7;
v17 = v7;
v10 = v7 + 3;
v11 = (v5 * v18) >> 2;
v12 = (v20[0] * v5) >> 2;
v13 = (unsigned __int16)v11;
v18 = v11;
if ( v9 + 2 >= (unsigned __int16)v8 )
LOWORD(v8) = v10;
v14 = v11 + 3;
if ( v13 + 2 >= (unsigned __int16)v12 )
LOWORD(v12) = v14;
v19 = v8;
v15 = 10LL;
v20[0] = v12;
if ( a3 )
v15 = *(unsigned __int8 *)(dbGetObject(*(unsigned int *)(a2 + 20), 10LL) + 23);
gfxSetPens(l_gc, v15, (unsigned int)v15, (unsigned int)v15);
return gfxRectFill(l_gc, v17, v18, v19, v20[0]);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, __int64 a2, char a3)
{
unsigned int v5; // ebx
unsigned __int16 v6; // ax
unsigned int v7; // edx
unsigned int v8; // ecx
int v9; // er8
__int16 v10; // dx
unsigned int v11; // esi
unsigned int v12; // ebx
int v13; // er10
__int16 v14; // si
__int64 v15; // rsi
unsigned __int16 v17; // [rsp+8h] [rbp-30h] BYREF
unsigned __int16 v18; // [rsp+Ah] [rbp-2Eh] BYREF
unsigned __int16 v19; // [rsp+Ch] [rbp-2Ch] BYREF
unsigned __int16 v20[21]; // [rsp+Eh] [rbp-2Ah] BYREF

v5 = (unsigned __int16)func1();
v6 = func2(a1);
if ( v5 > v6 )
v5 = v6;
lsCalcExactSize(a2, &v17, &v18, &v19, v20);
v7 = (v5 * v17) >> 2;
v8 = (v5 * v19) >> 2;
v9 = (unsigned __int16)v7;
v17 = v7;
v10 = v7 + 3;
v11 = (v5 * v18) >> 2;
v12 = (v20[0] * v5) >> 2;
v13 = (unsigned __int16)v11;
v18 = v11;
if ( v9 + 2 >= (unsigned __int16)v8 )
LOWORD(v8) = v10;
v14 = v11 + 3;
if ( v13 + 2 >= (unsigned __int16)v12 )
LOWORD(v12) = v14;
v19 = v8;
v15 = 10LL;
v20[0] = v12;
if ( a3 )
v15 = *(unsigned __int8 *)(dbGetObject(*(unsigned int *)(a2 + 20), 10LL) + 23);
gfxSetPens(l_gc, v15, (unsigned int)v15, (unsigned int)v15);
return gfxRectFill(l_gc, v17, v18, v19, v20[0]);
}

original_code:
void lsFadeRasterObject(U32 areaID, LSObject lso, ubyte status)
{
    U32 rasterXSize, rasterYSize, rasterSize, col;
    uword xStart, yStart, xEnd, yEnd;
    rasterXSize = lsGetRasterXSize(areaID);
    rasterYSize = lsGetRasterYSize(areaID);
    rasterSize = ((rasterXSize) < (rasterYSize) ? (rasterXSize) : (rasterYSize));
    lsCalcExactSize(lso, &xStart, &yStart, &xEnd, &yEnd);
    xStart = ((xStart) * rasterSize) / 4;
    yStart = ((yStart) * rasterSize) / 4;
    xEnd = ((xEnd) * rasterSize) / 4;
    yEnd = ((yEnd) * rasterSize) / 4;
    xEnd = ((xStart + 3) > (xEnd) ? (xStart + 3) : (xEnd));
    yEnd = ((yStart + 3) > (yEnd) ? (yStart + 3) : (yEnd));
    if (status)
 col = (((Item) dbGetObject(lso->Type))->ColorNr);
    else
 col = 10;
    gfxSetPens(l_gc, col, col, col);
    gfxRectFill(l_gc, xStart, yStart, xEnd, yEnd);
}

canonical_original_code:
void lsFadeRasterObject(unsigned int areaID, struct _LSObject *lso, unsigned char status)
{
    unsigned int rasterXSize; unsigned int rasterYSize; unsigned int rasterSize; unsigned int col;
    unsigned short xStart; unsigned short yStart; unsigned short xEnd; unsigned short yEnd;
    rasterXSize = lsGetRasterXSize(areaID);
    rasterYSize = lsGetRasterYSize(areaID);
    rasterSize = ((rasterXSize) < (rasterYSize) ? (rasterXSize) : (rasterYSize));
    lsCalcExactSize(lso, &xStart, &yStart, &xEnd, &yEnd);
    xStart = ((xStart) * rasterSize) / 4;
    yStart = ((yStart) * rasterSize) / 4;
    xEnd = ((xEnd) * rasterSize) / 4;
    yEnd = ((yEnd) * rasterSize) / 4;
    xEnd = ((xStart + 3) > (xEnd) ? (xStart + 3) : (xEnd));
    yEnd = ((yStart + 3) > (yEnd) ? (yStart + 3) : (yEnd));
    if (status)
 col = (((struct _Item *) dbGetObject(lso->Type))->ColorNr);
    else
 col = 10;
    gfxSetPens(l_gc, col, col, col);
    gfxRectFill(l_gc, xStart, yStart, xEnd, yEnd);
}

variable_types:
status
unsigned char

variable_types:
rasterXSize
unsigned int

variable_types:
rasterYSize
unsigned int

variable_types:
rasterSize
unsigned int

variable_types:
col
unsigned int

variable_types:
xStart
unsigned short

variable_types:
yStart
unsigned short

variable_types:
xEnd
unsigned short

variable_types:
yEnd
unsigned short

user_defined_types: struct _Item { enum ItemE Type; unsigned short OffsetFact; unsigned short HExactXOffset; unsigned short HExactYOffset; unsigned short HExactWidth; unsigned short HExactHeight; unsigned short VExactXOffset; unsigned short VExactYOffset; unsigned short VExactWidth; unsigned short VExactHeight; unsigned char Size; unsigned char ColorNr; }

user_defined_types: enum ItemE { Holztuer=0, Stahltuer=1, Ausstellungskasten=2, Kasse=3, Kasten=4, Schreibtisch=5, Nachtkaestchen=6, Wertschrank=7, Stahlschrank=8, Panzerschrank=9, Tresorraum=10, Mauer=11, Mauerecke=12, Steinmauer=13, Mauertor=14, Zaun=15, Zauntor=16, Saeule=17, Fenster=18, Alarmanlage_Z3=19, Alarmanlage_X3=20, Alarmanlage_Top=21, Mikrophon=22, Stechuhr=23, Scheinwerfer=24, Lichtschranke=25, Steuerkasten=26, Grab=27, Grabhuegel=28, Kreuz=29, Kranz=30, Gruft=31, Treppe=32, Sockel=33, WC=34, Sessel=35, Pult=36, Statue=37, Beutesack=38, Bett=39, Billardtisch=40, Sofa=41, Spiegel=42, Tisch=43, Kamin=44, Badewanne=45, Tresen=46, Gemaelde=47, Klavier=48, Buecherregal=49, Skelett=50, Dinosaurier=51, Elch=52, Kanone=53, Beefeater=54, Busch=55, Strauch=56, Gebuesch=57, Laubbaum=58, Nadelbaum=59, Hecke=60, Hantel=61, Regal=62, Flugzeugheck=63, linker_Flugzeugfluegel=64, rechter_Flugzeugfluegel=65, Bild=66, Vase=67, Kuehlschrank=68, Wache=69, Beichtstuhl=70, Kirchenbank=71, Altar=72, Kroehnungsstuhl=73, Opferkassa=74, Schrein=75, Kerzen=76, Weihwasserbecken=77, Heiligenstatue=78, Kerzenstaender=79, Kirchenkreuz=80, Gelaender=81, verzierte_Saeule=82, Regal_mit_Chemikalien=83, Versuchstisch=84, Kiste=85, Fasz=86, leere_Palette=87, Palette_mit_Schachteln=88, Absperrung=89, Hottentotten_Figur=90, Batman_Figur=91, Dicker_Man=92, Unbekannter=93, Jack_the_Ripper_Figur=94, Koenigs_Figur=95, Wache_Figur=96, Miss_World_1952=97, groszer_Koffer=98, Sitzbank=99, Speisetisch=100, Holzkiste=101, Palette_mit_Kisten=102, Postsack=103, Leiter=104, Zuggelaender=105, Lokomotive_vorne_rechts=106, Lokomotive_vorne_links=107, Lokomotive_oben=108, Lokomotive_seitlich=109, Lokomotive_Kabine=110, Lokomotive_Tuer=111 }


lsShowRaster

decompiled_code:
__int64 __fastcall lsShowRaster(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rbp
_QWORD **v4; // r13
int v5; // eax
_QWORD *v6; // r14
signed int v7; // ebx
__int64 v8; // rsi
int v9; // er15
unsigned int v10; // ecx
_QWORD *v11; // rbp
int v12; // er14
__int64 v13; // rsi
unsigned int v14; // edi
__int64 v15; // rsi
unsigned int v16; // er8
__int64 v17; // rsi
unsigned int v18; // er9
_QWORD *v19; // r14
__int64 v20; // rsi
int v21; // er15
unsigned int v22; // ecx
_QWORD *v23; // rbp
int v24; // er14
__int64 v25; // rsi
unsigned int v26; // edi
__int64 v27; // rsi
unsigned int v28; // er8
__int64 v29; // rsi
unsigned int v30; // er9
__int64 v31; // rsi
unsigned int v32; // er10
_QWORD *v33; // rbp
int v34; // er14
__int64 v35; // rsi
unsigned int v36; // er11
_QWORD *v37; // r15
__int64 v38; // rsi
unsigned int v39; // eax
_QWORD *v40; // rbp
__int64 v41; // rsi
unsigned int v42; // edx
__int64 v43; // rsi
unsigned int v44; // er10
_QWORD *v45; // rbp
int v46; // er14
__int64 v47; // rsi
unsigned int v48; // er11
_QWORD *v49; // r15
__int64 v50; // rsi
unsigned int v51; // eax
_QWORD *v52; // rbp
__int64 v53; // rsi
unsigned int v54; // edx

v2 = a1;
v3 = dbGetObject(a1, a2);
gfxShow(154LL, 33LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
SetObjectListAttr(4LL, 9913LL);
AskAll(v3, ConsistOfRelationID, &BuildObjectList);
v4 = (_QWORD **)ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
{
Say(4LL, 0LL, 7LL, "KEIN_GRUNDRISS");
return RemoveList(v4);
}
v5 = GetNrOfNodes(ObjectListPrivate);
v6 = *v4;
v7 = v5 * (unsigned int)(unsigned __int8)a2 / 0xFF;
if ( **v4 && v7 )
{
v8 = v6[5];
v9 = ((_BYTE)v7 - 1) & 3;
v10 = *(_DWORD *)(v8 + 20);
if ( v10 > 0x23F9 )
{
if ( v10 != 9253 )
goto LABEL_6;
}
else if ( v10 <= 0x23F7 )
{
LABEL_6:
v11 = (_QWORD *)*v6;
v12 = 1;
if ( !*v11 || v7 <= 1 )
{
LABEL_20:
v19 = *v4;
if ( !**v4 )
return RemoveList(v4);
v20 = v19[5];
v21 = ((_BYTE)v7 - 1) & 3;
v22 = *(_DWORD *)(v20 + 20);
if ( v22 > 0x23F9 )
{
if ( v22 == 9253 )
goto LABEL_24;
}
else if ( v22 > 0x23F7 )
{
LABEL_24:
v23 = (_QWORD *)*v19;
v24 = 1;
if ( !*v23 || v7 <= 1 )
return RemoveList(v4);
if ( (((_BYTE)v7 - 1) & 3) == 0 )
goto LABEL_62;
if ( v21 == 1 )
{
LABEL_37:
v29 = v23[5];
v30 = *(_DWORD *)(v29 + 20);
if ( v30 > 0x23F9 )
{
if ( v30 == 9253 )
{
LABEL_94:
v23 = (_QWORD *)*v23;
++v24;
if ( !*v23 )
return RemoveList(v4);
while ( 1 )
{
if ( v7 <= v24 )
return RemoveList(v4);
LABEL_62:
v43 = v23[5];
v44 = *(_DWORD *)(v43 + 20);
if ( v44 <= 0x23F9 )
break;
if ( v44 != 9253 )
goto LABEL_64;
LABEL_65:
v45 = (_QWORD *)*v23;
v46 = v24 + 1;
if ( !*v45 )
return RemoveList(v4);
v47 = v45[5];
v48 = *(_DWORD *)(v47 + 20);
if ( v48 <= 0x23F9 )
{
if ( v48 > 0x23F7 )
goto LABEL_69;
LABEL_68:
lsFadeRasterObject(v2, v47, 1);
goto LABEL_69;
}
if ( v48 != 9253 )
goto LABEL_68;
LABEL_69:
v49 = (_QWORD *)*v45;
if ( !*(_QWORD *)*v45 )
return RemoveList(v4);
v50 = v49[5];
v51 = *(_DWORD *)(v50 + 20);
if ( v51 <= 0x23F9 )
{
if ( v51 > 0x23F7 )
goto LABEL_73;
LABEL_72:
lsFadeRasterObject(v2, v50, 1);
goto LABEL_73;
}
if ( v51 != 9253 )
goto LABEL_72;
LABEL_73:
v52 = (_QWORD *)*v49;
if ( !*(_QWORD *)*v49 )
return RemoveList(v4);
v53 = v52[5];
v54 = *(_DWORD *)(v53 + 20);
if ( v54 > 0x23F9 )
{
if ( v54 != 9253 )
goto LABEL_76;
}
else if ( v54 <= 0x23F7 )
{
LABEL_76:
lsFadeRasterObject(v2, v53, 1);
goto LABEL_60;
}
LABEL_60:
v23 = (_QWORD *)*v52;
v24 = v46 + 3;
if ( !*v23 )
return RemoveList(v4);
}
if ( v44 > 0x23F7 )
goto LABEL_65;
LABEL_64:
lsFadeRasterObject(v2, v43, 1);
goto LABEL_65;
}
}
else if ( v30 > 0x23F7 )
{
goto LABEL_94;
}
lsFadeRasterObject(v2, v29, 1);
goto LABEL_94;
}
if ( v21 == 2 )
{
LABEL_33:
v27 = v23[5];
v28 = *(_DWORD *)(v27 + 20);
if ( v28 > 0x23F9 )
{
if ( v28 == 9253 )
{
LABEL_36:
v23 = (_QWORD *)*v23;
++v24;
if ( *v23 )
goto LABEL_37;
return RemoveList(v4);
}
}
else if ( v28 > 0x23F7 )
{
goto LABEL_36;
}
lsFadeRasterObject(v2, v27, 1);
goto LABEL_36;
}
v25 = v23[5];
v26 = *(_DWORD *)(v25 + 20);
if ( v26 > 0x23F9 )
{
if ( v26 == 9253 )
{
LABEL_32:
v23 = (_QWORD *)*v23;
v24 = 2;
if ( !*v23 )
return RemoveList(v4);
goto LABEL_33;
}
}
else if ( v26 > 0x23F7 )
{
goto LABEL_32;
}
lsFadeRasterObject(v2, v25, 1);
goto LABEL_32;
}
lsFadeRasterObject(v2, v20, 1);
goto LABEL_24;
}
if ( (((_BYTE)v7 - 1) & 3) == 0 )
goto LABEL_45;
if ( v9 == 1 )
{
LABEL_17:
v17 = v11[5];
v18 = *(_DWORD *)(v17 + 20);
if ( v18 <= 0x23F9 )
{
if ( v18 <= 0x23F7 )
goto LABEL_19;
}
else if ( v18 != 9253 )
{
goto LABEL_19;
}
lsFadeRasterObject(v2, v17, 1);
LABEL_19:
v11 = (_QWORD *)*v11;
++v12;
if ( !*v11 )
goto LABEL_20;
while ( 1 )
{
if ( v7 <= v12 )
goto LABEL_20;
LABEL_45:
v31 = v11[5];
v32 = *(_DWORD *)(v31 + 20);
if ( v32 > 0x23F9 )
{
if ( v32 != 9253 )
goto LABEL_47;
}
else if ( v32 <= 0x23F7 )
{
goto LABEL_47;
}
lsFadeRasterObject(v2, v31, 1);
LABEL_47:
v33 = (_QWORD *)*v11;
v34 = v12 + 1;
if ( !*v33 )
goto LABEL_20;
v35 = v33[5];
v36 = *(_DWORD *)(v35 + 20);
if ( v36 > 0x23F9 )
{
if ( v36 != 9253 )
goto LABEL_50;
}
else if ( v36 <= 0x23F7 )
{
goto LABEL_50;
}
lsFadeRasterObject(v2, v35, 1);
LABEL_50:
v37 = (_QWORD *)*v33;
if ( !*(_QWORD *)*v33 )
goto LABEL_20;
v38 = v37[5];
v39 = *(_DWORD *)(v38 + 20);
if ( v39 > 0x23F9 )
{
if ( v39 != 9253 )
goto LABEL_53;
}
else if ( v39 <= 0x23F7 )
{
goto LABEL_53;
}
lsFadeRasterObject(v2, v38, 1);
LABEL_53:
v40 = (_QWORD *)*v37;
if ( !*(_QWORD *)*v37 )
goto LABEL_20;
v41 = v40[5];
v42 = *(_DWORD *)(v41 + 20);
if ( v42 > 0x23F9 )
{
if ( v42 == 9253 )
goto LABEL_56;
}
else if ( v42 > 0x23F7 )
{
LABEL_56:
lsFadeRasterObject(v2, v41, 1);
goto LABEL_43;
}
LABEL_43:
v11 = (_QWORD *)*v40;
v12 = v34 + 3;
if ( !*v11 )
goto LABEL_20;
}
}
if ( v9 == 2 )
{
LABEL_14:
v15 = v11[5];
v16 = *(_DWORD *)(v15 + 20);
if ( v16 > 0x23F9 )
{
if ( v16 != 9253 )
goto LABEL_16;
}
else if ( v16 <= 0x23F7 )
{
goto LABEL_16;
}
lsFadeRasterObject(v2, v15, 1);
LABEL_16:
v11 = (_QWORD *)*v11;
++v12;
if ( !*v11 )
goto LABEL_20;
goto LABEL_17;
}
v13 = v11[5];
v14 = *(_DWORD *)(v13 + 20);
if ( v14 > 0x23F9 )
{
if ( v14 != 9253 )
goto LABEL_13;
}
else if ( v14 <= 0x23F7 )
{
goto LABEL_13;
}
lsFadeRasterObject(v2, v13, 1);
LABEL_13:
v11 = (_QWORD *)*v11;
v12 = 2;
if ( !*v11 )
goto LABEL_20;
goto LABEL_14;
}
lsFadeRasterObject(a1, v8, 1);
goto LABEL_6;
}
return RemoveList(v4);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rbp
_QWORD **v4; // r13
int v5; // eax
_QWORD *v6; // r14
signed int v7; // ebx
__int64 v8; // rsi
int v9; // er15
unsigned int v10; // ecx
_QWORD *v11; // rbp
int v12; // er14
__int64 v13; // rsi
unsigned int v14; // edi
__int64 v15; // rsi
unsigned int v16; // er8
__int64 v17; // rsi
unsigned int v18; // er9
_QWORD *v19; // r14
__int64 v20; // rsi
int v21; // er15
unsigned int v22; // ecx
_QWORD *v23; // rbp
int v24; // er14
__int64 v25; // rsi
unsigned int v26; // edi
__int64 v27; // rsi
unsigned int v28; // er8
__int64 v29; // rsi
unsigned int v30; // er9
__int64 v31; // rsi
unsigned int v32; // er10
_QWORD *v33; // rbp
int v34; // er14
__int64 v35; // rsi
unsigned int v36; // er11
_QWORD *v37; // r15
__int64 v38; // rsi
unsigned int v39; // eax
_QWORD *v40; // rbp
__int64 v41; // rsi
unsigned int v42; // edx
__int64 v43; // rsi
unsigned int v44; // er10
_QWORD *v45; // rbp
int v46; // er14
__int64 v47; // rsi
unsigned int v48; // er11
_QWORD *v49; // r15
__int64 v50; // rsi
unsigned int v51; // eax
_QWORD *v52; // rbp
__int64 v53; // rsi
unsigned int v54; // edx

v2 = a1;
v3 = dbGetObject(a1, a2);
gfxShow(154LL, 33LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
SetObjectListAttr(4LL, 9913LL);
AskAll(v3, ConsistOfRelationID, &BuildObjectList);
v4 = (_QWORD **)ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
{
Say(4LL, 0LL, 7LL, "KEIN_GRUNDRISS");
return RemoveList(v4);
}
v5 = GetNrOfNodes(ObjectListPrivate);
v6 = *v4;
v7 = v5 * (unsigned int)(unsigned __int8)a2 / 0xFF;
if ( **v4 && v7 )
{
v8 = v6[5];
v9 = ((_BYTE)v7 - 1) & 3;
v10 = *(_DWORD *)(v8 + 20);
if ( v10 > 0x23F9 )
{
if ( v10 != 9253 )
goto LABEL_6;
}
else if ( v10 <= 0x23F7 )
{
LABEL_6:
v11 = (_QWORD *)*v6;
v12 = 1;
if ( !*v11 || v7 <= 1 )
{
LABEL_20:
v19 = *v4;
if ( !**v4 )
return RemoveList(v4);
v20 = v19[5];
v21 = ((_BYTE)v7 - 1) & 3;
v22 = *(_DWORD *)(v20 + 20);
if ( v22 > 0x23F9 )
{
if ( v22 == 9253 )
goto LABEL_24;
}
else if ( v22 > 0x23F7 )
{
LABEL_24:
v23 = (_QWORD *)*v19;
v24 = 1;
if ( !*v23 || v7 <= 1 )
return RemoveList(v4);
if ( (((_BYTE)v7 - 1) & 3) == 0 )
goto LABEL_62;
if ( v21 == 1 )
{
LABEL_37:
v29 = v23[5];
v30 = *(_DWORD *)(v29 + 20);
if ( v30 > 0x23F9 )
{
if ( v30 == 9253 )
{
LABEL_94:
v23 = (_QWORD *)*v23;
++v24;
if ( !*v23 )
return RemoveList(v4);
while ( 1 )
{
if ( v7 <= v24 )
return RemoveList(v4);
LABEL_62:
v43 = v23[5];
v44 = *(_DWORD *)(v43 + 20);
if ( v44 <= 0x23F9 )
break;
if ( v44 != 9253 )
goto LABEL_64;
LABEL_65:
v45 = (_QWORD *)*v23;
v46 = v24 + 1;
if ( !*v45 )
return RemoveList(v4);
v47 = v45[5];
v48 = *(_DWORD *)(v47 + 20);
if ( v48 <= 0x23F9 )
{
if ( v48 > 0x23F7 )
goto LABEL_69;
LABEL_68:
func3(v2, v47, 1);
goto LABEL_69;
}
if ( v48 != 9253 )
goto LABEL_68;
LABEL_69:
v49 = (_QWORD *)*v45;
if ( !*(_QWORD *)*v45 )
return RemoveList(v4);
v50 = v49[5];
v51 = *(_DWORD *)(v50 + 20);
if ( v51 <= 0x23F9 )
{
if ( v51 > 0x23F7 )
goto LABEL_73;
LABEL_72:
func3(v2, v50, 1);
goto LABEL_73;
}
if ( v51 != 9253 )
goto LABEL_72;
LABEL_73:
v52 = (_QWORD *)*v49;
if ( !*(_QWORD *)*v49 )
return RemoveList(v4);
v53 = v52[5];
v54 = *(_DWORD *)(v53 + 20);
if ( v54 > 0x23F9 )
{
if ( v54 != 9253 )
goto LABEL_76;
}
else if ( v54 <= 0x23F7 )
{
LABEL_76:
func3(v2, v53, 1);
goto LABEL_60;
}
LABEL_60:
v23 = (_QWORD *)*v52;
v24 = v46 + 3;
if ( !*v23 )
return RemoveList(v4);
}
if ( v44 > 0x23F7 )
goto LABEL_65;
LABEL_64:
func3(v2, v43, 1);
goto LABEL_65;
}
}
else if ( v30 > 0x23F7 )
{
goto LABEL_94;
}
func3(v2, v29, 1);
goto LABEL_94;
}
if ( v21 == 2 )
{
LABEL_33:
v27 = v23[5];
v28 = *(_DWORD *)(v27 + 20);
if ( v28 > 0x23F9 )
{
if ( v28 == 9253 )
{
LABEL_36:
v23 = (_QWORD *)*v23;
++v24;
if ( *v23 )
goto LABEL_37;
return RemoveList(v4);
}
}
else if ( v28 > 0x23F7 )
{
goto LABEL_36;
}
func3(v2, v27, 1);
goto LABEL_36;
}
v25 = v23[5];
v26 = *(_DWORD *)(v25 + 20);
if ( v26 > 0x23F9 )
{
if ( v26 == 9253 )
{
LABEL_32:
v23 = (_QWORD *)*v23;
v24 = 2;
if ( !*v23 )
return RemoveList(v4);
goto LABEL_33;
}
}
else if ( v26 > 0x23F7 )
{
goto LABEL_32;
}
func3(v2, v25, 1);
goto LABEL_32;
}
func3(v2, v20, 1);
goto LABEL_24;
}
if ( (((_BYTE)v7 - 1) & 3) == 0 )
goto LABEL_45;
if ( v9 == 1 )
{
LABEL_17:
v17 = v11[5];
v18 = *(_DWORD *)(v17 + 20);
if ( v18 <= 0x23F9 )
{
if ( v18 <= 0x23F7 )
goto LABEL_19;
}
else if ( v18 != 9253 )
{
goto LABEL_19;
}
func3(v2, v17, 1);
LABEL_19:
v11 = (_QWORD *)*v11;
++v12;
if ( !*v11 )
goto LABEL_20;
while ( 1 )
{
if ( v7 <= v12 )
goto LABEL_20;
LABEL_45:
v31 = v11[5];
v32 = *(_DWORD *)(v31 + 20);
if ( v32 > 0x23F9 )
{
if ( v32 != 9253 )
goto LABEL_47;
}
else if ( v32 <= 0x23F7 )
{
goto LABEL_47;
}
func3(v2, v31, 1);
LABEL_47:
v33 = (_QWORD *)*v11;
v34 = v12 + 1;
if ( !*v33 )
goto LABEL_20;
v35 = v33[5];
v36 = *(_DWORD *)(v35 + 20);
if ( v36 > 0x23F9 )
{
if ( v36 != 9253 )
goto LABEL_50;
}
else if ( v36 <= 0x23F7 )
{
goto LABEL_50;
}
func3(v2, v35, 1);
LABEL_50:
v37 = (_QWORD *)*v33;
if ( !*(_QWORD *)*v33 )
goto LABEL_20;
v38 = v37[5];
v39 = *(_DWORD *)(v38 + 20);
if ( v39 > 0x23F9 )
{
if ( v39 != 9253 )
goto LABEL_53;
}
else if ( v39 <= 0x23F7 )
{
goto LABEL_53;
}
func3(v2, v38, 1);
LABEL_53:
v40 = (_QWORD *)*v37;
if ( !*(_QWORD *)*v37 )
goto LABEL_20;
v41 = v40[5];
v42 = *(_DWORD *)(v41 + 20);
if ( v42 > 0x23F9 )
{
if ( v42 == 9253 )
goto LABEL_56;
}
else if ( v42 > 0x23F7 )
{
LABEL_56:
func3(v2, v41, 1);
goto LABEL_43;
}
LABEL_43:
v11 = (_QWORD *)*v40;
v12 = v34 + 3;
if ( !*v11 )
goto LABEL_20;
}
}
if ( v9 == 2 )
{
LABEL_14:
v15 = v11[5];
v16 = *(_DWORD *)(v15 + 20);
if ( v16 > 0x23F9 )
{
if ( v16 != 9253 )
goto LABEL_16;
}
else if ( v16 <= 0x23F7 )
{
goto LABEL_16;
}
func3(v2, v15, 1);
LABEL_16:
v11 = (_QWORD *)*v11;
++v12;
if ( !*v11 )
goto LABEL_20;
goto LABEL_17;
}
v13 = v11[5];
v14 = *(_DWORD *)(v13 + 20);
if ( v14 > 0x23F9 )
{
if ( v14 != 9253 )
goto LABEL_13;
}
else if ( v14 <= 0x23F7 )
{
goto LABEL_13;
}
func3(v2, v13, 1);
LABEL_13:
v11 = (_QWORD *)*v11;
v12 = 2;
if ( !*v11 )
goto LABEL_20;
goto LABEL_14;
}
func3(a1, v8, 1);
goto LABEL_6;
}
return RemoveList(v4);
}

original_code:
void lsShowRaster(U32 areaID, ubyte perc)
{
    LSArea area = dbGetObject(areaID);
    struct ObjectNode *node;
    S32 count, i;
    LIST *objects;
    gfxShow(154, 1 | 32, 0, -1, -1);
    SetObjectListAttr((1 << 2), 9913L);
    AskAll(area, ConsistOfRelationID, BuildObjectList);
    objects = ObjectListPrivate;
    if (!((!(((NODE *)(((((NODE *)((&(((objects)))->Head)))->Succ))))->Succ)))) {
 count = (GetNrOfNodes(objects) * perc) / 255;
 for (node = (struct ObjectNode *) ((((NODE *)((&((objects))->Head)))->Succ)), i = 0;
      ((((NODE *)((NODE *) node))->Succ)) && (i < count);
      node = (struct ObjectNode *) (((NODE *)((NODE *) node))->Succ), i++) {
     LSObject lso = (((struct ObjectNode *)node)->data);
     switch (lso->Type) {
     case 9208U:
     case 9209U:
     case 9253U:
  lsFadeRasterObject(areaID, lso, 1);
  break;
     default:
  break;
     }
 }
 for (node = (struct ObjectNode *) ((((NODE *)((&((objects))->Head)))->Succ)), i = 0;
      ((((NODE *)((NODE *) node))->Succ)) && (i < count);
      node = (struct ObjectNode *) (((NODE *)((NODE *) node))->Succ), i++) {
     LSObject lso = (((struct ObjectNode *)node)->data);
     switch (lso->Type) {
     case 9208U:
     case 9209U:
     case 9253U:
  break;
     default:
  lsFadeRasterObject(areaID, lso, 1);
  break;
     }
 }
    } else
 Say(4U, 0, 7, "KEIN_GRUNDRISS");
    RemoveList(objects);
}

canonical_original_code:
void lsShowRaster(unsigned int areaID, unsigned char perc)
{
    struct _LSArea *area = dbGetObject(areaID);
    struct ObjectNode *node;
    int count; int i;
    struct List *objects;
    gfxShow(154, 1 | 32, 0, -1, -1);
    SetObjectListAttr((1 << 2), 9913L);
    AskAll(area, ConsistOfRelationID, BuildObjectList);
    objects = ObjectListPrivate;
    if (!((!(((struct Node *)(((((struct Node *)((&(((objects)))->Head)))->Succ))))->Succ)))) {
 count = (GetNrOfNodes(objects) * perc) / 255;
 for (node = (struct ObjectNode *) ((((struct Node *)((&((objects))->Head)))->Succ)), i = 0;
      ((((struct Node *)((struct Node *) node))->Succ)) && (i < count);
      node = (struct ObjectNode *) (((struct Node *)((struct Node *) node))->Succ), i++) {
     struct _LSObject *lso = (((struct ObjectNode *)node)->data);
     switch (lso->Type) {
     case 9208U:
     case 9209U:
     case 9253U:
  lsFadeRasterObject(areaID, lso, 1);
  break;
     default:
  break;
     }
 }
 for (node = (struct ObjectNode *) ((((struct Node *)((&((objects))->Head)))->Succ)), i = 0;
      ((((struct Node *)((struct Node *) node))->Succ)) && (i < count);
      node = (struct ObjectNode *) (((struct Node *)((struct Node *) node))->Succ), i++) {
     struct _LSObject *lso = (((struct ObjectNode *)node)->data);
     switch (lso->Type) {
     case 9208U:
     case 9209U:
     case 9253U:
  break;
     default:
  lsFadeRasterObject(areaID, lso, 1);
  break;
     }
 }
    } else
 Say(4U, 0, 7, "KEIN_GRUNDRISS");
    RemoveList(objects);
}

variable_types:
perc
unsigned char

variable_types: struct _LSArea { unsigned short us_Coll16ID; unsigned short us_Coll32ID; unsigned short us_Coll48ID; unsigned short us_PlanColl16ID; unsigned short us_PlanColl32ID; unsigned short us_PlanColl48ID; unsigned short us_FloorCollID; unsigned short us_PlanFloorCollID; unsigned short us_Width; unsigned short us_Height; unsigned int ul_ObjectBaseNr; unsigned char uch_Darkness; unsigned short us_StartX0; unsigned short us_StartX1; unsigned short us_StartX2; unsigned short us_StartX3; unsigned short us_StartX4; unsigned short us_StartX5; unsigned short us_StartY0; unsigned short us_StartY1; unsigned short us_StartY2; unsigned short us_StartY3; unsigned short us_StartY4; unsigned short us_StartY5; } *

variable_types: struct ObjectNode { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned int nr; unsigned int type; void *data; } *

variable_types: count int

variable_types: i int

variable_types: struct List { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Head; struct Node Tail; } *


plGetNextLoot

decompiled_code:
__int64 plGetNextLoot()
{
unsigned __int8 v0; // bp
__int64 v1; // rax
__int64 v3; // rdx
__int16 v4; // bx
unsigned __int16 v5; // ax

if ( Planing_Loot )
{
if ( *((_BYTE *)&Planing_Loot + 1) )
{
if ( *((_BYTE *)&Planing_Loot + 2) )
{
if ( *((_BYTE *)&Planing_Loot + 3) )
{
if ( *((_BYTE *)&Planing_Loot + 4) )
{
if ( *((_BYTE *)&Planing_Loot + 5) )
{
if ( *((_BYTE *)&Planing_Loot + 6) )
{
v0 = 8;
v1 = 7LL;
if ( *((_BYTE *)&Planing_Loot + 7) )
return 0LL;
}
else
{
v0 = 7;
v1 = 6LL;
}
}
else
{
v0 = 6;
v1 = 5LL;
}
}
else
{
v0 = 5;
v1 = 4LL;
}
}
else
{
v0 = 4;
v1 = 3LL;
}
}
else
{
v0 = 3;
v1 = 2LL;
}
}
else
{
v0 = 2;
v1 = 1LL;
}
}
else
{
v0 = 1;
v1 = 0LL;
}
v3 = CurrentPerson;
*((_BYTE *)&Planing_Loot + v1) = 1;
v4 = livGetYPos((char *)&Planing_Name + 20 * v3);
v5 = livGetXPos((char *)&Planing_Name + 20 * CurrentPerson);
return lsAddLootBag(v5, (unsigned __int16)(v4 + 5), v0);
}

canonical_decompiled_code:
__int64 func0()
{
unsigned __int8 v0; // bp
__int64 v1; // rax
__int64 v3; // rdx
__int16 v4; // bx
unsigned __int16 v5; // ax

if ( Planing_Loot )
{
if ( *((_BYTE *)&Planing_Loot + 1) )
{
if ( *((_BYTE *)&Planing_Loot + 2) )
{
if ( *((_BYTE *)&Planing_Loot + 3) )
{
if ( *((_BYTE *)&Planing_Loot + 4) )
{
if ( *((_BYTE *)&Planing_Loot + 5) )
{
if ( *((_BYTE *)&Planing_Loot + 6) )
{
v0 = 8;
v1 = 7LL;
if ( *((_BYTE *)&Planing_Loot + 7) )
return 0LL;
}
else
{
v0 = 7;
v1 = 6LL;
}
}
else
{
v0 = 6;
v1 = 5LL;
}
}
else
{
v0 = 5;
v1 = 4LL;
}
}
else
{
v0 = 4;
v1 = 3LL;
}
}
else
{
v0 = 3;
v1 = 2LL;
}
}
else
{
v0 = 2;
v1 = 1LL;
}
}
else
{
v0 = 1;
v1 = 0LL;
}
v3 = CurrentPerson;
*((_BYTE *)&Planing_Loot + v1) = 1;
v4 = livGetYPos((char *)&Planing_Name + 20 * v3);
v5 = livGetXPos((char *)&Planing_Name + 20 * CurrentPerson);
return lsAddLootBag(v5, (unsigned __int16)(v4 + 5), v0);
}

original_code:
U32 plGetNextLoot(void)
{
    register ubyte i;
    for (i = 0; i < 8; i++) {
 if (!Planing_Loot[i]) {
     Planing_Loot[i] = 1;
     return lsAddLootBag(livGetXPos(Planing_Name[CurrentPerson]),
    livGetYPos(Planing_Name[CurrentPerson]) + 5,
    i + 1);
 }
    }
    return 0L;
}

canonical_original_code:
unsigned int plGetNextLoot()
{
    register unsigned char i;
    for (i = 0; i < 8; i++) {
 if (!Planing_Loot[i]) {
     Planing_Loot[i] = 1;
     return lsAddLootBag(livGetXPos(Planing_Name[CurrentPerson]),
    livGetYPos(Planing_Name[CurrentPerson]) + 5,
    i + 1);
 }
    }
    return 0L;
}

variable_types:
i
unsigned char


plLivingsPosAtCar

decompiled_code:
__int64 __fastcall plLivingsPosAtCar(unsigned int a1)
{
__int64 v1; // rax
unsigned __int16 v2; // r13
unsigned __int16 v3; // bp
__int64 v4; // rax
unsigned __int8 v5; // r14
unsigned __int16 v6; // r15
int v7; // ebx

v1 = ((__int64 (*)(void))dbGetObject)();
v2 = *(_WORD *)(v1 + 24) + 8;
v3 = *(_WORD *)(v1 + 26) + 8;
SetObjectListAttr(0LL, 509992LL);
v4 = dbGetObject(a1);
AskAll(v4, 500001LL, &BuildObjectList);
if ( !BurglarsNr )
return 1LL;
v5 = 0;
while ( 1 )
{
v6 = livGetXPos((char *)&Planing_Name + 20 * v5);
v7 = (unsigned __int16)livGetYPos((char *)&Planing_Name + 20 * v5);
if ( (unsigned int)livWhereIs((char *)&Planing_Name + 20 * v5) != *(_DWORD *)(*ObjectList + 32LL)
|| (v6 < v2 - 16 || v6 > v2 + 16) && (v7 < v3 - 16 || v7 > v3 + 16) )
{
break;
}
if ( BurglarsNr <= ++v5 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
__int64 v1; // rax
unsigned __int16 v2; // r13
unsigned __int16 v3; // bp
__int64 v4; // rax
unsigned __int8 v5; // r14
unsigned __int16 v6; // r15
int v7; // ebx

v1 = ((__int64 (*)(void))dbGetObject)();
v2 = *(_WORD *)(v1 + 24) + 8;
v3 = *(_WORD *)(v1 + 26) + 8;
SetObjectListAttr(0LL, 509992LL);
v4 = dbGetObject(a1);
AskAll(v4, 500001LL, &BuildObjectList);
if ( !BurglarsNr )
return 1LL;
v5 = 0;
while ( 1 )
{
v6 = livGetXPos((char *)&Planing_Name + 20 * v5);
v7 = (unsigned __int16)livGetYPos((char *)&Planing_Name + 20 * v5);
if ( (unsigned int)livWhereIs((char *)&Planing_Name + 20 * v5) != *(_DWORD *)(*ObjectList + 32LL)
|| (v6 < v2 - 16 || v6 > v2 + 16) && (v7 < v3 - 16 || v7 > v3 + 16) )
{
break;
}
if ( BurglarsNr <= ++v5 )
return 1LL;
}
return 0LL;
}

original_code:
ubyte plLivingsPosAtCar(U32 bldId)
{
    Building bldObj = (Building) dbGetObject(bldId);
    uword xpos, ypos, carxpos, carypos;
    ubyte i, atCar = 1;
    carxpos = bldObj->CarXPos + 8;
    carypos = bldObj->CarYPos + 8;
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (bldId), 500001, BuildObjectList); };
    for (i = 0; i < BurglarsNr; i++) {
 xpos = livGetXPos(Planing_Name[i]);
 ypos = livGetYPos(Planing_Name[i]);
 if (livWhereIs(Planing_Name[i]) != (((struct ObjectNode *)((((NODE *)((&((ObjectList))->Head)))->Succ)))->nr)) {
     atCar = 0;
     break;
 }
 if (((xpos < (carxpos - 16))
      || (xpos > (carxpos + 16)))
     && ((ypos < (carypos - 16))
  || (ypos > (carypos + 16)))) {
     atCar = 0;
     break;
 }
    }
    return atCar;
}

canonical_original_code:
unsigned char plLivingsPosAtCar(unsigned int bldId)
{
    struct _Building *bldObj = (Building) dbGetObject(bldId);
    unsigned short xpos; unsigned short ypos; unsigned short carxpos; unsigned short carypos;
    unsigned char i; unsigned char atCar = 1;
    carxpos = bldObj->CarXPos + 8;
    carypos = bldObj->CarYPos + 8;
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (bldId), 500001, BuildObjectList); };
    for (i = 0; i < BurglarsNr; i++) {
 xpos = livGetXPos(Planing_Name[i]);
 ypos = livGetYPos(Planing_Name[i]);
 if (livWhereIs(Planing_Name[i]) != (((struct ObjectNode *)((((struct Node *)((&((ObjectList))->Head)))->Succ)))->nr)) {
     atCar = 0;
     break;
 }
 if (((xpos < (carxpos - 16))
      || (xpos > (carxpos + 16)))
     && ((ypos < (carypos - 16))
  || (ypos > (carypos + 16)))) {
     atCar = 0;
     break;
 }
    }
    return atCar;
}

variable_types:
bldId
unsigned int

variable_types: struct _Building { unsigned int LocationNr; unsigned short PoliceTime; unsigned short GTime; unsigned char Exactlyness; unsigned char GRate; unsigned char Strike; unsigned int Values; enum RouteE { Innenstadt=0, Stadt=1, Landstrasse=2, Autobahn=3 } EscapeRoute; unsigned char EscapeRouteLength; unsigned char RadioGuarding; unsigned char MaxVolume; unsigned char GuardStrength; unsigned short CarXPos; unsigned short CarYPos; unsigned char DiskId; } *

variable_types:
xpos
unsigned short

variable_types:
ypos
unsigned short

variable_types:
carxpos
unsigned short

variable_types:
carypos
unsigned short

variable_types:
atCar
unsigned char

user_defined_types: struct _Building { unsigned int LocationNr; unsigned short PoliceTime; unsigned short GTime; unsigned char Exactlyness; unsigned char GRate; unsigned char Strike; unsigned int Values; enum RouteE EscapeRoute; unsigned char EscapeRouteLength; unsigned char RadioGuarding; unsigned char MaxVolume; unsigned char GuardStrength; unsigned short CarXPos; unsigned short CarYPos; unsigned char DiskId; }


plAllInCar

decompiled_code:
__int64 __fastcall plAllInCar(unsigned int a1)
{
int v1; // eax
unsigned int v2; // er15
int v3; // er14
unsigned int v4; // ebp
int v5; // ebx
unsigned int v6; // er12
__int64 v7; // rax
__int64 v8; // rax
unsigned int v9; // er13
__int64 v11; // rax
unsigned int v12; // er14
unsigned int v13; // eax
__int64 v14; // rax
unsigned int v15; // ebp
unsigned int v16; // eax

v1 = CurrentTimer(plSys);
v2 = CurrentPerson;
v3 = v1;
if ( BurglarsNr )
{
v4 = 0;
v5 = 0;
v6 = 0;
do
{
while ( 1 )
{
v7 = GetNthNode(PersonsList, (unsigned __int8)v5);
SetActivHandler(plSys, *(unsigned int *)(v7 + 32));
if ( (unsigned int)GetMaxTimer(plSys) > v4 )
break;
if ( BurglarsNr <= (unsigned __int8)++v5 )
goto LABEL_6;
}
v6 = (unsigned __int8)v5++;
v4 = GetMaxTimer(plSys);
}
while ( BurglarsNr > (unsigned __int8)v5 );
}
else
{
v6 = 0;
v4 = 0;
}
LABEL_6:
v8 = GetNthNode(PersonsList, v6);
SetActivHandler(plSys, *(unsigned int *)(v8 + 32));
if ( v6 == v2 )
{
v9 = plLivingsPosAtCar(a1);
CurrentPerson = v6;
if ( (_BYTE)v9 )
v9 = 1;
}
else
{
v11 = GetNthNode(PersonsList, v6);
SetActivHandler(plSys, *(unsigned int *)(v11 + 32));
plMessage("PERSON_NOTES", 1LL);
v12 = GetMaxTimer(plSys) - v3;
v13 = GetMaxTimer(plSys);
plSync(1LL, v13, v12, 1LL);
v9 = plLivingsPosAtCar(a1);
CurrentPerson = v2;
if ( (_BYTE)v9 )
v9 = 1;
v14 = GetNthNode(PersonsList, v2);
SetActivHandler(plSys, *(unsigned int *)(v14 + 32));
plMessage("PERSON_NOTES", 1LL);
v15 = v4 - GetMaxTimer(plSys);
v16 = GetMaxTimer(plSys);
plSync(1LL, v16, v15, 0LL);
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
int v1; // eax
unsigned int v2; // er15
int v3; // er14
unsigned int v4; // ebp
int v5; // ebx
unsigned int v6; // er12
__int64 v7; // rax
__int64 v8; // rax
unsigned int v9; // er13
__int64 v11; // rax
unsigned int v12; // er14
unsigned int v13; // eax
__int64 v14; // rax
unsigned int v15; // ebp
unsigned int v16; // eax

v1 = CurrentTimer(plSys);
v2 = CurrentPerson;
v3 = v1;
if ( BurglarsNr )
{
v4 = 0;
v5 = 0;
v6 = 0;
do
{
while ( 1 )
{
v7 = GetNthNode(PersonsList, (unsigned __int8)v5);
SetActivHandler(plSys, *(unsigned int *)(v7 + 32));
if ( (unsigned int)GetMaxTimer(plSys) > v4 )
break;
if ( BurglarsNr <= (unsigned __int8)++v5 )
goto LABEL_6;
}
v6 = (unsigned __int8)v5++;
v4 = GetMaxTimer(plSys);
}
while ( BurglarsNr > (unsigned __int8)v5 );
}
else
{
v6 = 0;
v4 = 0;
}
LABEL_6:
v8 = GetNthNode(PersonsList, v6);
SetActivHandler(plSys, *(unsigned int *)(v8 + 32));
if ( v6 == v2 )
{
v9 = func1(a1);
CurrentPerson = v6;
if ( (_BYTE)v9 )
v9 = 1;
}
else
{
v11 = GetNthNode(PersonsList, v6);
SetActivHandler(plSys, *(unsigned int *)(v11 + 32));
plMessage("PERSON_NOTES", 1LL);
v12 = GetMaxTimer(plSys) - v3;
v13 = GetMaxTimer(plSys);
plSync(1LL, v13, v12, 1LL);
v9 = func1(a1);
CurrentPerson = v2;
if ( (_BYTE)v9 )
v9 = 1;
v14 = GetNthNode(PersonsList, v2);
SetActivHandler(plSys, *(unsigned int *)(v14 + 32));
plMessage("PERSON_NOTES", 1LL);
v15 = v4 - GetMaxTimer(plSys);
v16 = GetMaxTimer(plSys);
plSync(1LL, v16, v15, 0LL);
}
return v9;
}

original_code:
ubyte plAllInCar(U32 bldId)
{
    ubyte maxPerson = 0, i, ret = 1;
    U32 maxTimer = 0L, oldTimer = CurrentTimer(plSys), realCurrentPerson =
 CurrentPerson;
    for (i = 0; i < BurglarsNr; i++) {
 SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, i))->nr));
 if (maxTimer < GetMaxTimer(plSys)) {
     maxTimer = GetMaxTimer(plSys);
     maxPerson = i;
 }
    }
    SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, maxPerson))->nr));
    if (maxPerson != realCurrentPerson) {
 SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, maxPerson))->nr));
 plMessage("PERSON_NOTES", 1);
 plSync((1), GetMaxTimer(plSys),
        GetMaxTimer(plSys) - oldTimer, 1);
    }
    if (!plLivingsPosAtCar(bldId))
 ret = 0;
    CurrentPerson = realCurrentPerson;
    if (maxPerson != realCurrentPerson) {
 SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, CurrentPerson))->nr));
 plMessage("PERSON_NOTES", 1);
 plSync((1), GetMaxTimer(plSys),
        maxTimer - GetMaxTimer(plSys), 0);
    }
    return ret;
}

canonical_original_code:
unsigned char plAllInCar(unsigned int bldId)
{
    unsigned char maxPerson = 0; unsigned char i; unsigned char ret = 1;
    unsigned int maxTimer = 0L; unsigned int oldTimer = CurrentTimer(plSys); unsigned int realCurrentPerson = CurrentPerson;
    for (i = 0; i < BurglarsNr; i++) {
 SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, i))->nr));
 if (maxTimer < GetMaxTimer(plSys)) {
     maxTimer = GetMaxTimer(plSys);
     maxPerson = i;
 }
    }
    SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, maxPerson))->nr));
    if (maxPerson != realCurrentPerson) {
 SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, maxPerson))->nr));
 plMessage("PERSON_NOTES", 1);
 plSync((1), GetMaxTimer(plSys),
        GetMaxTimer(plSys) - oldTimer, 1);
    }
    if (!plLivingsPosAtCar(bldId))
 ret = 0;
    CurrentPerson = realCurrentPerson;
    if (maxPerson != realCurrentPerson) {
 SetActivHandler(plSys, (((struct ObjectNode *)GetNthNode(PersonsList, CurrentPerson))->nr));
 plMessage("PERSON_NOTES", 1);
 plSync((1), GetMaxTimer(plSys),
        maxTimer - GetMaxTimer(plSys), 0);
    }
    return ret;
}

variable_types:
maxPerson
unsigned char

variable_types:
ret
unsigned char

variable_types:
maxTimer
unsigned int

variable_types:
oldTimer
unsigned int

variable_types:
realCurrentPerson
unsigned int


plIsStair

decompiled_code:
bool __fastcall plIsStair(__int64 a1)
{
return *(_DWORD *)(dbGetObject(a1) + 20) == 9238;
}

canonical_decompiled_code:
bool __fastcall func3(__int64 a1)
{
return *(_DWORD *)(dbGetObject(a1) + 20) == 9238;
}

original_code:
ubyte plIsStair(U32 objId)
{
    return (ubyte) ((((LSObject) dbGetObject(objId))->Type == 9238U));
}

canonical_original_code:
unsigned char plIsStair(unsigned int objId)
{
    return (ubyte) ((((struct _LSObject *) dbGetObject(objId))->Type == 9238U));
}

variable_types:
objId
unsigned int


plCorrectOpened

decompiled_code:
unsigned __int64 __fastcall plCorrectOpened(__int64 a1, char a2)
{
unsigned __int64 result; // rax
__int64 v3; // rdx

result = (unsigned int)(*(_DWORD *)(a1 + 20) - 9201);
if ( (unsigned int)result <= 0x31 )
{
v3 = 0x2000000000043LL;
if ( _bittest64(&v3, result) )
{
if ( a2 )
lsTurnObject(a1, 0LL, 0LL);
else
lsTurnObject(a1, 1LL, 1LL);
result = livRefreshAll();
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(__int64 a1, char a2)
{
unsigned __int64 result; // rax
__int64 v3; // rdx

result = (unsigned int)(*(_DWORD *)(a1 + 20) - 9201);
if ( (unsigned int)result <= 0x31 )
{
v3 = 0x2000000000043LL;
if ( _bittest64(&v3, result) )
{
if ( a2 )
lsTurnObject(a1, 0LL, 0LL);
else
lsTurnObject(a1, 1LL, 1LL);
result = livRefreshAll();
}
}
return result;
}

original_code:
void plCorrectOpened(LSObject obj, ubyte open)
{
    switch (obj->Type) {
    case 9201U:
    case 9202U:
    case 9207U:
    case 9250U:
 if (open)
     lsTurnObject(obj, ((ubyte) 0), 0);
 else
     lsTurnObject(obj, ((ubyte) 1), 1);
 livRefreshAll();
 break;
    }
}

canonical_original_code:
void plCorrectOpened(struct _LSObject *obj, unsigned char open)
{
    switch (obj->Type) {
    case 9201U:
    case 9202U:
    case 9207U:
    case 9250U:
 if (open)
     lsTurnObject(obj, ((unsigned char) 0), 0);
 else
     lsTurnObject(obj, ((unsigned char) 1), 1);
 livRefreshAll();
 break;
    }
}

variable_types: struct _LSObject { unsigned short us_OffsetFact; unsigned short us_DestX; unsigned short us_DestY; unsigned char uch_ExactX; unsigned char uch_ExactY; unsigned char uch_ExactX1; unsigned char uch_ExactY1; unsigned char uch_Size; unsigned char uch_Visible; unsigned char uch_Chained; unsigned int ul_Status; unsigned int Type; } *

variable_types:
open
unsigned char


plIgnoreLock

decompiled_code:
__int64 __fastcall plIgnoreLock(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // er8
__int64 v3; // rax

v1 = dbGetObject(a1);
v2 = 0;
v3 = (unsigned int)(*(_DWORD *)(v1 + 20) - 9210);
if ( (unsigned int)v3 <= 3 )
v2 = (unsigned __int8)CSWTCH_44[v3];
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // er8
__int64 v3; // rax

v1 = dbGetObject(a1);
v2 = 0;
v3 = (unsigned int)(*(_DWORD *)(v1 + 20) - 9210);
if ( (unsigned int)v3 <= 3 )
v2 = (unsigned __int8)CSWTCH_44[v3];
return v2;
}

original_code:
ubyte plIgnoreLock(U32 objId)
{
    ubyte back = 0;
    switch (((LSObject) dbGetObject(objId))->Type) {
    case 9210U:
 back = 3;
 break;
    case 9211U:
 back = 8;
 break;
    case 9212U:
 back = 15;
 break;
    case 9213U:
 back = 1;
 break;
    }
    return back;
}

canonical_original_code:
unsigned char plIgnoreLock(unsigned int objId)
{
    unsigned char back = 0;
    switch (((struct _LSObject *) dbGetObject(objId))->Type) {
    case 9210U:
 back = 3;
 break;
    case 9211U:
 back = 8;
 break;
    case 9212U:
 back = 15;
 break;
    case 9213U:
 back = 1;
 break;
    }
    return back;
}

variable_types:
back
unsigned char


plMove

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

if ( a2 == 4 )
return livAnimate((char *)&Planing_Name + 20 * a1, 0LL, 0LL, 4294967294LL);
if ( a2 > 4u )
{
if ( a2 == 8 )
result = livAnimate((char *)&Planing_Name + 20 * a1, 1LL, 0LL, 2LL);
}
else if ( a2 == 1 )
{
result = livAnimate((char *)&Planing_Name + 20 * a1, 3LL, 4294967294LL, 0LL);
}
else if ( a2 == 2 )
{
result = livAnimate((char *)&Planing_Name + 20 * a1, 2LL, 2LL, 0LL);
}
return result;
}

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

if ( a2 == 4 )
return livAnimate((char *)&Planing_Name + 20 * a1, 0LL, 0LL, 4294967294LL);
if ( a2 > 4u )
{
if ( a2 == 8 )
result = livAnimate((char *)&Planing_Name + 20 * a1, 1LL, 0LL, 2LL);
}
else if ( a2 == 1 )
{
result = livAnimate((char *)&Planing_Name + 20 * a1, 3LL, 4294967294LL, 0LL);
}
else if ( a2 == 2 )
{
result = livAnimate((char *)&Planing_Name + 20 * a1, 2LL, 2LL, 0LL);
}
return result;
}

original_code:
void plMove(U32 current, ubyte direction)
{
    switch (direction) {
    case 1:
 livAnimate(Planing_Name[current], ((ubyte)3),
     -1 * 2, 0);
 break;
    case 2:
 livAnimate(Planing_Name[current], ((ubyte)2),
     1 * 2, 0);
 break;
    case 4:
 livAnimate(Planing_Name[current], ((ubyte)0), 0,
     -1 * 2);
 break;
    case 8:
 livAnimate(Planing_Name[current], ((ubyte)1), 0,
     1 * 2);
 break;
    }
}

canonical_original_code:
void plMove(unsigned int current, unsigned char direction)
{
    switch (direction) {
    case 1:
 livAnimate(Planing_Name[current], ((unsigned char)3),
     -1 * 2, 0);
 break;
    case 2:
 livAnimate(Planing_Name[current], ((unsigned char)2),
     1 * 2, 0);
 break;
    case 4:
 livAnimate(Planing_Name[current], ((unsigned char)0), 0,
     -1 * 2);
 break;
    case 8:
 livAnimate(Planing_Name[current], ((unsigned char)1), 0,
     1 * 2);
 break;
    }
}

variable_types:
current
unsigned int

variable_types:
direction
unsigned char


plWork

decompiled_code:
__int64 __fastcall plWork(unsigned int a1)
{
char *v1; // rbp
__int64 result; // rax

v1 = (char *)&Planing_Name + 20 * a1;
result = livGetViewDirection(v1);
if ( (_BYTE)result == 2 )
return livAnimate(v1, 7LL, 0LL, 0LL);
if ( (unsigned __int8)result > 2u )
{
if ( (_BYTE)result == 3 )
result = livAnimate(v1, 6LL, 0LL, 0LL);
}
else if ( (_BYTE)result )
{
result = livAnimate(v1, 5LL, 0LL, 0LL);
}
else
{
result = livAnimate(v1, 4LL, 0LL, 0LL);
}
return result;
}

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

v1 = (char *)&Planing_Name + 20 * a1;
result = livGetViewDirection(v1);
if ( (_BYTE)result == 2 )
return livAnimate(v1, 7LL, 0LL, 0LL);
if ( (unsigned __int8)result > 2u )
{
if ( (_BYTE)result == 3 )
result = livAnimate(v1, 6LL, 0LL, 0LL);
}
else if ( (_BYTE)result )
{
result = livAnimate(v1, 5LL, 0LL, 0LL);
}
else
{
result = livAnimate(v1, 4LL, 0LL, 0LL);
}
return result;
}

original_code:
void plWork(U32 current)
{
    switch (livGetViewDirection(Planing_Name[current])) {
    case ((ubyte)3):
 livAnimate(Planing_Name[current], ((ubyte)6), 0, 0);
 break;
    case ((ubyte)2):
 livAnimate(Planing_Name[current], ((ubyte)7), 0, 0);
 break;
    case ((ubyte)0):
 livAnimate(Planing_Name[current], ((ubyte)4), 0, 0);
 break;
    case ((ubyte)1):
 livAnimate(Planing_Name[current], ((ubyte)5), 0, 0);
 break;
    }
}

canonical_original_code:
void plWork(unsigned int current)
{
    switch (livGetViewDirection(Planing_Name[current])) {
    case ((unsigned char)3):
 livAnimate(Planing_Name[current], ((unsigned char)6), 0, 0);
 break;
    case ((unsigned char)2):
 livAnimate(Planing_Name[current], ((unsigned char)7), 0, 0);
 break;
    case ((unsigned char)0):
 livAnimate(Planing_Name[current], ((unsigned char)4), 0, 0);
 break;
    case ((unsigned char)1):
 livAnimate(Planing_Name[current], ((unsigned char)5), 0, 0);
 break;
    }
}


plGetObjectsList

decompiled_code:
__int64 __fastcall plGetObjectsList(unsigned int a1, unsigned __int8 a2)
{
char *v2; // rbp
unsigned int v4; // er12
unsigned int v5; // er13
unsigned __int8 v6; // al
__int16 v7; // r12
__int16 v8; // ax
unsigned __int16 v9; // r8
__int64 v10; // r12
__int64 v12; // rsi
unsigned __int16 v13; // dx
__int16 v14; // r12

v2 = (char *)&Planing_Name + 20 * a1;
v4 = livWhereIs(v2);
v5 = lsGetCurrObjectRetrieval();
lsSetObjectRetrievalList(v4);
v6 = livGetViewDirection(v2);
if ( v6 == 2 )
{
v12 = (unsigned __int16)(livGetYPos(v2) + 2);
v13 = livGetXPos(v2) + 9;
goto LABEL_9;
}
if ( v6 > 2u )
{
v10 = 0LL;
if ( v6 != 3 )
goto LABEL_6;
v12 = (unsigned __int16)(livGetYPos(v2) + 2);
v13 = livGetXPos(v2) - 9;
LABEL_9:
v10 = lsGetObjectsByList(v13, v12, 14LL, 12LL, 1LL, a2);
goto LABEL_6;
}
if ( v6 )
{
v7 = livGetYPos(v2);
v8 = livGetXPos(v2);
v9 = v7 + 9;
}
else
{
v14 = livGetYPos(v2);
v8 = livGetXPos(v2);
v9 = v14 - 9;
}
v10 = lsGetObjectsByList((unsigned __int16)(v8 + 2), v9, 12LL, 14LL, 1LL, a2);
LABEL_6:
lsSetObjectRetrievalList(v5);
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, unsigned __int8 a2)
{
char *v2; // rbp
unsigned int v4; // er12
unsigned int v5; // er13
unsigned __int8 v6; // al
__int16 v7; // r12
__int16 v8; // ax
unsigned __int16 v9; // r8
__int64 v10; // r12
__int64 v12; // rsi
unsigned __int16 v13; // dx
__int16 v14; // r12

v2 = (char *)&Planing_Name + 20 * a1;
v4 = livWhereIs(v2);
v5 = lsGetCurrObjectRetrieval();
lsSetObjectRetrievalList(v4);
v6 = livGetViewDirection(v2);
if ( v6 == 2 )
{
v12 = (unsigned __int16)(livGetYPos(v2) + 2);
v13 = livGetXPos(v2) + 9;
goto LABEL_9;
}
if ( v6 > 2u )
{
v10 = 0LL;
if ( v6 != 3 )
goto LABEL_6;
v12 = (unsigned __int16)(livGetYPos(v2) + 2);
v13 = livGetXPos(v2) - 9;
LABEL_9:
v10 = lsGetObjectsByList(v13, v12, 14LL, 12LL, 1LL, a2);
goto LABEL_6;
}
if ( v6 )
{
v7 = livGetYPos(v2);
v8 = livGetXPos(v2);
v9 = v7 + 9;
}
else
{
v14 = livGetYPos(v2);
v8 = livGetXPos(v2);
v9 = v14 - 9;
}
v10 = lsGetObjectsByList((unsigned __int16)(v8 + 2), v9, 12LL, 14LL, 1LL, a2);
LABEL_6:
lsSetObjectRetrievalList(v5);
return v10;
}

original_code:
LIST *plGetObjectsList(U32 current, ubyte addLootBags)
{
    LIST *list = ((void *)0);
    U32 areaId = livWhereIs(Planing_Name[current]), oldAreaId;
    oldAreaId = lsGetCurrObjectRetrieval();
    lsSetObjectRetrievalList(areaId);
    switch (livGetViewDirection(Planing_Name[current])) {
    case ((ubyte)3):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) - 9,
      livGetYPos(Planing_Name[current]) + 2,
      14, 12, 1, addLootBags);
 break;
    case ((ubyte)2):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) + 9,
      livGetYPos(Planing_Name[current]) + 2,
      14, 12, 1, addLootBags);
 break;
    case ((ubyte)0):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) + 2,
      livGetYPos(Planing_Name[current]) - 9,
      12, 14, 1, addLootBags);
 break;
    case ((ubyte)1):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) + 2,
      livGetYPos(Planing_Name[current]) + 9,
      12, 14, 1, addLootBags);
 break;
    }
    lsSetObjectRetrievalList(oldAreaId);
    return list;
}

canonical_original_code:
struct List *plGetObjectsList(unsigned int current, unsigned char addLootBags)
{
    struct List *list = ((void *)0);
    unsigned int areaId = livWhereIs(Planing_Name[current]); unsigned int oldAreaId;
    oldAreaId = lsGetCurrObjectRetrieval();
    lsSetObjectRetrievalList(areaId);
    switch (livGetViewDirection(Planing_Name[current])) {
    case ((unsigned char)3):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) - 9,
      livGetYPos(Planing_Name[current]) + 2,
      14, 12, 1, addLootBags);
 break;
    case ((unsigned char)2):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) + 9,
      livGetYPos(Planing_Name[current]) + 2,
      14, 12, 1, addLootBags);
 break;
    case ((unsigned char)0):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) + 2,
      livGetYPos(Planing_Name[current]) - 9,
      12, 14, 1, addLootBags);
 break;
    case ((unsigned char)1):
 list = lsGetObjectsByList(livGetXPos(Planing_Name[current]) + 2,
      livGetYPos(Planing_Name[current]) + 9,
      12, 14, 1, addLootBags);
 break;
    }
    lsSetObjectRetrievalList(oldAreaId);
    return list;
}

variable_types:
addLootBags
unsigned char

variable_types: struct List { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Head; struct Node Tail; } *

variable_types:
areaId
unsigned int

variable_types:
oldAreaId
unsigned int


plInsertGuard

decompiled_code:
__int64 __fastcall plInsertGuard(__int64 a1, unsigned int a2, unsigned int a3)
{
char *v3; // r12
__int64 result; // rax
__int64 v6; // r15
__int64 v7; // r14
__int64 v8; // r13
unsigned __int16 v9; // ax
unsigned __int16 v10; // r10
__int64 v11; // r15
__int64 v12; // r13
__int64 v13; // r14
__int16 v14; // ax
__int64 v15; // rcx
unsigned __int16 v16; // dx
__int16 v17; // ax
__int16 v18; // [rsp+Eh] [rbp-3Ah]
unsigned __int16 v19; // [rsp+Eh] [rbp-3Ah]
__int16 v20; // [rsp+Eh] [rbp-3Ah]
unsigned __int16 v21; // [rsp+Eh] [rbp-3Ah]

v3 = (char *)&Planing_Name + 20 * a2;
result = livGetViewDirection(v3);
if ( (_BYTE)result == 2 )
{
v11 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v12 = (unsigned __int8)(a3 - BurglarsNr + 5);
v13 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v21 = livGetYPos(v3);
v17 = livGetXPos(v3);
v15 = v21;
v16 = v17 + 9;
return tcInsertGuard(a1, *((_QWORD *)&Planing_GuardRoomList + a3 - BurglarsNr), v16, v15, 14LL, 14LL, v13, v12, v11);
}
if ( (unsigned __int8)result > 2u )
{
if ( (_BYTE)result != 3 )
return result;
v11 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v12 = (unsigned __int8)(a3 - BurglarsNr + 5);
v13 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v19 = livGetYPos(v3);
v14 = livGetXPos(v3);
v15 = v19;
v16 = v14 - 9;
return tcInsertGuard(a1, *((_QWORD *)&Planing_GuardRoomList + a3 - BurglarsNr), v16, v15, 14LL, 14LL, v13, v12, v11);
}
if ( (_BYTE)result )
{
v6 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v7 = (unsigned __int8)(a3 - BurglarsNr + 5);
v8 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v18 = livGetYPos(v3);
v9 = livGetXPos(v3);
v10 = v18 + 9;
}
else
{
v6 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v7 = (unsigned __int8)(a3 - BurglarsNr + 5);
v8 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v20 = livGetYPos(v3);
v9 = livGetXPos(v3);
v10 = v20 - 9;
}
return tcInsertGuard(a1, *((_QWORD *)&Planing_GuardRoomList + a3 - BurglarsNr), v9, v10, 14LL, 14LL, v8, v7, v6);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, unsigned int a2, unsigned int a3)
{
char *v3; // r12
__int64 result; // rax
__int64 v6; // r15
__int64 v7; // r14
__int64 v8; // r13
unsigned __int16 v9; // ax
unsigned __int16 v10; // r10
__int64 v11; // r15
__int64 v12; // r13
__int64 v13; // r14
__int16 v14; // ax
__int64 v15; // rcx
unsigned __int16 v16; // dx
__int16 v17; // ax
__int16 v18; // [rsp+Eh] [rbp-3Ah]
unsigned __int16 v19; // [rsp+Eh] [rbp-3Ah]
__int16 v20; // [rsp+Eh] [rbp-3Ah]
unsigned __int16 v21; // [rsp+Eh] [rbp-3Ah]

v3 = (char *)&Planing_Name + 20 * a2;
result = livGetViewDirection(v3);
if ( (_BYTE)result == 2 )
{
v11 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v12 = (unsigned __int8)(a3 - BurglarsNr + 5);
v13 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v21 = livGetYPos(v3);
v17 = livGetXPos(v3);
v15 = v21;
v16 = v17 + 9;
return tcInsertGuard(a1, *((_QWORD *)&Planing_GuardRoomList + a3 - BurglarsNr), v16, v15, 14LL, 14LL, v13, v12, v11);
}
if ( (unsigned __int8)result > 2u )
{
if ( (_BYTE)result != 3 )
return result;
v11 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v12 = (unsigned __int8)(a3 - BurglarsNr + 5);
v13 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v19 = livGetYPos(v3);
v14 = livGetXPos(v3);
v15 = v19;
v16 = v14 - 9;
return tcInsertGuard(a1, *((_QWORD *)&Planing_GuardRoomList + a3 - BurglarsNr), v16, v15, 14LL, 14LL, v13, v12, v11);
}
if ( (_BYTE)result )
{
v6 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v7 = (unsigned __int8)(a3 - BurglarsNr + 5);
v8 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v18 = livGetYPos(v3);
v9 = livGetXPos(v3);
v10 = v18 + 9;
}
else
{
v6 = (unsigned int)livWhereIs((char *)&Planing_Name + 20 * a2);
v7 = (unsigned __int8)(a3 - BurglarsNr + 5);
v8 = *(unsigned int *)(GetNthNode(PersonsList, a3) + 32);
v20 = livGetYPos(v3);
v9 = livGetXPos(v3);
v10 = v20 - 9;
}
return tcInsertGuard(a1, *((_QWORD *)&Planing_GuardRoomList + a3 - BurglarsNr), v9, v10, 14LL, 14LL, v8, v7, v6);
}

original_code:
void plInsertGuard(LIST * list, U32 current, U32 guard)
{
    switch (livGetViewDirection(Planing_Name[current])) {
    case ((ubyte)3):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]) - 9,
        livGetYPos(Planing_Name[current]),
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    case ((ubyte)2):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]) + 9,
        livGetYPos(Planing_Name[current]),
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    case ((ubyte)0):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]),
        livGetYPos(Planing_Name[current]) - 9,
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    case ((ubyte)1):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]),
        livGetYPos(Planing_Name[current]) + 9,
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    }
}

canonical_original_code:
void plInsertGuard(struct List *list, unsigned int current, unsigned int guard)
{
    switch (livGetViewDirection(Planing_Name[current])) {
    case ((unsigned char)3):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]) - 9,
        livGetYPos(Planing_Name[current]),
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    case ((unsigned char)2):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]) + 9,
        livGetYPos(Planing_Name[current]),
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    case ((unsigned char)0):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]),
        livGetYPos(Planing_Name[current]) - 9,
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    case ((unsigned char)1):
 tcInsertGuard(list, Planing_GuardRoomList[guard - BurglarsNr],
        livGetXPos(Planing_Name[current]),
        livGetYPos(Planing_Name[current]) + 9,
        14, 14,
        (((struct ObjectNode *)GetNthNode(PersonsList, guard))->nr),
        guard + 1 + (4 - BurglarsNr),
        livWhereIs(Planing_Name[current]));
 break;
    }
}

variable_types:
guard
unsigned int