plObjectInReach

decompiled_code:
__int64 __fastcall plObjectInReach(unsigned int a1, unsigned int a2)
{
__int64 v2; // rax
int v3; // ebx
_QWORD **v4; // rbp
unsigned int v5; // edx
unsigned int v6; // er12

v2 = plGetObjectsList(a1, 1u);
v3 = BurglarsNr;
v4 = (_QWORD **)v2;
if ( BurglarsNr < PersonsNr )
{
do
{
v5 = (unsigned __int8)v3++;
plInsertGuard((__int64)v4, a1, v5);
}
while ( PersonsNr > (unsigned __int8)v3 );
}
v6 = 0;
if ( **v4 )
LOBYTE(v6) = dbHasObjectNode(v4, a2) != 0;
RemoveList(v4);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, unsigned int a2)
{
__int64 v2; // rax
int v3; // ebx
_QWORD **v4; // rbp
unsigned int v5; // edx
unsigned int v6; // er12

v2 = func8(a1, 1u);
v3 = BurglarsNr;
v4 = (_QWORD **)v2;
if ( BurglarsNr < PersonsNr )
{
do
{
v5 = (unsigned __int8)v3++;
func9((__int64)v4, a1, v5);
}
while ( PersonsNr > (unsigned __int8)v3 );
}
v6 = 0;
if ( **v4 )
LOBYTE(v6) = dbHasObjectNode(v4, a2) != 0;
RemoveList(v4);
return v6;
}

original_code:
ubyte plObjectInReach(U32 current, U32 objId)
{
    LIST *actionList = plGetObjectsList(current, 1);
    ubyte i, ret = 0;
    for (i = BurglarsNr; i < PersonsNr; i++)
 plInsertGuard(actionList, current, i);
    if (!(!(((NODE *)(((((NODE *)((&(((actionList)))->Head)))->Succ))))->Succ))) {
 if (dbHasObjectNode(actionList, objId))
     ret = 1;
    }
    RemoveList(actionList);
    return ret;
}

canonical_original_code:
unsigned char plObjectInReach(unsigned int current, unsigned int objId)
{
    struct List *actionList = plGetObjectsList(current, 1);
    unsigned char i; unsigned char ret = 0;
    for (i = BurglarsNr; i < PersonsNr; i++)
 plInsertGuard(actionList, current, i);
    if (!(!(((struct Node *)(((((struct Node *)((&(((actionList)))->Head)))->Succ))))->Succ))) {
 if (dbHasObjectNode(actionList, objId))
     ret = 1;
    }
    RemoveList(actionList);
    return ret;
}

variable_types:
i
unsigned char


tcDisplayInfoAboutPerson

repo: vcosta/derclou

