lsRefreshClosedDoors

decompiled_code:
__int64 __fastcall lsRefreshClosedDoors(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3, unsigned __int16 a4)
{
__int64 result; // rax
_QWORD *v5; // rbx
unsigned int v7; // er12
__int64 v8; // rbp

result = ls;
*(_BYTE *)(ls + 407LL) = 64;
v5 = **(_QWORD ***)(result + 336);
if ( *v5 )
{
v7 = a4;
do
{
v8 = v5[5];
result = lsIsInside(v8, a1, a2, a3, v7);
if ( (_BYTE)result )
{
result = lsIsObjectADoor(v8);
if ( (_BYTE)result )
{
if ( *(_BYTE *)(v8 + 11) == 1 )
result = lsShowOneObject(v8, 0x8AD0u, 0x8AD0u, 64);
}
}
v5 = (_QWORD *)*v5;
}
while ( *v5 );
}
*(_BYTE *)(ls + 407LL) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3, unsigned __int16 a4)
{
__int64 result; // rax
_QWORD *v5; // rbx
unsigned int v7; // er12
__int64 v8; // rbp

result = ls;
*(_BYTE *)(ls + 407LL) = 64;
v5 = **(_QWORD ***)(result + 336);
if ( *v5 )
{
v7 = a4;
do
{
v8 = v5[5];
result = lsIsInside(v8, a1, a2, a3, v7);
if ( (_BYTE)result )
{
result = lsIsObjectADoor(v8);
if ( (_BYTE)result )
{
if ( *(_BYTE *)(v8 + 11) == 1 )
result = func6(v8, 0x8AD0u, 0x8AD0u, 64);
}
}
v5 = (_QWORD *)*v5;
}
while ( *v5 );
}
*(_BYTE *)(ls + 407LL) = 0;
return result;
}

original_code:
static void lsRefreshClosedDoors(uword us_X0, uword us_Y0,
                                 uword us_X1, uword us_Y1)
{
    NODE *node;
    ls->uch_ShowObjectMask = 0x40;
    for (node = (NODE *) ((((NODE *)((&((ls->p_ObjectRetrieval))->Head)))->Succ)); (((NODE *)(node))->Succ);
  node = (NODE *) (((NODE *)(node))->Succ)) {
 LSObject lso = (((struct ObjectNode *)node)->data);
 if (lsIsInside(lso, us_X0, us_Y0, us_X1, us_Y1))
     if (lsIsObjectADoor(lso))
  if (lso->uch_Visible == ((ubyte) 1))
      lsShowOneObject(lso, -30000, -30000,
        64);
    }
    ls->uch_ShowObjectMask = 0x0;
}

canonical_original_code:
static void lsRefreshClosedDoors(unsigned short us_X0, unsigned short us_Y0, unsigned short us_X1, unsigned short us_Y1)
{
    struct Node *node;
    ls->uch_ShowObjectMask = 0x40;
    for (node = (struct Node *) ((((struct Node *)((&((ls->p_ObjectRetrieval))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  node = (struct Node *) (((struct Node *)(node))->Succ)) {
 struct _LSObject *lso = (((struct ObjectNode *)node)->data);
 if (lsIsInside(lso, us_X0, us_Y0, us_X1, us_Y1))
     if (lsIsObjectADoor(lso))
  if (lso->uch_Visible == ((unsigned char) 1))
      lsShowOneObject(lso, -30000, -30000,
        64);
    }
    ls->uch_ShowObjectMask = 0x0;
}

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

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


lsBlitFloor

repo: vcosta/derclou

decompiled_code:
__int64 __fastcall lsBlitFloor(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3)
{
return gfxLSPut(
&LSFloorRPInMem,
(32 * *(unsigned __int8 *)(*(_QWORD *)(ls + 288LL) + a1)) & 0x1E0,
0LL,
a2,
a3,
32LL,
32LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3)
{
return gfxLSPut(
&LSFloorRPInMem,
(32 * *(unsigned __int8 *)(*(_QWORD *)(ls + 288LL) + a1)) & 0x1E0,
0LL,
a2,
a3,
32LL,
32LL);
}

original_code:
void lsBlitFloor(uword floorIndex, uword destx, uword desty)
{
    MemRastPort *rp = &LSFloorRPInMem;
    uword srcX;
    srcX =
 ((ls->p_CurrFloor[floorIndex].uch_FloorType) & 0xf) * 32;
    gfxLSPut(rp, srcX, 0, destx, desty, 32, 32);
}

canonical_original_code:
void lsBlitFloor(unsigned short floorIndex, unsigned short destx, unsigned short desty)
{
    struct _MemRastPort *rp = &LSFloorRPInMem;
    unsigned short srcX;
    srcX =
 ((ls->p_CurrFloor[floorIndex].uch_FloorType) & 0xf) * 32;
    gfxLSPut(rp, srcX, 0, destx, desty, 32, 32);
}

variable_types:
floorIndex
unsigned short

variable_types:
destx
unsigned short

variable_types:
desty
unsigned short

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

variable_types:
srcX
unsigned short

return_type: void


lsSetViewPort

decompiled_code:
__int64 __fastcall lsSetViewPort(unsigned __int16 a1, unsigned __int16 a2)
{
return gfxNCH4SetViewPort(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned __int16 a1, unsigned __int16 a2)
{
return gfxNCH4SetViewPort(a1, a2);
}

original_code:
void lsSetViewPort(uword x, uword y)
{
    gfxNCH4SetViewPort(x, y);
}

canonical_original_code:
void lsSetViewPort(unsigned short x, unsigned short y)
{
    gfxNCH4SetViewPort(x, y);
}

variable_types:
x
unsigned short

variable_types:
y
unsigned short


lsInitGfx

decompiled_code:
__int64 lsInitGfx()
{
gfxSetVideoMode(2LL);
lsSetViewPort(0, 0);
return gfxNCH4SetSplit(256LL);
}

canonical_decompiled_code:
__int64 func11()
{
gfxSetVideoMode(2LL);
func10(0, 0);
return gfxNCH4SetSplit(256LL);
}

original_code:
void lsInitGfx(void)
{
    gfxSetVideoMode(2);
    lsSetViewPort(0, 0);
    gfxNCH4SetSplit(256);
}

canonical_original_code:
void lsInitGfx()
{
    gfxSetVideoMode(2);
    lsSetViewPort(0, 0);
    gfxNCH4SetSplit(256);
}


lsCloseGfx

decompiled_code:
__int64 lsCloseGfx()
{
gfxSetVideoMode(1LL);
tcSetPermanentColors();
return inpMousePtrOn();
}

canonical_decompiled_code:
__int64 func12()
{
gfxSetVideoMode(1LL);
tcSetPermanentColors();
return inpMousePtrOn();
}

original_code:
void lsCloseGfx(void)
{
    gfxSetVideoMode(1);
    tcSetPermanentColors();
    inpMousePtrOn();
}

canonical_original_code:
void lsCloseGfx()
{
    gfxSetVideoMode(1);
    tcSetPermanentColors();
    inpMousePtrOn();
}


lsScrollCorrectData

decompiled_code:
__int64 __fastcall lsScrollCorrectData(__int16 a1, __int16 a2)
{
_WORD *v4; // rax
unsigned __int16 v5; // di
unsigned __int16 v6; // si

v4 = (_WORD *)ls;
v5 = *(_WORD *)(ls + 14LL) + a1;
*(_WORD *)(ls + 14LL) = v5;
v6 = v4[8] + a2;
v4[8] = v6;
v4[198] = a1;
v4[199] = a2;
return livSetVisLScape(v5, v6);
}

original_code:
void lsScrollCorrectData(S32 dx, S32 dy)
{
    ls->us_WindowXPos += dx;
    ls->us_WindowYPos += dy;
    ls->us_RasInfoScrollX = (word) dx;
    ls->us_RasInfoScrollY = (word) dy;
    livSetVisLScape(ls->us_WindowXPos, ls->us_WindowYPos);
}

canonical_original_code:
void lsScrollCorrectData(int dx, int dy)
{
    ls->us_WindowXPos += dx;
    ls->us_WindowYPos += dy;
    ls->us_RasInfoScrollX = (short) dx;
    ls->us_RasInfoScrollY = (short) dy;
    livSetVisLScape(ls->us_WindowXPos, ls->us_WindowYPos);
}

variable_types: dx int

variable_types: dy int


lsDoScroll

decompiled_code:
__int64 lsDoScroll()
{
__int64 result; // rax
__int64 v1; // rdx

result = gfxNCH4Scroll((unsigned int)*(__int16 *)(ls + 396LL), (unsigned int)*(__int16 *)(ls + 398LL));
v1 = ls;
*(_WORD *)(ls + 396LL) = 0;
*(_WORD *)(v1 + 398) = 0;
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 result; // rax
__int64 v1; // rdx

result = gfxNCH4Scroll((unsigned int)*(__int16 *)(ls + 396LL), (unsigned int)*(__int16 *)(ls + 398LL));
v1 = ls;
*(_WORD *)(ls + 396LL) = 0;
*(_WORD *)(v1 + 398) = 0;
return result;
}

original_code:
void lsDoScroll(void)
{
    gfxNCH4Scroll(ls->us_RasInfoScrollX, ls->us_RasInfoScrollY);
    ls->us_RasInfoScrollX = 0;
    ls->us_RasInfoScrollY = 0;
}

canonical_original_code:
void lsDoScroll()
{
    gfxNCH4Scroll(ls->us_RasInfoScrollX, ls->us_RasInfoScrollY);
    ls->us_RasInfoScrollX = 0;
    ls->us_RasInfoScrollY = 0;
}


DoneTaxi

decompiled_code:
__int64 DoneTaxi()
{
__int64 v0; // r12
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax
__int64 **i; // rbp
unsigned int v5; // ebx
__int64 v6; // rax
unsigned int v7; // ebx
int v8; // eax
char v9; // si
unsigned __int8 v10; // bl
__int64 v11; // rax
_BYTE v13[256]; // [rsp+0h] [rbp-218h] BYREF
char s[280]; // [rsp+100h] [rbp-118h] BYREF

v0 = CreateList();
v1 = dbGetObject(9821LL);
v2 = dbGetObject(9801LL);
SetP(v2, 5LL, v1, 0xFFFFFFFFLL);
SetObjectListAttr(0LL, 9903LL);
v3 = dbGetObject(9801LL);
AskAll(v3, 16LL, &BuildObjectList);
for ( i = (__int64 **)*ObjectList; *i; i = (__int64 **)*i )
{
v5 = *(_DWORD *)i[5];
v6 = GetNthNode(*(_QWORD *)(film + 24LL), v5);
sprintf(s, "*%s", *(const char **)(v6 + 16));
*(_DWORD *)(CreateNode(v0, 48LL, s) + 32) = v5 + 1;
}
v7 = (unsigned __int8)i_0;
v8 = GetNrOfNodes(v0);
v9 = i_0;
if ( v7 >= v8 - 1 )
v9 = GetNrOfNodes(v0) - 1;
i_0 = v9;
txtGetNthString(2LL, "NO_CHOICE", 0LL, v13);
ExpandObjectList(v0, v13);
v10 = Bubble(v0, (unsigned __int8)i_0, 0LL, 0LL);
if ( (unsigned __int8)ChoiceOk(v10, 255LL, v0) )
{
i_0 = v10;
v11 = GetNthNode(v0, v10);
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene((unsigned int)(*(_DWORD *)(v11 + 32) - 1));
}
else
{
Say(2LL, 0LL, 7LL, "LOVELY_TAXI");
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene(*(unsigned int *)(film + 56LL));
}
*((_BYTE *)&SceneArgs + 8) = 1;
SceneArgs = 0;
RemoveList(v0);
return gfxChangeColors(l_gc, 2LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // r12
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax
__int64 **i; // rbp
unsigned int v5; // ebx
__int64 v6; // rax
unsigned int v7; // ebx
int v8; // eax
char v9; // si
unsigned __int8 v10; // bl
__int64 v11; // rax
_BYTE v13[256]; // [rsp+0h] [rbp-218h] BYREF
char s[280]; // [rsp+100h] [rbp-118h] BYREF

v0 = CreateList();
v1 = dbGetObject(9821LL);
v2 = dbGetObject(9801LL);
SetP(v2, 5LL, v1, 0xFFFFFFFFLL);
SetObjectListAttr(0LL, 9903LL);
v3 = dbGetObject(9801LL);
AskAll(v3, 16LL, &BuildObjectList);
for ( i = (__int64 **)*ObjectList; *i; i = (__int64 **)*i )
{
v5 = *(_DWORD *)i[5];
v6 = GetNthNode(*(_QWORD *)(film + 24LL), v5);
sprintf(s, "*%s", *(const char **)(v6 + 16));
*(_DWORD *)(CreateNode(v0, 48LL, s) + 32) = v5 + 1;
}
v7 = (unsigned __int8)i_0;
v8 = GetNrOfNodes(v0);
v9 = i_0;
if ( v7 >= v8 - 1 )
v9 = GetNrOfNodes(v0) - 1;
i_0 = v9;
txtGetNthString(2LL, "NO_CHOICE", 0LL, v13);
ExpandObjectList(v0, v13);
v10 = Bubble(v0, (unsigned __int8)i_0, 0LL, 0LL);
if ( (unsigned __int8)ChoiceOk(v10, 255LL, v0) )
{
i_0 = v10;
v11 = GetNthNode(v0, v10);
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene((unsigned int)(*(_DWORD *)(v11 + 32) - 1));
}
else
{
Say(2LL, 0LL, 7LL, "LOVELY_TAXI");
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene(*(unsigned int *)(film + 56LL));
}
*((_BYTE *)&SceneArgs + 8) = 1;
SceneArgs = 0;
RemoveList(v0);
return gfxChangeColors(l_gc, 2LL, 4LL, 0LL);
}

original_code:
void DoneTaxi(void)
{
    static ubyte i = 0;
    ubyte j;
    char name[256], exp[256];
    LIST *locs = CreateList();
    struct ObjectNode *n, *new;
    U32 locNr;
    Location loc;
    SetP (dbGetObject (9801U), 5, dbGetObject (9821U), (4294967295U));
    { SetObjectListAttr ((0),9903L); AskAll (dbGetObject (9801U), 16, BuildObjectList); };
    for (n = (struct ObjectNode *) ((((NODE *)((&((ObjectList))->Head)))->Succ)); (((NODE *)(n))->Succ);
  n = (struct ObjectNode *) (((NODE *)(n))->Succ)) {
 loc = (((struct ObjectNode *)n)->data);
 locNr = ((Location) loc)->LocationNr;
 sprintf(name, "*%s", (((NODE *)(GetNthNode(film->loc_names, locNr)))->Name));
 new = (struct ObjectNode *) CreateNode(locs, sizeof(struct ObjectNode), name);
 new->nr = locNr + 1;
    }
    i = ((i) < (GetNrOfNodes(locs) - 1) ? (i) : (GetNrOfNodes(locs) - 1));
    (txtGetNthString(2U, "NO_CHOICE", 0, exp));
    ExpandObjectList(locs, exp);
    if (ChoiceOk(j = Bubble(locs, i, 0L, 0L), ((U8)-1), locs)) {
 i = j;
 locNr = (((struct ObjectNode *)GetNthNode(locs, i))->nr) - 1;
 SceneArgs.ReturnValue = (U32)GetLocScene(locNr)->EventNr;
    } else {
 Say(2U, 0, 7, "LOVELY_TAXI");
 SceneArgs.ReturnValue = (U32)GetLocScene((film->alter_Ort))->EventNr;
    }
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.Moeglichkeiten = 0L;
    RemoveList(locs);
    gfxChangeColors(l_gc, 2L, 4, 0L);
}

canonical_original_code:
void DoneTaxi()
{
    static unsigned char i = 0;
    unsigned char j;
    char name[256]; char exp[256];
    struct List *locs = CreateList();
    struct ObjectNode *n; struct ObjectNode *new;
    unsigned int locNr;
    struct _Location *loc;
    SetP (dbGetObject (9801U), 5, dbGetObject (9821U), (4294967295U));
    { SetObjectListAttr ((0),9903L); AskAll (dbGetObject (9801U), 16, BuildObjectList); };
    for (n = (struct ObjectNode *) ((((struct Node *)((&((ObjectList))->Head)))->Succ)); (((struct Node *)(n))->Succ);
  n = (struct ObjectNode *) (((struct Node *)(n))->Succ)) {
 loc = (((struct ObjectNode *)n)->data);
 locNr = ((struct _Location *) loc)->LocationNr;
 sprintf(name, "*%s", (((struct Node *)(GetNthNode(film->loc_names, locNr)))->Name));
 new = (struct ObjectNode *) CreateNode(locs, sizeof(struct ObjectNode), name);
 new->nr = locNr + 1;
    }
    i = ((i) < (GetNrOfNodes(locs) - 1) ? (i) : (GetNrOfNodes(locs) - 1));
    (txtGetNthString(2U, "NO_CHOICE", 0, exp));
    ExpandObjectList(locs, exp);
    if (ChoiceOk(j = Bubble(locs, i, 0L, 0L), ((U8)-1), locs)) {
 i = j;
 locNr = (((struct ObjectNode *)GetNthNode(locs, i))->nr) - 1;
 SceneArgs.ReturnValue = (unsigned int)GetLocScene(locNr)->EventNr;
    } else {
 Say(2U, 0, 7, "LOVELY_TAXI");
 SceneArgs.ReturnValue = (unsigned int)GetLocScene((film->alter_Ort))->EventNr;
    }
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.Moeglichkeiten = 0L;
    RemoveList(locs);
    gfxChangeColors(l_gc, 2L, 4, 0L);
}

variable_types:
i
unsigned char

variable_types:
j
unsigned char

variable_types:
name
char [256]

variable_types:
exp
char [256]

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

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

variable_types:
locNr
unsigned int

variable_types: struct _Location { unsigned int LocationNr; unsigned short OpenFromMinute; unsigned short OpenToMinute; } *

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

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


DoneInsideHouse

decompiled_code:
__int64 DoneInsideHouse()
{
__int64 v0; // r13
unsigned int v1; // er12
__int64 v2; // rax
__int64 *i; // rbx
unsigned int v4; // ebp
__int64 v5; // rax
unsigned int v6; // ebp
__int64 v7; // r14
unsigned __int8 v8; // bl
unsigned int v9; // eax
__int64 v10; // rdi
__int64 **j; // r12

v0 = txtGoKey(0LL, "Mainmenu");
*((_DWORD *)&SceneArgs + 1) = 0;
*((_BYTE *)&SceneArgs + 8) = 1;
ShowMenuBackground();
v1 = GetObjNrOfBuilding((unsigned int)(*(_DWORD *)(film + 52LL) + 1));
SetObjectListAttr(0LL, 509992LL);
v2 = dbGetObject(v1);
AskAll(v2, 500002LL, &BuildObjectList);
for ( i = (__int64 *)*ObjectList; *i; i = (__int64 *)*i )
{
v4 = *((_DWORD *)i + 8);
lsInitRelations(v4);
lsInitObjectDB(v1, v4);
}
SetObjectListAttr(0LL, 509992LL);
v5 = dbGetObject(v1);
AskAll(v5, 500001LL, &BuildObjectList);
v6 = *(_DWORD *)(*ObjectList + 32LL);
lsLoadGlobalData(v1, v6);
lsSetRelations(v6);
v7 = *(unsigned __int8 *)(dbGetObject(v1) + 8);
lsShowRaster(v6, v7);
gfxShow(154LL, 6LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
v8 = 0;
while ( !*((_DWORD *)&SceneArgs + 1) )
{
if ( SceneArgs )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v8 = Menu(v0, SceneArgs, v8, 0LL, 0LL);
inpTurnFunctionKey(1LL);
inpTurnESC(1LL);
if ( v8 )
{
if ( v8 == 3 )
{
tcInsideOfHouse(v1, v6, (unsigned int)v7);
ShowMenuBackground();
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
AddVTime(19LL);
ShowTime(0LL);
}
else
{
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v8));
}
}
else
{
v9 = tcGoInsideOfHouse(v1);
v6 = v9;
if ( v9 )
{
lsSetRelations(v9);
lsShowRaster(v6, (unsigned int)v7);
}
else
{
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)(**(_QWORD **)(GetCurrentScene() + 32) + 32LL);
}
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
}
}
}
SetObjectListAttr(0LL, 509992LL);
v10 = dbGetObject(v1);
AskAll(v10, 500002LL, &BuildObjectList);
for ( j = (__int64 **)*ObjectList; *j; j = (__int64 **)*j )
lsDoneObjectDB(*((unsigned int *)j + 8));
StopAnim();
gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
return RemoveList(v0);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // r13
unsigned int v1; // er12
__int64 v2; // rax
__int64 *i; // rbx
unsigned int v4; // ebp
__int64 v5; // rax
unsigned int v6; // ebp
__int64 v7; // r14
unsigned __int8 v8; // bl
unsigned int v9; // eax
__int64 v10; // rdi
__int64 **j; // r12

v0 = txtGoKey(0LL, "Mainmenu");
*((_DWORD *)&SceneArgs + 1) = 0;
*((_BYTE *)&SceneArgs + 8) = 1;
ShowMenuBackground();
v1 = GetObjNrOfBuilding((unsigned int)(*(_DWORD *)(film + 52LL) + 1));
SetObjectListAttr(0LL, 509992LL);
v2 = dbGetObject(v1);
AskAll(v2, 500002LL, &BuildObjectList);
for ( i = (__int64 *)*ObjectList; *i; i = (__int64 *)*i )
{
v4 = *((_DWORD *)i + 8);
lsInitRelations(v4);
lsInitObjectDB(v1, v4);
}
SetObjectListAttr(0LL, 509992LL);
v5 = dbGetObject(v1);
AskAll(v5, 500001LL, &BuildObjectList);
v6 = *(_DWORD *)(*ObjectList + 32LL);
lsLoadGlobalData(v1, v6);
lsSetRelations(v6);
v7 = *(unsigned __int8 *)(dbGetObject(v1) + 8);
lsShowRaster(v6, v7);
gfxShow(154LL, 6LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
v8 = 0;
while ( !*((_DWORD *)&SceneArgs + 1) )
{
if ( SceneArgs )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v8 = Menu(v0, SceneArgs, v8, 0LL, 0LL);
inpTurnFunctionKey(1LL);
inpTurnESC(1LL);
if ( v8 )
{
if ( v8 == 3 )
{
tcInsideOfHouse(v1, v6, (unsigned int)v7);
ShowMenuBackground();
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
AddVTime(19LL);
ShowTime(0LL);
}
else
{
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v8));
}
}
else
{
v9 = tcGoInsideOfHouse(v1);
v6 = v9;
if ( v9 )
{
lsSetRelations(v9);
lsShowRaster(v6, (unsigned int)v7);
}
else
{
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)(**(_QWORD **)(GetCurrentScene() + 32) + 32LL);
}
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
}
}
}
SetObjectListAttr(0LL, 509992LL);
v10 = dbGetObject(v1);
AskAll(v10, 500002LL, &BuildObjectList);
for ( j = (__int64 **)*ObjectList; *j; j = (__int64 **)*j )
lsDoneObjectDB(*((unsigned int *)j + 8));
StopAnim();
gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
return RemoveList(v0);
}

original_code:
void DoneInsideHouse(void)
{
    LIST *menu = txtGoKey(0U, "Mainmenu");
    U32 choice, buildingID, areaID;
    ubyte activ = 0, perc;
    NODE *node;
    SceneArgs.ReturnValue = 0;
    SceneArgs.Ueberschrieben = 1;
    ShowMenuBackground();
    buildingID = GetObjNrOfBuilding((film->akt_Ort) + 1);
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (NODE *) ((((NODE *)((&((ObjectList))->Head)))->Succ)); (((NODE *)(node))->Succ);
  node = (NODE *) (((NODE *)(node))->Succ)) {
 areaID = (((struct ObjectNode *)node)->nr);
 lsInitRelations(areaID);
 lsInitObjectDB(buildingID, areaID);
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500001, BuildObjectList); };
    areaID = (((struct ObjectNode *)((((NODE *)((&((ObjectList))->Head)))->Succ)))->nr);
    lsLoadGlobalData(buildingID, areaID);
    lsSetRelations(areaID);
    perc = ((Building) dbGetObject(buildingID))->Exactlyness;
    lsShowRaster(areaID, perc);
    gfxShow(154, 4 | 2, 5, -1, -1);
    tcRefreshLocationInTitle((film->akt_Ort));
    while (!SceneArgs.ReturnValue) {
 if (SceneArgs.Moeglichkeiten) {
     inpTurnFunctionKey(0);
     inpTurnESC(0);
     activ =
  Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
     inpTurnFunctionKey(1);
     inpTurnESC(1);
     choice = (U32) 1L << activ;
     switch (choice) {
     case (1<<3):
  tcInsideOfHouse(buildingID, areaID, perc);
  ShowMenuBackground();
  tcRefreshLocationInTitle((film->akt_Ort));
  AddVTime(19);
  ShowTime(0);
  break;
     case (1):
  if (!(areaID = tcGoInsideOfHouse(buildingID)))
      SceneArgs.ReturnValue =
   (U32) (((struct TCEventNode
     *) (((((NODE *)((&(((GetCurrentScene()-> std_succ)))->Head)))->Succ))))->EventNr);
  else {
      lsSetRelations(areaID);
      lsShowRaster(areaID, perc);
  }
  tcRefreshLocationInTitle((film->akt_Ort));
  break;
     default:
  SceneArgs.ReturnValue = StdHandle(choice);
  break;
     }
 }
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (NODE *) ((((NODE *)((&((ObjectList))->Head)))->Succ)); (((NODE *)(node))->Succ);
  node = (NODE *) (((NODE *)(node))->Succ))
 lsDoneObjectDB((((struct ObjectNode *)node)->nr));
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
    RemoveList(menu);
}