decompiled_code:
__int64 __fastcall tcDisplayInfoAboutPerson(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 v4; // rbp
_BYTE v5[280]; // [rsp+0h] [rbp-118h] BYREF

v1 = ((__int64 (*)(void))dbGetObject)();
v2 = dbGetObject(9801LL);
if ( (unsigned int)AskP(v2, 4LL, v1, 0xFFFFFFFFLL, 0LL) )
return Present(a1, "Person", &InitPersonPresent);
dbGetObjectName(a1, v5);
v4 = txtGoKey(13LL, v5);
SetBubbleType(13LL);
Bubble(v4, 0LL, 0LL, 0LL);
RemoveList(v4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 v4; // rbp
_BYTE v5[280]; // [rsp+0h] [rbp-118h] BYREF

v1 = ((__int64 (*)(void))dbGetObject)();
v2 = dbGetObject(9801LL);
if ( (unsigned int)AskP(v2, 4LL, v1, 0xFFFFFFFFLL, 0LL) )
return Present(a1, "Person", &InitPersonPresent);
dbGetObjectName(a1, v5);
v4 = txtGoKey(13LL, v5);
SetBubbleType(13LL);
Bubble(v4, 0LL, 0LL, 0LL);
RemoveList(v4);
return 0LL;
}

original_code:
static ubyte tcDisplayInfoAboutPerson(U32 objID)
{
    LIST *bubble;
    char name[256];
    ubyte ret = 0;
    if (AskP (dbGetObject (9801U), 4, dbGetObject (objID), (4294967295U), ((U8)0)))
 ret = Present(objID, "Person", InitPersonPresent);
    else {
 dbGetObjectName(objID, name);
 bubble = txtGoKey(13U, name);
 SetBubbleType(13);
 Bubble(bubble, 0, 0L, 0L);
 RemoveList(bubble);
    }
    return ret;
}

canonical_original_code:
static unsigned char tcDisplayInfoAboutPerson(unsigned int objID)
{
    struct List *bubble;
    char name[256];
    unsigned char ret = 0;
    if (AskP (dbGetObject (9801U), 4, dbGetObject (objID), (4294967295U), ((unsigned char)0)))
 ret = Present(objID, "Person", InitPersonPresent);
    else {
 dbGetObjectName(objID, name);
 bubble = txtGoKey(13U, name);
 SetBubbleType(13);
 Bubble(bubble, 0, 0L, 0L);
 RemoveList(bubble);
    }
    return ret;
}

variable_types:
objID
unsigned int

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

variable_types:
name
char [256]

variable_types:
ret
unsigned char

return_type: unsigned char

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


AddTaxiLocation

decompiled_code:
__int64 AddTaxiLocation()
{
__int64 result; // rax
__int64 v1; // r12
__int64 v2; // rax

result = GetObjNrOfLocation();
if ( (_DWORD)result )
{
v1 = dbGetObject((unsigned int)result);
v2 = dbGetObject(9801LL);
result = SetP(v2, 16LL, v1, 0xFFFFFFFFLL);
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
__int64 v1; // r12
__int64 v2; // rax

result = GetObjNrOfLocation();
if ( (_DWORD)result )
{
v1 = dbGetObject((unsigned int)result);
v2 = dbGetObject(9801LL);
result = SetP(v2, 16LL, v1, 0xFFFFFFFFLL);
}
return result;
}

original_code:
void AddTaxiLocation(U32 locNr)
{
    U32 objNr;
    if ((objNr = GetObjNrOfLocation(locNr)))
 SetP (dbGetObject (9801U), 16, dbGetObject (objNr), (4294967295U));
}

canonical_original_code:
void AddTaxiLocation(unsigned int locNr)
{
    unsigned int objNr;
    if ((objNr = GetObjNrOfLocation(locNr)))
 SetP (dbGetObject (9801U), 16, dbGetObject (objNr), (4294967295U));
}

variable_types:
locNr
unsigned int

variable_types:
objNr
unsigned int

return_type: void


RemTaxiLocation

decompiled_code:
__int64 RemTaxiLocation()
{
__int64 result; // rax
__int64 v1; // r12
__int64 v2; // rax

result = GetObjNrOfLocation();
if ( (_DWORD)result )
{
v1 = dbGetObject((unsigned int)result);
v2 = dbGetObject(9801LL);
result = UnSet(v2, 16LL, v1);
}
return result;
}

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

result = GetObjNrOfLocation();
if ( (_DWORD)result )
{
v1 = dbGetObject((unsigned int)result);
v2 = dbGetObject(9801LL);
result = UnSet(v2, 16LL, v1);
}
return result;
}

original_code:
void RemTaxiLocation(U32 locNr)
{
    U32 objNr;
    if ((objNr = GetObjNrOfLocation(locNr)))
 UnSet (dbGetObject (9801U), 16, dbGetObject (objNr));
}

canonical_original_code:
void RemTaxiLocation(unsigned int locNr)
{
    unsigned int objNr;
    if ((objNr = GetObjNrOfLocation(locNr)))
 UnSet (dbGetObject (9801U), 16, dbGetObject (objNr));
}


Go

decompiled_code:
__int64 __fastcall Go(_QWORD **a1)
{
_QWORD *v2; // rbx
char v3; // bp
__int64 v4; // rax
__int64 v5; // rsi
unsigned __int8 v6; // al
__int64 v7; // rax
_QWORD *v8; // rdi
unsigned int v9; // er13
_QWORD *v10; // rdx
_QWORD *v11; // rsi
_BYTE v13[296]; // [rsp+0h] [rbp-128h] BYREF

inpTurnFunctionKey(0LL);
if ( (unsigned int)GetNrOfNodes(a1) <= 1 )
{
v9 = *(_DWORD *)(GetNthNode(a1, 0LL) + 32);
}
else
{
ShowMenuBackground();
txtGetNthString(4LL, "Gehen", 0LL, v13);
PrintStatus(v13);
v2 = *a1;
if ( **a1 )
{
v3 = 0;
do
{
++v3;
v4 = GetScene(*((unsigned int *)v2 + 8));
v2[2] = *(_QWORD *)(GetNthNode(*(_QWORD *)(film + 24LL), *(unsigned int *)(v4 + 56)) + 16);
v2 = (_QWORD *)*v2;
}
while ( *v2 );
v5 = (unsigned int)((1 << v3) - 1);
}
else
{
v5 = 0LL;
}
v6 = Menu(a1, v5, 0LL, 0LL, 0LL);
v7 = GetNthNode(a1, v6);
v8 = *a1;
v9 = *(_DWORD *)(v7 + 32);
v10 = (_QWORD *)**a1;
if ( v10 )
{
while ( 1 )
{
v11 = (_QWORD *)*v10;
v8[2] = 0LL;
v8 = v10;
if ( !v11 )
break;
v10 = v11;
}
}
}
inpTurnFunctionKey(1LL);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD **a1)
{
_QWORD *v2; // rbx
char v3; // bp
__int64 v4; // rax
__int64 v5; // rsi
unsigned __int8 v6; // al
__int64 v7; // rax
_QWORD *v8; // rdi
unsigned int v9; // er13
_QWORD *v10; // rdx
_QWORD *v11; // rsi
_BYTE v13[296]; // [rsp+0h] [rbp-128h] BYREF

inpTurnFunctionKey(0LL);
if ( (unsigned int)GetNrOfNodes(a1) <= 1 )
{
v9 = *(_DWORD *)(GetNthNode(a1, 0LL) + 32);
}
else
{
ShowMenuBackground();
txtGetNthString(4LL, "Gehen", 0LL, v13);
PrintStatus(v13);
v2 = *a1;
if ( **a1 )
{
v3 = 0;
do
{
++v3;
v4 = GetScene(*((unsigned int *)v2 + 8));
v2[2] = *(_QWORD *)(GetNthNode(*(_QWORD *)(film + 24LL), *(unsigned int *)(v4 + 56)) + 16);
v2 = (_QWORD *)*v2;
}
while ( *v2 );
v5 = (unsigned int)((1 << v3) - 1);
}
else
{
v5 = 0LL;
}
v6 = Menu(a1, v5, 0LL, 0LL, 0LL);
v7 = GetNthNode(a1, v6);
v8 = *a1;
v9 = *(_DWORD *)(v7 + 32);
v10 = (_QWORD *)**a1;
if ( v10 )
{
while ( 1 )
{
v11 = (_QWORD *)*v10;
v8[2] = 0LL;
v8 = v10;
if ( !v11 )
break;
v10 = v11;
}
}
}
inpTurnFunctionKey(1LL);
return v9;
}

original_code:
U32 Go(LIST * succ)
{
    struct TCEventNode *node;
    struct Scene *sc;
    U32 prob, succ_eventnr;
    NODE *location;
    char line[255];
    inpTurnFunctionKey(0);
    if (GetNrOfNodes(succ) > 1) {
 prob = 0L;
 ShowMenuBackground();
 (txtGetNthString(4U, "Gehen", 0, line));
 PrintStatus(line);
 for (node = (struct TCEventNode *) ((((NODE *)((&((succ))->Head)))->Succ)); (((NODE *)(node))->Succ);
      node = (struct TCEventNode *) (((NODE *)(node))->Succ)) {
     sc = GetScene(node->EventNr);
     location = GetNthNode(film->loc_names, (U32) sc->LocationNr);
     (((NODE *)(node))->Name) = (((NODE *)(location))->Name);
     prob++;
 }
 prob = (1 << prob) - 1;
 prob = Menu(succ, prob, 0, ((void *)0), 0L);
 succ_eventnr =
     ((struct TCEventNode *) GetNthNode(succ, (U32) prob))->EventNr;
 for (node = (struct TCEventNode *) ((((NODE *)((&((succ))->Head)))->Succ)); (((NODE *)(node))->Succ);
      node = (struct TCEventNode *) (((NODE *)(node))->Succ))
     (((NODE *)(node))->Name) = ((void *)0);
    } else {
 succ_eventnr = (U32) ((struct TCEventNode *)
         GetNthNode(succ, 0L))->EventNr;
    }
    inpTurnFunctionKey(1);
    return (succ_eventnr);
}

canonical_original_code:
unsigned int Go(struct List *succ)
{
    struct TCEventNode *node;
    struct Scene *sc;
    unsigned int prob; unsigned int succ_eventnr;
    struct Node *location;
    char line[255];
    inpTurnFunctionKey(0);
    if (GetNrOfNodes(succ) > 1) {
 prob = 0L;
 ShowMenuBackground();
 (txtGetNthString(4U, "Gehen", 0, line));
 PrintStatus(line);
 for (node = (struct TCEventNode *) ((((struct Node *)((&((succ))->Head)))->Succ)); (((struct Node *)(node))->Succ);
      node = (struct TCEventNode *) (((struct Node *)(node))->Succ)) {
     sc = GetScene(node->EventNr);
     location = GetNthNode(film->loc_names, (unsigned int) sc->LocationNr);
     (((struct Node *)(node))->Name) = (((struct Node *)(location))->Name);
     prob++;
 }
 prob = (1 << prob) - 1;
 prob = Menu(succ, prob, 0, ((void *)0), 0L);
 succ_eventnr =
     ((struct TCEventNode *) GetNthNode(succ, (unsigned int) prob))->EventNr;
 for (node = (struct TCEventNode *) ((((struct Node *)((&((succ))->Head)))->Succ)); (((struct Node *)(node))->Succ);
      node = (struct TCEventNode *) (((struct Node *)(node))->Succ))
     (((struct Node *)(node))->Name) = ((void *)0);
    } else {
 succ_eventnr = (U32) ((struct TCEventNode *)
         GetNthNode(succ, 0L))->EventNr;
    }
    inpTurnFunctionKey(1);
    return (succ_eventnr);
}

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

variable_types: struct Scene { unsigned int EventNr; void (*Init)(); void (*Done)(); struct Bedingungen { unsigned int Ort; struct List { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Head; struct Node Tail; } *events; struct List *n_events; } *bed; struct List *std_succ; unsigned int Moeglichkeiten; unsigned int Dauer; unsigned short Anzahl; unsigned short Geschehen; unsigned char Probability; unsigned int LocationNr; } *

variable_types:
prob
unsigned int

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

variable_types:
line
char [255]

return_type: unsigned int

user_defined_types: struct TCEventNode { struct Node Node; unsigned int EventNr; }

user_defined_types: struct Scene { unsigned int EventNr; void (*Init)(); void (*Done)(); struct Bedingungen *bed; struct List *std_succ; unsigned int Moeglichkeiten; unsigned int Dauer; unsigned short Anzahl; unsigned short Geschehen; unsigned char Probability; unsigned int LocationNr; }

user_defined_types: struct Bedingungen { unsigned int Ort; struct List *events; struct List *n_events; }


Information

decompiled_code:
__int64 Information()
{
char v0; // bp
unsigned __int8 v1; // bl
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r12
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // r12
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // r12
__int64 v14; // rax
unsigned int v15; // eax
__int64 v16; // r12
__int64 v17; // rax
_BYTE v18[296]; // [rsp+0h] [rbp-128h] BYREF

v0 = 0;
v1 = 0;
result = inpTurnESC(1LL);
LABEL_2:
while ( v1 != 6 && v0 != -1 )
{
SetBubbleType(13LL);
v3 = txtGoKey(4LL, "INFORMATION");
v1 = Bubble(v3, v1, 0LL, 0LL);
RemoveList(v3);
switch ( v1 )
{
case 0u:
v15 = getKey(1LL);
result = Present(v15, "Player", &InitPlayerPresent);
if ( (_BYTE)result != 0xFF )
result = Present(9801LL, "Person", &InitPersonPresent);
goto LABEL_2;
case 1u:
SetObjectListAttr(7LL, 9902LL);
v12 = dbGetObject(9801LL);
AskAll(v12, 4LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
goto LABEL_6;
txtGetNthString(2LL, "GENUG", 0LL, v18);
LODWORD(v13) = 0;
ExpandObjectList(v5, v18);
SetBubbleType(13LL);
while ( 1 )
{
v13 = (unsigned __int8)Bubble(v5, (unsigned int)v13, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v13, 255LL, v5) )
break;
SetBubbleType(13LL);
v14 = GetNthNode(v5, (unsigned int)v13);
v0 = Present(*(unsigned int *)(v14 + 32), "Car", &InitCarPresent);
}
goto LABEL_7;
case 2u:
SetObjectListAttr(7LL, 9900LL);
v9 = dbGetObject(9801LL);
AskAll(v9, 5LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
goto LABEL_6;
txtGetNthString(2LL, "GENUG", 0LL, v18);
LODWORD(v10) = 0;
ExpandObjectList(v5, v18);
SetBubbleType(13LL);
while ( 1 )
{
v10 = (unsigned __int8)Bubble(v5, (unsigned int)v10, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v10, 255LL, v5) )
break;
SetBubbleType(13LL);
v11 = GetNthNode(v5, (unsigned int)v10);
v0 = tcDisplayInfoAboutPerson(*(_DWORD *)(v11 + 32));
}
goto LABEL_7;
case 3u:
SetObjectListAttr(7LL, 9906LL);
v6 = dbGetObject(9801LL);
AskAll(v6, 4LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
goto LABEL_6;
LODWORD(v7) = 0;
SetBubbleType(13LL);
txtGetNthString(2LL, "GENUG", 0LL, v18);
ExpandObjectList(v5, v18);
while ( 1 )
{
v7 = (unsigned __int8)Bubble(v5, (unsigned int)v7, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v7, 255LL, v5) )
break;
SetBubbleType(13LL);
v8 = GetNthNode(v5, (unsigned int)v7);
v0 = Present(*(unsigned int *)(v8 + 32), "Tool", &InitToolPresent);
}
goto LABEL_7;
case 4u:
SetObjectListAttr(7LL, 509990LL);
v4 = dbGetObject(9801LL);
AskAll(v4, 4LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( *(_QWORD *)*ObjectListPrivate )
{
LODWORD(v16) = 0;
SetBubbleType(13LL);
txtGetNthString(2LL, "GENUG", 0LL, v18);
ExpandObjectList(v5, v18);
while ( 1 )
{
v16 = (unsigned __int8)Bubble(v5, (unsigned int)v16, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v16, 255LL, v5) )
break;
SetBubbleType(13LL);
v17 = GetNthNode(v5, (unsigned int)v16);
v0 = Present(*(unsigned int *)(v17 + 32), "Building", &InitBuildingPresent);
}
}
else
{
LABEL_6:
Say(2LL, 0LL, 7LL, "POOR");
}
LABEL_7:
result = RemoveList(v5);
break;
case 5u:
result = Present(0LL, "Beute", &InitLootPresent);
break;
default:
JUMPOUT(0xEC5LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
char v0; // bp
unsigned __int8 v1; // bl
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r12
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // r12
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // r12
__int64 v14; // rax
unsigned int v15; // eax
__int64 v16; // r12
__int64 v17; // rax
_BYTE v18[296]; // [rsp+0h] [rbp-128h] BYREF

v0 = 0;
v1 = 0;
result = inpTurnESC(1LL);
LABEL_2:
while ( v1 != 6 && v0 != -1 )
{
SetBubbleType(13LL);
v3 = txtGoKey(4LL, "INFORMATION");
v1 = Bubble(v3, v1, 0LL, 0LL);
RemoveList(v3);
switch ( v1 )
{
case 0u:
v15 = getKey(1LL);
result = Present(v15, "Player", &InitPlayerPresent);
if ( (_BYTE)result != 0xFF )
result = Present(9801LL, "Person", &InitPersonPresent);
goto LABEL_2;
case 1u:
SetObjectListAttr(7LL, 9902LL);
v12 = dbGetObject(9801LL);
AskAll(v12, 4LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
goto LABEL_6;
txtGetNthString(2LL, "GENUG", 0LL, v18);
LODWORD(v13) = 0;
ExpandObjectList(v5, v18);
SetBubbleType(13LL);
while ( 1 )
{
v13 = (unsigned __int8)Bubble(v5, (unsigned int)v13, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v13, 255LL, v5) )
break;
SetBubbleType(13LL);
v14 = GetNthNode(v5, (unsigned int)v13);
v0 = Present(*(unsigned int *)(v14 + 32), "Car", &InitCarPresent);
}
goto LABEL_7;
case 2u:
SetObjectListAttr(7LL, 9900LL);
v9 = dbGetObject(9801LL);
AskAll(v9, 5LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
goto LABEL_6;
txtGetNthString(2LL, "GENUG", 0LL, v18);
LODWORD(v10) = 0;
ExpandObjectList(v5, v18);
SetBubbleType(13LL);
while ( 1 )
{
v10 = (unsigned __int8)Bubble(v5, (unsigned int)v10, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v10, 255LL, v5) )
break;
SetBubbleType(13LL);
v11 = GetNthNode(v5, (unsigned int)v10);
v0 = func0(*(_DWORD *)(v11 + 32));
}
goto LABEL_7;
case 3u:
SetObjectListAttr(7LL, 9906LL);
v6 = dbGetObject(9801LL);
AskAll(v6, 4LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( !*(_QWORD *)*ObjectListPrivate )
goto LABEL_6;
LODWORD(v7) = 0;
SetBubbleType(13LL);
txtGetNthString(2LL, "GENUG", 0LL, v18);
ExpandObjectList(v5, v18);
while ( 1 )
{
v7 = (unsigned __int8)Bubble(v5, (unsigned int)v7, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v7, 255LL, v5) )
break;
SetBubbleType(13LL);
v8 = GetNthNode(v5, (unsigned int)v7);
v0 = Present(*(unsigned int *)(v8 + 32), "Tool", &InitToolPresent);
}
goto LABEL_7;
case 4u:
SetObjectListAttr(7LL, 509990LL);
v4 = dbGetObject(9801LL);
AskAll(v4, 4LL, &BuildObjectList);
v5 = ObjectListPrivate;
if ( *(_QWORD *)*ObjectListPrivate )
{
LODWORD(v16) = 0;
SetBubbleType(13LL);
txtGetNthString(2LL, "GENUG", 0LL, v18);
ExpandObjectList(v5, v18);
while ( 1 )
{
v16 = (unsigned __int8)Bubble(v5, (unsigned int)v16, 0LL, 0LL);
if ( !(unsigned __int8)ChoiceOk(v16, 255LL, v5) )
break;
SetBubbleType(13LL);
v17 = GetNthNode(v5, (unsigned int)v16);
v0 = Present(*(unsigned int *)(v17 + 32), "Building", &InitBuildingPresent);
}
}
else
{
LABEL_6:
Say(2LL, 0LL, 7LL, "POOR");
}
LABEL_7:
result = RemoveList(v5);
break;
case 5u:
result = Present(0LL, "Beute", &InitLootPresent);
break;
default:
JUMPOUT(0xEC5LL);
}
}
return result;
}

original_code:
void Information(void)
{
    LIST *bubble, *list;
    ubyte choice = 0, choice1 = 0, ret = 0;
    char enough[256];
    U32 objID;
    inpTurnESC(1);
    while ((choice != 6) && (ret != ((U8)-1))) {
 SetBubbleType(13);
 bubble = txtGoKey(4U, "INFORMATION");
 choice = Bubble(bubble, choice, 0L, 0L);
 RemoveList(bubble);
 choice1 = 0;
 switch (choice) {
 case 0:
     if ((Present(getKey(_Player_Player_1), "Player", InitPlayerPresent)) !=
  ((U8)-1))
  Present(9801U, "Person", InitPersonPresent);
     break;
 case 1:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9902L); AskAll (dbGetObject (9801U), 4, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((NODE *)(((((NODE *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  SetBubbleType(13);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (U32) choice1))->nr);
      ret = Present(objID, "Car", InitCarPresent);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 2:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9900L); AskAll (dbGetObject (9801U), 5, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((NODE *)(((((NODE *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  SetBubbleType(13);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (U32) choice1))->nr);
      ret = tcDisplayInfoAboutPerson(objID);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 3:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9906L); AskAll (dbGetObject (9801U), 4, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((NODE *)(((((NODE *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  SetBubbleType(13);
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (U32) choice1))->nr);
      ret = Present(objID, "Tool", InitToolPresent);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 4:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),509990L); AskAll (dbGetObject (9801U), 4, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((NODE *)(((((NODE *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  SetBubbleType(13);
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (U32) choice1))->nr);
      ret = Present(objID, "Building", InitBuildingPresent);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 5:
     Present(0, "Beute", InitLootPresent);
     break;
 default:
     choice = 6;
     break;
 }
    }
}

canonical_original_code:
void Information()
{
    struct List *bubble; struct List *list;
    unsigned char choice = 0; unsigned char choice1 = 0; unsigned char ret = 0;
    char enough[256];
    unsigned int objID;
    inpTurnESC(1);
    while ((choice != 6) && (ret != ((U8)-1))) {
 SetBubbleType(13);
 bubble = txtGoKey(4U, "INFORMATION");
 choice = Bubble(bubble, choice, 0L, 0L);
 RemoveList(bubble);
 choice1 = 0;
 switch (choice) {
 case 0:
     if ((Present(getKey(_Player_Player_1), "Player", InitPlayerPresent)) !=
  ((U8)-1))
  Present(9801U, "Person", InitPersonPresent);
     break;
 case 1:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9902L); AskAll (dbGetObject (9801U), 4, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((struct Node *)(((((struct Node *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  SetBubbleType(13);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (unsigned int) choice1))->nr);
      ret = Present(objID, "Car", InitCarPresent);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 2:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9900L); AskAll (dbGetObject (9801U), 5, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((struct Node *)(((((struct Node *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  SetBubbleType(13);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (unsigned int) choice1))->nr);
      ret = tcDisplayInfoAboutPerson(objID);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 3:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9906L); AskAll (dbGetObject (9801U), 4, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((struct Node *)(((((struct Node *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  SetBubbleType(13);
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (unsigned int) choice1))->nr);
      ret = Present(objID, "Tool", InitToolPresent);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 4:
     { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),509990L); AskAll (dbGetObject (9801U), 4, BuildObjectList); };
     list = ObjectListPrivate;
     if (!((!(((struct Node *)(((((struct Node *)((&(((list)))->Head)))->Succ))))->Succ)))) {
  SetBubbleType(13);
  (txtGetNthString(2U, "GENUG", 0, enough));
  ExpandObjectList(list, enough);
  while (ChoiceOk
         ((choice1 =
    Bubble(list, choice1, 0L, 0L)), ((U8)-1), list)) {
      SetBubbleType(13);
      objID =
   (U32) (((struct ObjectNode *)
    GetNthNode(list, (unsigned int) choice1))->nr);
      ret = Present(objID, "Building", InitBuildingPresent);
  }
     } else
  Say(2U, 0, 7, "POOR");
     RemoveList(list);
     break;
 case 5:
     Present(0, "Beute", InitLootPresent);
     break;
 default:
     choice = 6;
     break;
 }
    }
}

variable_types:
choice
unsigned char

variable_types:
enough
char [256]

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

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


Look

decompiled_code:
__int64 __fastcall Look(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rbp
char v3; // bl
__int64 result; // rax
unsigned int v5; // ebp
__int64 v6; // rax
__int64 v7; // rax
unsigned int v8; // ebx
__int64 v9; // rax
unsigned __int8 v10; // al
_BYTE v11[296]; // [rsp+0h] [rbp-128h] BYREF

v1 = 0LL;
inpTurnESC(1LL);
while ( 1 )
{
while ( 1 )
{
v2 = txtGoKey(4LL, "UMSEHEN");
SetBubbleType(13LL);
v3 = Bubble(v2, 0LL, 0LL, 0LL);
result = RemoveList(v2);
if ( v3 )
break;
v6 = GetNthNode(*(_QWORD *)(film + 24LL), a1);
v1 = txtGoKey(3LL, *(_QWORD *)(v6 + 16));
SetBubbleType(13LL);
Bubble(v1, 0LL, 0LL, 0LL);
RemoveList(v1);
}
if ( v3 != 1 )
break;
v5 = GetObjNrOfLocation(a1);
if ( v5
&& (SetObjectListAttr(7LL, 9900LL),
v7 = dbGetObject(v5),
AskAll(v7, 4LL, &BuildObjectList),
v1 = ObjectListPrivate,
*(_QWORD *)*ObjectListPrivate) )
{
txtGetNthString(2LL, "GENUG_2", 0LL, v11);
v8 = 0;
ExpandObjectList(v1, v11);
SetBubbleType(13LL);
while ( 1 )
{
v10 = Bubble(v1, v8, 0LL, 0LL);
v8 = v10;
if ( !(unsigned __int8)ChoiceOk(v10, 255LL, v1) )
break;
v9 = GetNthNode(v1, v8);
tcDisplayInfoAboutPerson(*(_DWORD *)(v9 + 32));
}
}
else
{
Say(2LL, 0LL, 7LL, "NOBODY TO SEE");
}
RemoveList(v1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rbp
char v3; // bl
__int64 result; // rax
unsigned int v5; // ebp
__int64 v6; // rax
__int64 v7; // rax
unsigned int v8; // ebx
__int64 v9; // rax
unsigned __int8 v10; // al
_BYTE v11[296]; // [rsp+0h] [rbp-128h] BYREF

v1 = 0LL;
inpTurnESC(1LL);
while ( 1 )
{
while ( 1 )
{
v2 = txtGoKey(4LL, "UMSEHEN");
SetBubbleType(13LL);
v3 = Bubble(v2, 0LL, 0LL, 0LL);
result = RemoveList(v2);
if ( v3 )
break;
v6 = GetNthNode(*(_QWORD *)(film + 24LL), a1);
v1 = txtGoKey(3LL, *(_QWORD *)(v6 + 16));
SetBubbleType(13LL);
Bubble(v1, 0LL, 0LL, 0LL);
RemoveList(v1);
}
if ( v3 != 1 )
break;
v5 = GetObjNrOfLocation(a1);
if ( v5
&& (SetObjectListAttr(7LL, 9900LL),
v7 = dbGetObject(v5),
AskAll(v7, 4LL, &BuildObjectList),
v1 = ObjectListPrivate,
*(_QWORD *)*ObjectListPrivate) )
{
txtGetNthString(2LL, "GENUG_2", 0LL, v11);
v8 = 0;
ExpandObjectList(v1, v11);
SetBubbleType(13LL);
while ( 1 )
{
v10 = Bubble(v1, v8, 0LL, 0LL);
v8 = v10;
if ( !(unsigned __int8)ChoiceOk(v10, 255LL, v1) )
break;
v9 = GetNthNode(v1, v8);
func0(*(_DWORD *)(v9 + 32));
}
}
else
{
Say(2LL, 0LL, 7LL, "NOBODY TO SEE");
}
RemoveList(v1);
}
return result;
}

original_code:
void Look(U32 locNr)
{
    LIST *menu, *bubble = ((void *)0);
    ubyte choice = 0, choice1 = 0;
    char enough[256];
    U32 objID;
    inpTurnESC(1);
    while (choice != 2) {
 menu = txtGoKey(4U, "UMSEHEN");
 SetBubbleType(13);
 choice = Bubble(menu, 0, 0L, 0L);
 RemoveList(menu);
 choice1 = 0;
 switch (choice) {
 case 0:
     bubble = txtGoKey(3U,
         (((NODE *)(GetNthNode(film->loc_names, (locNr))))->Name));
     SetBubbleType(13);
     choice1 = Bubble(bubble, 0, 0L, 0L);
     RemoveList(bubble);
     break;
 case 1:
     objID = GetObjNrOfLocation(locNr);
     if (objID) {
  { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9900L); AskAll (dbGetObject (objID), 4, BuildObjectList); };
  bubble = ObjectListPrivate;
  if (!((!(((NODE *)(((((NODE *)((&(((bubble)))->Head)))->Succ))))->Succ)))) {
      (txtGetNthString(2U, "GENUG_2", 0, enough));
      ExpandObjectList(bubble, enough);
      SetBubbleType(13);
      while (ChoiceOk
      ((choice1 =
        Bubble(bubble, choice1, 0L, 0L)), ((U8)-1),
       bubble)) {
   objID =
       ((struct ObjectNode *)
        GetNthNode(bubble, (U32) choice1))->nr;
   tcDisplayInfoAboutPerson(objID);
      }
  } else
      Say(2U, 0, 7, "NOBODY TO SEE");
     } else
  Say(2U, 0, 7, "NOBODY TO SEE");
     RemoveList(bubble);
     break;
 default:
     choice = 2;
     break;
 }
    }
}

canonical_original_code:
void Look(unsigned int locNr)
{
    struct List *menu; struct List *bubble = ((void *)0);
    unsigned char choice = 0; unsigned char choice1 = 0;
    char enough[256];
    unsigned int objID;
    inpTurnESC(1);
    while (choice != 2) {
 menu = txtGoKey(4U, "UMSEHEN");
 SetBubbleType(13);
 choice = Bubble(menu, 0, 0L, 0L);
 RemoveList(menu);
 choice1 = 0;
 switch (choice) {
 case 0:
     bubble = txtGoKey(3U,
         (((struct Node *)(GetNthNode(film->loc_names, (locNr))))->Name));
     SetBubbleType(13);
     choice1 = Bubble(bubble, 0, 0L, 0L);
     RemoveList(bubble);
     break;
 case 1:
     objID = GetObjNrOfLocation(locNr);
     if (objID) {
  { SetObjectListAttr ((1 << 2) | (1) | (1 << 1),9900L); AskAll (dbGetObject (objID), 4, BuildObjectList); };
  bubble = ObjectListPrivate;
  if (!((!(((struct Node *)(((((struct Node *)((&(((bubble)))->Head)))->Succ))))->Succ)))) {
      (txtGetNthString(2U, "GENUG_2", 0, enough));
      ExpandObjectList(bubble, enough);
      SetBubbleType(13);
      while (ChoiceOk
      ((choice1 =
        Bubble(bubble, choice1, 0L, 0L)), ((U8)-1),
       bubble)) {
   objID =
       ((struct ObjectNode *)
        GetNthNode(bubble, (unsigned int) choice1))->nr;
   tcDisplayInfoAboutPerson(objID);
      }
  } else
      Say(2U, 0, 7, "NOBODY TO SEE");
     } else
  Say(2U, 0, 7, "NOBODY TO SEE");
     RemoveList(bubble);
     break;
 default:
     choice = 2;
     break;
 }
    }
}


tcTelefon

decompiled_code:
__int64 tcTelefon()
{
unsigned __int16 *v0; // rbx
__int64 v1; // rax
char v2; // bp
__int64 v4; // r12
__int64 v5; // rbp
unsigned int v6; // ebp
__int64 v7; // r12
unsigned int v8; // eax
__int64 v9; // rax
_BYTE v10[280]; // [rsp+0h] [rbp-118h] BYREF

v0 = (unsigned __int16 *)dbGetObject(9844LL);
gfxShow(175LL, 33LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
SetObjectListAttr(3LL, 9900LL);
v1 = dbGetObject(9801LL);
AskAll(v1, 5LL, &BuildObjectList);
if ( *(_QWORD *)*ObjectList )
{
txtGetNthString(2LL, "DONT_CONNECT_ME", 0LL, v10);
ExpandObjectList(ObjectList, v10);
inpTurnESC(0LL);
v2 = Say(4LL, 0LL, 7LL, "CONNECT_ME");
inpTurnESC(1LL);
if ( v2 != -1 )
{
v4 = ObjectList;
v5 = (unsigned __int8)Bubble(ObjectList, 0LL, 0LL, 0LL);
if ( (unsigned __int8)ChoiceOk(v5, 255LL, v4) )
{
v6 = *(_DWORD *)(GetNthNode(ObjectList, (unsigned int)v5) + 32);
if ( v6 == 9844 )
Say(2LL, 0LL, *v0, "ALREADY_PHONING");
v7 = dbGetObject(v6);
v8 = getKey(2LL);
v9 = dbGetObject(v8);
if ( (unsigned int)AskP(v9, 10LL, v7, 0xFFFFFFFFLL, 0LL) )
{
if ( (unsigned int)CalcRandomNr(0LL, 9LL) == 3 )
{
Say(2LL, 0LL, *v0, "OCCUPIED");
}
else
{
inpTurnESC(0LL);
DynamicTalk(9801LL, v6, 2LL);
inpTurnESC(1LL);
}
}
else
{
Say(2LL, 0LL, *v0, "NOBODY_AT_HOME");
}
}
}
}
else
{
Say(4LL, 0LL, 7LL, "POOR_MATT");
}
gfxShow(173LL, 33LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
unsigned __int16 *v0; // rbx
__int64 v1; // rax
char v2; // bp
__int64 v4; // r12
__int64 v5; // rbp
unsigned int v6; // ebp
__int64 v7; // r12
unsigned int v8; // eax
__int64 v9; // rax
_BYTE v10[280]; // [rsp+0h] [rbp-118h] BYREF

v0 = (unsigned __int16 *)dbGetObject(9844LL);
gfxShow(175LL, 33LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
SetObjectListAttr(3LL, 9900LL);
v1 = dbGetObject(9801LL);
AskAll(v1, 5LL, &BuildObjectList);
if ( *(_QWORD *)*ObjectList )
{
txtGetNthString(2LL, "DONT_CONNECT_ME", 0LL, v10);
ExpandObjectList(ObjectList, v10);
inpTurnESC(0LL);
v2 = Say(4LL, 0LL, 7LL, "CONNECT_ME");
inpTurnESC(1LL);
if ( v2 != -1 )
{
v4 = ObjectList;
v5 = (unsigned __int8)Bubble(ObjectList, 0LL, 0LL, 0LL);
if ( (unsigned __int8)ChoiceOk(v5, 255LL, v4) )
{
v6 = *(_DWORD *)(GetNthNode(ObjectList, (unsigned int)v5) + 32);
if ( v6 == 9844 )
Say(2LL, 0LL, *v0, "ALREADY_PHONING");
v7 = dbGetObject(v6);
v8 = getKey(2LL);
v9 = dbGetObject(v8);
if ( (unsigned int)AskP(v9, 10LL, v7, 0xFFFFFFFFLL, 0LL) )
{
if ( (unsigned int)CalcRandomNr(0LL, 9LL) == 3 )
{
Say(2LL, 0LL, *v0, "OCCUPIED");
}
else
{
inpTurnESC(0LL);
DynamicTalk(9801LL, v6, 2LL);
inpTurnESC(1LL);
}
}
else
{
Say(2LL, 0LL, *v0, "NOBODY_AT_HOME");
}
}
}
}
else
{
Say(4LL, 0LL, 7LL, "POOR_MATT");
}
gfxShow(173LL, 33LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
return 0LL;
}

original_code:
U32 tcTelefon(void)
{
    char connect[256];
    U32 eventNr = 0L;
    Person ben = dbGetObject(9844U);
    gfxShow(175, 1 | 32, 0, -1, -1);
    { SetObjectListAttr ((1) | (1 << 1),9900L); AskAll (dbGetObject (9801U), 5, BuildObjectList); };
    if (!((!(((NODE *)(((((NODE *)((&(((ObjectList)))->Head)))->Succ))))->Succ)))) {
 ubyte choice = 0;
 U32 persID;
 (txtGetNthString(2U, "DONT_CONNECT_ME", 0, connect));
 ExpandObjectList(ObjectList, connect);
 inpTurnESC(0);
 choice = Say(4U, 0, 7, "CONNECT_ME");
 inpTurnESC(1);
 if (choice != ((U8)-1)) {
     if (ChoiceOk
  ((choice =
    Bubble(ObjectList, 0, 0L, 0L)), ((U8)-1), ObjectList)) {
  persID =
      (U32) (((struct ObjectNode *)
       GetNthNode(ObjectList, (U32) choice))->nr);
  if (persID == 9844U)
      Say(2U, 0, ben->PictID, "ALREADY_PHONING");
  if (AskP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (persID), (4294967295U), ((U8)0))) {
      if (CalcRandomNr(0L, 9L) == 3)
   Say(2U, 0, ben->PictID, "OCCUPIED");
      else {
   inpTurnESC(0);
   DynamicTalk(9801U, persID,
        2);
   inpTurnESC(1);
      }
  } else
      Say(2U, 0, ben->PictID, "NOBODY_AT_HOME");
     }
 } else
     choice = ((U8)-1);
    } else
 Say(4U, 0, 7, "POOR_MATT");
    gfxShow(173, 32 | 1, 0, -1, -1);
    return (eventNr);
}

canonical_original_code:
unsigned int tcTelefon()
{
    char connect[256];
    unsigned int eventNr = 0L;
    struct _Person *ben = dbGetObject(9844U);
    gfxShow(175, 1 | 32, 0, -1, -1);
    { SetObjectListAttr ((1) | (1 << 1),9900L); AskAll (dbGetObject (9801U), 5, BuildObjectList); };
    if (!((!(((struct Node *)(((((struct Node *)((&(((ObjectList)))->Head)))->Succ))))->Succ)))) {
 unsigned char choice = 0;
 unsigned int persID;
 (txtGetNthString(2U, "DONT_CONNECT_ME", 0, connect));
 ExpandObjectList(ObjectList, connect);
 inpTurnESC(0);
 choice = Say(4U, 0, 7, "CONNECT_ME");
 inpTurnESC(1);
 if (choice != ((U8)-1)) {
     if (ChoiceOk
  ((choice =
    Bubble(ObjectList, 0, 0L, 0L)), ((U8)-1), ObjectList)) {
  persID =
      (U32) (((struct ObjectNode *)
       GetNthNode(ObjectList, (unsigned int) choice))->nr);
  if (persID == 9844U)
      Say(2U, 0, ben->PictID, "ALREADY_PHONING");
  if (AskP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (persID), (4294967295U), ((unsigned char)0))) {
      if (CalcRandomNr(0L, 9L) == 3)
   Say(2U, 0, ben->PictID, "OCCUPIED");
      else {
   inpTurnESC(0);
   DynamicTalk(9801U, persID,
        2);
   inpTurnESC(1);
      }
  } else
      Say(2U, 0, ben->PictID, "NOBODY_AT_HOME");
     }
 } else
     choice = ((U8)-1);
    } else
 Say(4U, 0, 7, "POOR_MATT");
    gfxShow(173, 32 | 1, 0, -1, -1);
    return (eventNr);
}

variable_types:
connect
char [256]

variable_types:
eventNr
unsigned int

variable_types: struct _Person { unsigned short PictID; enum JobE { Detektiv=0, Sprengmeister=1, Schlosser=2, Hehler=3, Haendler=4, Taxifahrer=5, Mechaniker=6, Elektriker=7, Sekretaerin=8, Anwalt=9, Unbekannt=10, Profiboxer=11, Angestellte=12, Soldat=13, Student=14, Literat=15, Professor=16, Hausfrau=17, Politiker=18, Abenteurer=19, Agent=20, Musiker=21, Pilot=22, Kellner=23, Rezeptionist=24, Polizeichef=25, Polizist=26, Moench=27, Inspektor=28, Pizzafahrer=29, Kellner_und_Student=30, Arbeiter=31, Butler=32, Krankenschwester=33 } Job; enum SexE { Maennlich=0, Weiblich=1 } Sex; char Age; unsigned char Health; unsigned char Mood; unsigned char Intelligence; unsigned char Strength; unsigned char Stamina; unsigned char Loyality; unsigned char Skill; unsigned char Known; unsigned char Popularity; unsigned char Avarice; unsigned char Panic; unsigned char KnownToPolice; unsigned int TalkBits; unsigned char TalkFileID; unsigned char OldHealth; } *

variable_types:
persID
unsigned int

user_defined_types: struct _Person { unsigned short PictID; enum JobE Job; enum SexE Sex; char Age; unsigned char Health; unsigned char Mood; unsigned char Intelligence; unsigned char Strength; unsigned char Stamina; unsigned char Loyality; unsigned char Skill; unsigned char Known; unsigned char Popularity; unsigned char Avarice; unsigned char Panic; unsigned char KnownToPolice; unsigned int TalkBits; unsigned char TalkFileID; unsigned char OldHealth; }


tcWait

decompiled_code:
__int64 tcWait()
{
unsigned int v0; // er13
unsigned int v1; // ebx
unsigned int v2; // ebp
unsigned int v3; // er12
__int64 v5; // rax
unsigned int v6; // eax
__int64 v7; // rax
unsigned int v8; // er14
__int64 v9; // rax
unsigned int v10; // er14
__int64 v11; // rax
unsigned int v12; // er12
_BYTE v13[296]; // [rsp+0h] [rbp-128h] BYREF

v0 = 0;
v1 = 0;
v2 = GetObjNrOfLocation(*(unsigned int *)(film + 52LL));
inpTurnESC(0LL);
ShowMenuBackground();
ShowTime(0LL);
inpSetWaitTicks(25LL);
gfxSetRect(0LL, 320LL);
gfxSetPens(m_gc, 249LL, 0LL, 255LL);
txtGetNthString(4LL, "WAIT", 0LL, v13);
gfxPrint(m_gc, v13, 22LL, 1LL);
while ( 1 )
{
v3 = v1 + 60;
AddVTime(60LL);
v1 += 60;
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v5 = dbGetObject(v2);
AskAll(v5, 4LL, &BuildObjectList);
v6 = GetNrOfNodes(ObjectList);
if ( v6 > v0 && v0 )
{
v0 = v6;
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
else
{
v0 = v6;
}
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
v1 = v3 + 60;
AddVTime(60LL);
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v7 = dbGetObject(v2);
AskAll(v7, 4LL, &BuildObjectList);
v8 = GetNrOfNodes(ObjectList);
if ( v8 > v0 && v0 )
{
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
v0 = v8;
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
v1 = v3 + 120;
AddVTime(60LL);
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v9 = dbGetObject(v2);
AskAll(v9, 4LL, &BuildObjectList);
v10 = GetNrOfNodes(ObjectList);
if ( v10 > v0 && v0 )
{
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
v0 = v10;
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
v1 = v3 + 180;
AddVTime(60LL);
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v11 = dbGetObject(v2);
AskAll(v11, 4LL, &BuildObjectList);
v12 = GetNrOfNodes(ObjectList);
if ( v12 > v0 && v0 )
{
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
v0 = v12;
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
if ( v1 > 0x3BF )
goto LABEL_11;
}
if ( v1 > 0x3BF )
{
LABEL_11:
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "WURZEL_SEPP");
}
inpSetWaitTicks(0LL);
ShowMenuBackground();
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
inpTurnESC(1LL);
return ShowTime(0LL);
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // er13
unsigned int v1; // ebx
unsigned int v2; // ebp
unsigned int v3; // er12
__int64 v5; // rax
unsigned int v6; // eax
__int64 v7; // rax
unsigned int v8; // er14
__int64 v9; // rax
unsigned int v10; // er14
__int64 v11; // rax
unsigned int v12; // er12
_BYTE v13[296]; // [rsp+0h] [rbp-128h] BYREF

v0 = 0;
v1 = 0;
v2 = GetObjNrOfLocation(*(unsigned int *)(film + 52LL));
inpTurnESC(0LL);
ShowMenuBackground();
ShowTime(0LL);
inpSetWaitTicks(25LL);
gfxSetRect(0LL, 320LL);
gfxSetPens(m_gc, 249LL, 0LL, 255LL);
txtGetNthString(4LL, "WAIT", 0LL, v13);
gfxPrint(m_gc, v13, 22LL, 1LL);
while ( 1 )
{
v3 = v1 + 60;
AddVTime(60LL);
v1 += 60;
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v5 = dbGetObject(v2);
AskAll(v5, 4LL, &BuildObjectList);
v6 = GetNrOfNodes(ObjectList);
if ( v6 > v0 && v0 )
{
v0 = v6;
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
else
{
v0 = v6;
}
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
v1 = v3 + 60;
AddVTime(60LL);
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v7 = dbGetObject(v2);
AskAll(v7, 4LL, &BuildObjectList);
v8 = GetNrOfNodes(ObjectList);
if ( v8 > v0 && v0 )
{
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
v0 = v8;
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
v1 = v3 + 120;
AddVTime(60LL);
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v9 = dbGetObject(v2);
AskAll(v9, 4LL, &BuildObjectList);
v10 = GetNrOfNodes(ObjectList);
if ( v10 > v0 && v0 )
{
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
v0 = v10;
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
v1 = v3 + 180;
AddVTime(60LL);
ShowTime(0LL);
if ( v2 )
{
SetObjectListAttr(0LL, 9900LL);
v11 = dbGetObject(v2);
AskAll(v11, 4LL, &BuildObjectList);
v12 = GetNrOfNodes(ObjectList);
if ( v12 > v0 && v0 )
{
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "NEW_PEOPLE");
ShowTime(0LL);
}
v0 = v12;
}
if ( (inpWaitFor(2224LL) & 0xB0) != 0 )
break;
if ( v1 > 0x3BF )
goto LABEL_11;
}
if ( v1 > 0x3BF )
{
LABEL_11:
SetBubbleType(13LL);
Say(4LL, 0LL, 7LL, "WURZEL_SEPP");
}
inpSetWaitTicks(0LL);
ShowMenuBackground();
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
inpTurnESC(1LL);
return ShowTime(0LL);
}

original_code:
void tcWait(void)
{
    char line[256];
    ubyte ende = 0;
    U32 action = 0L, minutes = 0L, locNr = GetObjNrOfLocation((film->akt_Ort));
    U32 newCount = 0, oldCount = 0;
    inpTurnESC(0);
    ShowMenuBackground();
    ShowTime(0);
    inpSetWaitTicks(25L);
    gfxSetRect(0, 320);
    gfxSetPens(m_gc, 249, 0, ((ubyte)255));
    (txtGetNthString(4U, "WAIT", 0, line));
    gfxPrint(m_gc, line, 22, (1));
    while ((!ende) && (minutes < 960)) {
 minutes += 60;
 AddVTime(60L);
 ShowTime(0);
 if (locNr) {
     { SetObjectListAttr ((0),9900L); AskAll (dbGetObject (locNr), 4, BuildObjectList); };
     newCount = GetNrOfNodes(ObjectList);
     if ((newCount > oldCount) && (oldCount != 0)) {
  SetBubbleType(13);
  Say(4U, 0, 7, "NEW_PEOPLE");
  ShowTime(0);
     }
     oldCount = newCount;
 }
 action = inpWaitFor((1<<11) | (1<<5) | (1<<7) | (1<<4));
 if ((action & (1<<5)) || (action & (1<<7)) ||
     (action & (1<<4)))
     ende = 1;
    }
    if (minutes >= 960) {
 SetBubbleType(13);
 Say(4U, 0, 7, "WURZEL_SEPP");
    }
    inpSetWaitTicks(0L);
    ShowMenuBackground();
    tcRefreshLocationInTitle((film->akt_Ort));
    inpTurnESC(1);
    ShowTime(0);
}

canonical_original_code:
void tcWait()
{
    char line[256];
    unsigned char ende = 0;
    unsigned int action = 0L; unsigned int minutes = 0L; unsigned int locNr = GetObjNrOfLocation((film->akt_Ort));
    unsigned int newCount = 0; unsigned int oldCount = 0;
    inpTurnESC(0);
    ShowMenuBackground();
    ShowTime(0);
    inpSetWaitTicks(25L);
    gfxSetRect(0, 320);
    gfxSetPens(m_gc, 249, 0, ((unsigned char)255));
    (txtGetNthString(4U, "WAIT", 0, line));
    gfxPrint(m_gc, line, 22, (1));
    while ((!ende) && (minutes < 960)) {
 minutes += 60;
 AddVTime(60L);
 ShowTime(0);
 if (locNr) {
     { SetObjectListAttr ((0),9900L); AskAll (dbGetObject (locNr), 4, BuildObjectList); };
     newCount = GetNrOfNodes(ObjectList);
     if ((newCount > oldCount) && (oldCount != 0)) {
  SetBubbleType(13);
  Say(4U, 0, 7, "NEW_PEOPLE");
  ShowTime(0);
     }
     oldCount = newCount;
 }
 action = inpWaitFor((1<<11) | (1<<5) | (1<<7) | (1<<4));
 if ((action & (1<<5)) || (action & (1<<7)) ||
     (action & (1<<4)))
     ende = 1;
    }
    if (minutes >= 960) {
 SetBubbleType(13);
 Say(4U, 0, 7, "WURZEL_SEPP");
    }
    inpSetWaitTicks(0L);
    ShowMenuBackground();
    tcRefreshLocationInTitle((film->akt_Ort));
    inpTurnESC(1);
    ShowTime(0);
}

variable_types:
line
char [256]

variable_types:
ende
unsigned char

variable_types:
action
unsigned int

variable_types:
minutes
unsigned int

variable_types:
newCount
unsigned int

variable_types:
oldCount
unsigned int


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

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

original_code:
int CDROM_Install(void)
{
    return 1;
}

canonical_original_code:
int CDROM_Install()
{
    return 1;
}

return_type: int


decompiled_code:
void CDROM_UnInstall()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void CDROM_UnInstall(void)
{
}

canonical_original_code:
void CDROM_UnInstall()
{
}


decompiled_code:
void CDROM_WaitForMedia()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void CDROM_WaitForMedia(void)
{
}

canonical_original_code:
void CDROM_WaitForMedia()
{
}


decompiled_code:
void CDROM_PlayAudioSequence()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void CDROM_PlayAudioSequence(U8 TrackNum, U32 StartOffset, U32 EndOffset)
{
}

canonical_original_code:
void CDROM_PlayAudioSequence(unsigned char TrackNum, unsigned int StartOffset, unsigned int EndOffset)
{
}

variable_types:
TrackNum
unsigned char

variable_types:
StartOffset
unsigned int

variable_types:
EndOffset
unsigned int


decompiled_code:
void CDROM_StopAudioTrack()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void CDROM_StopAudioTrack(void)
{
}

canonical_original_code:
void CDROM_StopAudioTrack()
{
}


Round

canonical_original_code:
int Round(int v, int p)
{
    register int i; register int z;
    for (i = 0, z = 1; i < p; i++, z *= 10);
    if (v / z != 0)
 v = (v / z) * z;
    return (v);
}

variable_types: v int

variable_types: p int

variable_types: i int

variable_types: z int


CalcValue

decompiled_code:
__int64 __fastcall CalcValue(int a1, signed int a2, signed int a3, int a4, int a5)
{
unsigned int v5; // er9
int v6; // ecx

v5 = a2;
v6 = a1 + a1 * ((a5 * a4 - (a5 << 7)) / 127) / 100;
if ( v6 >= a2 )
{
if ( v6 <= a3 )
a3 = v6;
v5 = a3;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, signed int a2, signed int a3, int a4, int a5)
{
unsigned int v5; // er9
int v6; // ecx

v5 = a2;
v6 = a1 + a1 * ((a5 * a4 - (a5 << 7)) / 127) / 100;
if ( v6 >= a2 )
{
if ( v6 <= a3 )
a3 = v6;
v5 = a3;
}
return v5;
}

original_code:
S32 CalcValue(S32 value, S32 min, S32 max, S32 fact, S32 perc)
{
    perc = ((perc * fact) - (perc * 128)) / 127;
    value = value + (value * perc) / 100;
    return ((value) < (min) ? (min) : (value) > (max) ? (max) : (value));
}

canonical_original_code:
int CalcValue(int value, int min, int max, int fact, int perc)
{
    perc = ((perc * fact) - (perc * 128)) / 127;
    value = value + (value * perc) / 100;
    return ((value) < (min) ? (min) : (value) > (max) ? (max) : (value));
}

variable_types: value int

variable_types: min int

variable_types: max int

variable_types: fact int

variable_types: perc int


ChangeAbs

decompiled_code:
__int64 __fastcall ChangeAbs(int a1, int a2, unsigned int a3, unsigned int a4)
{
signed int v4; // esi
__int64 result; // rax

v4 = a1 + a2;
result = a3;
if ( v4 >= (int)a3 )
{
result = a4;
if ( v4 <= (int)a4 )
result = (unsigned int)v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, unsigned int a3, unsigned int a4)
{
signed int v4; // esi
__int64 result; // rax

v4 = a1 + a2;
result = a3;
if ( v4 >= (int)a3 )
{
result = a4;
if ( v4 <= (int)a4 )
result = (unsigned int)v4;
}
return result;
}

original_code:
S32 ChangeAbs(S32 item, S32 value, S32 min, S32 max)
{
    item += value;
    return ((item) < (min) ? (min) : (item) > (max) ? (max) : (item));
}

canonical_original_code:
int ChangeAbs(int item, int value, int min, int max)
{
    item += value;
    return ((item) < (min) ? (min) : (item) > (max) ? (max) : (item));
}

variable_types: item int


CreateList

decompiled_code:
_QWORD *CreateList()
{
_QWORD *result; // rax

result = (_QWORD *)TCAllocMem(64LL, 1LL);
if ( result )
{
result[1] = 0LL;
*result = result + 4;
result[2] = 0LL;
result[4] = 0LL;
result[5] = result;
result[6] = 0LL;
}
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = (_QWORD *)TCAllocMem(64LL, 1LL);
if ( result )
{
result[1] = 0LL;
*result = result + 4;
result[2] = 0LL;
result[4] = 0LL;
result[5] = result;
result[6] = 0LL;
}
return result;
}

original_code:
LIST *CreateList(void)
{
    LIST *list = ((void *)0);
    if ((list = (LIST *) TCAllocMem(sizeof(*list), 1))) {
        (((NODE *)((&(list)->Head)))->Succ) = (&(list)->Tail);
        (((NODE *)((&(list)->Head)))->Pred) = ((void *)0);
        (((NODE *)((&(list)->Head)))->Name) = ((void *)0);
        (((NODE *)((&(list)->Tail)))->Succ) = ((void *)0);
        (((NODE *)((&(list)->Tail)))->Pred) = (&(list)->Head);
        (((NODE *)((&(list)->Tail)))->Name) = ((void *)0);
    }
    return list;
}

canonical_original_code:
struct List *CreateList()
{
    struct List *list = ((void *)0);
    if ((list = (struct List *) TCAllocMem(sizeof(*list), 1))) {
        (((struct Node *)((&(list)->Head)))->Succ) = (&(list)->Tail);
        (((struct Node *)((&(list)->Head)))->Pred) = ((void *)0);
        (((struct Node *)((&(list)->Head)))->Name) = ((void *)0);
        (((struct Node *)((&(list)->Tail)))->Succ) = ((void *)0);
        (((struct Node *)((&(list)->Tail)))->Pred) = (&(list)->Head);
        (((struct Node *)((&(list)->Tail)))->Name) = ((void *)0);
    }
    return list;
}

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


FreeList

decompiled_code:
__int64 __fastcall FreeList(__int64 a1)
{
return TCFreeMem(a1, 64LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return TCFreeMem(a1, 64LL);
}

original_code:
void FreeList(LIST *list)
{
    TCFreeMem(list, sizeof(*list));
}

canonical_original_code:
void FreeList(struct List *list)
{
    TCFreeMem(list, sizeof(*list));
}


FreeNode

decompiled_code:
__int64 __fastcall FreeNode(__int64 a1)
{
__int64 v2; // r12
const char *v3; // rdi

v2 = *(_QWORD *)(a1 + 24);
v3 = *(const char **)(a1 + 16);
if ( v3 )
v2 += strlen(v3) + 1;
return TCFreeMem(a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v2; // r12
const char *v3; // rdi

v2 = *(_QWORD *)(a1 + 24);
v3 = *(const char **)(a1 + 16);
if ( v3 )
v2 += strlen(v3) + 1;
return TCFreeMem(a1, v2);
}

original_code:
void FreeNode(void *node)
{
    size_t size;
    size = (((NODE *)(node))->Size);
    if ((((NODE *)(node))->Name))
 size += strlen((((NODE *)(node))->Name)) + 1;
    TCFreeMem(node, size);
}

canonical_original_code:
void FreeNode(void *node)
{
    unsigned long size;
    size = (((struct Node *)(node))->Size);
    if ((((struct Node *)(node))->Name))
 size += strlen((((struct Node *)(node))->Name)) + 1;
    TCFreeMem(node, size);
}

variable_types:
node
void *

variable_types:
size
unsigned long


RemoveList

decompiled_code:
__int64 __fastcall RemoveList(_QWORD **a1)
{
RemoveNode(a1, 0LL);
return FreeList((__int64)a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD **a1)
{
RemoveNode(a1, 0LL);
return func1((__int64)a1);
}

original_code:
void RemoveList(LIST *list)
{
    RemoveNode(list, ((void *)0));
    FreeList(list);
}

canonical_original_code:
void RemoveList(struct List *list)
{
    RemoveNode(list, ((void *)0));
    FreeList(list);
}


GetNrOfNodes

decompiled_code:
__int64 __fastcall GetNrOfNodes(_QWORD **a1)
{
unsigned int v1; // er8
_QWORD *i; // rdx

v1 = 0;
for ( i = (_QWORD *)**a1; i; ++v1 )
i = (_QWORD *)*i;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD **a1)
{
unsigned int v1; // er8
_QWORD *i; // rdx

v1 = 0;
for ( i = (_QWORD *)**a1; i; ++v1 )
i = (_QWORD *)*i;
return v1;
}

original_code:
U32 GetNrOfNodes(LIST *list)
{
    register NODE *node = ((void *)0);
    register U32 i = 0;
    for (i = 0, node = ((((NODE *)((&((list))->Head)))->Succ)); (((NODE *)(node))->Succ);
  i++, node = (((NODE *)(node))->Succ));
    return i;
}

canonical_original_code:
unsigned int GetNrOfNodes(struct List *list)
{
    register struct Node *node = ((void *)0);
    register unsigned int i = 0;
    for (i = 0, node = ((((struct Node *)((&((list))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  i++, node = (((struct Node *)(node))->Succ));
    return i;
}

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

variable_types:
i
unsigned int


GetNodeNrByAddr

decompiled_code:
__int64 __fastcall GetNodeNrByAddr(_QWORD **a1, _QWORD *a2)
{
unsigned int v2; // er8
_QWORD *v3; // rax
_QWORD *v4; // rcx

v2 = 0;
v3 = (_QWORD *)**a1;
if ( *a1 != a2 )
{
do
{
if ( !v3 )
break;
v4 = v3;
++v2;
v3 = (_QWORD *)*v3;
}
while ( a2 != v4 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD **a1, _QWORD *a2)
{
unsigned int v2; // er8
_QWORD *v3; // rax
_QWORD *v4; // rcx

v2 = 0;
v3 = (_QWORD *)**a1;
if ( *a1 != a2 )
{
do
{
if ( !v3 )
break;
v4 = v3;
++v2;
v3 = (_QWORD *)*v3;
}
while ( a2 != v4 );
}
return v2;
}

original_code:
U32 GetNodeNrByAddr(LIST *list, void *node)
{
    register NODE *s;
    register U32 i;
    for (s = ((((NODE *)((&((list))->Head)))->Succ)), i = 0; (((NODE *)(s))->Succ) && (s != node);
  s = (((NODE *)(s))->Succ), i++);
    return i;
}

canonical_original_code:
unsigned int GetNodeNrByAddr(struct List *list, void *node)
{
    register struct Node *s;
    register unsigned int i;
    for (s = ((((struct Node *)((&((list))->Head)))->Succ)), i = 0; (((struct Node *)(s))->Succ) && (s != node);
  s = (((struct Node *)(s))->Succ), i++);
    return i;
}


GetNodeNr

decompiled_code:
__int64 __fastcall GetNodeNr(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rax

v2 = GetNode(a1, a2);
return GetNodeNrByAddr(a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rax

v2 = GetNode(a1, a2);
return func6(a1, v2);
}

original_code:
U32 GetNodeNr(LIST *list, const char *name)
{
    return GetNodeNrByAddr(list, GetNode(list, name));
}

canonical_original_code:
unsigned int GetNodeNr(struct List *list, char *name)
{
    return GetNodeNrByAddr(list, GetNode(list, name));
}

variable_types:
name
char *


ReplaceNodeByAddr

decompiled_code:
__int64 __fastcall ReplaceNodeByAddr(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 *v3; // r9
_QWORD *v4; // r10
__int64 v5; // r8
__int64 *v6; // [rsp+8h] [rbp-10h] BYREF

result = (__int64)UnLinkByAddr(a1, a2, &v6);
if ( result )
{
Link(v3, v4, v6);
result = FreeNode(v5);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
__int64 *v3; // r9
_QWORD *v4; // r10
__int64 v5; // r8
__int64 *v6; // [rsp+8h] [rbp-10h] BYREF

result = (__int64)UnLinkByAddr(a1, a2, &v6);
if ( result )
{
Link(v3, v4, v6);
result = func3(v5);
}
return result;
}

original_code:
void ReplaceNodeByAddr(LIST *list, void *node, NODE *newNode)
{
    NODE *predNode;
    if ((node = UnLinkByAddr(list, node, &predNode))) {
 Link(list, newNode, predNode);
 FreeNode(node);
    }
}

canonical_original_code:
void ReplaceNodeByAddr(struct List *list, void *node, struct Node *newNode)
{
    struct Node *predNode;
    if ((node = UnLinkByAddr(list, node, &predNode))) {
 Link(list, newNode, predNode);
 FreeNode(node);
    }
}

variable_types:
newNode
struct Node *


ReplaceNode

decompiled_code:
__int64 __fastcall ReplaceNode(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rax

v2 = GetNode(a1, a2);
return ReplaceNodeByAddr((__int64)a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rax

v2 = GetNode(a1, a2);
return func9((__int64)a1, v2);
}

original_code:
void ReplaceNode(LIST *list, const char *name, NODE *newNode)
{
    ReplaceNodeByAddr(list, GetNode(list, name), newNode);
}

canonical_original_code:
void ReplaceNode(struct List *list, char *name, struct Node *newNode)
{
    ReplaceNodeByAddr(list, GetNode(list, name), newNode);
}


inpDoPseudoMultiTasking

decompiled_code:
// attributes: thunk
__int64 inpDoPseudoMultiTasking()
{
return animator();
}

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

original_code:
static void inpDoPseudoMultiTasking(void)
{
    animator();
}

canonical_original_code:
static void inpDoPseudoMultiTasking()
{
    animator();
}


inpCloseAllInputDevs

decompiled_code:
void inpCloseAllInputDevs()
{
;
}

original_code:
void inpCloseAllInputDevs(void)
{
}

canonical_original_code:
void inpCloseAllInputDevs()
{
}


inpMousePtrOn

decompiled_code:
void inpMousePtrOn()
{
;
}

original_code:
void inpMousePtrOn(void)
{
}

canonical_original_code:
void inpMousePtrOn()
{
}


inpMousePtrOff

decompiled_code:
void inpMousePtrOff()
{
;
}

original_code:
void inpMousePtrOff(void)
{
}

canonical_original_code:
void inpMousePtrOff()
{
}


inpSetWaitTicks

decompiled_code:
void __fastcall inpSetWaitTicks(int a1)
{
IHandler[2] = a1;
}

canonical_decompiled_code:
void __fastcall func5(int a1)
{
IHandler[2] = a1;
}

original_code:
void inpSetWaitTicks(U32 l_Ticks)
{
    IHandler.ul_WaitTicks = l_Ticks;
}

canonical_original_code:
void inpSetWaitTicks(unsigned int l_Ticks)
{
    IHandler.ul_WaitTicks = l_Ticks;
}


inpTurnESC

decompiled_code:
void __fastcall inpTurnESC(char a1)
{
BYTE1(IHandler[3]) = a1;
}

canonical_decompiled_code:
void __fastcall func6(char a1)
{
BYTE1(IHandler[3]) = a1;
}

original_code:
void inpTurnESC(_Bool us_NewStatus)
{
    IHandler.EscStatus = us_NewStatus;
}


inpTurnFunctionKey

decompiled_code:
void __fastcall inpTurnFunctionKey(char a1)
{
BYTE2(IHandler[3]) = a1;
}

canonical_decompiled_code:
void __fastcall func7(char a1)
{
BYTE2(IHandler[3]) = a1;
}

original_code:
void inpTurnFunctionKey(_Bool us_NewStatus)
{
    IHandler.FunctionKeyStatus = us_NewStatus;
}


inpTurnMouse

decompiled_code:
void __fastcall inpTurnMouse(char a1)
{
HIBYTE(IHandler[3]) = a1;
}

canonical_decompiled_code:
void __fastcall func8(char a1)
{
HIBYTE(IHandler[3]) = a1;
}

original_code:
void inpTurnMouse(_Bool us_NewStatus)
{
    IHandler.MouseStatus = us_NewStatus;
}


inpDelay

decompiled_code:
void __fastcall inpDelay(int a1)
{
int v1; // ebx
int v2; // eax

if ( a1 > 0 )
{
v1 = 0;
v2 = a1 & 7;
if ( (a1 & 7) == 0 )
goto LABEL_19;
if ( v2 != 1 )
{
if ( v2 != 2 )
{
if ( v2 != 3 )
{
if ( v2 != 4 )
{
if ( v2 != 5 )
{
if ( v2 != 6 )
{
gfxWaitTOF();
v1 = 1;
inpDoPseudoMultiTasking();
}
gfxWaitTOF();
++v1;
inpDoPseudoMultiTasking();
}
gfxWaitTOF();
++v1;
inpDoPseudoMultiTasking();
}
gfxWaitTOF();
++v1;
inpDoPseudoMultiTasking();
}
gfxWaitTOF();
++v1;
inpDoPseudoMultiTasking();
}
gfxWaitTOF();
++v1;
inpDoPseudoMultiTasking();
}
gfxWaitTOF();
++v1;
inpDoPseudoMultiTasking();
if ( a1 != v1 )
{
LABEL_19:
do
{
gfxWaitTOF();
v1 += 8;
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
gfxWaitTOF();
inpDoPseudoMultiTasking();
}
while ( a1 != v1 );
}
}
}

canonical_decompiled_code:
void __fastcall func9(int a1)
{
int v1; // ebx
int v2; // eax

if ( a1 > 0 )
{
v1 = 0;
v2 = a1 & 7;
if ( (a1 & 7) == 0 )
goto LABEL_19;
if ( v2 != 1 )
{
if ( v2 != 2 )
{
if ( v2 != 3 )
{
if ( v2 != 4 )
{
if ( v2 != 5 )
{
if ( v2 != 6 )
{
gfxWaitTOF();
v1 = 1;
func0();
}
gfxWaitTOF();
++v1;
func0();
}
gfxWaitTOF();
++v1;
func0();
}
gfxWaitTOF();
++v1;
func0();
}
gfxWaitTOF();
++v1;
func0();
}
gfxWaitTOF();
++v1;
func0();
}
gfxWaitTOF();
++v1;
func0();
if ( a1 != v1 )
{
LABEL_19:
do
{
gfxWaitTOF();
v1 += 8;
func0();
gfxWaitTOF();
func0();
gfxWaitTOF();
func0();
gfxWaitTOF();
func0();
gfxWaitTOF();
func0();
gfxWaitTOF();
func0();
gfxWaitTOF();
func0();
gfxWaitTOF();
func0();
}
while ( a1 != v1 );
}
}
}

original_code:
void inpDelay(S32 l_Ticks)
{
    S32 i;
    for (i = 0; i < l_Ticks; i++) {
 gfxWaitTOF();
 inpDoPseudoMultiTasking();
    }
}

canonical_original_code:
void inpDelay(int l_Ticks)
{
    int i;
    for (i = 0; i < l_Ticks; i++) {
 gfxWaitTOF();
 inpDoPseudoMultiTasking();
    }
}


inpOpenAllInputDevs

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

result = inpSetKeyRepeat(42LL);
LOBYTE(IHandler[4]) = 0;
IHandler[3] = 16843009;
return result;
}

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

result = func10(42LL);
LOBYTE(IHandler[4]) = 0;
IHandler[3] = 16843009;
return result;
}

original_code:
void inpOpenAllInputDevs(void)
{
    inpSetKeyRepeat((1 << 5) | 10);
    IHandler.EscStatus = 1;
    IHandler.FunctionKeyStatus = 1;
    IHandler.MouseExists = 1;
    IHandler.MouseStatus = 1;
    IHandler.JoyExists = 0;
    inpClearKbBuffer();
}

canonical_original_code:
void inpOpenAllInputDevs()
{
    inpSetKeyRepeat((1 << 5) | 10);
    IHandler.EscStatus = 1;
    IHandler.FunctionKeyStatus = 1;
    IHandler.MouseExists = 1;
    IHandler.MouseStatus = 1;
    IHandler.JoyExists = 0;
    inpClearKbBuffer();
}


inpClearKbBuffer

decompiled_code:
void inpClearKbBuffer()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void inpClearKbBuffer(void)
{
}

canonical_original_code:
void inpClearKbBuffer()
{
}


plBuildHandler

decompiled_code:
__int64 __fastcall plBuildHandler(__int64 a1)
{
return InitHandler(plSys, *(unsigned int *)(a1 + 32), *(_DWORD *)(a1 + 36) == 509991);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return InitHandler(plSys, *(unsigned int *)(a1 + 32), *(_DWORD *)(a1 + 36) == 509991);
}

original_code:
void plBuildHandler(NODE * n)
{
    U32 flags = 0;
    if ((((struct ObjectNode *)n)->type) == 509991L)
 flags |= 1;
    InitHandler(plSys, (((struct ObjectNode *)n)->nr), flags);
}

canonical_original_code:
void plBuildHandler(struct Node *n)
{
    unsigned int flags = 0;
    if ((((struct ObjectNode *)n)->type) == 509991L)
 flags |= 1;
    InitHandler(plSys, (((struct ObjectNode *)n)->nr), flags);
}

variable_types:
flags
unsigned int


plClearHandler

decompiled_code:
__int64 __fastcall plClearHandler(__int64 a1)
{
return ClearHandler(plSys, *(unsigned int *)(a1 + 32));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return ClearHandler(plSys, *(unsigned int *)(a1 + 32));
}

original_code:
void plClearHandler(NODE * n)
{
    ClearHandler(plSys, (((struct ObjectNode *)n)->nr));
}

canonical_original_code:
void plClearHandler(struct Node *n)
{
    ClearHandler(plSys, (((struct ObjectNode *)n)->nr));
}


plCloseHandler

decompiled_code:
__int64 __fastcall plCloseHandler(__int64 a1)
{
return CloseHandler(plSys, *(unsigned int *)(a1 + 32));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return CloseHandler(plSys, *(unsigned int *)(a1 + 32));
}

original_code:
void plCloseHandler(NODE * n)
{
    CloseHandler(plSys, (((struct ObjectNode *)n)->nr));
}

canonical_original_code:
void plCloseHandler(struct Node *n)
{
    CloseHandler(plSys, (((struct ObjectNode *)n)->nr));
}


plPrepareData

decompiled_code:
void plPrepareData()
{
Planing_Loot = 0LL;
Planing_Weight = 0LL;
*(&Planing_Weight + 1) = 0LL;
Planing_Volume = 0LL;
*(&Planing_Volume + 1) = 0LL;
Planing_Guard = 0;
}

canonical_decompiled_code:
void func3()
{
Planing_Loot = 0LL;
Planing_Weight = 0LL;
*(&Planing_Weight + 1) = 0LL;
Planing_Volume = 0LL;
*(&Planing_Volume + 1) = 0LL;
Planing_Guard = 0;
}

original_code:
void plPrepareData(void)
{
    register ubyte i;
    for (i = 0; i < 8; i++)
 Planing_Loot[i] = 0;
    for (i = 0; i < 4; i++)
 Planing_Weight[i] = 0;
    for (i = 0; i < 4; i++)
 Planing_Volume[i] = 0;
    for (i = 0; i < 4; i++)
 Planing_Guard[i] = 0;
}

canonical_original_code:
void plPrepareData()
{
    register unsigned char i;
    for (i = 0; i < 8; i++)
 Planing_Loot[i] = 0;
    for (i = 0; i < 4; i++)
 Planing_Weight[i] = 0;
    for (i = 0; i < 4; i++)
 Planing_Volume[i] = 0;
    for (i = 0; i < 4; i++)
 Planing_Guard[i] = 0;
}

variable_types:
i
unsigned char


plPrepareSprite

decompiled_code:
__int64 __fastcall plPrepareSprite(unsigned int a1, unsigned int a2)
{
_WORD *v2; // r12
__int64 result; // rax
__int16 v4; // r9
__int16 v5; // r10
int v6; // er12

v2 = (_WORD *)dbGetObject(a2);
result = livLivesInArea((char *)&Planing_Name + 20 * a1, a2);
if ( (unsigned __int8)BurglarsNr > a1 )
{
if ( a1 == 2 )
{
v4 = v2[15];
v5 = v2[21];
}
else if ( a1 > 2 )
{
if ( a1 != 3 )
return result;
v4 = v2[16];
v5 = v2[22];
}
else if ( a1 )
{
v4 = v2[14];
v5 = v2[20];
}
else
{
v4 = v2[13];
v5 = v2[19];
}
goto LABEL_6;
}
if ( a1 - (unsigned __int8)BurglarsNr != 2 )
{
if ( a1 - (unsigned __int8)BurglarsNr + 4 > 6 )
{
if ( a1 - (unsigned __int8)BurglarsNr != 3 )
return result;
goto LABEL_16;
}
if ( a1 != (unsigned __int8)BurglarsNr )
{
if ( a1 - (unsigned __int8)BurglarsNr != 1 )
return result;
LABEL_16:
v4 = v2[18] - 4;
v5 = v2[24] + 11;
goto LABEL_6;
}
}
v4 = v2[17] - 4;
v5 = v2[23] + 11;
LABEL_6:
livSetPos((char *)&Planing_Name + 20 * a1, (unsigned __int16)(v4 + 9), (unsigned __int16)(v5 - 18));
if ( (unsigned __int8)BurglarsNr > a1 )
return livAnimate((char *)&Planing_Name + 20 * a1, 9LL, 0LL, 0LL);
livAnimate((char *)&Planing_Name + 20 * a1, 1LL, 0LL, 0LL);
v6 = (unsigned __int8)BurglarsNr;
result = lsGetRoomsOfArea(a2);
Planing_GuardRoomList[a1 - v6] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, unsigned int a2)
{
_WORD *v2; // r12
__int64 result; // rax
__int16 v4; // r9
__int16 v5; // r10
int v6; // er12

v2 = (_WORD *)dbGetObject(a2);
result = livLivesInArea((char *)&Planing_Name + 20 * a1, a2);
if ( (unsigned __int8)BurglarsNr > a1 )
{
if ( a1 == 2 )
{
v4 = v2[15];
v5 = v2[21];
}
else if ( a1 > 2 )
{
if ( a1 != 3 )
return result;
v4 = v2[16];
v5 = v2[22];
}
else if ( a1 )
{
v4 = v2[14];
v5 = v2[20];
}
else
{
v4 = v2[13];
v5 = v2[19];
}
goto LABEL_6;
}
if ( a1 - (unsigned __int8)BurglarsNr != 2 )
{
if ( a1 - (unsigned __int8)BurglarsNr + 4 > 6 )
{
if ( a1 - (unsigned __int8)BurglarsNr != 3 )
return result;
goto LABEL_16;
}
if ( a1 != (unsigned __int8)BurglarsNr )
{
if ( a1 - (unsigned __int8)BurglarsNr != 1 )
return result;
LABEL_16:
v4 = v2[18] - 4;
v5 = v2[24] + 11;
goto LABEL_6;
}
}
v4 = v2[17] - 4;
v5 = v2[23] + 11;
LABEL_6:
livSetPos((char *)&Planing_Name + 20 * a1, (unsigned __int16)(v4 + 9), (unsigned __int16)(v5 - 18));
if ( (unsigned __int8)BurglarsNr > a1 )
return livAnimate((char *)&Planing_Name + 20 * a1, 9LL, 0LL, 0LL);
livAnimate((char *)&Planing_Name + 20 * a1, 1LL, 0LL, 0LL);
v6 = (unsigned __int8)BurglarsNr;
result = lsGetRoomsOfArea(a2);
Planing_GuardRoomList[a1 - v6] = result;
return result;
}

original_code:
void plPrepareSprite(U32 livNr, U32 areaId)
{
    LSArea activArea = (LSArea) dbGetObject(areaId);
    uword xpos, ypos;
    livLivesInArea(Planing_Name[livNr], areaId);
    if (livNr < BurglarsNr) {
 switch (livNr) {
 case 0:
     xpos = activArea->us_StartX0;
     ypos = activArea->us_StartY0;
     break;
 case 1:
     xpos = activArea->us_StartX1;
     ypos = activArea->us_StartY1;
     break;
 case 2:
     xpos = activArea->us_StartX2;
     ypos = activArea->us_StartY2;
     break;
 case 3:
     xpos = activArea->us_StartX3;
     ypos = activArea->us_StartY3;
     break;
 default:
     return;
 }
    } else {
 switch (livNr + (4 - BurglarsNr)) {
 case 4:
 case 6:
     xpos = activArea->us_StartX4 - 4;
     ypos = activArea->us_StartY4 + 11;
     break;
 case 5:
 case 7:
     xpos = activArea->us_StartX5 - 4;
     ypos = activArea->us_StartY5 + 11;
     break;
 default:
     return;
 }
    }
    livSetPos(Planing_Name[livNr], xpos + 9, ypos - 18);
    if (livNr < BurglarsNr)
 livAnimate(Planing_Name[livNr], ((ubyte)9), 0, 0);
    else {
 livAnimate(Planing_Name[livNr], ((ubyte)1), 0, 0);
 Planing_GuardRoomList[livNr - BurglarsNr] = lsGetRoomsOfArea(areaId);
    }
}

canonical_original_code:
void plPrepareSprite(unsigned int livNr, unsigned int areaId)
{
    struct _LSArea *activArea = (LSArea) dbGetObject(areaId);
    unsigned short xpos; unsigned short ypos;
    livLivesInArea(Planing_Name[livNr], areaId);
    if (livNr < BurglarsNr) {
 switch (livNr) {
 case 0:
     xpos = activArea->us_StartX0;
     ypos = activArea->us_StartY0;
     break;
 case 1:
     xpos = activArea->us_StartX1;
     ypos = activArea->us_StartY1;
     break;
 case 2:
     xpos = activArea->us_StartX2;
     ypos = activArea->us_StartY2;
     break;
 case 3:
     xpos = activArea->us_StartX3;
     ypos = activArea->us_StartY3;
     break;
 default:
     return;
 }
    } else {
 switch (livNr + (4 - BurglarsNr)) {
 case 4:
 case 6:
     xpos = activArea->us_StartX4 - 4;
     ypos = activArea->us_StartY4 + 11;
     break;
 case 5:
 case 7:
     xpos = activArea->us_StartX5 - 4;
     ypos = activArea->us_StartY5 + 11;
     break;
 default:
     return;
 }
    }
    livSetPos(Planing_Name[livNr], xpos + 9, ypos - 18);
    if (livNr < BurglarsNr)
 livAnimate(Planing_Name[livNr], ((unsigned char)9), 0, 0);
    else {
 livAnimate(Planing_Name[livNr], ((unsigned char)1), 0, 0);
 Planing_GuardRoomList[livNr - BurglarsNr] = lsGetRoomsOfArea(areaId);
    }
}

variable_types:
livNr
unsigned int

variable_types:
areaId
unsigned int

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:
xpos
unsigned short

variable_types:
ypos
unsigned short


plPrepareGfx

decompiled_code:
void __fastcall plPrepareGfx(__int64 a1, unsigned __int8 a2, char a3)
{
unsigned int v3; // ebp
unsigned int v5; // ebx
unsigned int v6; // eax
unsigned int v7; // edi
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // r12
__int64 v12; // rax
unsigned int v13; // eax
unsigned int v14; // edi

v3 = a1;
if ( (a3 & 1) != 0 )
lsInitLandScape(a1, a2);
if ( (a3 & 4) != 0 )
{
CurrentBackground = 23;
ShowMenuBackground();
gfxShow(CurrentBackground, 3LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}
if ( (a3 & 2) != 0 )
{
if ( PersonsNr )
{
v5 = 0;
do
{
while ( 1 )
{
v8 = GetNthNode(PersonsList, v5);
if ( !dbIsObject(*(unsigned int *)(v8 + 32), 9900LL) )
break;
v6 = lsGetActivAreaID();
v7 = v5++;
plPrepareSprite(v7, v6);
if ( (unsigned __int8)PersonsNr <= v5 )
goto LABEL_11;
}
v9 = GetNthNode(PersonsList, v5);
*(_BYTE *)(dbGetObject(*(unsigned int *)(v9 + 32)) + 2) = v5;
v10 = GetNthNode(PersonsList, v5);
v11 = dbGetObject(*(unsigned int *)(v10 + 32));
v12 = dbGetObject(v3);
v13 = GetP(v12, 500003LL, v11);
v14 = v5++;
plPrepareSprite(v14, v13);
}
while ( (unsigned __int8)PersonsNr > v5 );
}
LABEL_11:
lsSetActivLiving((char *)&Planing_Name + 20 * (unsigned int)CurrentPerson, 0xFFFFLL, 0xFFFFLL);
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, unsigned __int8 a2, char a3)
{
unsigned int v3; // ebp
unsigned int v5; // ebx
unsigned int v6; // eax
unsigned int v7; // edi
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // r12
__int64 v12; // rax
unsigned int v13; // eax
unsigned int v14; // edi

v3 = a1;
if ( (a3 & 1) != 0 )
lsInitLandScape(a1, a2);
if ( (a3 & 4) != 0 )
{
CurrentBackground = 23;
ShowMenuBackground();
gfxShow(CurrentBackground, 3LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}
if ( (a3 & 2) != 0 )
{
if ( PersonsNr )
{
v5 = 0;
do
{
while ( 1 )
{
v8 = GetNthNode(PersonsList, v5);
if ( !dbIsObject(*(unsigned int *)(v8 + 32), 9900LL) )
break;
v6 = lsGetActivAreaID();
v7 = v5++;
func4(v7, v6);
if ( (unsigned __int8)PersonsNr <= v5 )
goto LABEL_11;
}
v9 = GetNthNode(PersonsList, v5);
*(_BYTE *)(dbGetObject(*(unsigned int *)(v9 + 32)) + 2) = v5;
v10 = GetNthNode(PersonsList, v5);
v11 = dbGetObject(*(unsigned int *)(v10 + 32));
v12 = dbGetObject(v3);
v13 = GetP(v12, 500003LL, v11);
v14 = v5++;
func4(v14, v13);
}
while ( (unsigned __int8)PersonsNr > v5 );
}
LABEL_11:
lsSetActivLiving((char *)&Planing_Name + 20 * (unsigned int)CurrentPerson, 0xFFFFLL, 0xFFFFLL);
}
}

original_code:
void plPrepareGfx(U32 objId, ubyte landscapMode, ubyte prepareMode)
{
    if (prepareMode & (1))
 lsInitLandScape(objId, landscapMode);
    if (prepareMode & (1<<2)) {
 CurrentBackground = 23;
 ShowMenuBackground();
 gfxShow(CurrentBackground, 1 | 2, 5, -1, -1);
    }
    if (prepareMode & (1<<1)) {
 U32 i;
 for (i = 0; i < PersonsNr; i++) {
     if (dbIsObject((((struct ObjectNode *)GetNthNode(PersonsList, i))->nr), 9900L))
  plPrepareSprite(i, lsGetActivAreaID());
     else {
  ((Police) dbGetObject((((struct ObjectNode *)GetNthNode(PersonsList, i))->nr)))->
      LivingID = i;
  plPrepareSprite(i,
    GetP (dbGetObject (objId), 500003, dbGetObject ((((struct ObjectNode *)GetNthNode (PersonsList, i))->nr))));
     }
 }
 lsSetActivLiving(Planing_Name[CurrentPerson], (uword) - 1, (uword) - 1);
    }
}

canonical_original_code:
void plPrepareGfx(unsigned int objId, unsigned char landscapMode, unsigned char prepareMode)
{
    if (prepareMode & (1))
 lsInitLandScape(objId, landscapMode);
    if (prepareMode & (1<<2)) {
 CurrentBackground = 23;
 ShowMenuBackground();
 gfxShow(CurrentBackground, 1 | 2, 5, -1, -1);
    }
    if (prepareMode & (1<<1)) {
 unsigned int i;
 for (i = 0; i < PersonsNr; i++) {
     if (dbIsObject((((struct ObjectNode *)GetNthNode(PersonsList, i))->nr), 9900L))
  plPrepareSprite(i, lsGetActivAreaID());
     else {
  ((struct _Police *) dbGetObject((((struct ObjectNode *)GetNthNode(PersonsList, i))->nr)))->
      LivingID = i;
  plPrepareSprite(i,
    GetP (dbGetObject (objId), 500003, dbGetObject ((((struct ObjectNode *)GetNthNode (PersonsList, i))->nr))));
     }
 }
 lsSetActivLiving(Planing_Name[CurrentPerson], (uword) - 1, (uword) - 1);
    }
}

variable_types:
objId
unsigned int

variable_types:
landscapMode
unsigned char

variable_types:
prepareMode
unsigned char

user_defined_types: struct _Police { unsigned short PictID; unsigned char LivingID; }


plUnprepareGfx

decompiled_code:
__int64 plUnprepareGfx()
{
int v0; // ebx
int i; // edx
int v2; // eax

gfxShow(CurrentBackground, 5LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
gfxClearArea(u_gc);
v0 = (unsigned __int8)BurglarsNr;
if ( (unsigned __int8)BurglarsNr < (unsigned __int8)PersonsNr )
{
for ( i = (unsigned __int8)BurglarsNr; ; i = (unsigned __int8)BurglarsNr )
{
v2 = (unsigned __int8)v0++;
RemoveList(Planing_GuardRoomList[v2 - i]);
if ( (unsigned __int8)PersonsNr <= (unsigned __int8)v0 )
break;
}
}
lsDoneLandScape();
return gfxShow(CurrentBackground, 3LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}

canonical_decompiled_code:
__int64 func6()
{
int v0; // ebx
int i; // edx
int v2; // eax

gfxShow(CurrentBackground, 5LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
gfxClearArea(u_gc);
v0 = (unsigned __int8)BurglarsNr;
if ( (unsigned __int8)BurglarsNr < (unsigned __int8)PersonsNr )
{
for ( i = (unsigned __int8)BurglarsNr; ; i = (unsigned __int8)BurglarsNr )
{
v2 = (unsigned __int8)v0++;
RemoveList(Planing_GuardRoomList[v2 - i]);
if ( (unsigned __int8)PersonsNr <= (unsigned __int8)v0 )
break;
}
}
lsDoneLandScape();
return gfxShow(CurrentBackground, 3LL, 0LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}

original_code:
void plUnprepareGfx(void)
{
    register ubyte i;
    gfxShow(CurrentBackground, 1 | 4, 5, -1, -1);
    gfxClearArea(u_gc);
    for (i = BurglarsNr; i < PersonsNr; i++)
 RemoveList(Planing_GuardRoomList[i - BurglarsNr]);
    lsDoneLandScape();
    gfxShow(CurrentBackground, 1 | 2, 0, -1, -1);
}

canonical_original_code:
void plUnprepareGfx()
{
    register unsigned char i;
    gfxShow(CurrentBackground, 1 | 4, 5, -1, -1);
    gfxClearArea(u_gc);
    for (i = BurglarsNr; i < PersonsNr; i++)
 RemoveList(Planing_GuardRoomList[i - BurglarsNr]);
    lsDoneLandScape();
    gfxShow(CurrentBackground, 1 | 2, 0, -1, -1);
}


plPrepareRel

decompiled_code:
__int64 plPrepareRel()
{
__int64 v0; // rax
__int64 v1; // rbp
_QWORD *i; // rbx
__int64 result; // rax

SetObjectListAttr(4LL, 509992LL);
v0 = dbGetObject((unsigned int)Planing_BldId);
AskAll(v0, 500002LL, &BuildObjectList);
v1 = ObjectListPrivate;
for ( i = (_QWORD *)*ObjectListPrivate; *i; i = (_QWORD *)*i )
{
while ( (unsigned int)CloneRelation((unsigned int)(*(_DWORD *)(i[5] + 20LL) + 7), 1300002LL) )
{
i = (_QWORD *)*i;
if ( !*i )
goto LABEL_6;
}
ErrorMsg(2LL, 12LL, 0LL);
}
LABEL_6:
RemoveList(v1);
result = AddRelation(1300001LL);
if ( !(_DWORD)result )
result = ErrorMsg(2LL, 12LL, 0LL);
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rax
__int64 v1; // rbp
_QWORD *i; // rbx
__int64 result; // rax

SetObjectListAttr(4LL, 509992LL);
v0 = dbGetObject((unsigned int)Planing_BldId);
AskAll(v0, 500002LL, &BuildObjectList);
v1 = ObjectListPrivate;
for ( i = (_QWORD *)*ObjectListPrivate; *i; i = (_QWORD *)*i )
{
while ( (unsigned int)CloneRelation((unsigned int)(*(_DWORD *)(i[5] + 20LL) + 7), 1300002LL) )
{
i = (_QWORD *)*i;
if ( !*i )
goto LABEL_6;
}
ErrorMsg(2LL, 12LL, 0LL);
}
LABEL_6:
RemoveList(v1);
result = AddRelation(1300001LL);
if ( !(_DWORD)result )
result = ErrorMsg(2LL, 12LL, 0LL);
return result;
}

original_code:
void plPrepareRel(void)
{
    LIST *areas;
    NODE *n;
    LSArea area;
    { SetObjectListAttr ((1 << 2),509992L); AskAll (dbGetObject (Planing_BldId), 500002, BuildObjectList); };
    areas = ObjectListPrivate;
    for (n = (NODE *) ((((NODE *)((&((areas))->Head)))->Succ)); (((NODE *)(n))->Succ); n = (NODE *) (((NODE *)(n))->Succ)) {
 area = (((struct ObjectNode *)n)->data);
 if (!CloneRelation
     (area->ul_ObjectBaseNr + 7, 1300000 +2))
     ErrorMsg(No_Mem, ERROR_MODULE_PLANING, 0);
    }
    RemoveList(areas);
    if (!AddRelation(1300000 +1))
 ErrorMsg(No_Mem, ERROR_MODULE_PLANING, 0);
}

canonical_original_code:
void plPrepareRel()
{
    struct List *areas;
    struct Node *n;
    struct _LSArea *area;
    { SetObjectListAttr ((1 << 2),509992L); AskAll (dbGetObject (Planing_BldId), 500002, BuildObjectList); };
    areas = ObjectListPrivate;
    for (n = (struct Node *) ((((struct Node *)((&((areas))->Head)))->Succ)); (((struct Node *)(n))->Succ); n = (struct Node *) (((struct Node *)(n))->Succ)) {
 area = (((struct ObjectNode *)n)->data);
 if (!CloneRelation
     (area->ul_ObjectBaseNr + 7, 1300000 +2))
     ErrorMsg(No_Mem, ERROR_MODULE_PLANING, 0);
    }
    RemoveList(areas);
    if (!AddRelation(1300000 +1))
 ErrorMsg(No_Mem, ERROR_MODULE_PLANING, 0);
}

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

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


plUnprepareRel

decompiled_code:
__int64 plUnprepareRel()
{
RemRelation(1300001LL);
return RemRelation(1300002LL);
}

canonical_decompiled_code:
__int64 func8()
{
RemRelation(1300001LL);
return RemRelation(1300002LL);
}

original_code:
void plUnprepareRel(void)
{
    RemRelation(1300000 +1);
    RemRelation(1300000 +2);
}

canonical_original_code:
void plUnprepareRel()
{
    RemRelation(1300000 +1);
    RemRelation(1300000 +2);
}


plPrepareNames

decompiled_code:
void plPrepareNames()
{
int v0; // ebx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rdx
char *v4; // rdi

if ( PersonsNr )
{
v0 = 0;
do
{
while ( 1 )
{
v1 = GetNthNode(PersonsList, (unsigned __int8)v0);
v2 = dbIsObject(*(unsigned int *)(v1 + 32), 9900LL);
v3 = (unsigned int)(unsigned __int8)v0 + 1;
v4 = (char *)&Planing_Name + 20 * (unsigned __int8)v0;
if ( !v2 )
break;
++v0;
sprintf(v4, "Person_%d", v3);
if ( (unsigned __int8)PersonsNr <= (unsigned __int8)v0 )
return;
}
++v0;
sprintf(v4, "Police_%d", 4 - (unsigned __int8)BurglarsNr + (unsigned int)v3);
}
while ( (unsigned __int8)PersonsNr > (unsigned __int8)v0 );
}
}

canonical_decompiled_code:
void func9()
{
int v0; // ebx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rdx
char *v4; // rdi

if ( PersonsNr )
{
v0 = 0;
do
{
while ( 1 )
{
v1 = GetNthNode(PersonsList, (unsigned __int8)v0);
v2 = dbIsObject(*(unsigned int *)(v1 + 32), 9900LL);
v3 = (unsigned int)(unsigned __int8)v0 + 1;
v4 = (char *)&Planing_Name + 20 * (unsigned __int8)v0;
if ( !v2 )
break;
++v0;
sprintf(v4, "Person_%d", v3);
if ( (unsigned __int8)PersonsNr <= (unsigned __int8)v0 )
return;
}
++v0;
sprintf(v4, "Police_%d", 4 - (unsigned __int8)BurglarsNr + (unsigned int)v3);
}
while ( (unsigned __int8)PersonsNr > (unsigned __int8)v0 );
}
}

original_code:
void plPrepareNames(void)
{
    register ubyte i;
    for (i = 0; i < PersonsNr; i++) {
 if (dbIsObject((((struct ObjectNode *)GetNthNode(PersonsList, i))->nr), 9900L))
     sprintf(Planing_Name[i], "Person_%d", i + 1);
 else
     sprintf(Planing_Name[i], "Police_%d",
      i + 1 + (4 - BurglarsNr));
    }
}

canonical_original_code:
void plPrepareNames()
{
    register unsigned char i;
    for (i = 0; i < PersonsNr; i++) {
 if (dbIsObject((((struct ObjectNode *)GetNthNode(PersonsList, i))->nr), 9900L))
     sprintf(Planing_Name[i], "Person_%d", i + 1);
 else
     sprintf(Planing_Name[i], "Police_%d",
      i + 1 + (4 - BurglarsNr));
    }
}


plUnprepareSys

decompiled_code:
void plUnprepareSys()
{
plPrepareSys(0, 0, 4);
if ( PersonsList )
RemoveList(PersonsList);
if ( BurglarsList )
RemoveList(BurglarsList);
PersonsList = 0LL;
BurglarsList = 0LL;
}

canonical_decompiled_code:
void func11()
{
func10(0, 0, 4);
if ( PersonsList )
RemoveList(PersonsList);
if ( BurglarsList )
RemoveList(BurglarsList);
PersonsList = 0LL;
BurglarsList = 0LL;
}

original_code:
void plUnprepareSys(void)
{
    plPrepareSys(0, 0, (1<<2));
    if (PersonsList)
 RemoveList(PersonsList);
    if (BurglarsList)
 RemoveList(BurglarsList);
    PersonsList = ((void *)0);
    BurglarsList = ((void *)0);
}

canonical_original_code:
void plUnprepareSys()
{
    plPrepareSys(0, 0, (1<<2));
    if (PersonsList)
 RemoveList(PersonsList);
    if (BurglarsList)
 RemoveList(BurglarsList);
    PersonsList = ((void *)0);
    BurglarsList = ((void *)0);
}


pcErrClose

decompiled_code:
void pcErrClose()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void pcErrClose(void)
{
}

canonical_original_code:
void pcErrClose()
{
}


DebugMsg

decompiled_code:
void DebugMsg(unsigned int a1, unsigned int a2, const char *a3, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-2E0h] BYREF
char s[512]; // [rsp+20h] [rbp-2C8h] BYREF

va_start(arg, a3);
vsprintf(s, a3, arg);
ErrDebugMsg(a1, (const char *)*(&moduleNames + a2), s);
}

canonical_decompiled_code:
void func3(unsigned int a1, unsigned int a2, const char *a3, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-2E0h] BYREF
char s[512]; // [rsp+20h] [rbp-2C8h] BYREF

va_start(arg, a3);
vsprintf(s, a3, arg);
func0(a1, (const char *)*(&moduleNames + a2), s);
}

original_code:
void DebugMsg(DebugE type, ErrorModuleE moduleId, const char *format, ...)
{
    va_list arglist;
    char txt[512];
    __builtin_va_start(arglist,format);
    vsprintf(txt, format, arglist);
    __builtin_va_end(arglist);
    ErrDebugMsg(type, moduleNames[moduleId], txt);
}

canonical_original_code:
void DebugMsg(enum DebugE type, enum ErrorModuleE moduleId, char *format, ...)
{
    __builtin_va_list arglist;
    char txt[512];
    __builtin_va_start(arglist,format);
    vsprintf(txt, format, arglist);
    __builtin_va_end(arglist);
    ErrDebugMsg(type, moduleNames[moduleId], txt);
}

variable_types: enum DebugE { ERR_ERROR=0, ERR_WARNING=1, ERR_DEBUG=2 }

variable_types: enum ErrorModuleE { ERROR_MODULE_BASE=3, ERROR_MODULE_TXT=4, ERROR_MODULE_DISK=5, ERROR_MODULE_MEMORY=6, ERROR_MODULE_DATABASE=7, ERROR_MODULE_GAMEPLAY=8, ERROR_MODULE_LOADSAVE=9, ERROR_MODULE_LANDSCAP=10, ERROR_MODULE_LIVING=11, ERROR_MODULE_PLANING=12, ERROR_MODULE_SOUND=13, ERROR_MODULE_PRESENT=14, ERROR_MODULE_GFX=15, ERROR_MODULE_INPUT=16, ERROR_MODULE_LAST=17 }

variable_types:
format
char *

variable_types:
txt
char [512]


ErrorMsg

decompiled_code:
void __fastcall __noreturn ErrorMsg(int a1, unsigned int a2, unsigned int a3)
{
DebugMsg(2u, a2, "Error %d", a3);
tcDone();
switch ( a1 )
{
case 2:
puts("You don't have enough memory!");
break;
case 3:
puts("Can't open file! Please install DER CLOU! again");
break;
case 1:
puts("Internal Error!");
break;
}
exit(-1);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(int a1, unsigned int a2, unsigned int a3)
{
func3(2u, a2, "Error %d", a3);
tcDone();
switch ( a1 )
{
case 2:
puts("You don't have enough memory!");
break;
case 3:
puts("Can't open file! Please install DER CLOU! again");
break;
case 1:
puts("Internal Error!");
break;
}
exit(-1);
}

original_code:
void ErrorMsg(ErrorE type, ErrorModuleE moduleId, U32 errorId)
{
    DebugMsg(ERR_DEBUG, moduleId, "Error %d", errorId);
    tcDone();
    switch (type) {
    case Internal_Error:
 printf("Internal Error!\n");
 break;
    case No_Mem:
 printf("You don't have enough memory!\n");
 break;
    case Disk_Defect:
 printf("Can't open file! Please install DER CLOU! again\n");
 break;
    default:
 break;
    }
    exit(-1);
}

canonical_original_code:
void ErrorMsg(enum ErrorE type, enum ErrorModuleE moduleId, unsigned int errorId)
{
    DebugMsg(ERR_DEBUG, moduleId, "Error %d", errorId);
    tcDone();
    switch (type) {
    case Internal_Error:
 printf("Internal Error!\n");
 break;
    case No_Mem:
 printf("You don't have enough memory!\n");
 break;
    case Disk_Defect:
 printf("Can't open file! Please install DER CLOU! again\n");
 break;
    default:
 break;
    }
    exit(-1);
}

variable_types: enum ErrorE { No_Error=0, Internal_Error=1, No_Mem=2, Disk_Defect=3, Insert_Disk=4, Lib_Error=5, Last_Error=6 }

variable_types:
errorId
unsigned int

user_defined_types: enum ErrorModuleE { ERROR_MODULE_BASE=3, ERROR_MODULE_TXT=4, ERROR_MODULE_DISK=5, ERROR_MODULE_MEMORY=6, ERROR_MODULE_DATABASE=7, ERROR_MODULE_GAMEPLAY=8, ERROR_MODULE_LOADSAVE=9, ERROR_MODULE_LANDSCAP=10, ERROR_MODULE_LIVING=11, ERROR_MODULE_PLANING=12, ERROR_MODULE_SOUND=13, ERROR_MODULE_PRESENT=14, ERROR_MODULE_GFX=15, ERROR_MODULE_INPUT=16, ERROR_MODULE_LAST=17 }


lsPrepareFromMemBySize

decompiled_code:
void *__fastcall lsPrepareFromMemBySize(char a1)
{
if ( a1 == 32 )
return &AddRPInMem;
if ( a1 == 48 )
return &LSObjectRPInMem;
if ( a1 != 16 )
_assert_fail("rp", "landscap/hardware.c", 0xE3u, "lsPrepareFromMemBySize");
return &AnimRPInMem;
}

canonical_decompiled_code:
void *__fastcall func0(char a1)
{
if ( a1 == 32 )
return &AddRPInMem;
if ( a1 == 48 )
return &LSObjectRPInMem;
if ( a1 != 16 )
_assert_fail("rp", "landscap/hardware.c", 0xE3u, "lsPrepareFromMemBySize");
return &AnimRPInMem;
}

original_code:
static MemRastPort *lsPrepareFromMemBySize(ubyte uch_Size)
{
    MemRastPort *rp = ((void *)0);
    switch (uch_Size) {
    case 16:
        rp = &AnimRPInMem;
 break;
    case 32:
        rp = &AddRPInMem;
 break;
    case 48:
        rp = &LSObjectRPInMem;
 break;
    }
    ((rp) ? (void) (0) : __assert_fail ("rp", "landscap/hardware.c", 227, __extension__ __PRETTY_FUNCTION__));
    return rp;
}

canonical_original_code:
static struct _MemRastPort *lsPrepareFromMemBySize(unsigned char uch_Size)
{
    struct _MemRastPort *rp = ((void *)0);
    switch (uch_Size) {
    case 16:
        rp = &AnimRPInMem;
 break;
    case 32:
        rp = &AddRPInMem;
 break;
    case 48:
        rp = &LSObjectRPInMem;
 break;
    }
    ((rp) ? (void) (0) : __assert_fail ("rp", "landscap/hardware.c", 227, __extension__ __PRETTY_FUNCTION__));
    return rp;
}

variable_types: struct _MemRastPort { unsigned short w; unsigned short h; unsigned char palette[768]; unsigned char *pixels; unsigned short collId; } *


lsShowEscapeCar

decompiled_code:
__int64 lsShowEscapeCar()
{
__int64 v0; // rbx

v0 = dbGetObject((unsigned int)*ls);
livPrepareAnims();
BobSet(*(unsigned __int16 *)(ls + 400LL), *(unsigned __int16 *)(v0 + 24), *(unsigned __int16 *)(v0 + 26), 14LL, 168LL);
return BobVis(*(unsigned __int16 *)(ls + 400LL));
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbx

v0 = dbGetObject((unsigned int)*ls);
livPrepareAnims();
BobSet(*(unsigned __int16 *)(ls + 400LL), *(unsigned __int16 *)(v0 + 24), *(unsigned __int16 *)(v0 + 26), 14LL, 168LL);
return BobVis(*(unsigned __int16 *)(ls + 400LL));
}

original_code:
void lsShowEscapeCar(void)
{
    Building b = dbGetObject(ls->ul_BuildingID);
    livPrepareAnims();
    BobSet(ls->us_EscapeCarBobId, b->CarXPos, b->CarYPos,
    14, 168);
    BobVis(ls->us_EscapeCarBobId);
}

canonical_original_code:
void lsShowEscapeCar()
{
    struct _Building *b = dbGetObject(ls->ul_BuildingID);
    livPrepareAnims();
    BobSet(ls->us_EscapeCarBobId, b->CarXPos, b->CarYPos,
    14, 168);
    BobVis(ls->us_EscapeCarBobId);
}

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

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


lsRefreshStatue

decompiled_code:
__int64 __fastcall lsRefreshStatue(__int64 a1)
{
void *v1; // rax
__int64 v3; // [rsp-10h] [rbp-18h]

*(_BYTE *)(ls + 407LL) = 64;
v1 = lsPrepareFromMem_isra_0(16);
gfxLSPutMsk(
v1,
16LL,
0LL,
(unsigned __int16)(*(_WORD *)(a1 + 2) + 7),
(unsigned __int16)(*(_WORD *)(a1 + 4) + 10),
16LL,
16LL);
*(_BYTE *)(ls + 407LL) = 0;
return v3;
}

original_code:
void lsRefreshStatue(LSObject lso)
{
    uword srcX, srcY, destX, destY, size;
    struct _LSObject dummy;
    MemRastPort *rp;
    ls->uch_ShowObjectMask = 0x40;
    size = 16;
    dummy.uch_Size = (ubyte) size;
    rp = lsPrepareFromMem(&dummy);
    srcX = 16;
    srcY = 0;
    destX = lso->us_DestX + 7;
    destY = lso->us_DestY + 10;
    gfxLSPutMsk(rp, srcX, srcY, destX, destY, size, size);
    ls->uch_ShowObjectMask = 0x0;
}

canonical_original_code:
void lsRefreshStatue(struct _LSObject *lso)
{
    unsigned short srcX; unsigned short srcY; unsigned short destX; unsigned short destY; unsigned short size;
    struct _LSObject dummy;
    struct _MemRastPort *rp;
    ls->uch_ShowObjectMask = 0x40;
    size = 16;
    dummy.uch_Size = (unsigned char) size;
    rp = lsPrepareFromMem(&dummy);
    srcX = 16;
    srcY = 0;
    destX = lso->us_DestX + 7;
    destY = lso->us_DestY + 10;
    gfxLSPutMsk(rp, srcX, srcY, destX, destY, size, size);
    ls->uch_ShowObjectMask = 0x0;
}

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:
srcX
unsigned short

variable_types:
srcY
unsigned short

variable_types:
destX
unsigned short

variable_types:
destY
unsigned short

variable_types:
size
unsigned short

user_defined_types: struct _MemRastPort { unsigned short w; unsigned short h; unsigned char palette[768]; unsigned char *pixels; unsigned short collId; }


lsBlitOneObject

decompiled_code:
__int64 __fastcall lsBlitOneObject(__int64 a1, unsigned __int16 a2, unsigned __int16 a3, unsigned __int16 a4, unsigned __int16 a5)
{
unsigned __int16 v5; // ax
__int64 v7; // [rsp-10h] [rbp-18h]

v5 = 288;
if ( a5 == 32 )
v5 = 320;
gfxLSPutMsk(
a1,
(unsigned __int16)(a2 % (unsigned __int16)(v5 / a5) * a5),
(unsigned __int16)(a5 * (a2 / (unsigned __int16)(v5 / a5))),
a3,
a4,
a5,
a5);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int16 a2, unsigned __int16 a3, unsigned __int16 a4, unsigned __int16 a5)
{
unsigned __int16 v5; // ax
__int64 v7; // [rsp-10h] [rbp-18h]

v5 = 288;
if ( a5 == 32 )
v5 = 320;
gfxLSPutMsk(
a1,
(unsigned __int16)(a2 % (unsigned __int16)(v5 / a5) * a5),
(unsigned __int16)(a5 * (a2 / (unsigned __int16)(v5 / a5))),
a3,
a4,
a5,
a5);
return v7;
}

original_code:
void lsBlitOneObject(MemRastPort *rp, U16 offsetFact, U16 dx, U16 dy, U16 size)
{
    uword srcWidth = 288;
    uword srcX, srcY, perRow;
    if (size == 32)
 srcWidth = 320;
    perRow = srcWidth / size;
    srcY = (offsetFact / perRow) * size;
    srcX = (offsetFact % perRow) * size;
    if (ls->uch_ShowObjectMask)
        gfxLSPutMsk(rp, srcX, srcY, dx, dy, size, size);
    else
        gfxLSPutMsk(rp, srcX, srcY, dx, dy, size, size);
}

canonical_original_code:
void lsBlitOneObject(struct _MemRastPort *rp, unsigned short offsetFact, unsigned short dx, unsigned short dy, unsigned short size)
{
    unsigned short srcWidth = 288;
    unsigned short srcX; unsigned short srcY; unsigned short perRow;
    if (size == 32)
 srcWidth = 320;
    perRow = srcWidth / size;
    srcY = (offsetFact / perRow) * size;
    srcX = (offsetFact % perRow) * size;
    if (ls->uch_ShowObjectMask)
        gfxLSPutMsk(rp, srcX, srcY, dx, dy, size, size);
    else
        gfxLSPutMsk(rp, srcX, srcY, dx, dy, size, size);
}

variable_types:
offsetFact
unsigned short

variable_types:
dx
unsigned short

variable_types:
dy
unsigned short

variable_types:
srcWidth
unsigned short

variable_types:
perRow
unsigned short


lsSetAlarmPict

decompiled_code:
__int64 __fastcall lsSetAlarmPict(__int64 a1)
{
__int64 result; // rax
void *v2; // rax
__int16 v3; // [rsp+8h] [rbp-10h] BYREF
__int16 v4; // [rsp+Ah] [rbp-Eh] BYREF
__int16 v5; // [rsp+Ch] [rbp-Ch] BYREF
__int16 v6[5]; // [rsp+Eh] [rbp-Ah] BYREF

result = lsCalcExactSize(a1, &v3, &v5, &v4, v6);
if ( (*(_BYTE *)(a1 + 12) & 1) != 0 )
{
v2 = lsPrepareFromMemBySize(16);
result = lsBlitOneObject(
(__int64)v2,
0x18u,
v3 + (unsigned __int16)((v4 - v3 - 6) / 2) - 1,
v5 + (unsigned __int16)((v6[0] - v5 - 7) / 2) + 2,
0x10u);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
void *v2; // rax
__int16 v3; // [rsp+8h] [rbp-10h] BYREF
__int16 v4; // [rsp+Ah] [rbp-Eh] BYREF
__int16 v5; // [rsp+Ch] [rbp-Ch] BYREF
__int16 v6[5]; // [rsp+Eh] [rbp-Ah] BYREF

result = lsCalcExactSize(a1, &v3, &v5, &v4, v6);
if ( (*(_BYTE *)(a1 + 12) & 1) != 0 )
{
v2 = func0(16);
result = func4(
(__int64)v2,
0x18u,
v3 + (unsigned __int16)((v4 - v3 - 6) / 2) - 1,
v5 + (unsigned __int16)((v6[0] - v5 - 7) / 2) + 2,
0x10u);
}
return result;
}

original_code:
static void lsSetAlarmPict(LSObject lso)
{
    U16 x0, x1, y0, y1, destx, desty;
    lsCalcExactSize(lso, &x0, &y0, &x1, &y1);
    if (lso->uch_Chained & 1) {
        MemRastPort *rp;
 rp = lsPrepareFromMemBySize(16);
 destx = ((word) x1 - (word) x0 - 6) / 2 + x0 - 1;
 desty = ((word) y1 - (word) y0 - 7) / 2 + y0 + 2;
 lsBlitOneObject(rp, 24, destx, desty, 16);
    }
}

canonical_original_code:
static void lsSetAlarmPict(struct _LSObject *lso)
{
    unsigned short x0; unsigned short x1; unsigned short y0; unsigned short y1; unsigned short destx; unsigned short desty;
    lsCalcExactSize(lso, &x0, &y0, &x1, &y1);
    if (lso->uch_Chained & 1) {
        struct _MemRastPort *rp;
 rp = lsPrepareFromMemBySize(16);
 destx = ((short) x1 - (short) x0 - 6) / 2 + x0 - 1;
 desty = ((short) y1 - (short) y0 - 7) / 2 + y0 + 2;
 lsBlitOneObject(rp, 24, destx, desty, 16);
    }
}

variable_types:
destx
unsigned short

variable_types:
desty
unsigned short

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