canonical_original_code:
void DoneInsideHouse()
{
    struct List *menu = txtGoKey(0U, "Mainmenu");
    unsigned int choice; unsigned int buildingID; unsigned int areaID;
    unsigned char activ = 0; unsigned char perc;
    struct Node *node;
    SceneArgs.ReturnValue = 0;
    SceneArgs.Ueberschrieben = 1;
    ShowMenuBackground();
    buildingID = GetObjNrOfBuilding((film->akt_Ort) + 1);
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (struct Node *) ((((struct Node *)((&((ObjectList))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  node = (struct Node *) (((struct Node *)(node))->Succ)) {
 areaID = (((struct ObjectNode *)node)->nr);
 lsInitRelations(areaID);
 lsInitObjectDB(buildingID, areaID);
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500001, BuildObjectList); };
    areaID = (((struct ObjectNode *)((((struct Node *)((&((ObjectList))->Head)))->Succ)))->nr);
    lsLoadGlobalData(buildingID, areaID);
    lsSetRelations(areaID);
    perc = ((struct _Building *) dbGetObject(buildingID))->Exactlyness;
    lsShowRaster(areaID, perc);
    gfxShow(154, 4 | 2, 5, -1, -1);
    tcRefreshLocationInTitle((film->akt_Ort));
    while (!SceneArgs.ReturnValue) {
 if (SceneArgs.Moeglichkeiten) {
     inpTurnFunctionKey(0);
     inpTurnESC(0);
     activ =
  Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
     inpTurnFunctionKey(1);
     inpTurnESC(1);
     choice = (unsigned int) 1L << activ;
     switch (choice) {
     case (1<<3):
  tcInsideOfHouse(buildingID, areaID, perc);
  ShowMenuBackground();
  tcRefreshLocationInTitle((film->akt_Ort));
  AddVTime(19);
  ShowTime(0);
  break;
     case (1):
  if (!(areaID = tcGoInsideOfHouse(buildingID)))
      SceneArgs.ReturnValue =
   (U32) (((struct TCEventNode *) (((((struct Node *)((&(((GetCurrentScene()-> std_succ)))->Head)))->Succ))))->EventNr);
  else {
      lsSetRelations(areaID);
      lsShowRaster(areaID, perc);
  }
  tcRefreshLocationInTitle((film->akt_Ort));
  break;
     default:
  SceneArgs.ReturnValue = StdHandle(choice);
  break;
     }
 }
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (struct Node *) ((((struct Node *)((&((ObjectList))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  node = (struct Node *) (((struct Node *)(node))->Succ))
 lsDoneObjectDB((((struct ObjectNode *)node)->nr));
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
    RemoveList(menu);
}

variable_types:
choice
unsigned int

variable_types:
buildingID
unsigned int

variable_types:
areaID
unsigned int

variable_types:
activ
unsigned char

variable_types:
perc
unsigned char

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

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

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

user_defined_types: enum RouteE { Innenstadt=0, Stadt=1, Landstrasse=2, Autobahn=3 }


DoneTools

decompiled_code:
__int64 DoneTools()
{
__int64 v0; // rbp
unsigned int v1; // eax
__int64 v2; // rbx
unsigned int v3; // eax
__int64 v4; // rax
unsigned __int8 v5; // bl
__int64 v6; // rbx
unsigned int v7; // eax
__int64 v8; // rax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
v1 = getKey(11LL);
tcMoveAPerson(9824LL, v1);
v2 = dbGetObject(9824LL);
v3 = getKey(2LL);
v4 = dbGetObject(v3);
UnSet(v4, 10LL, v2);
if ( !*((_DWORD *)&SceneArgs + 1) )
{
v5 = 0;
do
{
tcPersonIsHere();
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v5 = Menu(v0, SceneArgs, v5, 0LL, 0LL);
inpTurnESC(1LL);
if ( v5 == 2 )
{
tcToolsShop();
AddVTime(9LL);
ShowTime(0LL);
}
else
{
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v5));
}
}
while ( !*((_DWORD *)&SceneArgs + 1) );
}
inpTurnFunctionKey(1LL);
v6 = dbGetObject(9824LL);
v7 = getKey(2LL);
v8 = dbGetObject(v7);
SetP(v8, 10LL, v6, 0xFFFFFFFFLL);
RemoveList(v0);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbp
unsigned int v1; // eax
__int64 v2; // rbx
unsigned int v3; // eax
__int64 v4; // rax
unsigned __int8 v5; // bl
__int64 v6; // rbx
unsigned int v7; // eax
__int64 v8; // rax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
v1 = getKey(11LL);
tcMoveAPerson(9824LL, v1);
v2 = dbGetObject(9824LL);
v3 = getKey(2LL);
v4 = dbGetObject(v3);
UnSet(v4, 10LL, v2);
if ( !*((_DWORD *)&SceneArgs + 1) )
{
v5 = 0;
do
{
tcPersonIsHere();
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v5 = Menu(v0, SceneArgs, v5, 0LL, 0LL);
inpTurnESC(1LL);
if ( v5 == 2 )
{
tcToolsShop();
AddVTime(9LL);
ShowTime(0LL);
}
else
{
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v5));
}
}
while ( !*((_DWORD *)&SceneArgs + 1) );
}
inpTurnFunctionKey(1LL);
v6 = dbGetObject(9824LL);
v7 = getKey(2LL);
v8 = dbGetObject(v7);
SetP(v8, 10LL, v6, 0xFFFFFFFFLL);
RemoveList(v0);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneTools(void)
{
    ubyte activ = 0;
    U32 choice = 0;
    LIST *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    tcMoveAPerson(9824U, getKey(_Location_Tools_Shop));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U));
    while (!SceneArgs.ReturnValue) {
 tcPersonIsHere();
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 choice = (U32) 1L << (activ);
 if (choice == (1<<2)) {
     tcToolsShop();
     AddVTime(9);
     ShowTime(0);
 } else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    inpTurnFunctionKey(1);
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneTools()
{
    unsigned char activ = 0;
    unsigned int choice = 0;
    struct List *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    tcMoveAPerson(9824U, getKey(_Location_Tools_Shop));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U));
    while (!SceneArgs.ReturnValue) {
 tcPersonIsHere();
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 choice = (unsigned int) 1L << (activ);
 if (choice == (1<<2)) {
     tcToolsShop();
     AddVTime(9);
     ShowTime(0);
 } else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    inpTurnFunctionKey(1);
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

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


DoneDealer

decompiled_code:
__int64 DoneDealer()
{
__int64 v0; // rbp
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rbx
unsigned int v5; // eax
__int64 v6; // rax
__int64 v7; // rbx
unsigned int v8; // eax
__int64 v9; // rax
__int64 v10; // rbx
unsigned int v11; // eax
__int64 v12; // rax
unsigned __int8 v13; // bl
__int64 v14; // rbx
unsigned int v15; // eax
__int64 v16; // rax
__int64 v17; // rbx
unsigned int v18; // eax
__int64 v19; // rax
__int64 v20; // rbx
unsigned int v21; // eax
__int64 v22; // rax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v1 = getKey(17LL);
tcMoveAPerson(9814LL, v1);
v2 = getKey(18LL);
tcMoveAPerson(9825LL, v2);
v3 = getKey(16LL);
tcMoveAPerson(9820LL, v3);
v4 = dbGetObject(9814LL);
v5 = getKey(2LL);
v6 = dbGetObject(v5);
UnSet(v6, 10LL, v4);
v7 = dbGetObject(9825LL);
v8 = getKey(2LL);
v9 = dbGetObject(v8);
UnSet(v9, 10LL, v7);
v10 = dbGetObject(9820LL);
v11 = getKey(2LL);
v12 = dbGetObject(v11);
UnSet(v12, 10LL, v10);
if ( !*((_DWORD *)&SceneArgs + 1) )
{
v13 = 0;
do
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v13 = Menu(v0, SceneArgs, v13, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v13 == 2 )
tcDealerDlg();
else
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v13));
}
while ( !*((_DWORD *)&SceneArgs + 1) );
}
v14 = dbGetObject(9814LL);
v15 = getKey(2LL);
v16 = dbGetObject(v15);
SetP(v16, 10LL, v14, 0xFFFFFFFFLL);
v17 = dbGetObject(9825LL);
v18 = getKey(2LL);
v19 = dbGetObject(v18);
SetP(v19, 10LL, v17, 0xFFFFFFFFLL);
v20 = dbGetObject(9820LL);
v21 = getKey(2LL);
v22 = dbGetObject(v21);
SetP(v22, 10LL, v20, 0xFFFFFFFFLL);
RemoveList(v0);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // eax
__int64 v4; // rbx
unsigned int v5; // eax
__int64 v6; // rax
__int64 v7; // rbx
unsigned int v8; // eax
__int64 v9; // rax
__int64 v10; // rbx
unsigned int v11; // eax
__int64 v12; // rax
unsigned __int8 v13; // bl
__int64 v14; // rbx
unsigned int v15; // eax
__int64 v16; // rax
__int64 v17; // rbx
unsigned int v18; // eax
__int64 v19; // rax
__int64 v20; // rbx
unsigned int v21; // eax
__int64 v22; // rax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v1 = getKey(17LL);
tcMoveAPerson(9814LL, v1);
v2 = getKey(18LL);
tcMoveAPerson(9825LL, v2);
v3 = getKey(16LL);
tcMoveAPerson(9820LL, v3);
v4 = dbGetObject(9814LL);
v5 = getKey(2LL);
v6 = dbGetObject(v5);
UnSet(v6, 10LL, v4);
v7 = dbGetObject(9825LL);
v8 = getKey(2LL);
v9 = dbGetObject(v8);
UnSet(v9, 10LL, v7);
v10 = dbGetObject(9820LL);
v11 = getKey(2LL);
v12 = dbGetObject(v11);
UnSet(v12, 10LL, v10);
if ( !*((_DWORD *)&SceneArgs + 1) )
{
v13 = 0;
do
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v13 = Menu(v0, SceneArgs, v13, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v13 == 2 )
tcDealerDlg();
else
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v13));
}
while ( !*((_DWORD *)&SceneArgs + 1) );
}
v14 = dbGetObject(9814LL);
v15 = getKey(2LL);
v16 = dbGetObject(v15);
SetP(v16, 10LL, v14, 0xFFFFFFFFLL);
v17 = dbGetObject(9825LL);
v18 = getKey(2LL);
v19 = dbGetObject(v18);
SetP(v19, 10LL, v17, 0xFFFFFFFFLL);
v20 = dbGetObject(9820LL);
v21 = getKey(2LL);
v22 = dbGetObject(v21);
SetP(v22, 10LL, v20, 0xFFFFFFFFLL);
RemoveList(v0);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneDealer(void)
{
    ubyte activ = 0;
    U32 choice = 0;
    LIST *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0L;
    tcMoveAPerson(9814U, getKey(_Location_Maloya));
    tcMoveAPerson(9825U, getKey(_Location_Pooly));
    tcMoveAPerson(9820U, getKey(_Location_Parker));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U));
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (U32) 1L << (activ);
 if (choice == (1<<2))
     tcDealerDlg();
 else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneDealer()
{
    unsigned char activ = 0;
    unsigned int choice = 0;
    struct List *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0L;
    tcMoveAPerson(9814U, getKey(_Location_Maloya));
    tcMoveAPerson(9825U, getKey(_Location_Pooly));
    tcMoveAPerson(9820U, getKey(_Location_Parker));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U));
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (unsigned int) 1L << (activ);
 if (choice == (1<<2))
     tcDealerDlg();
 else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}


DoneParking

decompiled_code:
__int64 DoneParking()
{
__int64 v0; // r12
__int64 v1; // rbp
unsigned __int16 *v2; // r14
unsigned __int8 v3; // bl
unsigned int v4; // eax
char v5; // al

v0 = txtGoKey(2LL, "PARKING");
v1 = txtGoKey(0LL, "Mainmenu");
v2 = (unsigned __int16 *)dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v3 = 0;
do
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v3 = Menu(v1, SceneArgs, v3, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v3 == 2 )
{
while ( 1 )
{
v5 = Bubble(v0, 0LL, 0LL, 0LL);
if ( !v5 )
{
tcBuyCar();
AddVTime(9LL);
goto LABEL_7;
}
if ( v5 != 1 )
goto LABEL_7;
v4 = tcChooseCar(27LL);
if ( !v4 )
break;
tcSellCar(v4);
AddVTime(11LL);
}
Say(2LL, 0LL, *v2, "SELL_HERE");
LABEL_7:
ShowTime(0LL);
}
else
{
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL << v3);
inpTurnESC(1LL);
}
}
while ( !*((_DWORD *)&SceneArgs + 1) );
RemoveList(v0);
RemoveList(v1);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // r12
__int64 v1; // rbp
unsigned __int16 *v2; // r14
unsigned __int8 v3; // bl
unsigned int v4; // eax
char v5; // al

v0 = txtGoKey(2LL, "PARKING");
v1 = txtGoKey(0LL, "Mainmenu");
v2 = (unsigned __int16 *)dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v3 = 0;
do
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v3 = Menu(v1, SceneArgs, v3, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v3 == 2 )
{
while ( 1 )
{
v5 = Bubble(v0, 0LL, 0LL, 0LL);
if ( !v5 )
{
tcBuyCar();
AddVTime(9LL);
goto LABEL_7;
}
if ( v5 != 1 )
goto LABEL_7;
v4 = tcChooseCar(27LL);
if ( !v4 )
break;
tcSellCar(v4);
AddVTime(11LL);
}
Say(2LL, 0LL, *v2, "SELL_HERE");
LABEL_7:
ShowTime(0LL);
}
else
{
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL << v3);
inpTurnESC(1LL);
}
}
while ( !*((_DWORD *)&SceneArgs + 1) );
RemoveList(v0);
RemoveList(v1);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneParking(void)
{
    LIST *bubble = txtGoKey(2U, "PARKING");
    LIST *menu = txtGoKey(0U, "Mainmenu");
    ubyte activ = 0, choice = 0;
    U32 carID;
    Person marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), 0L, 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 if ((1L << activ) == (1<<2)) {
     choice = 0;
     while (choice != 2) {
  choice = Bubble(bubble, 0, 0L, 0L);
  switch (choice) {
  case 0:
      tcBuyCar();
      AddVTime(9);
      choice = 2;
      break;
  case 1:
      if ((carID = tcChooseCar(27))) {
   tcSellCar(carID);
   AddVTime(11);
      } else {
   Say(2U, 0, marc->PictID, "SELL_HERE");
   choice = 2;
      }
      break;
  default:
      choice = 2;
      break;
  }
     }
     ShowTime(0);
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(1L << activ);
     inpTurnESC(1);
 }
    }
    RemoveList(bubble);
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneParking()
{
    struct List *bubble = txtGoKey(2U, "PARKING");
    struct List *menu = txtGoKey(0U, "Mainmenu");
    unsigned char activ = 0; unsigned char choice = 0;
    unsigned int carID;
    struct _Person *marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), 0L, 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 if ((1L << activ) == (1<<2)) {
     choice = 0;
     while (choice != 2) {
  choice = Bubble(bubble, 0, 0L, 0L);
  switch (choice) {
  case 0:
      tcBuyCar();
      AddVTime(9);
      choice = 2;
      break;
  case 1:
      if ((carID = tcChooseCar(27))) {
   tcSellCar(carID);
   AddVTime(11);
      } else {
   Say(2U, 0, marc->PictID, "SELL_HERE");
   choice = 2;
      }
      break;
  default:
      choice = 2;
      break;
  }
     }
     ShowTime(0);
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(1L << activ);
     inpTurnESC(1);
 }
    }
    RemoveList(bubble);
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

variable_types:
choice
unsigned char

variable_types:
carID
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; } *

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


DoneGarage

decompiled_code:
__int64 DoneGarage()
{
__int64 v0; // rbp
unsigned __int16 *v1; // r12
unsigned __int8 v2; // bl
unsigned int v3; // eax

v0 = txtGoKey(0LL, "Mainmenu");
v1 = (unsigned __int16 *)dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v2 = 0;
do
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v2 = Menu(v0, SceneArgs, v2, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v2 == 2 )
{
v3 = tcChooseCar(26LL);
if ( v3 )
{
tcCarInGarage(v3);
AddVTime(9LL);
ShowTime(0LL);
}
else
{
Say(2LL, 0LL, *v1, "REPAIR_HERE");
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL);
inpTurnESC(1LL);
}
}
else
{
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v2));
inpTurnESC(1LL);
}
}
while ( !*((_DWORD *)&SceneArgs + 1) );
RemoveList(v0);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rbp
unsigned __int16 *v1; // r12
unsigned __int8 v2; // bl
unsigned int v3; // eax

v0 = txtGoKey(0LL, "Mainmenu");
v1 = (unsigned __int16 *)dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v2 = 0;
do
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v2 = Menu(v0, SceneArgs, v2, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v2 == 2 )
{
v3 = tcChooseCar(26LL);
if ( v3 )
{
tcCarInGarage(v3);
AddVTime(9LL);
ShowTime(0LL);
}
else
{
Say(2LL, 0LL, *v1, "REPAIR_HERE");
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL);
inpTurnESC(1LL);
}
}
else
{
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v2));
inpTurnESC(1LL);
}
}
while ( !*((_DWORD *)&SceneArgs + 1) );
RemoveList(v0);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneGarage(void)
{
    LIST *menu = txtGoKey(0U, "Mainmenu");
    ubyte activ = 0;
    U32 choice, carID;
    Person marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (U32) 1L << (activ);
 if (choice == (1<<2)) {
     if ((carID = tcChooseCar(26))) {
  tcCarInGarage(carID);
  AddVTime(9);
  ShowTime(0);
     } else {
  Say(2U, 0, marc->PictID, "REPAIR_HERE");
  inpTurnESC(0);
  SceneArgs.ReturnValue = StdHandle((1));
  inpTurnESC(1);
     }
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(choice);
     inpTurnESC(1);
 }
    }
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneGarage()
{
    struct List *menu = txtGoKey(0U, "Mainmenu");
    unsigned char activ = 0;
    unsigned int choice; unsigned int carID;
    struct _Person *marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (unsigned int) 1L << (activ);
 if (choice == (1<<2)) {
     if ((carID = tcChooseCar(26))) {
  tcCarInGarage(carID);
  AddVTime(9);
  ShowTime(0);
     } else {
  Say(2U, 0, marc->PictID, "REPAIR_HERE");
  inpTurnESC(0);
  SceneArgs.ReturnValue = StdHandle((1));
  inpTurnESC(1);
     }
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(choice);
     inpTurnESC(1);
 }
    }
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

user_defined_types: 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 }


tcInitFahndung

decompiled_code:
__int64 tcInitFahndung()
{
unsigned int v0; // eax
__int64 v1; // rbx
__int64 result; // rax

v0 = getKey(1LL);
v1 = dbGetObject(v0);
result = tcMattGoesTo(59LL);
++*(_BYTE *)(v1 + 12);
return result;
}

canonical_decompiled_code:
__int64 func6()
{
unsigned int v0; // eax
__int64 v1; // rbx
__int64 result; // rax

v0 = getKey(1LL);
v1 = dbGetObject(v0);
result = tcMattGoesTo(59LL);
++*(_BYTE *)(v1 + 12);
return result;
}

original_code:
void tcInitFahndung(void)
{
    Player player = dbGetObject(getKey(_Player_Player_1));
    tcMattGoesTo(59);
    player->NrOfBurglaries++;
}

canonical_original_code:
void tcInitFahndung()
{
    struct _Player *player = dbGetObject(getKey(_Player_Player_1));
    tcMattGoesTo(59);
    player->NrOfBurglaries++;
}

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


tcDoneFahndung

decompiled_code:
__int64 tcDoneFahndung()
{
__int64 v1; // rdi

if ( (unsigned int)tcStartEvidence() )
{
tcDonePrison();
*((_DWORD *)&SceneArgs + 1) = 45350912;
}
else
{
v1 = (unsigned int)getKey(1LL);
if ( *(_BYTE *)(dbGetObject(v1) + 12) == 3 )
*((_DWORD *)&SceneArgs + 1) = 21495808;
else
*((_DWORD *)&SceneArgs + 1) = 0x200000;
}
if ( (unsigned int)tcIsDeadlock() )
*((_DWORD *)&SceneArgs + 1) = 45350912;
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v1; // rdi

if ( (unsigned int)tcStartEvidence() )
{
tcDonePrison();
*((_DWORD *)&SceneArgs + 1) = 45350912;
}
else
{
v1 = (unsigned int)getKey(1LL);
if ( *(_BYTE *)(dbGetObject(v1) + 12) == 3 )
*((_DWORD *)&SceneArgs + 1) = 21495808;
else
*((_DWORD *)&SceneArgs + 1) = 0x200000;
}
if ( (unsigned int)tcIsDeadlock() )
*((_DWORD *)&SceneArgs + 1) = 45350912;
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void tcDoneFahndung(void)
{
    if (tcStartEvidence()) {
 tcDonePrison();
 SceneArgs.ReturnValue = 45350912L;
    } else {
 switch (((Player) (dbGetObject(getKey(_Player_Player_1))))->NrOfBurglaries) {
 case 3:
     SceneArgs.ReturnValue = 21495808L;
     break;
 default:
     SceneArgs.ReturnValue = 2097152L;
     break;
 }
    }
    if (tcIsDeadlock())
 SceneArgs.ReturnValue = 45350912L;
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void tcDoneFahndung()
{
    if (tcStartEvidence()) {
 tcDonePrison();
 SceneArgs.ReturnValue = 45350912L;
    } else {
 switch (((Player) (dbGetObject(getKey(_Player_Player_1))))->NrOfBurglaries) {
 case 3:
     SceneArgs.ReturnValue = 21495808L;
     break;
 default:
     SceneArgs.ReturnValue = 2097152L;
     break;
 }
    }
    if (tcIsDeadlock())
 SceneArgs.ReturnValue = 45350912L;
    gfxChangeColors(l_gc, 5L, 4, 0L);
}


DoneHotelRoom

decompiled_code:
__int64 DoneHotelRoom()
{
tcCheckForBones();
if ( setup[1] )
tcCheckForDowning();
return StdDone();
}

canonical_decompiled_code:
__int64 func8()
{
tcCheckForBones();
if ( setup[1] )
tcCheckForDowning();
return StdDone();
}

original_code:
void DoneHotelRoom(void)
{
    tcCheckForBones();
    if (setup.Profidisk) {
        tcCheckForDowning();
    }
    StdDone();
}

canonical_original_code:
void DoneHotelRoom()
{
    tcCheckForBones();
    if (setup.Profidisk) {
        tcCheckForDowning();
    }
    StdDone();
}


sndInit

decompiled_code:
__int64 sndInit()
{
currSoundName = 0;
return hscInit();
}

canonical_decompiled_code:
__int64 func0()
{
currSoundName = 0;
return hscInit();
}

original_code:
void sndInit(void)
{
    currSoundName[0] = '\0';
    hscInit();
}

canonical_original_code:
void sndInit()
{
    currSoundName[0] = '\0';
    hscInit();
}


sndDone

decompiled_code:
__int64 sndDone()
{
SDL_LockAudio();
hscDone();
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func1()
{
SDL_LockAudio();
hscDone();
return SDL_UnlockAudio();
}

original_code:
void sndDone(void)
{
    SDL_LockAudio();
    hscDone();
    SDL_UnlockAudio();
}

canonical_original_code:
void sndDone()
{
    SDL_LockAudio();
    hscDone();
    SDL_UnlockAudio();
}


sndPlaySound

decompiled_code:
int __fastcall sndPlaySound(char *src)
{
int result; // eax
_BYTE v2[520]; // [rsp+0h] [rbp-208h] BYREF

result = strcmp(&currSoundName, src);
if ( result )
{
result = (unsigned int)strcpy(&currSoundName, src);
if ( FXBase )
{
dskBuildPathName(0LL, "sounds", src, v2);
SDL_LockAudio();
hscLoad(v2);
result = SDL_UnlockAudio();
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(char *src)
{
int result; // eax
_BYTE v2[520]; // [rsp+0h] [rbp-208h] BYREF

result = strcmp(&currSoundName, src);
if ( result )
{
result = (unsigned int)strcpy(&currSoundName, src);
if ( FXBase )
{
dskBuildPathName(0LL, "sounds", src, v2);
SDL_LockAudio();
hscLoad(v2);
result = SDL_UnlockAudio();
}
}
return result;
}

original_code:
void sndPlaySound(char *name, U32 mode)
{
    char path[512];
    if (strcmp(currSoundName, name) != 0) {
 strcpy(currSoundName, name);
 if (FXBase.us_AudioOk) {
     dskBuildPathName(DISK_CHECK_FILE, "sounds", name, path);
            SDL_LockAudio();
     hscLoad(path);
            SDL_UnlockAudio();
 }
    }
}

canonical_original_code:
void sndPlaySound(char *name, unsigned int mode)
{
    char path[512];
    if (strcmp(currSoundName, name) != 0) {
 strcpy(currSoundName, name);
 if (FXBase.us_AudioOk) {
     dskBuildPathName(DISK_CHECK_FILE, "sounds", name, path);
            SDL_LockAudio();
     hscLoad(path);
            SDL_UnlockAudio();
 }
    }
}

variable_types:
name
char *

variable_types:
mode
unsigned int

variable_types:
path
char [512]


sndGetCurrSoundName

decompiled_code:
char *sndGetCurrSoundName()
{
return &currSoundName;
}

canonical_decompiled_code:
char *func3()
{
return &currSoundName;
}

original_code:
char *sndGetCurrSoundName(void)
{
    return currSoundName;
}

canonical_original_code:
char *sndGetCurrSoundName()
{
    return currSoundName;
}

return_type: char *


sndFading

decompiled_code:
void sndFading()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void sndFading(short int targetVol)
{
    if (FXBase.us_AudioOk) {
    }
}

canonical_original_code:
void sndFading(short targetVol)
{
    if (FXBase.us_AudioOk) {
    }
}

variable_types: targetVol short


sndStopSound

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

if ( FXBase )
{
SDL_LockAudio();
hscReset();
result = SDL_UnlockAudio();
}
return result;
}

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

if ( FXBase )
{
SDL_LockAudio();
hscReset();
result = SDL_UnlockAudio();
}
return result;
}

original_code:
void sndStopSound(U8 dummy)
{
    if (FXBase.us_AudioOk) {
        SDL_LockAudio();
        hscReset();
        SDL_UnlockAudio();
    }
}

canonical_original_code:
void sndStopSound(unsigned char dummy)
{
    if (FXBase.us_AudioOk) {
        SDL_LockAudio();
        hscReset();
        SDL_UnlockAudio();
    }
}

variable_types:
dummy
unsigned char


sndCallBack

decompiled_code:
__int64 __fastcall sndCallBack(__int64 a1, _WORD *a2, unsigned int a3)
{
__int64 result; // rax
unsigned __int64 v5; // rdx
_WORD *v6; // rbx
__int64 v7; // rbp
_WORD *v8; // rbx
float v9; // [rsp+8h] [rbp-30h]
float v10; // [rsp+Ch] [rbp-2Ch]
__int16 v11; // [rsp+1Ch] [rbp-1Ch] BYREF
__int16 v12[13]; // [rsp+1Eh] [rbp-1Ah] BYREF

v9 = (float)setup[1] / 255.0;
v10 = (float)setup[2] / 255.0;
hscMusicPlayer(a3);
result = SDL_memset(a2, 0LL, (int)a3);
v5 = (unsigned __int64)(int)a3 >> 1;
if ( (int)v5 > 0 )
{
v6 = a2;
v7 = (__int64)&a2[(unsigned int)(v5 - 1) + 1];
if ( ((2 * ((_BYTE)v5 - 1) + 2) & 2) == 0 )
goto LABEL_14;
v12[0] = 0;
v11 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v11, 2LL);
result = sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v12, 2LL);
*a2 = (int)(float)((float)((float)((float)v12[0] * v10) + (float)((float)v11 * v9)) + 0.5);
v6 = a2 + 1;
if ( a2 + 1 != (_WORD *)v7 )
{
LABEL_14:
do
{
v12[0] = 0;
v11 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v11, 2LL);
sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v12, 2LL);
*v6 = (int)(float)((float)((float)((float)v12[0] * v10) + (float)((float)v11 * v9)) + 0.5);
v8 = v6 + 1;
v12[0] = 0;
v11 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v11, 2LL);
sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v12, 2LL);
result = (unsigned int)(int)(float)((float)((float)((float)v12[0] * v10) + (float)((float)v11 * v9)) + 0.5);
*v8 = result;
v6 = v8 + 1;
}
while ( v6 != (_WORD *)v7 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _WORD *a2, unsigned int a3)
{
__int64 result; // rax
unsigned __int64 v5; // rdx
_WORD *v6; // rbx
__int64 v7; // rbp
_WORD *v8; // rbx
float v9; // [rsp+8h] [rbp-30h]
float v10; // [rsp+Ch] [rbp-2Ch]
__int16 v11; // [rsp+1Ch] [rbp-1Ch] BYREF
__int16 v12[13]; // [rsp+1Eh] [rbp-1Ah] BYREF

v9 = (float)setup[1] / 255.0;
v10 = (float)setup[2] / 255.0;
hscMusicPlayer(a3);
result = SDL_memset(a2, 0LL, (int)a3);
v5 = (unsigned __int64)(int)a3 >> 1;
if ( (int)v5 > 0 )
{
v6 = a2;
v7 = (__int64)&a2[(unsigned int)(v5 - 1) + 1];
if ( ((2 * ((_BYTE)v5 - 1) + 2) & 2) == 0 )
goto LABEL_14;
v12[0] = 0;
v11 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v11, 2LL);
result = sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v12, 2LL);
*a2 = (int)(float)((float)((float)((float)v12[0] * v10) + (float)((float)v11 * v9)) + 0.5);
v6 = a2 + 1;
if ( a2 + 1 != (_WORD *)v7 )
{
LABEL_14:
do
{
v12[0] = 0;
v11 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v11, 2LL);
sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v12, 2LL);
*v6 = (int)(float)((float)((float)((float)v12[0] * v10) + (float)((float)v11 * v9)) + 0.5);
v8 = v6 + 1;
v12[0] = 0;
v11 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v11, 2LL);
sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v12, 2LL);
result = (unsigned int)(int)(float)((float)((float)((float)v12[0] * v10) + (float)((float)v11 * v9)) + 0.5);
*v8 = result;
v6 = v8 + 1;
}
while ( v6 != (_WORD *)v7 );
}
}
return result;
}

original_code:
static void sndCallBack(void *udata, Uint8 *stream, int len)
{
    S16 *MixStream = (S16 *) stream;
    const float sfxFactor = ((float)setup.SfxVolume) / 255,
     musicFactor = ((float)setup.MusicVolume) / 255;
    int sizeStream, i;
    if (MusicChannelOn) {
 hscMusicPlayer(len);
    }
    SDL_memset(stream, 0, len);
    sizeStream = len / sizeof(S16);
    for (i = 0; i < sizeStream; i++) {
 S16 Sfx, Music;
 Sfx = Music = 0;
 if (SfxChannelOn) {
     sndRemoveBuffer(FXBase.pSfxBuffer, &Sfx, sizeof(Sfx));
 }
 if (MusicChannelOn) {
     sndRemoveBuffer(FXBase.pMusicBuffer, &Music, sizeof(Music));
 }
 MixStream[i] = sfxFactor*Sfx + musicFactor*Music + 0.5f;
    }
}

canonical_original_code:
static void sndCallBack(void *udata, unsigned char *stream, int len)
{
    short *MixStream = (S16 *) stream;
    float sfxFactor = ((float)setup.SfxVolume) / 255; float musicFactor = ((float)setup.MusicVolume) / 255;
    int sizeStream; int i;
    if (MusicChannelOn) {
 hscMusicPlayer(len);
    }
    SDL_memset(stream, 0, len);
    sizeStream = len / sizeof(S16);
    for (i = 0; i < sizeStream; i++) {
 short Sfx; short Music;
 Sfx = Music = 0;
 if (SfxChannelOn) {
     sndRemoveBuffer(FXBase.pSfxBuffer, &Sfx, sizeof(Sfx));
 }
 if (MusicChannelOn) {
     sndRemoveBuffer(FXBase.pMusicBuffer, &Music, sizeof(Music));
 }
 MixStream[i] = sfxFactor*Sfx + musicFactor*Music + 0.5f;
    }
}

variable_types:
udata
void *

variable_types:
stream
unsigned char *

variable_types: len int

variable_types:
MixStream
short *

variable_types: sfxFactor float

variable_types: musicFactor float

variable_types: sizeStream int

variable_types: i int

variable_types: Sfx short

variable_types: Music short


LoadVOC

decompiled_code:
void __fastcall LoadVOC(const char *a1)
{
unsigned __int16 *v1; // rax
unsigned __int16 *v2; // rbp
unsigned int v3; // ebx
__int64 v4; // rcx
int v5; // er14
int v6; // er13
__int64 v7; // r12
unsigned int v8; // er15
char *v9; // rbx
__m128 v10; // xmm3
__m128 v11; // xmm1
__m128 v12; // xmm7
int v13; // er15
unsigned int v14; // er13
_WORD *v15; // r12
unsigned int v16; // er14
__int64 v17; // rax
__m128 v18; // xmm3
float v19; // xmm9_4
__m128 v20; // xmm0
unsigned int v21; // edi
unsigned int v22; // esi
float v23; // xmm2_4
unsigned int v24; // er9
unsigned int v25; // esi
float v26; // xmm10_4
__m128 v27; // xmm7
float v28; // xmm3_4
__m128 v29; // xmm1
unsigned int v30; // er8
unsigned int v31; // esi
float v32; // xmm9_4
__int64 v33; // rax
__m128 v34; // xmm2
float v35; // xmm7_4
__m128 v36; // xmm8
float v37; // [rsp+Ch] [rbp-3Ch]

v1 = (unsigned __int16 *)dskLoad();
if ( v1 )
{
v2 = v1;
if ( memcmp(v1, &magicString, 0x14uLL) )
DebugMsg(0LL, 13LL, "Not a VOC file: %s", a1);
v3 = v2[10];
v4 = *((unsigned __int8 *)v2 + v2[10]);
if ( (_DWORD)v4 != 1 )
DebugMsg(0LL, 13LL, "Unknown VOC block-type: %d", v4);
v5 = *((unsigned __int8 *)v2 + v3 + 1) | (*((unsigned __int8 *)v2 + v3 + 2) << 8) | (*((unsigned __int8 *)v2 + v3 + 3) << 16);
v6 = v5 - 2;
DebugMsg(2LL, 13LL, "block-offset: %d, num-samples: %d", v3, (unsigned int)(v5 - 2));
v7 = 1000000 / (256LL - *((unsigned __int8 *)v2 + v3 + 4));
v8 = *((unsigned __int8 *)v2 + v3 + 5);
DebugMsg(2LL, 13LL, "sample-rate: %d Hz, compression-type: %d", (unsigned int)v7, *((unsigned __int8 *)v2 + v3 + 5));
if ( v8 )
DebugMsg(0LL, 13LL, "Unknown VOC compression-type: %d", v8);
v9 = (char *)v2 + v3 + 6;
v10 = (__m128)(unsigned int)LC7;
v10.m128_f32[0] = (float)(22050.0 / (float)(int)v7) * (float)v6;
v11.m128_f32[0] = v10.m128_f32[0];
if ( COERCE_FLOAT(v10.m128_i32[0] & LC9) < 8388608.0 )
{
v12.m128_f32[0] = (float)(int)v10.m128_f32[0];
v11.m128_i32[0] = _mm_andnot_ps((__m128)(unsigned int)LC9, v10).m128_u32[0] | COERCE_UNSIGNED_INT(
v12.m128_f32[0]
+ COERCE_FLOAT(_mm_cmpgt_ss(
v11,
v12).m128_u32[0] & LC10));
}
v13 = (int)v11.m128_f32[0];
v37 = (float)(int)v7 / (float)((float)(v11.m128_f32[0] * (float)(int)v7) / (float)v6);
v14 = 2 * (int)v11.m128_f32[0];
v15 = malloc(v14);
if ( (int)v11.m128_f32[0] )
{
v16 = v5 - 3;
v17 = 0LL;
if ( (v13 & 1) == 0 )
goto LABEL_36;
v18 = 0LL;
v18.m128_f32[0] = (float)0 * v37;
v19 = v18.m128_f32[0];
if ( COERCE_FLOAT(v18.m128_i32[0] & LC9) < 8388608.0 )
{
v20.m128_f32[0] = (float)(int)v18.m128_f32[0];
LODWORD(v19) = COERCE_UNSIGNED_INT(v20.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v20, v18).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v18).m128_u32[0];
}
v21 = (int)v19;
if ( v16 <= (int)v19 )
v21 = v16;
v22 = v21 + 1;
if ( v16 <= v21 + 1 )
v22 = v16;
v23 = (float)(unsigned __int8)v9[v21];
*v15 = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v22] - v23)
* (float)(v18.m128_f32[0] - v19))
+ v23)
* 255.0)
- 32768.0)
+ 0.5);
v17 = 1LL;
if ( v13 != 1LL )
{
LABEL_36:
do
{
v27 = 0LL;
v27.m128_f32[0] = (float)(int)v17 * v37;
v28 = v27.m128_f32[0];
if ( COERCE_FLOAT(v27.m128_i32[0] & LC9) < 8388608.0 )
{
v29.m128_f32[0] = (float)(int)v27.m128_f32[0];
LODWORD(v28) = COERCE_UNSIGNED_INT(v29.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v29, v27).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v27).m128_u32[0];
}
v30 = (int)v28;
if ( v16 <= (int)v28 )
v30 = v16;
v31 = v30 + 1;
if ( v16 <= v30 + 1 )
v31 = v16;
v32 = (float)(unsigned __int8)v9[v30];
v15[v17] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v31] - v32)
* (float)(v27.m128_f32[0] - v28))
+ v32)
* 255.0)
- 32768.0)
+ 0.5);
v33 = v17 + 1;
v34 = 0LL;
v34.m128_f32[0] = (float)(int)v33 * v37;
v35 = v34.m128_f32[0];
if ( COERCE_FLOAT(v34.m128_i32[0] & LC9) < 8388608.0 )
{
v36.m128_f32[0] = (float)(int)v34.m128_f32[0];
LODWORD(v35) = COERCE_UNSIGNED_INT(v36.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v36, v34).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v34).m128_u32[0];
}
v24 = (int)v35;
if ( v16 <= (int)v35 )
v24 = v16;
v25 = v24 + 1;
if ( v16 <= v24 + 1 )
v25 = v16;
v26 = (float)(unsigned __int8)v9[v24];
v15[v33] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v25] - v26)
* (float)(v34.m128_f32[0] - v35))
+ v26)
* 255.0)
- 32768.0)
+ 0.5);
v17 = v33 + 1;
}
while ( v17 != v13 );
}
}
sndResetBuffer(*((_QWORD *)&FXBase + 1));
sndInsertBuffer(*((_QWORD *)&FXBase + 1), v15, v14);
free(v15);
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func1(const char *a1)
{
unsigned __int16 *v1; // rax
unsigned __int16 *v2; // rbp
unsigned int v3; // ebx
__int64 v4; // rcx
int v5; // er14
int v6; // er13
__int64 v7; // r12
unsigned int v8; // er15
char *v9; // rbx
__m128 v10; // xmm3
__m128 v11; // xmm1
__m128 v12; // xmm7
int v13; // er15
unsigned int v14; // er13
_WORD *v15; // r12
unsigned int v16; // er14
__int64 v17; // rax
__m128 v18; // xmm3
float v19; // xmm9_4
__m128 v20; // xmm0
unsigned int v21; // edi
unsigned int v22; // esi
float v23; // xmm2_4
unsigned int v24; // er9
unsigned int v25; // esi
float v26; // xmm10_4
__m128 v27; // xmm7
float v28; // xmm3_4
__m128 v29; // xmm1
unsigned int v30; // er8
unsigned int v31; // esi
float v32; // xmm9_4
__int64 v33; // rax
__m128 v34; // xmm2
float v35; // xmm7_4
__m128 v36; // xmm8
float v37; // [rsp+Ch] [rbp-3Ch]

v1 = (unsigned __int16 *)dskLoad();
if ( v1 )
{
v2 = v1;
if ( memcmp(v1, &magicString, 0x14uLL) )
DebugMsg(0LL, 13LL, "Not a VOC file: %s", a1);
v3 = v2[10];
v4 = *((unsigned __int8 *)v2 + v2[10]);
if ( (_DWORD)v4 != 1 )
DebugMsg(0LL, 13LL, "Unknown VOC block-type: %d", v4);
v5 = *((unsigned __int8 *)v2 + v3 + 1) | (*((unsigned __int8 *)v2 + v3 + 2) << 8) | (*((unsigned __int8 *)v2 + v3 + 3) << 16);
v6 = v5 - 2;
DebugMsg(2LL, 13LL, "block-offset: %d, num-samples: %d", v3, (unsigned int)(v5 - 2));
v7 = 1000000 / (256LL - *((unsigned __int8 *)v2 + v3 + 4));
v8 = *((unsigned __int8 *)v2 + v3 + 5);
DebugMsg(2LL, 13LL, "sample-rate: %d Hz, compression-type: %d", (unsigned int)v7, *((unsigned __int8 *)v2 + v3 + 5));
if ( v8 )
DebugMsg(0LL, 13LL, "Unknown VOC compression-type: %d", v8);
v9 = (char *)v2 + v3 + 6;
v10 = (__m128)(unsigned int)LC7;
v10.m128_f32[0] = (float)(22050.0 / (float)(int)v7) * (float)v6;
v11.m128_f32[0] = v10.m128_f32[0];
if ( COERCE_FLOAT(v10.m128_i32[0] & LC9) < 8388608.0 )
{
v12.m128_f32[0] = (float)(int)v10.m128_f32[0];
v11.m128_i32[0] = _mm_andnot_ps((__m128)(unsigned int)LC9, v10).m128_u32[0] | COERCE_UNSIGNED_INT(
v12.m128_f32[0]
+ COERCE_FLOAT(_mm_cmpgt_ss(
v11,
v12).m128_u32[0] & LC10));
}
v13 = (int)v11.m128_f32[0];
v37 = (float)(int)v7 / (float)((float)(v11.m128_f32[0] * (float)(int)v7) / (float)v6);
v14 = 2 * (int)v11.m128_f32[0];
v15 = malloc(v14);
if ( (int)v11.m128_f32[0] )
{
v16 = v5 - 3;
v17 = 0LL;
if ( (v13 & 1) == 0 )
goto LABEL_36;
v18 = 0LL;
v18.m128_f32[0] = (float)0 * v37;
v19 = v18.m128_f32[0];
if ( COERCE_FLOAT(v18.m128_i32[0] & LC9) < 8388608.0 )
{
v20.m128_f32[0] = (float)(int)v18.m128_f32[0];
LODWORD(v19) = COERCE_UNSIGNED_INT(v20.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v20, v18).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v18).m128_u32[0];
}
v21 = (int)v19;
if ( v16 <= (int)v19 )
v21 = v16;
v22 = v21 + 1;
if ( v16 <= v21 + 1 )
v22 = v16;
v23 = (float)(unsigned __int8)v9[v21];
*v15 = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v22] - v23)
* (float)(v18.m128_f32[0] - v19))
+ v23)
* 255.0)
- 32768.0)
+ 0.5);
v17 = 1LL;
if ( v13 != 1LL )
{
LABEL_36:
do
{
v27 = 0LL;
v27.m128_f32[0] = (float)(int)v17 * v37;
v28 = v27.m128_f32[0];
if ( COERCE_FLOAT(v27.m128_i32[0] & LC9) < 8388608.0 )
{
v29.m128_f32[0] = (float)(int)v27.m128_f32[0];
LODWORD(v28) = COERCE_UNSIGNED_INT(v29.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v29, v27).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v27).m128_u32[0];
}
v30 = (int)v28;
if ( v16 <= (int)v28 )
v30 = v16;
v31 = v30 + 1;
if ( v16 <= v30 + 1 )
v31 = v16;
v32 = (float)(unsigned __int8)v9[v30];
v15[v17] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v31] - v32)
* (float)(v27.m128_f32[0] - v28))
+ v32)
* 255.0)
- 32768.0)
+ 0.5);
v33 = v17 + 1;
v34 = 0LL;
v34.m128_f32[0] = (float)(int)v33 * v37;
v35 = v34.m128_f32[0];
if ( COERCE_FLOAT(v34.m128_i32[0] & LC9) < 8388608.0 )
{
v36.m128_f32[0] = (float)(int)v34.m128_f32[0];
LODWORD(v35) = COERCE_UNSIGNED_INT(v36.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v36, v34).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v34).m128_u32[0];
}
v24 = (int)v35;
if ( v16 <= (int)v35 )
v24 = v16;
v25 = v24 + 1;
if ( v16 <= v24 + 1 )
v25 = v16;
v26 = (float)(unsigned __int8)v9[v24];
v15[v33] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v25] - v26)
* (float)(v34.m128_f32[0] - v35))
+ v26)
* 255.0)
- 32768.0)
+ 0.5);
v17 = v33 + 1;
}
while ( v17 != v13 );
}
}
sndResetBuffer(*((_QWORD *)&FXBase + 1));
sndInsertBuffer(*((_QWORD *)&FXBase + 1), v15, v14);
free(v15);
free(v2);
}
}

original_code:
static void LoadVOC(const char *fileName)
{
    U8 *pSoundFile, *pRawSound;
    S16 *pResampledSound;
    unsigned blockOffset, blockType, numSamples;
    U8 SR;
    unsigned sampleRate, compressionType;
    if (!(pSoundFile = dskLoad(fileName))) {
 return;
    }
    if (memcmp(pSoundFile, magicString, strlen(magicString)) != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND, "Not a VOC file: %s",
   fileName);
    }
    blockOffset = (pSoundFile[0x14])
  | (pSoundFile[0x15] << 8);
    if ((blockType = pSoundFile[blockOffset]) != 1) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC block-type: %d",
   blockType);
    }
    numSamples = (pSoundFile[blockOffset + 0x3] << 16)
        | (pSoundFile[blockOffset + 0x2] << 8)
        | (pSoundFile[blockOffset + 0x1]);
    numSamples -= 2;
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "block-offset: %d, num-samples: %d",
      blockOffset, numSamples);
    SR = pSoundFile[blockOffset + 0x4];
    sampleRate = 1000000L / (256L - SR);
    compressionType = pSoundFile[blockOffset + 0x5];
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "sample-rate: %d Hz, compression-type: %d",
      sampleRate, compressionType);
    if (compressionType != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC compression-type: %d",
   compressionType);
    }
    pRawSound = &pSoundFile[blockOffset + 0x6];
    {
 float resampleRate, resampleRatio, numResamples;
 unsigned i, nResamples, sizeResamples;
 resampleRate = 22050;
 resampleRatio = resampleRate / sampleRate;
 numResamples = ceil(resampleRatio * numSamples);
 nResamples = numResamples;
 resampleRate = numResamples * sampleRate / numSamples;
 resampleRatio = (float) sampleRate / resampleRate;
 sizeResamples = nResamples * sizeof(*pResampledSound);
 pResampledSound = malloc(sizeResamples);
 for (i = 0; i < nResamples; i++) {
     float middleT, leftT;
     float middleS, leftS, rightS;
     unsigned left, right;
     middleT = resampleRatio * i;
     leftT = floor(middleT);
     left = leftT;
     left = ((left) < (0) ? (0) : (left) > (numSamples - 1) ? (numSamples - 1) : (left));
     right = left + 1;
     right = ((right) < (0) ? (0) : (right) > (numSamples - 1) ? (numSamples - 1) : (right));
     leftS = pRawSound[left];
     rightS = pRawSound[right];
     middleS = (rightS - leftS) * (middleT - leftT) + leftS;
     middleS = middleS * 255.0f - 32768.0f;
     pResampledSound[i] = (middleS + 0.5f);
 }
 sndResetBuffer(FXBase.pSfxBuffer);
 sndInsertBuffer(FXBase.pSfxBuffer, pResampledSound, sizeResamples);
 free(pResampledSound);
    }
    free(pSoundFile);
}

canonical_original_code:
static void LoadVOC(char *fileName)
{
    unsigned char *pSoundFile; unsigned char *pRawSound;
    short *pResampledSound;
    unsigned int blockOffset; unsigned int blockType; unsigned int numSamples;
    unsigned char SR;
    unsigned int sampleRate; unsigned int compressionType;
    if (!(pSoundFile = dskLoad(fileName))) {
 return;
    }
    if (memcmp(pSoundFile, magicString, strlen(magicString)) != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND, "Not a VOC file: %s",
   fileName);
    }
    blockOffset = (pSoundFile[0x14])
  | (pSoundFile[0x15] << 8);
    if ((blockType = pSoundFile[blockOffset]) != 1) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC block-type: %d",
   blockType);
    }
    numSamples = (pSoundFile[blockOffset + 0x3] << 16)
        | (pSoundFile[blockOffset + 0x2] << 8)
        | (pSoundFile[blockOffset + 0x1]);
    numSamples -= 2;
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "block-offset: %d, num-samples: %d",
      blockOffset, numSamples);
    SR = pSoundFile[blockOffset + 0x4];
    sampleRate = 1000000L / (256L - SR);
    compressionType = pSoundFile[blockOffset + 0x5];
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "sample-rate: %d Hz, compression-type: %d",
      sampleRate, compressionType);
    if (compressionType != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC compression-type: %d",
   compressionType);
    }
    pRawSound = &pSoundFile[blockOffset + 0x6];
    {
 float resampleRate; float resampleRatio; float numResamples;
 unsigned int i; unsigned int nResamples; unsigned int sizeResamples;
 resampleRate = 22050;
 resampleRatio = resampleRate / sampleRate;
 numResamples = ceil(resampleRatio * numSamples);
 nResamples = numResamples;
 resampleRate = numResamples * sampleRate / numSamples;
 resampleRatio = (float) sampleRate / resampleRate;
 sizeResamples = nResamples * sizeof(*pResampledSound);
 pResampledSound = malloc(sizeResamples);
 for (i = 0; i < nResamples; i++) {
     float middleT; float leftT;
     float middleS; float leftS; float rightS;
     unsigned int left; unsigned int right;
     middleT = resampleRatio * i;
     leftT = floor(middleT);
     left = leftT;
     left = ((left) < (0) ? (0) : (left) > (numSamples - 1) ? (numSamples - 1) : (left));
     right = left + 1;
     right = ((right) < (0) ? (0) : (right) > (numSamples - 1) ? (numSamples - 1) : (right));
     leftS = pRawSound[left];
     rightS = pRawSound[right];
     middleS = (rightS - leftS) * (middleT - leftT) + leftS;
     middleS = middleS * 255.0f - 32768.0f;
     pResampledSound[i] = (middleS + 0.5f);
 }
 sndResetBuffer(FXBase.pSfxBuffer);
 sndInsertBuffer(FXBase.pSfxBuffer, pResampledSound, sizeResamples);
 free(pResampledSound);
    }
    free(pSoundFile);
}

variable_types:
fileName
char *

variable_types:
pSoundFile
unsigned char *

variable_types:
pRawSound
unsigned char *

variable_types:
pResampledSound
short *

variable_types:
blockOffset
unsigned int

variable_types:
blockType
unsigned int

variable_types:
numSamples
unsigned int

variable_types:
SR
unsigned char

variable_types:
sampleRate
unsigned int

variable_types:
compressionType
unsigned int

variable_types: resampleRate float

variable_types: resampleRatio float

variable_types: numResamples float

variable_types:
i
unsigned int

variable_types:
nResamples
unsigned int

variable_types:
sizeResamples
unsigned int

variable_types: middleT float

variable_types: leftT float

variable_types: middleS float

variable_types: leftS float

variable_types: rightS float

variable_types:
left
unsigned int

variable_types:
right
unsigned int


InitAudio

decompiled_code:
__int64 InitAudio()
{
__int64 result; // rax
const char *v1; // rax
const char *v2; // rax
int v3; // [rsp+0h] [rbp-28h] BYREF
__int16 v4; // [rsp+4h] [rbp-24h]
char v5; // [rsp+6h] [rbp-22h]
__int16 v6; // [rsp+8h] [rbp-20h]
__int64 (__fastcall *v7)(__int64, _WORD *, unsigned int); // [rsp+10h] [rbp-18h]
__int64 v8; // [rsp+18h] [rbp-10h]

if ( (unsigned int)SDL_InitSubSystem(16LL) )
{
v1 = (const char *)SDL_GetError();
result = DebugMsg(1LL, 13LL, "SDL_InitSubSystem: %s", v1);
FXBase = 0;
}
else
{
FXBase = 1;
v3 = 22050;
v4 = -32752;
v5 = 1;
v6 = 1024;
v7 = sndCallBack;
v8 = 0LL;
if ( (unsigned int)SDL_OpenAudio(&v3, 0LL) )
{
v2 = (const char *)SDL_GetError();
result = DebugMsg(1LL, 13LL, "SDL_OpenAudio: %s", v2);
FXBase = 0;
}
else
{
*((_QWORD *)&FXBase + 1) = sndCreateBuffer(0x10000LL);
*((_QWORD *)&FXBase + 2) = sndCreateBuffer(0x10000LL);
result = SDL_PauseAudio(0LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
const char *v1; // rax
const char *v2; // rax
int v3; // [rsp+0h] [rbp-28h] BYREF
__int16 v4; // [rsp+4h] [rbp-24h]
char v5; // [rsp+6h] [rbp-22h]
__int16 v6; // [rsp+8h] [rbp-20h]
__int64 (__fastcall *v7)(__int64, _WORD *, unsigned int); // [rsp+10h] [rbp-18h]
__int64 v8; // [rsp+18h] [rbp-10h]

if ( (unsigned int)SDL_InitSubSystem(16LL) )
{
v1 = (const char *)SDL_GetError();
result = DebugMsg(1LL, 13LL, "SDL_InitSubSystem: %s", v1);
FXBase = 0;
}
else
{
FXBase = 1;
v3 = 22050;
v4 = -32752;
v5 = 1;
v6 = 1024;
v7 = sndCallBack;
v8 = 0LL;
if ( (unsigned int)SDL_OpenAudio(&v3, 0LL) )
{
v2 = (const char *)SDL_GetError();
result = DebugMsg(1LL, 13LL, "SDL_OpenAudio: %s", v2);
FXBase = 0;
}
else
{
*((_QWORD *)&FXBase + 1) = sndCreateBuffer(0x10000LL);
*((_QWORD *)&FXBase + 2) = sndCreateBuffer(0x10000LL);
result = SDL_PauseAudio(0LL);
}
}
return result;
}

original_code:
void InitAudio(void)
{
    SDL_AudioSpec spec;
    if (SDL_InitSubSystem(0x00000010u) == 0) {
 FXBase.us_AudioOk = 1;
    } else {
 DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_InitSubSystem: %s", SDL_GetError());
 FXBase.us_AudioOk = 0;
 return;
    }
    spec.freq = 22050;
    spec.format = 0x8010;
    spec.channels = 1;
    spec.samples = 1024;
    spec.callback = sndCallBack;
    spec.userdata = ((void *)0);
    if (SDL_OpenAudio(&spec, ((void *)0))) {
        DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_OpenAudio: %s", SDL_GetError());
        FXBase.us_AudioOk = 0;
 return;
    }
    FXBase.pSfxBuffer = sndCreateBuffer(65536);
    FXBase.pMusicBuffer = sndCreateBuffer(65536);
    SDL_PauseAudio(0);
}

canonical_original_code:
void InitAudio()
{
    struct SDL_AudioSpec spec;
    if (SDL_InitSubSystem(0x00000010u) == 0) {
 FXBase.us_AudioOk = 1;
    } else {
 DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_InitSubSystem: %s", SDL_GetError());
 FXBase.us_AudioOk = 0;
 return;
    }
    spec.freq = 22050;
    spec.format = 0x8010;
    spec.channels = 1;
    spec.samples = 1024;
    spec.callback = sndCallBack;
    spec.userdata = ((void *)0);
    if (SDL_OpenAudio(&spec, ((void *)0))) {
        DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_OpenAudio: %s", SDL_GetError());
        FXBase.us_AudioOk = 0;
 return;
    }
    FXBase.pSfxBuffer = sndCreateBuffer(65536);
    FXBase.pMusicBuffer = sndCreateBuffer(65536);
    SDL_PauseAudio(0);
}

variable_types: struct SDL_AudioSpec { int freq; unsigned short format; unsigned char channels; unsigned char silence; unsigned short samples; unsigned short padding; unsigned int size; void (*callback)(void *userdata, unsigned char *stream, int len); void *userdata; }


RemoveAudio

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

SDL_CloseAudio();
result = SDL_WasInit(16LL);
if ( (_DWORD)result )
result = SDL_QuitSubSystem(16LL);
FXBase = 0;
return result;
}

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

SDL_CloseAudio();
result = SDL_WasInit(16LL);
if ( (_DWORD)result )
result = SDL_QuitSubSystem(16LL);
FXBase = 0;
return result;
}

original_code:
void RemoveAudio(void)
{
    SDL_CloseAudio();
    if (SDL_WasInit(0x00000010u) != 0) {
        SDL_QuitSubSystem(0x00000010u);
    }
    FXBase.us_AudioOk = 0;
}

canonical_original_code:
void RemoveAudio()
{
    SDL_CloseAudio();
    if (SDL_WasInit(0x00000010u) != 0) {
        SDL_QuitSubSystem(0x00000010u);
    }
    FXBase.us_AudioOk = 0;
}


sndInitFX

decompiled_code:
__int64 sndInitFX()
{
SDL_LockAudio();
SfxChannelOn = 0;
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func4()
{
SDL_LockAudio();
SfxChannelOn = 0;
return SDL_UnlockAudio();
}

original_code:
void sndInitFX(void)
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}

canonical_original_code:
void sndInitFX()
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}


sndDoneFX

decompiled_code:
__int64 sndDoneFX()
{
SDL_LockAudio();
SfxChannelOn = 0;
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func5()
{
SDL_LockAudio();
SfxChannelOn = 0;
return SDL_UnlockAudio();
}

original_code:
void sndDoneFX(void)
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}

canonical_original_code:
void sndDoneFX()
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}


sndPrepareFX

decompiled_code:
void __fastcall sndPrepareFX(__int64 a1)
{
char v1[520]; // [rsp+0h] [rbp-208h] BYREF

sndDoneFX();
if ( FXBase )
{
dskBuildPathName(0LL, "samples", a1, v1);
LoadVOC(v1);
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
char v1[520]; // [rsp+0h] [rbp-208h] BYREF

func5();
if ( FXBase )
{
dskBuildPathName(0LL, "samples", a1, v1);
func1(v1);
}
}

original_code:
void sndPrepareFX(const char *name)
{
    sndDoneFX();
    if (FXBase.us_AudioOk) {
        char fileName[512];
        dskBuildPathName(DISK_CHECK_FILE, "samples", name, fileName);
        LoadVOC(fileName);
    }
}

canonical_original_code:
void sndPrepareFX(char *name)
{
    sndDoneFX();
    if (FXBase.us_AudioOk) {
        char fileName[512];
        dskBuildPathName(DISK_CHECK_FILE, "samples", name, fileName);
        LoadVOC(fileName);
    }
}

variable_types:
name
char *

variable_types:
fileName
char [512]


sndPlayFX

decompiled_code:
__int64 sndPlayFX()
{
SDL_LockAudio();
SfxChannelOn = 1;
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func7()
{
SDL_LockAudio();
SfxChannelOn = 1;
return SDL_UnlockAudio();
}

original_code:
void sndPlayFX(void)
{
    SDL_LockAudio();
    SfxChannelOn = 1;
    SDL_UnlockAudio();
}

canonical_original_code:
void sndPlayFX()
{
    SDL_LockAudio();
    SfxChannelOn = 1;
    SDL_UnlockAudio();
}


InitAnimHandler

decompiled_code:
void InitAnimHandler()
{
Handler = &RunningAnimLine;
RunningAnimLine = 0;
}

canonical_decompiled_code:
void func0()
{
Handler = &RunningAnimLine;
RunningAnimLine = 0;
}

original_code:
void InitAnimHandler(void)
{
    Handler.RunningAnimID = RunningAnimLine;
    Handler.RunningAnimID[0] = '\0';
}

canonical_original_code:
void InitAnimHandler()
{
    Handler.RunningAnimID = RunningAnimLine;
    Handler.RunningAnimID[0] = '\0';
}


SuspendAnim

decompiled_code:
void SuspendAnim()
{
byte_5ED |= 1u;
}

canonical_decompiled_code:
void func1()
{
byte_5ED |= 1u;
}

original_code:
void SuspendAnim(void)
{
    Handler.AnimatorState |= (1<<0);
}

canonical_original_code:
void SuspendAnim()
{
    Handler.AnimatorState |= (1<<0);
}


ContinueAnim

decompiled_code:
void ContinueAnim()
{
byte_5ED &= 0xFEu;
}

canonical_decompiled_code:
void func2()
{
byte_5ED &= 0xFEu;
}

original_code:
void ContinueAnim(void)
{
    Handler.AnimatorState &= (0xff - (1<<0));
}

canonical_original_code:
void ContinueAnim()
{
    Handler.AnimatorState &= (0xff - (1<<0));
}


GetAnim

decompiled_code:
__int64 __fastcall GetAnim(char *src, __int64 a2)
{
char v2; // dl
char *v3; // rax
char v5[264]; // [rsp+0h] [rbp-108h] BYREF

strcpy(v5, src);
v2 = v5[0];
if ( v5[0] )
{
v3 = v5;
do
{
if ( v2 == 44 )
*v3 = 95;
v2 = *++v3;
}
while ( *v3 );
}
return txtGetNthString(8LL, v5, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(char *src, __int64 a2)
{
char v2; // dl
char *v3; // rax
char v5[264]; // [rsp+0h] [rbp-108h] BYREF

strcpy(v5, src);
v2 = v5[0];
if ( v5[0] )
{
v3 = v5;
do
{
if ( v2 == 44 )
*v3 = 95;
v2 = *++v3;
}
while ( *v3 );
}
return txtGetNthString(8LL, v5, 0LL, a2);
}

original_code:
void GetAnim(char *AnimID, char *Dest)
{
    int i;
    char ID[256];
    strcpy(ID, AnimID);
    for (i = 0; ID[i] != '\0'; i++)
 if (ID[i] == ',')
     ID[i] = '_';
    txtGetNthString(8U, ID, 0, Dest);
}

variable_types:
AnimID
char *

variable_types:
Dest
char *

variable_types: i int

variable_types:
ID
char [256]


PrepareAnim

decompiled_code:
__int64 __fastcall PrepareAnim(char *a1)
{
__int64 result; // rax
unsigned __int16 v2; // ax
__int64 v3; // rbx
unsigned __int16 v4; // si
int v5; // ecx
__int64 v6; // rdx
_BYTE v7[264]; // [rsp+0h] [rbp-108h] BYREF

GetAnim(a1, (__int64)v7);
result = txtCountKey(v7);
if ( (unsigned int)result > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v7);
v3 = gfxGetCollection(v2);
word_5D2 = txtGetKeyAsULONG(5LL, v7);
word_5CC = txtGetKeyAsULONG(6LL, v7);
word_5CE = txtGetKeyAsULONG(7LL, v7);
word_5D0 = txtGetKeyAsULONG(8LL, v7);
word_5C8 = txtGetKeyAsULONG(9LL, v7);
word_5CA = txtGetKeyAsULONG(10LL, v7);
v4 = *(_WORD *)(v3 + 64);
v5 = (unsigned __int16)word_5D0 + (unsigned __int16)word_5CC;
v6 = (unsigned int)(((unsigned __int16)word_5D0 + v4) >> 31);
LODWORD(v6) = ((unsigned __int16)word_5D0 + v4) % v5;
word_5D4 = ((unsigned __int16)word_5D0 + v4) / v5;
word_5D6 = v4;
word_5E0 = *(_WORD *)(v3 + 32);
result = gfxCollToMem((unsigned __int16)word_5E0, &AnimRPInMem, v6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
__int64 result; // rax
unsigned __int16 v2; // ax
__int64 v3; // rbx
unsigned __int16 v4; // si
int v5; // ecx
__int64 v6; // rdx
_BYTE v7[264]; // [rsp+0h] [rbp-108h] BYREF

func3(a1, (__int64)v7);
result = txtCountKey(v7);
if ( (unsigned int)result > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v7);
v3 = gfxGetCollection(v2);
word_5D2 = txtGetKeyAsULONG(5LL, v7);
word_5CC = txtGetKeyAsULONG(6LL, v7);
word_5CE = txtGetKeyAsULONG(7LL, v7);
word_5D0 = txtGetKeyAsULONG(8LL, v7);
word_5C8 = txtGetKeyAsULONG(9LL, v7);
word_5CA = txtGetKeyAsULONG(10LL, v7);
v4 = *(_WORD *)(v3 + 64);
v5 = (unsigned __int16)word_5D0 + (unsigned __int16)word_5CC;
v6 = (unsigned int)(((unsigned __int16)word_5D0 + v4) >> 31);
LODWORD(v6) = ((unsigned __int16)word_5D0 + v4) % v5;
word_5D4 = ((unsigned __int16)word_5D0 + v4) / v5;
word_5D6 = v4;
word_5E0 = *(_WORD *)(v3 + 32);
result = gfxCollToMem((unsigned __int16)word_5E0, &AnimRPInMem, v6);
}
return result;
}

original_code:
static void PrepareAnim(char *AnimID)
{
    char pict_list[256];
    struct Collection *coll;
    GetAnim(AnimID, pict_list);
    if ((U32) (txtCountKey(pict_list)) > 3) {
 coll =
     gfxGetCollection(txtGetKeyAsULONG(4, pict_list));
 Handler.frameCount = txtGetKeyAsULONG(5, pict_list);
 Handler.width =
     (U16) txtGetKeyAsULONG(6, pict_list);
 Handler.height =
     (U16) txtGetKeyAsULONG(7, pict_list);
 Handler.offset =
     (U16) txtGetKeyAsULONG(8, pict_list);
 Handler.destX =
     (U16) txtGetKeyAsULONG(9, pict_list);
 Handler.destY =
     (U16) txtGetKeyAsULONG(10, pict_list);
 Handler.pictsPerRow =
     (coll->us_TotalWidth + Handler.offset) / (Handler.width +
            Handler.offset);
 Handler.totalWidth = coll->us_TotalWidth;
 Handler.AnimCollection = coll->us_CollId;
 gfxCollToMem(coll->us_CollId, &AnimRPInMem);
    }
}

canonical_original_code:
static void PrepareAnim(char *AnimID)
{
    char pict_list[256];
    struct Collection *coll;
    GetAnim(AnimID, pict_list);
    if ((U32) (txtCountKey(pict_list)) > 3) {
 coll =
     gfxGetCollection(txtGetKeyAsULONG(4, pict_list));
 Handler.frameCount = txtGetKeyAsULONG(5, pict_list);
 Handler.width =
     (unsigned short) txtGetKeyAsULONG(6, pict_list);
 Handler.height =
     (unsigned short) txtGetKeyAsULONG(7, pict_list);
 Handler.offset =
     (unsigned short) txtGetKeyAsULONG(8, pict_list);
 Handler.destX =
     (unsigned short) txtGetKeyAsULONG(9, pict_list);
 Handler.destY =
     (unsigned short) txtGetKeyAsULONG(10, pict_list);
 Handler.pictsPerRow =
     (coll->us_TotalWidth + Handler.offset) / (Handler.width +
            Handler.offset);
 Handler.totalWidth = coll->us_TotalWidth;
 Handler.AnimCollection = coll->us_CollId;
 gfxCollToMem(coll->us_CollId, &AnimRPInMem);
    }
}

variable_types: struct Collection { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned short us_CollId; char *puch_Filename; struct _MemRastPort { unsigned short w; unsigned short h; unsigned char palette[768]; unsigned char *pixels; unsigned short collId; } *prepared; void *p_ColorTable; unsigned short us_TotalWidth; unsigned short us_TotalHeight; unsigned char uch_ColorRangeStart; unsigned char uch_ColorRangeEnd; } *

user_defined_types: struct Collection { struct Node Link; unsigned short us_CollId; char *puch_Filename; struct _MemRastPort *prepared; void *p_ColorTable; unsigned short us_TotalWidth; unsigned short us_TotalHeight; unsigned char uch_ColorRangeStart; unsigned char uch_ColorRangeEnd; }


StopAnim

decompiled_code:
void StopAnim()
{
unsigned __int16 v0; // ax
__int64 v1; // rax
unsigned __int16 v2; // ax
_BYTE v3[264]; // [rsp-108h] [rbp-108h] BYREF

if ( Handler && *Handler )
{
GetAnim(Handler, (__int64)v3);
v0 = txtGetKeyAsULONG(3LL, v3);
v1 = gfxGetPicture(v0);
if ( v1 )
gfxUnPrepareColl(*(unsigned __int16 *)(v1 + 34));
if ( (unsigned int)txtCountKey(v3) > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v3);
gfxUnPrepareColl(v2);
}
*Handler = 0;
}
}

canonical_decompiled_code:
void func5()
{
unsigned __int16 v0; // ax
__int64 v1; // rax
unsigned __int16 v2; // ax
_BYTE v3[264]; // [rsp-108h] [rbp-108h] BYREF

if ( Handler && *Handler )
{
func3(Handler, (__int64)v3);
v0 = txtGetKeyAsULONG(3LL, v3);
v1 = gfxGetPicture(v0);
if ( v1 )
gfxUnPrepareColl(*(unsigned __int16 *)(v1 + 34));
if ( (unsigned int)txtCountKey(v3) > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v3);
gfxUnPrepareColl(v2);
}
*Handler = 0;
}
}

original_code:
void StopAnim(void)
{
    char pict_list[256];
    struct Picture *pict;
    if (Handler.RunningAnimID) {
 if (Handler.RunningAnimID[0] != '\0') {
     GetAnim(Handler.RunningAnimID, pict_list);
     pict =
  gfxGetPicture((U16)
         txtGetKeyAsULONG((U16) 3,
            pict_list));
     if (pict)
  gfxUnPrepareColl((U16) pict->us_CollId);
     if (txtCountKey(pict_list) > 3)
  gfxUnPrepareColl((U16)
     txtGetKeyAsULONG((U16) 4,
        pict_list));
     Handler.RunningAnimID[0] = '\0';
 }
    }
}

canonical_original_code:
void StopAnim()
{
    char pict_list[256];
    struct Picture *pict;
    if (Handler.RunningAnimID) {
 if (Handler.RunningAnimID[0] != '\0') {
     GetAnim(Handler.RunningAnimID, pict_list);
     pict =
  gfxGetPicture((unsigned short)
         txtGetKeyAsULONG((unsigned short) 3,
            pict_list));
     if (pict)
  gfxUnPrepareColl((unsigned short) pict->us_CollId);
     if (txtCountKey(pict_list) > 3)
  gfxUnPrepareColl((unsigned short)
     txtGetKeyAsULONG((unsigned short) 4,
        pict_list));
     Handler.RunningAnimID[0] = '\0';
 }
    }
}

variable_types: struct Picture { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned short us_PictId; unsigned short us_CollId; unsigned short us_XOffset; unsigned short us_YOffset; unsigned short us_Width; unsigned short us_Height; unsigned short us_DestX; unsigned short us_DestY; } *

user_defined_types: struct Picture { struct Node Link; unsigned short us_PictId; unsigned short us_CollId; unsigned short us_XOffset; unsigned short us_YOffset; unsigned short us_Width; unsigned short us_Height; unsigned short us_DestX; unsigned short us_DestY; }


CloseAnimHandler

decompiled_code:
void CloseAnimHandler()
{
StopAnim();
}

canonical_decompiled_code:
void func6()
{
func5();
}

original_code:
void CloseAnimHandler(void)
{
    StopAnim();
}

canonical_original_code:
void CloseAnimHandler()
{
    StopAnim();
}


PlayAnim

decompiled_code:
void __fastcall PlayAnim(char *src, __int16 a2, unsigned int a3)
{
unsigned __int16 v4; // ax
__int16 v5; // ax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

GetAnim(src, (__int64)v6);
if ( v6[0] )
{
StopAnim();
PrepareAnim(src);
if ( (a3 & 0x40) == 0 )
{
if ( !a3 )
a3 = txtGetKeyAsULONG(1LL, v6);
v4 = txtGetKeyAsULONG(3LL, v6);
if ( v4 )
gfxShow(v4, a3, 2LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}
if ( (unsigned int)txtCountKey(v6) > 3 )
{
v5 = txtGetKeyAsULONG(2LL, v6);
byte_5EC = 1;
word_5DA = v5;
word_5DC = a2;
word_5E8 = 0;
word_5EA = 1;
word_5DE = 0;
dword_5E4 = 1;
strcpy(Handler, src);
ContinueAnim();
}
else
{
*Handler = 0;
}
}
else
{
gfxClearArea(l_gc);
}
}

canonical_decompiled_code:
void __fastcall func7(char *src, __int16 a2, unsigned int a3)
{
unsigned __int16 v4; // ax
__int16 v5; // ax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

func3(src, (__int64)v6);
if ( v6[0] )
{
func5();
func4(src);
if ( (a3 & 0x40) == 0 )
{
if ( !a3 )
a3 = txtGetKeyAsULONG(1LL, v6);
v4 = txtGetKeyAsULONG(3LL, v6);
if ( v4 )
gfxShow(v4, a3, 2LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}
if ( (unsigned int)txtCountKey(v6) > 3 )
{
v5 = txtGetKeyAsULONG(2LL, v6);
byte_5EC = 1;
word_5DA = v5;
word_5DC = a2;
word_5E8 = 0;
word_5EA = 1;
word_5DE = 0;
dword_5E4 = 1;
strcpy(Handler, src);
func2();
}
else
{
*Handler = 0;
}
}
else
{
gfxClearArea(l_gc);
}
}

original_code:
void PlayAnim(char *AnimID, U16 how_often, U32 mode)
{
    char pict_list[256];
    U16 pict_id = 0, rate;
    GetAnim(AnimID, pict_list);
    if (pict_list[0] == '\0')
 gfxClearArea(l_gc);
    else {
 StopAnim();
 PrepareAnim(AnimID);
 if (!(mode & 64)) {
     if (!mode)
  mode = (U32) txtGetKeyAsULONG((U16) 1, pict_list);
     pict_id = (U16) txtGetKeyAsULONG((U16) 3, pict_list);
 }
 if (pict_id)
     gfxShow(pict_id, mode, 2, -1L, -1L);
 if ((U32) (txtCountKey(pict_list)) > 3) {
     rate = (U16) txtGetKeyAsULONG((U16) 2, pict_list);
     Handler.PlayMode = 1;
     Handler.PictureRate = rate;
     Handler.Repeatation = how_often;
     Handler.CurrPictNr = 0;
     Handler.Direction = 1;
     Handler.RepeatationCount = 0;
     Handler.WaitCounter = 1;
     strcpy(Handler.RunningAnimID, AnimID);
     ContinueAnim();
 } else
     Handler.RunningAnimID[0] = '\0';
    }
}

canonical_original_code:
void PlayAnim(char *AnimID, unsigned short how_often, unsigned int mode)
{
    char pict_list[256];
    unsigned short pict_id = 0; unsigned short rate;
    GetAnim(AnimID, pict_list);
    if (pict_list[0] == '\0')
 gfxClearArea(l_gc);
    else {
 StopAnim();
 PrepareAnim(AnimID);
 if (!(mode & 64)) {
     if (!mode)
  mode = (unsigned int) txtGetKeyAsULONG((unsigned short) 1, pict_list);
     pict_id = (unsigned short) txtGetKeyAsULONG((unsigned short) 3, pict_list);
 }
 if (pict_id)
     gfxShow(pict_id, mode, 2, -1L, -1L);
 if ((U32) (txtCountKey(pict_list)) > 3) {
     rate = (unsigned short) txtGetKeyAsULONG((unsigned short) 2, pict_list);
     Handler.PlayMode = 1;
     Handler.PictureRate = rate;
     Handler.Repeatation = how_often;
     Handler.CurrPictNr = 0;
     Handler.Direction = 1;
     Handler.RepeatationCount = 0;
     Handler.WaitCounter = 1;
     strcpy(Handler.RunningAnimID, AnimID);
     ContinueAnim();
 } else
     Handler.RunningAnimID[0] = '\0';
    }
}

variable_types:
mode
unsigned int

variable_types:
rate
unsigned short


animator

decompiled_code:
void animator()
{
unsigned __int16 v0; // bx
unsigned __int16 v1; // bp
int v2; // er12
unsigned int v3; // er13
unsigned __int16 v4; // r12

if ( (byte_5ED & 1) == 0 )
{
if ( Handler )
{
if ( *Handler )
{
if ( (unsigned __int16)word_5DE <= (unsigned __int16)word_5DC )
{
v0 = word_5C8;
v1 = word_5CA;
if ( !--dword_5E4 )
{
v2 = (unsigned __int16)word_5DA;
dword_5E4 = CalcRandomNr(0LL, 3LL) + v2;
if ( !word_5E8 )
{
++word_5DE;
word_5EA = 1;
}
if ( word_5E8 == word_5D2 )
{
++word_5DE;
if ( (byte_5EC & 1) != 0 )
word_5E8 = 0;
else
word_5EA = -1;
}
if ( (unsigned __int16)word_5DE <= (unsigned __int16)word_5DC )
{
v3 = (unsigned __int16)word_5E8 * ((unsigned __int16)word_5D0 + (unsigned __int16)word_5CC)
% (unsigned __int16)word_5D6;
v4 = word_5D4;
if ( word_5D4 )
v4 = word_5CE * ((unsigned __int16)word_5E8 / (unsigned __int16)word_5D4);
inpMousePtrOff();
gfxBlit(l_gc, &AnimRPInMem, v3, v4, v0, v1, (unsigned __int16)word_5CC, (unsigned __int16)word_5CE, 0LL);
inpMousePtrOn();
}
word_5E8 += word_5EA;
}
}
}
}
}
}

canonical_decompiled_code:
void func8()
{
unsigned __int16 v0; // bx
unsigned __int16 v1; // bp
int v2; // er12
unsigned int v3; // er13
unsigned __int16 v4; // r12

if ( (byte_5ED & 1) == 0 )
{
if ( Handler )
{
if ( *Handler )
{
if ( (unsigned __int16)word_5DE <= (unsigned __int16)word_5DC )
{
v0 = word_5C8;
v1 = word_5CA;
if ( !--dword_5E4 )
{
v2 = (unsigned __int16)word_5DA;
dword_5E4 = CalcRandomNr(0LL, 3LL) + v2;
if ( !word_5E8 )
{
++word_5DE;
word_5EA = 1;
}
if ( word_5E8 == word_5D2 )
{
++word_5DE;
if ( (byte_5EC & 1) != 0 )
word_5E8 = 0;
else
word_5EA = -1;
}
if ( (unsigned __int16)word_5DE <= (unsigned __int16)word_5DC )
{
v3 = (unsigned __int16)word_5E8 * ((unsigned __int16)word_5D0 + (unsigned __int16)word_5CC)
% (unsigned __int16)word_5D6;
v4 = word_5D4;
if ( word_5D4 )
v4 = word_5CE * ((unsigned __int16)word_5E8 / (unsigned __int16)word_5D4);
inpMousePtrOff();
gfxBlit(l_gc, &AnimRPInMem, v3, v4, v0, v1, (unsigned __int16)word_5CC, (unsigned __int16)word_5CE, 0LL);
inpMousePtrOn();
}
word_5E8 += word_5EA;
}
}
}
}
}
}

original_code:
void animator(void)
{
    U16 destX = Handler.destX;
    U16 destY = Handler.destY;
    if (!(Handler.AnimatorState & (1<<0))) {
 if (Handler.RunningAnimID && Handler.RunningAnimID[0] != '\0') {
     if (Handler.RepeatationCount <= Handler.Repeatation) {
  if ((--Handler.WaitCounter) == 0) {
      Handler.WaitCounter =
   Handler.PictureRate + CalcRandomNr(0, 3);
      if (Handler.CurrPictNr == 0) {
   Handler.RepeatationCount++;
   Handler.Direction = 1;
      }
      if (Handler.CurrPictNr == Handler.frameCount) {
   Handler.RepeatationCount++;
   if (Handler.PlayMode & 1)
       Handler.CurrPictNr = 0;
   else
       Handler.Direction = -1;
      }
      if (Handler.RepeatationCount <= Handler.Repeatation) {
   U16 sourceX;
   U16 sourceY;
                        sourceX =
       ((Handler.width +
         Handler.offset) * Handler.CurrPictNr) %
       (Handler.totalWidth);
                        if (Handler.pictsPerRow != 0)
                            sourceY =
       (Handler.CurrPictNr / Handler.pictsPerRow) *
       (Handler.height + 0);
                        else
                            sourceY = 0;
   inpMousePtrOff();
                        gfxBlit(l_gc, &AnimRPInMem, sourceX, sourceY,
                                destX, destY, Handler.width, Handler.height,
                                0);
   inpMousePtrOn();
      }
      Handler.CurrPictNr = Handler.CurrPictNr + Handler.Direction;
  }
     }
 }
    }
}

canonical_original_code:
void animator()
{
    unsigned short destX = Handler.destX;
    unsigned short destY = Handler.destY;
    if (!(Handler.AnimatorState & (1<<0))) {
 if (Handler.RunningAnimID && Handler.RunningAnimID[0] != '\0') {
     if (Handler.RepeatationCount <= Handler.Repeatation) {
  if ((--Handler.WaitCounter) == 0) {
      Handler.WaitCounter =
   Handler.PictureRate + CalcRandomNr(0, 3);
      if (Handler.CurrPictNr == 0) {
   Handler.RepeatationCount++;
   Handler.Direction = 1;
      }
      if (Handler.CurrPictNr == Handler.frameCount) {
   Handler.RepeatationCount++;
   if (Handler.PlayMode & 1)
       Handler.CurrPictNr = 0;
   else
       Handler.Direction = -1;
      }
      if (Handler.RepeatationCount <= Handler.Repeatation) {
   unsigned short sourceX;
   unsigned short sourceY;
                        sourceX =
       ((Handler.width +
         Handler.offset) * Handler.CurrPictNr) %
       (Handler.totalWidth);
                        if (Handler.pictsPerRow != 0)
                            sourceY =
       (Handler.CurrPictNr / Handler.pictsPerRow) *
       (Handler.height + 0);
                        else
                            sourceY = 0;
   inpMousePtrOff();
                        gfxBlit(l_gc, &AnimRPInMem, sourceX, sourceY,
                                destX, destY, Handler.width, Handler.height,
                                0);
   inpMousePtrOn();
      }
      Handler.CurrPictNr = Handler.CurrPictNr + Handler.Direction;
  }
     }
 }
    }
}

variable_types:
destX
unsigned short

variable_types:
destY
unsigned short

variable_types:
sourceX
unsigned short

variable_types:
sourceY
unsigned short


plPrintInfo

decompiled_code:
__int64 __fastcall plPrintInfo(__int64 a1)
{
char v2[88]; // [rsp+0h] [rbp-58h] BYREF

strcpy(v2, (const char *)(a1 + 1));
gfxSetRect(2LL, 320LL);
gfxSetPens(m_gc, 249LL, 255LL, 255LL);
return gfxPrint(m_gc, v2, 12LL, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
char v2[88]; // [rsp+0h] [rbp-58h] BYREF

strcpy(v2, (const char *)(a1 + 1));
gfxSetRect(2LL, 320LL);
gfxSetPens(m_gc, 249LL, 255LL, 255LL);
return gfxPrint(m_gc, v2, 12LL, 1LL);
}

original_code:
void plPrintInfo(char *person)
{
    char info[80];
    sprintf(info, "%s", &person[1]);
    gfxSetRect(2, 320);
    gfxSetPens(m_gc, 249, ((ubyte)255), ((ubyte)255));
    gfxPrint(m_gc, info, 12, (1));
}

canonical_original_code:
void plPrintInfo(char *person)
{
    char info[80];
    sprintf(info, "%s", &person[1]);
    gfxSetRect(2, 320);
    gfxSetPens(m_gc, 249, ((unsigned char)255), ((unsigned char)255));
    gfxPrint(m_gc, info, 12, (1));
}

variable_types:
person
char *

variable_types:
info
char [80]


plMessage

decompiled_code:
__int64 __fastcall plMessage(__int64 a1, char a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = txtGoKey(11LL, a1);
if ( (a2 & 1) != 0 )
ShowMenuBackground();
if ( v2 )
plPrintInfo(*(_QWORD *)(*(_QWORD *)v2 + 16LL));
result = RemoveList(v2);
if ( (a2 & 2) != 0 )
{
inpSetWaitTicks(140LL);
inpWaitFor(2080LL);
result = inpSetWaitTicks(0LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = txtGoKey(11LL, a1);
if ( (a2 & 1) != 0 )
ShowMenuBackground();
if ( v2 )
func0(*(_QWORD *)(*(_QWORD *)v2 + 16LL));
result = RemoveList(v2);
if ( (a2 & 2) != 0 )
{
inpSetWaitTicks(140LL);
inpWaitFor(2080LL);
result = inpSetWaitTicks(0LL);
}
return result;
}

original_code:
void plMessage(char *msg, ubyte flags)
{
    LIST *m = txtGoKey(11U, msg);
    if (flags & 1)
 ShowMenuBackground();
    if (m)
 plPrintInfo((char *) (((NODE *)(((((NODE *)((&((m))->Head)))->Succ))))->Name));
    RemoveList(m);
    if (flags & 2) {
 inpSetWaitTicks(140L);
 inpWaitFor((1<<5) | (1<<11));
 inpSetWaitTicks(0L);
    }
}

canonical_original_code:
void plMessage(char *msg, unsigned char flags)
{
    struct List *m = txtGoKey(11U, msg);
    if (flags & 1)
 ShowMenuBackground();
    if (m)
 plPrintInfo((char *) (((struct Node *)(((((struct Node *)((&((m))->Head)))->Succ))))->Name));
    RemoveList(m);
    if (flags & 2) {
 inpSetWaitTicks(140L);
 inpWaitFor((1<<5) | (1<<11));
 inpSetWaitTicks(0L);
    }
}

variable_types:
msg
char *

variable_types:
flags
unsigned char

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